Examples of GlassFish


Examples of org.glassfish.embeddable.GlassFish

            System.out.println("Deployed [" + app + "]");
        }
    }

    public static void undeploy(String appName, String serverId) throws Exception {
        GlassFish glassfish = gfMap.get(serverId);
        if (glassfish == null) {
            throw new Exception("Embedded GlassFish [" + serverId + "] not running");
        }
        if (appName == null) {
            throw new Exception("Application name can not be null");
        }
        Deployer deployer = glassfish.getDeployer();
        deployer.undeploy(appName);
        System.out.println("Undeployed [" + appName + "]");
    }
View Full Code Here

Examples of org.glassfish.embeddable.GlassFish

        deployer.undeploy(appName);
        System.out.println("Undeployed [" + appName + "]");
    }

    public static void runCommand(String commandLine, String serverId) throws Exception {
        GlassFish glassfish = gfMap.get(serverId);
        if (glassfish == null) {
            throw new Exception("Embedded GlassFish [" + serverId + "] not running");
        }
        if (commandLine == null) {
            throw new Exception("Command can not be null");
        }
        String[] split = commandLine.split(" ");
        String command = split[0].trim();
        String[] commandParams = null;
        if (split.length > 1) {
            commandParams = new String[split.length - 1];
            for (int i = 1; i < split.length; i++) {
                commandParams[i - 1] = split[i].trim();
            }
        }
        CommandRunner cr = glassfish.getCommandRunner();
        CommandResult result = commandParams == null ?
                cr.run(command) : cr.run(command, commandParams);
        System.out.println("Executed command [" + commandLine +
                "]. Output : \n" + result.getOutput());
    }
View Full Code Here

Examples of org.glassfish.embeddable.GlassFish

                "]. Output : \n" + result.getOutput());
    }

    public static synchronized void disposeGlassFish(String serverID)
            throws GlassFishException {
        GlassFish glassfish = gfMap.remove(serverID);
        if (glassfish != null) {
            glassfish.dispose();
            System.out.println("Stopped GlassFish [" + serverID + "]");
        }
    }
View Full Code Here

Examples of org.glassfish.embeddable.GlassFish

    public static synchronized GlassFish startGlassFish(String serverID, String installRoot,
                                                        String instanceRoot, String configFileURI,
                                                        boolean configFileReadOnly, int httpPort)
            throws GlassFishException {
        GlassFish glassfish = gfMap.get(serverID);
        if (glassfish != null) {
            return glassfish;
        }
        if (glassfishRuntime == null) {
            BootstrapProperties bootstrapProperties = new BootstrapProperties();
            if (installRoot != null) {
                bootstrapProperties.setInstallRoot(installRoot);
            }
            glassfishRuntime = GlassFishRuntime.bootstrap(bootstrapProperties);
        }

        GlassFishProperties glassfishProperties = new GlassFishProperties();
        if (instanceRoot != null) {
            glassfishProperties.setInstanceRoot(instanceRoot);
        }
        if (configFileURI != null) {
            glassfishProperties.setConfigFileURI(configFileURI);
            glassfishProperties.setConfigFileReadOnly(configFileReadOnly);
        }
        if (httpPort != -1) {
            glassfishProperties.setPort("http-listener", httpPort);
        }

        glassfish = glassfishRuntime.newGlassFish(glassfishProperties);
        glassfish.start();

        gfMap.put(serverID, glassfish);

        System.out.println("Started GlassFish [" + serverID + "]");
View Full Code Here

Examples of org.glassfish.embeddable.GlassFish

        return glassfish;
    }

    public static void deploy(String app, String serverId, List<String> deployParams)
            throws Exception {
        GlassFish glassfish = gfMap.get(serverId);
        if (glassfish == null) {
            throw new Exception("Embedded GlassFish [" + serverId + "] not running");
        }
        if (app == null) {
            throw new Exception("Application can not be null");
        }
        Deployer deployer = glassfish.getDeployer();
        if (deployParams.size() > 0) {
            deployer.deploy(new File(app).toURI(), deployParams.toArray(new String[0]));
            System.out.println("Deployed [" + app + "] with parameters " + deployParams);
        } else {
            deployer.deploy(new File(app).toURI());
View Full Code Here

Examples of org.glassfish.embeddable.GlassFish

            System.out.println("Deployed [" + app + "]");
        }
    }

    public static void undeploy(String appName, String serverId) throws Exception {
        GlassFish glassfish = gfMap.get(serverId);
        if (glassfish == null) {
            throw new Exception("Embedded GlassFish [" + serverId + "] not running");
        }
        if (appName == null) {
            throw new Exception("Application name can not be null");
        }
        Deployer deployer = glassfish.getDeployer();
        deployer.undeploy(appName);
        System.out.println("Undeployed [" + appName + "]");
    }
View Full Code Here

Examples of org.glassfish.embeddable.GlassFish

        deployer.undeploy(appName);
        System.out.println("Undeployed [" + appName + "]");
    }

    public static void runCommand(String commandLine, String serverId) throws Exception {
        GlassFish glassfish = gfMap.get(serverId);
        if (glassfish == null) {
            throw new Exception("Embedded GlassFish [" + serverId + "] not running");
        }
        if (commandLine == null) {
            throw new Exception("Command can not be null");
        }
        String[] split = commandLine.split(" ");
        String command = split[0].trim();
        String[] commandParams = null;
        if (split.length > 1) {
            commandParams = new String[split.length - 1];
            for (int i = 1; i < split.length; i++) {
                commandParams[i - 1] = split[i].trim();
            }
        }
        CommandRunner cr = glassfish.getCommandRunner();
        CommandResult result = commandParams == null ?
                cr.run(command) : cr.run(command, commandParams);
        System.out.println("Executed command [" + commandLine +
                "]. Output : \n" + result.getOutput());
    }
View Full Code Here

Examples of org.glassfish.embeddable.GlassFish

                "]. Output : \n" + result.getOutput());
    }

    public static synchronized void disposeGlassFish(String serverID)
            throws GlassFishException {
        GlassFish glassfish = gfMap.remove(serverID);
        if (glassfish != null) {
            glassfish.dispose();
            System.out.println("Stopped GlassFish [" + serverID + "]");
        }
    }
View Full Code Here

Examples of org.glassfish.embeddable.GlassFish

            // we are supposed to stop. Leave any cleanup to some other code.
           
            // get the GlassFish object - we have to wait in case startup is still in progress
            // This is a temporary work-around until HK2 supports waiting for the service to
            // show up in the ServiceLocator.
            GlassFish gfKernel = habitat.getService(GlassFish.class);
            while (gfKernel == null) {
                Thread.sleep(1000);
                gfKernel = habitat.getService(GlassFish.class);
            }
            if (gfKernel != null) {
                gfKernel.stop();
            }
        }
        catch (Throwable t) {
            // ignore
        }
View Full Code Here

Examples of org.glassfish.embeddable.GlassFish

            init(context);
           
            // get the GlassFish object - we have to wait in case startup is still in progress
            // This is a temporary work-around until HK2 supports waiting for the service to
            // show up in the ServiceLocator.
            GlassFish gfKernel = glassfishProvider.get();
            while (gfKernel == null) {
                Thread.sleep(1000);
                gfKernel = glassfishProvider.get();
            }
           
            if (!verbose) {
                // do it now while we still have the Logging service running...
                reincarnate();
            }
            // else we just return a special int from System.exit()
            gfKernel.stop();
        }
        catch (Exception e) {
            context.getLogger().severe(strings.get("restart.server.failure", e));
        }
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.