BootstrapProperties bootstrapProperties = new BootstrapProperties(); bootstrapProperties.setInstallRoot("C:\\applicationserverdir"); GlassFishRuntime glassfishRuntime = GlassFishRuntime.bootstrap(bootstrapProperties); GlassFishProperties glassfishProperties = new GlassFishProperties(); glassfishProperties.setInstanceRoot("C:\\applicationserverdir\\domains\\myJavaFXAppDomain"); glassfishProperties.setPort("http-listener", 8080); glassfishProperties.setPort("https-listener", 8181); GlassFish glassfish = glassfishRuntime.newGlassFish(glassfishProperties); glassfish.start();
private void setGlassFishProperties(GlassFishProperties props, EmbeddedFileSystem fs) { props.setProperty("-type", "EMBEDDED"); props.setProperty("org.glassfish.persistence.embedded.weaving.enabled", "false"); if (fs != null) { String instanceRoot = fs.instanceRoot != null ? fs.instanceRoot.getAbsolutePath() : null; if (instanceRoot != null) { props.setInstanceRoot(fs.instanceRoot.getAbsolutePath()); } if (fs.configFile != null) { props.setConfigFileURI(fs.configFile.toURI().toString()); } if (fs.autoDelete) { props.setProperty("org.glassfish.embeddable.autoDelete", "true"); } } // TODO :: Support modification of jmxPort }
private LauncherMain(String[] args) { try { new CmdLineParser(this).parseArgument(args); } catch (CmdLineException ex) { throw new IllegalArgumentException(ex); } if (inputWar == null) { throw new IllegalArgumentException("No --deploy is given."); } if (configFile != null) { glassfishProperties.setConfigFileReadOnly(true); if (outputJar == null) { glassfishProperties.setConfigFileURI(new File(configFile).toURI().normalize().toString()); } } else { glassfishProperties.setConfigFileReadOnly(false); glassfishProperties.setPort("http-listener", httpListener); glassfishProperties.setPort("https-listener", httpsListener); } if (contextRoot != null) { deployProperties.setContextRoot(contextRoot); } if (libraries != null) { deployProperties.setLibraries(libraries); } }
GlassFishProperties glassFishProperties = new GlassFishProperties(newProps); if (Boolean.getBoolean(KEEP_TEMPORARY_FILES)) { glassFishProperties.setProperty("org.glassfish.embeddable.autoDelete", "false"); // set autodelete to false. glassFishProperties.setConfigFileReadOnly(false); // make sure the domain.xml is written back. _logger.fine("[EJBContainerProviderImpl] Reusing instance location at: " + l.instance_root); glassFishProperties.setInstanceRoot(l.instance_root.getCanonicalPath()); } else { glassFishProperties.setConfigFileURI(l.domain_file.toURI().toString());
GlassFishProperties serverProps = new GlassFishProperties(); cleanup = false; serverProps.setInstanceRoot(configuration.getInstanceRoot()); shouldSetPort = false; serverProps.setConfigFileURI(configuration.getConfigurationXml()); shouldSetPort = false; serverProps.setConfigFileReadOnly(configuration.isConfigurationReadOnly()); if (shouldSetPort) { bindHttpPort = configuration.getBindHttpPort(); serverProps.setPort("http-listener", bindHttpPort); bindHttpsPort = configuration.getBindHttpsPort(); serverProps.setPort("https-listener", bindHttpsPort);
/** * Create a new instance of GlassFish with default {@link org.glassfish.embeddable.GlassFishProperties} * * @return New GlassFish instance. * @throws GlassFishException If at all fails to create a new GlassFish instance. */ public GlassFish newGlassFish() throws GlassFishException { return newGlassFish(new GlassFishProperties()); }
public synchronized void launch() { if (glassFish != null) { return; } /* * Running under "Run as JUnit test" from Eclipse in a separate process, we do not get * notified when Eclipse is finished running the test suite. The shutdown hook is just * to be on the safe side. */ addShutdownHook(); File domainConfig = getConfiguration(); if (!domainConfig.exists()) { throw new IllegalArgumentException(domainConfig + " not found"); } GlassFishProperties gfProps = new GlassFishProperties(); if (domainConfig.exists()) { gfProps.setConfigFileURI(domainConfig.toURI().toString()); } try { glassFish = GlassFishRuntime.bootstrap().newGlassFish(gfProps); glassFish.start(); } catch (GlassFishException exc) { throw new RuntimeException(exc); } }
private void start() { try ( InputStream gpis = this.getClass().getClassLoader().getResourceAsStream("uber-jar_glassfish.properties"); InputStream dpis = this.getClass().getClassLoader().getResourceAsStream("uber-jar_deploy.properties"); InputStream wis = this.getClass().getClassLoader().getResourceAsStream("uber-jar_application.war")) { GlassFishProperties glassfishProperties = new GlassFishProperties(); glassfishProperties.getProperties().load(gpis); URL url = this.getClass().getClassLoader().getResource("uber-jar_domain.xml"); if (url != null) { glassfishProperties.setConfigFileURI(url.toURI().toString()); } DeployProperties deployProperties = new DeployProperties(); deployProperties.load(dpis); GlassFish glassfish = GlassFishRuntime.bootstrap().newGlassFish(glassfishProperties); glassfish.start(); glassfish.getDeployer().deploy(wis, deployProperties.getDeployOptions()); } catch (Throwable th) { Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Server was stopped.", th); System.exit(1); } } }
String port = System.getenv("PORT"); GlassFishProperties gfProps = new GlassFishProperties(); gfProps.setPort("http-listener", Integer.parseInt(port)); GlassFish glassfish = GlassFishRuntime.bootstrap().newGlassFish(gfProps); glassfish.start(); Deployer deployer = glassfish.getDeployer(); File file = new File("YourSimpleMavenWebapplication.war"); deployer.deploy(file);
public void run() throws Exception { GlassFishProperties gfProps =new GlassFishProperties(); gfProps.setProperty("org.glassfish.embeddable.autoDelete", System.getProperty("org.glassfish.embeddable.autoDelete", "true"));
cloned.putAll(glassFishProperties.getProperties()); final GlassFishProperties gfProps = new GlassFishProperties(cloned); setEnv(gfProps); final StartupContext startupContext = new StartupContext(gfProps.getProperties()); GlassFishImpl gfImpl = new GlassFishImpl(gfKernel, serviceLocator, gfProps.getProperties()) { @Override public void dispose() throws GlassFishException { gfMap.put(gfProps.getInstanceRoot(), gfImpl); return gfImpl; } catch (GlassFishException e) {
String instanceRootValue = gfProps.getInstanceRoot(); if (instanceRootValue == null) { instanceRootValue = createTempInstanceRoot(gfProps); gfProps.setInstanceRoot(instanceRootValue); gfProps.getProperties().setProperty(Constants.INSTALL_ROOT_PROP_NAME, installRoot.getAbsolutePath()); gfProps.getProperties().setProperty(Constants.INSTALL_ROOT_URI_PROP_NAME, installRoot.toURI().toString());
public GlassfishPreStartConfigurator setHttpPort(int port) { props.setPort("http-listener", port); return this; } }
GlassFishProperties glassFishProperties = new GlassFishProperties(newProps); if (Boolean.getBoolean(KEEP_TEMPORARY_FILES)) { glassFishProperties.setProperty("org.glassfish.embeddable.autoDelete", "false"); // set autodelete to false. glassFishProperties.setConfigFileReadOnly(false); // make sure the domain.xml is written back. glassFishProperties.setInstanceRoot(l.instance_root.getCanonicalPath()); } else if (l.domain_file != null) { _logger.info("[EJBContainerProviderImpl] Using config file location: " + l.domain_file.toURI().toString()); glassFishProperties.setConfigFileURI(l.domain_file.toURI().toString());
/** * Create a new instance of GlassFish with default {@link org.glassfish.embeddable.GlassFishProperties} * * @return New GlassFish instance. * @throws GlassFishException If at all fails to create a new GlassFish instance. */ public GlassFish newGlassFish() throws GlassFishException { return newGlassFish(new GlassFishProperties()); }
/** * Starts the GlassFish container. */ @Override public void start() { System.setProperty("java.protocol.handler.pkgs", "org.ops4j.pax.url"); ConfigurationManager cm = new ConfigurationManager(); configDirName = cm.getProperty(GLASSFISH_CONFIG_DIR_KEY, "src/test/resources/glassfish-config"); File domainConfig = new File(configDirName, "domain.xml"); GlassFishProperties gfProps = new GlassFishProperties(); if (domainConfig.exists()) { gfProps.setConfigFileURI(domainConfig.toURI().toString()); } try { glassFish = GlassFishRuntime.bootstrap().newGlassFish(gfProps); glassFish.start(); // set access point in test directory String portNumber = getPortNumber(domainConfig); testDirectory.setAccessPoint(new URI("http://localhost:" + portNumber + "/Pax-Exam-Probe/")); deployModules(); } catch (GlassFishException e) { throw new TestContainerException("Problem starting test container.", e); } catch (URISyntaxException e) { throw new TestContainerException("Problem starting test container.", e); } }
public void run() throws Exception { GlassFishProperties gfProps =new GlassFishProperties(); gfProps.setProperty("org.glassfish.embeddable.autoDelete", System.getProperty("org.glassfish.embeddable.autoDelete", "true"));
cloned.putAll(glassFishProperties.getProperties()); final GlassFishProperties gfProps = new GlassFishProperties(cloned); setEnv(gfProps); final StartupContext startupContext = new StartupContext(gfProps.getProperties()); GlassFishImpl gfImpl = new GlassFishImpl(gfKernel, serviceLocator, gfProps.getProperties()) { @Override public void dispose() throws GlassFishException { gfMap.put(gfProps.getInstanceRoot(), gfImpl); return gfImpl; } catch (GlassFishException e) {
String instanceRootValue = gfProps.getInstanceRoot(); if (instanceRootValue == null) { instanceRootValue = createTempInstanceRoot(gfProps); gfProps.setInstanceRoot(instanceRootValue); gfProps.getProperties().setProperty(Constants.INSTALL_ROOT_PROP_NAME, installRoot.getAbsolutePath()); gfProps.getProperties().setProperty(Constants.INSTALL_ROOT_URI_PROP_NAME, installRoot.toURI().toString());
private void addWebContainerIfRequested(Map<?, ?> properties, GlassFishProperties props) throws EJBException { String http_port = (properties == null)? null : (String)properties.get(GF_WEB_HTTP_PORT); if (http_port != null) { int port = 8080; try { port = Integer.parseInt(http_port); } catch (NumberFormatException e) { System.err.println("Using port 8080"); } props.setPort("http-listener-1", port); } }