Author: heiko.braun(a)jboss.com
Date: 2009-12-07 09:14:35 -0500 (Mon, 07 Dec 2009)
New Revision: 371
Modified:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/EndpointManager.java
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/ServiceEndpointReference.java
Log:
Fix RIFTSAW-44: WS undeployment doesn't properly cleanup
Modified:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/EndpointManager.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/EndpointManager.java 2009-12-07
11:02:02 UTC (rev 370)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/EndpointManager.java 2009-12-07
14:14:35 UTC (rev 371)
@@ -27,7 +27,6 @@
import org.jboss.dependency.spi.ControllerContext;
import org.jboss.deployers.client.spi.DeployerClient;
import org.jboss.deployers.client.spi.Deployment;
-import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.attachments.MutableAttachments;
import org.jboss.deployers.structure.spi.ClassLoaderFactory;
import org.jboss.deployers.structure.spi.DeploymentUnit;
@@ -44,8 +43,12 @@
import javax.xml.namespace.QName;
import java.io.File;
+import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.RandomAccessFile;
import java.net.URL;
+import java.nio.channels.FileChannel;
+import java.nio.channels.FileLock;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -57,21 +60,21 @@
* @see org.jboss.soa.bpel.runtime.ws.AbstractWebServiceEndpoint
* @see org.jboss.soa.bpel.runtime.ws.WebServiceClient
* @see org.jboss.soa.bpel.runtime.engine.ode.JAXWSBindingContext
- *
+ *
* @author Heiko.Braun <heiko.braun(a)jboss.com>
*/
public class EndpointManager
{
protected final Log log = LogFactory.getLog(getClass());
- private Map<String, ServiceEndpointReference> endpointMapping = new
ConcurrentHashMap<String, ServiceEndpointReference>();
+ private Map<String, ServiceEndpointReference> endpointMapping = new
ConcurrentHashMap<String, ServiceEndpointReference>();
private ServerConfig serverConfig;
private ExecutionEnvironment executionEnvironment;
public EndpointManager(ExecutionEnvironment executionEnvironment)
{
- this.executionEnvironment = executionEnvironment;
+ this.executionEnvironment = executionEnvironment;
this.serverConfig = ServerConfigFactory.getServerConfig();
}
@@ -131,7 +134,7 @@
);
ref.setArchiveLocation(warArchive.getAbsolutePath());
-
+
endpointMapping.put(
createEndpointKey(metaData.getServiceName(), metaData.getPortName()),
ref
@@ -183,7 +186,7 @@
throws IOException
{
VirtualFile webAppVFS = VFS.getRoot(war.toURL());
- return VFSDeploymentFactory.getInstance().createVFSDeployment(webAppVFS);
+ return VFSDeploymentFactory.getInstance().createVFSDeployment(webAppVFS);
}
public void removeEndpoint(QName service, String port) throws
EndpointManagementException
@@ -196,10 +199,24 @@
{
try
{
+ // undeploy call
getMainDeployer().undeploy(deploymentId);
+
+ // unregister
endpointMapping.remove(key);
+
+ // remove physical artifacts
+ File warArchive = new File(ref.getArchiveLocation());
+ if(warArchive.exists())
+ {
+ if(!deleteDirectory(warArchive)) log.warn(warArchive + " could no be
deleted");
+ }
+ else
+ {
+ log.warn(ref.getArchiveLocation() + " cannot be removed (doesn't
exist).");
+ }
}
- catch (DeploymentException e)
+ catch (Exception e)
{
throw new EndpointManagementException("Failed to undeploy
"+deploymentId, e);
}
@@ -263,11 +280,27 @@
new WebServiceClient(metaData, wsdlRef, executionEnvironment);
return client;
-
+
}
catch (Exception e)
{
throw new EndpointManagementException("Failed to create endpoint", e);
}
}
+
+ static public boolean deleteDirectory(File path)
+ {
+ if( path.exists() ) {
+ File[] files = path.listFiles();
+ for(int i=0; i<files.length; i++) {
+ if(files[i].isDirectory()) {
+ deleteDirectory(files[i]);
+ }
+ else {
+ files[i].delete();
+ }
+ }
+ }
+ return( path.delete() );
+ }
}
Modified:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/ServiceEndpointReference.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/ServiceEndpointReference.java 2009-12-07
11:02:02 UTC (rev 370)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/ServiceEndpointReference.java 2009-12-07
14:14:35 UTC (rev 371)
@@ -25,19 +25,21 @@
import org.w3c.dom.Document;
/**
+ * References webservice endpoint deployment properties.
+ *
* @author Heiko.Braun <heiko.braun(a)jboss.com>
*/
public final class ServiceEndpointReference implements EndpointReference
{
private String endpointId;
- private String location;
+ private String serviceUrl;
private String deploymentName;
private String archiveLocation;
-
+
public ServiceEndpointReference(String endpointId, String location, String
deploymentName)
{
this.endpointId = endpointId;
- this.location = location;
+ this.serviceUrl = location;
this.deploymentName = deploymentName;
}
@@ -58,7 +60,7 @@
ret =
javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
org.w3c.dom.Element elem=ret.createElement("attr");
- elem.setAttribute("location", location);
+ elem.setAttribute("location", serviceUrl);
elem.setAttribute("endpointId", endpointId);
elem.setAttribute("deploymentName", deploymentName);
@@ -75,9 +77,9 @@
return endpointId;
}
- public String getLocation()
+ public String getServiceUrl()
{
- return location;
+ return serviceUrl;
}
public String getDeploymentName()
Show replies by date