Examples of BundleAnnotationFinder


Examples of org.apache.xbean.finder.BundleAnnotationFinder

            final String webInfClassesFolder = moduleNamePrefix + "WEB-INF/classes/";
            final boolean webInfClassesScanRequired = bundle.getEntry(moduleNamePrefix + "WEB-INF/beans.xml") != null;

            //2. Scan annotations
            BundleAnnotationFinder bundleAnnotationFinder = new BundleAnnotationFinder(packageAdmin, bundle, new ResourceDiscoveryFilter() {

                @Override
                public boolean directoryDiscoveryRequired(String directory) {
                    return directory.equals(webInfClassesFolder) && webInfClassesScanRequired;
                }

                @Override
                public boolean rangeDiscoveryRequired(DiscoveryRange discoveryRange) {
                    return discoveryRange.equals(DiscoveryRange.BUNDLE_CLASSPATH);
                }

                @Override
                public boolean zipFileDiscoveryRequired(String jarFile) {
                    return annotationScanRequiredJarFiles.contains(jarFile);
                }
            });

            final List<Member> members = new ArrayList<Member>();



            final Class<? extends Annotation>[] annotation = new Class[]{
                    Produces.class,
                    EJB.class,
                    PersistenceContext.class,
                    PersistenceUnit.class,
                    Resource.class,
            };

            for (Class<? extends Annotation> annotationClass : annotation) {
                members.addAll(bundleAnnotationFinder.findAnnotatedMethods(annotationClass));
                members.addAll(bundleAnnotationFinder.findAnnotatedFields(annotationClass));

            }

            final Set<Class<?>> classes = new HashSet<Class<?>>();
            for (Member member : members) {
View Full Code Here

Examples of org.apache.xbean.finder.BundleAnnotationFinder

    @SuppressWarnings("unchecked")
    public static void mergeAnnotations(Bundle bundle, WebAppType webApp, MergeContext mergeContext, final String prefix) throws DeploymentException {
        final boolean isJarFile = prefix.endsWith(".jar");
        try {
            BundleAnnotationFinder bundleAnnotationFinder = new BundleAnnotationFinder(null, bundle, new ResourceDiscoveryFilter() {

                @Override
                public boolean directoryDiscoveryRequired(String url) {
                    return !isJarFile;
                }

                @Override
                public boolean rangeDiscoveryRequired(DiscoveryRange discoveryRange) {
                    return discoveryRange.equals(DiscoveryRange.BUNDLE_CLASSPATH);
                }

                @Override
                public boolean zipFileDiscoveryRequired(String url) {
                    return isJarFile ? url.equals(prefix) : false;
                }
            });
            List<Class> webServlets = bundleAnnotationFinder.findAnnotatedClasses(WebServlet.class);
            WEB_SERVLET_ANNOTATION_MERGE_HANDLER.merge(webServlets.toArray(new Class<?>[0]), webApp, mergeContext);
            List<Class> webFilters = bundleAnnotationFinder.findAnnotatedClasses(WebFilter.class);
            WEB_FILTER_ANNOTATION_MERGE_HANDLER.merge(webFilters.toArray(new Class<?>[0]), webApp, mergeContext);
            List<Class> webListeners = bundleAnnotationFinder.findAnnotatedClasses(WebListener.class);
            WEB_LISTENER_ANNOTATION_MERGE_HANDLER.merge(webListeners.toArray(new Class<?>[0]), webApp, mergeContext);
        } catch (Exception e) {
            throw new DeploymentException("Fail to merge annotations in " + prefix, e);
        }
    }
View Full Code Here

Examples of org.apache.xbean.finder.BundleAnnotationFinder

    public void initContext(EARContext earContext, Module module, Bundle bundle) throws DeploymentException {
        log.info("deploying bundle " + bundle + " at " + bundle.getLocation());
        ConnectorModule<ConnectorBase, XmlObject> resourceModule = (ConnectorModule<ConnectorBase, XmlObject>) module;

        BundleAnnotationFinder classFinder;
        try {
            classFinder = new BundleAnnotationFinder(packageAdmin, bundle);
        } catch (Exception e) {
            throw new DeploymentException("could not create class finder for rar bundle " + bundle, e);
        }

        ConnectorBase connector = resourceModule.getSpecDD();
View Full Code Here

Examples of org.apache.xbean.finder.BundleAnnotationFinder

        LOG.debug("Discovering web service classes");
       
        ServiceReference sr = bundle.getBundleContext().getServiceReference(PackageAdmin.class.getName());
        PackageAdmin packageAdmin = (PackageAdmin) bundle.getBundleContext().getService(sr);
        try {
            BundleAnnotationFinder classFinder = new BundleAnnotationFinder(packageAdmin, bundle);
            List<Class> classes = new ArrayList<Class>();
            classes.addAll(classFinder.findAnnotatedClasses(WebService.class));
            classes.addAll(classFinder.findAnnotatedClasses(WebServiceProvider.class));
            return classes;
        } catch (Exception e) {
            throw new DeploymentException("Error scanning for web service annotations in bundle", e);
        } finally {
            bundle.getBundleContext().ungetService(sr);
View Full Code Here

Examples of org.apache.xbean.finder.BundleAnnotationFinder

   
    public void buildNaming(XmlObject specDD, XmlObject plan, Module module, Map componentContext) throws DeploymentException {
                       
        Bundle bundle = module.getEarContext().getDeploymentBundle();
       
        BundleAnnotationFinder classFinder;
        try {
            classFinder = new BundleAnnotationFinder(packageAdmin, bundle);
        } catch (Exception e) {
            throw new DeploymentException("could not create class finder " + bundle, e);
        }
       
        AnnotatedApp app = module.getAnnotatedApp();
       
        // step 1: process annotations and update deployment descriptor
        List<Class> classes;       
        classes = classFinder.findAnnotatedClasses(DataSourceDefinitions.class);
        if (classes != null) {
            for (Class clazz : classes) {
                DataSourceDefinitions dsDefinitions = (DataSourceDefinitions) clazz.getAnnotation(DataSourceDefinitions.class);
                for (DataSourceDefinition dsDefinition : dsDefinitions.value()) {
                    processDefinition(dsDefinition, app);
                }
               
            }
        }
        classes = classFinder.findAnnotatedClasses(DataSourceDefinition.class);
        if (classes != null) {
            for (Class clazz : classes) {
                DataSourceDefinition dsDefinition = (DataSourceDefinition) clazz.getAnnotation(DataSourceDefinition.class);
                processDefinition(dsDefinition, app);
            }
View Full Code Here

Examples of org.apache.xbean.finder.BundleAnnotationFinder

    }

    private BundleAnnotationFinder createBundleAnnotationFinder(Bundle bundle) {
        ServiceReference sr = this.context.getServiceReference(PackageAdmin.class.getName());
        PackageAdmin pa = (PackageAdmin) this.context.getService(sr);
        BundleAnnotationFinder baf = null;
        try {
            baf = new BundleAnnotationFinder(pa, bundle);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
View Full Code Here

Examples of org.apache.xbean.finder.BundleAnnotationFinder

        marshaller.marshal(tblueprint, blueprintFile);

    }

    private Tblueprint generateBlueprintModel(Bundle bundle) {
        BundleAnnotationFinder baf = createBundleAnnotationFinder(bundle);

        // we don't trust baf when it comes to returning classes just once (ARIES-654)
        Set<Class> blueprintClasses = new LinkedHashSet<Class>(baf.findAnnotatedClasses(Blueprint.class));
        Set<Class> beanClasses = new HashSet<Class>(baf.findAnnotatedClasses(Bean.class));
        Set<Class> refListenerClasses = new HashSet<Class>(baf.findAnnotatedClasses(ReferenceListener.class));
        Set<Class> regListenerClasses = new HashSet<Class>(baf.findAnnotatedClasses(RegistrationListener.class));
        Map<String, TreferenceListener> reflMap = new HashMap<String, TreferenceListener>();
        Map<String, TregistrationListener> reglMap = new HashMap<String, TregistrationListener>();
       
        Tblueprint tblueprint = new Tblueprint();
       
View Full Code Here

Examples of org.apache.xbean.finder.BundleAnnotationFinder

    }

    private BundleAnnotationFinder createBundleAnnotationFinder(Bundle bundle) {
        ServiceReference sr = this.context.getServiceReference(PackageAdmin.class.getName());
        PackageAdmin pa = (PackageAdmin) this.context.getService(sr);
        BundleAnnotationFinder baf = null;
        try {
            baf = new BundleAnnotationFinder(pa, bundle);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
View Full Code Here

Examples of org.apache.xbean.finder.BundleAnnotationFinder

        marshaller.marshal(tblueprint, blueprintFile);

    }

    private Tblueprint generateBlueprintModel(Bundle bundle) {
        BundleAnnotationFinder baf = createBundleAnnotationFinder(bundle);

        List<Class> blueprintClasses = baf.findAnnotatedClasses(Blueprint.class);
        List<Class> beanClasses = baf.findAnnotatedClasses(Bean.class);
        List<Class> refListenerClasses = baf.findAnnotatedClasses(ReferenceListener.class);
        List<Class> regListenerClasses = baf.findAnnotatedClasses(RegistrationListener.class);
        Map<String, TreferenceListener> reflMap = new HashMap<String, TreferenceListener>();
        Map<String, TregistrationListener> reglMap = new HashMap<String, TregistrationListener>();
       
        Tblueprint tblueprint = new Tblueprint();
       
View Full Code Here

Examples of org.apache.xbean.finder.BundleAnnotationFinder

            boolean useLocation = location != null
                    && !location.isEmpty()
                    && !module.isStandaloneModule();
            Set<String> beanArchiveJarNames = findBeansXml(bundle, packageAdmin, useLocation? location : "");

            BundleAnnotationFinder bundleAnnotationFinder;
            if (useLocation) {
                ResourceDiscoveryFilter filter = new ResourceDiscoveryFilter() {

                    @Override
                    public boolean rangeDiscoveryRequired(DiscoveryRange discoveryRange) {
                        return discoveryRange == DiscoveryRange.BUNDLE_CLASSPATH || discoveryRange == DiscoveryRange.FRAGMENT_BUNDLES;
                    }

                    @Override
                    public boolean zipFileDiscoveryRequired(String s) {
                        return isWAR ? s.startsWith(location) : s.equals(location);
                    }

                    @Override
                    public boolean directoryDiscoveryRequired(String s) {
                        return isWAR ? s.startsWith(location) : s.equals(location);
                    }
                };

                bundleAnnotationFinder = new BundleAnnotationFinder(packageAdmin, bundle, filter, beanArchiveJarNames);
            } else {
                ResourceDiscoveryFilter filter = new ResourceDiscoveryFilter() {

                    @Override
                    public boolean rangeDiscoveryRequired(DiscoveryRange discoveryRange) {
                        return discoveryRange == DiscoveryRange.BUNDLE_CLASSPATH || discoveryRange == DiscoveryRange.FRAGMENT_BUNDLES;
                    }

                    @Override
                    public boolean zipFileDiscoveryRequired(String s) {
                        return true;
                    }

                    @Override
                    public boolean directoryDiscoveryRequired(String s) {
                        return true;
                    }
                };

                bundleAnnotationFinder = new BundleAnnotationFinder(packageAdmin, bundle, filter, beanArchiveJarNames);
            }
            bundleAnnotationFinder.link();
            return bundleAnnotationFinder;
        }

        throw new IllegalStateException("Module classloader is not a BundleReference. Only use BundleFactoryFinder in an pure osgi environment");
    }
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.