Examples of Deployments


Examples of org.apache.openejb.config.sys.Deployments

    @Test
    public void testToConfigDeclaration() throws Exception {
        final String path = ".";
        ConfigurationFactory factory = new ConfigurationFactory();
        Deployments deployments = (Deployments) factory.toConfigDeclaration("", new URI("new://Deployments?classpath="
                + path));
        URLClassLoader cl = (URLClassLoader) deployments.getClasspath();
        URL[] urls = cl.getURLs();
        assertEquals(urls[0], new File(path).toURI().normalize().toURL());
    }
View Full Code Here

Examples of org.apache.openejb.config.sys.Deployments

                }
            }
        }

        /* Create a new Deployments entry */
        Deployments dep = JaxbOpenejb.createDeployments();
        dep.setJar(jarLocation);
        config.getDeployments().add(dep);
        return true;
    }
View Full Code Here

Examples of org.apache.openejb.config.sys.Deployments

                service.setId(id);
                service.setType(map.remove("type"));
                service.setProvider(map.remove("provider"));
                service.getProperties().putAll(map);
            } else if (object instanceof Deployments){
                Deployments deployments = (Deployments) object;
                deployments.setDir(map.remove("dir"));
                deployments.setJar(map.remove("jar"));
                String cp = map.remove("classpath");
                if (cp != null) {
                    String[] paths = cp.split(File.pathSeparator);
                    List<URL> urls = new ArrayList<URL>();
                    for (String path : paths) {
                        urls.add(new File(path).toURI().normalize().toURL());
                    }
                    deployments.setClasspath(new URLClassLoader(urls.toArray(new URL[0])));
                }
            }

            return object;
        } catch (Exception e) {
View Full Code Here

Examples of org.apache.openejb.config.sys.Deployments

    }

    private static void processUrls(List<URL> urls, ClassLoader classLoader, boolean searchForDescriptorlessApplications, FileUtils base, List<String> jarList) {
        for (URL url : urls) {
            Deployments deployment;
            String path;
            try {
                Class<? extends DeploymentModule> moduleType = DeploymentLoader.discoverModuleType(url, classLoader, searchForDescriptorlessApplications);
                if (AppModule.class.isAssignableFrom(moduleType) || EjbModule.class.isAssignableFrom(moduleType) || PersistenceModule.class.isAssignableFrom(moduleType) || ConnectorModule.class.isAssignableFrom(moduleType)) {
                    deployment = JaxbOpenejb.createDeployments();
                    if (url.getProtocol().equals("jar")) {
                        url = new URL(url.getFile().replaceFirst("!.*$", ""));
                        File file = toFile(url);
                        path = file.getAbsolutePath();
                        deployment.setJar(path);
                    } else if (url.getProtocol().equals("file")) {
                        File file = toFile(url);
                        path = file.getAbsolutePath();
                        deployment.setDir(path);
                    } else {
                        logger.warning("Not loading " + moduleType.getSimpleName() + ".  Unknown protocol " + url.getProtocol());
                        continue;
                    }
                    logger.info("Found " + moduleType.getSimpleName() + " in classpath: " + path);
View Full Code Here

Examples of org.apache.openejb.config.sys.Deployments

            if (!isValidURL) {
                logger.warning("Unknown protocol " + urlProtocol);
                continue;
            }

            final Deployments deployment;
            String path = "";
            try {

                final DeploymentLoader deploymentLoader = new DeploymentLoader();

                final Class<? extends DeploymentModule> moduleType = deploymentLoader.discoverModuleType(url, classLoader, requireDescriptors);
                if (AppModule.class.isAssignableFrom(moduleType) || EjbModule.class.isAssignableFrom(moduleType) || PersistenceModule.class.isAssignableFrom(moduleType) || ConnectorModule.class.isAssignableFrom(moduleType) || ClientModule.class.isAssignableFrom(moduleType)) {

                    if (AppModule.class.isAssignableFrom(moduleType) || ConnectorModule.class.isAssignableFrom(moduleType)) {

                        deployment = JaxbOpenejb.createDeployments();

                        if (urlProtocol.equals("jar")) {
                            url = new URL(url.getFile().replaceFirst("!.*$", ""));
                            final File file = toFile(url);
                            path = file.getAbsolutePath();
                            deployment.setJar(path);
                        } else if (urlProtocol.equals("file")) {
                            final File file = toFile(url);
                            path = file.getAbsolutePath();
                            deployment.setDir(path);
                        }

                        logger.info("Found " + moduleType.getSimpleName() + " in classpath: " + path);

                        loadFrom(deployment, base, jarList);
View Full Code Here

Examples of org.apache.openejb.config.sys.Deployments

            throw new OpenEJBException(e);
        }
    }

    private synchronized void saveDeployment(final File file, boolean add) {
        final Deployments deps = new Deployments();
        if (file.isDirectory()) {
            deps.setDir(file.getAbsolutePath());
        } else {
            deps.setJar(file.getAbsolutePath());
        }

        File config;
        try {
            config = SystemInstance.get().getBase().getFile(ADDITIONAL_DEPLOYMENTS, false);
        } catch (IOException e) {
            config = null;
        }
        if (config == null || !config.getParentFile().exists()) {
            LOGGER.error("can't save the added app because the conf folder doesn't exist, it will not be present next time you'll start");
            return;
        }

        // dump it
        OutputStream os = null;
        try {
            final AdditionalDeployments additionalDeployments;
            if (config.exists() && config.length() > 0) {
                final InputStream fis = IO.read(config);
                try {
                    additionalDeployments = JaxbOpenejb.unmarshal(AdditionalDeployments.class, fis);
                } finally {
                    IO.close(fis);
                }
            } else {
                additionalDeployments = new AdditionalDeployments();
            }

            if (add) {
                additionalDeployments.getDeployments().add(deps);
            } else {
                Iterator<Deployments> it = additionalDeployments.getDeployments().iterator();
                while (it.hasNext()) {
                    final Deployments current = it.next();
                    if (deps.getDir() != null && deps.getDir().equals(current.getDir())) {
                        it.remove();
                        break;
                    } else if (deps.getJar() != null && deps.getJar().equals(current.getJar())) {
                        it.remove();
                        break;
                    }
                }
            }
View Full Code Here

Examples of org.apache.openejb.config.sys.Deployments

                service.setId(id);
                service.setType(map.remove("type"));
                service.setProvider(map.remove("provider"));
                service.getProperties().putAll(map);
            } else if (object instanceof Deployments) {
                final Deployments deployments = (Deployments) object;
                deployments.setDir(map.remove("dir"));
                deployments.setJar(map.remove("jar"));
                final String cp = map.remove("classpath");
                if (cp != null) {
                    final String[] paths = cp.split(File.pathSeparator);
                    final List<URL> urls = new ArrayList<URL>();
                    for (final String path : paths) {
                        urls.add(new File(path).toURI().normalize().toURL());
                    }
                    deployments.setClasspath(new URLClassLoader(urls.toArray(new URL[urls.size()])));
                }
            }

            return object;
        } catch (Exception e) {
View Full Code Here

Examples of org.apache.openejb.config.sys.Deployments

        String flag = SystemInstance.get().getProperty("openejb.deployments.classpath", "true").toLowerCase();
        boolean searchClassPath = flag.equals("true");
        //// getOption /////////////////////////////////  END  ////////////////////

        if (searchClassPath) {
            Deployments deployment = JaxbOpenejb.createDeployments();
            deployment.setClasspath(Thread.currentThread().getContextClassLoader());
            deployments.add(deployment);
        }
        // resolve jar locations //////////////////////////////////////  BEGIN  ///////

        FileUtils base = SystemInstance.get().getBase();

        List<String> jarList = new ArrayList<String>(deployments.size());
        try {
            for (Deployments deployment : deployments) {
                if (deployment.getClasspath() != null) {
                    loadFromClasspath(base, jarList, deployment.getClasspath());
                } else {
                    loadFrom(deployment, base, jarList);
                }
            }
        } catch (SecurityException ignored) {
View Full Code Here

Examples of org.apache.openejb.config.sys.Deployments

     * 2- Loading the resource is the default behaviour in case of not defining a value for any class-path pattern
     * This appears in step 3 of the above algorithm.
     */
    private static void loadFromClasspath(FileUtils base, List<String> jarList, ClassLoader classLoader) {

        Deployments deployment = null;
        String include = null;
        String exclude = null;
        String path = null;

        include = SystemInstance.get().getProperty(CLASSPATH_INCLUDE, "");
View Full Code Here

Examples of org.apache.openejb.config.sys.Deployments

        }

    }

    private static void processUrls(List<URL> urls, ClassLoader classLoader, boolean desc, FileUtils base, List<String> jarList) {
        Deployments deployment;
        String path;
        for (URL url : urls) {
            try {
                Class moduleType = DeploymentLoader.discoverModuleType(url, classLoader, desc);
                if (AppModule.class.isAssignableFrom(moduleType) || EjbModule.class.isAssignableFrom(moduleType)) {
                    deployment = JaxbOpenejb.createDeployments();
                    if (url.getProtocol().equals("jar")) {
                        url = new URL(url.getFile().replaceFirst("!.*$", ""));
                        File file = new File(url.getFile());
                        path = file.getAbsolutePath();
                        deployment.setJar(path);
                    } else if (url.getProtocol().equals("file")) {
                        File file = new File(url.getFile());
                        path = file.getAbsolutePath();
                        deployment.setDir(path);
                    } else {
                        logger.warning("Not loading " + moduleType.getSimpleName() + ".  Unknown protocol " + url.getProtocol());
                        continue;
                    }
                    logger.info("Found " + moduleType.getSimpleName() + " in classpath: " + path);
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.