Package org.apache.openejb.config.sys

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


                service.setClassName(map.remove("class-name"));
                service.setConstructor(map.remove("constructor"));
                service.setFactoryName(map.remove("factory-name"));
                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


            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.info("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) {
                if (!additionalDeployments.getDeployments().contains(deps)) {
                    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;
                    } else { // exploded dirs
                        String jar = deps.getJar();
                        if (jar != null && jar.length() > 3 && jar.substring(0, jar.length() - 4).equals(deps.getDir())) {
View Full Code Here

            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

        public Properties getProperties() {
            return properties;
        }

        public File deploymentsDir(String dir) {
            openejb.getDeployments().add(new Deployments().dir(dir));
            return Files.mkdir(base, dir);
        }
View Full Code Here

            openejb.getDeployments().add(new Deployments().dir(dir));
            return Files.mkdir(base, dir);
        }

        public File deploymentsFile(String file) {
            openejb.getDeployments().add(new Deployments().file(file));
            return Files.path(base, file);
        }
View Full Code Here

    @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

                service.setClassName(map.remove("class-name"));
                service.setConstructor(map.remove("constructor"));
                service.setFactoryName(map.remove("factory-name"));
                service.getProperties().putAll(map);
            } else if (object instanceof Deployments) {
                final Deployments deployments = (Deployments) object;
                deployments.setDir(map.remove("dir"));
                deployments.setFile(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

TOP

Related Classes of org.apache.openejb.config.sys.Deployments

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.