Search in sources :

Example 11 with AppConstants

use of nl.nn.adapterframework.util.AppConstants in project iaf by ibissource.

the class IbisApplicationServlet method getIbisContext.

/**
 * Retrieves the IbisContext from the ServletContext
 * @param servletContext
 * @return IbisContext or IllegalStateException when not found
 */
public static IbisContext getIbisContext(ServletContext servletContext) {
    AppConstants appConstants = AppConstants.getInstance();
    String ibisContextKey = appConstants.getResolvedProperty(KEY_CONTEXT);
    IbisContext ibisContext = (IbisContext) servletContext.getAttribute(ibisContextKey);
    if (ibisContext == null) {
        Throwable t = (Throwable) servletContext.getAttribute(KEY_EXCEPTION);
        throw new IllegalStateException("Unable to retrieve IbisContext from ServletContext attribute [" + KEY_CONTEXT + "]", t);
    }
    return ibisContext;
}
Also used : IbisContext(nl.nn.adapterframework.configuration.IbisContext) AppConstants(nl.nn.adapterframework.util.AppConstants)

Example 12 with AppConstants

use of nl.nn.adapterframework.util.AppConstants in project iaf by ibissource.

the class ServerStatistics method getServerInformation.

@GET
@PermitAll
@Path("/server/info")
@Produces(MediaType.APPLICATION_JSON)
public Response getServerInformation() throws ApiException {
    Map<String, Object> returnMap = new HashMap<>();
    AppConstants appConstants = AppConstants.getInstance();
    Map<String, Object> framework = new HashMap<>(2);
    framework.put("name", "FF!");
    framework.put("version", appConstants.getProperty("application.version"));
    returnMap.put("framework", framework);
    Map<String, Object> instance = new HashMap<>(2);
    instance.put("version", appConstants.getProperty("instance.version"));
    instance.put("name", getIbisContext().getApplicationName());
    returnMap.put("instance", instance);
    String dtapStage = appConstants.getProperty("dtap.stage");
    returnMap.put("dtap.stage", dtapStage);
    String dtapSide = appConstants.getProperty("dtap.side");
    returnMap.put("dtap.side", dtapSide);
    returnMap.put("configurations", getConfigurations());
    String user = getUserPrincipalName();
    if (user != null) {
        returnMap.put("userName", user);
    }
    returnMap.put("applicationServer", servletConfig.getServletContext().getServerInfo());
    returnMap.put("javaVersion", System.getProperty("java.runtime.name") + " (" + System.getProperty("java.runtime.version") + ")");
    Map<String, Object> fileSystem = new HashMap<>(2);
    fileSystem.put("totalSpace", Misc.getFileSystemTotalSpace());
    fileSystem.put("freeSpace", Misc.getFileSystemFreeSpace());
    returnMap.put("fileSystem", fileSystem);
    returnMap.put("processMetrics", ProcessMetrics.toMap());
    Date date = new Date();
    returnMap.put("serverTime", date.getTime());
    returnMap.put("machineName", Misc.getHostname());
    ApplicationMetrics metrics = getIbisContext().getBean("metrics", ApplicationMetrics.class);
    returnMap.put("uptime", (metrics != null) ? metrics.getUptimeDate() : "");
    return Response.status(Response.Status.OK).entity(returnMap).build();
}
Also used : HashMap(java.util.HashMap) ApplicationMetrics(nl.nn.adapterframework.lifecycle.ApplicationMetrics) Date(java.util.Date) AppConstants(nl.nn.adapterframework.util.AppConstants) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) PermitAll(javax.annotation.security.PermitAll)

Example 13 with AppConstants

use of nl.nn.adapterframework.util.AppConstants in project iaf by ibissource.

the class FxfPropertySourcePostProcessor method convertProperties.

@Override
protected void convertProperties(Properties props) {
    AppConstants appConstants = AppConstants.getInstance();
    String fxfDir = appConstants.getResolvedProperty("fxf.dir");
    if (fxfDir == null) {
        // Use default location, see was.policy too
        fxfDir = System.getProperty("APPSERVER_ROOT_DIR");
        if (fxfDir != null) {
            fxfDir = fxfDir + File.separator + "fxf-work";
        }
    }
    if (fxfDir != null) {
        appConstants.setProperty("fxf.dir", fxfDir);
        props.put("fxf.dir", fxfDir);
    }
    log.debug("FxF directory: " + fxfDir);
}
Also used : AppConstants(nl.nn.adapterframework.util.AppConstants)

Example 14 with AppConstants

use of nl.nn.adapterframework.util.AppConstants in project iaf by ibissource.

the class JdbcMessageBrowser method setOperationControls.

protected void setOperationControls() {
    AppConstants ac = AppConstants.getInstance();
    useParameters = ac.getBoolean(PROPERTY_USE_PARAMETERS, true);
    assumePrimaryKeyUnique = ac.getBoolean(PROPERTY_ASSUME_PRIMARY_KEY_UNIQUE, true);
}
Also used : AppConstants(nl.nn.adapterframework.util.AppConstants)

Example 15 with AppConstants

use of nl.nn.adapterframework.util.AppConstants in project iaf by ibissource.

the class TestTool method windiff.

// Used by saveResultToFile.jsp
public static void windiff(ServletContext application, HttpServletRequest request, String expectedFileName, String result, String expected) throws IOException, SenderException {
    IbisContext ibisContext = getIbisContext(application);
    AppConstants appConstants = getAppConstants(ibisContext);
    String windiffCommand = appConstants.getResolvedProperty("larva.windiff.command");
    if (windiffCommand == null) {
        String servletPath = request.getServletPath();
        int i = servletPath.lastIndexOf('/');
        String realPath = application.getRealPath(servletPath.substring(0, i));
        List<String> scenariosRootDirectories = new ArrayList<String>();
        List<String> scenariosRootDescriptions = new ArrayList<String>();
        String currentScenariosRootDirectory = TestTool.initScenariosRootDirectories(appConstants, realPath, null, scenariosRootDirectories, scenariosRootDescriptions, null);
        windiffCommand = currentScenariosRootDirectory + "..\\..\\IbisAlgemeenWasbak\\WinDiff\\WinDiff.Exe";
    }
    File tempFileResult = writeTempFile(expectedFileName, result);
    File tempFileExpected = writeTempFile(expectedFileName, expected);
    String command = windiffCommand + " " + tempFileResult + " " + tempFileExpected;
    ProcessUtil.executeCommand(command);
}
Also used : IbisContext(nl.nn.adapterframework.configuration.IbisContext) ArrayList(java.util.ArrayList) File(java.io.File) 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