|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openejb.core.ivm.IntraVmArtifact
public class IntraVmArtifact
This class represents all artifacts of the IntraVM in a stream.
Classes create this object in the writeReplace method.
When the object is serialized, the writeReplace method is invoked and this artifact is written to the stream instead. The original object instance is placed in a HashMap and not serialized.
During deserialization, it is this object that is deserialized. This class implements the readResolve method of the serialization API. In the readResolve method, the original object instance is retrieved from the HashMap and returned instead.
Basically, we mark all local serialization operations the same way you would mark a transaction.
Definition:
This is a full serialization/deserialization takes place in the local vm inside the marked scope of the IntraVM server.
Circumstances:
When an IntraVM implementation of a javax.ejb.* interface is serialized in the scope of a local IntraVM serialization.
These serializations happen when objects are passed as parameters or return values from one client/ejb to another client/ejb running inside the same VM.
Action:
Temporarily cache the instance in memory during serialization, retrieve again during deserialization.
Example Scenario:
BEFORE SERIALIZATION
1. Call IntraVmCopyMonitor.preCopyOperation().
2. Method parameters are sent to ObjectOutputStream.
SERIALIZATION
3. ObjectOutputStream encounters an IntraVmMetaData instance
in the object graph and calls its writeReplace method.
4. The IntraVmMetaData instance determines it is being
serialized in the scope of an IntraVM serialization by
calling IntraVmCopyMonitor.isIntraVmCopyOperation().
5. The IntraVmMetaData instance creates an IntraVmArtifact
that caches it in a static hashtable keyed on a
combination of the thread id and instance hashCode.
6. The IntraVmMetaData instance returns the IntraVmArtifact
instance from the writeReplace method.
7. The ObjectOutputStream serializes the IntraVmArtifact
instance in place of the IntraVmMetaData instance.
DESERIALIZATION
8. ObjectInputStream encounters and deserializes an
IntraVmArtifact instance and calls its readResolve method.
9. The IntraVmArtifact instance uses the key it created in
step 5 to retrieve the IntraVmMetaData instance from the
static hashtable.
10. The IntraVmArtifact instance returns the IntraVmMetaData
instance from the readResolve method.
11. ObjectInputStream places the IntraVmMetaData instance in
the object graph in place of the IntraVmArtifact
instance.
AFTER
12. Method parameters are now de-referenced as mandated by the
spec and can be passed into the bean's method.
13. IntraVmCopyMonitor.postCopyOperation() is called, ending
the local IntraVm serialization scope.
Constructor Summary | |
---|---|
IntraVmArtifact()
This class is Externalizable and this public, no-arg, constructor is required. |
|
IntraVmArtifact(java.lang.Object obj)
Used to creat an IntraVmArtifact object that can represent the true intra-vm artifact in a stream. |
Method Summary | |
---|---|
void |
readExternal(java.io.ObjectInput in)
Reads the instanceHandle from the stream |
void |
writeExternal(java.io.ObjectOutput out)
Writes the instanceHandle to the stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public IntraVmArtifact(java.lang.Object obj)
obj
- The object instance this class should represent in the stream.public IntraVmArtifact()
Method Detail |
---|
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
out
-
java.io.IOException
public void readExternal(java.io.ObjectInput in) throws java.io.IOException
readExternal
in interface java.io.Externalizable
in
-
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |