Search in sources :

Example 31 with AppConstants

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);
}
Also used : AppConstants(nl.nn.adapterframework.util.AppConstants)

Example 32 with AppConstants

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);
    }
}
Also used : ClassLoaderException(nl.nn.adapterframework.configuration.ClassLoaderException) File(java.io.File) AppConstants(nl.nn.adapterframework.util.AppConstants)

Example 33 with AppConstants

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);
    }
}
Also used : AppConstants(nl.nn.adapterframework.util.AppConstants)

Example 34 with AppConstants

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");
    }
}
Also used : IbisContext(nl.nn.adapterframework.configuration.IbisContext) ApplicationContext(org.springframework.context.ApplicationContext) ServletContext(javax.servlet.ServletContext) ServletException(javax.servlet.ServletException) AppConstants(nl.nn.adapterframework.util.AppConstants)

Example 35 with AppConstants

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;
}
Also used : AppConstants(nl.nn.adapterframework.util.AppConstants)

Aggregations

AppConstants (nl.nn.adapterframework.util.AppConstants)42 IbisContext (nl.nn.adapterframework.configuration.IbisContext)7 File (java.io.File)6 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)6 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)3 FileWriter (java.io.FileWriter)2 URL (java.net.URL)2 Enumeration (java.util.Enumeration)2 ServletContext (javax.servlet.ServletContext)2 ServletException (javax.servlet.ServletException)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 ZipEntry (java.util.zip.ZipEntry)1 ZipInputStream (java.util.zip.ZipInputStream)1