Package com.sun.star.bridge

Examples of com.sun.star.bridge.XBridge


     */
    public void execute(ExecutionContext context) throws Exception {
  XComponent xComponent = null;
  XDesktop xdesktop = null;
  IDossierDAO dossierDAO = null;
  XBridge bridge = null;
  String tempFolder = null;
  ContextInstance contextInstance = null;
  try {
      logger.debug("Start execution");
      contextInstance = context.getContextInstance();
      logger.debug("Context Instance retrived " + contextInstance);
      ProcessInstance processInstance = context.getProcessInstance();
      Long workflowProcessId = new Long(processInstance.getId());
      logger.debug("Workflow process id: " + workflowProcessId);
      String dossierIdStr = (String) contextInstance.getVariable(DossierConstants.DOSSIER_ID);
      logger.debug("Dossier id variable retrived " + dossierIdStr);
      Integer dossierId = new Integer(dossierIdStr);
      BIObject dossier = DAOFactory.getBIObjectDAO().loadBIObjectById(dossierId);
      logger.debug("Dossier retrived " + dossier);
      dossierDAO = DAOFactory.getDossierDAO();
      tempFolder = dossierDAO.init(dossier);
      logger.debug("Path tmp folder dossier =" + tempFolder + " created.");

      // gets the template file data
      String templateFileName = dossierDAO.getPresentationTemplateFileName(tempFolder);
      logger.debug("Template file name: " + templateFileName);
      InputStream contentTempIs = dossierDAO.getPresentationTemplateContent(tempFolder);
      logger.debug("InputStream opened on dossier template.");
      byte[] contentTempBytes = GeneralUtilities.getByteArrayFromInputStream(contentTempIs);
      logger.debug("DossierTemplateContent stored into a byte array.");
      contentTempIs.close();
      // write template content into a temp file
      File templateFile = new File(tempFolder, templateFileName);
      FileOutputStream fosTemplate = new FileOutputStream(templateFile);
      fosTemplate.write(contentTempBytes);
      fosTemplate.flush();
      fosTemplate.close();
      logger.debug("Dossier template content written into a temp file.");

      // initialize openoffice environment
      ConfigSingleton config = ConfigSingleton.getInstance();
      SourceBean officeConnectSB = (SourceBean) config.getAttribute("DOSSIER.OFFICECONNECTION");
      logger.debug("Office connection Sourcebean retrieved: " + officeConnectSB.toXML());
      String host = (String) officeConnectSB.getAttribute("host");
      String port = (String) officeConnectSB.getAttribute("port");
      logger.debug("Office connection host: " + host);
      logger.debug("Office connection port: " + port);
      XComponentContext xRemoteContext = Bootstrap.createInitialComponentContext(null);
      logger.debug("InitialComponentContext xRemoteContext created: " + xRemoteContext);

      Object x = xRemoteContext.getServiceManager().createInstanceWithContext(
        "com.sun.star.connection.Connector", xRemoteContext);
      XConnector xConnector = (XConnector) UnoRuntime.queryInterface(XConnector.class, x);
      logger.debug("XConnector retrieved: " + xConnector);
      XConnection connection = xConnector.connect("socket,host=" + host + ",port=" + port);
      logger.debug("XConnection retrieved: " + connection);
      x = xRemoteContext.getServiceManager().createInstanceWithContext("com.sun.star.bridge.BridgeFactory",
        xRemoteContext);
      XBridgeFactory xBridgeFactory = (XBridgeFactory) UnoRuntime.queryInterface(XBridgeFactory.class, x);
      logger.debug("XBridgeFactory retrieved: " + xBridgeFactory);
      // this is the bridge that you will dispose
      bridge = xBridgeFactory.createBridge("", "urp", connection, null);
      logger.debug("XBridge retrieved: " + bridge);
      XComponent xComp = (XComponent) UnoRuntime.queryInterface(XComponent.class, bridge);
      // get the remote instance
      x = bridge.getInstance("StarOffice.ServiceManager");
      logger.debug("StarOffice.ServiceManager instance retrieved: " + x);
      // Query the initial object for its main factory interface
      XMultiComponentFactory xRemoteServiceManager = (XMultiComponentFactory) UnoRuntime.queryInterface(
        XMultiComponentFactory.class, x);

View Full Code Here


            XBridgeFactory xBridgeFactory = (XBridgeFactory) UnoRuntime.queryInterface(
                XBridgeFactory.class , x );

            // create a nameless bridge with no instance provider
            // using the middle part of the uno-url
            XBridge bridge = xBridgeFactory.createBridge( "" , a[1] , connection , null );

            // query for the XComponent interface and add this as event listener
            XComponent xComponent = (XComponent) UnoRuntime.queryInterface(
                XComponent.class, bridge );
            xComponent.addEventListener( this );

            // get the remote instance
            x = bridge.getInstance( a[2] );

            // Did the remote server export this object ?
            if( null == x )
            {
                throw new com.sun.star.uno.Exception(
View Full Code Here

    // do not create a new bridge, if one already exists
        if (hasName) {
            IBridge iBridges[] = UnoRuntime.getBridges();
            for(int i = 0; i < iBridges.length; ++ i) {
                XBridge xBridge = (XBridge)UnoRuntime.queryInterface(XBridge.class, iBridges[i]);

                if(xBridge != null) {
                    if(xBridge.getName().equals(sName))
                        throw new BridgeExistsException(sName + " already exists");
                }
            }
        }

    XBridge xBridge = null;

    try {
      IBridge iBridge = UnoRuntime.getBridgeByName("java", context, "remote", context, hasName ? new Object[]{sProtocol, aConnection, anInstanceProvider, sName} : new Object[]{sProtocol, aConnection, anInstanceProvider});

      xBridge = (XBridge)UnoRuntime.queryInterface(XBridge.class, iBridge);
View Full Code Here

   * @return   the bridge
   * @param    sName                the name of the bridge
   * @see                           com.sun.star.bridge.XBridgeFactory
   */
    public XBridge getBridge(String sName) throws com.sun.star.uno.RuntimeException {
    XBridge xBridge = null;

    IBridge iBridges[] = UnoRuntime.getBridges();
    for(int i = 0; i < iBridges.length; ++ i) {
      xBridge = (XBridge)UnoRuntime.queryInterface(XBridge.class, iBridges[i]);

      if(xBridge != null) {
        if(xBridge.getName().equals(sName))
          break;
         
        else
          xBridge = null;
      }
View Full Code Here

    public synchronized XBridge[] getExistingBridges() throws com.sun.star.uno.RuntimeException {
    Vector vector = new Vector();

    IBridge iBridges[] = UnoRuntime.getBridges();
    for(int i = 0; i < iBridges.length; ++ i) {
      XBridge xBridge = (XBridge)UnoRuntime.queryInterface(XBridge.class, iBridges[i]);

      if(xBridge != null)
        vector.addElement(xBridge);
    }

    XBridge xBridges[]= new XBridge[vector.size()];
    for(int i = 0; i < vector.size(); ++ i)
      xBridges[i] = (XBridge)vector.elementAt(i);

    return xBridges;
  }
View Full Code Here

       XBridgeFactory xBridgeFactory = (XBridgeFactory) UnoRuntime.queryInterface(
                XBridgeFactory.class , x );

       // create a nameless bridge with no instance provider
       // using the middle part of the uno-url
       XBridge bridge = xBridgeFactory.createBridge( "" , a[1] , m_Connection , null );

       // query for the XComponent interface and add this as event listener
       XComponent xComponent = (XComponent) UnoRuntime.queryInterface(
                XComponent.class, bridge );

       // get the remote instance
       x = bridge.getInstance( a[2] );

       // Did the remote server export this object ?
       if( null == x )
       {
           throw new com.sun.star.uno.Exception(
View Full Code Here

          if( broadcaster != null )
            broadcaster.addStreamListener(
              new ConnectionListener( holder ) );
             
          // create the bridge
          XBridge xBridge = xBridgeFactory.createBridge(conDcp + ";" + protDcp + "#" + (connect_count ++), protDcp, xConnection, new InstanceProvider(rootOid, object));
        }
        catch(com.sun.star.uno.Exception exception) {
          System.err.println( "UnoApp acceptor:  exeception occurred - " + exception);
          if(xConnection != null)
            xConnection.close();
View Full Code Here

                        localServiceManager.createInstanceWithContext("com.sun.star.connection.Connector", localContext));
                XConnection connection = connector.connect(connectionString);
                XBridgeFactory bridgeFactory = as(XBridgeFactory.class,
                        localServiceManager.createInstanceWithContext("com.sun.star.bridge.BridgeFactory", localContext));
                String bridgeName = "yarg_" + bridgeIndex.incrementAndGet();
                XBridge bridge = bridgeFactory.createBridge(bridgeName, "urp", connection, null);
                XMultiComponentFactory serviceManager = as(XMultiComponentFactory.class, bridge.getInstance("StarOffice.ServiceManager"));
                XPropertySet properties = as(XPropertySet.class, serviceManager);
                xComponentContext = as(XComponentContext.class, properties.getPropertyValue("DefaultContext"));

                officeResourceProvider = new OfficeResourceProvider(xComponentContext, officeIntegration);
                closed = false;
View Full Code Here

           
            XBridgeFactory xBridgeFactory = (XBridgeFactory)UnoRuntime.queryInterface(
                XBridgeFactory.class,
                smgr.createInstanceWithContext("com.sun.star.bridge.BridgeFactory",ctx));
           
            XBridge xBridge = xBridgeFactory.createBridge(
                "", protDcp, xConnection, new InstanceProvider(ctx));

            if (singleaccept) {
                Listener listener = new Listener();
                ((XComponent) UnoRuntime.queryInterface(
View Full Code Here

        XBridgeFactory xBridgeFactory = (XBridgeFactory) UnoRuntime.queryInterface(
                XBridgeFactory.class, x);

        // create a nameless bridge with no instance provider
        // using the middle part of the uno-url
        XBridge bridge = xBridgeFactory.createBridge("", a[1], m_Connection, null);

        // query for the XComponent interface and add this as event listener
        XComponent xComponent = (XComponent) UnoRuntime.queryInterface(
                XComponent.class, bridge);

        // get the remote instance
        x = bridge.getInstance(a[2]);

        // Did the remote server export this object ?
        if (null == x) {
            throw new com.sun.star.uno.Exception(
                    "Server didn't provide an instance for" + a[2], null);
View Full Code Here

TOP

Related Classes of com.sun.star.bridge.XBridge

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.