uk.org.ogsadai.persistence.file.activity
Class SimpleFileActivitySpecDAO

java.lang.Object
  extended by uk.org.ogsadai.persistence.file.SimpleFileDAO
      extended by uk.org.ogsadai.persistence.file.activity.SimpleFileActivitySpecDAO
All Implemented Interfaces:
java.util.EventListener, ActivityEventListener, ActivitySpecDAO, DAO, FilePersistenceConfiguration

public class SimpleFileActivitySpecDAO
extends SimpleFileDAO
implements ActivitySpecDAO, ActivityEventListener

This class manages the persistence of activity-related information within configuration files. It populates objects with state from persistence media and also persists state represented by objects. The DAO records itself as a listener to any ActivitySpec objects it provides or is given and, depending upon the persistence policy in place, will react to changes in the activity specification and persist such changes. The activity-related file is expected to be called activties.txt and be within a configuration directory provided to this class. The file is expected to have the following format:

 # Activity ID
 # A value compliant with the format of uk.org.ogsadai.activity.ActivityID.
 id=ACTIVITY-ID
 # Activity implementation class name.
 class=ACTIVITY-CLASS
 # Human-readable description.
 description=ACTIVITY-DESCRIPTION
 CONFIG
 # Activity configuration - specific to implementation class.
 # Zero or more key-value properties.
 # Key must be compliant with uk.org.ogsadai.common.Key.
 # Value can be a string, boolean or number.
 KEY1=VALUE1
 KEY2=VALUE2
 KEY3=VALUE3
 ...
 END
 ...
 
For example:
 id=uk.org.ogsadai.SQLQueryActivity
 class=uk.org.ogsadai.activity.sql.SQLQueryActivity
 description=A standard SQL query activity.
 CONFIG
 default.fetch.size=1234
 max.fetch.size=5678
 END
 id=uk.org.ogsadai.XSLTransformActivity
 class=uk.org.ogsadai.activity.transform.XSLTransformActivity
 description=An XSL transform activity.
 CONFIG
 END
 ...
 

This class does not support auto-detection of changes to configuration files.

Author:
The OGSA-DAI Project Team

Field Summary
 
Fields inherited from class uk.org.ogsadai.persistence.file.SimpleFileDAO
mConfigDir, mFileUtils
 
Constructor Summary
SimpleFileActivitySpecDAO()
          Constructor.
SimpleFileActivitySpecDAO(java.io.File configDir)
          Constructor.
 
Method Summary
 void activityUpdated(ActivityUpdateEvent event)
          Inform a component that an activity-related component changed state.
 void deleteActivitySpec(ActivityID activityID)
          Delete the specification of an activity.
 ActivitySpec getActivitySpec(ActivityID activityID)
          This class will register itself as a listener for changes in the ActivitySpec returned.
 boolean hasPersistedStateChanged(ActivityID activityID)
          This class does not support auto-detection of changes to configuration files.
 void insertActivitySpec(ActivitySpec activitySpec)
          If activitySpec implements ActivityEventDispatcher then this class will register itself as a listener.
 boolean isActivityKnown(ActivityID activityID)
          Is an activity recorded in the persistence media?
 java.util.List listActivities()
          Get a list of activities persisted in the persistence media.
 void setConfigDir(java.io.File configDir)
          Set the configuration directory.
 
Methods inherited from class uk.org.ogsadai.persistence.file.SimpleFileDAO
getConfigDir
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleFileActivitySpecDAO

public SimpleFileActivitySpecDAO()
Constructor.


SimpleFileActivitySpecDAO

public SimpleFileActivitySpecDAO(java.io.File configDir)
Constructor.

Parameters:
configDir - Configuration directory
Throws:
java.lang.IllegalArgumentException - If configDir is null.
Method Detail

setConfigDir

public void setConfigDir(java.io.File configDir)
Description copied from interface: FilePersistenceConfiguration
Set the configuration directory.

Specified by:
setConfigDir in interface FilePersistenceConfiguration
Overrides:
setConfigDir in class SimpleFileDAO
Parameters:
configDir - Configuration directory.

listActivities

public java.util.List listActivities()
                              throws PersistenceException
Description copied from interface: ActivitySpecDAO
Get a list of activities persisted in the persistence media.

Specified by:
listActivities in interface ActivitySpecDAO
Returns:
List<ActivityID>
Throws:
PersistenceException - If any problems arise when interacting with the persistence media.

isActivityKnown

public boolean isActivityKnown(ActivityID activityID)
                        throws PersistenceException
Description copied from interface: ActivitySpecDAO
Is an activity recorded in the persistence media?

Specified by:
isActivityKnown in interface ActivitySpecDAO
Parameters:
activityID - Activity ID
Returns:
true if the activity is known.
Throws:
java.lang.IllegalArgumentException - If activityID is null.
PersistenceException - If any problems arise when interacting with the persistence media.

getActivitySpec

public ActivitySpec getActivitySpec(ActivityID activityID)
                             throws ActivityUnknownException,
                                    PersistenceException
This class will register itself as a listener for changes in the ActivitySpec returned.

Specified by:
getActivitySpec in interface ActivitySpecDAO
Parameters:
activityID - Activity ID
Returns:
activity specification.
Throws:
java.lang.IllegalArgumentException - If activityID is null.
ActivityUnknownException - If the activity is unknown i.e. not recorded in the persistence media.
PersistenceException - If any problems arise when interacting with the persistence media.

deleteActivitySpec

public void deleteActivitySpec(ActivityID activityID)
                        throws PersistenceException
Description copied from interface: ActivitySpecDAO
Delete the specification of an activity.

Specified by:
deleteActivitySpec in interface ActivitySpecDAO
Parameters:
activityID - Activity ID
Throws:
java.lang.IllegalArgumentException - If activitySpec is null.
PersistenceException - If any problems arise when interacting with the persistence media.

insertActivitySpec

public void insertActivitySpec(ActivitySpec activitySpec)
                        throws PersistenceException
If activitySpec implements ActivityEventDispatcher then this class will register itself as a listener.

Specified by:
insertActivitySpec in interface ActivitySpecDAO
Parameters:
activitySpec - Activity specification
Throws:
java.lang.IllegalArgumentException - If activitySpec is null.
PersistenceException - If any problems arise when interacting with the persistence media.

activityUpdated

public void activityUpdated(ActivityUpdateEvent event)
Description copied from interface: ActivityEventListener
Inform a component that an activity-related component changed state.

Specified by:
activityUpdated in interface ActivityEventListener
Parameters:
event - Information on the update.
Throws:
java.lang.IllegalArgumentException - If event is null.
PersistenceException - If any problems arise when interacting with the persistence media.

hasPersistedStateChanged

public boolean hasPersistedStateChanged(ActivityID activityID)
                                 throws PersistenceException
This class does not support auto-detection of changes to configuration files.

Specified by:
hasPersistedStateChanged in interface ActivitySpecDAO
Parameters:
activityID - Activity ID
Returns:
false always.
Throws:
PersistenceException - If any problems arise when interacting with the persistence media.