Examples of TemporaryClassLoader


Examples of org.apache.openejb.core.TemporaryClassLoader

        // replace any webservices with the webservice servlet
        // HACK: use a temp class loader because the class may have been loaded before
        // the openejb classes were added to the system class path so the WebService anntation
        // will not be present on the class
        TemporaryClassLoader tempClassLoader = new TemporaryClassLoader(standardContext.getLoader().getClassLoader());
        for (Container container : standardContext.findChildren()) {
            if (container instanceof Wrapper) {
                Wrapper wrapper = (Wrapper) container;
                String servletClass = wrapper.getServletClass();
                try {
                    Class<?> clazz = tempClassLoader.loadClass(servletClass);
                    if (JaxWsUtils.isWebService(clazz)) {
                        wrapper.setServletClass(WsServlet.class.getName());
                        if (getServlet(wrapper) != null) {
                            wrapper.load();
                            wrapper.unload();
View Full Code Here

Examples of org.apache.openejb.core.TemporaryClassLoader

            logger.error("Unable to load web.xml in war " + standardContext.getPath() + ": Exception: " + e.getMessage(), e);
        }

        // create the web module
        String basePath = new File(servletContext.getRealPath(".")).getParentFile().getAbsolutePath();
        ClassLoader classLoader = new TemporaryClassLoader(standardContext.getLoader().getClassLoader());
        String path = standardContext.getPath();
        System.out.println("context path = " + path);
        WebModule webModule = new WebModule(webApp, path, classLoader, basePath, getId(standardContext));
        webModule.setHost(standardContext.getHostname());
View Full Code Here

Examples of org.apache.openejb.core.TemporaryClassLoader

                }
            }
        }

        public ClassLoader getNewTempClassLoader(ClassLoader classLoader) {
            return new TemporaryClassLoader(classLoader);
        }
View Full Code Here

Examples of org.apache.openejb.core.TemporaryClassLoader

    private final Set<String> entries = new TreeSet<String>();
    private final AppInfo appInfo;

    public CmpJarBuilder(AppInfo appInfo, ClassLoader classLoader) {
        this.appInfo = appInfo;
        tempClassLoader = new TemporaryClassLoader(classLoader);
    }
View Full Code Here

Examples of org.apache.openejb.core.TemporaryClassLoader

            public void destroy(String unitId) {
            }

            public ClassLoader getNewTempClassLoader(ClassLoader classLoader) {
                return new TemporaryClassLoader(classLoader);
            }
        };

        PersistenceUnitInfoImpl unitInfo = new PersistenceUnitInfoImpl(persistenceClassLoaderHandler);
        unitInfo.setPersistenceUnitName("CMP");
View Full Code Here

Examples of org.apache.openejb.core.TemporaryClassLoader

                throw new OpenEJBException("Invalid application directory " + appDir.getAbsolutePath());
            }

            URL appUrl = getFileUrl(appDir);

            ClassLoader tmpClassLoader = new TemporaryClassLoader(new URL[]{appUrl}, OpenEJB.class.getClassLoader());

            ResourceFinder finder = new ResourceFinder("", tmpClassLoader, appUrl);

            Map<String, URL> appDescriptors;
            try {
                appDescriptors = finder.getResourcesMap("META-INF");
            } catch (IOException e) {
                throw new OpenEJBException("Unable to determine descriptors in jar: " + appUrl.toExternalForm(), e);
            }

            try {

                //
                // Find all the modules using either the application xml or by searching for all .jar, .war and .rar files.
                //

                Map<String, URL> ejbModules = new HashMap<String, URL>();
                Map<String, URL> clientModules = new HashMap<String, URL>();
                Map<String, URL> resouceModules = new HashMap<String, URL>();
                Map<String, URL> webModules = new HashMap<String, URL>();
                Map<String, String> webContextRoots = new HashMap<String, String>();

                URL applicationXmlUrl = appDescriptors.get("application.xml");

                Application application;
                if (applicationXmlUrl != null) {
                    application = unmarshal(Application.class, "application.xml", applicationXmlUrl);
                    for (Module module : application.getModule()) {
                        try {
                            if (module.getEjb() != null) {
                                URL url = finder.find(module.getEjb().trim());
                                ejbModules.put(module.getEjb(), url);
                            } else if (module.getJava() != null) {
                                URL url = finder.find(module.getJava().trim());
                                clientModules.put(module.getConnector(), url);
                            } else if (module.getConnector() != null) {
                                URL url = finder.find(module.getConnector().trim());
                                resouceModules.put(module.getConnector(), url);
                            } else if (module.getWeb() != null) {
                                URL url = finder.find(module.getWeb().getWebUri().trim());
                                webModules.put(module.getWeb().getWebUri(), url);
                                webContextRoots.put(module.getWeb().getWebUri(), module.getWeb().getContextRoot());
                            }
                        } catch (IOException e) {
                            throw new OpenEJBException("Invalid path to module " + e.getMessage(), e);
                        }
                    }
                } else {
                    application = new Application();
                    HashMap<String, URL> files = new HashMap<String, URL>();
                    scanDir(appDir, files, "");
                    files.remove("META-INF/MANIFEST.MF");
                    for (Map.Entry<String, URL> entry : files.entrySet()) {
                        if (entry.getKey().startsWith("lib/")) continue;
                        if (!entry.getKey().matches(".*\\.(jar|war|rar|ear)")) continue;

                        try {
                            ClassLoader moduleClassLoader = new TemporaryClassLoader(new URL[]{entry.getValue()}, tmpClassLoader);

                            Class moduleType = discoverModuleType(entry.getValue(), moduleClassLoader, true);
                            if (EjbModule.class.equals(moduleType)) {
                                ejbModules.put(entry.getKey(), entry.getValue());
                            } else if (ClientModule.class.equals(moduleType)) {
                                clientModules.put(entry.getKey(), entry.getValue());
                            } else if (ConnectorModule.class.equals(moduleType)) {
                                resouceModules.put(entry.getKey(), entry.getValue());
                            } else if (WebModule.class.equals(moduleType)) {
                                webModules.put(entry.getKey(), entry.getValue());
                            }
                        } catch (UnsupportedOperationException e) {
                            // Ignore it as per the javaee spec EE.8.4.2 section 1.d.iiilogger.info("Ignoring unknown module type: "+entry.getKey());
                        } catch (Exception e) {
                            throw new OpenEJBException("Unable to determine the module type of " + entry.getKey() + ": Exception: " + e.getMessage(), e);
                        }
                    }
                }

                //
                // Create a class loader for the application
                //

                // lib/*
                if (application.getLibraryDirectory() == null) {
                    application.setLibraryDirectory("lib/");
                } else {
                    String dir = application.getLibraryDirectory();
                    if (!dir.endsWith("/")) application.setLibraryDirectory(dir + "/");
                }
                List<URL> extraLibs = new ArrayList<URL>();
                try {
                    Map<String, URL> libs = finder.getResourcesMap(application.getLibraryDirectory());
                    extraLibs.addAll(libs.values());
                } catch (IOException e) {
                    logger.warning("Cannot load libs from '" + application.getLibraryDirectory() + "' : " + e.getMessage(), e);
                }

                // APP-INF/lib/*
                try {
                    Map<String, URL> libs = finder.getResourcesMap("APP-INF/lib/");
                    extraLibs.addAll(libs.values());
                } catch (IOException e) {
                    logger.warning("Cannot load libs from 'APP-INF/lib/' : " + e.getMessage(), e);
                }

                // META-INF/lib/*
                try {
                    Map<String, URL> libs = finder.getResourcesMap("META-INF/lib/");
                    extraLibs.addAll(libs.values());
                } catch (IOException e) {
                    logger.warning("Cannot load libs from 'META-INF/lib/' : " + e.getMessage(), e);
                }

                // All jars nested in the Resource Adapter
                HashMap<String, URL> rarLibs = new HashMap<String, URL>();
                for (Map.Entry<String, URL> entry : resouceModules.entrySet()) {
                    try {
                        // unpack the resource adapter archive
                        File rarFile = new File(entry.getValue().getPath());
                        rarFile = unpack(rarFile);
                        entry.setValue(rarFile.toURL());

                        scanDir(appDir, rarLibs, "");
                    } catch (MalformedURLException e) {
                        throw new OpenEJBException("Malformed URL to app. " + e.getMessage(), e);
                    }
                }
                for (Iterator<Map.Entry<String, URL>> iterator = rarLibs.entrySet().iterator(); iterator.hasNext();) {
                    // remove all non jars from the rarLibs
                    Map.Entry<String, URL> fileEntry = iterator.next();
                    if (!fileEntry.getKey().endsWith(".jar")) continue;
                    iterator.remove();
                }

                List<URL> classPath = new ArrayList<URL>();
                classPath.addAll(ejbModules.values());
                classPath.addAll(clientModules.values());
                classPath.addAll(rarLibs.values());
                classPath.addAll(extraLibs);
                URL[] urls = classPath.toArray(new URL[classPath.size()]);
                ClassLoader appClassLoader = new TemporaryClassLoader(urls, OpenEJB.class.getClassLoader());

                //
                // Create the AppModule and all nested module objects
                //

View Full Code Here

Examples of org.apache.openejb.core.TemporaryClassLoader

            }
        }

        // create the class loader
        URL[] webUrls = webClassPath.toArray(new URL[webClassPath.size()]);
        ClassLoader warClassLoader = new TemporaryClassLoader(webUrls, parentClassLoader);

        // create web module
        WebModule webModule = new WebModule(webApp, contextRoot, warClassLoader, warFile.getAbsolutePath(), moduleName);
        webModule.getAltDDs().putAll(descriptors);
        webModule.getWatchedResources().add(warPath);
View Full Code Here

Examples of org.apache.openejb.core.TemporaryClassLoader

        // create the class loader
        List<URL> classPath = new ArrayList<URL>();
        classPath.addAll(rarLibs.values());
        URL[] urls = classPath.toArray(new URL[classPath.size()]);
        ClassLoader appClassLoader = new TemporaryClassLoader(urls, parentClassLoader);

        // create the Resource Module
        ConnectorModule connectorModule = new ConnectorModule(connector, appClassLoader, rarPath, moduleId);
        connectorModule.getAltDDs().putAll(descriptors);
        connectorModule.getLibraries().addAll(classPath);
View Full Code Here

Examples of org.apache.openejb.core.TemporaryClassLoader

    }

    private ClassLoader getClassLoader(File jarFile) throws OpenEJBException {
        try {
            URL[] urls = new URL[]{jarFile.toURL()};
            return new TemporaryClassLoader(urls, OpenEJB.class.getClassLoader());
        } catch (MalformedURLException e) {
            throw new OpenEJBException(messages.format("cl0001", jarFile.getAbsolutePath(), e.getMessage()), e);
        }
    }
View Full Code Here

Examples of org.apache.openjpa.lib.util.TemporaryClassLoader

        } catch (IOException e) {
            logger.warning("Unable to determine URLs in web application " + basePath, e);
        }

        // create the app module
        ClassLoader appClassLoader = new TemporaryClassLoader(classLoader);
        AppModule appModule = new AppModule(appClassLoader, basePath);

        // add the web module itself
        WebModule webModule = new WebModule(webApp, servletContext.getContextPath(), classLoader, basePath, getId(standardContext));
        appModule.getWebModules().add(webModule);
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.