本文整理汇总了Java中play.inject.ApplicationLifecycle类的典型用法代码示例。如果您正苦于以下问题:Java ApplicationLifecycle类的具体用法?Java ApplicationLifecycle怎么用?Java ApplicationLifecycle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ApplicationLifecycle类属于play.inject包,在下文中一共展示了ApplicationLifecycle类的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: MyStupidBasicAuthProvider
import play.inject.ApplicationLifecycle; //导入依赖的package包/类
@Inject
public MyStupidBasicAuthProvider(final PlayAuthenticate auth, final UserProvider userProvider,
final FormFactory formFactory,
final ApplicationLifecycle lifecycle) {
super(auth, lifecycle);
this.userProvider = userProvider;
this.LOGIN_FORM = formFactory.form(MyUsernamePasswordAuthProvider.MyLogin.class);
}
示例4: 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);
});
}
示例5: 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");
}
示例6: 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");
}
示例7: TableProviderImpl
import play.inject.ApplicationLifecycle; //导入依赖的package包/类
/**
* Initialize the service.
*
* @param lifecycle
* the Play life cycle service
* @param kpiService
* the KPI service
* @param i18nMessagesPlugin
* the i18n messages service
* @param attachmentManagerPlugin
* the attachment manager service
*/
@Inject
public TableProviderImpl(ApplicationLifecycle lifecycle, IKpiService kpiService, II18nMessagesPlugin i18nMessagesPlugin,
IAttachmentManagerPlugin attachmentManagerPlugin, IPreferenceManagerPlugin preferenceManagerPlugin) {
Logger.info("SERVICE>>> TableProviderImpl starting...");
this.kpiService = kpiService;
this.i18nMessagesPlugin = i18nMessagesPlugin;
this.attachmentManagerPlugin = attachmentManagerPlugin;
this.preferenceManagerPlugin = preferenceManagerPlugin;
this.tableDefinitions = null;
lifecycle.addStopHook(() -> {
Logger.info("SERVICE>>> TableProviderImpl stopping...");
Logger.info("SERVICE>>> TableProviderImpl stopped");
return Promise.pure(null);
});
Logger.info("SERVICE>>> TableProviderImpl started");
}
示例8: EchannelServiceImpl
import play.inject.ApplicationLifecycle; //导入依赖的package包/类
/**
* Initialize the service.
*
* @param lifecycle
* the Play life cycle service
* @param configuration
* the Play configuration service
* @param cache
* the Play cache service
* @param preferenceManagerPlugin
* the preference service
*/
@Inject
public EchannelServiceImpl(ApplicationLifecycle lifecycle, Configuration configuration, CacheApi cache,
IPreferenceManagerPlugin preferenceManagerPlugin) {
Logger.info("SERVICE>>> EchannelServiceImpl starting...");
this.echannelApiUrl = configuration.getString(Config.ECHANNEL_API_URL.getConfigurationKey());
this.apiSecretKey = null;
this.cache = cache;
this.preferenceManagerPlugin = preferenceManagerPlugin;
lifecycle.addStopHook(() -> {
Logger.info("SERVICE>>> EchannelServiceImpl stopping...");
Logger.info("SERVICE>>> EchannelServiceImpl stopped");
return Promise.pure(null);
});
ObjectMapper mapper = new ObjectMapper();
mapper.setDateFormat(new SimpleDateFormat(AbstractApiController.DATE_FORMAT));
this.mapper = mapper;
Logger.info("SERVICE>>> EchannelServiceImpl started");
}
示例9: 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");
}
示例10: 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");
}
示例11: BudgetTrackingServiceImpl
import play.inject.ApplicationLifecycle; //导入依赖的package包/类
/**
* Initialize the service.
*
* @param lifecycle
* the Play life cycle service
* @param configuration
* the Play configuration service
* @param preferenceManagerPlugin
* the preference manager service
*/
@Inject
public BudgetTrackingServiceImpl(ApplicationLifecycle lifecycle, Configuration configuration, IPreferenceManagerPlugin preferenceManagerPlugin) {
Logger.info("SERVICE>>> BudgetTrackingServiceImpl starting...");
lifecycle.addStopHook(() -> {
Logger.info("SERVICE>>> BudgetTrackingServiceImpl stopping...");
Logger.info("SERVICE>>> BudgetTrackingServiceImpl stopped");
return Promise.pure(null);
});
this.preferenceManagerPlugin = preferenceManagerPlugin;
Logger.info("SERVICE>>> BudgetTrackingServiceImpl started");
}
示例12: ActorSystemPluginImpl
import play.inject.ApplicationLifecycle; //导入依赖的package包/类
/**
* Creates a new ActorSystemPluginImpl
*
* @param lifecycle
* the play application lifecycle listener
* @param configuration
* the play application configuration
* @param actorSystem
* @throws ActorSystemPluginException
*/
@Inject
public ActorSystemPluginImpl(ApplicationLifecycle lifecycle, Configuration configuration, ActorSystem actorSystem) throws ActorSystemPluginException {
log.info("SERVICE>>> ActorSystemPluginImpl starting...");
this.actorSystemName = configuration.getString(Config.ACTOR_SYSTEM_NAME.getConfigurationKey());
this.deadLetterFileSystem = new File(configuration.getString(Config.DEAD_LETTERS_FOLDER.getConfigurationKey()));
this.reprocessedDeadLetters = new File(configuration.getString(Config.DEAD_LETTERS_REPROCESSING_FOLDER.getConfigurationKey()));
lifecycle.addStopHook(() -> {
log.info("SERVICE>>> ActorSystemPluginImpl stopping...");
shutdown();
log.info("SERVICE>>> ActorSystemPluginImpl stopped");
return Promise.pure(null);
});
startup();
log.info("SERVICE>>> ActorSystemPluginImpl started");
}
示例13: 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...");
}
示例14: 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");
}
示例15: AuditLoggerServiceImpl
import play.inject.ApplicationLifecycle; //导入依赖的package包/类
/**
* Creates a new instance.
*
* @param lifecycle
* the play application lifecycle listener
* @param configuration
* the play application configuration
* @param userSessionManager
* the user session manager (will be used to enrich the log with
* the id of the user)
* @param databaseService
* the service managing the access to data
* @param sysAdminUtils
* the utils for scheduling management
*/
@Inject
public AuditLoggerServiceImpl(ApplicationLifecycle lifecycle, Configuration configuration, IDatabaseDependencyService databaseService,
IUserSessionManagerPlugin userSessionManager, ISysAdminUtils sysAdminUtils) {
log.info("SERVICE>>> AuditLoggerServiceImpl starting...");
this.configuration = configuration;
this.userSessionManager = userSessionManager;
this.sysAdminUtils = sysAdminUtils;
databaseService.addDatabaseChangeListener(this);
this.auditableEntitiesFilePath = configuration.getString(Config.AUDITABLE_ENTITIES_FILE.getConfigurationKey());
log.info("Activating audit log with audit log file " + this.auditableEntitiesFilePath);
reload();
lifecycle.addStopHook(() -> {
log.info("SERVICE>>> AuditLoggerServiceImpl stopping...");
databaseService.removeDatabaseChangeListener(this);
log.info("SERVICE>>> AuditLoggerServiceImpl stopped");
return Promise.pure(null);
});
log.info("SERVICE>>> AuditLoggerServiceImpl started");
}