use of org.glassfish.embeddable.BootstrapProperties 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