Package org.apache.felix.ipojo

Examples of org.apache.felix.ipojo.ComponentInstance


    try {
      Properties configuration = new Properties();
      if (initialProperties != null)
        configuration.putAll(initialProperties);
     
      ComponentInstance ipojoInstance = factory.createComponentInstance(configuration);
      return new ApformIpojoInstance(ipojoInstance);
     
    } catch (Exception cause) {
      throw new IllegalArgumentException(cause);
    }
View Full Code Here


         */
        if (!(service instanceof Pojo)) {
            return;
        }

        ComponentInstance ipojoInstance = ((Pojo) service).getComponentInstance();
       
        /*
         * Ignore hybrid APAM+iPOJO instances
         */
        if (service instanceof ApamInstanceManager) {
View Full Code Here

    public void modifiedService(ServiceReference reference, Object service) {

        if (!(service instanceof Pojo))
            return;

        ComponentInstance ipojoInstance = ((Pojo) service).getComponentInstance();

        /*
         * If the service is not reified in APAM, just ignore event
         */
        Instance instance = CST.componentBroker.getInst(ipojoInstance.getInstanceName());
        if (instance == null)
            return;

        /*
         * Otherwise propagate property changes to Apam, we only propagate properties that are defined
View Full Code Here

                // System.out.println("current level = " + currentLevel);
                Properties props = new Properties();
                props.put(ComponentTestImpl.CURRENTLEVELPROPERTY, Integer.valueOf(i).toString());
                props.put("instance.name", UUID.randomUUID().toString());

                ComponentInstance instanceRef = ComponentTestImpl.factory.createComponentInstance(props);
                instanceRef.start();
                instance1 = (ComponentTestImpl) ((InstanceManager) instanceRef).getPojoObject();

                props.put("instance.name", UUID.randomUUID().toString());
                instanceRef = ComponentTestImpl.factory.createComponentInstance(props);
                instanceRef.start();
                instance2 = (ComponentTestImpl) ((InstanceManager) instanceRef).getPojoObject();

                props = null;
            } catch (Exception e) {
                e.printStackTrace();
View Full Code Here

    }

    @Test
    public void testNoDelayWithProxy() {
        String prov = "provider";
        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
        String un = "under-1";
        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-ProxiedCheckServiceProvider", un);
        assertNotNull("Check creation", under);
        assertNotNull("Check provider creation", prov);

        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
        assertNotNull("Check foo availability", ref_fs);

        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
        assertNotNull("Check cs availability", ref_cs);

        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
        assertTrue("Check invocation", cs.check());

        provider.stop();
        provider.dispose();
        under.stop();
        under.dispose();
    }
View Full Code Here

    }

    @Test
    public void testMultipleNoDelay() {
        String prov1 = "provider-1";
        ComponentInstance provider1 = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov1);
        String un = "under-2";
        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-MultipleCheckServiceProvider", un);

        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov1);
        assertNotNull("Check foo availability", ref_fs);

        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
        assertNotNull("Check cs availability", ref_cs);

        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
        assertTrue("Check invocation", cs.check());

        provider1.stop();
        provider1.dispose();
        under.stop();
        under.dispose();
    }
View Full Code Here

    }

    @Test
    public void testCollectionNoDelay() {
        String prov1 = "provider-1";
        ComponentInstance provider1 = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov1);
        String un = "under-2";
        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-ColCheckServiceProvider", un);

        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov1);
        assertNotNull("Check foo availability", ref_fs);

        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
        assertNotNull("Check cs availability", ref_cs);

        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
        assertTrue("Check invocation", cs.check());

        provider1.stop();
        provider1.dispose();
        under.stop();
        under.dispose();
    }
View Full Code Here

    }

    @Test
    public void testProxiedCollectionNoDelay() {
        String prov1 = "provider-1";
        ComponentInstance provider1 = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov1);
        String un = "under-2";
        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-ProxiedColCheckServiceProvider", un);

        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov1);
        assertNotNull("Check foo availability", ref_fs);

        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
        assertNotNull("Check cs availability", ref_cs);

        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
        assertTrue("Check invocation", cs.check());

        provider1.stop();
        provider1.dispose();
        under.stop();
        under.dispose();
    }
View Full Code Here

                ));
    }

    @Test
    public void testOkOutsideTransaction() {
        ComponentInstance prov = ipojoHelper.createComponentInstance("org.apache.felix.ipojo.handler.transaction.components.FooImpl");
        ComponentInstance under = ipojoHelper.createComponentInstance("supported-ok");

        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
        Assert.assertEquals(ComponentInstance.VALID, under.getState());

        ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
        Assert.assertNotNull(ref);

        CheckService cs = ((CheckService) osgiHelper.getServiceObject(ref));
        cs.doSomethingGood();
        // No transaction.
View Full Code Here

        // No transaction.
    }

    @Test
    public void testOkInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
        ComponentInstance prov = ipojoHelper.createComponentInstance("org.apache.felix.ipojo.handler.transaction.components.FooImpl");
        ComponentInstance under = ipojoHelper.createComponentInstance("supported-ok");

        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
        Assert.assertEquals(ComponentInstance.VALID, under.getState());

        ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
        Assert.assertNotNull(ref);

        osgiHelper.waitForService(TransactionManager.class.getName(), null, 5000);
        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref);
        TransactionManager tm = (TransactionManager) osgiHelper.getServiceObject(TransactionManager.class.getName(), null);
View Full Code Here

TOP

Related Classes of org.apache.felix.ipojo.ComponentInstance

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.