Search in sources :

Example 1 with ApplicationComposer

use of org.apache.openejb.api.configuration.ApplicationComposer in project tomee by apache.

the class ApplicationComposerDeployer method deploy.

@Override
public AppModule deploy(final AppModule appModule) throws OpenEJBException {
    if (!appModule.isStandaloneModule()) {
        return appModule;
    }
    for (final EjbModule ejbModule : appModule.getEjbModules()) {
        if (ejbModule.getFinder() == null) {
            continue;
        }
        WebModule webModule = null;
        for (final WebModule web : appModule.getWebModules()) {
            if (!web.getModuleId().equals(ejbModule.getModuleId())) {
                continue;
            }
            webModule = web;
            break;
        }
        if (webModule == null) {
            continue;
        }
        for (final Class<?> clazz : ejbModule.getFinder().findAnnotatedClasses(ApplicationComposer.class)) {
            final ApplicationComposer applicationComposer = clazz.getAnnotation(ApplicationComposer.class);
            final Descriptor descriptor = clazz.getAnnotation(Descriptor.class);
            if (descriptor != null) {
                configureDescriptor(appModule, descriptor);
            }
            final Descriptors descriptors = clazz.getAnnotation(Descriptors.class);
            if (descriptors != null) {
                for (final Descriptor d : descriptors.value()) {
                    configureDescriptor(appModule, descriptor);
                }
            }
            final Classes classes = clazz.getAnnotation(Classes.class);
            if (classes != null) {
                configureClasses(webModule, ejbModule, applicationComposer, classes);
            }
            Object instance = null;
            final AnnotationFinder finder = new AnnotationFinder(new ClassesArchive(org.apache.openejb.util.Classes.ancestors(clazz)));
            for (final Method m : finder.findAnnotatedMethods(org.apache.openejb.testing.Module.class)) {
                instance = configureModule(appModule, ejbModule, clazz, instance, m);
            }
            for (final Method m : finder.findAnnotatedMethods(Configuration.class)) {
                instance = configureConfiguration(appModule, clazz, instance, m);
            }
            final JaxrsProviders jaxrsProviders = clazz.getAnnotation(JaxrsProviders.class);
            if (jaxrsProviders != null) {
                for (final Class<?> c : jaxrsProviders.value()) {
                    webModule.getJaxrsProviders().add(c.getName());
                }
            }
        }
    }
    return appModule;
}
Also used : Method(java.lang.reflect.Method) JaxrsProviders(org.apache.openejb.testing.JaxrsProviders) ApplicationComposer(org.apache.openejb.api.configuration.ApplicationComposer) ClassesArchive(org.apache.xbean.finder.archive.ClassesArchive) Descriptor(org.apache.openejb.testing.Descriptor) Descriptors(org.apache.openejb.testing.Descriptors) AnnotationFinder(org.apache.xbean.finder.AnnotationFinder) Classes(org.apache.openejb.testing.Classes)

Aggregations

Method (java.lang.reflect.Method)1 ApplicationComposer (org.apache.openejb.api.configuration.ApplicationComposer)1 Classes (org.apache.openejb.testing.Classes)1 Descriptor (org.apache.openejb.testing.Descriptor)1 Descriptors (org.apache.openejb.testing.Descriptors)1 JaxrsProviders (org.apache.openejb.testing.JaxrsProviders)1 AnnotationFinder (org.apache.xbean.finder.AnnotationFinder)1 ClassesArchive (org.apache.xbean.finder.archive.ClassesArchive)1