Author: andygumbrecht
Date: Tue Apr 10 14:09:23 2012
New Revision: 1311735
URL: http://svn.apache.org/viewvc?rev=1311735&view=rev
Log:
EJBRequest: Added version to body. Removed boxing. Finals.
EJBResponse: Added version checking.
EjbRequestHandler: Added version. Use InterfaceType on invoke.
Modified:
openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EJBRequest.java
openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EJBResponse.java
openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/EjbRequestHandler.java
Modified:
openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EJBRequest.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EJBRequest.java?rev=1311735&r1=1311734&r2=1311735&view=diff
==============================================================================
---
openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EJBRequest.java
(original)
+++
openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EJBRequest.java
Tue Apr 10 14:09:23 2012
@@ -52,7 +52,7 @@ public class EJBRequest implements Clust
ejbMetaData = null;
}
- public EJBRequest(RequestMethodCode requestMethod, EJBMetaDataImpl ejb,
Method method, Object[] args, Object primaryKey) {
+ public EJBRequest(final RequestMethodCode requestMethod, final
EJBMetaDataImpl ejb, final Method method, final Object[] args, final Object
primaryKey) {
body = new Body(ejb);
this.ejbMetaData = ejb;
@@ -92,15 +92,15 @@ public class EJBRequest implements Clust
return body.getPrimaryKey();
}
- public void setMethodInstance(Method methodInstance) {
+ public void setMethodInstance(final Method methodInstance) {
body.setMethodInstance(methodInstance);
}
- public void setMethodParameters(Object[] methodParameters) {
+ public void setMethodParameters(final Object[] methodParameters) {
body.setMethodParameters(methodParameters);
}
- public void setPrimaryKey(Object primaryKey) {
+ public void setPrimaryKey(final Object primaryKey) {
body.setPrimaryKey(primaryKey);
}
@@ -108,10 +108,14 @@ public class EJBRequest implements Clust
return body;
}
- public void setBody(Body body) {
+ public void setBody(final Body body) {
this.body = body;
}
+ public byte getVersion() {
+ return this.body.getVersion();
+ }
+
public static class Body implements java.io.Externalizable {
private transient EJBMetaDataImpl ejb;
@@ -124,11 +128,19 @@ public class EJBRequest implements Clust
private transient Object primaryKey;
private transient String requestId;
+ private byte version = EJBResponse.VERSION;
- public Body(EJBMetaDataImpl ejb) {
+ public Body(final EJBMetaDataImpl ejb) {
this.ejb = ejb;
}
+ public Body() {
+ }
+
+ public byte getVersion() {
+ return version;
+ }
+
public Method getMethodInstance() {
return methodInstance;
}
@@ -153,14 +165,14 @@ public class EJBRequest implements Clust
return methodParamTypes;
}
- public void setMethodInstance(Method methodInstance) {
+ public void setMethodInstance(final Method methodInstance) {
if (methodInstance == null) {
throw new NullPointerException("methodInstance input parameter
is null");
}
this.methodInstance = methodInstance;
this.methodName = methodInstance.getName();
this.methodParamTypes = methodInstance.getParameterTypes();
- Class methodClass = methodInstance.getDeclaringClass();
+ final Class methodClass = methodInstance.getDeclaringClass();
if (ejb.homeClass != null) {
if (methodClass.isAssignableFrom(ejb.homeClass)) {
@@ -176,7 +188,7 @@ public class EJBRequest implements Clust
}
}
- for (Class businessClass : ejb.businessClasses) {
+ for (final Class businessClass : ejb.businessClasses) {
if (methodClass.isAssignableFrom(businessClass)) {
this.interfaceClass = businessClass;
return;
@@ -184,11 +196,11 @@ public class EJBRequest implements Clust
}
}
- public void setMethodParameters(Object[] methodParameters) {
+ public void setMethodParameters(final Object[] methodParameters) {
this.methodParameters = methodParameters;
}
- public void setPrimaryKey(Object primaryKey) {
+ public void setPrimaryKey(final Object primaryKey) {
this.primaryKey = primaryKey;
}
@@ -196,12 +208,14 @@ public class EJBRequest implements Clust
return requestId;
}
- public void setRequestId(String requestId) {
+ public void setRequestId(final String requestId) {
this.requestId = requestId;
}
- public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
- byte version = in.readByte(); // future use
+ @Override
+ public void readExternal(final ObjectInput in) throws IOException,
ClassNotFoundException {
+
+ this.version = in.readByte();
requestId = null;
ClassNotFoundException result = null;
@@ -215,7 +229,7 @@ public class EJBRequest implements Clust
interfaceClass = (Class) in.readObject();
// methodClass = (Class) in.readObject();
} catch (ClassNotFoundException cnfe) {
- if (result == null) result = cnfe;
+ result = cnfe;
}
methodName = in.readUTF();
@@ -236,9 +250,10 @@ public class EJBRequest implements Clust
throw result;
}
- public void writeExternal(ObjectOutput out) throws IOException {
- // write out the version of the serialized data for future use
- out.writeByte(1);
+ @Override
+ public void writeExternal(final ObjectOutput out) throws IOException {
+
+ out.writeByte(this.version);
out.writeObject(requestId);
@@ -251,53 +266,53 @@ public class EJBRequest implements Clust
writeMethodParameters(out, methodParamTypes, methodParameters);
}
- protected void writeMethodParameters(ObjectOutput out, Class[] types,
Object[] args) throws IOException {
+ protected void writeMethodParameters(final ObjectOutput out, final
Class[] types, final Object[] args) throws IOException {
out.writeByte(types.length);
for (int i = 0; i < types.length; i++) {
- Class type = types[i];
+ final Class type = types[i];
Object obj = args[i];
if (type.isPrimitive()) {
if (type == Byte.TYPE) {
out.write(B);
- byte bytevalue = ((Byte) obj).byteValue();
+ final byte bytevalue = (Byte) obj;
out.writeByte(bytevalue);
} else if (type == Character.TYPE) {
out.write(C);
- char charvalue = ((Character) obj).charValue();
+ final char charvalue = (Character) obj;
out.writeChar(charvalue);
} else if (type == Integer.TYPE) {
out.write(I);
- int intvalue = ((Integer) obj).intValue();
+ final int intvalue = (Integer) obj;
out.writeInt(intvalue);
} else if (type == Boolean.TYPE) {
out.write(Z);
- boolean booleanvalue = ((Boolean) obj).booleanValue();
+ final boolean booleanvalue = (Boolean) obj;
out.writeBoolean(booleanvalue);
} else if (type == Long.TYPE) {
out.write(J);
- long longvalue = ((Long) obj).longValue();
+ final long longvalue = (Long) obj;
out.writeLong(longvalue);
} else if (type == Float.TYPE) {
out.write(F);
- float fvalue = ((Float) obj).floatValue();
+ final float fvalue = (Float) obj;
out.writeFloat(fvalue);
} else if (type == Double.TYPE) {
out.write(D);
- double dvalue = ((Double) obj).doubleValue();
+ final double dvalue = (Double) obj;
out.writeDouble(dvalue);
} else if (type == Short.TYPE) {
out.write(S);
- short shortvalue = ((Short) obj).shortValue();
+ final short shortvalue = (Short) obj;
out.writeShort(shortvalue);
} else {
@@ -305,11 +320,11 @@ public class EJBRequest implements Clust
}
} else {
if (obj instanceof PortableRemoteObject && obj instanceof
Remote) {
- Tie tie = javax.rmi.CORBA.Util.getTie((Remote) obj);
+ final Tie tie = javax.rmi.CORBA.Util.getTie((Remote)
obj);
if (tie == null) {
throw new IOException("Unable to serialize
PortableRemoteObject; object has not been exported: " + obj);
}
- ORB orb = getORB();
+ final ORB orb = getORB();
tie.orb(orb);
obj = PortableRemoteObject.toStub((Remote) obj);
}
@@ -328,12 +343,13 @@ public class EJBRequest implements Clust
* arguments and return results.
*
* @return An ORB instance.
+ * @throws java.io.IOException On error
*/
protected ORB getORB() throws IOException {
// first ORB request? Check our various sources
if (orb == null) {
try {
- Context initialContext = new InitialContext();
+ final Context initialContext = new InitialContext();
orb = (ORB) initialContext.lookup("java:comp/ORB");
} catch (Throwable e) {
try {
@@ -347,8 +363,8 @@ public class EJBRequest implements Clust
return orb;
}
- protected void readMethodParameters(ObjectInput in) throws
IOException, ClassNotFoundException {
- int length = in.read();
+ protected void readMethodParameters(final ObjectInput in) throws
IOException, ClassNotFoundException {
+ final int length = in.read();
if (length < 1) {
methodParamTypes = noArgsC;
@@ -356,62 +372,62 @@ public class EJBRequest implements Clust
return;
}
- Class[] types = new Class[length];
- Object[] args = new Object[length];
+ final Class[] types = new Class[length];
+ final Object[] args = new Object[length];
for (int i = 0; i < types.length; i++) {
Class clazz = null;
Object obj = null;
- int type = in.read();
+ final int type = in.read();
switch (type) {
case B:
clazz = Byte.TYPE;
- obj = new Byte(in.readByte());
+ obj = in.readByte();
break;
case C:
clazz = Character.TYPE;
- obj = new Character(in.readChar());
+ obj = in.readChar();
break;
case I:
clazz = Integer.TYPE;
- obj = new Integer(in.readInt());
+ obj = in.readInt();
break;
case Z:
clazz = Boolean.TYPE;
- obj = new Boolean(in.readBoolean());
+ obj = in.readBoolean();
break;
case J:
clazz = Long.TYPE;
- obj = new Long(in.readLong());
+ obj = in.readLong();
break;
case F:
clazz = Float.TYPE;
- obj = new Float(in.readFloat());
+ obj = in.readFloat();
break;
case D:
clazz = Double.TYPE;
- obj = new Double(in.readDouble());
+ obj = in.readDouble();
break;
case S:
clazz = Short.TYPE;
- obj = new Short(in.readShort());
+ obj = in.readShort();
break;
case L:
clazz = (Class) in.readObject();
obj = in.readObject();
if (obj instanceof Stub) {
- Stub stub = (Stub) obj;
- ORB orb = getORB();
+ final Stub stub = (Stub) obj;
+ final ORB orb = getORB();
stub.connect(orb);
}
break;
@@ -439,6 +455,7 @@ public class EJBRequest implements Clust
private static final int A = 9;
}
+ @Override
public RequestType getRequestType() {
return RequestType.EJB_REQUEST;
}
@@ -459,26 +476,28 @@ public class EJBRequest implements Clust
return deploymentCode;
}
- public void setRequestMethod(RequestMethodCode requestMethod) {
+ public void setRequestMethod(final RequestMethodCode requestMethod) {
this.requestMethod = requestMethod;
}
- public void setClientIdentity(Object clientIdentity) {
+ public void setClientIdentity(final Object clientIdentity) {
this.clientIdentity = clientIdentity;
}
- public void setDeploymentId(String deploymentId) {
+ public void setDeploymentId(final String deploymentId) {
this.deploymentId = deploymentId;
}
- public void setDeploymentCode(int deploymentCode) {
+ public void setDeploymentCode(final int deploymentCode) {
this.deploymentCode = deploymentCode;
}
- public void setServerHash(int serverHash) {
+ @Override
+ public void setServerHash(final int serverHash) {
this.serverHash = serverHash;
}
+ @Override
public int getServerHash() {
return serverHash;
}
@@ -511,14 +530,15 @@ public class EJBRequest implements Clust
There will be one request instance for each handler
*/
- public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
+ @Override
+ public void readExternal(final ObjectInput in) throws IOException,
ClassNotFoundException {
ClassNotFoundException result = null;
deploymentId = null;
deploymentCode = -1;
clientIdentity = null;
- int code = in.readByte();
+ final int code = in.readByte();
try {
requestMethod = RequestMethodCode.valueOf(code);
} catch (IllegalArgumentException iae) {
@@ -540,7 +560,8 @@ public class EJBRequest implements Clust
throw result;
}
- public void writeExternal(ObjectOutput out) throws IOException {
+ @Override
+ public void writeExternal(final ObjectOutput out) throws IOException {
out.writeByte(requestMethod.getCode());
if (deploymentCode > 0) {
Modified:
openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EJBResponse.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EJBResponse.java?rev=1311735&r1=1311734&r2=1311735&view=diff
==============================================================================
---
openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EJBResponse.java
(original)
+++
openejb/trunk/openejb/server/openejb-client/src/main/java/org/apache/openejb/client/EJBResponse.java
Tue Apr 10 14:09:23 2012
@@ -22,6 +22,13 @@ import java.io.ObjectOutput;
public class EJBResponse implements ClusterableResponse {
+ /**
+ * 1. Initial
+ * 2. Append times.
+ */
+ public static final byte VERSION = 2;
+
+ private transient byte version = VERSION;
private transient int responseCode = -1;
private transient Object result;
private transient ServerMetaData server;
@@ -29,12 +36,6 @@ public class EJBResponse implements Clus
private transient final int timesLength = times.length;
public EJBResponse() {
-
- }
-
- public EJBResponse(final int code, final Object obj) {
- responseCode = code;
- result = obj;
}
public int getResponseCode() {
@@ -45,7 +46,8 @@ public class EJBResponse implements Clus
return result;
}
- public void setResponse(final int code, final Object result) {
+ public void setResponse(final byte version, final int code, final Object
result) {
+ this.version = version;
this.responseCode = code;
this.result = result;
}
@@ -113,34 +115,32 @@ public class EJBResponse implements Clus
@Override
public void readExternal(final ObjectInput in) throws IOException,
ClassNotFoundException {
- final byte version = in.readByte(); // future use
+ final byte version = in.readByte();
- if (version == 1) {
+ final boolean readServer = in.readBoolean();
+ if (readServer) {
+ server = new ServerMetaData();
+ server.readExternal(in);
+ }
- final boolean readServer = in.readBoolean();
- if (readServer) {
- server = new ServerMetaData();
- server.readExternal(in);
- }
+ responseCode = in.readByte();
+
+ result = in.readObject();
- responseCode = in.readByte();
+ if (version == 2) {
- result = in.readObject();
+ final byte size = in.readByte();
-// final byte size = in.readByte();
-//
-// for (int i = 0; (i < size && i < timesLength); i++) {
-// times[i] = in.readLong();
-// }
- }else{
- throw new IOException("Invalid EJBResponse version: " + version);
+ for (int i = 0; (i < size && i < timesLength); i++) {
+ times[i] = in.readLong();
+ }
}
}
@Override
public void writeExternal(final ObjectOutput out) throws IOException {
- // write out the version of the serialized data for future use
- out.writeByte(1);
+
+ out.writeByte(this.version);
if (null != server) {
out.writeBoolean(true);
@@ -159,7 +159,7 @@ public class EJBResponse implements Clus
final Throwable throwable = (Throwable) result;
result = new ThrowableArtifact(throwable);
}
- break;
+ break;
}
start(Time.SERIALIZATION);
@@ -167,11 +167,14 @@ public class EJBResponse implements Clus
stop(Time.SERIALIZATION);
stop(Time.TOTAL);
-// out.writeByte(timesLength);
-//
-// for (final long time : times) {
-// out.writeLong(time);
-// }
+ if (this.version == 2) {
+
+ out.writeByte(timesLength);
+
+ for (final long time : times) {
+ out.writeLong(time);
+ }
+ }
}
public static enum Time {
Modified:
openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/EjbRequestHandler.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/EjbRequestHandler.java?rev=1311735&r1=1311734&r2=1311735&view=diff
==============================================================================
---
openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/EjbRequestHandler.java
(original)
+++
openejb/trunk/openejb/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/EjbRequestHandler.java
Tue Apr 10 14:09:23 2012
@@ -17,6 +17,7 @@
package org.apache.openejb.server.ejbd;
import org.apache.openejb.BeanContext;
+import org.apache.openejb.InterfaceType;
import org.apache.openejb.ProxyInfo;
import org.apache.openejb.RpcContainer;
import org.apache.openejb.client.EJBHomeProxyHandle;
@@ -69,6 +70,7 @@ class EjbRequestHandler {
EJBObjectProxyHandle.resolver.set(SERVER_SIDE_RESOLVER);
final EJBRequest req = new EJBRequest();
+ byte version = req.getVersion();
final EJBResponse res = new EJBResponse();
res.start(EJBResponse.Time.TOTAL);
@@ -76,7 +78,7 @@ class EjbRequestHandler {
try {
req.readExternal(in);
} catch (Throwable t) {
- replyWithFatalError(out, t, "Bad request");
+ replyWithFatalError(version, out, t, "Bad request");
return;
}
@@ -87,7 +89,7 @@ class EjbRequestHandler {
securityService.associate(clientIdentity);
}
} catch (Throwable t) {
- replyWithFatalError(out, t, "Client identity is not valid: " +
req);
+ replyWithFatalError(version, out, t, "Client identity is not valid
- " + req);
return;
}
@@ -97,16 +99,10 @@ class EjbRequestHandler {
try {
di = this.daemon.getDeployment(req);
} catch (RemoteException e) {
- replyWithFatalError(out, e, "No such deployment");
+ replyWithFatalError(version, out, e, "No such deployment");
return;
- /*
- logger.warn( req + "No such deployment: "+e.getMessage());
- res.setResponse( EJB_SYS_EXCEPTION, e);
- res.writeExternal( out );
- return;
- */
} catch (Throwable t) {
- replyWithFatalError(out, t, "Unkown error occured while retrieving
deployment");
+ replyWithFatalError(version, out, t, "Unkown error occured while
retrieving deployment");
return;
}
@@ -118,10 +114,11 @@ class EjbRequestHandler {
res.start(EJBResponse.Time.DESERIALIZATION);
req.getBody().readExternal(in);
+ version = req.getVersion();
res.stop(EJBResponse.Time.DESERIALIZATION);
} catch (Throwable t) {
- replyWithFatalError(out, t, "Error caught during request
processing");
+ replyWithFatalError(version, out, t, "Error caught during request
processing");
return;
}
@@ -130,7 +127,7 @@ class EjbRequestHandler {
call.setEJBRequest(req);
call.setBeanContext(di);
} catch (Throwable t) {
- replyWithFatalError(out, t, "Unable to set the thread context for
this request");
+ replyWithFatalError(version, out, t, "Unable to set the thread
context for this request");
return;
}
@@ -209,18 +206,19 @@ class EjbRequestHandler {
doFUTURE_CANCEL_METHOD(req, res);
break;
}
+
res.stop(EJBResponse.Time.CONTAINER);
} catch (org.apache.openejb.InvalidateReferenceException e) {
- res.setResponse(ResponseCodes.EJB_SYS_EXCEPTION, new
ThrowableArtifact(e.getRootCause()));
+ res.setResponse(version, ResponseCodes.EJB_SYS_EXCEPTION, new
ThrowableArtifact(e.getRootCause()));
} catch (org.apache.openejb.ApplicationException e) {
- res.setResponse(ResponseCodes.EJB_APP_EXCEPTION, new
ThrowableArtifact(e.getRootCause()));
+ res.setResponse(version, ResponseCodes.EJB_APP_EXCEPTION, new
ThrowableArtifact(e.getRootCause()));
} catch (org.apache.openejb.SystemException e) {
- res.setResponse(ResponseCodes.EJB_ERROR, new
ThrowableArtifact(e.getRootCause()));
+ res.setResponse(version, ResponseCodes.EJB_ERROR, new
ThrowableArtifact(e.getRootCause()));
logger.error(req + ": OpenEJB encountered an unknown system error
in container: ", e);
} catch (Throwable t) {
- replyWithFatalError(out, t, "Unknown error in container");
+ replyWithFatalError(version, out, t, "Unknown error in container");
respond = false;
} finally {
@@ -266,7 +264,7 @@ class EjbRequestHandler {
//TODO ?
} else {
invocationCancelTag.set((Boolean)
req.getBody().getMethodParameters()[0]);
- res.setResponse(ResponseCodes.EJB_OK, null);
+ res.setResponse(req.getVersion(), ResponseCodes.EJB_OK, null);
}
}
@@ -283,18 +281,26 @@ class EjbRequestHandler {
}
final RpcContainer c = (RpcContainer)
call.getBeanContext().getContainer();
- Object result = c.invoke(req.getDeploymentId(),
- req.getInterfaceClass(), req.getMethodInstance(),
+// Object result = c.invoke(req.getDeploymentId(),
+// req.getInterfaceClass(), req.getMethodInstance(),
+// req.getMethodParameters(),
+// req.getPrimaryKey()
+// );
+
+ Object result = c.invoke(
+ req.getDeploymentId(),
+ InterfaceType.EJB_OBJECT,
+ req.getInterfaceClass(),
+ req.getMethodInstance(),
req.getMethodParameters(),
- req.getPrimaryKey()
- );
+ req.getPrimaryKey());
//Pass the internal value to the remote client, as AsyncResult is
not serializable
if (result != null && asynchronous) {
result = ((Future) result).get();
}
- res.setResponse(ResponseCodes.EJB_OK, result);
+ res.setResponse(req.getVersion(), ResponseCodes.EJB_OK, result);
} finally {
if (asynchronous) {
ThreadContext.removeAsynchronousCancelled();
@@ -308,13 +314,16 @@ class EjbRequestHandler {
final CallContext call = CallContext.getCallContext();
final RpcContainer c = (RpcContainer)
call.getBeanContext().getContainer();
- final Object result = c.invoke(req.getDeploymentId(),
- req.getInterfaceClass(), req.getMethodInstance(),
+ final Object result = c.invoke(
+ req.getDeploymentId(),
+ InterfaceType.EJB_HOME,
+ req.getInterfaceClass(),
+ req.getMethodInstance(),
req.getMethodParameters(),
req.getPrimaryKey()
);
- res.setResponse(ResponseCodes.EJB_OK, result);
+ res.setResponse(req.getVersion(), ResponseCodes.EJB_OK, result);
}
protected void doEjbHome_CREATE(final EJBRequest req, final EJBResponse
res) throws Exception {
@@ -322,20 +331,23 @@ class EjbRequestHandler {
final CallContext call = CallContext.getCallContext();
final RpcContainer c = (RpcContainer)
call.getBeanContext().getContainer();
- Object result = c.invoke(req.getDeploymentId(),
- req.getInterfaceClass(), req.getMethodInstance(),
+ Object result = c.invoke(
+ req.getDeploymentId(),
+ InterfaceType.EJB_HOME,
+ req.getInterfaceClass(),
+ req.getMethodInstance(),
req.getMethodParameters(),
req.getPrimaryKey()
);
if (result instanceof ProxyInfo) {
final ProxyInfo info = (ProxyInfo) result;
- res.setResponse(ResponseCodes.EJB_OK, info.getPrimaryKey());
+ res.setResponse(req.getVersion(), ResponseCodes.EJB_OK,
info.getPrimaryKey());
} else {
result = new RemoteException("The bean is not EJB compliant. The
bean should be created or and exception should be thrown.");
logger.error(req + "The bean is not EJB compliant. The bean
should be created or and exception should be thrown.");
- res.setResponse(ResponseCodes.EJB_SYS_EXCEPTION, new
ThrowableArtifact((Throwable) result));
+ res.setResponse(req.getVersion(), ResponseCodes.EJB_SYS_EXCEPTION,
new ThrowableArtifact((Throwable) result));
}
}
@@ -344,8 +356,11 @@ class EjbRequestHandler {
final CallContext call = CallContext.getCallContext();
final RpcContainer c = (RpcContainer)
call.getBeanContext().getContainer();
- Object result = c.invoke(req.getDeploymentId(),
- req.getInterfaceClass(), req.getMethodInstance(),
+ Object result = c.invoke(
+ req.getDeploymentId(),
+ InterfaceType.EJB_HOME,
+ req.getInterfaceClass(),
+ req.getMethodInstance(),
req.getMethodParameters(),
req.getPrimaryKey()
);
@@ -364,7 +379,7 @@ class EjbRequestHandler {
}
}
- res.setResponse(ResponseCodes.EJB_OK_FOUND_COLLECTION,
primaryKeys);
+ res.setResponse(req.getVersion(),
ResponseCodes.EJB_OK_FOUND_COLLECTION, primaryKeys);
} else if (result instanceof java.util.Enumeration) {
@@ -379,14 +394,14 @@ class EjbRequestHandler {
}
}
- res.setResponse(ResponseCodes.EJB_OK_FOUND_ENUMERATION,
listOfPKs.toArray(new Object[listOfPKs.size()]));
+ res.setResponse(req.getVersion(),
ResponseCodes.EJB_OK_FOUND_ENUMERATION, listOfPKs.toArray(new
Object[listOfPKs.size()]));
/* Single instance found */
} else if (result instanceof ProxyInfo) {
final ProxyInfo proxyInfo = ((ProxyInfo) result);
result = proxyInfo.getPrimaryKey();
- res.setResponse(ResponseCodes.EJB_OK_FOUND, result);
+ res.setResponse(req.getVersion(), ResponseCodes.EJB_OK_FOUND,
result);
} else if (result == null) {
- res.setResponse(ResponseCodes.EJB_OK_FOUND, null);
+ res.setResponse(req.getVersion(), ResponseCodes.EJB_OK_FOUND,
null);
} else {
final String message = "The bean is not EJB compliant. " +
@@ -395,7 +410,7 @@ class EjbRequestHandler {
"but [" + result.getClass().getName() + "]";
result = new RemoteException(message);
logger.error(req + " " + message);
- res.setResponse(ResponseCodes.EJB_SYS_EXCEPTION, result);
+ res.setResponse(req.getVersion(), ResponseCodes.EJB_SYS_EXCEPTION,
result);
}
}
@@ -420,13 +435,16 @@ class EjbRequestHandler {
final CallContext call = CallContext.getCallContext();
final RpcContainer c = (RpcContainer)
call.getBeanContext().getContainer();
- final Object result = c.invoke(req.getDeploymentId(),
- req.getInterfaceClass(), req.getMethodInstance(),
+ c.invoke(
+ req.getDeploymentId(),
+ InterfaceType.EJB_OBJECT,
+ req.getInterfaceClass(),
+ req.getMethodInstance(),
req.getMethodParameters(),
req.getPrimaryKey()
);
- res.setResponse(ResponseCodes.EJB_OK, null);
+ res.setResponse(req.getVersion(), ResponseCodes.EJB_OK, null);
}
protected void doEjbHome_GET_EJB_META_DATA(final EJBRequest req, final
EJBResponse res) throws Exception {
@@ -442,13 +460,16 @@ class EjbRequestHandler {
final CallContext call = CallContext.getCallContext();
final RpcContainer c = (RpcContainer)
call.getBeanContext().getContainer();
- final Object result = c.invoke(req.getDeploymentId(),
- req.getInterfaceClass(), req.getMethodInstance(),
+ c.invoke(
+ req.getDeploymentId(),
+ InterfaceType.EJB_HOME,
+ req.getInterfaceClass(),
+ req.getMethodInstance(),
req.getMethodParameters(),
req.getPrimaryKey()
);
- res.setResponse(ResponseCodes.EJB_OK, null);
+ res.setResponse(req.getVersion(), ResponseCodes.EJB_OK, null);
}
protected void doEjbHome_REMOVE_BY_PKEY(final EJBRequest req, final
EJBResponse res) throws Exception {
@@ -456,20 +477,23 @@ class EjbRequestHandler {
final CallContext call = CallContext.getCallContext();
final RpcContainer c = (RpcContainer)
call.getBeanContext().getContainer();
- final Object result = c.invoke(req.getDeploymentId(),
- req.getInterfaceClass(), req.getMethodInstance(),
+ c.invoke(
+ req.getDeploymentId(),
+ InterfaceType.EJB_HOME,
+ req.getInterfaceClass(),
+ req.getMethodInstance(),
req.getMethodParameters(),
req.getPrimaryKey()
);
- res.setResponse(ResponseCodes.EJB_OK, null);
+ res.setResponse(req.getVersion(), ResponseCodes.EJB_OK, null);
}
protected void checkMethodAuthorization(final EJBRequest req, final
EJBResponse res) throws Exception {
- res.setResponse(ResponseCodes.EJB_OK, null);
+ res.setResponse(req.getVersion(), ResponseCodes.EJB_OK, null);
}
- private void replyWithFatalError(final ObjectOutputStream out, final
Throwable error, final String message) {
+ private void replyWithFatalError(final byte version, final
ObjectOutputStream out, final Throwable error, final String message) {
//This is fatal for the client, but not the server.
if (logger.isWarningEnabled()) {
@@ -480,7 +504,7 @@ class EjbRequestHandler {
final RemoteException re = new RemoteException(message, error);
final EJBResponse res = new EJBResponse();
- res.setResponse(ResponseCodes.EJB_ERROR, new ThrowableArtifact(re));
+ res.setResponse(version, ResponseCodes.EJB_ERROR, new
ThrowableArtifact(re));
try {
res.writeExternal(out);