/** * When the deployment is loaded register for recovery * * @param init a javax.servlet.ServletContext */ void enableRecovery(@Observes @Initialized(ApplicationScoped.class) Object init) { assert lraRecoveryModule == null; if (LRALogger.logger.isDebugEnabled()) LRALogger.logger.debugf("LRAServicve.enableRecovery%n"); lraRecoveryModule = new LRARecoveryModule(this); RecoveryManager.manager().addModule(lraRecoveryModule); Implementations.install(); lraRecoveryModule.getRecoveringLRAs(recoveringLRAs); for (Transaction transaction : recoveringLRAs.values()) transaction.getRecoveryCoordinatorUrls(participants); }
public void onTrigger(@Observes @Initialized(ApplicationScoped.class) Object test) { mes.submit(new Runnable() { @Override public void run() { try { while (true) { eventBus.fireAsync(new TickTock("tick-" + gen.nextInt(10), "tock-" + gen.nextInt(10))); System.out.println("Fired CDI event from thread " + Thread.currentThread().getName()); Thread.sleep(5000); } } catch (Exception e) { e.printStackTrace(); } } }); System.out.println("Scheduler initialized"); }
public void onStartUp( @Observes @Initialized(ApplicationScoped.class) Object init, @DevMode boolean isDevMode, @BackEndProviders Set<BackendID> availableProviders) throws MTException { LOG.info("==================================="); LOG.info("==================================="); LOG.info("=== Machine Translation Service ==="); LOG.info("==================================="); LOG.info("==================================="); LOG.info("Build info: version-" + configurationService.getVersion() + " date-" + configurationService.getBuildDate()); if (isDevMode) { LOG.warn("THIS IS A DEV MODE BUILD. DO NOT USE IT FOR PRODUCTION"); } LOG.info("Available backend providers: {}", availableProviders); verifyCredentials(); }
/** * Read in web.xml the optional STACKTRACE_LENGTH config and set it in StacktraceConfigurationManager * @param sc */ public void readStacktraceConfig(@Observes @Initialized(ApplicationScoped.class) ServletContext sc) { String stacktrace; if(ocelotConfigurationsStack.isUnsatisfied()) { stacktrace = sc.getInitParameter(Constants.Options.STACKTRACE_LENGTH); if(stacktrace==null) { stacktrace = DEFAULTSTACKTRACE; } else { logger.debug("Read '{}' option in web.xml : '{}'.", Constants.Options.STACKTRACE_LENGTH, stacktrace); } } else { stacktrace = ocelotConfigurationsStack.get(); logger.debug("Read '{}' option from producer : '{}'.", Constants.Options.STACKTRACE_LENGTH, stacktrace); } int stacktracelenght = Integer.parseInt(stacktrace); logger.debug("'{}' value : '{}'.", Constants.Options.STACKTRACE_LENGTH, stacktracelenght); setStacktracelength(stacktracelenght); }
public void initVertx(@Observes @Initialized(ApplicationScoped.class) Object obj) { System.setProperty("vertx.disableDnsResolver", "true"); this.vertx = Vertx.vertx(); this.vertx.eventBus().registerDefaultCodec(ChatMessage.class, new ChatMessageCodec()); this.vertx.eventBus().registerDefaultCodec(PersonName.class, new PersonNameCodec()); this.vertx.eventBus().registerDefaultCodec(String[].class, new StringArrayCodec()); allDiscoveredVerticles.forEach(v -> { System.out.println("Found verticle "+v); vertx.deployVerticle(v); }); }
public void onInitialized(@Observes @Initialized(ApplicationScoped.class) Object init) { beanManager.getBeans(Object.class, new AnnotationLiteral<Startup>() { }).forEach(bean -> { final CreationalContext<?> context = beanManager.createCreationalContext(bean); LOGGER.info("Force initializing {}...", beanManager.getReference(bean, bean.getBeanClass(), context).toString()); }); initialize(); }
void start( @Observes @Initialized(ApplicationScoped.class) Object o ) { try { if( !scheduler.isStarted() ) { scheduler.start(); } } catch( SchedulerException ex ) { LOG.log( Level.SEVERE, "Failed to start scheduler", ex ); } }
public void init(@Observes @Initialized(ApplicationScoped.class) Object doesntMatter) { this.cachingProvider = Caching.getCachingProvider(); this.cacheManager = cachingProvider.getCacheManager(); Configuration<String, String> configuration = getConfiguration(); this.store = this.cacheManager.getCache(CONFIGURATION, String.class, String.class); if (this.store == null) { this.store = this.cacheManager.createCache(CONFIGURATION, configuration); } for (Map<String, String> initial : initialValues) { this.store.putAll(initial); } }
void login(@Observes @Initialized(ApplicationScoped.class) Object event) { System.out.println( "████████╗██╗ ██╗███████╗ ███╗ ███╗ █████╗ ████████╗██████╗ ██╗██╗ ██╗\n" + "╚══██╔══╝██║ ██║██╔════╝ ████╗ ████║██╔══██╗╚══██╔══╝██╔══██╗██║╚██╗██╔╝\n" + " ██║ ███████║█████╗ ██╔████╔██║███████║ ██║ ██████╔╝██║ ╚███╔╝ \n" + " ██║ ██╔══██║██╔══╝ ██║╚██╔╝██║██╔══██║ ██║ ██╔══██╗██║ ██╔██╗ \n" + " ██║ ██║ ██║███████╗ ██║ ╚═╝ ██║██║ ██║ ██║ ██║ ██║██║██╔╝ ██╗\n" + " ╚═╝ ╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝╚═╝ ╚═╝"); }
/** * This creates the bi-function listener-producers that will create listeners which will * create JMS bus listeners for each websocket session that gets created in the future. * * @param ignore unused */ public void initialize(@Observes @Initialized(ApplicationScoped.class) Object ignore) { log.debugf("Initializing [%s]", this.getClass().getName()); try { feedSessionListenerProducer = new BiFunction<String, Session, WsSessionListener>() { @Override public WsSessionListener apply(String key, Session session) { // In the future, if we need other queues/topics that need to be listened to, we add them here. final Endpoint endpoint = Constants.FEED_COMMAND_QUEUE; BasicMessageListener<BasicMessage> busEndpointListener = new FeedBusEndpointListener(session, key, endpoint); return new BusWsSessionListener(Constants.HEADER_FEEDID, key, endpoint, busEndpointListener); } }; wsEndpoints.getFeedSessions().addWsSessionListenerProducer(feedSessionListenerProducer); uiClientSessionListenerProducer = new BiFunction<String, Session, WsSessionListener>() { @Override public WsSessionListener apply(String key, Session session) { // In the future, if we need other queues/topics that need to be listened to, we add them here. final Endpoint endpoint = Constants.UI_COMMAND_QUEUE; BasicMessageListener<BasicMessage> busEndpointListener = new UiClientBusEndpointListener( commandContextFactory, busCommands, endpoint); return new BusWsSessionListener(Constants.HEADER_UICLIENTID, key, endpoint, busEndpointListener); } }; wsEndpoints.getUiClientSessions().addWsSessionListenerProducer(uiClientSessionListenerProducer); } catch (Exception e) { log.errorCouldNotInitialize(e, this.getClass().getName()); } }
public void init(@Observes @Initialized(ApplicationScoped.class) Object obj) { String body = "This is a test"; Queue queue = context.createQueue("test"); context.createProducer().send(queue, body); String receivedBody = context.createConsumer(queue).receiveBody(String.class, 5000); System.out.println("Received a message " + receivedBody); }
public final void afterInitialized(@Observes @Initialized(ApplicationScoped.class) Object event) throws NamingException { ManagedScheduledExecutorService executor = lookupBean("java:comp/DefaultManagedScheduledExecutorService", ManagedScheduledExecutorService.class); ContextService proxy = lookupBean("java:comp/DefaultContextService", ContextService.class); future = executor.scheduleAtFixedRate( () -> proxy.createContextualProxy(lookupBean(getJobType()), Runnable.class).run(), 0, getPeriodTime(), getTimeUnit()); }
public void init(@Observes @Initialized(ApplicationScoped.class) Object doesntMatter) { this.caches = new HashMap<>(); CachesMetaData cachesMetaData = CachesProvider.getCacheUnits(); this.cachingProvider = Caching.getCachingProvider(cachesMetaData.getCachingProviderClass()); this.cacheManager = cachingProvider.getCacheManager(); this.caches = createCaches(cachesMetaData.getCaches()); }
public void applicationInitialized(@Observes @Initialized(ApplicationScoped.class) Object init) { log.debug("Initializing application services"); customLibrariesLoader.init(); createEntryManagerFactory(); configurationFactory.create(); loggerService.configure(); LdapEntryManager localLdapEntryManager = ldapEntryManagerInstance.get(); this.ldapAuthConfigs = loadLdapAuthConfigs(localLdapEntryManager); setDefaultAuthenticationMethod(localLdapEntryManager); // Initialize python interpreter pythonService.initPythonInterpreter(configurationFactory.getLdapConfiguration().getString("pythonModulesDir", null)); // Initialize script manager List<CustomScriptType> supportedCustomScriptTypes = Arrays.asList(CustomScriptType.PERSON_AUTHENTICATION, CustomScriptType.CONSENT_GATHERING, CustomScriptType.CLIENT_REGISTRATION, CustomScriptType.ID_GENERATOR, CustomScriptType.UMA_RPT_POLICY, CustomScriptType.UMA_CLAIMS_GATHERING, CustomScriptType.APPLICATION_SESSION, CustomScriptType.DYNAMIC_SCOPE); // Start timer quartzSchedulerManager.start(); // Schedule timer tasks metricService.initTimer(); configurationFactory.initTimer(); ldapStatusTimer.initTimer(); cleanerTimer.initTimer(); customScriptManager.initTimer(supportedCustomScriptTypes); keyGeneratorTimer.initTimer(); initTimer(); }
private void capture(@Observes @Initialized(ApplicationScoped.class) final ServletContext context) { if (this.context != null) { throw new IllegalStateException("app context started twice"); } this.context = context; this.value = context.getInitParameter("test"); }
@Transactional public void add(@Observes @Initialized(ApplicationScoped.class) Object init) { final User user = new User(); user.setUserName("test"); user.setUserPass("9003d1df22eb4d3820015070385194c8"); // md5(pwd) em.persist(user); final RoleId roleId = new RoleId(); roleId.setUserName(user.getUserName()); roleId.setUserRole("arquillian"); final Role role = new Role(); role.setId(roleId); em.persist(role); }
private void capture(@Observes @Initialized(ApplicationScoped.class) final Object context) { if (this.context != null) { throw new IllegalStateException("app context started twice"); } this.context = context; }
public void processApplicationScopedInit(@Observes @Initialized(ApplicationScoped.class) ServletContext payload) { logger.info("initialized the ApplicationBean"); applicationBean.incrementCounter(); }
public void processDependentScopedInit(@Observes @Initialized(ApplicationScoped.class) ServletContext payload) { logger.info("initialized the DependentBean"); dependentBean.incrementCounter(); }
private final void watch(@Observes @Initialized(ApplicationScoped.class) @Priority(LIBRARY_AFTER) final Object event, final KubernetesClient client, final BeanManager beanManager) throws InterruptedException { if (client != null && beanManager != null && this.startWatcher) { final javax.enterprise.event.Event<Event> eventBroadcaster = beanManager.getEvent().select(Event.class); assert eventBroadcaster != null; final javax.enterprise.event.Event<Event> addedBroadcaster = eventBroadcaster.select(Added.Literal.INSTANCE); assert addedBroadcaster != null; final javax.enterprise.event.Event<Event> modifiedBroadcaster = eventBroadcaster.select(Modified.Literal.INSTANCE); assert modifiedBroadcaster != null; final javax.enterprise.event.Event<Event> deletedBroadcaster = eventBroadcaster.select(Deleted.Literal.INSTANCE); assert deletedBroadcaster != null; final javax.enterprise.event.Event<Event> errorBroadcaster = eventBroadcaster.select(Error.Literal.INSTANCE); assert errorBroadcaster != null; // TODO: restrict namespace, filter events using strategy found // here: // http://stackoverflow.com/questions/32894599/how-do-i-get-events-associated-with-a-pod-via-the-api#comment53651235_32898853 this.watch = client.events().inAnyNamespace().watch(new Watcher<Event>() { @Override public final void eventReceived(final Action action, final Event resource) { javax.enterprise.event.Event<Event> specificBroadcaster = null; if (action != null) { switch (action) { case ADDED: specificBroadcaster = addedBroadcaster; break; case MODIFIED: specificBroadcaster = modifiedBroadcaster; break; case DELETED: specificBroadcaster = deletedBroadcaster; break; case ERROR: specificBroadcaster = errorBroadcaster; break; default: throw new IllegalStateException(); } } assert specificBroadcaster != null; specificBroadcaster.fire(resource); } @Override public final void onClose(final KubernetesClientException kubernetesClientException) { if (kubernetesClientException != null) { closeException = kubernetesClientException; unblock(); } } }); } }
/** * @param init used initialise on startup of application. */ public void startup(@Observes @Initialized(ApplicationScoped.class) Object init) { connect(); }
public void onInit( @Observes @Initialized(ApplicationScoped.class) Object init) throws MTException { api = new MicrosoftTranslatorClient(clientSubscriptionKey, restClient, dtoUtil); }
void observeRequestInitialized(@Observes @Initialized(RequestScoped.class) Object event) { log.tracef("observeRequestInitialized, event=%s", event); }
public void migrate(@Observes @Initialized(ApplicationScoped.class) Object context) { Flyway flyway = new Flyway(); flyway.setDataSource(dataSource); flyway.migrate(); }
static void expectations(@Observes @Initialized(ApplicationScoped.class) Object event, @Uri("mock:out") MockEndpoint mock) { mock.expectedMessageCount(1); mock.expectedBodiesReceived(1); }
public void init(@Observes @Initialized(ApplicationScoped.class) Object o) { ManagedScheduledExecutorService executorService = getExecutorService(); executorService.scheduleAtFixedRate(new ActorTask(this), 0L, 10L, TimeUnit.SECONDS); }
@Transactional public void createTestUser(@Observes @Initialized(ApplicationScoped.class) Object event) { em.persist(new User("jsmith", "pswd")); }
/** * Read in web.xml and differents producers the optional DASHBOARD_ROLES config and set it in OcelotConfiguration * * @param sc */ public void readDashboardRolesConfig(@Observes @Initialized(ApplicationScoped.class) ServletContext sc) { readFromConfigurationRoles(); readFromInitParameter(sc); logger.debug("'{}' value : '{}'.", Constants.Options.DASHBOARD_ROLES, roles); }
/** * Initialize components and schedule DS connection time checker */ public void applicationInitialized(@Observes @Initialized(ApplicationScoped.class) Object init) { log.debug("Initializing application services"); showBuildInfo(); customLibrariesLoader.init(); createEntryManagerFactory(); configurationFactory.create(); LdapEntryManager localLdapEntryManager = ldapEntryManagerInstance.get(); initializeLdifArchiver(localLdapEntryManager); // Initialize template engine templateService.initTemplateEngine(); // Initialize SubversionService subversionService.initSubversionService(); // Initialize python interpreter pythonService.initPythonInterpreter(configurationFactory.getLdapConfiguration().getString("pythonModulesDir", null)); // Initialize Shibboleth shibbolethInitializer.createShibbolethConfiguration(); // Initialize script manager List<CustomScriptType> supportedCustomScriptTypes = Arrays.asList( CustomScriptType.CACHE_REFRESH, CustomScriptType.UPDATE_USER, CustomScriptType.USER_REGISTRATION, CustomScriptType.ID_GENERATOR, CustomScriptType.SCIM ); // Start timer quartzSchedulerManager.start(); // Schedule timer tasks metricService.initTimer(); configurationFactory.initTimer(); ldapStatusTimer.initTimer(); metadataValidationTimer.initTimer(); entityIDMonitoringService.initTimer(); cacheRefreshTimer.initTimer(); customScriptManager.initTimer(supportedCustomScriptTypes); statusCheckerDaily.initTimer(); statusCheckerTimer.initTimer(); svnSyncTimer.initTimer(); logFileSizeChecker.initTimer(); loggerService.updateLoggerConfigLocation(); }
void eagerInit(@Observes @Initialized(ApplicationScoped.class) Object event) { // init }
void init(@Observes @Initialized(ApplicationScoped.class) Object obj) { LOGGER.info("Starting webserver on "+getMachineURL()); if(isSecuredConfigured()) { LOGGER.info("Running securely on " + getSecureURL()); } }
public void start(@Observes @Initialized(ApplicationScoped.class) final Object boot) { TheTestEntity entity = new TheTestEntity(); em.persist(entity); // ensure it works persisted = entity; }
public void newApplicationContext(@Observes @Initialized(ApplicationScoped.class) Object obj){ System.out.println("CDI: Application Context started..."); System.out.println("CDI: payload: "+ obj); }
public void newSessionContext(@Observes @Initialized(SessionScoped.class) Object obj){ System.out.println("CDI: Session Context started..."); System.out.println("CDI: payload: "+ obj); }
public void observesContext(@Observes @Initialized(ApplicationScoped.class) ServletContext context){ this.context = context; }
private final void onStartup(@Observes @Initialized(ApplicationScoped.class) final Object event) { }
/** * This methods starts up the receiver on application startup. * * @param payload * servlet context. */ public void processApplicationScopedInit(@Observes @Initialized(ApplicationScoped.class) ServletContext payload) { // do nothing. }
public void init(@Observes @Initialized(ApplicationScoped.class) Object object) { }