@LifecycleHandlerType(LifecycleLevel.STOP_SERVICE) public void stop() { tenantCacheInvalidation.stop(); } }
private Multimap<LifecycleHandlerType.LifecycleLevel, LifecycleHandler<? extends KillbillService>> findAllHandlers(final KillbillService service) { final Multimap<LifecycleHandlerType.LifecycleLevel, LifecycleHandler<? extends KillbillService>> methodsInService = HashMultimap.create(); final Class<? extends KillbillService> clazz = service.getClass(); for (final Method method : clazz.getMethods()) { final LifecycleHandlerType annotation = method.getAnnotation(LifecycleHandlerType.class); if (annotation != null) { final LifecycleHandlerType.LifecycleLevel level = annotation.value(); final LifecycleHandler<? extends KillbillService> handler = new LifecycleHandler<KillbillService>(service, method); methodsInService.put(level, handler); } } return methodsInService; }
@LifecycleHandlerType(LifecycleLevel.BOOT) public void init() { try { // Compute a first version early on before plugins were installed to at least provide info about Kill Bill component versions createBootNodeInfo(true); } catch (JsonProcessingException e) { logger.error("Failed to create bootNodeInfo", e); } }
@LifecycleHandlerType(LifecycleLevel.START_SERVICE) public void start() { try { // Re-Compute including the plugins createBootNodeInfo(false); } catch (JsonProcessingException e) { logger.error("Failed to create bootNodeInfo", e); } }
@LifecycleHandlerType(LifecycleLevel.STOP_SERVICE) public void stop() { SecurityUtils.setSecurityManager(null); } }
@LifecycleHandlerType(LifecycleHandlerType.LifecycleLevel.INIT_SERVICE) public void initialize() { SecurityUtils.setSecurityManager(securityManager); }
@LifecycleHandlerType(LifecycleLevel.START_SERVICE) public void start() { subscriptionEventQueue.startQueue(); }
@LifecycleHandlerType(LifecycleLevel.START_SERVICE) public void start() { tenantCacheInvalidation.start(); }
@LifecycleHandlerType(LifecycleLevel.INIT_SERVICE) public synchronized void initialize() throws ServiceException { tenantInternalApi.initializeCacheInvalidationCallback(TenantKey.PER_TENANT_CONFIG, cacheInvalidationCallback); }
@LifecycleHandlerType(LifecycleLevel.INIT_SERVICE) public synchronized void initialize() throws ServiceException { tenantInternalApi.initializeCacheInvalidationCallback(TenantKey.CATALOG, cacheInvalidationCallback); }
@LifecycleHandlerType(LifecycleLevel.STOP_SERVICE) public void stop() { if (isStopped) { logger.warn("BroadcastExecutor is already in a stopped state"); return; } try { broadcastExecutor.shutdown(); boolean success = broadcastExecutor.awaitTermination(TERMINATION_TIMEOUT_SEC, TimeUnit.SECONDS); if (!success) { logger.warn("BroadcastExecutor failed to complete termination within {} sec", TERMINATION_TIMEOUT_SEC); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); logger.warn("BroadcastExecutor stop sequence got interrupted"); } finally { isStopped = true; } }
@LifecycleHandlerType(LifecycleLevel.INIT_SERVICE) public void initialize() { final BroadcastModelDao entry = broadcastDao.getLatestEntry(); this.latestRecordIdProcessed = entry != null ? new AtomicLong(entry.getRecordId()) : new AtomicLong(0L); this.broadcastExecutor = Executors.newSingleThreadScheduledExecutor("BroadcastExecutor"); this.isStopped = false; }
@LifecycleHandlerType(LifecycleLevel.INIT_SERVICE) public void initialize() { tenantCacheInvalidation.initialize(); for (TenantKey cacheableKey : DefaultTenantUserApi.CACHED_TENANT_KEY) { tenantCacheInvalidation.registerCallback(cacheableKey, tenantCacheInvalidationCallback); } }
@LifecycleHandlerType(LifecycleLevel.START_SERVICE) public void start() { checkNotifier.start(); asyncNotifier.start(); }
@LifecycleHandlerType(LifecycleLevel.STOP_SERVICE) public void stop() { nodeInfoDao.delete(CreatorName.get()); }
@LifecycleHandlerType(LifecycleLevel.LOAD_CATALOG) public synchronized void loadConfig() throws ServiceException { if (!isConfigLoaded) { try { overdueConfigCache.loadDefaultOverdueConfig(properties.getConfigURI()); isConfigLoaded = true; } catch (OverdueApiException e) { log.warn("Overdue system disabled: unable to load the overdue config from uri='{}'", properties.getConfigURI(), e); } } }
@LifecycleHandlerType(LifecycleLevel.INIT_SERVICE) public void initialize() { try { final NotificationQueueHandler queueHandler = new NotificationQueueHandler() { @Override public void handleReadyNotification(final NotificationEvent inputKey, final DateTime eventDateTime, final UUID fromNotificationQueueUserToken, final Long accountRecordId, final Long tenantRecordId) { if (!(inputKey instanceof SubscriptionNotificationKey)) { log.error("SubscriptionBase service received an unexpected event className='{}'", inputKey.getClass().getName()); return; } final SubscriptionNotificationKey key = (SubscriptionNotificationKey) inputKey; final SubscriptionBaseEvent event = dao.getEventById(key.getEventId(), internalCallContextFactory.createInternalTenantContext(tenantRecordId, accountRecordId)); if (event == null) { // This can be expected if the event is soft deleted (is_active = 0) log.debug("Failed to extract event for notification key {}", inputKey); return; } final InternalCallContext context = internalCallContextFactory.createInternalCallContext(tenantRecordId, accountRecordId, "SubscriptionEventQueue", CallOrigin.INTERNAL, UserType.SYSTEM, fromNotificationQueueUserToken); processEventReady(event, key.getSeqId(), context); } }; subscriptionEventQueue = notificationQueueService.createNotificationQueue(KILLBILL_SERVICES.SUBSCRIPTION_BASE_SERVICE.getServiceName(), NOTIFICATION_QUEUE_NAME, queueHandler); } catch (final NotificationQueueAlreadyExists e) { throw new RuntimeException(e); } }
@LifecycleHandlerType(LifecycleLevel.STOP_SERVICE) public void stop() { try { busService.getBus().unregister(listener); } catch (final EventBusException e) { log.error("Failed to unregister OverdueListener", e); } checkNotifier.stop(); asyncNotifier.stop(); }
@LifecycleHandlerType(LifecycleHandlerType.LifecycleLevel.START_SERVICE) public void start() { final TimeUnit pendingRateUnit = broadcastConfig.getBroadcastServiceRunningRate().getUnit(); final long pendingPeriod = broadcastConfig.getBroadcastServiceRunningRate().getPeriod(); broadcastExecutor.scheduleAtFixedRate(new BroadcastServiceRunnable(this, broadcastDao, eventBus), pendingPeriod, pendingPeriod, pendingRateUnit); }
@LifecycleHandlerType(LifecycleHandlerType.LifecycleLevel.INIT_SERVICE) public void initialize() { registerForBus(); checkNotifier.initialize(); asyncNotifier.initialize(); tenantInternalApi.initializeCacheInvalidationCallback(TenantKey.OVERDUE_CONFIG, overdueCacheInvalidationCallback); }