Author: heiko.braun(a)jboss.com
Date: 2009-11-23 11:52:29 -0500 (Mon, 23 Nov 2009)
New Revision: 302
Added:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/DeploymentBuilder.java
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:
Copy WSDL artifacts when creating web service deployment
Added:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/DeploymentBuilder.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/DeploymentBuilder.java
(rev 0)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/DeploymentBuilder.java 2009-11-23
16:52:29 UTC (rev 302)
@@ -0,0 +1,127 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.soa.bpel.runtime.ws;
+
+import org.jboss.soa.bpel.runtime.integration.ServerConfig;
+
+import java.io.*;
+
+class DeploymentBuilder
+{
+ private File war;
+ private File webInf;
+ private File wsdlDir;
+ private DeploymentBuilder instance;
+
+ private ServerConfig serverConfig;
+
+ public DeploymentBuilder(ServerConfig serverConfig)
+ {
+ this.serverConfig = serverConfig;
+ }
+
+ public DeploymentBuilder setEndpoint(String endpointId)
+ {
+ File tmpDir = new File(serverConfig.getServerTempDir(), "riftsaw");
+
+ tmpDir.mkdir();
+ File fakeWebApp = new File(tmpDir,
"riftsaw-"+endpointId+".war");
+ File fakeWebInf = new File(fakeWebApp, "WEB-INF");
+ fakeWebInf.mkdirs();
+
+ // Workaround
+ // See
https://jira.jboss.org/jira/browse/JBWS-2718
+ File fakeWSDLDir = new File(fakeWebInf, "wsdl");
+ fakeWSDLDir.mkdirs();
+
+ this.war = fakeWebApp;
+ this.webInf = fakeWebInf;
+ this.wsdlDir = fakeWSDLDir;
+
+ return this;
+ }
+
+ public DeploymentBuilder setWSDL(File wsdl)
+ {
+ copy(wsdl, new File(this.wsdlDir, wsdl.getName()));
+
+ // any related artifact as well (brute force, I know)
+ File parent = wsdl.getParentFile();
+ assert parent.isDirectory();
+ for(File f : parent.listFiles())
+ {
+ if(f.equals(wsdl)) continue;
+ copy(f, new File(this.wsdlDir, f.getName()));
+ }
+ return this;
+ }
+
+ public File build()
+ {
+ return this.war;
+ }
+
+ public static synchronized void copy(File src, File dest)
+ {
+ InputStream in = null;
+ OutputStream out = null;
+
+ try
+ {
+ in = new FileInputStream(src);
+ out = new FileOutputStream(dest);
+
+ // Transfer bytes from in to out
+ byte[] buf = new byte[1024];
+ int len;
+ while ((len = in.read(buf)) > 0) {
+ out.write(buf, 0, len);
+ }
+ in.close();
+ out.close();
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException("Failed to copy files", e);
+ }
+ finally
+ {
+ try
+ {
+ if(in!=null) in.close();
+ }
+ catch (IOException e)
+ {
+ //
+ }
+
+ try
+ {
+ if(out!=null) out.close();
+ }
+ catch (IOException e)
+ {
+ //
+ }
+ }
+ }
+}
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-11-23
16:51:40 UTC (rev 301)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/EndpointManager.java 2009-11-23
16:52:29 UTC (rev 302)
@@ -51,7 +51,7 @@
/**
* Manages creation and destroyal of web service endpoints and clients.
- * This instance is stateful and retain references to both endpoints and clients.
+ * This instance is stateful and retains references to both endpoints and clients.
* As such it should only exists once.
*
* @see org.jboss.soa.bpel.runtime.ws.AbstractWebServiceEndpoint
@@ -81,9 +81,14 @@
try
{
- // create deployment structure
+ // create deployment structure (maybe replaced by shrinkwrap)
+ File warArchive = new DeploymentBuilder(serverConfig)
+ .setEndpoint(metaData.getEndpointId())
+ .setWSDL(wsdlRef.getWsdlFile())
+ .build();
+
//Deployment deployment = createInMemoryDeployment(endpointId);
- Deployment deployment = createVFSDeployment(metaData.getEndpointId());
+ Deployment deployment = createVFSDeployment(warArchive);
// generate provider impl
WebServiceProviderFactory providerFactory = new WebServiceProviderFactory();
@@ -126,6 +131,8 @@
metaData.getEndpointId(), serviceUrl.toExternalForm(), deployment.getName()
);
+ ref.setArchiveLocation(warArchive.getAbsolutePath());
+
endpointMapping.put(
createEndpointKey(metaData.getServiceName(), metaData.getPortName()),
ref
@@ -173,18 +180,11 @@
return deployment;
}*/
- private Deployment createVFSDeployment(String endpointId)
+ private Deployment createVFSDeployment(File war)
throws IOException
{
- File tmpDir = new File(serverConfig.getServerTempDir(), "riftsaw");
- tmpDir.mkdir();
- File fakeWebApp = new File(tmpDir,
"riftsaw-"+endpointId+".war");
- File fakeWebInf = new File(fakeWebApp, "WEB-INF");
- fakeWebInf.mkdirs();
-
- VirtualFile webAppVFS = VFS.getRoot(fakeWebApp.toURL());
- Deployment deployment =
VFSDeploymentFactory.getInstance().createVFSDeployment(webAppVFS);
- return deployment;
+ VirtualFile webAppVFS = VFS.getRoot(war.toURL());
+ return VFSDeploymentFactory.getInstance().createVFSDeployment(webAppVFS);
}
public void removeEndpoint(QName service, String port) throws
EndpointManagementException
@@ -207,7 +207,7 @@
}
else
{
- log.warn("Endpoint not found for removal:"+key);
+ log.warn("Endpoint not found for removal: "+key);
}
}
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-11-23
16:51:40 UTC (rev 301)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/ServiceEndpointReference.java 2009-11-23
16:52:29 UTC (rev 302)
@@ -32,7 +32,8 @@
private String endpointId;
private String location;
private String deploymentName;
-
+ private String archiveLocation;
+
public ServiceEndpointReference(String endpointId, String location, String
deploymentName)
{
this.endpointId = endpointId;
@@ -40,6 +41,16 @@
this.deploymentName = deploymentName;
}
+ public String getArchiveLocation()
+ {
+ return archiveLocation;
+ }
+
+ public void setArchiveLocation(String archiveLocation)
+ {
+ this.archiveLocation = archiveLocation;
+ }
+
public Document toXML() {
Document ret=null;