public Object invoke( Object deployID, InterfaceType type, Class callInterface, Method callMethod, Object[] args, Object primKey) throws OpenEJBException { BeanContext beanContext = this.getBeanContext(deployID); if (beanContext == null) throw new OpenEJBException( "Deployment does not exist in this container. Deployment(id='" + deployID + "'), Container(id='" + containerID + "')"); // Use the backup way to determine call type if null was supplied. if (type == null) type = beanContext.getInterfaceType(callInterface); Data data = (Data) beanContext.getContainerData(); MethodType methodType = data.getMethodIndex().get(callMethod); methodType = (methodType != null) ? methodType : MethodType.BUSINESS; switch (methodType) { case CREATE: return createEJBObject(beanContext, callMethod, args, type); case REMOVE: return removeEJBObject(beanContext, primKey, callInterface, callMethod, args, type); default: return businessMethod(beanContext, primKey, callInterface, callMethod, args, type); } }
public Object invoke( Object deployID, InterfaceType type, Class callInterface, Method callMethod, Object[] args, Object primKey) throws OpenEJBException { BeanContext beanContext = this.getBeanContext(deployID); if (beanContext == null) throw new OpenEJBException( "Deployment does not exist in this container. Deployment(id='" + deployID + "'), Container(id='" + containerID + "')"); // Use the backup way to determine call type if null was supplied. if (type == null) type = beanContext.getInterfaceType(callInterface); Method runMethod = beanContext.getMatchingBeanMethod(callMethod); ThreadContext callContext = new ThreadContext(beanContext, primKey); ThreadContext oldCallContext = ThreadContext.enter(callContext); Object bean = null; try { boolean authorized = type == InterfaceType.TIMEOUT || getSecurityService().isCallerAuthorized(callMethod, type); if (!authorized) throw new org.apache.openejb.ApplicationException( new EJBAccessException("Unauthorized Access by Principal Denied")); Class declaringClass = callMethod.getDeclaringClass(); if (EJBHome.class.isAssignableFrom(declaringClass) || EJBLocalHome.class.isAssignableFrom(declaringClass)) { if (callMethod.getName().startsWith("create")) { return createEJBObject(beanContext, callMethod); } else return null; // EJBHome.remove( ) and other EJBHome methods are not process by the // container } else if (EJBObject.class == declaringClass || EJBLocalObject.class == declaringClass) { return null; // EJBObject.remove( ) and other EJBObject methods are not process by the // container } bean = instanceManager.getInstance(callContext); callContext.setCurrentOperation( type == InterfaceType.TIMEOUT ? Operation.TIMEOUT : Operation.BUSINESS); callContext.set(Method.class, runMethod); callContext.setInvokedInterface(callInterface); Object retValue = _invoke(callMethod, runMethod, args, (Instance) bean, callContext, type); return retValue; } finally { if (bean != null) { if (callContext.isDiscardInstance()) { instanceManager.discardInstance(callContext, bean); } else { instanceManager.poolInstance(callContext, bean); } } ThreadContext.exit(oldCallContext); } }
@Override public Object invoke( final Object deployID, InterfaceType type, final Class callInterface, final Method callMethod, final Object[] args, final Object primKey) throws OpenEJBException { final BeanContext beanContext = this.getBeanContext(deployID); if (beanContext == null) { throw new OpenEJBException( "Deployment does not exist in this container. Deployment(id='" + deployID + "'), Container(id='" + containerID + "')"); } // Use the backup way to determine call type if null was supplied. if (type == null) { type = beanContext.getInterfaceType(callInterface); } final ThreadContext callContext = new ThreadContext(beanContext, primKey); final ThreadContext oldCallContext = ThreadContext.enter(callContext); try { final boolean authorized = securityService.isCallerAuthorized(callMethod, type); if (!authorized) { throw new ApplicationException( new EJBAccessException("Unauthorized Access by Principal Denied")); } final Class declaringClass = callMethod.getDeclaringClass(); final String methodName = callMethod.getName(); if (EJBHome.class.isAssignableFrom(declaringClass) || EJBLocalHome.class.isAssignableFrom(declaringClass)) { if (declaringClass != EJBHome.class && declaringClass != EJBLocalHome.class) { if (methodName.startsWith("create")) { return createEJBObject(callMethod, args, callContext, type); } else if (methodName.equals("findByPrimaryKey")) { return findByPrimaryKey(callMethod, args, callContext, type); } else if (methodName.startsWith("find")) { return findEJBObject(callMethod, args, callContext, type); } else { return homeMethod(callMethod, args, callContext, type); } } else if (methodName.equals("remove")) { removeEJBObject(callMethod, callContext, type); return null; } } else if ((EJBObject.class == declaringClass || EJBLocalObject.class == declaringClass) && methodName.equals("remove")) { removeEJBObject(callMethod, callContext, type); return null; } // business method callContext.setCurrentOperation(Operation.BUSINESS); final Method runMethod = beanContext.getMatchingBeanMethod(callMethod); callContext.set(Method.class, runMethod); return businessMethod(callMethod, runMethod, args, callContext, type); } finally { ThreadContext.exit(oldCallContext); } }