asia.redact.bracket.properties.mgmt
Class ServerLocale
java.lang.Object
asia.redact.bracket.properties.mgmt.ServerLocale
public class ServerLocale
- extends Object
Sort of like a Locale, but for server environments.
The description of properties with environment localization has the following structure:
For a given properties file:
basename[_environment|*][_cluster|*][_instance|*][_variant|*].properties
where
basename is a file name, for example "myprops"
Note: the base name cannot have underscore characters (this is a limitation
of the localization algorithm)
_[environment|] where "environment" is any non-empty token such as "dev", "development",
"test", "prod", and so on. The empty string matches any environment, null matches none.
_[cluster|] where "cluster" is any non-empty token such as "liferay", "mycluster" and so on.
The empty string matches any cluster, null matches none.
_[instance|] where "instance" is any non-empty token such as "s1", "s2" and so on
The empty string matches any environment, null matches none.
_[variant|] the variant can by any token but is often used for "secure" as a special case
The empty string matches any environment, null matches none.
This structure is arbitrary, but it does fit a number of different commonly encountered situations.
Example properties files forming a set of feasible server environment localized properties to this schemata:
portal-ext.properties a template of properties across all environments (no environment localization)
portal-ext_dev.properties specific to the dev environment
portal-ext_dev_liferay.properties specific to the dev liferay cluster
portal-ext_dev_liferay_s1.properties specific to the dev liferay s1 instance
portal-ext_dev_liferay_s2.properties specific to the dev liferay s2 instance
portal-ext_dev_liferay_s3.properties specific to the dev liferay s3 instance
portal-ext_dev_liferay_s4.properties specific to the dev liferay s4 instance
portal-ext_dev_liferay_s4_secure.properties specific variant to the dev liferay s4 instance with this baseName
portal-ext_dev_liferay__secure.properties variant applied to any dev liferay cluster instance with this baseName
portal-ext_dev___secure.properties variant applied to any dev environnment instance with this baseName
portal-ext____secure.properties variant - apply these properties to all environments with this baseName
portal-ext_____.properties legal but identical in effect to portal-ext.properties
These files can be located in different places in the file system.
- Author:
- Dave
environment
String environment
cluster
String cluster
instance
String instance
variant
String variant
ServerLocale
public ServerLocale(String environment,
String cluster,
String instance,
String variant)
ServerLocale
public ServerLocale(String environment,
String cluster,
String instance)
ServerLocale
public ServerLocale(String environment,
String cluster)
ServerLocale
public ServerLocale(String environment)
ServerLocale
public ServerLocale()
getEnvironment
public String getEnvironment()
setEnvironment
public void setEnvironment(String environment)
getCluster
public String getCluster()
setCluster
public void setCluster(String cluster)
getInstance
public String getInstance()
setInstance
public void setInstance(String instance)
getVariant
public String getVariant()
setVariant
public void setVariant(String sec)
toString
public String toString()
- Overrides:
toString in class Object
isWildcard
boolean isWildcard(String s)
isNotSet
boolean isNotSet(String s)
isSet
boolean isSet(String s)
matchEnvironment
boolean matchEnvironment(String env)
matchCluster
boolean matchCluster(String cluster)
matchInstance
boolean matchInstance(String inst)
includes
public boolean includes(ServerLocale locale)
- If this locale "includes" locale, then return true. This will be the case
if it has the same attributes or wildcards
- Parameters:
locale -
- Returns:
fromFileName
public static ServerLocalizedFileInfo fromFileName(String fileName)
- Collect the baseName, encoded locale, and extension of a file name
assume the fileName ends in .properties, fail if this is not so.
- Parameters:
fileName -
- Returns:
fromString
public static ServerLocale fromString(String input)
return a server locale instance parsed from the input
The ServerLocale generated will have a toString() method that returns a
value equal to the input
Inputs must match the following patterns:
empty string
_[environment|]
_[environment|]_[cluster|]
_[environment|]_[cluster|]_[instance|]
_[environment|]_[cluster|]_[instance|]_[variant|]
the tokens for environment, cluster, instance, and variant
can be anything legal in a file name except an underscore
and are user defined
- Parameters:
input - a string containing the pattern
- Returns:
hashCode
public int hashCode()
- Overrides:
hashCode in class Object
equals
public boolean equals(Object obj)
- Overrides:
equals in class Object
Copyright © 2011-2013 David R. Smith. All Rights Reserved.