Package com.sun.star.loader

Examples of com.sun.star.loader.XImplementationLoader


                                    XComponentContext context = Bootstrap.
                                       defaultBootstrap_InitialComponentContext(
                                            null, params);
                                    XMultiComponentFactory factory
                                        = context.getServiceManager();
                                    XImplementationLoader loader =
                                        UnoRuntime.queryInterface(
                                            XImplementationLoader.class,
                                            factory.createInstanceWithContext(
                                                "com.sun.star.loader."
                                                + "SharedLibrary",
                                                context));
                                    XSingleComponentFactory factory2 =
                                        UnoRuntime.queryInterface(
                                            XSingleComponentFactory.class,
                                            loader.activate(
                                                "com.sun.star.test.bridges."
                                                + "testequals.impl",
                                                "", "../lib/testequals.uno",
                                                null));
                                    XTestInterface test =
View Full Code Here


    @return a new context.
    */
  static public XComponentContext createInitialComponentContext( Hashtable context_entries )
        throws Exception
    {
    XImplementationLoader xImpLoader = UnoRuntime.queryInterface(
            XImplementationLoader.class, new JavaLoader() );
   
    // Get the factory of the ServiceManager
    XSingleComponentFactory smgr_fac = UnoRuntime.queryInterface(
            XSingleComponentFactory.class, xImpLoader.activate(
                "com.sun.star.comp.servicemanager.ServiceManager", null, null, null ) );
       
    // Create an instance of the ServiceManager
    XMultiComponentFactory xSMgr = UnoRuntime.queryInterface(
            XMultiComponentFactory.class, smgr_fac.createInstanceWithContext( null ) );
View Full Code Here

   * @see        com.sun.star.lang.ServiceManager
   */
  static public XMultiServiceFactory createSimpleServiceManager() throws Exception {
    JavaLoader loader = new JavaLoader();
       
    XImplementationLoader xImpLoader = (XImplementationLoader)UnoRuntime.queryInterface(XImplementationLoader.class, loader);
   
    // Get the factory for the ServiceManager
    Object loaderobj = xImpLoader.activate("com.sun.star.comp.servicemanager.ServiceManager", null, null, null);
       
    // Ensure that we have got a factory
    XSingleServiceFactory xManagerFac =  (XSingleServiceFactory) UnoRuntime.queryInterface(XSingleServiceFactory.class, loaderobj);
    // Create an instance of the ServiceManager
    XMultiServiceFactory xMultiFac = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class,
                                              xManagerFac.createInstance());

    // set the ServiceManager at the JavaLoader with the XInitialization interface
    XInitialization xInit = (XInitialization) UnoRuntime.queryInterface(XInitialization.class, xImpLoader);
    Object[] iniargs = { xMultiFac };  
    xInit.initialize( iniargs );
   

    // now use the XSet interface at the ServiceManager to add the factory of the loader
    XSet xSet = (XSet) UnoRuntime.queryInterface(XSet.class, xMultiFac);

    // Get the factory of the loader       
    XSingleServiceFactory xSingleServiceFactory = (XSingleServiceFactory) UnoRuntime.queryInterface(XSingleServiceFactory.class,
                                                    xImpLoader.activate("com.sun.star.comp.loader.JavaLoader", null, null, null));

    // add the javaloader
    xSet.insert(xSingleServiceFactory);
   
    // add the service manager
    xSet.insert(xManagerFac);

    // Get the factory of the URLResolver       
    xSingleServiceFactory = (XSingleServiceFactory)UnoRuntime.queryInterface(XSingleServiceFactory.class,
                                         xImpLoader.activate("com.sun.star.comp.urlresolver.UrlResolver", null, null, null));
    xSet.insert(xSingleServiceFactory);

    // add the bridgefactory
    xSingleServiceFactory = (XSingleServiceFactory)UnoRuntime.queryInterface(XSingleServiceFactory.class,
                                         xImpLoader.activate("com.sun.star.comp.bridgefactory.BridgeFactory", null, null, null));
    xSet.insert(xSingleServiceFactory);

    // add the connector
    xSingleServiceFactory = (XSingleServiceFactory)UnoRuntime.queryInterface(XSingleServiceFactory.class,
                                         xImpLoader.activate("com.sun.star.comp.connections.Connector", null, null, null));
    xSet.insert(xSingleServiceFactory);
   
    // add the acceptor
    xSingleServiceFactory = (XSingleServiceFactory)UnoRuntime.queryInterface(XSingleServiceFactory.class,
                                         xImpLoader.activate("com.sun.star.comp.connections.Acceptor", null, null, null));
    xSet.insert(xSingleServiceFactory);

    return xMultiFac;
  }
View Full Code Here

    }

    Object create(CompContext compContext) throws Exception {
      String componentName = (String)compContext._context;

      XImplementationLoader loader = (XImplementationLoader)UnoRuntime.queryInterface(XImplementationLoader.class,
                                              compContext._xMultiServiceFactory.createInstance("com.sun.star.loader.Java"));

      Object serviceManager = compContext._xMultiServiceFactory.createInstance("com.sun.star.lang.ServiceManager");
      XSet serviceManager_xSet = (XSet)UnoRuntime.queryInterface(XSet.class, serviceManager);

      XRegistryKey xRegistryKey = new RegistryKey("ROOT");

      loader.writeRegistryInfo(xRegistryKey, null, componentName);

      String keys[] = xRegistryKey.getKeyNames();
      for(int j = 0; j < keys.length; ++ j) {
        String implName = keys[j].substring(1);
        implName = implName.substring(0, implName.length() - "/UNO/SERVICES".length());

        Object factory = loader.activate(implName, null, componentName, xRegistryKey);
        XSingleServiceFactory xSingleServiceFactory = (XSingleServiceFactory)UnoRuntime.queryInterface(XSingleServiceFactory.class,
                                                         factory);
         
        if (xSingleServiceFactory == null)
          throw new com.sun.star.loader.CannotActivateFactoryException("Can not get factory for " +  implName);
View Full Code Here

  {
    loadNativeLibrary();

    Object  object  = new JavaLoader();

    XImplementationLoader implLoader;
    implLoader  = (XImplementationLoader)UnoRuntime.queryInterface(
      XImplementationLoader.class, object);

    object  = implLoader.activate(
      "com.sun.star.comp.servicemanager.ServiceManager", null, null, null);

    // Ensure that we have got a factory
    XSingleServiceFactory  managerFact;
    managerFact  = (XSingleServiceFactory)UnoRuntime.queryInterface(
      XSingleServiceFactory.class, object);

    // Create an instance of the ServiceManager
    XMultiServiceFactory  serviceMgr;
    serviceMgr  = (XMultiServiceFactory)UnoRuntime.queryInterface(
      XMultiServiceFactory.class, managerFact.createInstance());

    // Set the ServiceManager at the JavaLoader with the XInitialization
    XInitialization      init;
    init  = (XInitialization)UnoRuntime.queryInterface(
      XInitialization.class, implLoader);

    Object[]  initargs  = { serviceMgr };  
    init.initialize(initargs);

    // Use the XSet interface at the ServiceManager to add the factory of
    // the loader
    XSet  serviceMgrXSet  = (XSet)UnoRuntime.queryInterface(
      XSet.class, serviceMgr);

    XSingleServiceFactory  singleServiceFact;
    // Add the factory of the loader
    singleServiceFact  = (XSingleServiceFactory)UnoRuntime.queryInterface(
      XSingleServiceFactory.class,
      implLoader.activate(
        "com.sun.star.comp.loader.JavaLoader", null, null, null));
    serviceMgrXSet.insert(singleServiceFact);
               
    // Add the service manager
    serviceMgrXSet.insert(managerFact);

    // Add the factory of the URLResolver       
    singleServiceFact  = (XSingleServiceFactory)UnoRuntime.queryInterface(
      XSingleServiceFactory.class,
      implLoader.activate(
        "com.sun.star.comp.urlresolver.UrlResolver", null, null, null));
    serviceMgrXSet.insert(singleServiceFact);

    // Add the bridgefactory
    singleServiceFact  = (XSingleServiceFactory)UnoRuntime.queryInterface(
      XSingleServiceFactory.class,
      implLoader.activate(
        "com.sun.star.comp.bridgefactory.BridgeFactory", null, null, null));
    serviceMgrXSet.insert(singleServiceFact);

    // Ufff ... that's all
    mLocalServiceFactory = serviceMgr;
View Full Code Here

    @return a new context.
    */
  static public XComponentContext createInitialComponentContext( Hashtable context_entries )
        throws Exception
    {
    XImplementationLoader xImpLoader = (XImplementationLoader)UnoRuntime.queryInterface(
            XImplementationLoader.class, new JavaLoader() );
   
    // Get the factory of the ServiceManager
    XSingleComponentFactory smgr_fac = (XSingleComponentFactory)UnoRuntime.queryInterface(
            XSingleComponentFactory.class, xImpLoader.activate(
                "com.sun.star.comp.servicemanager.ServiceManager", null, null, null ) );
       
    // Create an instance of the ServiceManager
    XMultiComponentFactory xSMgr = (XMultiComponentFactory)UnoRuntime.queryInterface(
            XMultiComponentFactory.class, smgr_fac.createInstanceWithContext( null ) );
View Full Code Here

    public LoaderTest2( String[] args ) {
        try {
         
          JavaLoader loader = new JavaLoader();
         
          XImplementationLoader xImpLoader = (XImplementationLoader) UnoRuntime.queryInterface(XImplementationLoader.class, loader);
          Object loaderobj = xImpLoader.activate("com.sun.star.comp.servicemanager.ServiceManager", null, null, null);
         
          XSingleServiceFactory xManagerFac = (XSingleServiceFactory) UnoRuntime.queryInterface(XSingleServiceFactory.class, loaderobj);

          XMultiServiceFactory xMultiFac = (XMultiServiceFactory) UnoRuntime.queryInterface(
              XMultiServiceFactory.class,
              xManagerFac.createInstance() );
             
          XSingleServiceFactory xSingleServiceFactory = (XSingleServiceFactory) UnoRuntime.queryInterface(
              XSingleServiceFactory.class,
              xImpLoader.activate("com.sun.star.comp.loader.JavaLoader", null, null, null));
         
          XInitialization xInit = (XInitialization) UnoRuntime.queryInterface(XInitialization.class, xImpLoader);
          Object[] iniargs = { xMultiFac };
         
          xInit.initialize( iniargs );
         
      XSet xSet = (XSet) UnoRuntime.queryInterface(XSet.class, xMultiFac);
      xSet.insert( xSingleServiceFactory );
         
            System.err.println("create ServiceManager");
            System.err.println();
           
            manager = (ServiceManager) xSet;
           
            /*
            String[] factories = new String[args.length + 2];
           
            factories[0] = "com.sun.star.comp.servicemanager.ServiceManager";
            factories[1] = "java.awt.Button";
            factories[2] ="com.sun.star.comp.loader.DummyService"
           
            System.arraycopy(args, 0, factories, 2, args.length);
            */
           
            String[] factories = {   "com.sun.star.comp.servicemanager.ServiceManager",
                        "java.awt.Button"
                        };

                       
            manager.addFactories( factories );
           
            System.err.println("now try to instanciate the components");
           
            for (int j=0; j<args.length; j++) {
                try {
                    System.err.println( "try to create instance of " + args[j] );
                    Object obj = manager.createInstance(args[j]);
                    System.err.println( "create instance done ... " );
                } catch (Exception e) {
                    System.err.println("an "+e.toString() + " occured while create instance of " +args[j] );
                }
            }
           
            System.err.println("---------------------------------------------------------------");
            System.err.println("test the  XMultiServiceFactory interface  of the ServiceManager");
           
            System.err.println("-- createInstance");
           
            Object test1 = manager.createInstance( "java.awt.Button" );
            java.awt.Button btn1 = (java.awt.Button) UnoRuntime.queryInterface(java.awt.Button.class, test1);
            System.err.println("button 1 created without args" );
            System.err.println("-- done ...");
           
            System.err.println("-- createInstanceWithArguments");
           
            String[] params = { "TestButton" };
            Object test2 = manager.createInstanceWithArguments( "java.awt.Button", params );
           
            java.awt.Button btn2 = (java.awt.Button) UnoRuntime.queryInterface(java.awt.Button.class, test2);
           
            System.err.println("button 2 created with label " + btn2.getLabel() );
           
            System.err.println("-- done ...");
           
            System.err.println("-- getAvailableServiceNames");
           
            String[] availableServiceNames = manager.getAvailableServiceNames();
           
            for (int n=0; n<availableServiceNames.length; n++)
                System.err.println("service #"+n+" : " +availableServiceNames[n] );
           
            System.err.println("-- done ...");
            System.err.println();
            System.err.println("---------------------------------------------------------------");
            System.err.println("test the  XSet interface  of the ServiceManager");
           
            Object[] param = { manager };
            Object loaderObj = manager.createInstanceWithArguments("com.sun.star.loader.Java", param);
            XImplementationLoader xLoader = (XImplementationLoader) UnoRuntime.queryInterface(XImplementationLoader.class, loaderObj);
           
            Object dummyFactory = xLoader.activate( "com.sun.star.comp.loader.DummyService", null, null, null );
           
            System.err.println("-- insert");
            manager.insert(dummyFactory);
            System.err.println("-- done ...");
           
View Full Code Here

 
  public RmServer_test(String host, String port) {   
      try {        
          JavaLoader loader = new JavaLoader();
         
          XImplementationLoader xImpLoader = (XImplementationLoader) UnoRuntime.queryInterface(XImplementationLoader.class, loader);
          Object loaderobj = xImpLoader.activate("com.sun.star.comp.servicemanager.ServiceManager", null, null, null);
         
          XSingleServiceFactory xManagerFac = (XSingleServiceFactory) UnoRuntime.queryInterface(XSingleServiceFactory.class, loaderobj);

          XMultiServiceFactory xMultiFac = (XMultiServiceFactory) UnoRuntime.queryInterface(
              XMultiServiceFactory.class,
              xManagerFac.createInstance() );
             
          XSingleServiceFactory xSingleServiceFactory = (XSingleServiceFactory) UnoRuntime.queryInterface(
              XSingleServiceFactory.class,
              xImpLoader.activate("com.sun.star.comp.loader.JavaLoader", null, null, null));
         
          XInitialization xInit = (XInitialization) UnoRuntime.queryInterface( XInitialization.class, xImpLoader );
          Object[] iniargs = { xMultiFac };
         
          xInit.initialize( iniargs );
View Full Code Here

            System.err.println("---------------------------------------------------------------");
            System.err.println("test the  XSet interface  of the ServiceManager");
           
            Object[] param = { manager };
            Object loaderObj = manager.createInstanceWithArguments("com.sun.star.loader.Java", param);
            XImplementationLoader xLoader = (XImplementationLoader) UnoRuntime.queryInterface(XImplementationLoader.class, loaderObj);
           
            Object dummyFactory = xLoader.activate( "com.sun.star.comp.loader.DummyService", null, null, null );
           
            System.err.println("-- insert");
            manager.insert(dummyFactory);
            System.err.println("-- done ...");
           
View Full Code Here

    public RmClient_test( String host, String port ) {
        try {
         
          JavaLoader loader = new JavaLoader();
         
          XImplementationLoader xImpLoader = (XImplementationLoader) UnoRuntime.queryInterface(XImplementationLoader.class, loader);
          Object loaderobj = xImpLoader.activate("com.sun.star.comp.servicemanager.ServiceManager", null, null, null);
         
          XSingleServiceFactory xManagerFac = (XSingleServiceFactory) UnoRuntime.queryInterface(XSingleServiceFactory.class, loaderobj);

          XMultiServiceFactory xMultiFac = (XMultiServiceFactory) UnoRuntime.queryInterface(
              XMultiServiceFactory.class,
              xManagerFac.createInstance() );
             
          XSingleServiceFactory xSingleServiceFactory = (XSingleServiceFactory) UnoRuntime.queryInterface(
              XSingleServiceFactory.class,
              xImpLoader.activate("com.sun.star.comp.loader.JavaLoader", null, null, null));
         
          XInitialization xInit = (XInitialization) UnoRuntime.queryInterface( XInitialization.class, xImpLoader );
          Object[] iniargs = { xMultiFac };
         
          xInit.initialize( iniargs );
View Full Code Here

TOP

Related Classes of com.sun.star.loader.XImplementationLoader

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.