Search in sources :

Example 1 with DatabaseClassLoader

use of nl.nn.adapterframework.configuration.classloaders.DatabaseClassLoader 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<String, Object>();
    List<Object> configurations = new ArrayList<Object>();
    initBase(servletConfig);
    for (Configuration configuration : ibisManager.getConfigurations()) {
        Map<String, Object> cfg = new HashMap<String, Object>();
        cfg.put("name", configuration.getName());
        cfg.put("version", configuration.getVersion());
        cfg.put("type", configuration.getClassLoaderType());
        ClassLoader classLoader = configuration.getClassLoader().getParent();
        if (classLoader instanceof DatabaseClassLoader) {
            cfg.put("filename", ((DatabaseClassLoader) classLoader).getFileName());
            cfg.put("created", ((DatabaseClassLoader) classLoader).getCreationDate());
            cfg.put("user", ((DatabaseClassLoader) classLoader).getUser());
        }
        configurations.add(cfg);
    }
    returnMap.put("configurations", configurations);
    returnMap.put("version", ibisContext.getFrameworkVersion());
    returnMap.put("name", ibisContext.getApplicationName());
    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<String, Object>(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());
    returnMap.put("uptime", ibisContext.getUptimeDate());
    return Response.status(Response.Status.CREATED).entity(returnMap).build();
}
Also used : DatabaseClassLoader(nl.nn.adapterframework.configuration.classloaders.DatabaseClassLoader) Configuration(nl.nn.adapterframework.configuration.Configuration) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) DatabaseClassLoader(nl.nn.adapterframework.configuration.classloaders.DatabaseClassLoader) Date(java.util.Date) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) PermitAll(javax.annotation.security.PermitAll)

Example 2 with DatabaseClassLoader

use of nl.nn.adapterframework.configuration.classloaders.DatabaseClassLoader in project iaf by ibissource.

the class ClassLoaderManager method createClassloader.

private ClassLoader createClassloader(String configurationName, String configurationFile, ClassLoader parentClassLoader) throws ConfigurationException {
    String classLoaderType = APP_CONSTANTS.getResolvedProperty("configurations." + configurationName + ".classLoaderType");
    ClassLoader classLoader = null;
    if ("DirectoryClassLoader".equals(classLoaderType)) {
        String directory = APP_CONSTANTS.getResolvedProperty("configurations." + configurationName + ".directory");
        classLoader = new DirectoryClassLoader(directory, parentClassLoader);
    } else if ("JarFileClassLoader".equals(classLoaderType)) {
        String jar = APP_CONSTANTS.getResolvedProperty("configurations." + configurationName + ".jar");
        classLoader = new JarFileClassLoader(jar, configurationName, parentClassLoader);
    } else if ("ServiceClassLoader".equals(classLoaderType)) {
        String adapterName = APP_CONSTANTS.getResolvedProperty("configurations." + configurationName + ".adapterName");
        classLoader = new ServiceClassLoader(ibisManager, adapterName, configurationName, parentClassLoader);
    } else if ("DatabaseClassLoader".equals(classLoaderType)) {
        try {
            classLoader = new DatabaseClassLoader(ibisContext, configurationName, parentClassLoader);
        } catch (ConfigurationException ce) {
            String configNotFoundReportLevel = APP_CONSTANTS.getString("configurations." + configurationName + ".configNotFoundReportLevel", "ERROR").toUpperCase();
            String msg = "Could not get config '" + configurationName + "' from database, skipping";
            if (configNotFoundReportLevel.equals("DEBUG")) {
                LOG.debug(msg);
            } else if (configNotFoundReportLevel.equals("INFO")) {
                ibisContext.log(msg);
            } else if (configNotFoundReportLevel.equals("WARN")) {
                ConfigurationWarnings.getInstance().add(LOG, msg);
            } else {
                if (!configNotFoundReportLevel.equals("ERROR"))
                    ConfigurationWarnings.getInstance().add(LOG, "Invalid configNotFoundReportLevel [" + configNotFoundReportLevel + "], using default [ERROR]");
                throw ce;
            }
            // Break here, we cannot continue when there are ConfigurationExceptions!
            return null;
        }
    } else if ("DummyClassLoader".equals(classLoaderType)) {
        classLoader = new DummyClassLoader(configurationName, configurationFile);
    } else if (classLoaderType != null) {
        throw new ConfigurationException("Invalid classLoaderType: " + classLoaderType);
    }
    // It is possible that no classloader has been defined, use default contextClassloader.
    if (classLoader == null) {
        classLoader = parentClassLoader;
    }
    LOG.debug(configurationName + " created classloader [" + classLoader.getClass().getSimpleName() + "]");
    return classLoader;
}
Also used : DirectoryClassLoader(nl.nn.adapterframework.configuration.classloaders.DirectoryClassLoader) ServiceClassLoader(nl.nn.adapterframework.configuration.classloaders.ServiceClassLoader) DatabaseClassLoader(nl.nn.adapterframework.configuration.classloaders.DatabaseClassLoader) JarFileClassLoader(nl.nn.adapterframework.configuration.classloaders.JarFileClassLoader) DirectoryClassLoader(nl.nn.adapterframework.configuration.classloaders.DirectoryClassLoader) ServiceClassLoader(nl.nn.adapterframework.configuration.classloaders.ServiceClassLoader) DummyClassLoader(nl.nn.adapterframework.configuration.classloaders.DummyClassLoader) JarFileClassLoader(nl.nn.adapterframework.configuration.classloaders.JarFileClassLoader) BasePathClassLoader(nl.nn.adapterframework.configuration.classloaders.BasePathClassLoader) DatabaseClassLoader(nl.nn.adapterframework.configuration.classloaders.DatabaseClassLoader) DummyClassLoader(nl.nn.adapterframework.configuration.classloaders.DummyClassLoader)

Example 3 with DatabaseClassLoader

use of nl.nn.adapterframework.configuration.classloaders.DatabaseClassLoader in project iaf by ibissource.

the class ShowConfiguration method getConfigurationDetailsByName.

@GET
@RolesAllowed({ "IbisObserver", "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/configurations/manage/{configuration}")
@Produces(MediaType.APPLICATION_JSON)
public Response getConfigurationDetailsByName(@PathParam("configuration") String configurationName, @QueryParam("realm") String jmsRealm) throws ApiException {
    initBase(servletConfig);
    Configuration configuration = ibisManager.getConfiguration(configurationName);
    if (configuration == null) {
        throw new ApiException("Configuration not found!");
    }
    if (configuration.getClassLoader().getParent() instanceof DatabaseClassLoader) {
        List<Map<String, Object>> configs = getConfigsFromDatabase(configurationName, jmsRealm);
        if (configs == null)
            return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
        for (Map<String, Object> config : configs) {
            if (config.get("version").toString().equals(configuration.getVersion()))
                config.put("loaded", true);
            else
                config.put("loaded", false);
        }
        return Response.status(Response.Status.CREATED).entity(configs).build();
    }
    return Response.status(Response.Status.NO_CONTENT).build();
}
Also used : DatabaseClassLoader(nl.nn.adapterframework.configuration.classloaders.DatabaseClassLoader) Configuration(nl.nn.adapterframework.configuration.Configuration) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) MultivaluedMap(javax.ws.rs.core.MultivaluedMap) Path(javax.ws.rs.Path) RolesAllowed(javax.annotation.security.RolesAllowed) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

DatabaseClassLoader (nl.nn.adapterframework.configuration.classloaders.DatabaseClassLoader)3 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 Configuration (nl.nn.adapterframework.configuration.Configuration)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Map (java.util.Map)1 PermitAll (javax.annotation.security.PermitAll)1 RolesAllowed (javax.annotation.security.RolesAllowed)1 MultivaluedMap (javax.ws.rs.core.MultivaluedMap)1 BasePathClassLoader (nl.nn.adapterframework.configuration.classloaders.BasePathClassLoader)1 DirectoryClassLoader (nl.nn.adapterframework.configuration.classloaders.DirectoryClassLoader)1 DummyClassLoader (nl.nn.adapterframework.configuration.classloaders.DummyClassLoader)1 JarFileClassLoader (nl.nn.adapterframework.configuration.classloaders.JarFileClassLoader)1 ServiceClassLoader (nl.nn.adapterframework.configuration.classloaders.ServiceClassLoader)1