javax.enterprise.context.Initialized Java Examples
The following examples show how to use
javax.enterprise.context.Initialized.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BeanArchives.java From quarkus with Apache License 2.0 | 6 votes |
private static IndexView buildAdditionalIndex() { Indexer indexer = new Indexer(); // CDI API index(indexer, ActivateRequestContext.class.getName()); index(indexer, Default.class.getName()); index(indexer, Any.class.getName()); index(indexer, Named.class.getName()); index(indexer, Initialized.class.getName()); index(indexer, BeforeDestroyed.class.getName()); index(indexer, Destroyed.class.getName()); index(indexer, Intercepted.class.getName()); index(indexer, Model.class.getName()); // Arc built-in beans index(indexer, ActivateRequestContextInterceptor.class.getName()); index(indexer, InjectableRequestContextController.class.getName()); return indexer.complete(); }
Example #2
Source File: H2DatabaseServiceInitializer.java From apicurio-registry with Apache License 2.0 | 5 votes |
@Override public void beforeAll(@Observes @Initialized(ApplicationScoped.class) Object event) throws Exception { log.info("Starting H2 ..."); H2DatabaseService tmp = new H2DatabaseService(); tmp.start(); service = tmp; }
Example #3
Source File: CDIMessagingIntegrator.java From activemq-artemis with Apache License 2.0 | 5 votes |
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); }
Example #4
Source File: TomEESecurityServletAuthenticationMechanismMapper.java From tomee with Apache License 2.0 | 5 votes |
public void init(@Observes @Initialized(ApplicationScoped.class) final ServletContext context) { final Map<String, ? extends ServletRegistration> servletRegistrations = context.getServletRegistrations(); servletRegistrations.forEach((servletName, servletRegistration) -> { try { final Class<?> servletClass = Thread.currentThread().getContextClassLoader().loadClass(servletName); if (servletClass.isAnnotationPresent(BasicAuthenticationMechanismDefinition.class)) { servletAuthenticationMapper.put(servletName, CDI.current().select(BasicAuthenticationMechanism.class).get()); } if (servletClass.isAnnotationPresent(FormAuthenticationMechanismDefinition.class)) { servletAuthenticationMapper.put(servletName, CDI.current().select(FormAuthenticationMechanism.class).get()); } } catch (final ClassNotFoundException e) { // Ignore } }); final Set<HttpAuthenticationMechanism> availableBeans = authenticationMechanisms.stream().collect(Collectors.toSet()); availableBeans.removeAll(servletAuthenticationMapper.values()); availableBeans.remove(defaultAuthenticationMechanism); if (availableBeans.size() == 1) { defaultAuthenticationMechanism.setDelegate(availableBeans.iterator().next()); } else if (availableBeans.size() > 1) { throw new IllegalStateException( "Multiple HttpAuthenticationMechanism found " + availableBeans.stream() .map(b -> substringBefore(b.getClass().getSimpleName(), "$$")) .collect(toList()) + " " + "without a @WebServlet association. " + "Deploy a single one for the application, or associate it with a @WebServlet."); } }
Example #5
Source File: AppScopeInitEventTest.java From tomee with Apache License 2.0 | 5 votes |
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"); }
Example #6
Source File: Start.java From tomee with Apache License 2.0 | 5 votes |
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"); }
Example #7
Source File: AddUser.java From tomee with Apache License 2.0 | 5 votes |
@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); }
Example #8
Source File: ArcContainerImpl.java From quarkus with Apache License 2.0 | 5 votes |
public void init() { requireRunning(); // Fire an event with qualifier @Initialized(ApplicationScoped.class) Set<Annotation> qualifiers = new HashSet<>(4); qualifiers.add(Initialized.Literal.APPLICATION); qualifiers.add(Any.Literal.INSTANCE); EventImpl.createNotifier(Object.class, Object.class, qualifiers, this).notify(toString()); // Configure CDIProvider used for CDI.current() CDI.setCDIProvider(new ArcCDIProvider()); LOGGER.debugf("ArC DI container initialized [beans=%s, observers=%s]", beans.size(), observers.size()); }
Example #9
Source File: TransactionBeanWithEvents.java From quarkus with Apache License 2.0 | 5 votes |
void transactionScopeActivated(@Observes @Initialized(TransactionScoped.class) final Object event, final BeanManager beanManager) throws SystemException { Transaction tx = tm.getTransaction(); if (tx == null) { log.error("@Intialized expects an active transaction"); throw new IllegalStateException("@Intialized expects an active transaction"); } if (tx.getStatus() != Status.STATUS_ACTIVE) { log.error("@Initialized expects transaction is Status.STATUS_ACTIVE"); throw new IllegalStateException("@Initialized expects transaction is Status.STATUS_ACTIVE"); } Context ctx; try { ctx = beanManager.getContext(TransactionScoped.class); } catch (Exception e) { log.error("Context on @Initialized is not available"); throw e; } if (!ctx.isActive()) { log.error("Context on @Initialized has to be active"); throw new IllegalStateException("Context on @Initialized has to be active"); } if (!(event instanceof Transaction)) { log.error("@Intialized scope expects event payload being the " + Transaction.class.getName()); throw new IllegalStateException("@Intialized scope expects event payload being the " + Transaction.class.getName()); } initializedCount++; }
Example #10
Source File: AppScopeInitEventTest.java From tomee with Apache License 2.0 | 5 votes |
private void capture(@Observes @Initialized(ApplicationScoped.class) final Object context) { if (this.context != null) { throw new IllegalStateException("app context started twice"); } this.context = context; }
Example #11
Source File: KafkaServiceInitializer.java From apicurio-registry with Apache License 2.0 | 5 votes |
@Override public void beforeAll(@Observes @Initialized(ApplicationScoped.class) Object event) throws Exception { Properties properties = new Properties(); properties.put( CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG, System.getProperty(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092") ); properties.put("connections.max.idle.ms", 10000); properties.put("request.timeout.ms", 5000); try (AdminClient client = AdminClient.create(properties)) { ListTopicsResult topics = client.listTopics(); Set<String> names = topics.names().get(); log.info("Kafka is running - {} ...", names); } }
Example #12
Source File: StreamsServiceInitializer.java From apicurio-registry with Apache License 2.0 | 5 votes |
@Override public void beforeAll(@Observes @Initialized(ApplicationScoped.class) Object event) throws Exception { Properties properties = new Properties(); properties.put( CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG, System.getProperty(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092") ); properties.put("connections.max.idle.ms", 10000); properties.put("request.timeout.ms", 5000); try (AdminClient client = AdminClient.create(properties)) { ListTopicsResult topics = client.listTopics(); Set<String> names = topics.names().get(); log.info("Kafka is running - {} ...", names); } }
Example #13
Source File: ServletContextFactory.java From vraptor4 with Apache License 2.0 | 4 votes |
public void observesContext(@Observes @Initialized(ApplicationScoped.class) ServletContext context){ this.context = context; }
Example #14
Source File: ConfigObserver.java From microprofile-config with Apache License 2.0 | 4 votes |
private static final void onStartup(@Observes @Initialized(ApplicationScoped.class) final Object event, @ConfigProperty(name = "this.property.does.not.exist") final String nonExistentConfigurationPropertyValue) { }
Example #15
Source File: ContextInProxiedInstancesTest.java From openwebbeans-meecrowave with Apache License 2.0 | 4 votes |
public void init(@Observes @Initialized(ApplicationScoped.class) final ServletContext sc) { // init without a Message }
Example #16
Source File: ThreadPoolManager.java From CodeDefenders with GNU Lesser General Public License v3.0 | 4 votes |
void init(@Observes @Initialized(ApplicationScoped.class) final Object start) { registrationEvent.fire(this); // note: doesn't prevent to support some default file configuration if desired running.set(true); }
Example #17
Source File: ComponentManagerService.java From component-runtime with Apache License 2.0 | 4 votes |
public void startupLoad(@Observes @Initialized(ApplicationScoped.class) final Object start) { // no-op }
Example #18
Source File: AppInitializer.java From oxTrust with MIT License | 4 votes |
/** * Initialize components and schedule DS connection time checker */ public void applicationInitialized(@Observes @Initialized(ApplicationScoped.class) Object init) { log.debug("Initializing application services"); showBuildInfo(); configurationFactory.create(); PersistenceEntryManager localLdapEntryManager = persistenceEntryManagerInstance.get(); initializeLdifArchiver(localLdapEntryManager); // Initialize template engine templateService.initTemplateEngine(); // Initialize python interpreter pythonService.initPythonInterpreter(configurationFactory.getBaseConfiguration() .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.PERSISTENCE_EXTENSION); // Start timer initSchedulerService(); // Schedule timer tasks metricService.initTimer(); configurationFactory.initTimer(); loggerService.initTimer(); ldapStatusTimer.initTimer(); metadataValidationTimer.initTimer(); entityIDMonitoringService.initTimer(); cacheRefreshTimer.initTimer(); customScriptManager.initTimer(supportedCustomScriptTypes); cleanerTimer.initTimer(); statusCheckerDaily.initTimer(); statusCheckerTimer.initTimer(); logFileSizeChecker.initTimer(); updateChecker.initTimer(); // Notify other components/plugins about finish application initialization eventApplicationInitialized.select(ApplicationInitialized.Literal.APPLICATION) .fire(new ApplicationInitializedEvent()); }
Example #19
Source File: MetricsServiceLifecycle.java From hawkular-metrics with Apache License 2.0 | 4 votes |
void eagerInit(@Observes @Initialized(ApplicationScoped.class) Object event) { // init }
Example #20
Source File: AppInitializer.java From oxAuth with MIT License | 4 votes |
public void applicationInitialized(@Observes @Initialized(ApplicationScoped.class) Object init) { log.debug("Initializing application services"); configurationFactory.create(); PersistenceEntryManager localPersistenceEntryManager = persistenceEntryManagerInstance.get(); log.trace("Attempting to use {}: {}", ApplicationFactory.PERSISTENCE_ENTRY_MANAGER_NAME, localPersistenceEntryManager.getOperationService()); GluuConfiguration newConfiguration = loadConfiguration(localPersistenceEntryManager, "oxIDPAuthentication", "oxAuthenticationMode"); this.persistenceAuthConfigs = loadPersistenceAuthConfigs(newConfiguration); // Initialize python interpreter pythonService.initPythonInterpreter(configurationFactory.getBaseConfiguration() .getString("pythonModulesDir", null)); // Initialize script manager List<CustomScriptType> supportedCustomScriptTypes = Lists.newArrayList(CustomScriptType.values()); supportedCustomScriptTypes.remove(CustomScriptType.CACHE_REFRESH); supportedCustomScriptTypes.remove(CustomScriptType.UPDATE_USER); supportedCustomScriptTypes.remove(CustomScriptType.USER_REGISTRATION); supportedCustomScriptTypes.remove(CustomScriptType.SCIM); supportedCustomScriptTypes.remove(CustomScriptType.IDP); // Start timer initSchedulerService(); // Schedule timer tasks metricService.initTimer(); configurationFactory.initTimer(); loggerService.initTimer(); ldapStatusTimer.initTimer(); cleanerTimer.initTimer(); customScriptManager.initTimer(supportedCustomScriptTypes); keyGeneratorTimer.initTimer(); expirationNotificatorTimer.initTimer(); initTimer(); initCibaRequestsProcessor(); // Set default authentication method after setDefaultAuthenticationMethod(newConfiguration); // Notify plugins about finish application initialization eventApplicationInitialized.select(ApplicationInitialized.Literal.APPLICATION) .fire(new ApplicationInitializedEvent()); }
Example #21
Source File: ServletContextProducer.java From portals-pluto with Apache License 2.0 | 4 votes |
public void applicationScopedInitialized( @Initialized(ApplicationScoped.class) @Observes ServletContext servletContext) { servletContexts.add(servletContext); }
Example #22
Source File: HammockRuntime.java From hammock with Apache License 2.0 | 4 votes |
void init(@Observes @Initialized(ApplicationScoped.class) Object obj) { LOGGER.info("Starting webserver on "+getMachineURL()); if(isSecuredConfigured()) { LOGGER.info("Running securely on " + getSecureURL()); } }
Example #23
Source File: JWTAuthConfigurationProperties.java From tomee with Apache License 2.0 | 4 votes |
public void init(@Observes @Initialized(ApplicationScoped.class) ServletContext context) { this.config = ConfigProvider.getConfig(); this.jwtAuthConfiguration = createJWTAuthConfiguration(); }
Example #24
Source File: JPAHasBeanManagerTest.java From tomee with Apache License 2.0 | 4 votes |
public void start(@Observes @Initialized(ApplicationScoped.class) final Object boot) { TheTestEntity entity = new TheTestEntity(); em.persist(entity); // ensure it works persisted = entity; }
Example #25
Source File: Startup.java From component-runtime with Apache License 2.0 | 4 votes |
public void onStart(@Observes @Initialized(ApplicationScoped.class) final Object start) { log.info("Starting..."); }
Example #26
Source File: MetricsInitializer.java From smallrye-metrics with Apache License 2.0 | 4 votes |
void init(@Observes @Initialized(ApplicationScoped.class) Object ignored) throws IOException { JmxRegistrar registrar = new JmxRegistrar(); registrar.init(); }
Example #27
Source File: RequestContext.java From quarkus with Apache License 2.0 | 4 votes |
private static Notifier<Object> createInitializedNotifier() { return EventImpl.createNotifier(Object.class, Object.class, new HashSet<>(Arrays.asList(Initialized.Literal.REQUEST, Any.Literal.INSTANCE)), ArcContainerImpl.instance()); }
Example #28
Source File: BeanDeploymentValidatorTest.java From quarkus with Apache License 2.0 | 4 votes |
void observeAppContextInit(@Observes @Initialized(ApplicationScoped.class) Object event) { }
Example #29
Source File: OriginalBean.java From quarkus with Apache License 2.0 | 4 votes |
void observerEvent(@Observes @Initialized(ApplicationScoped.class) Object event) { TIMES_INVOKED++; }
Example #30
Source File: ContextObserver.java From quarkus with Apache License 2.0 | 4 votes |
public void observeContextInit(@Observes @Initialized(RequestScoped.class) Object event) { initializedObserved++; }