public class EnvironmentUtility extends Object
Modifier and Type | Field and Description |
---|---|
protected static String |
APPLICABLE_BOTH
Value for "applicable" attribute in xml configuration file to indicate
both development and installation environments.
|
protected static String |
APPLICABLE_DEV_ENV
Value for "applicable" attribute in xml configuration file to indicate
development environment only.
|
protected static String |
APPLICABLE_INSTALL_ENV
Value for "applicable" attribute in xml configuration file to indicate
install environment only.
|
static String |
DATASOURCE_REGEX_JDBC_SERVICE
Datasource regular expression to match jdbc connection style string
with service name specified
group 1 should be host, 2 should be port, 3 should be servicename
|
static String |
DATASOURCE_REGEX_JDBC_SID
Datasource regular expression to match jdbc connection style string
with SID specified
group 1 should be host, 2 should be port, 3 should be sid
|
static String |
DATASOURCE_REGEX_TNS
Datasource regular expression to match TNS style string
group 1 should be host, 2 should be port, 3 should be servicename
|
static String |
IFS_INSTALL_ENVIRONMENT_VARIABLE
Environment variable to lookup to determine if running a dev environment
|
protected Map |
m_Classpaths
a map containing classpathGroup name/classpath value tuples
|
protected Map |
m_Commands
a map containing command name/value tuples
|
protected String |
m_DirSep
Operating system specific directory separator string to leverage
|
protected static Map |
m_Environment
Operating System environment variable map
|
protected Map |
m_Folders
a map containing folder name/path tuples
|
protected boolean |
m_IsInstallEnvironment
Runtime configuration mode being leveraged:
A value of false indicates utility leveraging dev environment
configuration, a value of true indicates install environment configuration.
|
protected SAXParser |
m_Parser
XML SAX parser instance
|
protected String |
m_PathSep
Operating system specific path separator string to leverage
|
static String |
UOA_JDBC_DATASOURCE
UOA JDBC Data Source name.
|
Constructor and Description |
---|
EnvironmentUtility(boolean isInstallEnvironment)
Constructor
|
Modifier and Type | Method and Description |
---|---|
protected String |
addTrailingDirSep(String path)
Adds trailing directory separator to supplied path if required.
|
protected String |
addTrailingPathSep(String classpath)
Adds trailing path separator to supplied classpath if required.
|
static void |
closeStream(InputStream is)
Close the specified inputstream if non-null, consuming any exception
|
static void |
closeWriter(Writer w)
Flush and close the specified writer if non-null, consuming any
exception
|
protected String |
convertPath(String value)
Return a path string derived from the specified path potentially replacing
occurrences of unix directory separator with the windows directory
separator should the windows directory seaparator be in use.
|
static Map |
getAttributes(Attributes atts)
Converts the specified Attributes instance in to a map of attribute
qname (the key)/value pairs.
|
Map |
getClasspaths()
Returns a map containing classpath group name/classpath value tuples
Note: classpath value always end with trailing path separator;
Note: by convention keys starting with a bang "!"
|
String |
getClasspathValue(String name)
Return classpath value for specified classpath group from classpath map.
|
Map |
getCommands()
Returns a map containing command name/value tuples
Note: by convention keys starting with a bang "!"
|
String |
getCommandValue(String name)
Return command value for specified command name from commands map.
|
String |
getConsoleInputString(String prompt,
String defValue,
boolean required,
boolean echoInput)
Get input string from the console, and return the result
|
static String |
getDatabaseUrl(String ifsDomain)
Synthesizes a basic database connection URL from the supplied IFS domain
string.
|
static String |
getDatabaseUrl(String ifsDomain,
boolean asSID)
Synthesizes a basic database connection URL from the supplied IFS domain
string.
|
static String |
getEnvironmentValue(String name)
Return value for specified environment variable.
|
static Map |
getEnvironmentVariables()
Returns a Map containing environment variable name-value pairs for
the current executing environment.
|
Map |
getFolders()
Returns a map containing folder name/path tuples
Note: by convention keys starting with a bang "!"
|
String |
getFolderValue(String name)
Return value for specified folder from folder map.
|
static String |
getIfsDomain(String databaseUrl,
String ifsSchema)
Attempts to synthesize an IFS domain string from the supplied database
connection URL and IFS schema name.
|
static String |
getIfsSchema(String ifsDomain)
Retrieves the IFS schema name connection component of the supplied
IFS domain string.
|
protected Properties |
getInstallEnvironmentCommonSettings()
Retrieves the 11g Installation environment settings from mbean server.
|
protected Properties |
getInternalProperties()
Derives a set of properties specific to the particular runtime
mode (development/install).
|
protected boolean |
isApplicable(String applicability)
Determine if the provided applicability attribute value should result in
processing continuing or being skipped.
|
static boolean |
isDevelopmentEnvironment()
Returns true if the runtime environment appears to be a development
environment.
|
protected static boolean |
isEmptyTrimmed(String value)
Utility method to determine if a String instance is empty post trimming
|
static boolean |
isInstallEnvironment()
Returns true if the runtime environment appears to be an installation
environment.
|
static boolean |
isWindows()
Returns a boolean indicating whether this JVM appear to be running in a
Windows based environment.
|
protected void |
log(oracle.ifs.admin.tools.config.EnvironmentUtility.Classpath group)
Log the specified classpath group instance if non-null
|
protected void |
log(oracle.ifs.admin.tools.config.EnvironmentUtility.Command command)
Log the specified command instance if non-null
|
protected void |
log(oracle.ifs.admin.tools.config.EnvironmentUtility.Folder f)
Log the specified folder instance if non-null
|
static void |
main(String[] args)
Initializes the utility.
|
void |
parseXmlStream(InputStream is) |
protected String |
removeTrailingDirSepIfNotRoot(String path)
Removes the trailing directory separator if applicable from supplied paths
that are not root folders
|
protected String |
removeTrailingPathSep(String classpath)
Removes the trailing path separator if applicable from supplied classpath
|
protected void |
saveClasspath(oracle.ifs.admin.tools.config.EnvironmentUtility.Classpath group)
Store name/value of classpath group instance in the classpath map.
|
protected void |
saveCommand(oracle.ifs.admin.tools.config.EnvironmentUtility.Command command)
Store name/value of command instance in the commands map.
|
protected void |
saveFolder(oracle.ifs.admin.tools.config.EnvironmentUtility.Folder folder)
Store name/value of folder instance in the folder map.
|
void |
setClasspathValue(String name,
String value)
Store value for classpath with specified group name in the classpath map.
|
void |
setCommandValue(String name,
String value)
Store value for command with specified name in the commands map.
|
void |
setFolderValue(String name,
String value)
Store value for folder with specified name in the folder map.
|
protected void |
setPropertyAndWarnIfEmpty(Properties props,
String propName,
String propValue,
String warnMsg2)
Sets the property in the provided Properties instance only if the
associated property value is not null or empty.
|
protected void |
writeEnvironment(BufferedWriter w)
Write exportable classpath entries and commands out.
|
protected void |
writeProperties(BufferedWriter w)
Write folder and internal property entries out.
|
public static final String IFS_INSTALL_ENVIRONMENT_VARIABLE
public static final String UOA_JDBC_DATASOURCE
public static final String DATASOURCE_REGEX_TNS
public static final String DATASOURCE_REGEX_JDBC_SID
public static final String DATASOURCE_REGEX_JDBC_SERVICE
protected static final String APPLICABLE_DEV_ENV
protected static final String APPLICABLE_INSTALL_ENV
protected static final String APPLICABLE_BOTH
protected static Map m_Environment
protected final Map m_Commands
protected final Map m_Classpaths
protected final Map m_Folders
protected final boolean m_IsInstallEnvironment
protected String m_DirSep
protected String m_PathSep
protected SAXParser m_Parser
public EnvironmentUtility(boolean isInstallEnvironment)
isInstallEnvironment
- runtime configuration mode to be leveraged
true=install environment, false=developmentpublic static void main(String[] args)
args
- command-line argumentspublic void parseXmlStream(InputStream is)
protected void writeEnvironment(BufferedWriter w) throws IOException
w
- buffered [file] writerIOException
protected void writeProperties(BufferedWriter w) throws IOException
w
- buffered [file] writerIOException
protected Properties getInternalProperties()
protected Properties getInstallEnvironmentCommonSettings()
public Map getCommands()
public Map getClasspaths()
public Map getFolders()
public void setCommandValue(String name, String value)
name
- name of commandvalue
- value for specified commandpublic String getCommandValue(String name)
name
- name of commandpublic void setClasspathValue(String name, String value)
name
- group name of classpathvalue
- value for specified classpathpublic String getClasspathValue(String name)
name
- group name of classpathpublic void setFolderValue(String name, String value)
name
- name of foldervalue
- value for specified folderpublic String getFolderValue(String name)
name
- name of folderprotected boolean isApplicable(String applicability)
applicability
- should be one of both/dev/installprotected void saveCommand(oracle.ifs.admin.tools.config.EnvironmentUtility.Command command)
command
- command instanceprotected void saveClasspath(oracle.ifs.admin.tools.config.EnvironmentUtility.Classpath group)
group
- classpath group instanceprotected void saveFolder(oracle.ifs.admin.tools.config.EnvironmentUtility.Folder folder)
folder
- folder instanceprotected void log(oracle.ifs.admin.tools.config.EnvironmentUtility.Command command)
command
- the command instance to log.protected void log(oracle.ifs.admin.tools.config.EnvironmentUtility.Classpath group)
group
- the classpath group instance to log.protected void log(oracle.ifs.admin.tools.config.EnvironmentUtility.Folder f)
f
- the folder instance to log.protected String convertPath(String value)
value
- input path stringprotected String addTrailingDirSep(String path)
path
- path to processprotected String removeTrailingDirSepIfNotRoot(String path)
path
- path to processprotected String addTrailingPathSep(String classpath)
classpath
- classpath to processprotected String removeTrailingPathSep(String classpath)
classpath
- classpath to processprotected void setPropertyAndWarnIfEmpty(Properties props, String propName, String propValue, String warnMsg2)
props
- Properties instancepropName
- Property NamepropValue
- Property ValuewarnMsg2
- Secondary warning message to be loggedpublic static void closeStream(InputStream is)
is
- the input stream.public static void closeWriter(Writer w)
w
- the writer.public static Map getAttributes(Attributes atts)
atts
- an Attributes instancepublic static String getEnvironmentValue(String name)
name
- name of environment variablepublic static Map getEnvironmentVariables()
public String getConsoleInputString(String prompt, String defValue, boolean required, boolean echoInput)
prompt
- the promptdefValue
- the value to use if no input is specifiedrequired
- boolean indication as to whether a value is requiredechoInput
- boolean indication as to whether to echo the user's inputpublic static String getIfsDomain(String databaseUrl, String ifsSchema)
databaseUrl
- database connection urlifsSchema
- IFS schema namepublic static String getIfsSchema(String ifsDomain)
ifsDomain
- IFS domain stringpublic static String getDatabaseUrl(String ifsDomain)
ifsDomain
- IFS domain stringpublic static String getDatabaseUrl(String ifsDomain, boolean asSID)
ifsDomain
- IFS domain stringasSID
- a true value indicates SID-based domain string
interpretation, a false value indicates a
SERVICE-based domain string interpretationprotected static boolean isEmptyTrimmed(String value)
value
- String instancepublic static boolean isDevelopmentEnvironment()
public static boolean isInstallEnvironment()
public static boolean isWindows()
Copyright © 2023. All rights reserved.