Examples of ResourceFinder


Examples of org.apache.xbean.finder.ResourceFinder

        URL appUrl = getFileUrl(appDir);

        String appId = appDir.getAbsolutePath();
        ClassLoader tmpClassLoader = ClassLoaderUtil.createTempClassLoader(appId, new URL[]{appUrl}, OpenEJB.class.getClassLoader());

        ResourceFinder finder = new ResourceFinder("", tmpClassLoader, appUrl);
        Map<String, URL> appDescriptors = getDescriptors(finder);

        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 = ClassLoaderUtil.createTempClassLoader(appId, 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);
            }

View Full Code Here

Examples of org.apache.xbean.finder.ResourceFinder

    protected static ClientModule createClientModule(URL clientUrl, String absolutePath, ClassLoader appClassLoader, String moduleName) throws OpenEJBException {
        return createClientModule(clientUrl, absolutePath, appClassLoader, moduleName, true);
    }

    protected static ClientModule createClientModule(URL clientUrl, String absolutePath, ClassLoader appClassLoader, String moduleName, boolean log) throws OpenEJBException {
        ResourceFinder clientFinder = new ResourceFinder(clientUrl);

        URL manifestUrl = null;
        try {
            manifestUrl = clientFinder.find("META-INF/MANIFEST.MF");
        } catch (IOException e) {
            //
        }

        String mainClass = null;
View Full Code Here

Examples of org.apache.xbean.finder.ResourceFinder


        for (URL url : urls) {
            // OPENEJB-1059: looking for an altdd persistence.xml file in all urls
            // delegates to xbean finder for going throughout the list
            ResourceFinder finder = new ResourceFinder("", appModule.getClassLoader(), url);
            Map<String, URL> descriptors = getDescriptors(finder, false);

            // if a persistence.xml has been found, just pull it to the list
            if (descriptors.containsKey("persistence.xml")) {
                URL descriptor = descriptors.get("persistence.xml");
View Full Code Here

Examples of org.apache.xbean.finder.ResourceFinder

        }
    }

    private static Map<String, URL> getDescriptors(URL moduleUrl) throws OpenEJBException {

        ResourceFinder finder = new ResourceFinder(moduleUrl);
        return getDescriptors(finder);
    }
View Full Code Here

Examples of org.apache.xbean.finder.ResourceFinder

        if (vendor == null) return null;

        // find the plugin class
        String pluginClassName = null;
        try {
            ResourceFinder finder = new ResourceFinder("META-INF");
            Map<String,String> plugins = finder.mapAvailableStrings(DataSourcePlugin.class.getName());
            pluginClassName = plugins.get(vendor);
        } catch (IOException ignored) {
            // couldn't determine the plugins, which isn't fatal
        }
View Full Code Here

Examples of org.codehaus.janino.util.resource.ResourceFinder

        final Collection problems = new ArrayList();

        final StringPattern[] pattern = StringPattern.PATTERNS_NONE;

        final Compiler compiler = new Compiler(
                new ResourceFinder() {
                    public Resource findResource( final String pSourceName ) {
                        final byte[] bytes = pResourceReader.getBytes(pSourceName);

                        if (bytes == null) {
                            return null;
                        }

                        return new JciResource(pSourceName, bytes);
                    }
                },
                new ClassLoaderIClassLoader(pClassLoader),
                new ResourceFinder() {
                    public Resource findResource( final String pResourceName ) {
                        final byte[] bytes = pStore.read(pResourceName);

                        if (bytes == null) {
                            return null;
View Full Code Here

Examples of org.glassfish.jersey.server.ResourceFinder

            final Set<String> resourcePaths = sc.getResourcePaths(path);
            if (resourcePaths == null) {
                break;
            }

            resourceFinderStack.push(new ResourceFinder() {

                private Deque<String> resourcePathsStack = new LinkedList<String>() {

                    private static final long serialVersionUID = 3109256773218160485L;
View Full Code Here

Examples of org.jboss.security.xacml.sunxacml.finder.ResourceFinder

      AttributeFinder attributeFinder = new AttributeFinder();
      attributeFinder.setModules(this.createAttributeFinderModules());
     
      policyFinder.setModules(this.createPolicyFinderModules());
     
      ResourceFinder resourceFinder = new ResourceFinder();
      resourceFinder.setModules(this.createResourceFinderModules());
     
      PDPConfig pdpConfig = new PDPConfig(attributeFinder, policyFinder, resourceFinder);
      policyDecisionPoint = new org.jboss.security.xacml.sunxacml.PDP(pdpConfig)
   }
View Full Code Here

Examples of org.locationtech.udig.omsbox.utils.ResourceFinder

        jarClassloader = new URLClassLoader(urls, this.getClass().getClassLoader());

        long t1 = System.currentTimeMillis();
        List<Class< ? >> classesList = new ArrayList<Class< ? >>();
        for( URL url : urlList ) {
            ResourceFinder finder = new ResourceFinder("META-INF/", url);
            Map<String, Properties> servicesList = finder.mapAllProperties("services");
            Set<Entry<String, Properties>> servicesEntrySets = servicesList.entrySet();
            for( Entry<String, Properties> serviceEntry : servicesEntrySets ) {
                Properties properties = serviceEntry.getValue();
                Set<Entry<Object, Object>> entrySet = properties.entrySet();
                for( Entry<Object, Object> entry : entrySet ) {
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.