// get the context class loader for the later restore of the context class loader
ClassLoader prevCl = Thread.currentThread().getContextClassLoader();
try {
DeploymentClassLoader urlCl = new DeploymentClassLoader(
new URL[]{deploymentFileData.getFile().toURL()}, null, prevCl);
Thread.currentThread().setContextClassLoader(urlCl);
// MediatorFactory registration
URL facURL = urlCl.findResource(
"META-INF/services/org.apache.synapse.config.xml.MediatorFactory");
if (facURL != null) {
InputStream facStream = facURL.openStream();
InputStreamReader facreader = new InputStreamReader(facStream);
StringBuffer facSB = new StringBuffer();
int c;
while ((c = facreader.read()) != -1) {
facSB.append((char) c);
}
String[] facClassName = facSB.toString().split("\n");
for (int i=0; i<facClassName.length; i++) {
log.info("Registering the Mediator factory: " + facClassName[i]);
Class facClass = urlCl.loadClass(facClassName[i]);
MediatorFactory facInst = (MediatorFactory) facClass.newInstance();
MediatorFactoryFinder.getInstance()
.getFactoryMap().put(facInst.getTagQName(), facClass);
log.info("Mediator loaded and registered for " +
"the tag name: " + facInst.getTagQName());
}
} else {
handleException("Unable to find the MediatorFactory implementation. " +
"Unable to register the MediatorFactory with the FactoryFinder");
}
// MediatorSerializer registration
URL serURL = urlCl.findResource(
"META-INF/services/org.apache.synapse.config.xml.MediatorSerializer");
if (serURL != null) {
InputStream serStream = serURL.openStream();
InputStreamReader serReader = new InputStreamReader(serStream);
StringBuffer serSB = new StringBuffer();
int c;
while ((c = serReader.read()) != -1) {
serSB.append((char) c);
}
String[] serClassName = serSB.toString().split("\n");
for (int i=0; i<serClassName.length; i++) {
log.info("Registering the Mediator serializer: " + serClassName[i]);
Class serClass = urlCl.loadClass(serClassName[i]);
MediatorSerializer serInst = (MediatorSerializer) serClass.newInstance();
MediatorSerializerFinder.getInstance()
.getSerializerMap().put(serInst.getMediatorClassName(), serInst);
log.info("Mediator loaded and registered for " +
"the serialization as: " + serInst.getMediatorClassName());