org.glassfish.embeddable.GlassFish.start()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(11.7k)|赞(0)|评价(0)|浏览(142)

本文整理了Java中org.glassfish.embeddable.GlassFish.start()方法的一些代码示例,展示了GlassFish.start()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GlassFish.start()方法的具体详情如下:
包路径:org.glassfish.embeddable.GlassFish
类名称:GlassFish
方法名:start

GlassFish.start介绍

[英]Start GlassFish. When this method is called, all the lifecycle (aka startup) services are started. Calling this method while the server is in Status#STARTED state is a no-op.
[中]开始吃玻璃鱼。调用此方法时,将启动所有生命周期(也称为启动)服务。当服务器处于“已启动”状态时调用此方法是不可操作的。

代码示例

代码示例来源:origin: eclipse-ee4j/glassfish

@Override
public void start() throws GlassFishException {
  decoratedGf.start();
}

代码示例来源:origin: org.glassfish.main.core/glassfish

@Override
public void start() throws GlassFishException {
  decoratedGf.start();
}

代码示例来源:origin: fujitsu/launcher

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);
  }
}

代码示例来源:origin: eclipse-ee4j/glassfish

/**
 * Starts the embedded server, opening ports, and running the startup
 * services.
 *
 * @throws LifecycleException if the server cannot be started propertly
 */
public synchronized void start() throws LifecycleException {
  if(glassfish != null) {
    try {
      if (glassfish.getStatus() != GlassFish.Status.STARTED) {
        glassfish.start();
      }
    } catch (GlassFishException e) {
      throw new LifecycleException(e); // TODO(Sahoo): Proper Exception Handling
    }
    logger.finer("GlassFish has been started");
  }
}

代码示例来源:origin: stackoverflow.com

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

代码示例来源:origin: org.glassfish.common/internal-api

/**
 * Starts the embedded server, opening ports, and running the startup
 * services.
 *
 * @throws LifecycleException if the server cannot be started propertly
 */
public synchronized void start() throws LifecycleException {
  if(glassfish != null) {
    try {
      if (glassfish.getStatus() != GlassFish.Status.STARTED) {
        glassfish.start();
      }
    } catch (GlassFishException e) {
      throw new LifecycleException(e); // TODO(Sahoo): Proper Exception Handling
    }
    logger.finer("GlassFish has been started");
  }
}

代码示例来源:origin: stackoverflow.com

//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);

代码示例来源:origin: fujitsu/launcher

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);
    }
  }
}

代码示例来源:origin: eclipse-ee4j/glassfish

public void start(BundleContext context) throws Exception {
  nonEmbedded = context.getProperty(Constants.BUILDER_NAME_PROPERTY) != null;
  if (nonEmbedded) {
    GlassFishRuntime embeddedGfr = new EmbeddedOSGiGlassFishRuntime(context);
    context.registerService(GlassFishRuntime.class.getName(), embeddedGfr, null);
    System.out.println("Registered " + embeddedGfr + " in service registry.");
  } else {
    Properties properties = prepareStartupContext(context);
    final BootstrapProperties bsProperties = new BootstrapProperties(properties);
    System.out.println(GlassFishRuntime.class + " is loaded by [" + GlassFishRuntime.class.getClassLoader() + "]");
    GlassFishRuntime existingGfr = lookupGfr(context);
    if (existingGfr == null) {
      System.out.println("Bootstrapping a new GlassFishRuntime");
      // Should we do the following in a separate thread?
      gfr = GlassFishRuntime.bootstrap(bsProperties, getClass().getClassLoader());
      existingGfr = gfr;
    } else {
      System.out.println("Using existing GlassFishRuntime: [" + existingGfr + "]");
    }
    gf = existingGfr.newGlassFish(new GlassFishProperties(properties));
    gf.start();
  }
}

代码示例来源:origin: org.glassfish.main.ejb/ejb-container

/**
 * Construct new EJBContainerImpl instance 
 */                                               
EJBContainerImpl(GlassFish server) throws GlassFishException {
  this.server = server;
  this.server.start();
  this.habitat = server.getService(ServiceLocator.class);
  deployer = server.getDeployer();
  state = RUNNING;
  cleanup = new Cleanup(this);
}

代码示例来源:origin: org.glassfish.ejb/ejb-container

/**
 * Construct new EJBContainerImpl instance 
 */                                               
EJBContainerImpl(GlassFish server) throws GlassFishException {
  this.server = server;
  this.server.start();
  this.habitat = server.getService(Habitat.class);
  deployer = server.getDeployer();
  state = RUNNING;
  cleanup = new Cleanup(this);
}

代码示例来源:origin: org.glassfish.main.core/glassfish

public void start(BundleContext context) throws Exception {
  nonEmbedded = context.getProperty(Constants.BUILDER_NAME_PROPERTY) != null;
  if (nonEmbedded) {
    GlassFishRuntime embeddedGfr = new EmbeddedOSGiGlassFishRuntime(context);
    context.registerService(GlassFishRuntime.class.getName(), embeddedGfr, null);
    System.out.println("Registered " + embeddedGfr + " in service registry.");
  } else {
    Properties properties = prepareStartupContext(context);
    final BootstrapProperties bsProperties = new BootstrapProperties(properties);
    System.out.println(GlassFishRuntime.class + " is loaded by [" + GlassFishRuntime.class.getClassLoader() + "]");
    GlassFishRuntime existingGfr = lookupGfr(context);
    if (existingGfr == null) {
      System.out.println("Bootstrapping a new GlassFishRuntime");
      // Should we do the following in a separate thread?
      gfr = GlassFishRuntime.bootstrap(bsProperties, getClass().getClassLoader());
      existingGfr = gfr;
    } else {
      System.out.println("Using existing GlassFishRuntime: [" + existingGfr + "]");
    }
    gf = existingGfr.newGlassFish(new GlassFishProperties(properties));
    gf.start();
  }
}

代码示例来源:origin: eclipse-ee4j/glassfish

public void launch(Properties ctx) throws Exception {
  addShutdownHook();
  gfr = GlassFishRuntime.bootstrap(new BootstrapProperties(ctx), getClass().getClassLoader());
  gf = gfr.newGlassFish(new GlassFishProperties(ctx));
  if (Boolean.valueOf(Util.getPropertyOrSystemProperty(ctx, "GlassFish_Interactive", "false"))) {
    startConsole();
  } else {
    gf.start();
  }
}

代码示例来源:origin: org.glassfish.main.core/glassfish

public void launch(Properties ctx) throws Exception {
  addShutdownHook();
  gfr = GlassFishRuntime.bootstrap(new BootstrapProperties(ctx), getClass().getClassLoader());
  gf = gfr.newGlassFish(new GlassFishProperties(ctx));
  if (Boolean.valueOf(Util.getPropertyOrSystemProperty(ctx, "GlassFish_Interactive", "false"))) {
    startConsole();
  } else {
    gf.start();
  }
}

代码示例来源:origin: com.googlecode.jeeunit/jeeunit-glassfish

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);
  }
}

代码示例来源:origin: com.java-adventures.junit/glassfish-junit-rule

public void start() {
  try {
    if (gfr == null) {
      gfr = GlassFishRuntime.bootstrap();
    }
    if (gf == null) {
      gf = gfr.newGlassFish(configurator.getProps());
      gf.start();
    }
    glassfishFuture.setGlassFish(gf);
    log.info("Executing {} startup commands.", startupCommands.size());
    for (AbstractAdminObject command : startupCommands) {
      try {
        log.info("Executing command: {}", command);
        command.execute(ctx);
      } catch (Exception e) {
        log.error("Startup failed. ", e);
        fail();
      }
    }
  } catch (GlassFishException e) {
    log.error("Startup failed", e);
    fail();
  }
}

代码示例来源:origin: org.jboss.arquillian.container/arquillian-glassfish-embedded-3.1

public void start() throws LifecycleException {
  try {
    glassfish.start();
    if (!shouldSetPort) {
      readBindingHttpPort();
    }
    bindCommandRunner();
  } catch (Exception e) {
    throw new LifecycleException("Could not start GlassFish Embedded", e);
  }
  // Server needs to be started before we can deploy resources
  for (String resource : configuration.getResourcesXml()) {
    try {
      executeCommand(COMMAND_ADD_RESOURCES, resource);
    } catch (Throwable e) {
      throw new RuntimeException("Could not deploy sun-reosurces file: " + resource, e);
    }
  }
}

代码示例来源:origin: ops4j/org.ops4j.pax.exam2

/**
 * 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);
  }
}

代码示例来源:origin: org.glassfish.common/internal-api

setGlassFishProperties(gfProps, fs);
glassfish = glassfishRuntime.newGlassFish(gfProps);
glassfish.start();

代码示例来源:origin: stackoverflow.com

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();

相关文章