use of nl.nn.adapterframework.configuration.ClassLoaderException in project iaf by ibissource.
the class ServiceClassLoader method loadResources.
@Override
protected Map<String, byte[]> loadResources() throws ClassLoaderException {
if (adapterName == null) {
throw new ClassLoaderException("Name of adapter to provide configuration jar not specified");
}
IAdapter adapter = getIbisContext().getIbisManager().getRegisteredAdapter(adapterName);
if (adapter != null) {
try (PipeLineSession pipeLineSession = new PipeLineSession()) {
adapter.processMessage(getCorrelationId(), new Message(getConfigurationName()), pipeLineSession);
// TODO check result of pipeline
Object object = pipeLineSession.get("configurationJar");
if (object != null) {
if (object instanceof byte[]) {
return readResources((byte[]) object);
}
throw new ClassLoaderException("SessionKey configurationJar not a byte array");
}
throw new ClassLoaderException("SessionKey configurationJar not found");
}
}
throw new ClassLoaderException("Could not find adapter: " + adapterName);
}
use of nl.nn.adapterframework.configuration.ClassLoaderException in project iaf by ibissource.
the class JarBytesClassLoader method readResources.
protected final Map<String, byte[]> readResources(InputStream stream) throws ClassLoaderException {
try (JarInputStream jarInputStream = new JarInputStream(stream)) {
Map<String, byte[]> resources = new HashMap<String, byte[]>();
JarEntry jarEntry;
while ((jarEntry = jarInputStream.getNextJarEntry()) != null) {
String fileName = jarEntry.getName();
if (getBasePath() != null) {
// if the name ends with a slash, assume it's a folder
boolean isFolder = fileName.endsWith("/");
if (isFolder || fileName.startsWith("META-INF/")) {
// Ignore all folders and files in META-INF
log.debug("ignoring {} [{}]", (isFolder ? "folder" : "file"), fileName);
continue;
}
if (fileName.startsWith(getBasePath())) {
// Remove BasePath from the filename
fileName = fileName.substring(getBasePath().length());
} else {
// Found a file that's not in the BasePath folder
if (!fileName.endsWith(".class")) {
// Allow classes to be in the root path, but not resources
log.warn("invalid file [" + fileName + "] not in folder [" + getBasePath() + "]");
// Don't add the file to the resources lists
continue;
}
}
}
resources.put(fileName, Misc.streamToBytes(StreamUtil.dontClose(jarInputStream)));
}
return resources;
} catch (IOException e) {
throw new ClassLoaderException("Could not read resources from jar input stream for configuration '" + getConfigurationName() + "'", e);
}
}
Aggregations