Package org.apache.openejb.assembler

Examples of org.apache.openejb.assembler.Deployer


*/
@Mojo(name = "undeploy")
public class UnDeployMojo extends AbstractDeployMojo {
    @Override
    public void execute() throws MojoExecutionException, MojoFailureException {
        final Deployer deployer = (Deployer) lookup("openejb/DeployerBusinessRemote");
        try {
            final Collection<AppInfo> apps = deployer.getDeployedApps();
            final Collection<String> paths = new ArrayList<String>(apps.size());
            for (final AppInfo info : apps) {
                paths.add(info.path);
            }

            if (paths.contains(path)) { // exact matching
                deployer.undeploy(path);
            } else {
                for (final String proposed : paths) { // exact matching + extension
                    if (path.equals(proposed + ".war") || path.equals(proposed + ".ear") || path.equals(proposed + ".jar")) {
                        deployer.undeploy(proposed);
                        return;
                    }
                }
                for (final String proposed : paths) { // just the app/folder name
                    if (proposed.endsWith("/" + path) || proposed.endsWith("\\" + path)) {
                        deployer.undeploy(proposed);
                        return;
                    }
                }
            }
        } catch (final OpenEJBException e) {
View Full Code Here


    @Parameter(property = "tomee-plugin.binary", defaultValue = "false")
    private boolean useBinaries;

    @Override
    public void execute() throws MojoExecutionException, MojoFailureException {
        final Deployer deployer = (Deployer) lookup("openejb/DeployerBusinessRemote");
        if ((!"localhost".equals(tomeeHost) && !tomeeHost.startsWith("127.")) || useBinaries) {

            final ByteArrayOutputStream baos = new ByteArrayOutputStream();
            final byte[] archive;
            FileInputStream fis = null;
            try {
                fis = new FileInputStream(path);
                IO.copy(fis, baos);
                archive = baos.toByteArray();
            } catch (Exception e) {
                throw new TomEEException(e.getMessage(), e);
            } finally {
                IO.close(fis);
                IO.close(baos);
            }

            try {
                final Properties prop = new Properties();
                prop.putAll(systemVariables);
                prop.put(DeployerEjb.OPENEJB_USE_BINARIES, "true");
                prop.put(DeployerEjb.OPENEJB_PATH_BINARIES, new File(path).getName());
                prop.put(DeployerEjb.OPENEJB_VALUE_BINARIES, archive);
                deployer.deploy(path, prop);
            } catch (OpenEJBException e) {
                throw new TomEEException(e.getMessage(), e);
            }
        } else {
            try {
                if (systemVariables.isEmpty()) {
                    deployer.deploy(path);
                } else {
                    final Properties prop = new Properties();
                    prop.putAll(systemVariables);
                    deployer.deploy(path, prop);
                }
            } catch (OpenEJBException e) {
                throw new TomEEException(e.getMessage(), e);
            }
        }
View Full Code Here

                instance.context = new InitialContext(new Properties() {{
                    setProperty(Context.INITIAL_CONTEXT_FACTORY, RemoteInitialContextFactory.class.getName());
                    setProperty(Context.PROVIDER_URL, remoteEjb);
                }});

                final Deployer deployer = Deployer.class.cast(instance.context.lookup("openejb/DeployerBusinessRemote"));

                if (modules instanceof File) {
                    final File file = File.class.cast(modules);
                    deployFile(deployer, file);
                } else if (modules instanceof String) {
View Full Code Here

        if (line.hasOption(serverUrl)) {
            serverUrl = line.getOptionValue("serverUrl");
        }
        p.put(Context.PROVIDER_URL, serverUrl);

        Deployer deployer = null;
        try {
            InitialContext ctx = new InitialContext(p);
            deployer = (Deployer) ctx.lookup("openejb/DeployerBusinessRemote");
        } catch (javax.naming.ServiceUnavailableException e) {
            System.out.println(e.getCause().getMessage());
            System.out.println(Undeploy.messages.format("cmd.deploy.serverOffline"));
            throw new SystemExitException(1);
        } catch (javax.naming.NamingException e) {
            System.out.println("DeployerEjb does not exist in server '" + serverUrl + "', check the server logs to ensure it exists and has not been removed.");
            throw new SystemExitException(2);
        }

        int exitCode = 0;
        for (Object obj : line.getArgList()) {
            String moduleId = (String) obj;

            try {
                boolean undeployed = false;

                // Treat moduleId as a file path, and see if there is a matching app to undeploy
                String path = null;
                try {
                    path = new File(moduleId).getCanonicalPath();
                } catch (IOException e) {
                }
                if (path != null) {
                    try {
                        deployer.undeploy(path);
                        undeployed = true;
                    } catch (NoSuchApplicationException e) {
                    }
                }

                // If that didn't work, undeploy using just the moduleId
                if (!undeployed) {
                    deployer.undeploy(moduleId);
                }

                // TODO make this message
                System.out.println(messages.format("cmd.undeploy.successful", moduleId));
            } catch (UndeployException e) {
View Full Code Here

        if (!apps.exists()) {
            System.out.println("Directory does not exist: " + apps.getAbsolutePath());
        }

        Deployer deployer = null;
        if (!offline) {
            Properties p = new Properties();
            p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory");

            String serverUrl = defaultServerUrl;
            if (line.hasOption(serverUrl)) {
                serverUrl = line.getOptionValue("serverUrl");
            }
            p.put(Context.PROVIDER_URL, serverUrl);

            try {
                InitialContext ctx = new InitialContext(p);
                deployer = (Deployer) ctx.lookup("openejb/DeployerBusinessRemote");
            } catch (javax.naming.ServiceUnavailableException e) {
                System.out.println(e.getCause().getMessage());
                System.out.println(messages.format("cmd.deploy.serverOffline"));
                throw new SystemExitException(1);
            } catch (javax.naming.NamingException e) {
                System.out.println("openejb/DeployerBusinessRemote does not exist in server '" + serverUrl
                        + "', check the server logs to ensure it exists and has not been removed.");
                throw new SystemExitException(2);
            }
        }

        int exitCode = 0;
        for (Object obj : line.getArgList()) {
            String path = (String) obj;

            try {
                File file = new File(path);

                File destFile = new File(apps, file.getName());


                if (shouldUnpack(file)) {
                    destFile = unpack(file, apps);
                } else {
                    checkDest(destFile, file);
                    copyFile(file, destFile);
                }

                if (offline) {
                    System.out.println(messages.format("cmd.deploy.offline", path, apps.getAbsolutePath()));
                    continue;
                }

                String location;
                try {
                    location = destFile.getCanonicalPath();
                } catch (IOException e) {
                    throw new OpenEJBException(messages.format("cmd.deploy.fileNotFound", path));
                }
                AppInfo appInfo = deployer.deploy(location);

                System.out.println(messages.format("cmd.deploy.successful", path, appInfo.jarPath));

                if (line.hasOption("quiet")) {
                    continue;
View Full Code Here

        p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory");

        final String serverUrl = line.getOptionValue("server-url", defaultServerUrl);
        p.put(Context.PROVIDER_URL, serverUrl);

        Deployer deployer = null;
        try {
            final InitialContext ctx = new InitialContext(p);
            deployer = (Deployer) ctx.lookup("openejb/DeployerBusinessRemote");
        } catch (final ServiceUnavailableException e) {
            System.out.println(e.getCause().getMessage());
View Full Code Here

        if (!apps.exists()) {
            System.out.println("Directory does not exist: " + apps.getAbsolutePath());
        }

        Deployer deployer = null;
        if (!offline) {
            final Properties p = new Properties();
            p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory");

            final String serverUrl = line.getOptionValue("server-url", defaultServerUrl);
            p.put(Context.PROVIDER_URL, serverUrl);

            try {
                final InitialContext ctx = new InitialContext(p);
                deployer = (Deployer) ctx.lookup("openejb/DeployerBusinessRemote");
            } catch (final ServiceUnavailableException e) {
                System.out.println(e.getCause().getMessage());
                System.out.println(messages.format("cmd.deploy.serverOffline"));
                throw new SystemExitException(-1);
            } catch (final NamingException e) {
                System.out.println("openejb/DeployerBusinessRemote does not exist in server '" + serverUrl
                    + "', check the server logs to ensure it exists and has not been removed.");
                throw new SystemExitException(-2);
            }
        }

        final boolean undeploy = line.hasOption("undeploy");

        // We increment the exit code once for every failed deploy
        int exitCode = 0;
        for (final Object obj : line.getArgList()) {
            final String path = (String) obj;

            final File file = new File(path);

            File destFile = new File(apps, file.getName());

            try {
                if (shouldUnpack(file)) {
                    final File unpacked = unpackedLocation(file, apps);
                    if (undeploy) {
                        undeploy(offline, unpacked, path, deployer);
                    }
                    destFile = unpack(file, unpacked);
                } else {
                    if (undeploy) {
                        undeploy(offline, destFile, path, deployer);
                    }
                    checkDest(destFile, file);
                    copyFile(file, destFile);
                }

                if (offline) {
                    System.out.println(messages.format("cmd.deploy.offline", path, apps.getAbsolutePath()));
                    continue;
                }

                final String location;
                try {
                    location = destFile.getCanonicalPath();
                } catch (final IOException e) {
                    throw new OpenEJBException(messages.format("cmd.deploy.fileNotFound", path));
                }
                final AppInfo appInfo = deployer.deploy(location);

                System.out.println(messages.format("cmd.deploy.successful", path, appInfo.path));

                if (line.hasOption("quiet")) {
                    continue;
View Full Code Here

        if (!apps.exists()) {
            System.out.println("Directory does not exist: " + apps.getAbsolutePath());
        }

        Deployer deployer = null;
        if (!offline) {
            final Properties p = new Properties();
            p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory");

            final String serverUrl = line.getOptionValue("server-url", defaultServerUrl);
            p.put(Context.PROVIDER_URL, serverUrl);

            try {
                final InitialContext ctx = new InitialContext(p);
                deployer = (Deployer) ctx.lookup("openejb/DeployerBusinessRemote");
            } catch (final ServiceUnavailableException e) {
                System.out.println(e.getCause().getMessage());
                System.out.println(messages.format("cmd.deploy.serverOffline"));
                throw new SystemExitException(-1);
            } catch (final NamingException e) {
                System.out.println("openejb/DeployerBusinessRemote does not exist in server '" + serverUrl
                    + "', check the server logs to ensure it exists and has not been removed.");
                throw new SystemExitException(-2);
            }
        }

        final boolean undeploy = line.hasOption("undeploy");

        // We increment the exit code once for every failed deploy
        int exitCode = 0;
        for (final Object obj : line.getArgList()) {
            final String path = (String) obj;

            final File file = new File(path);

            File destFile = new File(apps, file.getName());

            try {
                if (shouldUnpack(file)) {
                    final File unpacked = unpackedLocation(file, apps);
                    if (undeploy) {
                        undeploy(offline, unpacked, path, deployer);
                    }
                    destFile = unpack(file, unpacked);
                } else {
                    if (undeploy) {
                        undeploy(offline, destFile, path, deployer);
                    }
                    checkDest(destFile, file);
                    copyFile(file, destFile);
                }

                if (offline) {
                    System.out.println(messages.format("cmd.deploy.offline", path, apps.getAbsolutePath()));
                    continue;
                }

                final String location;
                try {
                    location = destFile.getCanonicalPath();
                } catch (final IOException e) {
                    throw new OpenEJBException(messages.format("cmd.deploy.fileNotFound", path));
                }
                final AppInfo appInfo = deployer.deploy(location);

                System.out.println(messages.format("cmd.deploy.successful", path, appInfo.path));

                if (line.hasOption("quiet")) {
                    continue;
View Full Code Here

        p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory");

        final String serverUrl = line.getOptionValue("server-url", defaultServerUrl);
        p.put(Context.PROVIDER_URL, serverUrl);

        Deployer deployer = null;
        try {
            final InitialContext ctx = new InitialContext(p);
            deployer = (Deployer) ctx.lookup("openejb/DeployerBusinessRemote");
        } catch (final ServiceUnavailableException e) {
            System.out.println(e.getCause().getMessage());
View Full Code Here

        p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory");

        String serverUrl = line.getOptionValue("server-url", defaultServerUrl);
        p.put(Context.PROVIDER_URL, serverUrl);

        Deployer deployer = null;
        try {
            InitialContext ctx = new InitialContext(p);
            deployer = (Deployer) ctx.lookup("openejb/DeployerBusinessRemote");
        } catch (javax.naming.ServiceUnavailableException e) {
            System.out.println(e.getCause().getMessage());
View Full Code Here

TOP

Related Classes of org.apache.openejb.assembler.Deployer

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.