当前位置: 首页>>代码示例>>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;未经允许,请勿转载。