org.inxar.hotswap
Interface ProxyObject


public interface ProxyObject

The ProxyObject interface is an optional interface that can be implemented by end-user classes to receive hotswap transaction lifecycle events. The names are prefixed with hotswap_ in order to avoid potential name conflicts with end-user code.

Since:
0.8.2

Method Summary
 Object hotswap_get(Object key)
          This is the type-safe window two ProxyObject instances having different Class membership can communicate through.
 void hotswap_onCommit()
          Called after hotswap_onPrepare(ProxyObject) in a transaction to signal that consensus has been successfully reached; state changes should be committed.
 boolean hotswap_onPrepare(ProxyObject oldInstance)
          Called when the ProxyObject is first involved in a hotswap transaction; the argument is the old ProxyObject instance that will be subsequently released (the one that this new object will replace).
 void hotswap_onRelease()
          Called when the ProxyObject is about to be dropped and presumably garbage-collected.
 void hotswap_onRollback()
          Called after hotswap_onPrepare(Object) in a transaction to signal that consensus has not been successfully reached; state changes be discarded.
 

Method Detail

hotswap_get

public Object hotswap_get(Object key)
This is the type-safe window two ProxyObject instances having different Class membership can communicate through. It is used for passing state from one ProxyObject instance to another within the body of hotswap_onPrepare(ProxyObject oldInstance).

hotswap_onPrepare

public boolean hotswap_onPrepare(ProxyObject oldInstance)
Called when the ProxyObject is first involved in a hotswap transaction; the argument is the old ProxyObject instance that will be subsequently released (the one that this new object will replace). The new object may use this old object to synchronize state changes, is desired.

The return value of the method should signal whether to commit the swap or rollback: if the return value is false, this new instance will not replace the old one; that is, the new object is saying I couldn't successfully accomplish the state translation to the new object, so rather than putting the application in a unpredictable state, just stick with the current one (rollback).


hotswap_onCommit

public void hotswap_onCommit()
Called after hotswap_onPrepare(ProxyObject) in a transaction to signal that consensus has been successfully reached; state changes should be committed.

hotswap_onRollback

public void hotswap_onRollback()
Called after hotswap_onPrepare(Object) in a transaction to signal that consensus has not been successfully reached; state changes be discarded.

hotswap_onRelease

public void hotswap_onRelease()
Called when the ProxyObject is about to be dropped and presumably garbage-collected.