uk.org.ogsadai.activity
Class ActivityFactoryImpl

java.lang.Object
  |
  +--uk.org.ogsadai.activity.ActivityFactoryImpl
All Implemented Interfaces:
ActivityFactory, PropertyCallback

public class ActivityFactoryImpl
extends java.lang.Object
implements ActivityFactory, PropertyCallback

Class that provided the implementation of an activity factory. The configuration of this class specifies which activities are supported by a data service. It also specifies the implementation class and their schemas and well as activity properties and activity specific configuration.

Author:
The OGSA-DAI Project Team

Field Summary
private static java.lang.String COPYRIGHT_NOTICE
          Copyright statement.
private static DAILogger LOG
          Logger object for logging in this class
private  java.util.Map mActivityMap
          Maps StringActivityCreator objects
private  ActivityTypesDocumentCreator mActivityTypes
          Used to construct the activityTypes property
private  org.w3c.dom.Document mSchema
          Perform document schema
private  DocumentValidator mValidator
          Validation chain for perform documents
 
Constructor Summary
ActivityFactoryImpl(ActivitiesConfig config)
          Constructs an ActivityFactory.
 
Method Summary
private  org.w3c.dom.Document buildPerformDocumentSchema(org.w3c.dom.Document baseSchema, ActivityConfig[] activityConfigs)
          Constructs the perform document schema dynamically from the activity schemas.
 Activity[] createActivities(org.w3c.dom.Document document)
          Constructs the activity implementations for each of the activity elements contained in the given perform document.
private  Activity createActivity(org.w3c.dom.Element element)
          Creates an Activity instance using an ActivityCreator.
private  java.util.Map createActivityMap(ActivityConfig[] activityConfigs)
          Creates an activity map.
 Property[] getProperties()
          Returns the resource properties associated with the supported activities.
 java.lang.Object getValue(javax.xml.namespace.QName name)
          Return the value of the property with the given name.
private  void parseChildren(org.w3c.dom.Node root, java.util.List list)
          Recursively parses the children of the specified node of a perform document, creating activities as their specifications are encountered and adding these to a list.
 void setSecurityContext(SecurityContext sec)
          Set a security context to be used if authorisation needs to be done when get/setting the value.
 void setValue(javax.xml.namespace.QName name, java.lang.Object value)
          Set the value of the property with the given name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPYRIGHT_NOTICE

private static final java.lang.String COPYRIGHT_NOTICE
Copyright statement.

See Also:
Constant Field Values

LOG

private static final DAILogger LOG
Logger object for logging in this class


mActivityMap

private final java.util.Map mActivityMap
Maps StringActivityCreator objects


mActivityTypes

private final ActivityTypesDocumentCreator mActivityTypes
Used to construct the activityTypes property


mValidator

private final DocumentValidator mValidator
Validation chain for perform documents


mSchema

private org.w3c.dom.Document mSchema
Perform document schema

Constructor Detail

ActivityFactoryImpl

public ActivityFactoryImpl(ActivitiesConfig config)
Constructs an ActivityFactory.

Parameters:
config - Configuration details of supported activities - their names, implementation classes and configurations.
Throws:
java.lang.IllegalArgumentException - If config is null.
Method Detail

createActivities

public Activity[] createActivities(org.w3c.dom.Document document)
                            throws DocumentValidationException,
                                   ActivitySpecificationException,
                                   ActivityCreationException
Description copied from interface: ActivityFactory
Constructs the activity implementations for each of the activity elements contained in the given perform document.

Specified by:
createActivities in interface ActivityFactory
Parameters:
document - The perform document containing the element to use to create the activities.
Returns:
an array of Activity objects.
Throws:
DocumentValidationException - If the perform document as a whole is in some way invalid e.g. contains unsupported pipes or unsupported activities.
ActivitySpecificationException - If a client mistake prevents one or more activities from being constructed successfully. This may be raised in either of the following circumstances:
  • one or more of the activities described in the perform document are unsupported by this factory
  • a required element or attribute has been omitted from an activity element in a perform document
ActivityCreationException - If there is some problem that prevents an activity being created. This is typically caused by a configuration or programming error.

parseChildren

private void parseChildren(org.w3c.dom.Node root,
                           java.util.List list)
                    throws DocumentValidationException,
                           ActivitySpecificationException,
                           ActivityCreationException
Recursively parses the children of the specified node of a perform document, creating activities as their specifications are encountered and adding these to a list.

Parameters:
root - Node from a perform document.
list - List of Activity objects.
Throws:
DocumentValidationException - If the perform document as a whole is in some way invalid.
ActivitySpecificationException - If a client mistake prevents one or more activities from being constructed successfully. This may be raised in either of the following circumstances:
  • one or more of the activities described in the perform document are unsupported by this factory
  • a required element or attribute has been omitted from an activity element in a perform document
ActivityCreationException - If there is some problem that prevents an activity being created. This is typically caused by a configuration or programming error.
java.lang.IllegalArgumentException - If the document is null.
See Also:
createActivity(org.w3c.dom.Element)

createActivity

private Activity createActivity(org.w3c.dom.Element element)
                         throws ActivitySpecificationException,
                                ActivityCreationException
Creates an Activity instance using an ActivityCreator.

Parameters:
element - Element from a perform document containing a specific activity.
Returns:
Activity.
Throws:
java.lang.IllegalArgumentException - If element is null.
ActivitySpecificationException - If a client mistake prevents the activity from being constructed successfully. This may be raised in either of the following circumstances:
  • the activity is unsupported by this factory
  • .
  • a required element or attribute has been omitted from an activity element in a perform document
ActivityCreationException - If there is some problem that prevents an activity being created. This is typically caused by a configuration or programming error.

createActivityMap

private java.util.Map createActivityMap(ActivityConfig[] activityConfigs)
Creates an activity map. This maps activity names to an ActivityCreator for activity.

Parameters:
activityConfigs - Array of configuration details for each activity.
Returns:
the activity map.

buildPerformDocumentSchema

private org.w3c.dom.Document buildPerformDocumentSchema(org.w3c.dom.Document baseSchema,
                                                        ActivityConfig[] activityConfigs)
Constructs the perform document schema dynamically from the activity schemas.

Parameters:
baseSchema - Base perform document schema
activityConfigs - Configuration details of each activity - this includes the schema for each activity.
Returns:
schema document for perform documents.

getProperties

public Property[] getProperties()
Returns the resource properties associated with the supported activities. These resource properties will be available to clients via the resource properties query functionality.

Specified by:
getProperties in interface ActivityFactory
Returns:
resource properties.

getValue

public java.lang.Object getValue(javax.xml.namespace.QName name)
                          throws PropertyValueException
Description copied from interface: PropertyCallback
Return the value of the property with the given name.

Specified by:
getValue in interface PropertyCallback
Parameters:
name - Property name.
Returns:
property value
Throws:
PropertyValueException - if a problem occurs.

setValue

public void setValue(javax.xml.namespace.QName name,
                     java.lang.Object value)
Description copied from interface: PropertyCallback
Set the value of the property with the given name.

Specified by:
setValue in interface PropertyCallback
Parameters:
name - Property name.
value - Property value.

setSecurityContext

public void setSecurityContext(SecurityContext sec)
Description copied from interface: PropertyCallback
Set a security context to be used if authorisation needs to be done when get/setting the value.

Specified by:
setSecurityContext in interface PropertyCallback
Parameters:
sec - Security context.