Class SystemPropertyChangeEnvironmentFacet
- java.lang.Object
-
- org.codehaus.mojo.jaxb2.shared.environment.AbstractLogAwareFacet
-
- org.codehaus.mojo.jaxb2.shared.environment.sysprops.SystemPropertyChangeEnvironmentFacet
-
- All Implemented Interfaces:
EnvironmentFacet
public final class SystemPropertyChangeEnvironmentFacet extends AbstractLogAwareFacet
EnvironmentFacet which changes the value of a system property for the duration of executing a tool. This is required for tools (such as the JDK SchemaGen) which relies on environment or system properties being set for their execution. This faced accepts one key and two values (original/new values).- Since:
- 2.1
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SystemPropertyChangeEnvironmentFacet.ChangeType
Operation definitions indicating how a System property should be changed by this EnvironmentFacet.static class
SystemPropertyChangeEnvironmentFacet.SystemPropertyChangesBuilder
Builder class intended to simplify creating SystemPropertyChange EnvironmentFacets.
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
key
private java.lang.String
newValue
private java.lang.String
originalValue
private SystemPropertyChangeEnvironmentFacet.ChangeType
type
-
Fields inherited from class org.codehaus.mojo.jaxb2.shared.environment.AbstractLogAwareFacet
log
-
-
Constructor Summary
Constructors Modifier Constructor Description private
SystemPropertyChangeEnvironmentFacet(org.apache.maven.plugin.logging.Log log, java.lang.String key)
Creates a SystemPropertyChange which will remove the supplied system property for the duration of this SystemPropertyChange.private
SystemPropertyChangeEnvironmentFacet(org.apache.maven.plugin.logging.Log log, java.lang.String key, java.lang.String newValue)
Creates a SystemPropertyChange which stores the current
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
existsAsSystemProperty(java.lang.String key)
static SystemPropertyChangeEnvironmentFacet.SystemPropertyChangesBuilder
getBuilder(org.apache.maven.plugin.logging.Log mavenLog)
Creates a SystemPropertyChangesBuilder which uses the supplied active Maven Log.void
restore()
Restores the original Environment, implying that the change performed insetup()
method are restored to the state before the setup method was called.void
setup()
Sets up this Environment, inferring temporary changes to environment variables or conditions.java.lang.String
toString()
-
-
-
Field Detail
-
type
private SystemPropertyChangeEnvironmentFacet.ChangeType type
-
key
private java.lang.String key
-
newValue
private java.lang.String newValue
-
originalValue
private java.lang.String originalValue
-
-
Constructor Detail
-
SystemPropertyChangeEnvironmentFacet
private SystemPropertyChangeEnvironmentFacet(org.apache.maven.plugin.logging.Log log, java.lang.String key)
Creates a SystemPropertyChange which will remove the supplied system property for the duration of this SystemPropertyChange. No exception will be thrown if the supplied System property key is not found in the present System.properties.- Parameters:
log
- The active Maven Log.key
- A non-null key.- See Also:
SystemPropertyChangeEnvironmentFacet.ChangeType.REMOVE
-
SystemPropertyChangeEnvironmentFacet
private SystemPropertyChangeEnvironmentFacet(org.apache.maven.plugin.logging.Log log, java.lang.String key, java.lang.String newValue)
Creates a SystemPropertyChange which stores the current- Parameters:
log
- The active Maven Log.key
- The key of the System property managed by this SystemPropertyChange.newValue
- The new value of this SystemPropertyChange.
-
-
Method Detail
-
setup
public void setup()
Sets up this Environment, inferring temporary changes to environment variables or conditions. The changes must be reversible, and should be restored to their original values in therestore()
method.
-
restore
public void restore()
Restores the original Environment, implying that the change performed insetup()
method are restored to the state before the setup method was called.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- Returns:
- A Debug string representation of this SystemPropertyChangeEnvironmentFacet.
-
getBuilder
public static SystemPropertyChangeEnvironmentFacet.SystemPropertyChangesBuilder getBuilder(org.apache.maven.plugin.logging.Log mavenLog)
Creates a SystemPropertyChangesBuilder which uses the supplied active Maven Log.- Parameters:
mavenLog
- The active Maven Log to be used by all SystemPropertyChange objects created by this SystemPropertyChangesBuilder.- Returns:
- A SystemPropertyChangesBuilder ready for use.
-
existsAsSystemProperty
private boolean existsAsSystemProperty(java.lang.String key)
-
-