use of org.apache.synapse.libraries.model.Library in project wso2-synapse by wso2.
the class MediatorFactoryFinder method getMediator.
/**
* This method returns a Processor given an OMElement. This will be used
* recursively by the elements which contain processor elements themselves
* (e.g. rules)
*
* @param element XML representation of a mediator
* @param properties bag of properties to pass in any information to the factory
* @return Processor
*/
public Mediator getMediator(OMElement element, Properties properties) {
String localName = element.getLocalName();
QName qName;
if (element.getNamespace() != null) {
qName = new QName(element.getNamespace().getNamespaceURI(), localName);
} else {
qName = new QName(localName);
}
if (log.isDebugEnabled()) {
log.debug("getMediator(" + qName + ")");
}
Class cls = factoryMap.get(qName);
if (cls == null && localName.indexOf('.') > -1) {
String newLocalName = localName.substring(0, localName.indexOf('.'));
qName = new QName(element.getNamespace().getNamespaceURI(), newLocalName);
if (log.isDebugEnabled()) {
log.debug("getMediator.2(" + qName + ")");
}
cls = factoryMap.get(qName);
}
if (cls == null) {
if (synapseLibraryMap != null && !synapseLibraryMap.isEmpty()) {
for (Map.Entry<String, Library> entry : synapseLibraryMap.entrySet()) {
if (entry.getValue().getLibArtifactDetails().containsKey(localName)) {
return getDynamicInvokeMediator(element, entry.getValue().getPackage());
}
}
}
if (!synapseImportMap.isEmpty()) {
for (Map.Entry<String, SynapseImport> entry : synapseImportMap.entrySet()) {
if (localName.startsWith(entry.getValue().getLibName())) {
return getDynamicInvokeMediator(element, entry.getValue().getLibPackage());
}
}
}
String msg = "Unknown mediator referenced by configuration element : " + qName;
log.error(msg);
throw new SynapseException(msg);
}
try {
MediatorFactory mf = (MediatorFactory) cls.newInstance();
return mf.createMediator(element, properties);
} catch (InstantiationException e) {
String msg = "Error initializing mediator factory : " + cls;
log.error(msg);
throw new SynapseException(msg, e);
} catch (IllegalAccessException e) {
String msg = "Error initializing mediator factory : " + cls;
log.error(msg);
throw new SynapseException(msg, e);
}
}
use of org.apache.synapse.libraries.model.Library in project wso2-synapse by wso2.
the class LibraryArtifactDeployer method undeploy.
public void undeploy(String fileName) throws DeploymentException {
fileName = FilenameUtils.normalize(fileName);
if (log.isDebugEnabled()) {
log.debug("UnDeployment of the synapse library from file : " + fileName + " : STARTED");
}
SynapseArtifactDeploymentStore deploymentStore = getSynapseConfiguration().getArtifactDeploymentStore();
if (deploymentStore.containsFileName(fileName)) {
File undeployingFile = new File(fileName);
if (fileName.contains(File.separator + "tmp" + File.separator + "carbonapps" + File.separator) && fileName.endsWith(".zip")) {
undeployingFile.delete();
}
// synapse artifacts which are being Hot-deployed
if (undeployingFile.exists()) {
if (log.isDebugEnabled()) {
log.debug("Marking artifact as updating from file : " + fileName);
}
// Hot-Update case
if (!deploymentStore.isRestoredFile(fileName)) {
deploymentStore.addUpdatingArtifact(fileName, deploymentStore.getArtifactNameForFile(fileName));
deploymentStore.removeArtifactWithFileName(fileName);
}
} else {
// if the file doesn't exists then it is an actual undeployment
String artifactName = deploymentStore.getArtifactNameForFile(fileName);
try {
// CarbonApplication instance to delete
Library currentMediationLib = null;
// undeploying the local entries
Collection<Library> appList = getSynapseConfiguration().getSynapseLibraries().values();
for (Library mediationLib : appList) {
if (artifactName.equals(mediationLib.getQName().toString())) {
currentMediationLib = mediationLib;
}
}
if (currentMediationLib != null) {
for (String localEntry : currentMediationLib.getLocalEntries()) {
getSynapseConfiguration().removeEntry(localEntry);
}
}
// do un-deployment
undeploySynapseArtifact(artifactName);
deploymentStore.removeArtifactWithFileName(fileName);
log.info("Synapse Library named '" + artifactName + "' has been undeployed");
} catch (SynapseArtifactDeploymentException sade) {
log.error("Unable to undeploy the synapse library artifact from file : " + fileName, sade);
}
}
} else {
String msg = "Artifact representing the filename " + fileName + " is not deployed on Synapse";
log.error(msg);
throw new DeploymentException(msg);
}
if (log.isDebugEnabled()) {
log.debug("UnDeployment of the synapse library artifact from file : " + fileName + " : COMPLETED");
}
}
use of org.apache.synapse.libraries.model.Library in project wso2-synapse by wso2.
the class LibraryArtifactDeployer method undeploySynapseArtifact.
public void undeploySynapseArtifact(String artifactName) {
// get Old Lib config
Library existingLib = null;
try {
existingLib = getSynapseConfiguration().getSynapseLibraries().get(artifactName);
existingLib.unLoadLibrary();
getSynapseConfiguration().removeSynapseImport(artifactName);
getSynapseConfiguration().removeSynapseLibrary(artifactName);
} catch (DeploymentException e) {
handleDeploymentError(e.getMessage(), e);
}
}
Aggregations