| Method from org.apache.openejb.core.stateless.StatelessContainer Detail: |
protected Object _invoke(Class callInterface,
Method callMethod,
Method runMethod,
Object[] args,
Object object,
ThreadContext callContext) throws OpenEJBException {
return _invoke(callInterface, callMethod, runMethod, args, (Instance) object, callContext);
} Deprecated! use - type-safe #_invoke(Class, java.lang.reflect.Method, java.lang.reflect.Method, Object[], Instance, org.apache.openejb.core.ThreadContext)
|
protected Object _invoke(Class callInterface,
Method callMethod,
Method runMethod,
Object[] args,
Instance instance,
ThreadContext callContext) throws OpenEJBException {
CoreDeploymentInfo deploymentInfo = callContext.getDeploymentInfo();
TransactionPolicy txPolicy = deploymentInfo.getTransactionPolicy(callMethod);
TransactionContext txContext = new TransactionContext(callContext, getTransactionManager());
txContext.callContext = callContext;
txPolicy.beforeInvoke(instance, txContext);
Object returnValue = null;
try {
InterfaceType type = deploymentInfo.getInterfaceType(callInterface);
if (type == InterfaceType.SERVICE_ENDPOINT){
callContext.setCurrentOperation(Operation.BUSINESS_WS);
returnValue = invokeWebService(args, deploymentInfo, runMethod, instance, returnValue);
} else {
List< InterceptorData > interceptors = deploymentInfo.getMethodInterceptors(runMethod);
InterceptorStack interceptorStack = new InterceptorStack(instance.bean, runMethod, Operation.BUSINESS, interceptors, instance.interceptors);
returnValue = interceptorStack.invoke(args);
}
} catch (Throwable re) {// handle reflection exception
ExceptionType type = deploymentInfo.getExceptionType(re);
if (type == ExceptionType.SYSTEM) {
/* System Exception ****************************/
/**
* The bean instance is not put into the pool via instanceManager.poolInstance
* and therefore the instance will be garbage collected and destroyed.
* For this reason the discardInstance method of the StatelessInstanceManager
* does nothing.
*/
txPolicy.handleSystemException(re, instance, txContext);
} else {
/* Application Exception ***********************/
instanceManager.poolInstance(callContext, instance);
txPolicy.handleApplicationException(re, type == ExceptionType.APPLICATION_ROLLBACK, txContext);
}
} finally {
txPolicy.afterInvoke(instance, txContext);
}
return returnValue;
}
|
protected ProxyInfo createEJBObject(CoreDeploymentInfo deploymentInfo,
Method callMethod) {
return new ProxyInfo(deploymentInfo, null);
}
|
public void deploy(DeploymentInfo info) throws OpenEJBException {
CoreDeploymentInfo deploymentInfo = (CoreDeploymentInfo) info;
instanceManager.deploy(deploymentInfo);
String id = (String) deploymentInfo.getDeploymentID();
synchronized (this) {
deploymentRegistry.put(id, deploymentInfo);
deploymentInfo.setContainer(this);
}
EjbTimerService timerService = deploymentInfo.getEjbTimerService();
if (timerService != null) {
timerService.start();
}
}
|
public synchronized DeploymentInfo[] deployments() {
return deploymentRegistry.values().toArray(new DeploymentInfo[deploymentRegistry.size()]);
}
|
public void discardInstance(Object instance,
ThreadContext context) {
instanceManager.discardInstance(context, instance);
}
|
public Object getContainerID() {
return containerID;
}
|
public ContainerType getContainerType() {
return ContainerType.STATELESS;
}
|
public synchronized DeploymentInfo getDeploymentInfo(Object deploymentID) {
String id = (String) deploymentID;
return deploymentRegistry.get(id);
}
|
public StatelessInstanceManager getInstanceManager() {
return instanceManager;
}
|
public Object invoke(Object deployID,
Method callMethod,
Object[] args,
Object primKey,
Object securityIdentity) throws OpenEJBException {
return invoke(deployID, callMethod.getDeclaringClass(), callMethod, args, primKey);
} Deprecated! use - invoke signature without 'securityIdentity' argument.
|
public Object invoke(Object deployID,
Class callInterface,
Method callMethod,
Object[] args,
Object primKey) throws OpenEJBException {
CoreDeploymentInfo deployInfo = (CoreDeploymentInfo) this.getDeploymentInfo(deployID);
if (deployInfo == null) throw new OpenEJBException("Deployment does not exist in this container. Deployment(id='"+deployID+"'), Container(id='"+containerID+"')");
ThreadContext callContext = new ThreadContext(deployInfo, primKey);
ThreadContext oldCallContext = ThreadContext.enter(callContext);
try {
boolean authorized = getSecurityService().isCallerAuthorized(callMethod, deployInfo.getInterfaceType(callInterface));
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(deployInfo, 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
}
Object bean = instanceManager.getInstance(callContext);
callContext.setCurrentOperation(Operation.BUSINESS);
callContext.setCurrentAllowedStates(StatelessContext.getStates());
Method runMethod = deployInfo.getMatchingBeanMethod(callMethod);
callContext.set(Method.class, runMethod);
callContext.setInvokedInterface(callInterface);
Object retValue = _invoke(callInterface, callMethod, runMethod, args, bean, callContext);
instanceManager.poolInstance(callContext, bean);
return retValue;
} finally {
ThreadContext.exit(oldCallContext);
}
}
|
public void undeploy(DeploymentInfo info) {
undeploy((CoreDeploymentInfo)info);
}
|