Search in sources :

Example 41 with Factory

use of org.apache.felix.ipojo.Factory in project felix by apache.

the class TestSimpleExport method setUp.

@Before
public void setUp() {
    fooProvider = ipojoHelper.getFactory("BazProviderType");
    assertNotNull("Check fooProvider availability", fooProvider);
    Properties p1 = new Properties();
    p1.put("instance.name", "foo1");
    Properties p2 = new Properties();
    p2.put("instance.name", "foo2");
    try {
        foo1 = fooProvider.createComponentInstance(p1);
        foo2 = fooProvider.createComponentInstance(p2);
    } catch (Exception e) {
        fail("Fail to create foos : " + e.getMessage());
    }
    foo1.stop();
    foo2.stop();
    Factory factory = ipojoHelper.getFactory("composite.export.1");
    Properties props = new Properties();
    props.put("instance.name", "export");
    try {
        export1 = factory.createComponentInstance(props);
    } catch (Exception e) {
        fail("Fail to instantiate exporter " + e.getMessage());
    }
}
Also used : Factory(org.apache.felix.ipojo.Factory) Properties(java.util.Properties) Before(org.junit.Before)

Example 42 with Factory

use of org.apache.felix.ipojo.Factory in project felix by apache.

the class TestDelayedMultipleImport method setUp.

@Before
public void setUp() {
    Properties p = new Properties();
    p.put("instance.name", "importer");
    Factory compFact = ipojoHelper.getFactory("composite.requires.2");
    try {
        import2 = compFact.createComponentInstance(p);
    } catch (Exception e) {
        fail("Cannot instantiate the component : " + e.getMessage());
    }
    import2.stop();
    fooProvider = ipojoHelper.getFactory("COMPO-FooProviderType-1");
    assertNotNull("Check fooProvider availability", fooProvider);
    Properties p1 = new Properties();
    p1.put("instance.name", "foo1");
    Properties p2 = new Properties();
    p2.put("instance.name", "foo2");
    try {
        foo1 = fooProvider.createComponentInstance(p1);
        foo2 = fooProvider.createComponentInstance(p2);
    } catch (Exception e) {
        fail("Cannot instantiate foo providers : " + e.getMessage());
    }
}
Also used : Factory(org.apache.felix.ipojo.Factory) Properties(java.util.Properties) Before(org.junit.Before)

Example 43 with Factory

use of org.apache.felix.ipojo.Factory in project felix by apache.

the class TestDelayedOptionalMultipleImport method setUp.

@Before
public void setUp() {
    Properties p = new Properties();
    p.put("instance.name", "importer");
    Factory compFact = ipojoHelper.getFactory("composite.requires.4");
    try {
        import4 = compFact.createComponentInstance(p);
    } catch (Exception e) {
        fail("Cannot instantiate the component : " + e.getMessage());
    }
    import4.stop();
    fooProvider = ipojoHelper.getFactory("COMPO-FooProviderType-1");
    assertNotNull("Check fooProvider availability", fooProvider);
    Properties p1 = new Properties();
    p1.put("instance.name", "foo1");
    Properties p2 = new Properties();
    p2.put("instance.name", "foo2");
    try {
        foo1 = fooProvider.createComponentInstance(p1);
        foo2 = fooProvider.createComponentInstance(p2);
    } catch (Exception e) {
        fail("Cannot instantiate foo providers : " + e.getMessage());
    }
}
Also used : Factory(org.apache.felix.ipojo.Factory) Properties(java.util.Properties) Before(org.junit.Before)

Example 44 with Factory

use of org.apache.felix.ipojo.Factory in project felix by apache.

the class TestDelayedSimpleImport method setUp.

@Before
public void setUp() {
    Properties p = new Properties();
    p.put("instance.name", "importer");
    Factory compFact = ipojoHelper.getFactory("composite.requires.1");
    try {
        import1 = compFact.createComponentInstance(p);
    } catch (Exception e) {
        fail("Cannot instantiate the component : " + e.getMessage());
    }
    import1.stop();
    fooProvider = ipojoHelper.getFactory("COMPO-FooProviderType-1");
    assertNotNull("Check fooProvider availability", fooProvider);
    Properties p1 = new Properties();
    p1.put("instance.name", "foo1");
    Properties p2 = new Properties();
    p2.put("instance.name", "foo2");
    try {
        foo1 = fooProvider.createComponentInstance(p1);
        foo2 = fooProvider.createComponentInstance(p2);
    } catch (Exception e) {
        fail("Cannot instantiate foo providers : " + e.getMessage());
    }
}
Also used : Factory(org.apache.felix.ipojo.Factory) Properties(java.util.Properties) Before(org.junit.Before)

Example 45 with Factory

use of org.apache.felix.ipojo.Factory in project felix by apache.

the class TestFilteredImport method setUp.

@Before
public void setUp() {
    Properties p = new Properties();
    p.put("instance.name", "importer");
    Factory compFact = ipojoHelper.getFactory("composite.requires.5");
    try {
        import1 = compFact.createComponentInstance(p);
    } catch (Exception e) {
        fail("Cannot instantiate the component : " + e.getMessage());
    }
    import1.stop();
    fooProvider = ipojoHelper.getFactory("COMPO-FooProviderType-1");
    assertNotNull("Check fooProvider availability", fooProvider);
    fooProvider2 = ipojoHelper.getFactory("COMPO-FooProviderType-2");
    assertNotNull("Check fooProvider availability", fooProvider2);
    Properties p1 = new Properties();
    p1.put("instance.name", "foo1");
    Properties p2 = new Properties();
    p2.put("instance.name", "foo2");
    try {
        foo1 = fooProvider.createComponentInstance(p1);
        foo2 = fooProvider2.createComponentInstance(p2);
    } catch (Exception e) {
        fail("Cannot instantiate foo providers : " + e.getMessage());
    }
}
Also used : Factory(org.apache.felix.ipojo.Factory) Properties(java.util.Properties) Before(org.junit.Before)

Aggregations

Factory (org.apache.felix.ipojo.Factory)111 Properties (java.util.Properties)88 Test (org.junit.Test)71 ComponentInstance (org.apache.felix.ipojo.ComponentInstance)53 Before (org.junit.Before)33 ServiceReference (org.osgi.framework.ServiceReference)29 FooService (org.apache.felix.ipojo.runtime.core.services.FooService)17 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)17 ComponentFactory (org.apache.felix.ipojo.ComponentFactory)14 ServiceContext (org.apache.felix.ipojo.ServiceContext)13 CheckService (org.apache.felix.ipojo.runtime.core.services.CheckService)11 IOException (java.io.IOException)6 HandlerFactory (org.apache.felix.ipojo.HandlerFactory)6 Architecture (org.apache.felix.ipojo.architecture.Architecture)4 HandlerDescription (org.apache.felix.ipojo.architecture.HandlerDescription)4 InstanceDescription (org.apache.felix.ipojo.architecture.InstanceDescription)4 CompositeInstanceDescription (org.apache.felix.ipojo.composite.CompositeInstanceDescription)4 CompositeManager (org.apache.felix.ipojo.composite.CompositeManager)4 ProvidedServiceDescription (org.apache.felix.ipojo.handlers.providedservice.ProvidedServiceDescription)4 ProvidedServiceHandlerDescription (org.apache.felix.ipojo.handlers.providedservice.ProvidedServiceHandlerDescription)4