Refine search
protected void checkInjectionPoint(InjectionPoint ip) { if (!(ip.getBean() instanceof Interceptor<?>)) { throw InterceptorLogger.LOG.interceptedBeanCanOnlyBeInjectedIntoInterceptor(ip); } }
private void validateInterceptor(Interceptor<?> interceptor) { Set<Annotation> bindings = interceptor.getInterceptorBindings(); if (bindings == null) { throw InterceptorLogger.LOG.nullInterceptorBindings(interceptor); } for (Annotation annotation : bindings) { if (!getBeanManager().isInterceptorBinding(annotation.annotationType())) { throw MetadataLogger.LOG.notAnInterceptorBinding(annotation, interceptor); } } }
@Override public AnnotatedTypeConfigurator<T> configure() { InterceptorLogger.LOG.interceptionFactoryConfigureInvoked(annotatedType.getJavaClass().getSimpleName()); if (configurator == null) { configurator = new AnnotatedTypeConfiguratorImpl<>(annotatedType); } return configurator; }
throw InterceptorLogger.LOG.interceptionFactoryNotReusable(); InterceptorLogger.LOG.interceptionFactoryInternalContainerConstruct(instance.getClass()); return instance; UnproxyableResolutionException exception = Proxies.getUnproxyableTypeException(annotatedType.getBaseType(), null, beanManager.getServices(), ignoreFinalMethods); if (exception != null) { AnnotatedType<?> instanceAnnotatedType = beanManager.createAnnotatedType(instance.getClass()); AnnotatedTypeConfiguratorImpl<?> newAtConfigurator = new AnnotatedTypeConfiguratorImpl<>(instanceAnnotatedType); if (beanManager.isInterceptorBinding(annotation.annotationType())) { if (newAtConfigurator.getAnnotated().isAnnotationPresent(annotation.annotationType())) { throw InterceptorLogger.LOG.interceptionFactoryAnnotationClash(originalAT, newAtConfigurator.getAnnotated(), annotation); if (result.getAnnotated().isAnnotationPresent(annotation.annotationType())) { throw InterceptorLogger.LOG.interceptionFactoryAnnotationClash(originalAT, newAtConfigurator.getAnnotated(), annotation); InterceptorLogger.LOG.interceptionFactoryNotRequired(resultingAnnotatedType.getJavaClass().getSimpleName()); return instance;
@Override protected Bean<?> newInstance(InjectionPoint ip, CreationalContext<Bean<?>> ctx) { checkInjectionPoint(ip); WeldCreationalContext<?> interceptorContext = getParentCreationalContext(ctx); WeldCreationalContext<?> interceptedBeanContext = getParentCreationalContext(interceptorContext); Contextual<?> interceptedContextual = interceptedBeanContext.getContextual(); if (interceptedContextual instanceof Bean<?>) { Bean<?> bean = (Bean<?>) interceptedContextual; if (bean instanceof Serializable) { return bean; } else { return SerializableForwardingBean.of(getBeanManager().getContextId(), bean); } } else { InterceptorLogger.LOG.unableToDetermineInterceptedBean(ip); return null; } }
@Override public T createInterceptedInstance(T instance) { if (used) { throw InterceptorLogger.LOG.interceptionFactoryNotReusable(); } if (instance instanceof ProxyObject) { InterceptorLogger.LOG.interceptionFactoryInternalContainerConstruct(instance.getClass()); return instance; } UnproxyableResolutionException exception = Proxies.getUnproxyableTypeException(annotatedType.getBaseType(), null, beanManager.getServices(), ignoreFinalMethods); if (exception != null) { throw exception; } used = true; Optional<InterceptionFactoryData<T>> cached = beanManager.getServices().get(InterceptionFactoryDataCache.class) .getInterceptionFactoryData(configurator != null ? configurator.complete() : annotatedType); if (!cached.isPresent()) { InterceptorLogger.LOG.interceptionFactoryNotRequired(annotatedType.getJavaClass().getSimpleName()); return instance; } InterceptionFactoryData<T> data = cached.get(); InterceptedProxyMethodHandler methodHandler = new InterceptedProxyMethodHandler(instance); methodHandler.setInterceptorMethodHandler(new InterceptorMethodHandler( InterceptionContext.forNonConstructorInterception(data.getInterceptionModel(), creationalContext, beanManager, data.getSlimAnnotatedType()))); T proxy = (System.getSecurityManager() == null) ? data.getInterceptedProxyFactory().run() : AccessController.doPrivileged(data.getInterceptedProxyFactory()); ((ProxyObject) proxy).weld_setHandler(methodHandler); return proxy; }
protected Object invokeNext() throws Exception { int oldCurrentPosition = position; try { InterceptorMethodInvocation nextInterceptorMethodInvocation = chain.get(position++); InterceptorLogger.LOG.invokingNextInterceptorInChain(nextInterceptorMethodInvocation); if (nextInterceptorMethodInvocation.expectsInvocationContext()) { return nextInterceptorMethodInvocation.invoke(WeldInvocationContextImpl.this); } else { nextInterceptorMethodInvocation.invoke(null); while (hasNextInterceptor()) { nextInterceptorMethodInvocation = chain.get(position++); nextInterceptorMethodInvocation.invoke(null); } return null; } } finally { position = oldCurrentPosition; } }
if (instance == null) { throw InterceptorLogger.LOG.targetInstanceNotCreated(constructor);
@Override public InterceptionFactory<T> ignoreFinalMethods() { InterceptorLogger.LOG.interceptionFactoryIgnoreFinalMethodsInvoked(annotatedType.getJavaClass().getSimpleName()); // Note that final methods are always ignored during proxy generation ignoreFinalMethods = true; return this; }
throw InterceptorLogger.LOG.interceptionFactoryNotReusable(); InterceptorLogger.LOG.interceptionFactoryInternalContainerConstruct(instance.getClass()); return instance; UnproxyableResolutionException exception = Proxies.getUnproxyableTypeException(annotatedType.getBaseType(), null, beanManager.getServices(), ignoreFinalMethods); if (exception != null) { AnnotatedType<?> instanceAnnotatedType = beanManager.createAnnotatedType(instance.getClass()); AnnotatedTypeConfiguratorImpl<?> newAtConfigurator = new AnnotatedTypeConfiguratorImpl<>(instanceAnnotatedType); if (beanManager.isInterceptorBinding(annotation.annotationType())) { if (newAtConfigurator.getAnnotated().isAnnotationPresent(annotation.annotationType())) { throw InterceptorLogger.LOG.interceptionFactoryAnnotationClash(originalAT, newAtConfigurator.getAnnotated(), annotation); if (result.getAnnotated().isAnnotationPresent(annotation.annotationType())) { throw InterceptorLogger.LOG.interceptionFactoryAnnotationClash(originalAT, newAtConfigurator.getAnnotated(), annotation); InterceptorLogger.LOG.interceptionFactoryNotRequired(resultingAnnotatedType.getJavaClass().getSimpleName()); return instance;
@Override protected Bean<?> newInstance(InjectionPoint ip, CreationalContext<Bean<?>> ctx) { checkInjectionPoint(ip); WeldCreationalContext<?> interceptorContext = getParentCreationalContext(ctx); WeldCreationalContext<?> interceptedBeanContext = getParentCreationalContext(interceptorContext); Contextual<?> interceptedContextual = interceptedBeanContext.getContextual(); if (interceptedContextual instanceof Bean<?>) { Bean<?> bean = (Bean<?>) interceptedContextual; if (bean instanceof Serializable) { return bean; } else { return SerializableForwardingBean.of(getBeanManager().getContextId(), bean); } } else { InterceptorLogger.LOG.unableToDetermineInterceptedBean(ip); return null; } }
@Override public T createInterceptedInstance(T instance) { if (used) { throw InterceptorLogger.LOG.interceptionFactoryNotReusable(); } if (instance instanceof ProxyObject) { InterceptorLogger.LOG.interceptionFactoryInternalContainerConstruct(instance.getClass()); return instance; } UnproxyableResolutionException exception = Proxies.getUnproxyableTypeException(annotatedType.getBaseType(), null, beanManager.getServices(), ignoreFinalMethods); if (exception != null) { throw exception; } used = true; Optional<InterceptionFactoryData<T>> cached = beanManager.getServices().get(InterceptionFactoryDataCache.class) .getInterceptionFactoryData(configurator != null ? configurator.complete() : annotatedType); if (!cached.isPresent()) { InterceptorLogger.LOG.interceptionFactoryNotRequired(annotatedType.getJavaClass().getSimpleName()); return instance; } InterceptionFactoryData<T> data = cached.get(); InterceptedProxyMethodHandler methodHandler = new InterceptedProxyMethodHandler(instance); methodHandler.setInterceptorMethodHandler(new InterceptorMethodHandler( InterceptionContext.forNonConstructorInterception(data.getInterceptionModel(), creationalContext, beanManager, data.getSlimAnnotatedType()))); T proxy = (System.getSecurityManager() == null) ? data.getInterceptedProxyFactory().run() : AccessController.doPrivileged(data.getInterceptedProxyFactory()); ((ProxyObject) proxy).weld_setHandler(methodHandler); return proxy; }
protected Object invokeNext() throws Exception { int oldCurrentPosition = position; try { InterceptorMethodInvocation nextInterceptorMethodInvocation = chain.get(position++); InterceptorLogger.LOG.invokingNextInterceptorInChain(nextInterceptorMethodInvocation); if (nextInterceptorMethodInvocation.expectsInvocationContext()) { return nextInterceptorMethodInvocation.invoke(WeldInvocationContextImpl.this); } else { nextInterceptorMethodInvocation.invoke(null); while (hasNextInterceptor()) { nextInterceptorMethodInvocation = chain.get(position++); nextInterceptorMethodInvocation.invoke(null); } return null; } } finally { position = oldCurrentPosition; } }
if (instance == null) { throw InterceptorLogger.LOG.targetInstanceNotCreated(constructor);
@Override public InterceptionFactory<T> ignoreFinalMethods() { InterceptorLogger.LOG.interceptionFactoryIgnoreFinalMethodsInvoked(annotatedType.getJavaClass().getSimpleName()); // Note that final methods are always ignored during proxy generation ignoreFinalMethods = true; return this; }
throw InterceptorLogger.LOG.interceptionFactoryNotReusable(); InterceptorLogger.LOG.interceptionFactoryInternalContainerConstruct(instance.getClass()); return instance; UnproxyableResolutionException exception = Proxies.getUnproxyableTypeException(annotatedType.getBaseType(), null, beanManager.getServices(), ignoreFinalMethods); if (exception != null) { AnnotatedType<?> instanceAnnotatedType = beanManager.createAnnotatedType(instance.getClass()); AnnotatedTypeConfiguratorImpl<?> newAtConfigurator = new AnnotatedTypeConfiguratorImpl<>(instanceAnnotatedType); if (beanManager.isInterceptorBinding(annotation.annotationType())) { if (newAtConfigurator.getAnnotated().isAnnotationPresent(annotation.annotationType())) { throw InterceptorLogger.LOG.interceptionFactoryAnnotationClash(originalAT, newAtConfigurator.getAnnotated(), annotation); if (result.getAnnotated().isAnnotationPresent(annotation.annotationType())) { throw InterceptorLogger.LOG.interceptionFactoryAnnotationClash(originalAT, newAtConfigurator.getAnnotated(), annotation); InterceptorLogger.LOG.interceptionFactoryNotRequired(resultingAnnotatedType.getJavaClass().getSimpleName()); return instance;
@Override protected Bean<?> newInstance(InjectionPoint ip, CreationalContext<Bean<?>> ctx) { checkInjectionPoint(ip); WeldCreationalContext<?> interceptorContext = getParentCreationalContext(ctx); WeldCreationalContext<?> interceptedBeanContext = getParentCreationalContext(interceptorContext); Contextual<?> interceptedContextual = interceptedBeanContext.getContextual(); if (interceptedContextual instanceof Bean<?>) { Bean<?> bean = (Bean<?>) interceptedContextual; if (bean instanceof Serializable) { return bean; } else { return SerializableForwardingBean.of(getBeanManager().getContextId(), bean); } } else { InterceptorLogger.LOG.unableToDetermineInterceptedBean(ip); return null; } }
private void validateInterceptor(Interceptor<?> interceptor) { Set<Annotation> bindings = interceptor.getInterceptorBindings(); if (bindings == null) { throw InterceptorLogger.LOG.nullInterceptorBindings(interceptor); } for (Annotation annotation : bindings) { if (!getBeanManager().isInterceptorBinding(annotation.annotationType())) { throw MetadataLogger.LOG.notAnInterceptorBinding(annotation, interceptor); } } }
protected void checkInjectionPoint(InjectionPoint ip) { if (!(ip.getBean() instanceof Interceptor<?>)) { throw InterceptorLogger.LOG.interceptedBeanCanOnlyBeInjectedIntoInterceptor(ip); } }
protected Object invokeNext() throws Exception { int oldCurrentPosition = position; try { InterceptorMethodInvocation nextInterceptorMethodInvocation = chain.get(position++); InterceptorLogger.LOG.invokingNextInterceptorInChain(nextInterceptorMethodInvocation); if (nextInterceptorMethodInvocation.expectsInvocationContext()) { return nextInterceptorMethodInvocation.invoke(WeldInvocationContextImpl.this); } else { nextInterceptorMethodInvocation.invoke(null); while (hasNextInterceptor()) { nextInterceptorMethodInvocation = chain.get(position++); nextInterceptorMethodInvocation.invoke(null); } return null; } } finally { position = oldCurrentPosition; } }