use of com.sun.enterprise.module.bootstrap.StartupContext in project Payara by payara.
the class CommandRunnerTest method setup.
@BeforeClass
public void setup() {
/*
* The CommandRunnerImpl now injects Domain but these tests do not
* exercise the code path that requires the domain. So register a
* dummy Domain instance with the habitat so injection will work.
*/
ServiceLocatorUtilities.addOneDescriptor(testLocator, BuilderHelper.createConstantDescriptor(simpleDomain(), null, Domain.class));
ServiceLocatorUtilities.addOneConstant(testLocator, new StartupContext());
ServiceLocatorUtilities.addOneDescriptor(testLocator, BuilderHelper.createConstantDescriptor(new SingleModulesRegistry(CommandRunnerTest.class.getClassLoader()), null, ModulesRegistry.class));
}
use of com.sun.enterprise.module.bootstrap.StartupContext in project Payara by payara.
the class EmbeddedOSGiGlassFishRuntime method newGlassFish.
@Override
public synchronized GlassFish newGlassFish(GlassFishProperties gfProps) throws GlassFishException {
try {
// set env props before updating config, because configuration update may actually trigger
// some code to be executed which may be depending on the environment variable values.
setEnv(gfProps.getProperties());
final StartupContext startupContext = new StartupContext(gfProps.getProperties());
final ServiceTracker hk2Tracker = new ServiceTracker(getBundleContext(), Main.class.getName(), null);
hk2Tracker.open();
final Main main = (Main) hk2Tracker.waitForService(0);
hk2Tracker.close();
final ModulesRegistry mr = ModulesRegistry.class.cast(getBundleContext().getService(getBundleContext().getServiceReference(ModulesRegistry.class.getName())));
ServiceLocator serviceLocator = main.createServiceLocator(mr, startupContext, null, null);
final ModuleStartup gfKernel = main.findStartupService(mr, serviceLocator, null, startupContext);
GlassFish glassFish = createGlassFish(gfKernel, serviceLocator, gfProps.getProperties());
gfs.add(glassFish);
return glassFish;
} catch (BootException ex) {
throw new GlassFishException(ex);
} catch (InterruptedException ex) {
throw new GlassFishException(ex);
}
}
use of com.sun.enterprise.module.bootstrap.StartupContext in project Payara by payara.
the class SunDeploymentManager method prepareHabitat.
private void prepareHabitat() {
ModulesRegistry registry = new StaticModulesRegistry(getClass().getClassLoader());
ServiceLocator serviceLocator = registry.createServiceLocator("default");
habitat = serviceLocator.getService(ServiceLocator.class);
StartupContext startupContext = new StartupContext();
ServiceLocatorUtilities.addOneConstant(habitat, startupContext);
ServiceLocatorUtilities.addOneConstant(habitat, new ProcessEnvironment(ProcessEnvironment.ProcessType.Other));
}
use of com.sun.enterprise.module.bootstrap.StartupContext in project Payara by payara.
the class AppServerStartupTest method initialize.
// ----- test initialization ---------------------------------------------
private void initialize(ServiceLocator testLocator) {
DynamicConfigurationService dcs = testLocator.getService(DynamicConfigurationService.class);
DynamicConfiguration config = dcs.createDynamicConfiguration();
config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(new TestSystemTasks()));
// These are services that would normally be started by hk2 core
config.addActiveDescriptor(AppServerStartup.AppInstanceListener.class);
AbstractActiveDescriptor<?> descriptor = BuilderHelper.createConstantDescriptor(new TestModulesRegistry());
descriptor.addContractType(ModulesRegistry.class);
config.addActiveDescriptor(descriptor);
descriptor = BuilderHelper.createConstantDescriptor(new ExecutorServiceFactory().provide());
descriptor.addContractType(ExecutorService.class);
config.addActiveDescriptor(descriptor);
config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(new ServerEnvironmentImpl()));
config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(new EventsImpl()));
config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(new Version()));
config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(new StartupContext()));
config.bind(BuilderHelper.link(RunLevelControllerImpl.class).to(RunLevelController.class).build());
config.addUnbindFilter(BuilderHelper.createContractFilter(RunLevelContext.class.getName()));
config.bind(BuilderHelper.link(RunLevelContext.class).to(Context.class).in(Singleton.class).build());
config.addUnbindFilter(BuilderHelper.createContractFilter(AsyncRunLevelContext.class.getName()));
config.bind(BuilderHelper.link(AsyncRunLevelContext.class).in(Singleton.class).build());
config.bind(BuilderHelper.link(AppServerStartup.class).build());
descriptor = BuilderHelper.createConstantDescriptor(testLocator);
descriptor.addContractType(ServiceLocator.class);
config.addActiveDescriptor(descriptor);
bindService(config, TestInitRunLevelService.class);
bindService(config, TestStartupService.class);
bindService(config, TestStartupRunLevelService.class);
bindService(config, TestPostStartupRunLevelService.class);
bindService(config, CommonClassLoaderServiceImpl.class);
bindService(config, APIClassLoaderServiceImpl.class);
bindService(config, APIExporterImpl.class);
config.commit();
}
use of com.sun.enterprise.module.bootstrap.StartupContext in project Payara by payara.
the class PhoneHomeTask method getUptime.
private String getUptime() {
RuntimeMXBean mxbean = ManagementFactory.getRuntimeMXBean();
long totalTime_ms = -1;
if (mxbean != null)
totalTime_ms = mxbean.getUptime();
if (totalTime_ms <= 0 && env != null) {
StartupContext ctx = env.getStartupContext();
if (ctx != null) {
long start = ctx.getCreationTime();
totalTime_ms = System.currentTimeMillis() - start;
}
}
return Long.toString(totalTime_ms);
}
Aggregations