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


Java InterceptionType类代码示例

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


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

示例1: invoke

import javax.enterprise.inject.spi.InterceptionType; //导入依赖的package包/类
private void invoke(
        final T t,
        final Class<?> c,
        final Class<? extends Annotation> annotation,
        final InterceptionType interceptionType
) {
    final Set<Method> candidates = stream(c.getDeclaredMethods())
            .filter(it -> it.getAnnotation(annotation) != null)
            .collect(toSet());
    if (candidates.isEmpty()) {
        return;
    }
    if (candidates.size() > 1) {
        throw new TestEEfiException("Only one @" + annotation.getSimpleName() + " method is allowed per class");
    }
    // TODO check for correct modifiers etc.
    final Method method = candidates.iterator().next();
    method.setAccessible(true);
    try {
        invokeIntercepted(new Object[]{}, t, method, interceptionType);
    } catch (final Throwable e) {
        throw new TestEEfiException("Failed to invoke @" + annotation.getSimpleName() + " method " + method, e);
    }
}
 
开发者ID:dajudge,项目名称:testee.fi,代码行数:25,代码来源:SingletonHolder.java

示例2: createInterceptorData

import javax.enterprise.inject.spi.InterceptionType; //导入依赖的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

示例3: getInterceptorChain

import javax.enterprise.inject.spi.InterceptionType; //导入依赖的package包/类
public InterceptorChain getInterceptorChain(
        final ContextFactory contextFactory
) {
    return new InterceptorChain() {
        @Override
        public <T> Object invoke(
                final Object target,
                final Method method,
                final Object[] args,
                final ChainEnd<T> next,
                final InterceptionType interceptionType
        ) throws Throwable {
            if (interceptorBindings == null) {
                return next.invoke();
            }
            return processInterceptorChain(
                    new ArrayList<>(interceptorBindings.getAllInterceptors()),
                    target,
                    method,
                    args,
                    contextFactory,
                    next,
                    interceptionType
            );
        }
    };
}
 
开发者ID:dajudge,项目名称:testee.fi,代码行数:28,代码来源:EjbDescriptorImpl.java

示例4: processInterceptorChain

import javax.enterprise.inject.spi.InterceptionType; //导入依赖的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

示例5: intercept

import javax.enterprise.inject.spi.InterceptionType; //导入依赖的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

示例6: invoke

import javax.enterprise.inject.spi.InterceptionType; //导入依赖的package包/类
<T> Object invoke(
        Object target,
        Method method,
        Object[] args,
        ChainEnd<T> next,
        InterceptionType interceptionType
) throws Throwable;
 
开发者ID:dajudge,项目名称:testee.fi,代码行数:8,代码来源:InterceptorChain.java

示例7: invokeIntercepted

import javax.enterprise.inject.spi.InterceptionType; //导入依赖的package包/类
private Object invokeIntercepted(
        final Object[] args,
        final T target,
        final Method method,
        final InterceptionType interceptionType
) throws Throwable {
    return chain.invoke(target, method, args,
            () -> {
                try {
                    return method.invoke(target, args);
                } catch (final InvocationTargetException e) {
                    throw e.getTargetException();
                }
            }, interceptionType);
}
 
开发者ID:dajudge,项目名称:testee.fi,代码行数:16,代码来源:SingletonHolder.java

示例8: resolveInterceptors

import javax.enterprise.inject.spi.InterceptionType; //导入依赖的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

示例9: resolveInterceptors

import javax.enterprise.inject.spi.InterceptionType; //导入依赖的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

示例10: testDisabledInterceptor

import javax.enterprise.inject.spi.InterceptionType; //导入依赖的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: intercepts

import javax.enterprise.inject.spi.InterceptionType; //导入依赖的package包/类
@Override
public boolean intercepts(InterceptionType type) {
    return this.type.equals(type);
}
 
开发者ID:weld,项目名称:weld-junit,代码行数:5,代码来源:MockInterceptor.java

示例12: intercept

import javax.enterprise.inject.spi.InterceptionType; //导入依赖的package包/类
@Override
public Object intercept(InterceptionType type, MockInterceptorInstance instance, InvocationContext ctx) throws Exception {
    return callback.invoke(ctx, instance.getInterceptedBean());
}
 
开发者ID:weld,项目名称:weld-junit,代码行数:5,代码来源:MockInterceptor.java

示例13: aroundInvoke

import javax.enterprise.inject.spi.InterceptionType; //导入依赖的package包/类
public MockInterceptor aroundInvoke(InterceptionCallback callback) {
    return type(InterceptionType.AROUND_INVOKE).callback(callback).build();
}
 
开发者ID:weld,项目名称:weld-junit,代码行数:4,代码来源:MockInterceptor.java

示例14: aroundConstruct

import javax.enterprise.inject.spi.InterceptionType; //导入依赖的package包/类
public MockInterceptor aroundConstruct(InterceptionCallback callback) {
    return type(InterceptionType.AROUND_CONSTRUCT).callback(callback).build();
}
 
开发者ID:weld,项目名称:weld-junit,代码行数:4,代码来源:MockInterceptor.java

示例15: postConstruct

import javax.enterprise.inject.spi.InterceptionType; //导入依赖的package包/类
public MockInterceptor postConstruct(InterceptionCallback callback) {
    return type(InterceptionType.POST_CONSTRUCT).callback(callback).build();
}
 
开发者ID:weld,项目名称:weld-junit,代码行数:4,代码来源:MockInterceptor.java


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