Examples of GlassFish


Examples of org.glassfish.embeddable.GlassFish

        try {
            logger.info(localStrings.getLocalString("stop.domain.init", "Server shutdown initiated"));
            // Don't shutdown GlassFishRuntime, as that can bring the OSGi framework down which is wrong
            // when we are embedded inside an existing runtime. So, just stop the glassfish instance that
            // we are supposed to stop. Leave any cleanup to some other code.
            GlassFish gfKernel = habitat.getComponent(GlassFish.class);
            if (gfKernel != null) {
                gfKernel.stop();
            }
        }
        catch (Throwable t) {
            // ignore
        }
View Full Code Here

Examples of org.glassfish.embeddable.GlassFish

        System.setProperty("java.protocol.handler.pkgs", "org.ops4j.pax.url");
        System.setProperty("java.util.logging.config.file",
            "src/test/resources/glassfish-config/logging.properties");

        GlassFishProperties gfProps = new GlassFishProperties();
        GlassFish gf = GlassFishRuntime.bootstrap().newGlassFish(gfProps);
        gf.start();

        Deployer deployer = gf.getDeployer();
        for (String appName : deployer.getDeployedApplications()) {
            log.info("undeploying " + appName);
            deployer.undeploy(appName);
        }

        URI sampleWarUri = new URI("mvn:org.apache.wicket/wicket-examples/1.5.3/war");
        String sampleAppName = "wicket-examples";

        log.info("deploying " + sampleAppName);
        deployer.deploy(sampleWarUri, "--name", sampleAppName, "--contextroot", sampleAppName);

        log.info("undeploying " + sampleAppName);
        deployer.undeploy(sampleAppName);

        log.info("stopping GlassFish");
        gf.stop();
    }
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 (instanceRoot==null && configFileURI==null) {
            // only set port if embedded domain.xml is used
            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();
        final int len = deployParams.size();
        if (len > 0) {
            deployer.deploy(new File(app).toURI(), deployParams.toArray(new String[len]));
            System.out.println("Deployed [" + app + "] with parameters " + deployParams);
        } else {
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);
            }
            // gfKernel is absolutely positively for-sure not null.
            gfKernel.stop();
        }
        catch (Throwable t) {
            // ignore
        }
View Full Code Here

Examples of org.glassfish.embeddable.GlassFish

  public void setBundleContext(BundleContext context){
    ctx = context;
  }
 
   private GlassFish getGlassFish() {
         GlassFish gf = (GlassFish) ctx.getService(ctx.getServiceReference(GlassFish.class.getName()));
         try {
             assert(gf.getStatus() == GlassFish.Status.STARTED);
         } catch (GlassFishException e) {
             throw new RuntimeException(e);
         }
         return gf;
     }
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.