| java.lang.Object org.space4j.passivation.PassivationObj
PassivationObj | public class PassivationObj implements Serializable(Code) | | If you want to make your object passivated, you must distribute it throughout your application as a PassivationObj.
Actually, this is pretty simple. You have an object User. If you put your User in a PassivationMap, you will receive
a PassivationObj whenever you ask for it through the get(key) method. So there won't be any references to User throughout
your applicatoin, but only references to PassivationObj. Whenever you want to gain access to the raal object, you can
use the get() method. If the your Object is in memory, PassivationObj just return it. If it is passivated, PassivationObj
brings it back from disk.
Note:
- An object can be passivated if and only if it has a unique id returned by its hashCode, like a database primary key.
- It is the programmer responsibility not to make strong references to the object itself. For example:
public class House {
User user = null; // WRONG !!!!
}
public class House {
PassivationObj user = null; // RIGHT !!!!
}
|
PassivationObj | public PassivationObj(Object obj)(Code) | | Creates a PassivationObj for an object.
Parameters: obj - The object to be passivated. |
canPassivate | boolean canPassivate(long n)(Code) | | |
get | public synchronized Object get()(Code) | | Return the object. If the object is passivated it will be activated before it is returned, of course.
The object itself. |
getLastAccessTime | long getLastAccessTime()(Code) | | |
getWithoutActivating | public synchronized Object getWithoutActivating()(Code) | | Return the object without activating it. This will be usefull when the system needs to access the object.
In this situation, there is no need to activate the object.
The object itself. |
hashCode | public int hashCode()(Code) | | |
isPassivated | public synchronized boolean isPassivated()(Code) | | Check if this object is passivated now.
true if this object is passivated |
passivate | synchronized void passivate()(Code) | | |
|
|