WebApplicationsHolder holder = (WebApplicationsHolder) getConfigContext().
getProperty(CarbonConstants.WEB_APPLICATIONS_HOLDER);
// first search in the started webapps
String state = STARTED;
WebApplication webApplication = holder.getStartedWebapps().get(fileName);
// if it is null, try searching stopped webapps
if (webApplication == null) {
state = STOPPED;
webApplication = holder.getStoppedWebapps().get(fileName);
}
// if it is still null, try searching faulty webapps
if (webApplication == null) {
state = FAULTY;
webApplication = holder.getFaultyWebapps().get(fileName);
}
// if we could find a web app for the given file name, create the Metadata instance
if (webApplication != null) {
warCappMetadata = new WarCappMetadata();
warCappMetadata.setContext(webApplication.getContextName());
warCappMetadata.setState(state);
warCappMetadata.setWebappFileName(webApplication.getWebappFile().getName());
try {
warCappMetadata.setHostName(NetworkUtils.getLocalHostname());
} catch (SocketException e) {
log.error("Error occurred while getting local hostname", e);