use of nl.nn.adapterframework.util.AppConstants in project iaf by ibissource.
the class OverwritePropertySourcePostProcessor method convertProperties.
@Override
protected void convertProperties(Properties props) {
AppConstants appConstants = AppConstants.getInstance();
appConstants.setProperty(propertyName, propertyValue);
props.put(propertyName, propertyValue);
}
use of nl.nn.adapterframework.util.AppConstants in project iaf by ibissource.
the class DirectoryClassLoader method configure.
@Override
public void configure(IbisContext ibisContext, String configurationName) throws ClassLoaderException {
super.configure(ibisContext, configurationName);
if (directory == null) {
AppConstants appConstants = AppConstants.getInstance();
String configurationsDirectory = appConstants.getResolvedProperty("configurations.directory");
if (configurationsDirectory == null) {
throw new ClassLoaderException("Could not find property configurations.directory");
}
setDirectory(configurationsDirectory);
}
if (getBasePath() != null) {
// Append BasePath, because legacy
log.debug("appending basepath [" + getBasePath() + "] to directory [" + directory + "]");
// Append BasePath, because legacy
directory = new File(directory, getBasePath());
}
if (!this.directory.isDirectory()) {
throw new ClassLoaderException("Could not find directory to load configuration from: " + this.directory);
}
}
use of nl.nn.adapterframework.util.AppConstants in project iaf by ibissource.
the class LowerCasePropertySourcePostProcessor method convertProperties.
@Override
protected void convertProperties(Properties props) {
AppConstants appConstants = AppConstants.getInstance();
String instanceName = appConstants.getProperty("instance.name");
if (instanceName != null) {
String lowerCase = instanceName.toLowerCase();
appConstants.setProperty("instance.name.lc", lowerCase);
props.put("instance.name.lc", lowerCase);
}
}
use of nl.nn.adapterframework.util.AppConstants in project iaf by ibissource.
the class IbisApplicationServlet method init.
@Override
public void init() throws ServletException {
super.init();
ServletContext servletContext = getServletContext();
AppConstants appConstants = AppConstants.getInstance();
String realPath = servletContext.getRealPath("/");
if (realPath != null) {
appConstants.put("webapp.realpath", realPath);
} else {
log.warn("Could not determine webapp.realpath");
}
String projectBaseDir = Misc.getProjectBaseDir();
if (projectBaseDir != null) {
appConstants.put("project.basedir", projectBaseDir);
} else {
log.info("Could not determine project.basedir");
}
ApplicationContext parentContext = null;
try {
// This can throw many different types of errors!
parentContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
if (parentContext == null) {
throw new IllegalStateException("No IBIS WebApplicationInitializer found. Aborting launch...");
}
} catch (Throwable t) {
servletContext.setAttribute(KEY_EXCEPTION, t);
log.error("IBIS WebApplicationInitializer failed to initialize", t);
// If the IBIS WebApplicationInitializer can't be found or initialized, throw the exception
throw t;
}
servletContext.log("Starting IbisContext");
ibisContext = new IbisContext();
ibisContext.setParentContext(parentContext);
ibisContext.init();
Exception startupException = ibisContext.getStartupException();
if (startupException != null) {
// Check if there are any problems initializing Spring
String msg = this.getClass().getSimpleName() + " finished without successfully initializing the IbisContext";
log.error(msg, startupException);
// We can't call servletContext.log(message, Exception) as it will prevent the servlet from starting up
servletContext.log(String.format("%s, check ibis logs for more information! (%s) %s", msg, startupException.getClass().getName(), startupException.getMessage()));
// Instead of the IbisContext we store the Exception, see IbisApplicationServlet.getIbisContext(ServletContext)
servletContext.setAttribute(KEY_EXCEPTION, startupException);
} else {
// Since Spring has started, save the IbisContext in the ServletContext
String attributeKey = appConstants.getResolvedProperty(KEY_CONTEXT);
servletContext.setAttribute(attributeKey, ibisContext);
log.debug("stored IbisContext [" + ClassUtils.nameOf(ibisContext) + "][" + ibisContext + "] in ServletContext under key [" + attributeKey + "]");
log.debug("Servlet init finished");
}
}
use of nl.nn.adapterframework.util.AppConstants in project iaf by ibissource.
the class ServletManager method getTransportGuarantee.
public static ServletSecurity.TransportGuarantee getTransportGuarantee(String propertyName) {
AppConstants appConstants = AppConstants.getInstance();
String constraintType = appConstants.getString(propertyName, null);
if (StringUtils.isNotEmpty(constraintType))
return ServletSecurity.TransportGuarantee.valueOf(constraintType);
String stage = appConstants.getString("dtap.stage", null);
if (StringUtils.isNotEmpty(stage) && stage.equalsIgnoreCase("LOC")) {
return ServletSecurity.TransportGuarantee.NONE;
}
return ServletSecurity.TransportGuarantee.CONFIDENTIAL;
}
Aggregations