use of org.glassfish.embeddable.GlassFishException in project Payara by payara.
the class DeployerImpl method getDeployedApplications.
@Override
public Collection<String> getDeployedApplications() throws GlassFishException {
try {
CommandExecutorImpl executer = habitat.getService(CommandExecutorImpl.class);
ActionReport report = executer.executeCommand("list-components");
Properties props = report.getTopMessagePart().getProps();
return new ArrayList<String>(props.stringPropertyNames());
} catch (Exception e) {
throw new GlassFishException(e);
}
}
use of org.glassfish.embeddable.GlassFishException in project Payara by payara.
the class DeployerImpl method deploy.
@Override
public String deploy(File file, String... params) throws GlassFishException {
String[] newParams = new String[params.length + 1];
System.arraycopy(params, 0, newParams, 0, params.length);
newParams[params.length] = file.getAbsolutePath();
CommandExecutorImpl executer = habitat.getService(CommandExecutorImpl.class);
try {
String command = "deploy";
ActionReport actionReport = executer.createActionReport();
ParameterMap commandParams = executer.getParameters(command, newParams);
org.glassfish.api.admin.CommandRunner.CommandInvocation inv = executer.getCommandRunner().getCommandInvocation(command, actionReport, kernelIdentity.getSubject());
inv.parameters(commandParams);
// set outputbound payload if --retrieve option is specified.
Payload.Outbound outboundPayload = null;
String retrieveOpt = commandParams.getOne("retrieve");
File retrieve = retrieveOpt != null ? new File(retrieveOpt) : null;
if (retrieve != null && retrieve.exists()) {
outboundPayload = PayloadImpl.Outbound.newInstance();
inv.outbound(outboundPayload);
}
inv.execute();
// extract the outbound payload.
if (outboundPayload != null) {
extractPayload(outboundPayload, actionReport, retrieve);
}
return actionReport.getResultType(String.class);
} catch (CommandException e) {
throw new GlassFishException(e);
}
}
use of org.glassfish.embeddable.GlassFishException 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.GlassFishException in project Payara by payara.
the class OSGiGlassFishRuntime method shutdown.
@Override
public void shutdown() throws GlassFishException {
if (framework == null) {
// already shutdown
return;
}
try {
super.shutdown();
framework.stop();
framework.waitForStop(0);
} catch (InterruptedException ex) {
throw new GlassFishException(ex);
} catch (BundleException ex) {
throw new GlassFishException(ex);
} finally {
// guard against repeated calls.
framework = null;
}
}
use of org.glassfish.embeddable.GlassFishException in project Payara by payara.
the class OSGiGlassFishRuntimeBuilder method build.
public GlassFishRuntime build(BootstrapProperties bsProps) throws GlassFishException {
try {
MainHelper.buildStartupContext(bsProps.getProperties());
Properties properties = bsProps.getProperties();
// Set the builder name so that when we check for nonEmbedded() inside GlassFishMainActivator,
// we can identify the environment.
properties.setProperty(Constants.BUILDER_NAME_PROPERTY, getClass().getName());
// Step 0: Locate and launch a framework
long t0 = System.currentTimeMillis();
fwLauncher = new OSGiFrameworkLauncher(properties);
framework = fwLauncher.launchOSGiFrameWork();
long t1 = System.currentTimeMillis();
logger.logp(Level.FINE, "OSGiGlassFishRuntimeBuilder", "build", "Launched {0}", new Object[] { framework });
// Step 1: install/update/delete bundles
if (newFramework()) {
storeProvisioningOptions(properties);
} else {
// this will reconfigure if any provisioning options have changed.
reconfigure(properties);
}
BundleProvisioner bundleProvisioner = BundleProvisioner.createBundleProvisioner(framework.getBundleContext(), properties);
List<Long> bundleIds = bundleProvisioner.installBundles();
if (bundleProvisioner.hasAnyThingChanged()) {
bundleProvisioner.refresh();
// clean hk2 cache so that updated bundle details will go in there.
deleteHK2Cache(properties);
// Save the bundle ids for use during restart.
storeBundleIds(bundleIds.toArray(new Long[bundleIds.size()]));
}
if (bundleProvisioner.isSystemBundleUpdationRequired()) {
logger.log(Level.INFO, LogFacade.UPDATING_SYSTEM_BUNDLE);
framework.update();
framework.waitForStop(0);
framework.init();
bundleProvisioner.setBundleContext(framework.getBundleContext());
}
// Step 2: Start bundles
bundleProvisioner.startBundles();
long t2 = System.currentTimeMillis();
// Step 3: Start the framework, so bundles will get activated as per their start levels
framework.start();
long t3 = System.currentTimeMillis();
printStats(bundleProvisioner, t0, t1, t2, t3);
// Step 4: Obtain reference to GlassFishRuntime and return the same
return getGlassFishRuntime();
} catch (Exception e) {
throw new GlassFishException(e);
}
}
Aggregations