A simple replacement for the RMI MarshalledObject that uses the thread
context class loader for resolving classes and proxies. This currently does
not support class annotations and dynamic class loading.
| Method from org.jboss.invocation.MarshalledValue Detail: |
public boolean equals(Object obj) {
if( this == obj )
return true;
boolean equals = false;
if( obj instanceof MarshalledValue )
{
MarshalledValue mv = (MarshalledValue) obj;
if( serializedForm == mv.serializedForm )
{
equals = true;
}
else
{
equals = Arrays.equals(serializedForm, mv.serializedForm);
}
}
return equals;
}
|
public Object get() throws ClassNotFoundException, IOException {
if (serializedForm == null)
return null;
ByteArrayInputStream bais = new ByteArrayInputStream(serializedForm);
MarshalledValueInputStream mvis = new MarshalledValueInputStream(bais);
Object retValue = mvis.readObject();
mvis.close();
return retValue;
}
|
public int hashCode() {
return hashCode;
}
Return a hash code for the serialized form of the value. |
public void readExternal(ObjectInput in) throws ClassNotFoundException, IOException {
int length = in.readInt();
serializedForm = null;
if( length > 0 )
{
serializedForm = new byte[length];
in.readFully(serializedForm);
}
hashCode = in.readInt();
}
The object implements the readExternal method to restore its
contents by calling the methods of DataInput for primitive
types and readObject for objects, strings and arrays. The
readExternal method must read the values in the same sequence
and with the same types as were written by writeExternal. |
public int size() {
int size = serializedForm != null ? serializedForm.length : 0;
return size;
}
|
public byte[] toByteArray() {
return serializedForm;
}
|
public void writeExternal(ObjectOutput out) throws IOException {
int length = serializedForm != null ? serializedForm.length : 0;
out.writeInt(length);
if( length > 0 )
{
out.write(serializedForm);
}
out.writeInt(hashCode);
}
The object implements the writeExternal method to save its contents
by calling the methods of DataOutput for its primitive values or
calling the writeObject method of ObjectOutput for objects, strings,
and arrays. |