當前位置: 首頁>>代碼示例>>Java>>正文


Java ApplicationScoped類代碼示例

本文整理匯總了Java中javax.enterprise.context.ApplicationScoped的典型用法代碼示例。如果您正苦於以下問題:Java ApplicationScoped類的具體用法?Java ApplicationScoped怎麽用?Java ApplicationScoped使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ApplicationScoped類屬於javax.enterprise.context包,在下文中一共展示了ApplicationScoped類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: enableRecovery

import javax.enterprise.context.ApplicationScoped; //導入依賴的package包/類
/**
 * 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);
}
 
開發者ID:xstefank,項目名稱:lra-service,代碼行數:21,代碼來源:LRAService.java

示例2: resolveScopeMetadata

import javax.enterprise.context.ApplicationScoped; //導入依賴的package包/類
@Override
public ScopeMetadata resolveScopeMetadata(final BeanDefinition definition) {

    if (definition instanceof AnnotatedBeanDefinition) {
        final AnnotatedBeanDefinition beanDefinition = (AnnotatedBeanDefinition) definition;
        final ScopeMetadata metadata = new ScopeMetadata();
        final Set<String> annotationTypes = beanDefinition.getMetadata().getAnnotationTypes();

        if (annotationTypes.contains(RequestScoped.class
            .getName())) {
            metadata.setScopeName("request");
            metadata.setScopedProxyMode(ScopedProxyMode.TARGET_CLASS);
        } else if (annotationTypes
            .contains(ApplicationScoped.class.getName())) {
            metadata.setScopeName("singleton");
        } else {
            return super.resolveScopeMetadata(definition);
        }
        return metadata;
    } else {
        return super.resolveScopeMetadata(definition);
    }
}
 
開發者ID:trajano,項目名稱:app-ms,代碼行數:24,代碼來源:CdiScopeMetadataResolver.java

示例3: stopWatching

import javax.enterprise.context.ApplicationScoped; //導入依賴的package包/類
private final void stopWatching(@Observes @BeforeDestroyed(ApplicationScoped.class) @Priority(LIBRARY_BEFORE) final Object event) throws Exception {
  final Closeable watch = this.watch;
  if (watch != null) {
    KubernetesClientException closeException = this.closeException;
    try {
      watch.close();
    } catch (final Exception everything) {
      if (closeException != null) {
        closeException.addSuppressed(everything);
        throw closeException;
      } else {
        throw everything;
      }
    }
    if (closeException != null) {
      throw closeException;
    }
  }
}
 
開發者ID:microbean,項目名稱:microbean-kubernetes-client-cdi,代碼行數:20,代碼來源:KubernetesClientExtension.java

示例4: onTrigger

import javax.enterprise.context.ApplicationScoped; //導入依賴的package包/類
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");
    }
 
開發者ID:abhirockzz,項目名稱:accs-javaee8,代碼行數:21,代碼來源:TickTockTickTock.java

示例5: applyBeforeFeatureConfig

import javax.enterprise.context.ApplicationScoped; //導入依賴的package包/類
void applyBeforeFeatureConfig(Class testClass) {
    CdiContainer container = CdiContainerLoader.getCdiContainer();

    if (!isContainerStarted()) {
        container.boot(CdiTestSuiteRunner.getTestContainerConfig());
        containerStarted = true;
        bootExternalContainers(testClass);
    }

    List<Class<? extends Annotation>> restrictedScopes = new ArrayList<Class<? extends Annotation>>();

    //controlled by the container and not supported by weld:
    restrictedScopes.add(ApplicationScoped.class);
    restrictedScopes.add(Singleton.class);

    if (this.parent == null && this.testControl.getClass().equals(TestControlLiteral.class)) {
        //skip scope-handling if @TestControl isn't used explicitly on the test-class -> TODO re-visit it
        restrictedScopes.add(RequestScoped.class);
        restrictedScopes.add(SessionScoped.class);
    }

    this.previousProjectStage = ProjectStageProducer.getInstance().getProjectStage();
    ProjectStageProducer.setProjectStage(this.projectStage);

    startScopes(container, testClass, null, restrictedScopes.toArray(new Class[restrictedScopes.size()]));
}
 
開發者ID:database-rider,項目名稱:database-rider,代碼行數:27,代碼來源:CdiCucumberTestRunner.java

示例6: onStartUp

import javax.enterprise.context.ApplicationScoped; //導入依賴的package包/類
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();
}
 
開發者ID:zanata,項目名稱:zanata-mt,代碼行數:19,代碼來源:MTStartup.java

示例7: defaultClusteredCacheManager

import javax.enterprise.context.ApplicationScoped; //導入依賴的package包/類
@Produces
@ApplicationScoped
public EmbeddedCacheManager defaultClusteredCacheManager() {
    GlobalConfiguration g = new GlobalConfigurationBuilder()
            .clusteredDefault()
            .transport()
            .clusterName(MACHINE_TRANSLATIONS_CLUSTER)
            .globalJmxStatistics()
            .allowDuplicateDomains(true)
            .build();
    Configuration cfg = new ConfigurationBuilder()
            .clustering()
            .cacheMode(CacheMode.DIST_ASYNC)
            .eviction()
            .strategy(EvictionStrategy.LRU)
            .type(EvictionType.COUNT).size(150)
            .transaction()
            .transactionMode(TransactionMode.TRANSACTIONAL)
            .lockingMode(LockingMode.PESSIMISTIC)
            .build();
    return new DefaultCacheManager(g, cfg);
}
 
開發者ID:zanata,項目名稱:zanata-mt,代碼行數:23,代碼來源:ResourceProducer.java

示例8: produce

import javax.enterprise.context.ApplicationScoped; //導入依賴的package包/類
@Produces
@ApplicationScoped
public JsonDataProvider produce(BeanManager beanManager) {
    ProbeExtension extension = beanManager.getExtension(ProbeExtension.class);
    if (extension == null) {
        throw new IllegalStateException("ProbeExtension not available");
    }
    try {
        // Unfortunately, getJsonDataProvider() is package-private
        Method getProviderMethod = SecurityActions.getDeclaredMethod(ProbeExtension.class, "getJsonDataProvider");
        if (getProviderMethod == null) {
            throw new IllegalStateException("ProbeExtension.getJsonDataProvider() method not found or inaccessible");
        }
        SecurityActions.ensureAccessible(getProviderMethod);
        return (JsonDataProvider) getProviderMethod.invoke(extension);
    } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
        throw new IllegalStateException("Unable to get JsonDataProvider", e);
    }
}
 
開發者ID:weld,項目名稱:weld-vertx,代碼行數:20,代碼來源:JsonDataProviderProducer.java

示例9: processClaimValueInjections

import javax.enterprise.context.ApplicationScoped; //導入依賴的package包/類
void processClaimValueInjections(@Observes ProcessInjectionPoint pip) {
    log.debugf("pipRaw: %s", pip.getInjectionPoint());
    InjectionPoint ip = pip.getInjectionPoint();
    if (ip.getAnnotated().isAnnotationPresent(Claim.class) && ip.getType() instanceof Class) {
        Class rawClass = (Class) ip.getType();
        if (Modifier.isFinal(rawClass.getModifiers())) {
            Claim claim = ip.getAnnotated().getAnnotation(Claim.class);
            rawTypes.add(ip.getType());
            rawTypeQualifiers.add(claim);
            log.debugf("+++ Added Claim raw type: %s", ip.getType());
            Class declaringClass = ip.getMember().getDeclaringClass();
            Annotation[] appScoped = declaringClass.getAnnotationsByType(ApplicationScoped.class);
            Annotation[] sessionScoped = declaringClass.getAnnotationsByType(SessionScoped.class);
            if ((appScoped != null && appScoped.length > 0) || (sessionScoped != null && sessionScoped.length > 0)) {
                String err = String.format("A raw type cannot be injected into application/session scope: IP=%s", ip);
                pip.addDefinitionError(new DeploymentException(err));
            }

        }
    }
}
 
開發者ID:wildfly-swarm,項目名稱:wildfly-swarm,代碼行數:22,代碼來源:MPJWTExtension.java

示例10: destroy

import javax.enterprise.context.ApplicationScoped; //導入依賴的package包/類
@Override
public void destroy() {
    if (isDestroyed()) {
        return;
    }
    isDestroyed = true;
    Destroyable.Util.tryDestroyAll(serviceById.values(), ApplicationScoped.class);
    Destroyable.Util.tryDestroyAll(dbHookers, ApplicationScoped.class);
    serviceById.clear();
    serviceByClassField.clear();
    fieldTypeMap.clear();
    serviceByClass.clear();
    updatePolicyByClassField.clear();
    updatePolicyByClass.clear();
    managedFieldByClass.clear();
    managedFieldByClass2.clear();
    setterByClass.clear();
    dbHookers.clear();
    app = null;
}
 
開發者ID:actframework,項目名稱:act-storage,代碼行數:21,代碼來源:StorageServiceManager.java

示例11: disableRecovery

import javax.enterprise.context.ApplicationScoped; //導入依賴的package包/類
/**
 * When the deployment is unloaded unregister for recovery
 *
 * @param init a javax.servlet.ServletContext
 */
void disableRecovery(@Observes @Destroyed(ApplicationScoped.class) Object init) {
    assert lraRecoveryModule != null;

    Implementations.uninstall();
    RecoveryManager.manager().removeModule(lraRecoveryModule, false);
    lraRecoveryModule = null;

    if (LRALogger.logger.isDebugEnabled())
        LRALogger.logger.debugf("LRAServicve.disableRecovery%n");    }
 
開發者ID:xstefank,項目名稱:lra-service,代碼行數:15,代碼來源:LRAService.java

示例12: createMetaModule

import javax.enterprise.context.ApplicationScoped; //導入依賴的package包/類
@Produces
@ApplicationScoped
public MetaModule createMetaModule() {
	MetaModuleConfig metaConfig = new MetaModuleConfig();
	metaConfig.addMetaProvider(new ResourceMetaProvider());
	MetaModule metaModule = MetaModule.createServerModule(metaConfig);
	return metaModule;
}
 
開發者ID:crnk-project,項目名稱:crnk-framework,代碼行數:9,代碼來源:MetaModuleProducer.java

示例13: createRepositoryModule

import javax.enterprise.context.ApplicationScoped; //導入依賴的package包/類
@Produces
@ApplicationScoped
public Module createRepositoryModule() {
	SimpleModule module = new SimpleModule("mock");
	module.addRepository(new ScheduleRepositoryImpl());
	module.addRepository(new ProjectRepository());
	module.addRepository(new TaskRepository());
	module.addRepository(new ProjectToTaskRepository());
	module.addRepository(new ScheduleToTaskRepository());
	module.addRepository(new TaskSubtypeRepository());
	module.addRepository(new TaskToProjectRepository());
	module.addRepository(new TaskToScheduleRepo());
	return module;
}
 
開發者ID:crnk-project,項目名稱:crnk-framework,代碼行數:15,代碼來源:MetaModuleProducer.java

示例14: createIdSupplierBean

import javax.enterprise.context.ApplicationScoped; //導入依賴的package包/類
static Bean<?> createIdSupplierBean() {
    return MockBean.<IdSupplier>builder()
        .types(IdSupplier.class)
        .scope(ApplicationScoped.class)
        .create(new CreateFunction<IdSupplier>() {
            @Override
            public IdSupplier create(CreationalContext<IdSupplier> creationalContext) {
                return new IdSupplier(UUID.randomUUID().toString());
            }
        }).build();
}
 
開發者ID:weld,項目名稱:weld-junit,代碼行數:12,代碼來源:AddBeanTest.java

示例15: createIdSupplierBean

import javax.enterprise.context.ApplicationScoped; //導入依賴的package包/類
static Bean<?> createIdSupplierBean() {
    return MockBean.<IdSupplier> builder()
            .types(IdSupplier.class)
            .scope(ApplicationScoped.class)
            .create(new CreateFunction<IdSupplier>() {
                @Override
                public IdSupplier create(CreationalContext<IdSupplier> creationalContext) {
                    return new IdSupplier(UUID.randomUUID().toString());
                }
            }).build();
}
 
開發者ID:weld,項目名稱:weld-junit,代碼行數:12,代碼來源:AddBeanTest.java


注:本文中的javax.enterprise.context.ApplicationScoped類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。