Package org.apache.openejb.assembler

Examples of org.apache.openejb.assembler.Deployer


        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 = line.getOptionValue("server-url", defaultServerUrl);
            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);
            }
        }

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

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

            File file = new File(path);

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

            try {
                if (shouldUnpack(file)) {
                    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;
                }

                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


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

                Deployer deployer = null;
                for (int i = 0; i < (properties.containsKey("retries") ? Integer.parseInt(String.class.cast(properties.get("retries"))) : 20); i++) {
                    deployer = Deployer.class.cast(instance.context.lookup("openejb/DeployerBusinessRemote"));
                    if (deployer != null) {
                        break;
                    }
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 = line.getOptionValue("server-url", defaultServerUrl);
            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);
            }
        }

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

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

            File file = new File(path);

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

            try {
                if (shouldUnpack(file)) {
                    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;
                }

                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.path));

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

*/
@Mojo(name = "undeploy")
public class UnDeployMojo extends AbstractDeployMojo {
    @Override
    public void execute() throws MojoExecutionException, MojoFailureException {
        final Deployer deployer = (Deployer) lookup("openejb/DeployerBusinessRemote");
        try {
            deployer.undeploy(path);
        } catch (OpenEJBException e) {
            throw new TomEEException(e.getMessage(), e);
        }
    }
View Full Code Here

    @Parameter
    protected Map<String, String> systemVariables = new HashMap<String, String>();

    @Override
    public void execute() throws MojoExecutionException, MojoFailureException {
        final Deployer deployer = (Deployer) lookup("openejb/DeployerBusinessRemote");
        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

* @goal list
*/
public class ListEjbMojo extends AbstractCommandMojo {
    @Override
    public void execute() throws MojoExecutionException, MojoFailureException {
        final Deployer deployer = (Deployer) lookup("openejb/DeployerBusinessRemote");
        final Collection<AppInfo> infos = deployer.getDeployedApps();
        final Lines lines = new Lines();
        lines.add(new Line("Name", "Class", "Interface Type", "Bean Type"));
        for (AppInfo info : infos) {
            for (EjbJarInfo ejbJar : info.ejbJars) {
                for (EnterpriseBeanInfo bean : ejbJar.enterpriseBeans) {
View Full Code Here

* @goal undeploy
*/
public class UnDeployMojo extends AbstractDeployMojo {
    @Override
    public void execute() throws MojoExecutionException, MojoFailureException {
        final Deployer deployer = (Deployer) lookup("openejb/DeployerBusinessRemote");
        try {
            deployer.undeploy(path);
        } catch (OpenEJBException e) {
            throw new TomEEException(e.getMessage(), e);
        }
    }
View Full Code Here

     */
    protected Map<String, String> systemVariables = new HashMap<String, String>();

    @Override
    public void execute() throws MojoExecutionException, MojoFailureException {
        final Deployer deployer = (Deployer) lookup("openejb/DeployerBusinessRemote");
        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

*/
@Mojo(name = "list")
public class ListEjbMojo extends AbstractCommandMojo {
    @Override
    public void execute() throws MojoExecutionException, MojoFailureException {
        final Deployer deployer = (Deployer) lookup("openejb/DeployerBusinessRemote");
        final Collection<AppInfo> infos = deployer.getDeployedApps();
        final Lines lines = new Lines();
        lines.add(new Line("Name", "Class", "Interface Type", "Bean Type"));
        for (AppInfo info : infos) {
            for (EjbJarInfo ejbJar : info.ejbJars) {
                for (EnterpriseBeanInfo bean : ejbJar.enterpriseBeans) {
View Full Code Here

@Mojo(name = "undeploy")
public class UnDeployMojo extends AbstractDeployMojo {
    @Override
    public void execute() throws MojoExecutionException, MojoFailureException {
        final Deployer deployer = (Deployer) lookup("openejb/DeployerBusinessRemote");
        try {
            deployer.undeploy(path);
        } catch (OpenEJBException e) {
            throw new TomEEException(e.getMessage(), e);
        }
    }
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.