本文整理汇总了Java中play.inject.ApplicationLifecycle.addStopHook方法的典型用法代码示例。如果您正苦于以下问题:Java ApplicationLifecycle.addStopHook方法的具体用法?Java ApplicationLifecycle.addStopHook怎么用?Java ApplicationLifecycle.addStopHook使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类play.inject.ApplicationLifecycle
的用法示例。
在下文中一共展示了ApplicationLifecycle.addStopHook方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ApplicationTimer
import play.inject.ApplicationLifecycle; //导入方法依赖的package包/类
@Inject
public ApplicationTimer(Clock clock, ApplicationLifecycle appLifecycle) {
this.clock = clock;
this.appLifecycle = appLifecycle;
// This code is called when the application starts.
start = clock.instant();
Logger.info("ApplicationTimer demo: Starting application at " + start);
// When the application starts, register a stop hook with the
// ApplicationLifecycle object. The code inside the stop hook will
// be run when the application stops.
appLifecycle.addStopHook(() -> {
Instant stop = clock.instant();
Long runningTime = stop.getEpochSecond() - start.getEpochSecond();
Logger.info("ApplicationTimer demo: Stopping application at " + clock.instant() + " after " + runningTime + "s.");
return CompletableFuture.completedFuture(null);
});
}
示例2: BaseThreadPool
import play.inject.ApplicationLifecycle; //导入方法依赖的package包/类
protected BaseThreadPool(String poolName,
int poolSize,
ApplicationLifecycle lifecycle) {
this.poolName = poolName;
this.poolSize = poolSize;
this.lifecycle = lifecycle;
ThreadFactory namedTF =
new ThreadFactoryBuilder().setNameFormat(poolName).build();
POOL = Executors.newFixedThreadPool(poolSize, namedTF);
lifecycle.addStopHook(() -> {
try {
POOL.shutdownNow();
} catch (SecurityException ex) {
log.warn("{}: thread pool shutdown ex={}", ex);
} finally {
log.info("{}: thread pool shutdown.", poolName);
}
return CompletableFuture.completedFuture(null);
});
}
示例3: ApplicationStart
import play.inject.ApplicationLifecycle; //导入方法依赖的package包/类
@Inject
public ApplicationStart(Clock clock, ApplicationLifecycle appLifecycle, final Configuration configuration, final Database dbSource)
throws GroundException {
this.start = clock.instant();
Logger.info("Ground Postgres: Starting application at " + this.start);
Logger.info("Queries will Cache for {} seconds.", configuration.underlying().getString("ground.cache.expire.secs"));
System.setProperty("ground.cache.expire.secs", configuration.underlying().getString("ground.cache.expire.secs"));
appLifecycle.addStopHook(
() -> {
Instant stop = clock.instant();
Long runningTime = stop.getEpochSecond() - this.start.getEpochSecond();
Logger.info("Ground Postgres: Stopping application at " + clock.instant() + " after " + runningTime + "s.");
return CompletableFuture.completedFuture(null);
});
}
示例4: DataSyndicationServiceImpl
import play.inject.ApplicationLifecycle; //导入方法依赖的package包/类
/**
* Initialize the service.
*
* @param lifecycle
* the Play life cycle service
* @param configuration
* the Play configuration service
* @param echannelService
* the eChannel service
* @param bizdockApiClient
* the BizDock API client (for the slave instance)
* @param apiSignatureService
* the API signature service
* @param preferenceManagerPlugin
* the preference service
* @param i18nMessagesPlugin
* the i18n service
*/
@Inject
public DataSyndicationServiceImpl(ApplicationLifecycle lifecycle, Configuration configuration, IEchannelService echannelService,
IBizdockApiClient bizdockApiClient, IApiSignatureService apiSignatureService, IPreferenceManagerPlugin preferenceManagerPlugin,
II18nMessagesPlugin i18nMessagesPlugin) {
Logger.info("SERVICE>>> DataSyndicationServiceImpl starting...");
this.isActive = configuration.getBoolean(Config.DATA_SYNDICATION_ACTIVE.getConfigurationKey());
this.lang = i18nMessagesPlugin.getLanguageByCode(i18nMessagesPlugin.getDefaultLanguageCode()).getLang();
this.echannelService = echannelService;
this.apiSignatureService = apiSignatureService;
this.preferenceManagerPlugin = preferenceManagerPlugin;
this.bizdockApiClient = bizdockApiClient;
lifecycle.addStopHook(() -> {
Logger.info("SERVICE>>> DataSyndicationServiceImpl stopping...");
Logger.info("SERVICE>>> DataSyndicationServiceImpl stopped");
return Promise.pure(null);
});
Logger.info("SERVICE>>> DataSyndicationServiceImpl started");
}
示例5: BizdockApiClientImpl
import play.inject.ApplicationLifecycle; //导入方法依赖的package包/类
/**
* Initialize the service.
*
* @param lifecycle
* the Play life cycle service
* @param configuration
* the Play configuration service
*/
@Inject
public BizdockApiClientImpl(ApplicationLifecycle lifecycle, Configuration configuration) {
Logger.info("SERVICE>>> BizdockApiClientImpl starting...");
lifecycle.addStopHook(() -> {
Logger.info("SERVICE>>> BizdockApiClientImpl stopping...");
Logger.info("SERVICE>>> BizdockApiClientImpl stopped");
return Promise.pure(null);
});
ObjectMapper mapper = new ObjectMapper();
mapper.setDateFormat(new SimpleDateFormat(IApiConstants.DATE_FORMAT));
this.mapper = mapper;
Logger.info("SERVICE>>> BizdockApiClientImpl started");
}
示例6: AbstractTopMenuBarService
import play.inject.ApplicationLifecycle; //导入方法依赖的package包/类
@Inject
public AbstractTopMenuBarService(ApplicationLifecycle lifecycle, Configuration configuration, IPreferenceManagerPlugin preferenceManagerPlugin,
IUserSessionManagerPlugin userSessionManagerPlugin) {
log.info("SERVICE>>> AbstractTopMenuBarService starting...");
this.preferenceManagerPlugin = preferenceManagerPlugin;
this.userSessionManagerPlugin = userSessionManagerPlugin;
this.perspectives = Collections.synchronizedMap(new LinkedHashMap<>());
this.perspectives.put(MAIN_PERSPECTIVE_KEY, new TopMenuBarPerspective(true, views.html.framework_views.parts.menubars.logo.render()));
resetTopMenuBar();
lifecycle.addStopHook(() -> {
log.info("SERVICE>>> AbstractTopMenuBarService stopping...");
log.info("SERVICE>>> AbstractTopMenuBarService stopped");
return Promise.pure(null);
});
log.info("SERVICE>>> AbstractTopMenuBarService started");
}
示例7: PickerServiceImpl
import play.inject.ApplicationLifecycle; //导入方法依赖的package包/类
/**
* Initialize the service.
*
* @param lifecycle
* the Play life cycle service
* @param configuration
* the Play configuration service
* @param accountManagerPlugin
* the account manager service
* @param attachmentManagerPlugin
* the attachment manager service
*/
@Inject
public PickerServiceImpl(ApplicationLifecycle lifecycle, Configuration configuration, IAccountManagerPlugin accountManagerPlugin,
IAttachmentManagerPlugin attachmentManagerPlugin) {
Logger.info("SERVICE>>> PickerServiceImpl starting...");
this.accountManagerPlugin = accountManagerPlugin;
this.attachmentManagerPlugin = attachmentManagerPlugin;
this.init();
lifecycle.addStopHook(() -> {
Logger.info("SERVICE>>> PickerServiceImpl stopping...");
Logger.info("SERVICE>>> PickerServiceImpl stopped");
return Promise.pure(null);
});
Logger.info("SERVICE>>> PickerServiceImpl started");
}
示例8: LicensesManagementServiceImpl
import play.inject.ApplicationLifecycle; //导入方法依赖的package包/类
/**
* Initialize the service.
*
* @param lifecycle
* the Play life cycle service
* @param configuration
* the Play configuration service
* @param echannelService
* the eChannel service
* @param sharedStorageService
* the shared storage service
* @param attachmentManagerPlugin
* the attachment manager service
* @param extensionManagerService
* the extension manager service
* @param personalStoragePlugin
* the personal storage service
*/
@Inject
public LicensesManagementServiceImpl(ApplicationLifecycle lifecycle, Configuration configuration, IEchannelService echannelService,
ISharedStorageService sharedStorageService, IAttachmentManagerPlugin attachmentManagerPlugin, IExtensionManagerService extensionManagerService,
IPersonalStoragePlugin personalStoragePlugin) {
Logger.info("SERVICE>>> LicensesManagementServiceImpl starting...");
this.isActive = configuration.getBoolean(Config.LICENSE_MANAGEMENT_ACTIVE.getConfigurationKey());
this.echannelService = echannelService;
this.sharedStorageService = sharedStorageService;
this.attachmentManagerPlugin = attachmentManagerPlugin;
this.extensionManagerService = extensionManagerService;
this.personalStoragePlugin = personalStoragePlugin;
lifecycle.addStopHook(() -> {
Logger.info("SERVICE>>> LicensesManagementServiceImpl stopping...");
Logger.info("SERVICE>>> LicensesManagementServiceImpl stopped");
return Promise.pure(null);
});
Logger.info("SERVICE>>> LicensesManagementServiceImpl started");
}
示例9: DefaultNotificationManagerPlugin
import play.inject.ApplicationLifecycle; //导入方法依赖的package包/类
/**
* Create a new DefaultNotificationManagerPlugin.
*
* @param lifecycle
* the play application lifecycle listener
* @param configuration
* the play application configuration
* @param actorSystemPlugin
* the service which is managing the BizDock actor system
* @param preferenceManagerPlugin
* the preference manager service
* @param accountManagerPlugin
* the account manager service
* @param emailService
* the email service
*
*/
@Inject
public DefaultNotificationManagerPlugin(ApplicationLifecycle lifecycle, Configuration configuration, IActorSystemPlugin actorSystemPlugin,
IPreferenceManagerPlugin preferenceManagerPlugin, IAccountManagerPlugin accountManagerPlugin, IEmailService emailService,
II18nMessagesPlugin i18nMessagesPlugin) {
log.info("SERVICE>>> DefaultNotificationManagerPlugin starting...");
this.poolSize = configuration.getInt(Config.NOTIFICATION_POOL_SIZE.getConfigurationKey());
this.notificationRetryDuration = configuration.getString(Config.RETRY_DURATION.getConfigurationKey());
this.notificationRetryNumber = configuration.getInt(Config.RETRY_NUMBER.getConfigurationKey());
this.configuration = configuration;
this.preferenceManagerPlugin = preferenceManagerPlugin;
this.accountManagerPlugin = accountManagerPlugin;
this.emailService = emailService;
this.i18nMessagesPlugin = i18nMessagesPlugin;
createActors(actorSystemPlugin.getActorSystem());
lifecycle.addStopHook(() -> {
log.info("SERVICE>>> DefaultNotificationManagerPlugin stopping...");
log.info("SERVICE>>> DefaultNotificationManagerPlugin stopped");
return Promise.pure(null);
});
log.info("SERVICE>>> DefaultNotificationManagerPlugin started");
}
示例10: EmailServiceImpl
import play.inject.ApplicationLifecycle; //导入方法依赖的package包/类
/**
* Create a new EmailServiceImpl
*
* @param lifecycle
* the play application lifecycle listener
* @param configuration
* the play application configuration
* @param databaseDependencyService
* the service which secure the availability of the database
*/
@Inject
public EmailServiceImpl(ApplicationLifecycle lifecycle, Configuration configuration, IDatabaseDependencyService databaseDependencyService,
IPreferenceManagerPlugin preferenceManagerPlugin, ISysAdminUtils sysAdminUtils) {
log.info("SERVICE>>> EmailServiceImpl starting...");
this.configuration = configuration;
this.preferenceManagerPlugin = preferenceManagerPlugin;
this.sysAdminUtils = sysAdminUtils;
this.simulateEmailSending = getConfiguration().getBoolean("maf.email.simulation");
lifecycle.addStopHook(() -> {
log.info("SERVICE>>> SysAdminUtilsImpl stopping...");
log.info("SERVICE>>> SysAdminUtilsImpl stopped");
return Promise.pure(null);
});
log.info("SERVICE>>> EmailServiceImpl started...");
}
示例11: ApplicationTimer
import play.inject.ApplicationLifecycle; //导入方法依赖的package包/类
@Inject
public ApplicationTimer(Clock clock, ApplicationLifecycle appLifecycle) {
this.clock = clock;
this.appLifecycle = appLifecycle;
// This code is called when the application starts.
start = clock.instant();
logger.info("ApplicationTimer demo: Starting application at " + start);
// When the application starts, register a stop hook with the
// ApplicationLifecycle object. The code inside the stop hook will
// be run when the application stops.
appLifecycle.addStopHook(() -> {
Instant stop = clock.instant();
Long runningTime = stop.getEpochSecond() - start.getEpochSecond();
logger.info("ApplicationTimer demo: Stopping application at " + clock.instant() + " after " + runningTime + "s.");
return CompletableFuture.completedFuture(null);
});
}
示例12: ApiSignatureServiceImpl
import play.inject.ApplicationLifecycle; //导入方法依赖的package包/类
/**
* Create a new ApiSignatureServiceImpl
*
* @param lifecycle
* the play application lifecycle listener
* @param configuration
* the play application configuration
* @param databaseDependencyService
* @throws ApiSignatureException
*/
@Inject
public ApiSignatureServiceImpl(ApplicationLifecycle lifecycle, Configuration configuration, IDatabaseDependencyService databaseDependencyService)
throws ApiSignatureException {
log.info("SERVICE>>> ApiSignatureServiceImpl starting...");
this.keyLength = configuration.getInt(Config.KEYS_LENGTH.getConfigurationKey());
this.allowedTimeDifference = configuration.getInt(Config.ALLOWED_TIME_DIFF.getConfigurationKey());
this.hashAlgorithm = configuration.getString(Config.HASH_ALGORITHM.getConfigurationKey());
this.protocolVersion = configuration.getInt(Config.PROTOCOL_VERSION.getConfigurationKey());
this.publicUrl = configuration.getString(Config.PUBLIC_URL.getConfigurationKey());
init();
lifecycle.addStopHook(() -> {
log.info("SERVICE>>> ApiSignatureServiceImpl stopping...");
log.info("SERVICE>>> ApiSignatureServiceImpl stopped");
return Promise.pure(null);
});
log.info("SERVICE>>> ApiSignatureServiceImpl started");
}
示例13: OnStartClass
import play.inject.ApplicationLifecycle; //导入方法依赖的package包/类
@Inject public OnStartClass(ExecutionSystemInitialization executionSystemInitialization,
InitialData initialData, ApplicationLifecycle applicationLifecycle) {
LOGGER.info("Initialization of system, executing on start actions.");
initialData.load();
executionSystemInitialization.init();
LOGGER.info("Registering shutdown hook for execution system.");
applicationLifecycle.addStopHook(() -> F.Promise.promise(() -> {
executionSystemInitialization.shutdown();
return null;
}));
LOGGER.info("Finished execution onStart actions.");
}
示例14: BackEndThreads
import play.inject.ApplicationLifecycle; //导入方法依赖的package包/类
@Inject
public BackEndThreads(ApplicationLifecycle lifecycle) {
super("Back-End-Pool", 50, lifecycle);
lifecycle.addStopHook(() -> {
try {
POOL.shutdownNow();
} catch (SecurityException ex) {
}
return CompletableFuture.completedFuture(null);
});
}
示例15: FrontEndThreads
import play.inject.ApplicationLifecycle; //导入方法依赖的package包/类
@Inject
public FrontEndThreads(ApplicationLifecycle lifecycle) {
super("Front-End-Pool", 50, lifecycle);
lifecycle.addStopHook(() -> {
try {
POOL.shutdownNow();
} catch (SecurityException ex) {
}
return CompletableFuture.completedFuture(null);
});
}