org.codehaus.cargo.container.spi.configuration.builder
Class AbstractStandaloneLocalConfigurationWithXMLConfigurationBuilder

java.lang.Object
  extended by org.codehaus.cargo.util.log.LoggedObject
      extended by org.codehaus.cargo.container.spi.configuration.AbstractConfiguration
          extended by org.codehaus.cargo.container.spi.configuration.AbstractLocalConfiguration
              extended by org.codehaus.cargo.container.spi.configuration.AbstractStandaloneLocalConfiguration
                  extended by org.codehaus.cargo.container.spi.configuration.builder.AbstractStandaloneLocalConfigurationWithXMLConfigurationBuilder
All Implemented Interfaces:
Configuration, DataSourceSupport, ResourceSupport, LocalConfiguration, StandaloneLocalConfiguration, ContainerConfiguration, Loggable

public abstract class AbstractStandaloneLocalConfigurationWithXMLConfigurationBuilder
extends AbstractStandaloneLocalConfiguration
implements DataSourceSupport, ResourceSupport

Convenience class that simplifies development of configurations with DataSourceSupport. It does this by implementing DataSourceSupport and instead asking for the inputs to this:

  1. createConfigurationBuilder: how do we generate the xml element(s) representing the datasource
  2. getXpathForDataSourcesParent: under which element should datasource elements be inserted?
  3. getNamespaces: does this configuration file use namespaces?
  4. getDataSourceConfigurationFile: where do we load and store the datasource configuration?

Version:
$Id: $

Field Summary
 
Fields inherited from class org.codehaus.cargo.container.spi.configuration.AbstractLocalConfiguration
RESOURCE_PATH
 
Constructor Summary
AbstractStandaloneLocalConfigurationWithXMLConfigurationBuilder(java.lang.String dir)
          
 
Method Summary
 void configure(DataSource ds, LocalContainer container)
          
 void configure(LocalContainer container)
          Configure the specified container.
 void configure(Resource ds, LocalContainer container)
          
 void configureDataSources(LocalContainer container)
          Configure the DataSources defined for this configuration.
 void configureResources(LocalContainer container)
          Configure the Resources defined for this configuration.
protected abstract  ConfigurationBuilder createConfigurationBuilder(LocalContainer container)
           
protected abstract  java.util.Map getNamespaces()
          Implementations should avoid passing null, and instead pass Collections.EMPTY_MAP, if the document is DTD bound.
protected abstract  java.lang.String getOrCreateDataSourceConfigurationFile(DataSource ds, LocalContainer container)
          note that this file could hold other configuration besides datasources.
protected abstract  java.lang.String getOrCreateResourceConfigurationFile(Resource resource, LocalContainer container)
          note that this file could hold other configuration besides Resources.
protected abstract  java.lang.String getXpathForDataSourcesParent()
          DataSource entries must be stored in the xml configuration file.
protected abstract  java.lang.String getXpathForResourcesParent()
          Resource entries must be stored in the xml configuration file.
protected  void writeConfigurationToXpath(java.lang.String file, java.lang.String xml, java.lang.String path)
          Utility method used to write XML to an appropriate place in the configuration file.
 
Methods inherited from class org.codehaus.cargo.container.spi.configuration.AbstractStandaloneLocalConfiguration
configureFiles, createFilterChain, getDestDirectoryLocation, getDestFileLocation, getFileProperties, getFilterChain, getType, setConfigFileProperty, setFileProperty, setupConfigurationDir, verify
 
Methods inherited from class org.codehaus.cargo.container.spi.configuration.AbstractLocalConfiguration
addDataSource, addDataSourcesFromProperties, addDeployable, addResource, addResourcesFromProperties, collectUnsupportedDataSourcesAndThrowException, collectUnsupportedResourcesAndThrowException, doConfigure, getAntUtils, getDataSources, getDeployables, getFileHandler, getHome, getResources, getResourceUtils, parsePropertiesForPendingConfiguration, setFileHandler
 
Methods inherited from class org.codehaus.cargo.container.spi.configuration.AbstractConfiguration
getProperties, getPropertyValue, setProperty
 
Methods inherited from class org.codehaus.cargo.util.log.LoggedObject
getLogger, setLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.codehaus.cargo.container.configuration.LocalConfiguration
addDeployable, addResource, getDeployables, getFileHandler, getHome, getResources, setFileHandler
 
Methods inherited from interface org.codehaus.cargo.container.configuration.Configuration
getCapability, getProperties, getPropertyValue, setProperty
 
Methods inherited from interface org.codehaus.cargo.util.log.Loggable
getLogger, setLogger
 

Constructor Detail

AbstractStandaloneLocalConfigurationWithXMLConfigurationBuilder

public AbstractStandaloneLocalConfigurationWithXMLConfigurationBuilder(java.lang.String dir)

Parameters:
dir - configuration home
Method Detail

getNamespaces

protected abstract java.util.Map getNamespaces()
Implementations should avoid passing null, and instead pass Collections.EMPTY_MAP, if the document is DTD bound.

Returns:
a map of prefixes to the url namespaces used in the datasource configuration file.

getXpathForDataSourcesParent

protected abstract java.lang.String getXpathForDataSourcesParent()
DataSource entries must be stored in the xml configuration file. Under which element do we insert the entries? example: //Engine/DefaultContext

Returns:
path the the parent element datasources should be inserted under.

getXpathForResourcesParent

protected abstract java.lang.String getXpathForResourcesParent()
Resource entries must be stored in the xml configuration file. Under which element do we insert the entries? example: //Engine/DefaultContext

Returns:
path the the parent element Resources should be inserted under.

getOrCreateDataSourceConfigurationFile

protected abstract java.lang.String getOrCreateDataSourceConfigurationFile(DataSource ds,
                                                                           LocalContainer container)
note that this file could hold other configuration besides datasources.

Parameters:
ds - the DataSource configuration you wish to install on the container.
container - the container whose configuration you wish to affect.
Returns:
the file that holds datasource configuration.

getOrCreateResourceConfigurationFile

protected abstract java.lang.String getOrCreateResourceConfigurationFile(Resource resource,
                                                                         LocalContainer container)
note that this file could hold other configuration besides Resources.

Parameters:
resource - the Resource configuration you wish to install on the container.
container - the container whose configuration you wish to affect.
Returns:
the file that holds Resource configuration.

createConfigurationBuilder

protected abstract ConfigurationBuilder createConfigurationBuilder(LocalContainer container)
Parameters:
container - Container the dataSource will be configured on.
Returns:
the object that produces xml entries for DataSource definitions.

configure

public void configure(LocalContainer container)
Configure the specified container.

Specified by:
configure in interface LocalConfiguration
Overrides:
configure in class AbstractStandaloneLocalConfiguration
Parameters:
container - the container to configure
See Also:
LocalConfiguration.configure(LocalContainer)

configureDataSources

public void configureDataSources(LocalContainer container)
Configure the DataSources defined for this configuration.

Specified by:
configureDataSources in interface DataSourceSupport
Parameters:
container - the container whose configuration you wish to affect.

configure

public void configure(Resource ds,
                      LocalContainer container)

Specified by:
configure in interface ResourceSupport
Parameters:
ds - the Resource configuration you wish to install on the container.
container - the container whose configuration you wish to affect.

configureResources

public void configureResources(LocalContainer container)
Configure the Resources defined for this configuration.

Specified by:
configureResources in interface ResourceSupport
Parameters:
container - the container whose configuration you wish to affect.

configure

public void configure(DataSource ds,
                      LocalContainer container)

Specified by:
configure in interface DataSourceSupport
Parameters:
ds - the DataSource configuration you wish to install on the container.
container - the container whose configuration you wish to affect.

writeConfigurationToXpath

protected void writeConfigurationToXpath(java.lang.String file,
                                         java.lang.String xml,
                                         java.lang.String path)
Utility method used to write XML to an appropriate place in the configuration file.

Parameters:
file - where to write the datasource configuration to.
xml - node you wish to write to the resources configuration file.
path - where in the file to write the configuration.


Copyright © 2004-2011 Codehaus. All Rights Reserved.