Package org.apache.felix.ipojo

Examples of org.apache.felix.ipojo.ComponentFactory$FactoryClassloader


        InstanceDescription[] contained = id.getContainedInstances();
        assertEquals("Check contained instances count (" + contained.length + ")", contained.length, 1);
        assertEquals("Check instance name", id.getName(), "under");
        assertEquals("Check component type name", id.getComponentDescription().getName(), "composite.bar.1");

        ComponentFactory fact1 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-1");
        ComponentFactory fact2 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-2");
        ComponentFactory fact3 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-3");

        fact1.stop();
        assertTrue("Check instance validity - 2", under.getState() == ComponentInstance.VALID);
        ref = osgiHelper.getServiceReference(Architecture.class.getName(), "(architecture.instance=under)");
        assertNotNull("Check architecture availability", ref);
        arch = (Architecture) getContext().getService(ref);
        //id = arch.getInstanceDescription();
        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
        contained = id.getContainedInstances();
        assertEquals("Check contained instances count", contained.length, 1);
        assertEquals("Check instance name", id.getName(), "under");
        assertEquals("Check component type name", id.getComponentDescription().getName(), "composite.bar.1");

        fact2.stop();
        assertTrue("Check instance validity - 3", under.getState() == ComponentInstance.VALID);
        ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "under");
        assertNotNull("Check architecture availability", ref);
        arch = (Architecture) getContext().getService(ref);
        //id = arch.getInstanceDescription();
        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
        contained = id.getContainedInstances();
        assertEquals("Check contained instances count", contained.length, 1);
        assertEquals("Check instance name", id.getName(), "under");
        assertEquals("Check component type name", id.getComponentDescription().getName(), "composite.bar.1");

        fact3.stop();
        assertTrue("Check instance invalidity", under.getState() == ComponentInstance.INVALID);
        ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "under");
        assertNotNull("Check architecture availability", ref);
        arch = (Architecture) getContext().getService(ref);
        //id = arch.getInstanceDescription();
        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.INVALID);
        contained = id.getContainedInstances();
        assertEquals("Check contained instances count", contained.length, 0);
        assertEquals("Check instance name", id.getName(), "under");
        assertEquals("Check component type name", id.getComponentDescription().getName(), "composite.bar.1");

        fact1.start();
        assertTrue("Check instance validity - 4", under.getState() == ComponentInstance.VALID);
        ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "under");
        assertNotNull("Check architecture availability", ref);
        arch = (Architecture) getContext().getService(ref);
        //id = arch.getInstanceDescription();
        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
        contained = id.getContainedInstances();
        assertEquals("Check contained instances count", contained.length, 1);
        assertEquals("Check instance name", id.getName(), "under");
        assertEquals("Check component type name", id.getComponentDescription().getName(), "composite.bar.1");

        under.dispose();
        fact2.start();
        fact3.start();
    }
View Full Code Here


        byte[] clazz = m_composition.buildPOJO();
        Element metadata = m_composition.buildMetadata(m_instanceName);

        // Create the factory
        try {
            m_factory = new ComponentFactory(m_context, clazz, metadata);
            m_factory.start();
        } catch (ConfigurationException e) {
            // Should not happen.
            m_manager.getFactory().getLogger().log(Logger.ERROR, "A factory cannot be created", e);
        }
View Full Code Here

*/
public class ObedienceTest extends OSGiTestCase {

  public void testObedience() {
    assertNull("Check no foo service", getContext().getServiceReference(FooService.class.getName()));
    ComponentFactory factory = (ComponentFactory) Utils.getFactoryByName(getContext(), "Factories-FooProviderType-1");
    assertNotNull("Check factory existing", factory);
   
    Properties props1 = new Properties();
    props1.put("instance.name","foo1");
    Properties props2 = new Properties();
    props2.put("instance.name","foo2");
   
    ComponentInstance ci1 = null, ci2 = null;
    try {
      ci1 = factory.createComponentInstance(props1);
      ci2 = factory.createComponentInstance(props2);
    } catch(Exception e) {
      fail("Cannot instantiate foo providers : " + e.getMessage());
    }
   
    assertTrue("Check foo1 validity", ci1.getState() == ComponentInstance.VALID);
    assertTrue("Check foo2 validity", ci2.getState() == ComponentInstance.VALID);
   
    assertNotNull("Check foo service", getContext().getServiceReference(FooService.class.getName()));
    assertEquals("Check the number of Foo", Utils.getServiceReferences(getContext(), FooService.class.getName(), null).length, 2);
   
    factory.stop();
   
    assertTrue("Check foo1 invalidity ("+ci1.getState()+")", ci1.getState() == ComponentInstance.DISPOSED);
    assertTrue("Check foo2 invalidity ("+ci1.getState()+")", ci2.getState() == ComponentInstance.DISPOSED);
   
    assertNull("Check no foo service", getContext().getServiceReference(FooService.class.getName()));
   
    factory.start();
    assertNull("Check no foo service", getContext().getServiceReference(FooService.class.getName()));
  }
View Full Code Here

    factory.start();
    assertNull("Check no foo service", getContext().getServiceReference(FooService.class.getName()));
  }
 
  public void testDisposeAfterFactoryInvalidation() {
      ComponentFactory cf = (ComponentFactory) Utils.getFactoryByName(getContext(), "org.apache.felix.ipojo.test.scenarios.component.SimpleType");
      assertNotNull("Check factory availability -1", cf);
      assertEquals("Check factory state -1", Factory.VALID, cf.getState());
     
      ServiceReference ref_arch = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "SimpleInstance");
      assertNotNull("Check Architecture availability -1", ref_arch);
     
        HandlerManagerFactory hf = (HandlerManagerFactory) Utils.getHandlerFactoryByName(getContext(), "controller");
        assertNotNull("Check handler availability -1", hf);
        assertEquals("Check handler state -1", Factory.VALID, hf.getState());
       
        // Stop the handler
        hf.stop();
        HandlerManagerFactory hf2 = (HandlerManagerFactory) Utils.getHandlerFactoryByName(getContext(), "controller");
        assertNull("Check handler availability -2", hf2);
       
        // Check the factory invalidity
        cf = (ComponentFactory) Utils.getFactoryByName(getContext(), "org.apache.felix.ipojo.test.scenarios.component.SimpleType");
        assertNotNull("Check factory availability -2", cf);
        assertEquals("Check factory state -2", Factory.INVALID, cf.getState());
       
        // Check the instance disparition
        ref_arch = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "SimpleInstance");
        assertNull("Check Architecture availability -1", ref_arch);
       
        // Restart the handler
        hf.start();
        hf2 = (HandlerManagerFactory) Utils.getHandlerFactoryByName(getContext(), "controller");
        assertNotNull("Check handler availability -3", hf2);
       
        // Check the factory state
        cf = (ComponentFactory) Utils.getFactoryByName(getContext(), "org.apache.felix.ipojo.test.scenarios.component.SimpleType");
        assertNotNull("Check factory availability -3", cf);
        assertEquals("Check factory state -3", Factory.VALID, cf.getState());
       
       
        // Check the instance re-creation
        ref_arch = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "SimpleInstance");
        assertNotNull("Check Architecture availability -3", ref_arch);
View Full Code Here

TOP

Related Classes of org.apache.felix.ipojo.ComponentFactory$FactoryClassloader

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.