appl.data
Class LateLoadingProxy

java.lang.Object
  extended by appl.data.LateLoadingProxy
All Implemented Interfaces:
DataProxy, Serializable
Direct Known Subclasses:
WritableGridLLProxy

public class LateLoadingProxy
extends Object
implements DataProxy, Serializable

Loads an object on demand with the help of an DataLoader. The unload() method unloads a serializable Object into a temporary folder on the hard disk. Unloading can be disabled via the setUnloading(boolean) method.

Author:
Dominik Appl
See Also:
DataLoader, Serialized Form

Field Summary
protected  Object baseObject
           
protected  DataLoader dataLoader
           
protected  DataLoader intialDataLoader
          The loader which constructs the object
protected  boolean loaded
          Object loaded?
protected  Logger LOG
           
 
Constructor Summary
LateLoadingProxy(DataLoader loader)
          Creates a new instance with the specified data loader
 
Method Summary
 Object getProxiedObject()
          returns the baseObject
protected  File getUnloadFile()
          returns the File, in which the object is/will be unloaded
 boolean isLateLoadable()
          This class supports late loading, of course.
 boolean isLoaded()
          returns true, if the baseObject is loaded
 boolean isUnloadingEnabled()
           
 void loadData()
          Loads the data into memory (if not already loaded).
 void setUnloadDir(String newUnloadDirectory)
           
 void setUnloading(boolean unloadingEnabled)
          Set to false, if you want to disable the unloading in a temporary file
 void unloadData()
          If no Data is loaded or unloading is disabled this method does nothing, else it saves the Data into a temporary File.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected final transient Logger LOG

loaded

protected boolean loaded
Object loaded?


dataLoader

protected transient DataLoader dataLoader

intialDataLoader

protected transient DataLoader intialDataLoader
The loader which constructs the object


baseObject

protected Object baseObject
Constructor Detail

LateLoadingProxy

public LateLoadingProxy(DataLoader loader)
Creates a new instance with the specified data loader

Parameters:
loader - the load method of the DataLoader is called for loading
Method Detail

getUnloadFile

protected File getUnloadFile()
returns the File, in which the object is/will be unloaded


loadData

public void loadData()
              throws LoadingException
Loads the data into memory (if not already loaded).
This method is thread-safe

Throws:
LoadingException

unloadData

public void unloadData()
If no Data is loaded or unloading is disabled this method does nothing, else it saves the Data into a temporary File.
Warning: Should be Thread-Safe with loadData, but was not tested


isLateLoadable

public boolean isLateLoadable()
This class supports late loading, of course.

Returns:
true;
See Also:
appl.data.LateLoadable#unloadData(), appl.data.LateLoadable#isLateLoadable()

getProxiedObject

public Object getProxiedObject()
returns the baseObject

Specified by:
getProxiedObject in interface DataProxy
See Also:
DataProxy.getProxiedObject()

isLoaded

public boolean isLoaded()
returns true, if the baseObject is loaded


setUnloadDir

public void setUnloadDir(String newUnloadDirectory)

setUnloading

public void setUnloading(boolean unloadingEnabled)
Set to false, if you want to disable the unloading in a temporary file


isUnloadingEnabled

public boolean isUnloadingEnabled()
Returns:
true, if unloading is enabled