use of org.apache.synapse.config.xml.MediatorSerializer in project wso2-synapse by wso2.
the class ExtensionDeployer method deploy.
/**
* This will be called when there is a change in the specified deployment
* folder (in the axis2.xml) and this will load the relevant classes to the system and
* register them with the MediatorFactoryFinder
*
* @param deploymentFileData - describes the updated file
* @throws DeploymentException - in case an error on the deployment
*/
public void deploy(DeploymentFileData deploymentFileData) throws DeploymentException {
log.info("Loading extensions from: " + deploymentFileData.getAbsolutePath());
// get the context class loader for the later restore of the context class loader
ClassLoader prevCl = Thread.currentThread().getContextClassLoader();
try {
boolean isDirectory = deploymentFileData.getFile().isDirectory();
deploymentFileData.setClassLoader(isDirectory, getClass().getClassLoader(), (File) cfgCtx.getAxisConfiguration().getParameterValue(Constants.Configuration.ARTIFACTS_TEMP_DIR), cfgCtx.getAxisConfiguration().isChildFirstClassLoading());
DeploymentClassLoader urlCl = (DeploymentClassLoader) deploymentFileData.getClassLoader();
Thread.currentThread().setContextClassLoader(urlCl);
// StartupFactory registration
for (StartupFactory factory : getProviders(StartupFactory.class, urlCl)) {
QName tagQName = factory.getTagQName();
Class<? extends StartupFactory> clazz = factory.getClass();
StartupFinder finder = StartupFinder.getInstance();
finder.getFactoryMap().put(tagQName, clazz);
finder.getSerializerMap().put(tagQName, factory.getSerializerClass());
log.info("Registered startup factory and serializer for " + tagQName);
}
// MediatorFactory registration
for (MediatorFactory factory : getProviders(MediatorFactory.class, urlCl)) {
QName tagQName = factory.getTagQName();
Class<? extends MediatorFactory> clazz = factory.getClass();
MediatorFactoryFinder.getInstance().getFactoryMap().put(tagQName, clazz);
log.info("Registered mediator factory " + clazz.getName() + " for " + tagQName);
}
// MediatorSerializer registration
for (MediatorSerializer serializer : getProviders(MediatorSerializer.class, urlCl)) {
String mediatorClassName = serializer.getMediatorClassName();
MediatorSerializerFinder.getInstance().getSerializerMap().put(mediatorClassName, serializer);
log.info("Registered mediator serializer " + serializer.getClass().getName() + " for " + mediatorClassName);
}
} catch (IOException e) {
handleException("I/O error in reading the mediator jar file", e);
} catch (Exception e) {
handleException("Error occurred while trying to deploy mediator jar file", e);
} catch (Throwable t) {
handleException("Error occurred while trying to deploy the mediator jar file", t);
} finally {
// restore the class loader back
if (log.isDebugEnabled()) {
log.debug("Restoring the context class loader to the original");
}
Thread.currentThread().setContextClassLoader(prevCl);
}
}
Aggregations