本文整理汇总了Java中javax.interceptor.Interceptor类的典型用法代码示例。如果您正苦于以下问题:Java Interceptor类的具体用法?Java Interceptor怎么用?Java Interceptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Interceptor类属于javax.interceptor包,在下文中一共展示了Interceptor类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: beans
import javax.interceptor.Interceptor; //导入依赖的package包/类
public <X> void beans(
final @Observes ProcessAnnotatedType<X> processBean
) {
if (!processBean.getAnnotatedType().isAnnotationPresent(Interceptor.class)) {
return;
}
final FilteringAnnotatedTypeWrapper<X> filtered = new FilteringAnnotatedTypeWrapper<>(
processBean.getAnnotatedType(),
it -> it != Priority.class
);
processBean.setAnnotatedType(filtered);
}
示例2: CdiEjbBean
import javax.interceptor.Interceptor; //导入依赖的package包/类
public CdiEjbBean(final BeanContext bc, final WebBeansContext webBeansContext, final Class beanClass, final AnnotatedType<T> at,
final InjectionTargetFactoryImpl<T> factory, final BeanAttributes<T> attributes) {
super(webBeansContext, toSessionType(bc.getComponentType()), at,
new EJBBeanAttributesImpl<T>(bc, attributes),
beanClass, factory);
this.beanContext = bc;
bc.set(Bean.class, this);
passivatingId = bc.getDeploymentID() + getReturnType().getName();
final boolean stateful = BeanType.STATEFUL.equals(bc.getComponentType());
final boolean isDependent = getScope().equals(Dependent.class);
isDependentAndStateful = isDependent && stateful;
if (webBeansContext.getBeanManagerImpl().isPassivatingScope(getScope()) && stateful) {
if (!getBeanContext().isPassivable()) {
throw new DefinitionException(
getBeanContext().getBeanClass()
+ " is a not apssivation-capable @Stateful with a scope "
+ getScope().getSimpleName() + " which need passivation");
}
passivable = true;
} else {
passivable = false;
}
if (!isDependent) {
for (final Type type : attributes.getTypes()) {
if (ParameterizedType.class.isInstance(type)) {
throw new DefinitionException("Parameterized session bean should be @Dependent: " + beanClass);
}
}
}
if (getAnnotatedType().isAnnotationPresent(Interceptor.class) || getAnnotatedType().isAnnotationPresent(Decorator.class)) {
throw new DefinitionException("An EJB can't be an interceptor or a decorator: " + beanClass);
}
}
示例3: createNewPojo
import javax.interceptor.Interceptor; //导入依赖的package包/类
public T createNewPojo(final CreationalContext<T> creationalContext) {
final CreationalContextImpl<T> ccImpl = CreationalContextImpl.class.cast(creationalContext);
// super.produce(cc) will not work since we need the unproxied instance - decorator case
final Map<javax.enterprise.inject.spi.Interceptor<?>, Object> interceptorInstances = super.createInterceptorInstances(ccImpl);
final InterceptorResolutionService.BeanInterceptorInfo interceptorInfo = super.getInterceptorInfo();
if (interceptorInfo != null) {
final Map<Constructor<?>, InterceptorResolutionService.BusinessMethodInterceptorInfo> constructorInterceptorInfos =
interceptorInfo.getConstructorInterceptorInfos();
if (!constructorInterceptorInfos.isEmpty()) { // were missed by OWB
final javax.enterprise.inject.spi.Interceptor<?>[] ejbInterceptors = constructorInterceptorInfos.values().iterator().next().getEjbInterceptors();
if (null != ejbInterceptors) {
for (final javax.enterprise.inject.spi.Interceptor interceptorBean : ejbInterceptors) {
if (!interceptorInstances.containsKey(interceptorBean)) {
ccImpl.putContextual(interceptorBean);
interceptorInstances.put(interceptorBean, interceptorBean.create(ccImpl));
}
}
}
}
}
final T produce = super.produce(interceptorInstances, ccImpl);
if (produce == null) { // user didnt call ic.proceed() in @AroundConstruct
return super.newInstance(ccImpl);
}
return (T) produce;
}
示例4: promoteInterceptors
import javax.interceptor.Interceptor; //导入依赖的package包/类
protected void promoteInterceptors(@Observes ProcessAnnotatedType pat)
{
if (priorityAnnotationInstance == null) //not CDI 1.1 or the extension is deactivated
{
return;
}
String beanClassName = pat.getAnnotatedType().getJavaClass().getName();
if (beanClassName.startsWith(DS_PACKAGE_NAME))
{
if (pat.getAnnotatedType().isAnnotationPresent(Interceptor.class))
{
//noinspection unchecked
pat.setAnnotatedType(new GlobalInterceptorWrapper(pat.getAnnotatedType(), priorityAnnotationInstance));
}
//currently not needed, because we don't use our interceptors internally -> check for the future
else if (!beanClassName.contains(".test."))
{
for (Annotation annotation : pat.getAnnotatedType().getAnnotations())
{
if (beanManager.isInterceptorBinding(annotation.annotationType()))
{
//once we see this warning we need to introduce double-call prevention logic due to WELD-1780
LOG.warning(beanClassName + " is an bean from DeltaSpike which is intercepted.");
}
}
}
}
}
示例5: processInjectionTarget
import javax.interceptor.Interceptor; //导入依赖的package包/类
/**
* Replaces the meta data of the {@link ProcessAnnotatedType}.
*
* <p>
* The ProcessAnnotatedType's meta data will be replaced, if the annotated type has one of the following annotations:
* <ul>
* <li> {@link Stateless}
* <li> {@link MessageDriven}
* <li> {@link Interceptor}
* <li> {@link Singleton}
* </ul>
*
* @param <X> the type of the ProcessAnnotatedType
* @param pat the annotated type representing the class being processed
*/
public <X> void processInjectionTarget(@Observes @WithAnnotations({Stateless.class, MessageDriven.class, Interceptor.class, Singleton.class}) ProcessAnnotatedType<X> pat) {
if (pat.getAnnotatedType().isAnnotationPresent(Stateless.class) || pat.getAnnotatedType().isAnnotationPresent(MessageDriven.class)) {
modifiyAnnotatedTypeMetadata(pat);
} else if (pat.getAnnotatedType().isAnnotationPresent(Interceptor.class)) {
processInterceptorDependencies(pat);
} else if(pat.getAnnotatedType().isAnnotationPresent(Singleton.class)) {
addApplicationScopedAndTransactionalToSingleton(pat);
}
}