Java 类javax.enterprise.context.Initialized 实例源码

项目:lra-service    文件:LRAService.java   
/**
 * 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);
}
项目:accs-javaee8    文件:TickTockTickTock.java   
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");
    }
项目:zanata-mt    文件:MTStartup.java   
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();
}
项目:ocelot    文件:StacktraceConfigurationManager.java   
/**
 * 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);
}
项目:chlorophytum-semantics    文件:VertxLauncher.java   
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);
        });
    }
项目:microbule    文件:CdiContainer.java   
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();
}
项目:opendata-common    文件:SchedulerExtension.java   
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 );
    }
}
项目:jc2    文件:Configurator.java   
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);
    }
}
项目:Camel    文件:Application.java   
void login(@Observes @Initialized(ApplicationScoped.class) Object event) {
    System.out.println(
          "████████╗██╗  ██╗███████╗    ███╗   ███╗ █████╗ ████████╗██████╗ ██╗██╗  ██╗\n"
        + "╚══██╔══╝██║  ██║██╔════╝    ████╗ ████║██╔══██╗╚══██╔══╝██╔══██╗██║╚██╗██╔╝\n"
        + "   ██║   ███████║█████╗      ██╔████╔██║███████║   ██║   ██████╔╝██║ ╚███╔╝ \n"
        + "   ██║   ██╔══██║██╔══╝      ██║╚██╔╝██║██╔══██║   ██║   ██╔══██╗██║ ██╔██╗ \n"
        + "   ██║   ██║  ██║███████╗    ██║ ╚═╝ ██║██║  ██║   ██║   ██║  ██║██║██╔╝ ██╗\n"
        + "   ╚═╝   ╚═╝  ╚═╝╚══════╝    ╚═╝     ╚═╝╚═╝  ╚═╝   ╚═╝   ╚═╝  ╚═╝╚═╝╚═╝  ╚═╝");
}
项目:hawkular-commons    文件:BusEndpointProcessors.java   
/**
 * 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());
    }

}
项目:activemq-artemis    文件:CDIMessagingIntegrator.java   
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);
}
项目:javaee-samples    文件:AbstractExtensionOnStartupTimer.java   
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());
}
项目:javaee_projects    文件:CacheExposer.java   
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());

}
项目:oxAuth    文件:AppInitializer.java   
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();
}
项目:camel-cdi    文件:Application.java   
void login(@Observes @Initialized(ApplicationScoped.class) Object event) {
    System.out.println(
          "████████╗██╗  ██╗███████╗    ███╗   ███╗ █████╗ ████████╗██████╗ ██╗██╗  ██╗\n"
        + "╚══██╔══╝██║  ██║██╔════╝    ████╗ ████║██╔══██╗╚══██╔══╝██╔══██╗██║╚██╗██╔╝\n"
        + "   ██║   ███████║█████╗      ██╔████╔██║███████║   ██║   ██████╔╝██║ ╚███╔╝ \n"
        + "   ██║   ██╔══██║██╔══╝      ██║╚██╔╝██║██╔══██║   ██║   ██╔══██╗██║ ██╔██╗ \n"
        + "   ██║   ██║  ██║███████╗    ██║ ╚═╝ ██║██║  ██║   ██║   ██║  ██║██║██╔╝ ██╗\n"
        + "   ╚═╝   ╚═╝  ╚═╝╚══════╝    ╚═╝     ╚═╝╚═╝  ╚═╝   ╚═╝   ╚═╝  ╚═╝╚═╝╚═╝  ╚═╝");
}
项目:tomee    文件:AppScopeInitEventTest.java   
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");
}
项目:tomee    文件:Start.java   
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");
}
项目:tomee    文件:AddUser.java   
@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);
}
项目:tomee    文件:AppScopeInitEventTest.java   
private void capture(@Observes @Initialized(ApplicationScoped.class) final Object context) {
    if (this.context != null) {
        throw new IllegalStateException("app context started twice");
    }

    this.context = context;
}
项目:Mastering-Java-EE-Development-with-WildFly    文件:InitializeApplicationObserver.java   
public void processApplicationScopedInit(@Observes @Initialized(ApplicationScoped.class) ServletContext payload) {
    logger.info("initialized the ApplicationBean");
    applicationBean.incrementCounter();
}
项目:Mastering-Java-EE-Development-with-WildFly    文件:InitializeDependentObserver.java   
public void processDependentScopedInit(@Observes @Initialized(ApplicationScoped.class) ServletContext payload) {
    logger.info("initialized the DependentBean");
    dependentBean.incrementCounter();
}
项目:microbean-kubernetes-client-cdi    文件:KubernetesClientExtension.java   
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();
          }
        }
      });
  }
}
项目:cito    文件:EventProducer.java   
/**
 * @param init used initialise on startup of application.
 */
public void startup(@Observes @Initialized(ApplicationScoped.class) Object init) {
    connect();
}
项目:zanata-mt    文件:MicrosoftTranslatorBackend.java   
public void onInit(
        @Observes @Initialized(ApplicationScoped.class) Object init)
        throws MTException {
    api = new MicrosoftTranslatorClient(clientSubscriptionKey, restClient, dtoUtil);
}
项目:wildfly-swarm    文件:MPJWTProducer.java   
void observeRequestInitialized(@Observes @Initialized(RequestScoped.class) Object event) {
    log.tracef("observeRequestInitialized, event=%s", event);
}
项目:sealion    文件:DomaConfig.java   
public void migrate(@Observes @Initialized(ApplicationScoped.class) Object context) {
    Flyway flyway = new Flyway();
    flyway.setDataSource(dataSource);
    flyway.migrate();
}
项目:Camel    文件:ApplicationScopedTest.java   
static void expectations(@Observes @Initialized(ApplicationScoped.class) Object event,
                         @Uri("mock:out") MockEndpoint mock) {
    mock.expectedMessageCount(1);
    mock.expectedBodiesReceived(1);
}
项目:blaze-storage    文件:AbstractActor.java   
public void init(@Observes @Initialized(ApplicationScoped.class) Object o) {
    ManagedScheduledExecutorService executorService = getExecutorService();
    executorService.scheduleAtFixedRate(new ActorTask(this), 0L, 10L, TimeUnit.SECONDS);
}
项目:javaee-samples    文件:TestDataCreator.java   
@Transactional
public void createTestUser(@Observes @Initialized(ApplicationScoped.class) Object event) {
    em.persist(new User("jsmith", "pswd"));
}
项目:ocelot    文件:RoleConfigurationManager.java   
/**
 * 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);
}
项目:oxTrust    文件:AppInitializer.java   
/**
 * 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();
}
项目:hawkular-metrics    文件:MetricsServiceLifecycle.java   
void eagerInit(@Observes @Initialized(ApplicationScoped.class) Object event) {
    // init
}
项目:hammock    文件:HammockRuntime.java   
void init(@Observes @Initialized(ApplicationScoped.class) Object obj) {
    LOGGER.info("Starting webserver on "+getMachineURL());
    if(isSecuredConfigured()) {
        LOGGER.info("Running securely on " + getSecureURL());
    }
}
项目:tomee    文件:JPAHasBeanManagerTest.java   
public void start(@Observes @Initialized(ApplicationScoped.class) final Object boot) {
    TheTestEntity entity = new TheTestEntity();
    em.persist(entity); // ensure it works
    persisted = entity;
}
项目:CDI-RegistrationSample_1.1    文件:ScopeListener.java   
public void newApplicationContext(@Observes @Initialized(ApplicationScoped.class) Object obj){
    System.out.println("CDI: Application Context started...");
    System.out.println("CDI: payload: "+ obj);
}
项目:CDI-RegistrationSample_1.1    文件:ScopeListener.java   
public void newSessionContext(@Observes @Initialized(SessionScoped.class) Object obj){
    System.out.println("CDI: Session Context started...");
    System.out.println("CDI: payload: "+ obj);
}
项目:vraptor4    文件:ServletContextFactory.java   
public void observesContext(@Observes @Initialized(ApplicationScoped.class) ServletContext context){
    this.context = context;
}
项目:microbean-kubernetes-client-cdi    文件:TestKubernetesClientExtension.java   
private final void onStartup(@Observes @Initialized(ApplicationScoped.class) final Object event) {

  }
项目:mqtt-camunda-bpm    文件:MqttReceiver.java   
/**
 * This methods starts up the receiver on application startup.
 * 
 * @param payload
 *            servlet context.
 */
public void processApplicationScopedInit(@Observes @Initialized(ApplicationScoped.class) ServletContext payload) {
    // do nothing.
}
项目:restful-and-beyond-tut2184    文件:MongoProducer.java   
public void init(@Observes @Initialized(ApplicationScoped.class) Object object) {

    }