com.sas.services
Class AbstractServiceComponentConfig

java.lang.Object
  |
  +--com.sas.services.AbstractServiceComponentConfig
All Implemented Interfaces:
ServiceComponentConfigInterface
Direct Known Subclasses:
InformationServiceInitObject, SessionServiceInitObject, UserServiceInitObject

public abstract class AbstractServiceComponentConfig
extends Object
implements ServiceComponentConfigInterface

Abstract implementation of a foundation service component's configuration.

A concrete subclass must implement the following abstract methods:

Since:
1.1.3

Field Summary
static String ENCODING
          Service configurations are encoded using UTF-8.
static String PROPERTY_NAME_INIT_DATA
          The name of a Property used to represent the service's configuration data.
static String PROPERTYROLE_INITIALIZATION
          Value of a metdata StoredText's Role attribute that designates that the text string is used for initialization purposes.
 
Constructor Summary
protected AbstractServiceComponentConfig(String xmlDocument)
          Constructs a default instance.
protected AbstractServiceComponentConfig(String xmlDocument, boolean isServiceConfigurationUpdateable)
          Constructs an instance specifying whether or not a service manafactured by this factory has a configuration which may be updated in an additive manner.
 
Method Summary
protected abstract  DocumentFragment appendDOM(Document document, AbstractServiceComponentConfig serviceConfig)
          Constructs a document object model representing the configuration data for a foundation service.
protected abstract  AbstractServiceComponentConfig getConfig(Document serviceConfigDocument)
          Gets an object representing the service's configuration data obtained from the specified XML document.
 Document getDocument()
          Gets an XML document representing the foundation service component's configuration.
protected  String[] getServiceClassIdentifiers()
          Gets an the service's class identifiers that are valid for this configuration.
static TextStore getServiceComponentConfigTextStore(ServiceComponent serviceComponent)
          Gets the service component's configuration.
 String getServiceComponentConfiguration(ServiceComponent serviceComponent)
          Gets the service component's configuration.
static String getServiceComponentConfigurationFromTextStore(ServiceComponent serviceComponent)
          Gets the service component's configuration from the service's text store.
protected static Property getServiceConfigProperty(ServiceComponent serviceComponent)
          Gets the service component's property that represents the service's configuration data.
protected abstract  String getServiceFactoryClassName()
          Gets the service factory's fully-qualified Java class name.
protected static Document getTextStoreServiceConfig(ServiceComponent serviceComponent)
          Gets an XML document representation of the service's configuration.
 boolean isConfigurationUpdateable()
          Determines whether or not a foundation services configuration may be updated in an additive manner.
 void mergeConfig(ServiceComponent serviceComponent, Document serviceConfiguration)
          Merges the service's configuration by adding new service configuration to the pre-existing configuration.
 void mergeConfigFromDocument(ServiceComponent serviceComponent, Document serviceConfiguration)
          Merges the service's configuration by adding new service configuration to the pre-existing configuration.
 void mergeConfigFromFile(ServiceComponent serviceComponent, File file)
          Updates the service's configuration by adding new service configuration read from the specified file to the service component's pre-existing configuration.
protected abstract  void mergeConfiguration(AbstractServiceComponentConfig currentConfig, AbstractServiceComponentConfig newConfig)
          Merges the new user service configuration into the current configuration.
 Document readServiceConfigFromFile(File file)
          Read the service's configuration from the specified file.
protected static void setTextStoreServiceConfig(ServiceComponent serviceComponent, Document serviceConfigDocument)
          Updates the service component's text store with the specified service configuration.
protected  void validateServiceComponent(ServiceComponent serviceComponent)
          Determines whether or not the service component is valid.
protected  void validateServiceConfiguration(Node serviceConfiguration)
          Determines whether or not the service configuration is valid for this service component.
protected abstract  void validateServiceConfigurationCustom(Node serviceConfiguration)
          Determines whether or not the service configuration is valid for this service component.
 void writeServiceConfigToFile(File file, ServiceComponent serviceComponent)
          Write the service's configuration to the specified file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENCODING

public static final String ENCODING
Service configurations are encoded using UTF-8.

PROPERTY_NAME_INIT_DATA

public static final String PROPERTY_NAME_INIT_DATA
The name of a Property used to represent the service's configuration data.

PROPERTYROLE_INITIALIZATION

public static final String PROPERTYROLE_INITIALIZATION
Value of a metdata StoredText's Role attribute that designates that the text string is used for initialization purposes. This value is "initialization"
Constructor Detail

AbstractServiceComponentConfig

protected AbstractServiceComponentConfig(String xmlDocument)
Constructs a default instance.

Use this constructor if the service manufactured by the service factory does not permit is configuration to be updated in an additive manner.

Use AbstractServiceComponentConfig(String xmlDocument, boolean isServiceConfigurationUpdateable) to construct an instance specifying whether or not the service's configuration may be updated in an additive manner.

Parameters:
xmlDocument - The XML document used to represent the service component's configuration.
Throws:
IllegalArgumentException - if a null XML document string is specified.

AbstractServiceComponentConfig

protected AbstractServiceComponentConfig(String xmlDocument,
                                         boolean isServiceConfigurationUpdateable)
Constructs an instance specifying whether or not a service manafactured by this factory has a configuration which may be updated in an additive manner.

Use AbstractServiceComponentConfig(String xmlDocument) to construct an instance of a factory which manufactures a service whose configuration may not be updated in an additive manner.

Parameters:
xmlDocument - The XML document used to represent the service component's configuration.
isServiceConfigurationUpdateable - true if the foundation service's configuration may be updated by appending new configuration data which does not conflict with the pre-existing configuration.
Throws:
IllegalArgumentException - if a null XML document string is specified.
Method Detail

getServiceConfigProperty

protected static final Property getServiceConfigProperty(ServiceComponent serviceComponent)
                                                  throws ServiceException
Gets the service component's property that represents the service's configuration data.
Parameters:
serviceComponent - Service component whose configuration data property is desired.
Returns:
Service component's property that represents the service's configuration data or null if a property is not defined.
Throws:
ServiceException - if unable to query the service component's properties.

isConfigurationUpdateable

public boolean isConfigurationUpdateable()
Determines whether or not a foundation services configuration may be updated in an additive manner. A service which supports an additive configuration allows one to update the current configuration with additional configuration data, so long as the added configuration does not conflict with the pre-existing configuration.
Specified by:
isConfigurationUpdateable in interface ServiceComponentConfigInterface
Returns:
true if the foundation service's configuration may be updated by appending new configuration data which does not conflict with the pre-existing configuration.

validateServiceComponent

protected final void validateServiceComponent(ServiceComponent serviceComponent)
                                       throws ServiceConfigurationException,
                                              IllegalArgumentException
Determines whether or not the service component is valid.
Parameters:
serviceComponent - The service component whose configuration data is to be updated.
Throws:
ServiceConfigurationException - if an invalid service component is specified.
IllegalArgumentException - if a null service component is specified.

validateServiceConfiguration

protected final void validateServiceConfiguration(Node serviceConfiguration)
                                           throws ServiceException,
                                                  IllegalArgumentException
Determines whether or not the service configuration is valid for this service component.
Parameters:
serviceConfiguration - The service component's configuration.
Throws:
ServiceException - if an invalid configuration is specified.
IllegalArgumentException - if a null service configuration is specified.

getServiceClassIdentifiers

protected String[] getServiceClassIdentifiers()
Gets an the service's class identifiers that are valid for this configuration. A subclass should override this method if a class identifier other than RemoteServiceInterface.CLASS_IDENTIFIER is employed.
Returns:
Service's class identifier.

mergeConfigFromDocument

public final void mergeConfigFromDocument(ServiceComponent serviceComponent,
                                          Document serviceConfiguration)
                                   throws ServiceException
Merges the service's configuration by adding new service configuration to the pre-existing configuration.

A subclass should override this method if it allows configuration data to be merged into a pre-existing configuration.

Parameters:
serviceComponent - The service whose configuration is to be updated.
serviceConfiguration - The service configuration to be added to the service's current configuration. Note that only configuration data that is additive in nature can be appended. Configuration data that is non-additive will be ignored.
Throws:
ServiceException - if unable to update the service's configuration.
IllegalArgumentException - if a null service component or service configuration is specified.

mergeConfiguration

protected abstract void mergeConfiguration(AbstractServiceComponentConfig currentConfig,
                                           AbstractServiceComponentConfig newConfig)
                                    throws ServiceConfigurationException,
                                           IllegalArgumentException
Merges the new user service configuration into the current configuration.
Parameters:
currentConfig - The current configuration into which the new configuration is to be merged.
newConfig - The new configuration which is to be merged into the current configuration.
Throws:
ServiceConfigurationException - if unable to merge the service configuration.
IllegalArgumentException - if a null current or new configuration is specified.

appendDOM

protected abstract DocumentFragment appendDOM(Document document,
                                              AbstractServiceComponentConfig serviceConfig)
                                       throws ServiceConfigurationException,
                                              IllegalArgumentException
Constructs a document object model representing the configuration data for a foundation service.
Parameters:
document - XML document to which the service's configuration is to be appended.
serviceConfig - Service configuration which is to be converted to an XML document.
Returns:
null since no child document fragments are to be added to the document.
Throws:
ServiceConfigurationException - if unable to create an XML representation of the service's configuration.
IllegalArgumentException - if a null document or service configuration is specified.

validateServiceConfigurationCustom

protected abstract void validateServiceConfigurationCustom(Node serviceConfiguration)
                                                    throws ServiceException
Determines whether or not the service configuration is valid for this service component.
Parameters:
serviceConfiguration - The service component's configuration.
Throws:
ServiceException - if an invalid configuration is specified.

getDocument

public Document getDocument()
                     throws ServiceException
Gets an XML document representing the foundation service component's configuration.
Returns:
Foundation service configuration document.
Throws:
ServiceException - if unable to create a document.

getServiceFactoryClassName

protected abstract String getServiceFactoryClassName()
Gets the service factory's fully-qualified Java class name.
Returns:
Service factory's fully-qualified Java class name.

getConfig

protected abstract AbstractServiceComponentConfig getConfig(Document serviceConfigDocument)
                                                     throws ServiceConfigurationException,
                                                            IllegalArgumentException
Gets an object representing the service's configuration data obtained from the specified XML document.
Parameters:
serviceConfigDocument - Service configuration represented as an XML document.
Returns:
Service's configuration.
Throws:
ServiceConfigurationException - if unable to obtain a configuration from the specified XML document.
IllegalArgumentException - if a null document is specified.

mergeConfig

public void mergeConfig(ServiceComponent serviceComponent,
                        Document serviceConfiguration)
                 throws ServiceException
Merges the service's configuration by adding new service configuration to the pre-existing configuration.
Parameters:
serviceComponent - The service whose configuration is to be merged with the specified configuration.
serviceConfiguration - The service configuration to be added to the service's current configuration. Note that only configuration data that is additive in nature can be appended. Configuration data that is non-additive will be ignored.
Throws:
ServiceException - if unable to update the service's configuration.
IllegalArgumentException - if a null service component or service configuration is specified.

mergeConfigFromFile

public void mergeConfigFromFile(ServiceComponent serviceComponent,
                                File file)
                         throws ServiceException
Updates the service's configuration by adding new service configuration read from the specified file to the service component's pre-existing configuration.
Specified by:
mergeConfigFromFile in interface ServiceComponentConfigInterface
Parameters:
serviceComponent - The service whose configuration is to be updated.
file - File containing the service configuration which is to be added to the service component's current configuration. Note that only configuration data that is additive in nature can be appended. Configuration data that is non-additive will be ignored.
Throws:
ServiceException - if unable to update the service's configuration.
IllegalArgumentException - if a null service component or file is specified.

readServiceConfigFromFile

public Document readServiceConfigFromFile(File file)
                                   throws ServiceException
Read the service's configuration from the specified file.
Parameters:
file - File to which the service's configuration is to be written using UTF-8 encoding.
Returns:
XML Document read from the file.
Throws:
ServiceException - if an exception was encountered persisting the service's configuration to a file.
IllegalArgumentException - if a null file is specified.

writeServiceConfigToFile

public void writeServiceConfigToFile(File file,
                                     ServiceComponent serviceComponent)
                              throws ServiceException
Write the service's configuration to the specified file.
Specified by:
writeServiceConfigToFile in interface ServiceComponentConfigInterface
Parameters:
file - File to which the service's configuration is to be written using UTF-8 encoding.
serviceComponent - Service component whose configuration is to be written to the specified file.
Throws:
ServiceException - if an exception was encountered persisting the service's configuration to a file.
IllegalArgumentException - if a null service component or file is specified.

getServiceComponentConfiguration

public String getServiceComponentConfiguration(ServiceComponent serviceComponent)
                                        throws ServiceException
Gets the service component's configuration.

This implementation locates the service component's property named PROPERTY_NAME_INIT_DATA, verifies that the property's text role is PROPERTYROLE_INITIALIZATION, and then obtains the property's stored text configuration.

If a service persists its configuration data in another manner, then this method should be overridden to provide an appropriate mechanism to obtain the service's configuration.

Parameters:
serviceComponent - Service whose configuration is to be obtained.
Returns:
Service's configuration.
Throws:
ServiceException - if unable to obtain the service's configuration.

getServiceComponentConfigurationFromTextStore

public static final String getServiceComponentConfigurationFromTextStore(ServiceComponent serviceComponent)
                                                                  throws ServiceException
Gets the service component's configuration from the service's text store.

This implementation locates the service component's property named PROPERTY_NAME_INIT_DATA, verifies that the property's text role is PROPERTYROLE_INITIALIZATION, and then obtains the property's stored text configuration.

Parameters:
serviceComponent - Service whose configuration is to be obtained.
Returns:
Service's configuration.
Throws:
ServiceException - if unable to obtain the service's configuration.

getServiceComponentConfigTextStore

public static final TextStore getServiceComponentConfigTextStore(ServiceComponent serviceComponent)
                                                          throws ServiceException
Gets the service component's configuration.

This implementation locates the service component's property named PROPERTY_NAME_INIT_DATA, verifies that the property's text role is PROPERTYROLE_INITIALIZATION, and then obtains the property's stored text configuration.

If a service persists its configuration data in another manner, then this method should be overridden to provide an appropriate mechanism to obtain the service's configuration.

Parameters:
serviceComponent - Service whose configuration is to be obtained.
Returns:
Service's configuration text store.
Throws:
ServiceException - if unable to obtain the service's configuration.

getTextStoreServiceConfig

protected static Document getTextStoreServiceConfig(ServiceComponent serviceComponent)
                                             throws ServiceException
Gets an XML document representation of the service's configuration. This implemenation reads the stored text associated with a service component property named PROPERTY_NAME_INIT_DATA.

A subclass should override this method if it does not persist its configuration using the PROPERTY_NAME_INIT_DATA property of the service component.

Parameters:
serviceComponent - The service component from which an XML document representation of its configuration is to be obtained.
Returns:
XML document representation of the service's configuration.
Throws:
ServiceException - if unable to obtain an XML document representation of the service's configuration.

setTextStoreServiceConfig

protected static final void setTextStoreServiceConfig(ServiceComponent serviceComponent,
                                                      Document serviceConfigDocument)
                                               throws ServiceException
Updates the service component's text store with the specified service configuration.
Parameters:
serviceComponent - Service component's whose text store is to be updated.
serviceConfigDocument - Service's configuration data which will be used to update the text store.
Throws:
ServiceException - if unable to update the text store.




Copyright © 2006 SAS Institute Inc. All Rights Reserved.
javadoc generated Fri, 10 Feb 2006 17:28:52