当前位置: 首页>>代码示例>>Java>>正文


Java Interceptor类代码示例

本文整理汇总了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);
}
 
开发者ID:dajudge,项目名称:testee.fi,代码行数:13,代码来源:MockingExtension.java

示例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);
    }
}
 
开发者ID:apache,项目名称:tomee,代码行数:35,代码来源:CdiEjbBean.java

示例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;
}
 
开发者ID:apache,项目名称:tomee,代码行数:28,代码来源:CdiEjbBean.java

示例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.");
                }
            }
        }
    }
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:30,代码来源:GlobalInterceptorExtension.java

示例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);
    }
}
 
开发者ID:NovaTecConsulting,项目名称:BeanTest,代码行数:25,代码来源:BeanTestExtension.java


注:本文中的javax.interceptor.Interceptor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。