Package org.apache.felix.ipojo

Examples of org.apache.felix.ipojo.Factory


  private ComponentFactory bar1Factory;
  private ComponentInstance empty;
 
  public void setUp() {
    bar1Factory = (ComponentFactory) Utils.getFactoryByName(getContext(), "composite.bar.3");
    Factory fact = Utils.getFactoryByName(getContext(), "composite.empty");
    Properties props = new Properties();
    props.put("instance.name","empty");
    try {
      empty = fact.createComponentInstance(props);
    } catch(Exception e) {
      fail("Cannot create the empty composite : " + e.getMessage());
    }
  }
View Full Code Here


    fooProvider = Utils.getFactoryByName(getContext(), "COMPO-FooProviderType-1");
    assertNotNull("Check fooProvider availability", fooProvider);
   
    Properties p = new Properties();
    p.put("instance.name","importer");
    Factory compFact = Utils.getFactoryByName(getContext(), "composite.requires.1");
    try {
      import1 = compFact.createComponentInstance(p);
    } catch(Exception e) {
        e.printStackTrace();
      fail("Cannot instantiate the component : " + e.getMessage());
    }
  }
View Full Code Here

  public void setUp() {
   
    Properties p = new Properties();
    p.put("instance.name","importer");
    Factory compFact = Utils.getFactoryByName(getContext(), "composite.requires.2");
    try {
      import2 = compFact.createComponentInstance(p);
    } catch(Exception e) {
      fail("Cannot instantiate the component : " + e.getMessage());
    }
   
    import2.stop();
View Full Code Here

    ComponentInstance instance2;
   
    ComponentInstance instance3;

    public void setUp() {
        Factory fact = Utils.getFactoryByName(getContext(), "CONFIG-MethodConfigurableCheckService");
        Properties props = new Properties();
        props.put("instance.name","under-test");
        props.put("b", "1");
        props.put("s", "1");
        props.put("i", "1");
        props.put("l", "1");
        props.put("d", "1");
        props.put("f", "1");
        props.put("c", "a");
        props.put("bool", "true");
        props.put("bs", "{1,2,3}");
        props.put("ss", "{1,2,3}");
        props.put("is", "{1,2,3}");
        props.put("ls", "{1,2,3}");
        props.put("ds", "{1,2,3}");
        props.put("fs", "{1,2,3}");
        props.put("cs", "{a,b,c}");
        props.put("bools", "{true,true,true}");
        props.put("string", "foo");
        props.put("strings", "{foo, bar, baz}");
       
        try {
            instance = fact.createComponentInstance(props);
        } catch(Exception e) {
           fail("Cannot create the under-test instance : " + e.getMessage());
        }
       
        Properties props2 = new Properties();
        props2.put("instance.name","under-test-2");
        props2.put("b", new Byte("1"));
        props2.put("s", new Short("1"));
        props2.put("i", new Integer("1"));
        props2.put("l", new Long("1"));
        props2.put("d", new Double("1"));
        props2.put("f", new Float("1"));
        props2.put("c", new Character('a'));
        props2.put("bool", new Boolean(true));
        props2.put("bs", new byte[] {1,2,3});
        props2.put("ss", new short[] {1,2,3});
        props2.put("is", new int[] {1,2,3});
        props2.put("ls", new long[] {1,2,3});
        props2.put("ds", new double[] {1,2,3});
        props2.put("fs", new float[] {1,2,3});
        props2.put("cs", new char[] {'a','b','c'});
        props2.put("bools", new boolean[] {true,true,true});
        props2.put("string", "foo");
        props2.put("strings", new String[] {"foo", "bar", "baz"});
       
        try {
            instance2 = fact.createComponentInstance(props2);
        } catch(Exception e) {
           e.printStackTrace();
           fail("Cannot create the under-test instance 2 : " + e.getMessage());
        }
       
        try {
            instance3 = fact.createComponentInstance(null);
        } catch(Exception e) {
           e.printStackTrace();
           fail("Cannot create the under-test instance 3 : " + e.getMessage());
        }
       
View Full Code Here

            return null;
        }
    }

    public static ComponentInstance getComponentInstance(BundleContext bc, String factoryName, Dictionary configuration) {
        Factory fact = getFactoryByName(bc, factoryName);

        if (fact == null) {
            System.err.println("Factory " + factoryName + " not found");
            return null;
        }

        // if(fact.isAcceptable(configuration)) {
        try {
            return fact.createComponentInstance(configuration);
        } catch (Exception e) {
            e.printStackTrace();
         
            Assert.fail("Cannot create the instance from " + factoryName + " : " + e.getMessage());
View Full Code Here

        // return null;
        // }
    }

    public static ComponentInstance getComponentInstanceByName(BundleContext bc, String factoryName, String name) {
        Factory fact = getFactoryByName(bc, factoryName);

        if (fact == null) {
            System.err.println("Factory " + factoryName + " not found");
            return null;
        }

        try {
            Properties props = new Properties();
            props.put("instance.name",name);
            return fact.createComponentInstance(props);
        } catch (Exception e) {
            System.err.println("Cannot create the instance from " + factoryName + " : " + e.getMessage());
            e.printStackTrace();
            return null;
        }
View Full Code Here

            return null;
        }
    }

    public static ComponentInstance getComponentInstance(ServiceContext bc, String factoryName, Dictionary configuration) {
        Factory fact = getFactoryByName(bc, factoryName);

        if (fact == null) { return null; }

        if (fact.isAcceptable(configuration)) {
            try {
                return fact.createComponentInstance(configuration);
            } catch (Exception e) {
                System.err.println(e.getMessage());
                e.printStackTrace();
                return null;
            }
View Full Code Here

public class TestSuperMethodProperties extends OSGiTestCase {
   
    ComponentInstance instance;

    public void setUp() {
        Factory fact = Utils.getFactoryByName(getContext(), "CONFIG-ParentMethodConfigurableCheckService");
        Properties props = new Properties();
        props.put("instance.name","under-test");
        props.put("b", "1");
        props.put("s", "1");
        props.put("i", "1");
        props.put("l", "1");
        props.put("d", "1");
        props.put("f", "1");
        props.put("c", "a");
        props.put("bool", "true");
        props.put("bs", "{1,2,3}");
        props.put("ss", "{1,2,3}");
        props.put("is", "{1,2,3}");
        props.put("ls", "{1,2,3}");
        props.put("ds", "{1,2,3}");
        props.put("fs", "{1,2,3}");
        props.put("cs", "{a,b,c}");
        props.put("bools", "{true,true,true}");
        props.put("string", "foo");
        props.put("strings", "{foo, bar, baz}");
       
        try {
            instance = fact.createComponentInstance(props);
        } catch (Exception e) {
           fail("Cannot create the under-test instance : " + e.getMessage());
        }
       
       
View Full Code Here

public class TestPropertyModifier extends OSGiTestCase {
   
    public void testPropertyModifier() {
        ComponentInstance ci = null;
        Factory factory =  Utils.getFactoryByName(getContext(), "org.apache.felix.ipojo.test.scenarios.component.PropertyModifier");
        Properties props = new Properties();
        props.put("cls", new String[] {FooService.class.getName()});
        try {
            ci = factory.createComponentInstance(props);
        } catch (Exception e) {
            fail(e.getMessage());
        }
       
        ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), ci.getInstanceName());
View Full Code Here

   
    ComponentInstance instance;
    ComponentInstance instance2;
   
    public void setUp() {
        Factory fact = Utils.getFactoryByName(getContext(), "CONFIG-FieldConfigurableCheckService");
        Properties props = new Properties();
        props.put("instance.name","under-test");
        props.put("b", "1");
        props.put("s", "1");
        props.put("i", "1");
        props.put("l", "1");
        props.put("d", "1");
        props.put("f", "1");
        props.put("c", "a");
        props.put("bool", "true");
        props.put("bs", "{1,2,3}");
        props.put("ss", "{1,2,3}");
        props.put("is", "{1,2,3}");
        props.put("ls", "{1,2,3}");
        props.put("ds", "{1,2,3}");
        props.put("fs", "{1,2,3}");
        props.put("cs", "{a,b,c}");
        props.put("bools", "{true,true,true}");
        props.put("string", "foo");
        props.put("strings", "{foo, bar, baz}");
       
        try {
            instance = fact.createComponentInstance(props);
        } catch(Exception e) {
           fail("Cannot create the under-test instance : " + e.getMessage());
        }
       
        try {
            instance2 = fact.createComponentInstance(null);
        } catch (Exception e) {
            e.printStackTrace();
            fail("Cannot create the instance : " + e.getMessage());

        }
View Full Code Here

TOP

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

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.