Search in sources :

Example 1 with Extensions

use of org.apache.openejb.Extensions in project tomee by apache.

the class ConfigurationFactory method configureApplication.

public AppInfo configureApplication(final AppModule appModule) throws OpenEJBException {
    try {
        final Collection<Class<?>> extensions = new HashSet<>();
        final Collection<String> notLoaded = new HashSet<>();
        final List<URL> libs = appModule.getAdditionalLibraries();
        if (libs != null && libs.size() > 0) {
            final Extensions.Finder finder = new Extensions.Finder("META-INF", false, libs.toArray(new URL[libs.size()]));
            extensions.addAll(Extensions.findExtensions(finder));
            notLoaded.addAll(finder.getResourcesNotLoaded());
        }
        for (final EjbModule ejb : appModule.getEjbModules()) {
            try {
                final URI uri = ejb.getModuleUri();
                if (uri.isAbsolute()) {
                    final URL url = uri.toURL();
                    if (libs != null && !libs.contains(url)) {
                        final Extensions.Finder finder = new Extensions.Finder("META-INF", false, url);
                        extensions.addAll(Extensions.findExtensions(finder));
                        notLoaded.addAll(finder.getResourcesNotLoaded());
                    }
                }
            } catch (final IllegalArgumentException | MalformedURLException iae) {
                logger.debug("can't look for server event listener for module " + ejb.getModuleUri(), iae);
            } catch (final Exception e) {
                logger.error("can't look for server event listener for module " + ejb.getJarLocation());
            }
        }
        for (final WebModule web : appModule.getWebModules()) {
            final List<URL> webLibs = web.getScannableUrls();
            if (webLibs != null && webLibs.size() > 0) {
                final Extensions.Finder finder = new Extensions.Finder("META-INF", false, webLibs.toArray(new URL[webLibs.size()]));
                extensions.addAll(Extensions.findExtensions(finder));
                notLoaded.addAll(finder.getResourcesNotLoaded());
            }
        }
        // add it as early as possible, the ones needing the app classloader will be added later
        Extensions.addExtensions(extensions);
        final String location = appModule.getJarLocation();
        logger.info("config.configApp", null != location ? location : appModule.getModuleId());
        deployer.deploy(appModule);
        final AppInfoBuilder appInfoBuilder = new AppInfoBuilder(this);
        final AppInfo info = appInfoBuilder.build(appModule);
        info.eventClassesNeedingAppClassloader.addAll(notLoaded);
        return info;
    } finally {
        destroy(appModule.getEarLibFinder());
        for (final EjbModule ejb : appModule.getEjbModules()) {
            destroy(ejb.getFinder());
        }
        for (final WebModule web : appModule.getWebModules()) {
            destroy(web.getFinder());
        }
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) ParentClassLoaderFinder(org.apache.openejb.core.ParentClassLoaderFinder) IAnnotationFinder(org.apache.xbean.finder.IAnnotationFinder) Extensions(org.apache.openejb.Extensions) URI(java.net.URI) URL(java.net.URL) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) OpenEJBException(org.apache.openejb.OpenEJBException) MalformedURLException(java.net.MalformedURLException) AppInfo(org.apache.openejb.assembler.classic.AppInfo) WebAppInfo(org.apache.openejb.assembler.classic.WebAppInfo) MetaAnnotatedClass(org.apache.xbean.finder.MetaAnnotatedClass) HashSet(java.util.HashSet)

Aggregations

IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 HashSet (java.util.HashSet)1 Extensions (org.apache.openejb.Extensions)1 OpenEJBException (org.apache.openejb.OpenEJBException)1 AppInfo (org.apache.openejb.assembler.classic.AppInfo)1 WebAppInfo (org.apache.openejb.assembler.classic.WebAppInfo)1 ParentClassLoaderFinder (org.apache.openejb.core.ParentClassLoaderFinder)1 IAnnotationFinder (org.apache.xbean.finder.IAnnotationFinder)1 MetaAnnotatedClass (org.apache.xbean.finder.MetaAnnotatedClass)1