Package org.jboss.as.ee.component.interceptors

Source Code of org.jboss.as.ee.component.interceptors.UserInterceptorFactory

package org.jboss.as.ee.component.interceptors;

/**
* Interceptor factory that handles user interceptors, and switches between timer normal invocations
*
* @author Stuart Douglas
*/

import org.jboss.invocation.Interceptor;
import org.jboss.invocation.InterceptorContext;
import org.jboss.invocation.InterceptorFactory;
import org.jboss.invocation.InterceptorFactoryContext;


public class UserInterceptorFactory implements InterceptorFactory {
    private final InterceptorFactory aroundInvoke;
    private final InterceptorFactory aroundTimeout;

    public UserInterceptorFactory(final InterceptorFactory aroundInvoke, final InterceptorFactory aroundTimeout) {
        this.aroundInvoke = aroundInvoke;
        this.aroundTimeout = aroundTimeout;
    }


    @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);
                }
            }
        };

    }
}
TOP

Related Classes of org.jboss.as.ee.component.interceptors.UserInterceptorFactory

TOP
Copyright © 2018 www.massapi.com. 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.