Cleaned up RMI field names
This commit is contained in:
parent
5183309262
commit
c927f87316
|
@ -1280,12 +1280,12 @@ class ConnectionImpl extends ChannelInboundHandlerAdapter implements CryptoConne
|
|||
*
|
||||
* @see RemoteObject
|
||||
*
|
||||
* @param objectID this is the remote object ID (assigned by RMI). This is NOT the kryo registration ID
|
||||
* @param rmiId this is the remote object ID (assigned by RMI). This is NOT the kryo registration ID
|
||||
* @param iFace this is the RMI interface
|
||||
*/
|
||||
@Override
|
||||
public
|
||||
RemoteObject getProxyObject(final int objectID, final Class<?> iFace) {
|
||||
RemoteObject getProxyObject(final int rmiId, final Class<?> iFace) {
|
||||
if (iFace == null) {
|
||||
throw new IllegalArgumentException("iface cannot be null.");
|
||||
}
|
||||
|
@ -1296,14 +1296,13 @@ class ConnectionImpl extends ChannelInboundHandlerAdapter implements CryptoConne
|
|||
// we want to have a connection specific cache of IDs
|
||||
// because this is PER CONNECTION, there is no need for synchronize(), since there will not be any issues with concurrent
|
||||
// access, but there WILL be issues with thread visibility because a different worker thread can be called for different connections
|
||||
RemoteObject remoteObject = proxyIdCache.get(objectID);
|
||||
RemoteObject remoteObject = proxyIdCache.get(rmiId);
|
||||
|
||||
if (remoteObject == null) {
|
||||
// duplicates are fine, as they represent the same object (as specified by the ID) on the remote side.
|
||||
// remoteObject = rmiBridge.createProxyObject(this, objectID, iFace);
|
||||
|
||||
// the ACTUAL proxy is created in the connection impl.
|
||||
RmiProxyHandler proxyObject = new RmiProxyHandler(this, objectID, iFace);
|
||||
RmiProxyHandler proxyObject = new RmiProxyHandler(this, rmiId, iFace);
|
||||
proxyListeners.add(proxyObject.getListener());
|
||||
|
||||
Class<?>[] temp = new Class<?>[2];
|
||||
|
@ -1312,7 +1311,7 @@ class ConnectionImpl extends ChannelInboundHandlerAdapter implements CryptoConne
|
|||
|
||||
remoteObject = (RemoteObject) Proxy.newProxyInstance(RmiBridge.class.getClassLoader(), temp, proxyObject);
|
||||
|
||||
proxyIdCache.put(objectID, remoteObject);
|
||||
proxyIdCache.put(rmiId, remoteObject);
|
||||
}
|
||||
|
||||
return remoteObject;
|
||||
|
|
|
@ -39,7 +39,7 @@ class InvocationHandlerSerializer extends Serializer<Object> {
|
|||
public
|
||||
void write(Kryo kryo, Output output, Object object) {
|
||||
RmiProxyHandler handler = (RmiProxyHandler) Proxy.getInvocationHandler(object);
|
||||
output.writeInt(handler.objectID, true);
|
||||
output.writeInt(handler.rmiObjectId, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -32,14 +32,14 @@ class InvocationResultSerializer extends FieldSerializer<InvokeMethodResult> {
|
|||
public
|
||||
void write(Kryo kryo, Output output, InvokeMethodResult result) {
|
||||
super.write(kryo, output, result);
|
||||
output.writeInt(result.objectID, true);
|
||||
output.writeInt(result.rmiObjectId, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public
|
||||
InvokeMethodResult read(Kryo kryo, Input input, Class<InvokeMethodResult> type) {
|
||||
InvokeMethodResult result = super.read(kryo, input, type);
|
||||
result.objectID = input.readInt(true);
|
||||
result.rmiObjectId = input.readInt(true);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,8 +39,8 @@ package dorkbox.network.rmi;
|
|||
*/
|
||||
public
|
||||
class InvokeMethodResult implements RmiMessage {
|
||||
public int objectID;
|
||||
public int rmiObjectId;
|
||||
|
||||
public byte responseID;
|
||||
public byte responseId;
|
||||
public Object result;
|
||||
}
|
||||
|
|
|
@ -256,7 +256,7 @@ class RmiObjectLocalHandler extends RmiObjectHandler {
|
|||
if (o instanceof RemoteObject) {
|
||||
RmiProxyHandler handler = (RmiProxyHandler) Proxy.getInvocationHandler(o);
|
||||
|
||||
int id = handler.objectID;
|
||||
int id = handler.rmiObjectId;
|
||||
field.set(message, connection.getImplementationObject(id));
|
||||
fields.add(field);
|
||||
}
|
||||
|
@ -309,7 +309,7 @@ class RmiObjectLocalHandler extends RmiObjectHandler {
|
|||
if (o instanceof RemoteObject) {
|
||||
RmiProxyHandler handler = (RmiProxyHandler) Proxy.getInvocationHandler(o);
|
||||
|
||||
int id = handler.objectID;
|
||||
int id = handler.rmiObjectId;
|
||||
field.set(message, connection.getImplementationObject(id));
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -71,7 +71,7 @@ class RmiProxyHandler implements InvocationHandler {
|
|||
private final boolean[] pendingResponses = new boolean[64];
|
||||
|
||||
private final ConnectionImpl connection;
|
||||
public final int objectID; // this is the RMI id
|
||||
public final int rmiObjectId; // this is the RMI id
|
||||
public final int ID; // this is the KRYO id
|
||||
|
||||
|
||||
|
@ -97,16 +97,16 @@ class RmiProxyHandler implements InvocationHandler {
|
|||
|
||||
/**
|
||||
* @param connection this is really the network client -- there is ONLY ever 1 connection
|
||||
* @param objectID this is the remote object ID (assigned by RMI). This is NOT the kryo registration ID
|
||||
* @param rmiId this is the remote object ID (assigned by RMI). This is NOT the kryo registration ID
|
||||
* @param iFace this is the RMI interface
|
||||
*/
|
||||
public
|
||||
RmiProxyHandler(final ConnectionImpl connection, final int objectID, final Class<?> iFace) {
|
||||
RmiProxyHandler(final ConnectionImpl connection, final int rmiId, final Class<?> iFace) {
|
||||
super();
|
||||
|
||||
this.connection = connection;
|
||||
this.objectID = objectID;
|
||||
this.proxyString = "<proxy #" + objectID + ">";
|
||||
this.rmiObjectId = rmiId;
|
||||
this.proxyString = "<proxy #" + rmiId + ">";
|
||||
|
||||
EndPoint endPointConnection = this.connection.getEndPoint();
|
||||
final RmiSerializationManager serializationManager = endPointConnection.getSerialization();
|
||||
|
@ -114,8 +114,7 @@ class RmiProxyHandler implements InvocationHandler {
|
|||
KryoExtra kryoExtra = null;
|
||||
try {
|
||||
kryoExtra = serializationManager.takeKryo();
|
||||
this.ID = kryoExtra.getRegistration(iFace)
|
||||
.getId();
|
||||
this.ID = kryoExtra.getRegistration(iFace).getId();
|
||||
} finally {
|
||||
if (kryoExtra != null) {
|
||||
serializationManager.returnKryo(kryoExtra);
|
||||
|
@ -128,9 +127,9 @@ class RmiProxyHandler implements InvocationHandler {
|
|||
@Override
|
||||
public
|
||||
void received(Connection connection, InvokeMethodResult invokeMethodResult) {
|
||||
byte responseID = invokeMethodResult.responseID;
|
||||
byte responseID = invokeMethodResult.responseId;
|
||||
|
||||
if (invokeMethodResult.objectID != objectID) {
|
||||
if (invokeMethodResult.rmiObjectId != rmiId) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -165,7 +164,7 @@ class RmiProxyHandler implements InvocationHandler {
|
|||
|
||||
String name = method.getName();
|
||||
if (name.equals("close")) {
|
||||
connection.removeRmiListeners(objectID, getListener());
|
||||
connection.removeRmiListeners(rmiObjectId, getListener());
|
||||
return null;
|
||||
}
|
||||
else if (name.equals("setResponseTimeout")) {
|
||||
|
@ -227,10 +226,10 @@ class RmiProxyHandler implements InvocationHandler {
|
|||
}
|
||||
|
||||
InvokeMethod invokeMethod = new InvokeMethod();
|
||||
invokeMethod.objectID = this.objectID;
|
||||
invokeMethod.objectID = this.rmiObjectId;
|
||||
invokeMethod.args = args;
|
||||
|
||||
// which method do we access?
|
||||
// which method do we access? We always want to access the IMPLEMENTATION (if available!)
|
||||
CachedMethod[] cachedMethods = connection.getEndPoint()
|
||||
.getSerialization()
|
||||
.getMethods(ID);
|
||||
|
@ -419,7 +418,7 @@ class RmiProxyHandler implements InvocationHandler {
|
|||
int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + this.objectID;
|
||||
result = prime * result + this.rmiObjectId;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -436,6 +435,6 @@ class RmiProxyHandler implements InvocationHandler {
|
|||
return false;
|
||||
}
|
||||
RmiProxyHandler other = (RmiProxyHandler) obj;
|
||||
return this.objectID == other.objectID;
|
||||
return this.rmiObjectId == other.rmiObjectId;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user