• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Interceptor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中javax.enterprise.inject.spi.Interceptor的典型用法代码示例。如果您正苦于以下问题:Java Interceptor类的具体用法?Java Interceptor怎么用?Java Interceptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Interceptor类属于javax.enterprise.inject.spi包,在下文中一共展示了Interceptor类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createInterceptorData

import javax.enterprise.inject.spi.Interceptor; //导入依赖的package包/类
private InterceptorData createInterceptorData(final Interceptor<?> i) {
    final InterceptorData data;
    if (CdiInterceptorBean.class.isInstance(i)) {
        final CdiInterceptorBean cdiInterceptorBean = CdiInterceptorBean.class.cast(i);

        data = new InterceptorData(i.getBeanClass());
        data.getAroundInvoke().addAll(getInterceptionMethodAsListOrEmpty(cdiInterceptorBean, InterceptionType.AROUND_INVOKE));
        data.getPostConstruct().addAll(getInterceptionMethodAsListOrEmpty(cdiInterceptorBean, InterceptionType.POST_CONSTRUCT));
        data.getPreDestroy().addAll(getInterceptionMethodAsListOrEmpty(cdiInterceptorBean, InterceptionType.PRE_DESTROY));
        data.getPostActivate().addAll(getInterceptionMethodAsListOrEmpty(cdiInterceptorBean, InterceptionType.POST_ACTIVATE));
        data.getPrePassivate().addAll(getInterceptionMethodAsListOrEmpty(cdiInterceptorBean, InterceptionType.PRE_PASSIVATE));
        data.getAroundTimeout().addAll(getInterceptionMethodAsListOrEmpty(cdiInterceptorBean, InterceptionType.AROUND_TIMEOUT));
        /*
        AfterBegin, BeforeCompletion and AfterCompletion are ignored since not handled by CDI
         */
    } else { // TODO: here we are not as good as in previous since we loose inheritance for instance
        data = InterceptorData.scan(i.getBeanClass());
    }
    return data;
}
 
开发者ID:apache,项目名称:tomee,代码行数:21,代码来源:BeanContext.java


示例2: processInterceptorChain

import javax.enterprise.inject.spi.Interceptor; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private <T> Object processInterceptorChain(
        final List<Interceptor<?>> chain,
        final Object target,
        final Method method,
        final Object[] args,
        final ContextFactory contextFactory,
        final InterceptorChain.ChainEnd<T> next,
        final InterceptionType interceptionType
) throws Throwable {
    if (chain.isEmpty()) {
        return next.invoke();
    }
    final Interceptor<Object> it = (Interceptor<Object>) chain.remove(0);
    final Releaser releaser = new Releaser();
    try {
        return intercept(
                it,
                it.create(contextFactory.create(it, releaser)),
                target,
                method,
                args,
                () -> processInterceptorChain(chain, target, method, args, contextFactory, next, interceptionType),
                interceptionType
        );
    } finally {
        releaser.release();
    }
}
 
开发者ID:dajudge,项目名称:testee.fi,代码行数:30,代码来源:EjbDescriptorImpl.java


示例3: intercept

import javax.enterprise.inject.spi.Interceptor; //导入依赖的package包/类
private <T> Object intercept(
        final Interceptor<T> it,
        final T instance,
        final Object target,
        final Method method,
        final Object[] args,
        final Proceed proceed,
        final InterceptionType interceptionType
) throws Exception {
    return it.intercept(
            interceptionType,
            instance,
            context(target, interceptionType == InterceptionType.AROUND_INVOKE ? method : null, args, proceed)
    );
}
 
开发者ID:dajudge,项目名称:testee.fi,代码行数:16,代码来源:EjbDescriptorImpl.java


示例4: resolveInterceptors

import javax.enterprise.inject.spi.Interceptor; //导入依赖的package包/类
@Override
public List<Interceptor<?>> resolveInterceptors(final InterceptionType type, final Annotation... interceptorBindings) {
    final List<Interceptor<?>> interceptors = super.resolveInterceptors(type, interceptorBindings);
    final List<Interceptor<?>> parentInterceptors = getParentBm().resolveInterceptors(type, interceptorBindings);
    for (final Interceptor<?> i : parentInterceptors) {
        if (!interceptors.contains(i)) {
            interceptors.add(i);
        }
    }
    return interceptors;
}
 
开发者ID:apache,项目名称:tomee,代码行数:12,代码来源:WebappBeanManager.java


示例5: invoke

import javax.enterprise.inject.spi.Interceptor; //导入依赖的package包/类
@Override
public Object invoke(Object proxy, Method method, Object[] parameters) throws Throwable
{
    // check if interceptors are defined, otherwise just call the original logik
    List<Interceptor<?>> interceptors = interceptorLookup.lookup(proxy, method);
    if (interceptors != null && !interceptors.isEmpty())
    {
        try
        {
            DeltaSpikeProxyInvocationContext invocationContext = new DeltaSpikeProxyInvocationContext(
                    this, beanManager, interceptors, proxy, method, parameters, null);

            Object returnValue = invocationContext.proceed();

            if (invocationContext.isProceedOriginal())
            {
                return invocationContext.getProceedOriginalReturnValue();
            }

            return returnValue;
        }
        catch (DeltaSpikeProxyInvocationWrapperException e)
        {
            throw e.getCause();
        }
    }

    return proceed(proxy, method, parameters);
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:30,代码来源:DeltaSpikeProxyInvocationHandler.java


示例6: DeltaSpikeProxyInvocationContext

import javax.enterprise.inject.spi.Interceptor; //导入依赖的package包/类
public DeltaSpikeProxyInvocationContext(DeltaSpikeProxyInvocationHandler invocationHandler,
        BeanManager beanManager, List<Interceptor<H>> interceptors, 
        T target, Method method, Object[] parameters, Object timer)
{
    super(target, method, parameters, timer);

    this.invocationHandler = invocationHandler;
    this.interceptors = interceptors;
    this.beanManager = beanManager;

    this.interceptorIndex = 0;
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:13,代码来源:DeltaSpikeProxyInvocationContext.java


示例7: lookup

import javax.enterprise.inject.spi.Interceptor; //导入依赖的package包/类
public List<Interceptor<?>> lookup(Object instance, Method method)
{
    List<Interceptor<?>> interceptors = cache.get(method);
    
    if (interceptors == null)
    {
        interceptors = resolveInterceptors(instance, method);
        cache.put(method, interceptors);
    }
    
    return interceptors;
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:13,代码来源:DeltaSpikeProxyInterceptorLookup.java


示例8: resolveInterceptors

import javax.enterprise.inject.spi.Interceptor; //导入依赖的package包/类
private List<Interceptor<?>> resolveInterceptors(Object instance, Method method)
{
    BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager();
    
    Annotation[] interceptorBindings = extractInterceptorBindings(beanManager, instance, method);
    if (interceptorBindings.length > 0)
    {
        return beanManager.resolveInterceptors(InterceptionType.AROUND_INVOKE, interceptorBindings);
    }

    return new ArrayList<Interceptor<?>>();
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:13,代码来源:DeltaSpikeProxyInterceptorLookup.java


示例9: findHandlers

import javax.enterprise.inject.spi.Interceptor; //导入依赖的package包/类
/**
 * Listener to ProcessBean event to locate handlers.
 *
 * @param processBean current {@link AnnotatedType}
 * @param beanManager  Activated Bean Manager
 * @throws TypeNotPresentException if any of the actual type arguments refers to a non-existent type declaration
 *                                 when trying to obtain the actual type arguments from a
 *                                 {@link java.lang.reflect.ParameterizedType}
 * @throws java.lang.reflect.MalformedParameterizedTypeException
 *                                 if any of the actual type parameters refer to a parameterized type that cannot
 *                                 be instantiated for any reason when trying to obtain the actual type arguments
 *                                 from a {@link java.lang.reflect.ParameterizedType}
 */
@SuppressWarnings("UnusedDeclaration")
public <T> void findHandlers(@Observes final ProcessBean<?> processBean, final BeanManager beanManager)
{
    if (!isActivated)
    {
        return;
    }

    if (processBean.getBean() instanceof Interceptor || processBean.getBean() instanceof Decorator ||
            !(processBean.getAnnotated() instanceof AnnotatedType))
    {
        return;
    }

    AnnotatedType annotatedType = (AnnotatedType)processBean.getAnnotated();

    if (annotatedType.getJavaClass().isAnnotationPresent(ExceptionHandler.class))
    {
        final Set<AnnotatedMethod<? super T>> methods = annotatedType.getMethods();

        for (AnnotatedMethod<? super T> method : methods)
        {
            if (HandlerMethodImpl.isHandler(method))
            {
                if (method.getJavaMember().getExceptionTypes().length != 0)
                {
                    processBean.addDefinitionError(new IllegalArgumentException(
                        String.format("Handler method %s must not throw exceptions", method.getJavaMember())));
                }

                //beanManager won't be stored in the instance -> no issue with wls12c
                registerHandlerMethod(new HandlerMethodImpl(processBean.getBean(), method, beanManager));
            }
        }
    }
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:50,代码来源:ExceptionControlExtension.java


示例10: testDisabledInterceptor

import javax.enterprise.inject.spi.Interceptor; //导入依赖的package包/类
@Test
public void testDisabledInterceptor() {
    List<Interceptor<?>> interceptors = weld.getBeanManager().resolveInterceptors(InterceptionType.AROUND_INVOKE, FooBinding.Literal.INSTANCE);
    assertEquals(1, interceptors.size());
    assertEquals(MockInterceptor.class, interceptors.get(0).getBeanClass());
}
 
开发者ID:weld,项目名称:weld-junit,代码行数:7,代码来源:MockInterceptorTest.java


示例11: resolveInterceptors

import javax.enterprise.inject.spi.Interceptor; //导入依赖的package包/类
@Override
public List<Interceptor<?>> resolveInterceptors(InterceptionType type, Annotation... interceptorBindings)
{
    // TODO Auto-generated method stub
    return null;
}
 
开发者ID:satago,项目名称:tapestry-jpa-transactions,代码行数:7,代码来源:NoopBeanManager.java


示例12: resolveInterceptors

import javax.enterprise.inject.spi.Interceptor; //导入依赖的package包/类
@Override
public List<Interceptor<?>> resolveInterceptors(
        final InterceptionType arg0, final Annotation... arg1) {
    return this.beanManager.resolveInterceptors(arg0, arg1);
}
 
开发者ID:qjafcunuas,项目名称:jbromo,代码行数:6,代码来源:BeanManagerExt.java


示例13: isEjbInterceptor

import javax.enterprise.inject.spi.Interceptor; //导入依赖的package包/类
private boolean isEjbInterceptor(final Interceptor<?> pc) {
    final Set<Annotation> interceptorBindings = pc.getInterceptorBindings();
    return interceptorBindings == null || interceptorBindings.isEmpty();
}
 
开发者ID:apache,项目名称:tomee,代码行数:5,代码来源:BeanContext.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EntityDescription类代码示例发布时间:2022-05-23
下一篇:
Java SerializableEntity类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap