Class AbstractStandaloneLocalConfiguration
- java.lang.Object
-
- org.codehaus.cargo.util.log.LoggedObject
-
- org.codehaus.cargo.container.spi.configuration.AbstractConfiguration
-
- org.codehaus.cargo.container.spi.configuration.AbstractLocalConfiguration
-
- org.codehaus.cargo.container.spi.configuration.AbstractStandaloneLocalConfiguration
-
- All Implemented Interfaces:
Configuration
,LocalConfiguration
,StandaloneLocalConfiguration
,ContainerConfiguration
,Loggable
- Direct Known Subclasses:
AbstractGeronimoStandaloneLocalConfiguration
,AbstractGlassFishStandaloneLocalConfiguration
,AbstractJettyEmbeddedStandaloneLocalConfiguration
,AbstractJettyStandaloneLocalConfiguration
,AbstractJonasStandaloneLocalConfiguration
,AbstractStandaloneLocalConfigurationWithXMLConfigurationBuilder
,AbstractWebLogicWlstStandaloneLocalConfiguration
,AbstractWildFlyStandaloneLocalConfiguration
,JBoss3x4xStandaloneLocalConfiguration
,JBoss7xStandaloneLocalConfiguration
,Jo1xStandaloneLocalConfiguration
,LibertyStandaloneLocalConfiguration
,WebSphere85xStandaloneLocalConfiguration
,WildFlySwarmStandaloneLocalConfiguration
public abstract class AbstractStandaloneLocalConfiguration extends AbstractLocalConfiguration implements StandaloneLocalConfiguration
Base implementation for a standalone local configuration.
-
-
Field Summary
-
Fields inherited from class org.codehaus.cargo.container.spi.configuration.AbstractLocalConfiguration
RESOURCE_PATH
-
-
Constructor Summary
Constructors Constructor Description AbstractStandaloneLocalConfiguration(String dir)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addXmlReplacement(String filename, String xpathExpression, String configurationPropertyName)
Adds an XML replacement.void
addXmlReplacement(String filename, String xpathExpression, String attributeName, String configurationPropertyName)
Adds an XML replacement.void
addXmlReplacement(String filename, String xpathExpression, String attributeName, String configurationPropertyName, XmlReplacement.ReplacementBehavior replacementBehavior)
Adds an XML replacement.void
addXmlReplacement(XmlReplacement xmlReplacement)
Adds an XML replacement.protected void
configureFiles(Map<String,String> replacements, LocalContainer container)
Copy the customized configuration files into the cargo home directory.ConfigurationType
getType()
List<XmlReplacement>
getXmlReplacements()
protected void
performXmlReplacements(LocalContainer container)
Perform the XML replacements for the specified container.void
removeXmlReplacement(String filename, String xpathExpression)
Removes an XML replacement.void
removeXmlReplacement(String filename, String xpathExpression, String attributeName)
Removes an XML replacement.protected void
replaceInFile(String file, Map<String,String> replacements, Charset encoding)
Replaces using a map of replacements in a given file.protected void
setupConfigurationDir()
Set up the configuration directory (create it and clean it).void
verify()
Verify that the configuration is valid.-
Methods inherited from class org.codehaus.cargo.container.spi.configuration.AbstractLocalConfiguration
addDataSource, addDataSourcesFromProperties, addDeployable, addResource, addResourcesFromProperties, addUser, addUsersFromProperties, applyPortOffset, applyPortOffset, collectUnsupportedDataSourcesAndThrowException, collectUnsupportedResourcesAndThrowException, configure, doConfigure, flagOffsetApplied, getDataSources, getDeployables, getDestDirectoryLocation, getDestFileLocation, getFileHandler, getFileProperties, getHome, getPropertyValue, getReplacements, getResources, getResourceUtils, getUsers, isOffsetApplied, isOffsetApplied, parsePropertiesForPendingConfiguration, revertPortOffset, revertPortOffset, setConfigFileProperty, setFileHandler, setFileProperty, setLogger
-
Methods inherited from class org.codehaus.cargo.container.spi.configuration.AbstractConfiguration
getProperties, setProperty
-
Methods inherited from class org.codehaus.cargo.util.log.LoggedObject
getLogger
-
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, setProperty
-
Methods inherited from interface org.codehaus.cargo.container.configuration.LocalConfiguration
addDataSource, addDeployable, addResource, addUser, applyPortOffset, configure, getDataSources, getDeployables, getFileHandler, getFileProperties, getHome, getResources, getUsers, isOffsetApplied, revertPortOffset, setConfigFileProperty, setFileHandler, setFileProperty
-
-
-
-
Constructor Detail
-
AbstractStandaloneLocalConfiguration
public AbstractStandaloneLocalConfiguration(String dir)
- See Also:
AbstractLocalConfiguration(String)
-
-
Method Detail
-
performXmlReplacements
protected void performXmlReplacements(LocalContainer container)
Perform the XML replacements for the specified container.- Parameters:
container
- the container to configure
-
setupConfigurationDir
protected void setupConfigurationDir() throws IOException
Set up the configuration directory (create it and clean it). We clean it because we want to be sure the container starts with the same set up every time and there's no side effects introduced by a previous run or someone modifying some files in there.Note: We only clean the configuration directory if it's empty or if there is a Cargo timestamp file. This is to prevent deleting not empty directories if the user has mistakenly pointed the configuration dir to an existing location.
- Throws:
IOException
- if the directory cannot be created
-
addXmlReplacement
public void addXmlReplacement(XmlReplacement xmlReplacement)
Adds an XML replacement.- Specified by:
addXmlReplacement
in interfaceStandaloneLocalConfiguration
- Parameters:
xmlReplacement
- XML replacement to add.
-
addXmlReplacement
public void addXmlReplacement(String filename, String xpathExpression, String configurationPropertyName)
Adds an XML replacement.- Specified by:
addXmlReplacement
in interfaceStandaloneLocalConfiguration
- Parameters:
filename
- File in which to replace.xpathExpression
- XPath expression to look for.configurationPropertyName
- Name of the configuration property to set. The XML replacement will be ignored if the property is set tonull
.
-
addXmlReplacement
public void addXmlReplacement(String filename, String xpathExpression, String attributeName, String configurationPropertyName)
Adds an XML replacement.- Specified by:
addXmlReplacement
in interfaceStandaloneLocalConfiguration
- Parameters:
filename
- File in which to replace.xpathExpression
- XPath expression to look for.attributeName
- Attribute name to modify. Ifnull
, the node's contents will be modified.configurationPropertyName
- Name of the configuration property to set. The XML replacement will be ignored if the property is set tonull
.
-
addXmlReplacement
public void addXmlReplacement(String filename, String xpathExpression, String attributeName, String configurationPropertyName, XmlReplacement.ReplacementBehavior replacementBehavior)
Adds an XML replacement.- Specified by:
addXmlReplacement
in interfaceStandaloneLocalConfiguration
- Parameters:
filename
- File in which to replace.xpathExpression
- XPath expression to look for.attributeName
- Attribute name to modify. Ifnull
, the node's contents will be modified.configurationPropertyName
- Name of the configuration property to set. The XML replacement will be ignored if the property is set tonull
.replacementBehavior
- Behavior if XPath expression doesn't match anything.
-
removeXmlReplacement
public void removeXmlReplacement(String filename, String xpathExpression)
Removes an XML replacement.- Specified by:
removeXmlReplacement
in interfaceStandaloneLocalConfiguration
- Parameters:
filename
- File in which to replace.xpathExpression
- XPath expression to look for.
-
removeXmlReplacement
public void removeXmlReplacement(String filename, String xpathExpression, String attributeName)
Removes an XML replacement.- Specified by:
removeXmlReplacement
in interfaceStandaloneLocalConfiguration
- Parameters:
filename
- File in which to replace.xpathExpression
- XPath expression to look for.attributeName
- Attribute name to modify. Ifnull
, the node's contents will be modified.
-
getXmlReplacements
public List<XmlReplacement> getXmlReplacements()
- Specified by:
getXmlReplacements
in interfaceStandaloneLocalConfiguration
- Returns:
- All XML replacements.
-
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 interfaceContainerConfiguration
- Overrides:
verify
in classAbstractLocalConfiguration
-
getType
public ConfigurationType getType()
- Specified by:
getType
in interfaceConfiguration
- Returns:
- the configuration type (standalone, existing, runtime, etc)
-
configureFiles
protected void configureFiles(Map<String,String> replacements, LocalContainer container)
Copy the customized configuration files into the cargo home directory.- Overrides:
configureFiles
in classAbstractLocalConfiguration
- Parameters:
replacements
- the replacements to use during the copycontainer
- local container
-
replaceInFile
protected void replaceInFile(String file, Map<String,String> replacements, Charset encoding) throws CargoException
Replaces using a map of replacements in a given file.- Parameters:
file
- File to replace in.replacements
- Map containing replacements.encoding
- The character encoding to use, may benull
or empty to use the platform's default encoding.- Throws:
CargoException
- If anything fails, most notably if one of the replacements does not exist in the file.
-
-