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

    }
   
    static Class<?> getClassForMetaData(BlueprintContainer container, ComponentMetadata cmd) {
        Class<?> cls = null;
        if (cmd instanceof BeanMetadata) {
            BeanMetadata bm = (BeanMetadata)cmd;
            if (bm instanceof ExtendedBeanMetadata) {
                cls = ((ExtendedBeanMetadata)bm).getRuntimeClass();
            }
            if (cls == null && container instanceof ExtendedBlueprintContainer) {
                try {
                    cls = ((ExtendedBlueprintContainer)container).loadClass(bm.getClassName());
                } catch (ClassNotFoundException cnfe) {
                    //ignore
                }
            }
        }
View Full Code Here

    }

    public boolean hasConfiguredPropertyValue(String beanName, String propertyName, String value) {
        ComponentMetadata cmd = getComponentMetadata(beanName);
        if (cmd instanceof BeanMetadata) {
            BeanMetadata br = (BeanMetadata)cmd;
            for (BeanProperty s : br.getProperties()) {
                if (propertyName.equals(s.getName())) {
                    return true;
                }
            }
            return false;
View Full Code Here

        postConstructMethod = ResourceUtils.findPostConstructMethod(type);
        preDestroyMethod = ResourceUtils.findPreDestroyMethod(type);

        Object component = blueprintContainer.getComponentMetadata(beanId);
        if (component instanceof BeanMetadata) {
            BeanMetadata local = (BeanMetadata) component;
            isSingleton = BeanMetadata.SCOPE_SINGLETON.equals(local.getScope()) 
                || (local.getScope() == null && local.getId() != null);
        }
    }
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

        Set<String> ids = blueprintContainer.getComponentIds();
        for (String id: ids) {
            ComponentMetadata componentMetadata = blueprintContainer.getComponentMetadata(id);
            if ( componentMetadata instanceof BeanMetadata) {
                BeanMetadata metadata = (BeanMetadata)componentMetadata;
                if (KieObjectsFactoryBean.class.getName().equals(metadata.getClassName())) {
                    if ("fetchKBase".equalsIgnoreCase(metadata.getFactoryMethod())) {
                        BeanArgument kbRefArg = metadata.getArguments().get(0);
                        String kBaseName = ((MutableValueMetadata) kbRefArg.getValue()).getStringValue();
                        KieBaseModelImpl kBase = new KieBaseModelImpl();
                        kBase.setKModule(kieModuleModel);
                        kBase.setName(kBaseName);

                        BeanArgument kbOptionsArg = metadata.getArguments().get(2);
                        PassThroughMetadata passThroughMetadata = (PassThroughMetadata) kbOptionsArg.getValue();
                        KBaseOptions kBaseOptions = (KBaseOptions) passThroughMetadata.getObject();
                        String packages = kBaseOptions.getPackages();
                        if ( !kBaseOptions.getPackages().isEmpty()) {
                            for ( String pkg : packages.split( "," ) ) {
                                kBase.addPackage( pkg.trim() );
                            }
                        }

                        String includes = kBaseOptions.getIncludes();
                        if ( !includes.isEmpty() ) {
                            for ( String include : includes.split( "," ) ) {
                                kBase.addInclude( include.trim() );
                            }
                        }

                        String equalsBehavior = kBaseOptions.getEqualsBehavior();
                        if ( !equalsBehavior.isEmpty() ) {
                            kBase.setEqualsBehavior( EqualityBehaviorOption.determineEqualityBehavior(equalsBehavior) );
                        }

                        String eventProcessingMode = kBaseOptions.getEventProcessingMode();
                        if ( !eventProcessingMode.isEmpty() ) {
                            kBase.setEventProcessingMode( EventProcessingOption.determineEventProcessingMode(eventProcessingMode) );
                        }

                        String declarativeAgenda = kBaseOptions.getDeclarativeAgenda();
                        if ( !declarativeAgenda.isEmpty() ) {
                            kBase.setDeclarativeAgenda( DeclarativeAgendaOption.determineDeclarativeAgenda(declarativeAgenda) );
                        }

                        kieModuleModel.getRawKieBaseModels().put(kBase.getName(), kBase);

                        MutablePassThroughMetadata throughMetadata = parserContext.createMetadata(MutablePassThroughMetadata.class);
                        throughMetadata.setObject(releaseId);
                        ((MutableBeanArgument)metadata.getArguments().get(1)).setValue(throughMetadata);

                        addKieSessionModels(kBase);
                    }
                }
            }
View Full Code Here

    private void addKieSessionModels(KieBaseModelImpl kieBaseModel) {
        Set<String> ids = blueprintContainer.getComponentIds();
        for (String id: ids) {
            ComponentMetadata componentMetadata = blueprintContainer.getComponentMetadata(id);
            if ( componentMetadata instanceof BeanMetadata) {
                BeanMetadata metadata = (BeanMetadata)componentMetadata;
                if (KieObjectsFactoryBean.class.getName().equals(metadata.getClassName())) {
                    if ("createKieSession".equalsIgnoreCase(metadata.getFactoryMethod())){
                        BeanArgument beanArgument = metadata.getArguments().get(0);
                        String ksessionName = ((MutableValueMetadata)beanArgument.getValue()).getStringValue();

                        BeanArgument kbOptionsArg = metadata.getArguments().get(5);
                        PassThroughMetadata passThroughMetadata = (PassThroughMetadata) kbOptionsArg.getValue();
                        KSessionOptions kSessionOptions = (KSessionOptions) passThroughMetadata.getObject();
                        String type = kSessionOptions.getType();
                        String kbaseRef = kSessionOptions.getkBaseRef();

                        if( kbaseRef.equalsIgnoreCase(kieBaseModel.getName())) {
                            KieSessionModelImpl kSession = new KieSessionModelImpl(kieBaseModel, ksessionName);
                            kSession.setType(type != null ? KieSessionModel.KieSessionType.valueOf(type.toUpperCase()) : KieSessionModel.KieSessionType.STATEFUL);

                            kSession.setDefault( "true".equals( kSessionOptions.getDef() ) );
                            String clockType = kSessionOptions.getClockType();
                            if ( clockType != null && !clockType.isEmpty() ) {
                                kSession.setClockType( ClockTypeOption.get(clockType) );
                            }
                            String scope = kSessionOptions.getScope();
                            if ( scope !=null && !scope.isEmpty() ) {
                                kSession.setScope( scope.trim() );
                            }
                            Map<String, KieSessionModel> rawKieSessionModels = kieBaseModel.getRawKieSessionModels();
                            rawKieSessionModels.put(kSession.getName(), kSession);

                            MutablePassThroughMetadata throughMetadata = parserContext.createMetadata(MutablePassThroughMetadata.class);
                            throughMetadata.setObject(releaseId);
                            ((MutableBeanArgument)metadata.getArguments().get(1)).setValue(throughMetadata);
                        }
                    }
                }
            }
        }
View Full Code Here

     */
    private void traverseComponent(ComponentMetadata component, Set<ComponentMetadata> output) {
        if (!!!output.add(component)) return;
       
        if (component instanceof BeanMetadata) {
            BeanMetadata bean = (BeanMetadata) component;
           
            traverse(bean.getFactoryComponent(), output);

            for (BeanArgument argument : bean.getArguments()) {
                traverse(argument.getValue(), output);
            }
           
            for (BeanProperty property : bean.getProperties()) {
                traverse(property.getValue(), output);
            }
           
        } else if (component instanceof ServiceMetadata) {
            ServiceMetadata service = (ServiceMetadata) component;
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.