本文整理匯總了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);
}
示例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);
}
}
示例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;
}
}
}
示例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");
}
示例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()]));
}
示例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();
}
示例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);
}
示例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);
}
}
示例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));
}
}
}
}
示例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;
}
示例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"); }
示例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;
}
示例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;
}
示例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();
}
示例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();
}