本文整理匯總了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);
}
}