public class ApplicationContextInfo extends Object implements ApplicationInfo
ApplicationInfo
interface.
This class groups application metadata.
Because some of the metadata may only be available at build time,
you will usually have spring instantiate this object as a bean from xml.
You can refer to this bean from other beans that handle errors or provide
environment dependent logic.
An example spring configuration:
<bean id="applicationContextInfo" class="com.foreach.spring.context.ApplicationContextInfo">
<property name="environmentLabel" value="${app.environment}"/>
<-- see ApplicationEnvironment --/>
<property name="applicationName" value="${app.name}"/>
<property name="label" value="${app.label}"/>
<property name="buildNumber" value="${build.number}"/>
<property name="buildDate" value="${build.date}"/>
</bean>
ApplicationInfo,
MutableApplicationInfo| Constructor and Description |
|---|
ApplicationContextInfo() |
| Modifier and Type | Method and Description |
|---|---|
String |
getApplicationId()
Example: myapp
|
String |
getApplicationName()
Returns the specified application name
|
Date |
getBuildDate()
Returns the build date of the current application
|
String |
getBuildId()
Could be a build number from the build server, revision number from source control etc.
|
long |
getBuildNumber()
Returns the build number of the current application
|
ApplicationEnvironment |
getEnvironment()
Deprecated.
|
String |
getEnvironmentId()
Example: test
|
String |
getEnvironmentName()
Example: Test environment
|
String |
getHostName()
Example: localhost
|
String |
getInstanceId()
Application instance is usually a combination of the application, environment
and hostname.
|
String |
getLabel()
Returns the specified label of the current application
|
Date |
getStartupDate()
Returns the start-up date of the current application.
|
boolean |
isRunningIn(ApplicationEnvironment environmentToCheck)
Method to check whether the current application is running in given mode.
|
boolean |
isRunningIn(String environmentId) |
void |
setApplicationName(String applicationName)
Specify an application name
|
void |
setBuildDate(Date buildDate)
Specify the build date of current application
|
void |
setBuildNumber(long buildNumber)
Specify the build number of the current application
|
void |
setEnvironment(ApplicationEnvironment environment)
Specify a
ApplicationEnvironment enum for the current environment, the specified enum should be one of ApplicationEnvironment |
void |
setEnvironmentId(String environmentId) |
void |
setEnvironmentLabel(String environmentLabel)
Deprecated.
|
void |
setHostName(String hostName) |
void |
setLabel(String label)
Specify a readable label for the current application
|
String |
toString() |
public String getInstanceId()
getInstanceId in interface ApplicationInfopublic String getApplicationId()
getApplicationId in interface ApplicationInfopublic String getHostName()
ApplicationInfogetHostName in interface ApplicationInfopublic void setHostName(String hostName)
@Deprecated public final void setEnvironmentLabel(String environmentLabel)
ApplicationEnvironment label for the current environment, the specified label should be one of ApplicationEnvironmentenvironmentLabel - public final void setEnvironment(ApplicationEnvironment environment)
ApplicationEnvironment enum for the current environment, the specified enum should be one of ApplicationEnvironmentenvironment - public void setEnvironmentId(String environmentId)
public String getEnvironmentId()
getEnvironmentId in interface ApplicationInfopublic String getEnvironmentName()
getEnvironmentName in interface ApplicationInfo@Deprecated public final ApplicationEnvironment getEnvironment()
public final boolean isRunningIn(ApplicationEnvironment environmentToCheck)
environmentToCheck - public boolean isRunningIn(String environmentId)
isRunningIn in interface ApplicationInfoenvironmentId - Id of the environment to check against.public final void setLabel(String label)
label - public final String getLabel()
public final void setApplicationName(String applicationName)
applicationName - public final String getApplicationName()
getApplicationName in interface ApplicationInfopublic final void setBuildNumber(long buildNumber)
buildNumber - a number corresponding to a unique build to facilitate
defect tracking.public final long getBuildNumber()
public String getBuildId()
getBuildId in interface ApplicationInfopublic final void setBuildDate(Date buildDate)
buildDate - the date the application was built.public final Date getBuildDate()
getBuildDate in interface ApplicationInfopublic final Date getStartupDate()
getStartupDate in interface ApplicationInfoCopyright © 2017. All rights reserved.