Package org.apache.openejb.cdi

Examples of org.apache.openejb.cdi.CurrentCreationalContext


        final Method runMethod = beanContext.getMatchingBeanMethod(callMethod);
        final ThreadContext callContext = new ThreadContext(beanContext, primKey);
        final ThreadContext oldCallContext = ThreadContext.enter(callContext);

        Instance bean = null;
        final CurrentCreationalContext currentCreationalContext = beanContext.get(CurrentCreationalContext.class);

        try {

            //Check auth before overriding context
            final boolean authorized = type == InterfaceType.TIMEOUT || this.securityService.isCallerAuthorized(callMethod, type);

            if (!authorized) {
                throw new org.apache.openejb.ApplicationException(new javax.ejb.EJBAccessException("Unauthorized Access by Principal Denied"));
            }

            final Class declaringClass = callMethod.getDeclaringClass();
            if (javax.ejb.EJBHome.class.isAssignableFrom(declaringClass) || javax.ejb.EJBLocalHome.class.isAssignableFrom(declaringClass)) {
                if (callMethod.getName().startsWith("create")) {
                    return new ProxyInfo(beanContext, null);
                } else {
                    return null; // EJBHome.remove( ) and other EJBHome methods are not process by the container
                }

            } else if (javax.ejb.EJBObject.class == declaringClass || javax.ejb.EJBLocalObject.class == declaringClass) {
                return null; // EJBObject.remove( ) and other EJBObject methods are not process by the container
            }

            bean = this.instanceManager.getInstance(callContext);

            callContext.setCurrentOperation(type == InterfaceType.TIMEOUT ? Operation.TIMEOUT : Operation.BUSINESS);
            callContext.set(Method.class, runMethod);
            callContext.setInvokedInterface(callInterface);
            if (currentCreationalContext != null) {
                currentCreationalContext.set(bean.creationalContext);
            }
            return _invoke(callMethod, runMethod, args, bean, callContext, type);
        } finally {
            if (bean != null) {
                if (callContext.isDiscardInstance()) {
                    this.instanceManager.discardInstance(callContext, bean);
                } else {
                    this.instanceManager.poolInstance(callContext, bean);
                }
            }

            ThreadContext.exit(oldCallContext);

            if (currentCreationalContext != null) {
                currentCreationalContext.remove();
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.openejb.cdi.CurrentCreationalContext

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.