Examples of BlueprintContainer


Examples of org.osgi.service.blueprint.container.BlueprintContainer

        Bundle bundle = context().getBundleByName("org.apache.aries.blueprint.sample");
        assertNotNull(bundle);
        bundle.start();

        BlueprintContainer blueprintContainer = Helper.getBlueprintContainerForBundle(context(), "org.apache.aries.blueprint.sample");
        assertNotNull(blueprintContainer);

        Thread.sleep(5000);
    }
View Full Code Here

Examples of org.osgi.service.blueprint.container.BlueprintContainer

@RunWith(JUnit4TestRunner.class)
public class TestReferences extends AbstractIntegrationTest {

    @Test
    public void testUnaryReference() throws Exception {
        BlueprintContainer blueprintContainer = Helper.getBlueprintContainerForBundle(context(), "org.apache.aries.blueprint.sample");
        assertNotNull(blueprintContainer);

        BindingListener listener = (BindingListener) blueprintContainer.getComponentInstance("bindingListener");
        assertNull(listener.getA());
        assertNull(listener.getReference());

        InterfaceA a = (InterfaceA) blueprintContainer.getComponentInstance("ref2");
        try {
            a.hello("world");
            fail("A ServiceUnavailableException should have been thrown");
        } catch (ServiceUnavailableException e) {
            // Ignore, expected
View Full Code Here

Examples of org.osgi.service.blueprint.container.BlueprintContainer

        }
    }

    @Test
    public void testListReferences() throws Exception {
        BlueprintContainer blueprintContainer = Helper.getBlueprintContainerForBundle(context(), "org.apache.aries.blueprint.sample");
        assertNotNull(blueprintContainer);

        BindingListener listener = (BindingListener) blueprintContainer.getComponentInstance("listBindingListener");
        assertNull(listener.getA());
        assertNull(listener.getReference());

        List refs = (List) blueprintContainer.getComponentInstance("ref-list");
        assertNotNull(refs);
        assertTrue(refs.isEmpty());

        ServiceRegistration reg1 = bundleContext.registerService(InterfaceA.class.getName(), new InterfaceA() {
            public String hello(String msg) {
View Full Code Here

Examples of org.osgi.service.blueprint.container.BlueprintContainer

    }
   
    @Test
    public void testDefaultReference() throws Exception {
      BlueprintContainer blueprintContainer = Helper.getBlueprintContainerForBundle(context(), "org.apache.aries.blueprint.sample");
      assertNotNull(blueprintContainer);

      Runnable refRunnable = (Runnable) blueprintContainer.getComponentInstance("refWithDefault");
      DefaultRunnable defaultRunnable = (DefaultRunnable) blueprintContainer.getComponentInstance("defaultRunnable");
      refRunnable.run();
     
      assertEquals("The default runnable was not called", 1, defaultRunnable.getCount());
     
      Runnable mockService = Skeleton.newMock(Runnable.class);
View Full Code Here

Examples of org.osgi.service.blueprint.container.BlueprintContainer

   
    @Test
    public void testReferencesCallableInDestroy() throws Exception {
      bundleContext.registerService(Runnable.class.getName(), new Thread(), null);
     
      BlueprintContainer blueprintContainer = Helper.getBlueprintContainerForBundle(context(), "org.apache.aries.blueprint.sample");
      assertNotNull(blueprintContainer);
     
      DestroyTest dt = (DestroyTest) blueprintContainer.getComponentInstance("destroyCallingReference");
     
      Bundle b = findBundle("org.apache.aries.blueprint.sample");
      assertNotNull(b);
      b.stop();
     
View Full Code Here

Examples of org.osgi.service.blueprint.container.BlueprintContainer

                    mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint").noStart())
        );
    }
   
    public static void testBlueprintContainer(RichBundleContext context, Bundle bundle) throws Exception {
        BlueprintContainer blueprintContainer = getBlueprintContainerForBundle(context, "org.apache.aries.blueprint.sample");
        assertNotNull(blueprintContainer);

        Object obj = blueprintContainer.getComponentInstance("bar");
        assertNotNull(obj);
        assertEquals(Bar.class, obj.getClass());
        Bar bar = (Bar) obj;
        assertNotNull(bar.getContext());
        assertEquals("Hello FooBar", bar.getValue());
        assertNotNull(bar.getList());
        assertEquals(2, bar.getList().size());
        assertEquals("a list element", bar.getList().get(0));
        assertEquals(Integer.valueOf(5), bar.getList().get(1));
        obj = blueprintContainer.getComponentInstance("foo");
        assertNotNull(obj);
        assertEquals(Foo.class, obj.getClass());
        Foo foo = (Foo) obj;
        assertEquals(5, foo.getA());
        assertEquals(10, foo.getB());
        assertSame(bar, foo.getBar());
        assertEquals(Currency.getInstance("PLN"), foo.getCurrency());
        assertEquals(new SimpleDateFormat("yyyy.MM.dd").parse("2009.04.17"),
                foo.getDate());

        assertTrue(foo.isInitialized());
        assertFalse(foo.isDestroyed());

        obj = context.getService(Foo.class);
        assertNotNull(obj);
        assertEquals(obj, foo);
       
        obj = blueprintContainer.getComponentInstance("accountOne");
        assertNotNull(obj);
        Account account = (Account)obj;
        assertEquals(1, account.getAccountNumber());
    
        obj = blueprintContainer.getComponentInstance("accountTwo");
        assertNotNull(obj);
        account = (Account)obj;
        assertEquals(2, account.getAccountNumber());
       
        obj = blueprintContainer.getComponentInstance("accountThree");
        assertNotNull(obj);
        account = (Account)obj;
        assertEquals(3, account.getAccountNumber());
       
        obj = blueprintContainer.getComponentInstance("accountFactory");
        assertNotNull(obj);
        AccountFactory accountFactory = (AccountFactory)obj;
        assertEquals("account factory", accountFactory.getFactoryName());
       
        bundle.stop();
View Full Code Here

Examples of org.osgi.service.blueprint.container.BlueprintContainer

        }
        return serviceIds;
    }

    public String[] getComponentIds(long containerServiceId) {
        BlueprintContainer container = getBlueprintContainer(containerServiceId);
        return (String[]) container.getComponentIds().toArray(new String[0]);
    }
View Full Code Here

Examples of org.osgi.service.blueprint.container.BlueprintContainer

     * type could be Bean, Service, serviceReference (non-Javadoc)
     *
     * @see org.apache.aries.jmx.blueprint.BlueprintMetadataMBean#getComponentIdsByType(long, java.lang.String)
     */
    public String[] getComponentIdsByType(long containerServiceId, String type) {
        BlueprintContainer container = getBlueprintContainer(containerServiceId);
        Collection<? extends ComponentMetadata> components;
        if (type.equals(BlueprintMetadataMBean.SERVICE_METADATA)) {
            components = container.getMetadata(ServiceMetadata.class);
        } else if (type.equals(BlueprintMetadataMBean.BEAN_METADATA)) {
            components = container.getMetadata(BeanMetadata.class);
        } else if (type.equals(BlueprintMetadataMBean.SERVICE_REFERENCE_METADATA)) {
            components = container.getMetadata(ServiceReferenceMetadata.class);
        } else {
            throw new IllegalArgumentException("Unrecognized component type: " + type);
        }
        String ids[] = new String[components.size()];
        int i = 0;
View Full Code Here

Examples of org.osgi.service.blueprint.container.BlueprintContainer

        }
        return ids;
    }

    public CompositeData getComponentMetadata(long containerServiceId, String componentId) {
        BlueprintContainer container = getBlueprintContainer(containerServiceId);
        ComponentMetadata componentMetadata = container.getComponentMetadata(componentId);
        BPMetadata metadata = Util.metadata2BPMetadata(componentMetadata);
        return metadata.asCompositeData();
    }
View Full Code Here

Examples of org.osgi.service.blueprint.container.BlueprintContainer

@RunWith(JUnit4TestRunner.class)
public class TestReferences extends AbstractIntegrationTest {

    @Test
    public void testUnaryReference() throws Exception {
        BlueprintContainer blueprintContainer = getBlueprintContainerForBundle("org.apache.aries.blueprint.sample");
        assertNotNull(blueprintContainer);

        BindingListener listener = (BindingListener) blueprintContainer.getComponentInstance("bindingListener");
        assertNull(listener.getA());
        assertNull(listener.getReference());

        InterfaceA a = (InterfaceA) blueprintContainer.getComponentInstance("ref2");
        try {
            a.hello("world");
            fail("A ServiceUnavailableException should have been thrown");
        } catch (ServiceUnavailableException e) {
            // Ignore, expected
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.