org.codehaus.cargo.container.spi.configuration
Class AbstractLocalConfiguration

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
All Implemented Interfaces:
Configuration, LocalConfiguration, ContainerConfiguration, Loggable
Direct Known Subclasses:
AbstractExistingLocalConfiguration, AbstractStandaloneLocalConfiguration

public abstract class AbstractLocalConfiguration
extends AbstractConfiguration
implements LocalConfiguration

Base implementation of ContainerConfiguration that can be specialized for standalone configuration, existing configuration or other local configurations.

Version:
$Id: AbstractLocalConfiguration.java 1886 2009-02-13 15:23:09Z adriancole $

Field Summary
protected static java.lang.String RESOURCE_PATH
          The path under which the container resources are stored in the JAR.
 
Constructor Summary
AbstractLocalConfiguration(java.lang.String home)
           
 
Method Summary
 void addDataSource(DataSource dataSource)
          
protected  void addDataSourcesFromProperties()
          Parse properties and add any DataSources to pending configuration.
 void addDeployable(Deployable newDeployable)
          Deploy a Deployable in the container.
 void addResource(Resource resource)
          Add resources the container can take advantage of.
protected  void addResourcesFromProperties()
          Parse properties and add any Resources to pending configuration.
 void collectUnsupportedDataSourcesAndThrowException()
          Warn user and throw an Exception if any unsupported DataSources are setup for this configuration.
 void collectUnsupportedResourcesAndThrowException()
          Warn user and throw an Exception if any unsupported Resources are setup for this configuration.
 void configure(LocalContainer container)
          Setup the container which means setting up a valid directory structure, setting up configuration files and deploying static deployables.
protected abstract  void doConfigure(LocalContainer container)
          Implementation of LocalConfiguration.configure(LocalContainer) that all local configuration using this class must implement.
protected  AntUtils getAntUtils()
           
 java.util.List getDataSources()
           
 java.util.List getDeployables()
          
 FileHandler getFileHandler()
           
 java.lang.String getHome()
          
 java.util.List getResources()
           
protected  ResourceUtils getResourceUtils()
           
 void parsePropertiesForPendingConfiguration()
          Some configuration can be specified as encoded properties.
 void setFileHandler(FileHandler fileHandler)
           
 void verify()
          Verify that the configuration is valid.
 
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.Configuration
getCapability, getProperties, getPropertyValue, getType, setProperty
 
Methods inherited from interface org.codehaus.cargo.util.log.Loggable
getLogger, setLogger
 

Field Detail

RESOURCE_PATH

protected static final java.lang.String RESOURCE_PATH
The path under which the container resources are stored in the JAR.

See Also:
Constant Field Values
Constructor Detail

AbstractLocalConfiguration

public AbstractLocalConfiguration(java.lang.String home)
Parameters:
home - the home directory where the container will be set up to start and where it will deploy its deployables.
Method Detail

getFileHandler

public FileHandler getFileHandler()
Specified by:
getFileHandler in interface LocalConfiguration
Returns:
the file utility class to use for performing all file I/O.

setFileHandler

public void setFileHandler(FileHandler fileHandler)
Specified by:
setFileHandler in interface LocalConfiguration
Parameters:
fileHandler - the file utility class to use for performing all file I/O.

getAntUtils

protected final AntUtils getAntUtils()
Returns:
the Ant utility class

getResourceUtils

protected final ResourceUtils getResourceUtils()
Returns:
the Resource utility class

addDeployable

public void addDeployable(Deployable newDeployable)
Deploy a Deployable in the container. It installs the Deployable in the container's configuration directory.

Specified by:
addDeployable in interface LocalConfiguration
Parameters:
newDeployable - the Deployable to deploy
See Also:
LocalConfiguration.addDeployable(org.codehaus.cargo.container.deployable.Deployable)

getDeployables

public java.util.List getDeployables()

Specified by:
getDeployables in interface LocalConfiguration
Returns:
the list of Deployables that are going to be deployed in the container when it is started
See Also:
LocalConfiguration.getDeployables()

getHome

public java.lang.String getHome()

Specified by:
getHome in interface LocalConfiguration
Returns:
the configuration home directory. Note that we're returning a String instead of a File because we want to leave the possibility of using URIs for specifying the home location.
See Also:
LocalConfiguration.getHome()

configure

public void configure(LocalContainer container)
Setup the container which means setting up a valid directory structure, setting up configuration files and deploying static deployables.

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

verify

public void verify()
Verify that the configuration is valid. The checks to be performed may vay whether this is standalone or existing configuration. This method should also be used to verify that the configuration properties specified by the user are valid and that the required ones are set.

Specified by:
verify in interface ContainerConfiguration
Overrides:
verify in class AbstractConfiguration
See Also:
ContainerConfiguration.verify()

collectUnsupportedResourcesAndThrowException

public void collectUnsupportedResourcesAndThrowException()
Warn user and throw an Exception if any unsupported Resources are setup for this configuration.


collectUnsupportedDataSourcesAndThrowException

public void collectUnsupportedDataSourcesAndThrowException()
Warn user and throw an Exception if any unsupported DataSources are setup for this configuration.


parsePropertiesForPendingConfiguration

public void parsePropertiesForPendingConfiguration()
Some configuration can be specified as encoded properties. Parse properties and apply what is found to the appropriate pending configuration list.


addResourcesFromProperties

protected void addResourcesFromProperties()
Parse properties and add any Resources to pending configuration. Resources will be found if their property name starts with: ResourcePropertySet.RESOURCE


addDataSourcesFromProperties

protected void addDataSourcesFromProperties()
Parse properties and add any DataSources to pending configuration. DataSources will be found if their property name starts with: DatasourcePropertySet.DATASOURCE


doConfigure

protected abstract void doConfigure(LocalContainer container)
                             throws java.lang.Exception
Implementation of LocalConfiguration.configure(LocalContainer) that all local configuration using this class must implement. This provides the ability to perform generic actions before and after the container-specific implementation. Another way would be to use AOP...

Parameters:
container - the container to configure
Throws:
java.lang.Exception - if any error is raised during the configuration

addResource

public void addResource(Resource resource)
Add resources the container can take advantage of. I.e. datasources.

Specified by:
addResource in interface LocalConfiguration
Parameters:
resource - the Resource to add.
See Also:
LocalConfiguration.addResource(Resource)

getResources

public java.util.List getResources()
Specified by:
getResources in interface LocalConfiguration
Returns:
the configured resources for this container.

addDataSource

public void addDataSource(DataSource dataSource)

See Also:
LocalConfiguration#addDataSource(DataSource)

getDataSources

public java.util.List getDataSources()
Returns:
the configured DataSources for this container.


Copyright © 2004-2011 Codehaus. All Rights Reserved.