Package org.apache.xbean.classloader

Examples of org.apache.xbean.classloader.JarFileClassLoader


                }
            } else {
                try {
                    URL[] urls = getDefaultLocations();
                    ClassLoader parentLoader = getParentClassLoader(applicationContext);
                    classLoader = new JarFileClassLoader(applicationContext.getDisplayName(), urls, parentLoader);
                    // assign the class loader to the xml reader and the
                    // application context
                } catch (Exception e) {
                    throw new FatalBeanException("Unable to create default classloader for SU", e);
                }
View Full Code Here


                if (componentMBean == null) {
                    throw new IllegalStateException("No such component: " + componentMBean);
                }
                parents.add(componentMBean.getComponent().getClass().getClassLoader());
            }
            classLoader = new JarFileClassLoader(applicationContext.getDisplayName(),
                                                 urls,
                                                 parents.toArray(new ClassLoader[parents.size()]),
                                                 inverse,
                                                 hidden.toArray(new String[hidden.size()]),
                                                 nonOverridable.toArray(new String[nonOverridable.size()]));
View Full Code Here

        return invoke("wsimport", jars, os, arguments);
    }

    private boolean invoke(String toolName, URL[] jars, OutputStream os, String[] arguments) throws Exception {
        ClassLoader oldClassLoader = null;
        JarFileClassLoader loader = new JarFileClassLoader(null, jars, ClassLoader.getSystemClassLoader(), false, HIDDEN_CLASSES, new String[0]);
        if (overrideContextClassLoader) {
            oldClassLoader = Thread.currentThread().getContextClassLoader();
            Thread.currentThread().setContextClassLoader(loader);
        }
        try {
            return invoke(toolName, loader, os, arguments);
        } finally {
            if (overrideContextClassLoader) {
                Thread.currentThread().setContextClassLoader(oldClassLoader);
            }
            try {
                loader.destroy();
            } catch (Exception e) {
            }
        }
    }
View Full Code Here

                }
            }
        }

        URL[] urls = urlList.toArray(new URL[urlList.size()]);
        JarFileClassLoader tempClassLoader = null;
        try {
            tempClassLoader = new JarFileClassLoader(null, urls, parentClassLoader);
            List<Class<?>> classes = new ArrayList<Class<?>>();
            for (URL url : urlList) {
                try {
                    ClassFinder classFinder = new ClassFinder(tempClassLoader, Collections.singletonList(url));
                    classes.addAll(classFinder.findAnnotatedClasses(WebService.class));
                    classes.addAll(classFinder.findAnnotatedClasses(WebServiceProvider.class));
                } catch (Exception e) {
                    logger.warn("Fail to search Web Service in jar [" + url + "]", e);
                }
            }
            return classes;
        } finally {
            if (tempClassLoader != null) {
                tempClassLoader.destroy();
            }
            if (tmpDir != null) {
                FileUtils.recursiveDelete(tmpDir);
            }
        }
View Full Code Here

        return invoke("wsimport", jars, os, arguments);
    }

    private boolean invoke(String toolName, URL[] jars, OutputStream os, String[] arguments) throws Exception {
        ClassLoader oldClassLoader = null;
        JarFileClassLoader loader = new JarFileClassLoader(null, jars, ClassLoader.getSystemClassLoader(), false, HIDDEN_CLASSES, new String[0]);
        if (overrideContextClassLoader) {
            oldClassLoader = Thread.currentThread().getContextClassLoader();
            Thread.currentThread().setContextClassLoader(loader);
        }
        try {
            return invoke(toolName, loader, os, arguments);
        } finally {
            if (overrideContextClassLoader) {
                Thread.currentThread().setContextClassLoader(oldClassLoader);
            }
            try {
                loader.destroy();
            } catch (Exception e) {
            }
        }
    }
View Full Code Here

                urls[i] = file.toURL();
            } catch (MalformedURLException e) {
                throw new IllegalArgumentException(classPathNames[i], e);
            }
        }
        return new JarFileClassLoader(
                        getName(),
                        urls,
                        parent,
                        !parentFirst,
                        new String[0],
View Full Code Here

                }
            } else {
                try {
                    URL[] urls = getDefaultLocations();
                    ClassLoader parentLoader = getParentClassLoader(applicationContext);
                    classLoader = new JarFileClassLoader(applicationContext.getDisplayName(), urls, parentLoader);
                    // assign the class loader to the xml reader and the
                    // application context
                } catch (Exception e) {
                    throw new FatalBeanException("Unable to create default classloader for SU", e);
                }
View Full Code Here

            }

            // create the classloader
            List<ClassLoader> parents = new ArrayList<ClassLoader>();
            parents.add(getParentClassLoader(applicationContext));
            classLoader = new JarFileClassLoader(applicationContext.getDisplayName(),
                                                 urls,
                                                 parents.toArray(new ClassLoader[parents.size()]),
                                                 inverse,
                                                 hidden.toArray(new String[hidden.size()]),
                                                 nonOverridable.toArray(new String[nonOverridable.size()]));
View Full Code Here

                        file, file.getAbsolutePath());
            }
            urls.add(file.toURL());
        }

        ClassLoader cl = new JarFileClassLoader(
                        "Component ClassLoader",
                        (URL[]) urls.toArray(new URL[urls.size()]),
                        parents,
                        !parentFirst,
                        new String[0],
View Full Code Here

                }
            } else {
                try {
                    URL[] urls = getDefaultLocations();
                    ClassLoader parentLoader = getParentClassLoader(applicationContext);
                    classLoader = new JarFileClassLoader(applicationContext.getDisplayName(), urls, parentLoader);
                    // assign the class loader to the xml reader and the
                    // application context
                } catch (Exception e) {
                    throw new FatalBeanException("Unable to create default classloader for SU", e);
                }
View Full Code Here

TOP

Related Classes of org.apache.xbean.classloader.JarFileClassLoader

Copyright © 2018 www.massapicom. 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.