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();
}
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;
}
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();
}
Aggregations