|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openejb.core.ivm.IntraVmCopyMonitor
public class IntraVmCopyMonitor
This class is used to demarcate intra-VM copy operations so that intra-VM artifacts such as IntraVmHandle, IntraVmMetaData, and BaseEjbProxyHandlers (EjbHomeProxyHandler and EjbObjectProxyHandler) can know when they should replace themselves during serialization with an IntraVmArtifact or a application server specific artifact.
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.
Method Summary | |
---|---|
static boolean |
exists()
|
static boolean |
isIntraVmCopyOperation()
Returns true if the current operation is an IntraVM copy. |
static boolean |
isStatefulPassivationOperation()
Returns true if the current operation is the passivation of a stateful session bean. |
static void |
postCopyOperation()
Notifies the monitor for this thread just after a copy operation has taken place. |
static void |
postPassivationOperation()
Notifies the monitor for this thread just after a stateful session bean is passified. |
static void |
preCopyOperation()
Notifies the monitor for this thread just before a copy operation is to take place. |
static void |
prePassivationOperation()
Notifies the monitor for this thread just before a stateful session bean is passified. |
static void |
release()
Not to be used lightly. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static boolean exists()
public static void release()
public static void preCopyOperation()
public static void postCopyOperation()
public static void prePassivationOperation()
public static void postPassivationOperation()
public static boolean isIntraVmCopyOperation()
public static boolean isStatefulPassivationOperation()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |