Package org.osgi.service.blueprint.reflect

Examples of org.osgi.service.blueprint.reflect.BeanMetadata


        List<String> components = new ArrayList<String>();
        for (String name : componentDefinitionRegistry.getComponentDefinitionNames()) {
            ComponentMetadata component = componentDefinitionRegistry.getComponentDefinition(name);
            boolean eager = component.getActivation() == ComponentMetadata.ACTIVATION_EAGER;
            if (component instanceof BeanMetadata) {
                BeanMetadata local = (BeanMetadata) component;
                eager &= MetadataUtil.isSingletonScope(local);
            }
            if (eager) {
                components.add(name);
            }
View Full Code Here


        for (String id : ids) {
            try {
                ComponentMetadata metadata = blueprintContainer.getComponentMetadata(id);
                Class cl = null;
                if (metadata instanceof BeanMetadata) {
                    BeanMetadata beanMetadata = (BeanMetadata)metadata;
                    cl = bundle.loadClass(beanMetadata.getClassName());
                } else if (metadata instanceof ReferenceMetadata) {
                    ReferenceMetadata referenceMetadata = (ReferenceMetadata)metadata;
                    cl = bundle.loadClass(referenceMetadata.getInterface());
                }
                if (cl != null && type.isAssignableFrom(cl)) {
View Full Code Here

    /**
     * Allows for ignoring beans that are explicitly configured in the Spring XML files
     */
    protected boolean shouldIgnoreBean(Class<?> type) {
        for (Object metadataObject : blueprintContainer.getMetadata(BeanMetadata.class)) {
            BeanMetadata metadata = (BeanMetadata) metadataObject;
            if (BeanMetadata.SCOPE_SINGLETON.equals(metadata.getScope())) {
                Object bean = blueprintContainer.getComponentInstance(metadata.getId());
                if (type.isInstance(bean)) {
                    return true;
                }
            }
        }
View Full Code Here

        assertNotNull(registry);
        ComponentMetadata component = registry.getComponentDefinition("pojoA");
        assertNotNull(component);
        assertEquals("pojoA", component.getId());
        assertTrue(component instanceof BeanMetadata);
        BeanMetadata local = (BeanMetadata) component;
        List<String> deps = local.getDependsOn();
        assertNotNull(deps);
        assertEquals(2, deps.size());
        assertTrue(deps.contains("pojoB"));
        assertTrue(deps.contains("pojoC"));
        assertEquals("org.apache.aries.blueprint.pojos.PojoA", local.getClassName());
        List<BeanArgument> params = local.getArguments();
        assertNotNull(params);
        assertEquals(6, params.size());
        BeanArgument param = params.get(0);
        assertNotNull(param);
        assertEquals(-1, param.getIndex());
        assertNull(param.getValueType());
        assertNotNull(param.getValue());
        assertTrue(param.getValue() instanceof ValueMetadata);
        assertEquals("val0", ((ValueMetadata) param.getValue()).getStringValue());
        assertNull(((ValueMetadata) param.getValue()).getType());
        param = params.get(1);
        assertNotNull(param);
        assertEquals(-1, param.getIndex());
        assertNull(param.getValueType());
        assertNotNull(param.getValue());
        assertTrue(param.getValue() instanceof RefMetadata);
        assertEquals("val1", ((RefMetadata) param.getValue()).getComponentId());
        param = params.get(2);
        assertNotNull(param);
        assertEquals(-1, param.getIndex());
        assertNull(param.getValueType());
        assertNotNull(param.getValue());
        assertTrue(param.getValue() instanceof NullMetadata);
        param = params.get(3);
        assertNotNull(param);
        assertEquals(-1, param.getIndex());
        assertEquals("java.lang.String", param.getValueType());
        assertNotNull(param.getValue());
        assertTrue(param.getValue() instanceof ValueMetadata);
        assertEquals("val3", ((ValueMetadata) param.getValue()).getStringValue());
        assertNull(((ValueMetadata) param.getValue()).getType());
        param = params.get(4);
        assertNotNull(param);
        assertEquals(-1, param.getIndex());
        assertNull(param.getValueType());
        assertNotNull(param.getValue());
        assertTrue(param.getValue() instanceof CollectionMetadata);
        CollectionMetadata array = (CollectionMetadata) param.getValue();
        assertNull(array.getValueType());
        assertNotNull(array.getValues());
        assertEquals(3, array.getValues().size());
        assertTrue(array.getValues().get(0) instanceof ValueMetadata);
        assertTrue(array.getValues().get(1) instanceof ComponentMetadata);
        assertTrue(array.getValues().get(2) instanceof NullMetadata);
        param = params.get(5);
        assertNotNull(param);
        assertEquals(-1, param.getIndex());
        assertNull(param.getValueType());
        assertNotNull(param.getValue());
        assertTrue(param.getValue() instanceof RefMetadata);
        assertEquals("pojoB", ((RefMetadata) param.getValue()).getComponentId());
       
        assertEquals(null, local.getInitMethod());
        assertEquals(null, local.getDestroyMethod());
               
        // test pojoB
        ComponentMetadata pojoB = registry.getComponentDefinition("pojoB");
        assertNotNull(pojoB);
        assertEquals("pojoB", pojoB.getId());
        assertTrue(pojoB instanceof BeanMetadata);
        BeanMetadata pojoBLocal = (BeanMetadata) pojoB;
        assertEquals("initPojo", pojoBLocal.getInitMethod());
//        assertEquals("", pojoBLocal.getDestroyMethod());
       
        params = pojoBLocal.getArguments();
        assertNotNull(params);
        assertEquals(2, params.size());
        param = params.get(0);
        assertNotNull(param);
        assertEquals(1, param.getIndex());
View Full Code Here

        assertEquals("getVolatile", comp1.getOperation());
       
        metadata = registry.getComponentDefinition("barService");
        assertNotNull(metadata);
        assertTrue(metadata instanceof BeanMetadata);
        BeanMetadata comp2 = (BeanMetadata) metadata;
        assertEquals(1, comp2.getProperties().size());
        BeanProperty propertyMetadata = comp2.getProperties().get(0);
        assertEquals("localCache", propertyMetadata.getName());
        Metadata propertyValue = propertyMetadata.getValue();
        assertTrue(propertyValue instanceof BeanMetadata);
        BeanMetadata innerComp = (BeanMetadata) propertyValue;
        assertEquals("org.apache.aries.CacheProperty", innerComp.getClassName());
       
        metadata = registry.getComponentDefinition("myCache");
        assertNotNull(metadata);
        assertTrue(metadata instanceof BeanMetadata);
        BeanMetadata comp3 = (BeanMetadata) metadata;
        assertEquals("org.apache.aries.Cache", comp3.getClassName());        
    }
View Full Code Here

        }  
    }
   
    private Object runBeanProcPreInit(Object obj){
        String beanName = getName();
        BeanMetadata beanData = (BeanMetadata) blueprintContainer
          .getComponentDefinitionRegistry().getComponentDefinition(beanName);       
        List<BeanProcessor> processors = blueprintContainer.getProcessors(BeanProcessor.class);
       
        //The start link of the chain, that provides the
        //original, unprocessed bean to the head of the chain.
View Full Code Here

        }  
    }
   
    private Object runBeanProcPostInit(Object obj){
        String beanName = getName();
        BeanMetadata beanData = (BeanMetadata) blueprintContainer
          .getComponentDefinitionRegistry().getComponentDefinition(beanName);       
        List<BeanProcessor> processors = blueprintContainer.getProcessors(BeanProcessor.class);
       
        //The start link of the chain, that provides the
        //original, unprocessed bean to the head of the chain.
View Full Code Here

        List<String> components = new ArrayList<String>();
        for (String name : componentDefinitionRegistry.getComponentDefinitionNames()) {
            ComponentMetadata component = componentDefinitionRegistry.getComponentDefinition(name);
            boolean eager = component.getActivation() == ComponentMetadata.ACTIVATION_EAGER;
            if (component instanceof BeanMetadata) {
                BeanMetadata local = (BeanMetadata) component;
                eager &= MetadataUtil.isSingletonScope(local);
            }
            if (eager) {
                components.add(name);
            }
View Full Code Here

        }  
    }
   
    private Object runBeanProcPreInit(Object obj){
        String beanName = getName();
        BeanMetadata beanData = (BeanMetadata) blueprintContainer
          .getComponentDefinitionRegistry().getComponentDefinition(beanName);       
        List<BeanProcessor> processors = blueprintContainer.getProcessors(BeanProcessor.class);
       
        //The start link of the chain, that provides the
        //original, unprocessed bean to the head of the chain.
View Full Code Here

        }  
    }
   
    private Object runBeanProcPostInit(Object obj){
        String beanName = getName();
        BeanMetadata beanData = (BeanMetadata) blueprintContainer
          .getComponentDefinitionRegistry().getComponentDefinition(beanName);       
        List<BeanProcessor> processors = blueprintContainer.getProcessors(BeanProcessor.class);
       
        //The start link of the chain, that provides the
        //original, unprocessed bean to the head of the chain.
View Full Code Here

TOP

Related Classes of org.osgi.service.blueprint.reflect.BeanMetadata

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.