use of org.glassfish.embeddable.GlassFish in project Payara by payara.
the class Util method deploy.
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 {
deployer.deploy(new File(app).toURI());
System.out.println("Deployed [" + app + "]");
}
}
use of org.glassfish.embeddable.GlassFish in project Payara by payara.
the class EmbeddedOSGiGlassFishRuntime method shutdown.
public synchronized void shutdown() throws GlassFishException {
// make a copy to avoid ConcurrentModificationException
for (GlassFish gf : new ArrayList<GlassFish>(gfs)) {
if (gf.getStatus() != GlassFish.Status.DISPOSED) {
try {
gf.dispose();
} catch (GlassFishException e) {
e.printStackTrace();
}
}
}
gfs.clear();
shutdownInternal();
System.out.println("Completed shutdown of GlassFish runtime");
}
use of org.glassfish.embeddable.GlassFish in project Payara by payara.
the class RestartServer method doExecute.
/**
* Restart of the application server :
*
* All running services are stopped. LookupManager is flushed.
*
* Client code that started us should notice the special return value and restart us.
*/
protected final void doExecute(AdminCommandContext context) {
try {
// unfortunately we can't rely on constructors with HK2...
if (registry == null) {
throw new NullPointerException(new LocalStringsImpl(getClass()).get("restart.server.internalError", "registry was not set"));
}
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 (!supervised) {
// do it now while we still have the Logging service running...
reincarnate();
}
prepareToExit();
// else we just return a special int from System.exit()
gfKernel.stop();
} catch (Exception e) {
context.getLogger().severe(strings.get("restart.server.failure", e));
} finally {
stopLock.unlock();
}
}
use of org.glassfish.embeddable.GlassFish in project Payara by payara.
the class StopServer method doExecute.
/**
* Shutdown of the server :
*
* All running services are stopped.
* LookupManager is flushed.
*/
protected final void doExecute(ServiceLocator habitat, ServerEnvironment env, boolean force) {
try {
KernelLoggerInfo.getLogger().info(KernelLoggerInfo.serverShutdownInit);
// 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.
// 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
}
if (force) {
System.exit(0);
} else {
deletePidFile(env);
}
}
Aggregations