Author: objectiser
Date: 2010-11-23 08:54:42 -0500 (Tue, 23 Nov 2010)
New Revision: 1137
Added:
dsp/trunk/src/main/java/org/jboss/soa/dsp/ws/BuildProcessor.java
Modified:
dsp/trunk/src/main/java/org/jboss/soa/dsp/ws/DeploymentBuilder.java
dsp/trunk/src/main/java/org/jboss/soa/dsp/ws/WebServiceProviderGenerator.java
Log:
Update interface for generator, and enable a 'build processor' to be processed
when building the deployment, as a means of performing platform specific steps.
Added: dsp/trunk/src/main/java/org/jboss/soa/dsp/ws/BuildProcessor.java
===================================================================
--- dsp/trunk/src/main/java/org/jboss/soa/dsp/ws/BuildProcessor.java
(rev 0)
+++ dsp/trunk/src/main/java/org/jboss/soa/dsp/ws/BuildProcessor.java 2010-11-23 13:54:42
UTC (rev 1137)
@@ -0,0 +1,26 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.soa.dsp.ws;
+
+import java.io.File;
+
+public interface BuildProcessor {
+
+ public void process(File war, File webInf, File wsdl);
+
+}
Modified: dsp/trunk/src/main/java/org/jboss/soa/dsp/ws/DeploymentBuilder.java
===================================================================
--- dsp/trunk/src/main/java/org/jboss/soa/dsp/ws/DeploymentBuilder.java 2010-11-23
11:02:48 UTC (rev 1136)
+++ dsp/trunk/src/main/java/org/jboss/soa/dsp/ws/DeploymentBuilder.java 2010-11-23
13:54:42 UTC (rev 1137)
@@ -27,12 +27,13 @@
public class DeploymentBuilder
{
- private static final String SI = "si";
+ private static final String DSP = "dsp";
private File war;
private File webInf;
private File wsdlDir;
- private DeploymentBuilder instance;
+
+ private javax.xml.ws.Provider<?> provider;
private ServerConfig serverConfig;
@@ -43,10 +44,10 @@
public DeploymentBuilder setEndpoint(String endpointId)
{
- File tmpDir = new File(serverConfig.getServerTempDir(), SI);
+ File tmpDir = new File(serverConfig.getServerTempDir(), DSP);
tmpDir.mkdir();
- File fakeWebApp = new File(tmpDir, SI+"-"+endpointId+".war");
+ File fakeWebApp = new File(tmpDir, DSP+"-"+endpointId+".war");
File fakeWebInf = new File(fakeWebApp, "WEB-INF");
fakeWebInf.mkdirs();
@@ -103,56 +104,15 @@
}
public DeploymentBuilder setProvider(javax.xml.ws.Provider<?> provider) {
+ this.provider = provider;
- // Check if jbossws-cxf.xml is present, and if so, updated the provider implementation
class attribute
- File f=new File(this.webInf, "jbossws-cxf.xml");
+ return(this);
+ }
+
+ public DeploymentBuilder process(BuildProcessor processor) {
+ processor.process(this.war, this.webInf, this.wsdlDir);
- if (f.exists()) {
- FileInputStream fis=null;
- FileOutputStream fos=null;
-
- try {
- fis=new FileInputStream(f);
-
- byte[] b=new byte[fis.available()];
- fis.read(b);
-
- String str=new String(b);
-
- fis.close();
- fis = null;
-
- if (str.indexOf("@provider@") != -1) {
- fos=new FileOutputStream(f);
-
- str = str.replaceAll("@provider@", provider.getClass().getName());
-
- fos.write(str.getBytes());
-
- fos.flush();
- fos.close();
-
- fos = null;
- } else {
- // Report error
- System.err.println("jbossws-cxf.xml file does not contain @provider@
field");
- }
-
- } catch (IOException e) {
- throw new RuntimeException("Failed to copy files", e);
- } finally {
- try {
- if (fis != null) fis.close();
- } catch (IOException e) {
- }
- try {
- if (fos != null) fos.close();
- } catch (IOException e) {
- }
- }
- }
-
- return this;
+ return(this);
}
public File build()
Modified: dsp/trunk/src/main/java/org/jboss/soa/dsp/ws/WebServiceProviderGenerator.java
===================================================================
---
dsp/trunk/src/main/java/org/jboss/soa/dsp/ws/WebServiceProviderGenerator.java 2010-11-23
11:02:48 UTC (rev 1136)
+++
dsp/trunk/src/main/java/org/jboss/soa/dsp/ws/WebServiceProviderGenerator.java 2010-11-23
13:54:42 UTC (rev 1137)
@@ -31,7 +31,9 @@
import javax.xml.namespace.QName;
+import org.jboss.soa.dsp.EndpointMetaData;
+
/**
* Creates JAX-WS Provider classes using javassist.
* These provider classes can then be deployed to JBossWS in memory.<p>
@@ -45,11 +47,10 @@
private final static String PKG_PREFIX =
WebServiceProviderGenerator.class.getPackage().getName()+".generated.";
public BaseWebServiceEndpoint createProvider(
- QName service, String port,
- String endpointId,
+ EndpointMetaData metaData,
WSDLReference wsdlRef,
ClassLoader loader,
- java.io.File handlerFile,
+ String handlerFilePath,
Class<? extends WebServiceProviderFactory> providerFactory
)
throws Exception
@@ -64,7 +65,7 @@
CtClass stringType = pool.get("java.lang.String");
- String implClassName = PKG_PREFIX+"WebServiceEndpoint_"+endpointId;
+ String implClassName =
PKG_PREFIX+"WebServiceEndpoint_"+metaData.getEndpointId();
//CtClass impl = pool.makeClass(implClassName);
// Load an existing class representing the template for a Web Service provider
@@ -78,12 +79,12 @@
// AbstractWebServiceEndpoint.endpointId property
CtField idField = new CtField(stringType, "endpointId", impl);
idField.setModifiers(Modifier.PUBLIC);
- impl.addField(idField, "\""+endpointId+"\"");
+ impl.addField(idField,
"\""+metaData.getEndpointId()+"\"");
// AbstractWebServiceEndpoint.serviceName property
CtField serviceField = new CtField(stringType, "serviceName", impl);
serviceField.setModifiers(Modifier.PUBLIC);
- impl.addField(serviceField,
"\""+service.toString()+"\"");
+ impl.addField(serviceField,
"\""+metaData.getServiceName().toString()+"\"");
// AbstractWebServiceEndpoint.wsdlLocation property
CtField wsdlLocationField = new CtField(stringType, "wsdlLocation", impl);
@@ -93,7 +94,7 @@
// AbstractWebServiceEndpoint.portName property
CtField portNameField = new CtField(stringType, "portName", impl);
portNameField.setModifiers(Modifier.PUBLIC);
- impl.addField(portNameField, "\""+port+"\"");
+ impl.addField(portNameField,
"\""+metaData.getPortName()+"\"");
// Annotations
ClassFile classFile = impl.getClassFile();
@@ -118,15 +119,15 @@
providerAnnotation.addMemberValue(
"serviceName",
- new StringMemberValue(service.getLocalPart(), constantPool)
+ new StringMemberValue(metaData.getServiceName().getLocalPart(), constantPool)
);
providerAnnotation.addMemberValue(
"portName",
- new StringMemberValue(port, constantPool)
+ new StringMemberValue(metaData.getPortName(), constantPool)
);
providerAnnotation.addMemberValue(
"targetNamespace",
- new StringMemberValue(service.getNamespaceURI(), constantPool)
+ new StringMemberValue(metaData.getServiceName().getNamespaceURI(), constantPool)
);
providerAnnotation.addMemberValue(
"wsdlLocation",
@@ -158,11 +159,11 @@
// Check if handler chain should be established
- if (handlerFile != null) {
+ if (handlerFilePath != null) {
Annotation handlerChain = new Annotation("javax.jws.HandlerChain",
constantPool);
handlerChain.addMemberValue("file",
- new StringMemberValue("/"+handlerFile.getName(), constantPool));
+ new StringMemberValue(handlerFilePath, constantPool));
attr.addAnnotation(handlerChain);
}