org.lightwolf
Class FileProcess

java.lang.Object
  extended by org.lightwolf.Process
      extended by org.lightwolf.FileProcess
All Implemented Interfaces:
Serializable

public class FileProcess
extends Process

A process that stores data on a file.

Author:
Fernando Colombo
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.lightwolf.Process
ACTIVE, PASSIVE, state
 
Constructor Summary
FileProcess(File file)
           
FileProcess(ProcessManager manager, File file)
           
FileProcess(ProcessManager manager, String fileName)
           
FileProcess(String fileName)
           
 
Method Summary
protected  void discardData()
          Called to indicate that the stored data is not necessary anymore.
protected  Object loadData()
          Called by Process.activate() to retrieve data stored by Process.storeData(Object).
protected  void storeData(Object data)
          Called by Process.passivate() to store data on some media.
 
Methods inherited from class org.lightwolf.Process
accept, acceptMany, activate, activeFlows, addEventListener, call, connect, connectMany, current, getFlows, getState, notify, notifyAll, passivate, receive, receiveMany, removeEventListener, safeCurrent, send, serve, serveMany, stateName, suspendedFlows, wait, waitMany
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileProcess

public FileProcess(ProcessManager manager,
                   File file)

FileProcess

public FileProcess(File file)

FileProcess

public FileProcess(ProcessManager manager,
                   String fileName)

FileProcess

public FileProcess(String fileName)
Method Detail

storeData

protected void storeData(Object data)
                  throws IOException
Description copied from class: Process
Called by Process.passivate() to store data on some media. The default implementation throws IllegalStateException indicating that the process cannot be passivated.

This method must be implemented along with Process.loadData() and Process.discardData() by subclasses that support long-running-processes. The implementation must associate the informed data with this process. This method might be called more than once. Any data stored by the previous invocation to this method must be discarded.

This method typically serializes the informed data object, so that an unserialized version is returned by the next call to Process.loadData().

Overrides:
storeData in class Process
Parameters:
data - A serializable object to be stored on some media.
Throws:
IOException - If some error happens during access to storage.

loadData

protected Object loadData()
                   throws IOException,
                          ClassNotFoundException
Description copied from class: Process
Called by Process.activate() to retrieve data stored by Process.storeData(Object). The default implementation throws AssertionError.

This method must be implemented along with Process.storeData(Object) and Process.discardData() by subclasses that support long-running-processes. This method must not discard data from the storage.

Overrides:
loadData in class Process
Returns:
A serializable object that was read from storage.
Throws:
IOException - If some error happens during access to storage.
ClassNotFoundException - If the system can't find a class for a serialized object while assembling the result.

discardData

protected void discardData()
                    throws IOException
Description copied from class: Process
Called to indicate that the stored data is not necessary anymore. The default implementation throws AssertionError.

This method must be implemented along with Process.storeData(Object) and Process.loadData() by subclasses that support long-running-processes. This method must simply discard data from the storage.

Overrides:
discardData in class Process
Throws:
IOException - If some error happens during the storage access.