Search in sources :

Example 1 with CombinedInterceptorAndDecoratorStackMethodHandler

use of org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler in project core by weld.

the class ProxyClassConstructorInjectionPointWrapper method newInstance.

@Override
protected T newInstance(Object[] parameterValues) {
    // Once the instance is created, a method handler is required regardless of whether
    // an actual bean instance is known yet.
    final T instance = super.newInstance(parameterValues);
    if (decorator) {
        BeanInstance beanInstance = null;
        if (hasDelegateInjectionPoint()) {
            Object decoratorDelegate = parameterValues[delegateInjectionPointPosition];
            beanInstance = new TargetBeanInstance(decoratorDelegate);
        }
        ProxyFactory.setBeanInstance(contextId, instance, beanInstance, bean);
    } else {
        if (instance instanceof ProxyObject) {
            ((ProxyObject) instance).setHandler(new CombinedInterceptorAndDecoratorStackMethodHandler());
            // Set method handler for private methods if necessary
            InterceptedSubclassFactory.setPrivateMethodHandler(instance);
        }
    }
    return instance;
}
Also used : ProxyObject(org.jboss.weld.bean.proxy.ProxyObject) CombinedInterceptorAndDecoratorStackMethodHandler(org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler) TargetBeanInstance(org.jboss.weld.bean.proxy.TargetBeanInstance) BeanInstance(org.jboss.weld.bean.proxy.BeanInstance) ProxyObject(org.jboss.weld.bean.proxy.ProxyObject) TargetBeanInstance(org.jboss.weld.bean.proxy.TargetBeanInstance)

Example 2 with CombinedInterceptorAndDecoratorStackMethodHandler

use of org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler in project core by weld.

the class AbstractDecoratorApplyingInstantiator method registerOuterDecorator.

protected void registerOuterDecorator(ProxyObject instance, T outerDelegate) {
    CombinedInterceptorAndDecoratorStackMethodHandler wrapperMethodHandler = (CombinedInterceptorAndDecoratorStackMethodHandler) instance.getHandler();
    wrapperMethodHandler.setOuterDecorator(outerDelegate);
}
Also used : CombinedInterceptorAndDecoratorStackMethodHandler(org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler)

Example 3 with CombinedInterceptorAndDecoratorStackMethodHandler

use of org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler in project core by weld.

the class SessionBeanInjectionTarget method produce.

@Override
public T produce(CreationalContext<T> ctx) {
    T result = super.produce(ctx);
    if (result instanceof ProxyObject) {
        // if decorators are applied, use SessionBeanViewMethodHandler
        ProxyObject proxy = (ProxyObject) result;
        proxy.setHandler(new SessionBeanViewMethodHandler(bean.getTypes(), (CombinedInterceptorAndDecoratorStackMethodHandler) proxy.getHandler()));
    }
    return result;
}
Also used : ProxyObject(org.jboss.weld.bean.proxy.ProxyObject) CombinedInterceptorAndDecoratorStackMethodHandler(org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler)

Example 4 with CombinedInterceptorAndDecoratorStackMethodHandler

use of org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler in project core by weld.

the class InterceptorApplyingInstantiator method applyInterceptors.

protected T applyInterceptors(T instance, InterceptionContext interceptionContext) {
    try {
        InterceptorMethodHandler methodHandler = new InterceptorMethodHandler(interceptionContext);
        CombinedInterceptorAndDecoratorStackMethodHandler wrapperMethodHandler = (CombinedInterceptorAndDecoratorStackMethodHandler) ((ProxyObject) instance).getHandler();
        wrapperMethodHandler.setInterceptorMethodHandler(methodHandler);
    } catch (Exception e) {
        throw new DeploymentException(e);
    }
    return instance;
}
Also used : CombinedInterceptorAndDecoratorStackMethodHandler(org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler) InterceptorMethodHandler(org.jboss.weld.interceptor.proxy.InterceptorMethodHandler) DeploymentException(org.jboss.weld.exceptions.DeploymentException) DeploymentException(org.jboss.weld.exceptions.DeploymentException)

Aggregations

CombinedInterceptorAndDecoratorStackMethodHandler (org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler)4 ProxyObject (org.jboss.weld.bean.proxy.ProxyObject)2 BeanInstance (org.jboss.weld.bean.proxy.BeanInstance)1 TargetBeanInstance (org.jboss.weld.bean.proxy.TargetBeanInstance)1 DeploymentException (org.jboss.weld.exceptions.DeploymentException)1 InterceptorMethodHandler (org.jboss.weld.interceptor.proxy.InterceptorMethodHandler)1