本文整理汇总了Java中javax.enterprise.context.NormalScope类的典型用法代码示例。如果您正苦于以下问题:Java NormalScope类的具体用法?Java NormalScope怎么用?Java NormalScope使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NormalScope类属于javax.enterprise.context包,在下文中一共展示了NormalScope类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scope
import javax.enterprise.context.NormalScope; //导入依赖的package包/类
public Class<? extends Annotation> scope() {
if (null == scope) {
synchronized (this) {
if (null == scope) {
Class<?> c = getClass();
if (c.isAnnotationPresent(RequestScoped.class)) {
scope = RequestScoped.class;
} else if (c.isAnnotationPresent(SessionScoped.class)) {
scope = SessionScoped.class;
} else if (c.isAnnotationPresent(ApplicationScoped.class)) {
scope = ApplicationScoped.class;
} else {
scope = NormalScope.class;
}
}
}
}
return scope;
}
示例2: activate
import javax.enterprise.context.NormalScope; //导入依赖的package包/类
/**
* Activate and deactivate contexts for the given normal scopes for each test method execution.
* <p>
* {@link ApplicationScoped} is ignored as it is always active.
* </p>
*
* @param normalScopes
* @return self
*/
@SafeVarargs
public final T activate(Class<? extends Annotation>... normalScopes) {
for (Class<? extends Annotation> scope : normalScopes) {
if (ApplicationScoped.class.equals(scope)) {
continue;
}
if (!scope.isAnnotationPresent(NormalScope.class)) {
throw new IllegalArgumentException("Only annotations annotated with @NormalScope are supported!");
}
this.scopesToActivate.add(scope);
}
return self();
}