Package org.jboss.invocation

Examples of org.jboss.invocation.Interceptor


    /** {@inheritDoc} */
    @Override
    public Interceptor createClientInterceptor(final Class<?> viewClass) {
        // One instance per client lookup.
        final ComponentInstance instance = createInstance();
        return new Interceptor() {
            public Object processInvocation(final InterceptorContext context) throws Exception {
                context.putPrivateData(ComponentInstance.class, instance);
                return context.proceed();
            }

View Full Code Here


    }

    protected BasicComponentInstance instantiateComponentInstance(final AtomicReference<ManagedReference> instanceReference, final Interceptor preDestroyInterceptor, final Map<Method, Interceptor> methodInterceptors, final InterceptorFactoryContext interceptorContext) {
        final SimpleInterceptorFactoryContext factoryContext = new SimpleInterceptorFactoryContext();
        factoryContext.getContextData().put(Component.class, this);
        final Interceptor interceptor = relationInterceptorFactory.create(factoryContext);
        return new CmpEntityBeanComponentInstance(this, instanceReference, preDestroyInterceptor, methodInterceptors, interceptor);
    }
View Full Code Here

    }


    @Override
    public Interceptor create(final InterceptorFactoryContext context) {
        final Interceptor aroundInvoke = this.aroundInvoke.create(context);
        final Interceptor aroundTimeout = this.aroundTimeout.create(context);
        return new Interceptor() {
            @Override
            public Object processInvocation(final InterceptorContext context) throws Exception {
                final InvocationType marker = context.getPrivateData(InvocationType.class);
                if (marker == InvocationType.TIMER) {
                    return aroundTimeout.processInvocation(context);
                } else {
                    return aroundInvoke.processInvocation(context);
                }
            }
        };
View Full Code Here

        return null;
    }

    @Override
    public void invokeTimeoutMethod(final Method method, final Timer timer) {
        final Interceptor interceptor = timeoutInterceptors.get(method);
        if(interceptor == null) {
            throw new RuntimeException("Unknown timeout method " + method);
        }
        try {
            InterceptorContext context = prepareInterceptorContext();
            context.setMethod(method);
            context.setTimer(timer);
            context.setTarget(getInstance());
            final Object[] params;
            if(method.getParameterTypes().length == 1) {
                params = new Object[1];
                params[0] = timer;
            } else {
                params = EMPTY_OBJECT_ARRAY;
            }
            context.setParameters(params);
            interceptor.processInvocation(context);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

*/
public class SFSBCreateInterceptorFactory implements InterceptorFactory {

    @Override
    public Interceptor create(final InterceptorFactoryContext context) {
        return new Interceptor() {
            @Override
            public Object processInvocation(InterceptorContext interceptorContext) throws Exception {
                Object target = context.getContextData().get(AbstractComponent.COMPONENT_INSTANCE_KEY);
                StatefulSessionComponentInstance sfsb = (StatefulSessionComponentInstance)target;
                SFSBContextHandleImpl sfsbContextHandle = new SFSBContextHandleImpl(sfsb);
View Full Code Here

* @author Scott Marlow
*/
public class SFSBDestroyInterceptorFactory implements InterceptorFactory {

    public Interceptor create(final InterceptorFactoryContext context) {
        return new Interceptor() {
            @Override
            public Object processInvocation(InterceptorContext interceptorContext) throws Exception {
                StatefulSessionComponentInstance sfsb = (StatefulSessionComponentInstance) context.getContextData().get(AbstractComponent.COMPONENT_INSTANCE_KEY);
                SFSBContextHandleImpl sfsbContextHandle = new SFSBContextHandleImpl(sfsb);
                List<EntityManager> readyToClose = SFSBXPCMap.getINSTANCE().remove(sfsbContextHandle);
View Full Code Here

        return null;
    }

    @Override
    public void invokeTimeoutMethod(final Method method, final Timer timer) {
        final Interceptor interceptor = timeoutInterceptors.get(method);
        if (interceptor == null) {
            throw new RuntimeException("Unknown timeout method " + method);
        }
        try {
            InterceptorContext context = prepareInterceptorContext();
            context.setMethod(method);
            context.setTimer(timer);
            context.setTarget(getInstance());
            final Object[] params;
            if (method.getParameterTypes().length == 1) {
                params = new Object[1];
                params[0] = timer;
            } else {
                params = EMPTY_OBJECT_ARRAY;
            }
            context.setParameters(params);
            interceptor.processInvocation(context);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public Interceptor getInterceptor(final Method method) throws IllegalStateException {
        Interceptor interceptor = methodMap.get(method);
        if (interceptor == null) {
            throw MESSAGES.methodNotFound(method);
        }
        return interceptor;
    }
View Full Code Here

        // Interceptor factory context
        final SimpleInterceptorFactoryContext context = new SimpleInterceptorFactoryContext();
        context.getContextData().put(Component.class, this);

        // Create the post-construct interceptors for the ComponentInstance
        final Interceptor componentInstancePostConstructInterceptor = this.getPostConstruct().create(context);
        // create the pre-destroy interceptors
        final Interceptor componentInstancePreDestroyInterceptor = this.getPreDestroy().create(context);

        final AtomicReference<ManagedReference> instanceReference = (AtomicReference<ManagedReference>) context.getContextData().get(BasicComponentInstance.INSTANCE_KEY);

        instanceReference.set(instance);
View Full Code Here


        @Override
        public Object invoke(InterceptorContext interceptorContext) throws Exception {
            final Method method = interceptorContext.getMethod();
            final Interceptor interceptor = viewInterceptors.get(method);
            return interceptor.processInvocation(interceptorContext);
        }
View Full Code Here

TOP

Related Classes of org.jboss.invocation.Interceptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.