Difference between revisions of "Documentation/DevGuide/ProUNO/Creating the Bridge"
OOoWikiBot (Talk | contribs) m (FINAL VERSION FOR L10N) |
|||
Line 11: | Line 11: | ||
The <code>XConnection</code> instance can now be used to establish a UNO interprocess bridge on top of the connection, regardless if the connection was established with a Connector or Acceptor service (or another method). To do this, you must instantiate the service <idl>com.sun.star.bridge.BridgeFactory</idl>. It supports the <idl>com.sun.star.bridge.XBridgeFactory</idl> interface. | The <code>XConnection</code> instance can now be used to establish a UNO interprocess bridge on top of the connection, regardless if the connection was established with a Connector or Acceptor service (or another method). To do this, you must instantiate the service <idl>com.sun.star.bridge.BridgeFactory</idl>. It supports the <idl>com.sun.star.bridge.XBridgeFactory</idl> interface. | ||
− | + | <syntaxhighlight lang="idl"> | |
interface XBridgeFactory: com::sun::star::uno::XInterface | interface XBridgeFactory: com::sun::star::uno::XInterface | ||
{ | { | ||
Line 23: | Line 23: | ||
sequence < XBridge > getExistingBridges( ); | sequence < XBridge > getExistingBridges( ); | ||
}; | }; | ||
− | + | </syntaxhighlight> | |
The <code>BridgeFactory</code> service administrates all UNO interprocess connections. The <code>createBridge()</code> method creates a new bridge: | The <code>BridgeFactory</code> service administrates all UNO interprocess connections. The <code>createBridge()</code> method creates a new bridge: | ||
Line 33: | Line 33: | ||
* The fourth parameter is a UNO object, which supports the <idl>com.sun.star.bridge.XInstanceProvider</idl> interface. This parameter may be a null reference if you do not want to export a local object to the remote process. | * The fourth parameter is a UNO object, which supports the <idl>com.sun.star.bridge.XInstanceProvider</idl> interface. This parameter may be a null reference if you do not want to export a local object to the remote process. | ||
− | + | <syntaxhighlight lang="idl"> | |
interface XInstanceProvider: com::sun::star::uno::XInterface | interface XInstanceProvider: com::sun::star::uno::XInterface | ||
{ | { | ||
Line 48: | Line 48: | ||
string getDescription(); | string getDescription(); | ||
}; | }; | ||
− | + | </syntaxhighlight> | |
The <code>XBridge.getInstance()</code> method retrieves an initial object from the remote counterpart. The local <code>XBridge.getInstance()</code> call arrives in the remote process as an <code>XInstanceProvider.getInstance()</code> call. The object returned can be controlled by the string <code>sInstanceName</code>. It completely depends on the implementation of <code>XInstanceProvider</code>, which object it returns. | The <code>XBridge.getInstance()</code> method retrieves an initial object from the remote counterpart. The local <code>XBridge.getInstance()</code> call arrives in the remote process as an <code>XInstanceProvider.getInstance()</code> call. The object returned can be controlled by the string <code>sInstanceName</code>. It completely depends on the implementation of <code>XInstanceProvider</code>, which object it returns. | ||
Revision as of 11:48, 23 December 2020
The XConnection
instance can now be used to establish a UNO interprocess bridge on top of the connection, regardless if the connection was established with a Connector or Acceptor service (or another method). To do this, you must instantiate the service com.sun.star.bridge.BridgeFactory. It supports the com.sun.star.bridge.XBridgeFactory interface.
interface XBridgeFactory: com::sun::star::uno::XInterface { XBridge createBridge( [in] string sName, [in] string sProtocol , [in] com::sun::star::connection::XConnection aConnection , [in] XInstanceProvider anInstanceProvider ) raises ( BridgeExistsException , com::sun::star::lang::IllegalArgumentException ); XBridge getBridge( [in] string sName ); sequence < XBridge > getExistingBridges( ); };
The BridgeFactory
service administrates all UNO interprocess connections. The createBridge()
method creates a new bridge:
- You can give the bridge a distinct name with the sName argument. Later the bridge can be retrieved by using the
getBridge()
method with this name. This allows two independent code pieces to share the same interprocess bridge. If you callcreateBridge()
with the name of an already working interprocess bridge, aBridgeExistsException
is thrown. When you pass an empty string, you always create a new anonymous bridge, which can never be retrieved bygetBridge()
and which never throws aBridgeExistsException
.
- The second parameter specifies the protocol to be used on the connection. Currently, only the 'urp' protocol is supported. In the UNO URL, this string is separated by two ';'. The urp string may be followed by a comma separated list of name-value pairs describing properties for the bridge protocol. The urp specification can be found on udk.openoffice.org.
- The third parameter is the
XConnection
interface as it was retrieved by Connector/Acceptor service.
- The fourth parameter is a UNO object, which supports the com.sun.star.bridge.XInstanceProvider interface. This parameter may be a null reference if you do not want to export a local object to the remote process.
interface XInstanceProvider: com::sun::star::uno::XInterface { com::sun::star::uno::XInterface getInstance( [in] string sInstanceName ) raises ( com::sun::star::container::NoSuchElementException ); }; </source> The <code>BridgeFactory</code> returns a <idl>com.sun.star.bridge.XBridge</idl> interface. <source lang="idl"> interface XBridge: com::sun::star::uno::XInterface { XInterface getInstance( [in] string sInstanceName ); string getName(); string getDescription(); };
The XBridge.getInstance()
method retrieves an initial object from the remote counterpart. The local XBridge.getInstance()
call arrives in the remote process as an XInstanceProvider.getInstance()
call. The object returned can be controlled by the string sInstanceName
. It completely depends on the implementation of XInstanceProvider
, which object it returns.
The XBridge
interface can be queried for a com.sun.star.lang.XComponent interface, that adds a com.sun.star.lang.XEventListener to the bridge. This listener will be terminated when the underlying connection closes (see above). You can also call dispose()
on the XComponent
interface explicitly, which closes the underlying connection and initiates the bridge shutdown procedure.
Content on this page is licensed under the Public Documentation License (PDL). |