Author: keith
Date: Tue Mar 25 07:30:52 2008
New Revision: 15083
Log:
Overiding undeploy method too
Modified:
trunk/mashup/java/modules/core/src/org/wso2/mashup/deployers/DBDeployer.java
Modified:
trunk/mashup/java/modules/core/src/org/wso2/mashup/deployers/DBDeployer.java
==============================================================================
---
trunk/mashup/java/modules/core/src/org/wso2/mashup/deployers/DBDeployer.java
(original)
+++
trunk/mashup/java/modules/core/src/org/wso2/mashup/deployers/DBDeployer.java
Tue Mar 25 07:30:52 2008
@@ -32,6 +32,8 @@
import org.wso2.mashup.MashupConstants;
import org.wso2.mashup.utils.MashupUtils;
import org.wso2.registry.RegistryConstants;
+import org.wso2.registry.RegistryException;
+import org.wso2.registry.jdbc.JDBCRegistry;
import org.wso2.registry.users.UserRealm;
import org.wso2.ws.dataservice.DBConstants;
@@ -39,6 +41,8 @@
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.HashMap;
public class DBDeployer extends org.wso2.ws.dataservice.DBDeployer {
@@ -109,6 +113,57 @@
}
}
+ /**
+ * This gets called when undeploying a java script web service deployed
+ * using this deployer. This gets called even when hotUpdating a service as
+ * Axis2 updeploy and redeploys the service when performing an hotUpdate.
+ *
+ * @throws DeploymentException
+ * @see org.apache.axis2.deployment.Deployer#unDeploy(java.lang.String)
+ */
+ public void unDeploy(String fileName) throws DeploymentException {
+ try {
+ File file = new File(fileName);
+ String shortFileName = file.getName();
+ String username = file.getParentFile().getName();
+
+ String serviceGroupName = username +
MashupConstants.SEPARATOR_CHAR +
+ shortFileName.substring(0, shortFileName.indexOf("."));
+ AxisServiceGroup group =
+ axisConfig.getServiceGroup(serviceGroupName);
+ AxisService service;
+ if (group != null) {
+ Iterator iterator = group.getServices();
+ service = (AxisService) iterator.next();
+ } else {
+ // May be a faulty service
+ axisConfig.removeFaultyService(fileName);
+ return;
+ }
+ if (service != null) {
+ //Removing the service from registry
+ Parameter myRegistryPath =
+
service.getParameter(MashupConstants.REGISTRY_MASHUP_PATH);
+ if (myRegistryPath != null && myRegistryPath.getValue()
instanceof String) {
+ JDBCRegistry registry =
+ (JDBCRegistry)
configCtx.getAxisConfiguration().getParameterValue(
+ RegistryConstants.REGISTRY);
+ registry.delete((String) myRegistryPath.getValue());
+ }
+ }
+
+ // There exist only one servicegroup for the JavaScript services
deployed from this deployer
+ axisConfig.removeServiceGroup(serviceGroupName);
+ configCtx.removeServiceGroupContext(group);
+ log.info(Messages.getMessage(DeploymentErrorMsgs.SERVICE_REMOVED,
serviceGroupName));
+
+ } catch (AxisFault axisFault) {
+ throw new DeploymentException(axisFault);
+ } catch (RegistryException e) {
+ throw new DeploymentException(e);
+ }
+ }
+
private ArrayList processService(DeploymentFileData currentFile,
AxisServiceGroup axisServiceGroup,
ConfigurationContext configCtx)
_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev