Search in sources :

Example 6 with IAnnotationFinder

use of org.apache.xbean.finder.IAnnotationFinder in project tomee by apache.

the class DeploymentLoader method addWebModule.

public static EjbModule addWebModule(final WebModule webModule, final AppModule appModule) throws OpenEJBException {
    // create and add the WebModule
    appModule.getWebModules().add(webModule);
    if (appModule.isStandaloneModule()) {
        appModule.getAdditionalLibraries().addAll(webModule.getUrls());
    }
    {
        final Object pXml = appModule.getAltDDs().get("persistence.xml");
        List<URL> persistenceXmls = pXml == null ? null : (List.class.isInstance(pXml) ? (List<URL>) pXml : new ArrayList<>(asList(URL.class.cast(pXml))));
        if (persistenceXmls == null) {
            persistenceXmls = new ArrayList<>();
            appModule.getAltDDs().put("persistence.xml", persistenceXmls);
        }
        final Object o = webModule.getAltDDs().get("persistence.xml");
        if (o instanceof URL) {
            final URL url = (URL) o;
            persistenceXmls.add(url);
        }
        if (o instanceof List) {
            final List<URL> urls = (List<URL>) o;
            persistenceXmls.addAll(urls);
        }
    }
    // Per the Spec version of the Collapsed EAR there
    // aren't individual EjbModules inside a war.
    // The war itself is one big EjbModule if certain
    // conditions are met.  These conditions are different
    // than an ear file, so the ear-style code we were previously
    // using doesn't exactly work anymore.
    final EjbModule webEjbModule = new EjbModule(webModule.getClassLoader(), webModule.getModuleId(), webModule.getJarLocation(), null, null);
    webEjbModule.setWebapp(true);
    webEjbModule.getAltDDs().putAll(webModule.getAltDDs());
    appModule.getEjbModules().add(webEjbModule);
    try {
        // TODO:  Put our scanning ehnancements back, here
        fillEjbJar(webModule, webEjbModule);
        if (webModule.getFinder() == null) {
            if (isMetadataComplete(webModule, webEjbModule)) {
                final IAnnotationFinder finder = new org.apache.xbean.finder.AnnotationFinder(new ClassesArchive());
                webModule.setFinder(finder);
                webEjbModule.setFinder(finder);
            } else {
                final IAnnotationFinder finder = FinderFactory.createFinder(webModule);
                webModule.setFinder(finder);
                webEjbModule.setFinder(finder);
            }
        } else if (webEjbModule.getFinder() == null) {
            webEjbModule.setFinder(webModule.getFinder());
        }
    } catch (final Exception e) {
        throw new OpenEJBException("Unable to create annotation scanner for web module " + webModule.getModuleId(), e);
    }
    addWebservices(webEjbModule);
    return webEjbModule;
}
Also used : OpenEJBException(org.apache.openejb.OpenEJBException) IAnnotationFinder(org.apache.xbean.finder.IAnnotationFinder) ArrayList(java.util.ArrayList) ClassesArchive(org.apache.xbean.finder.archive.ClassesArchive) Arrays.asList(java.util.Arrays.asList) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) URL(java.net.URL) IAnnotationFinder(org.apache.xbean.finder.IAnnotationFinder) AnnotationFinder(org.apache.openejb.util.AnnotationFinder) OpenEJBException(org.apache.openejb.OpenEJBException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Aggregations

IAnnotationFinder (org.apache.xbean.finder.IAnnotationFinder)6 URL (java.net.URL)5 ArrayList (java.util.ArrayList)5 IOException (java.io.IOException)3 LinkedList (java.util.LinkedList)3 List (java.util.List)3 OpenejbJar (org.apache.openejb.jee.oejb3.OpenejbJar)3 AnnotationFinder (org.apache.xbean.finder.AnnotationFinder)3 ClassesArchive (org.apache.xbean.finder.archive.ClassesArchive)3 File (java.io.File)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 MalformedURLException (java.net.MalformedURLException)2 Arrays.asList (java.util.Arrays.asList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 OpenEJBException (org.apache.openejb.OpenEJBException)2 EjbModule (org.apache.openejb.config.EjbModule)2 WebModule (org.apache.openejb.config.WebModule)2 Beans (org.apache.openejb.jee.Beans)2 EjbJar (org.apache.openejb.jee.EjbJar)2