Creating the Bridge

From Apache OpenOffice Wiki
Jump to: navigation, search
The interaction of services that are needed to initiate a UNO interprocess bridge. The interfaces have been simplified.

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 It supports the 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 call createBridge() with the name of an already working interprocess bridge, a BridgeExistsException is thrown. When you pass an empty string, you always create a new anonymous bridge, which can never be retrieved by getBridge() and which never throws a BridgeExistsException.
  • 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 the wiki Uno Remote Protocol.
  • 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 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 ); 
The <code>BridgeFactory</code> returns a <idl></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 interface, that adds a 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).
Personal tools
In other languages