private void launch() { try { GlassFish glassfish = GlassFishRuntime.bootstrap().newGlassFish(glassfishProperties); glassfish.start(); glassfish.getDeployer().deploy(new File(inputWar), deployProperties.getDeployOptions()); } catch (Throwable th) { Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Server was stopped.", th); System.exit(1); } }
Deployer deployer = glassfish.getDeployer(); // Create a scattered web application. ScatteredArchive archive = new ScatteredArchive("testapp", ScatteredArchive.Type.WAR); // target/classes directory contains my complied servlets archive.addClassPath(new File("target", "classes")); // resources/sun-web.xml is my WEB-INF/sun-web.xml archive.addMetadata(new File("resources", "sun-web.xml")); // resources/MyLogFactory is my META-INF/services/org.apache.commons.logging.LogFactory archive.addMetadata(new File("resources", "MyLogFactory"), "META-INF/services/org.apache.commons.logging.LogFactory"); deployer.deploy(archive.toURI())
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);
//Start GF GlassFishRuntime gfRuntime = GlassFishRuntime.bootstrap(); GlassFish gf = gfRuntime.newGlassFish(); gf.start(); //Deploy application with EJBs Deployer deployer = gf.getService(Deployer.class); String deployedApp = deployer.deploy(new File(...), "--force=true"); //Create InitialContext Properties props = new Properties(); props.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory"); props.setProperty("java.naming.factory.url.pkgs", "com.sun.enterprise.naming"); props.setProperty("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl"); props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost"); props.setProperty("org.omg.CORBA.ORBInitialPort", "3700"); InitialContext ic = new InitialContext(props); //Lookup EJBs ic.lookup(...) //Stop GF gf.stop(); gfRuntime.shutdown(); //CORBA stuck thread, have to kill it manually System.exit(0);
private void deployWar(URI warUri) throws GlassFishException { Deployer deployer = glassFish.getDeployer(); String appName = deployer.deploy(warUri, "--name", getApplicationName(), "--contextroot", getContextRoot()); if (! getApplicationName().equals(appName)) { throw new RuntimeException("error deploying WAR"); } }
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); } } }
@RunWith(Arquillian.class) public class TestA { @Deployment(name = "x", managed = false) @TargetsContainer("manual_felix") public static Archive<?> deployment() { return ShrinkWrap.create.... } @ArquillianResource private ContainerController cc; @ArquillianResource private Deployer d; @Test @InSequence(1) public void start() { cc.start("manual_felix", new Config().add("frameworkProperties", "my-custom-properties-file")); d.deploy("x"); } @Test @InSequence(2) @OperatesOnDeployment("x") public void shouldDoSomethingInsideX() { // executes inside container in context of X } }
public void deploy(Archive<?> archive) { try { ZipExporter exporter = archive.as(ZipExporter.class); File file = tmpFolder.newFile(archive.getName()); exporter.exportTo(file, true); final String appName = getDeployer().deploy(file); log.info("Application {} deployed as {}", archive.getName(), appName); } catch (Exception e) { throw new RuntimeException("Deployment failed", e); } }
tempFile.deleteOnExit(); StreamUtils.copyStream(stream, new FileOutputStream(tempFile), true); deployer.deploy(tempFile, "--name", PROBE_APPLICATION_NAME, "--contextroot", PROBE_APPLICATION_NAME); deployed.push(PROBE_APPLICATION_NAME);
if (app instanceof ScatteredArchive) { _logger.info("[EJBContainerImpl] Deploying as a ScatteredArchive"); deployedAppName = deployer.deploy(((ScatteredArchive)app).toURI(), params); } else { _logger.info("[EJBContainerImpl] Deploying as a File"); deployedAppName = deployer.deploy((File)app, params);
deployer.deploy(uri, "--name", applicationName, "--contextroot", applicationName); deployed.push(applicationName); LOG.info("deployed module {}", url);
String name = deployer.deploy(uri, params); System.out.println("Deployed = " + name); } else if (command.startsWith("undeploy")) {
String name = deployer.deploy(uri, params); System.out.println("Deployed = " + name); } else if (command.startsWith("undeploy")) {
archive.addClassPath(new File("target", "test-classes")); appName = deployer.deploy(archive.toURI(), "--force=true");
String appName = deployer.deploy(docRoot, "--name", contextRoot);
public ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException { String deploymentName = createDeploymentName(archive.getName()); try { URL deploymentUrl = ShrinkWrapUtil.toURL(archive); glassfish.getDeployer().deploy(deploymentUrl.toURI(), "--name", deploymentName); } catch (Exception e) { throw new DeploymentException("Could not deploy " + archive.getName(), e); } try { HTTPContext httpContext = new HTTPContext(ADDRESS, bindHttpPort); findServlets(httpContext, resolveWebArchiveNames(archive)); return new ProtocolMetaData() .addContext(httpContext); } catch (GlassFishException e) { throw new DeploymentException("Could not probe GlassFish embedded for environment", e); } }