use of org.glassfish.hk2.api.DynamicConfigurationService in project Payara by payara.
the class RunCommandTest method setUp.
@Before
public void setUp() {
serviceLocator = ServiceLocatorFactory.getInstance().create("testServiceLocator");
ServiceLocatorUtilities.addOneConstant(serviceLocator, new TestNotificationService());
ServiceLocatorUtilities.addOneConstant(serviceLocator, this);
ServiceLocatorUtilities.addClasses(serviceLocator, AdminAuditService.class, GetAdminAuditServiceConfiguration.class, TestConfiguration.class, StartupContext.class, ServerEnvironmentImpl.class, PayaraNotificationFactory.class, Target.class, TestCommandRunner.class);
Globals.setDefaultHabitat(serviceLocator);
DynamicConfigurationService dcs = serviceLocator.getService(DynamicConfigurationService.class);
DynamicConfiguration config = dcs.createDynamicConfiguration();
config.addActiveDescriptor(RunLevelControllerImpl.class);
config.addActiveDescriptor(AsyncRunLevelContext.class);
config.addActiveDescriptor(RunLevelContext.class);
config.commit();
serviceLocator.getService(RunLevelController.class).proceedTo(StartupRunLevel.VAL);
events = new LinkedList<>();
}
use of org.glassfish.hk2.api.DynamicConfigurationService in project Payara by payara.
the class AppServerStartup method run.
/**
* @return True is startup succeeded, false if an error occurred preventing
* the server from starting
*/
public boolean run() {
if (context == null) {
System.err.println("Startup context not provided, cannot continue");
return false;
}
if (platform == null) {
platform = "Embedded";
}
platformInitTime = System.currentTimeMillis();
if (logger.isLoggable(level)) {
logger.log(level, "Startup class : {0}", getClass().getName());
}
// prepare the global variables
DynamicConfigurationService dcs = locator.getService(DynamicConfigurationService.class);
DynamicConfiguration config = dcs.createDynamicConfiguration();
config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(logger));
config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(masterListener));
config.addUnbindFilter(BuilderHelper.createContractFilter(ProcessEnvironment.class.getName()));
config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(env.isEmbedded() ? new ProcessEnvironment(ProcessEnvironment.ProcessType.Embedded) : new ProcessEnvironment(ProcessEnvironment.ProcessType.Server)));
config.commit();
// activate the run level services
masterListener.reset();
long initFinishTime = 0L;
long startupFinishTime = 0L;
if (!proceedTo(InitRunLevel.VAL)) {
appInstanceListener.stopRecordingTimes();
return false;
}
if (!logger.isLoggable(level)) {
// Stop recording the times, no-one cares
appInstanceListener.stopRecordingTimes();
} else {
initFinishTime = System.currentTimeMillis();
logger.log(level, "Init level done in " + (initFinishTime - context.getCreationTime()) + " ms");
}
appInstanceListener.startRecordingFutures();
if (!proceedTo(StartupRunLevel.VAL)) {
appInstanceListener.stopRecordingTimes();
return false;
}
if (!postStartupJob()) {
appInstanceListener.stopRecordingTimes();
return false;
}
if (logger.isLoggable(level)) {
startupFinishTime = System.currentTimeMillis();
logger.log(level, "Startup level done in " + (startupFinishTime - initFinishTime) + " ms");
}
if (!proceedTo(PostStartupRunLevel.VAL)) {
appInstanceListener.stopRecordingTimes();
return false;
}
if (logger.isLoggable(level)) {
long postStartupFinishTime = System.currentTimeMillis();
logger.log(level, "PostStartup level done in " + (postStartupFinishTime - startupFinishTime) + " ms");
}
return true;
}
use of org.glassfish.hk2.api.DynamicConfigurationService in project Payara by payara.
the class GlassfishNetworkListener method stop.
@Override
public void stop() throws IOException {
ServiceLocator locator = grizzlyService.getHabitat();
IndexedFilter removeFilter = BuilderHelper.createNameAndContractFilter(Mapper.class.getName(), (address.toString() + port));
DynamicConfigurationService dcs = locator.getService(DynamicConfigurationService.class);
DynamicConfiguration config = dcs.createDynamicConfiguration();
config.addUnbindFilter(removeFilter);
config.commit();
unregisterMonitoringStatsProviders();
super.stop();
}
Aggregations