Author: objectiser
Date: 2011-01-07 09:16:35 -0500 (Fri, 07 Jan 2011)
New Revision: 1220
Added:
dsp/trunk/samples/example-deployer/deployer/
dsp/trunk/samples/example-deployer/deployer/resources/
dsp/trunk/samples/example-deployer/deployer/resources/META-INF/
dsp/trunk/samples/example-deployer/deployer/resources/META-INF/MANIFEST.MF
dsp/trunk/samples/example-deployer/deployer/resources/WEB-INF/
dsp/trunk/samples/example-deployer/deployer/resources/WEB-INF/classes/
dsp/trunk/samples/example-deployer/deployer/resources/WEB-INF/classes/dsp.properties
dsp/trunk/samples/example-deployer/deployer/resources/WEB-INF/lib/
dsp/trunk/samples/example-deployer/deployer/resources/WEB-INF/web.xml
dsp/trunk/samples/example-deployer/deployer/resources/files/
dsp/trunk/samples/example-deployer/deployer/resources/files/placeholder.txt
dsp/trunk/samples/example-deployer/deployer/src/
dsp/trunk/samples/example-deployer/deployer/src/org/
dsp/trunk/samples/example-deployer/deployer/src/org/jboss/
dsp/trunk/samples/example-deployer/deployer/src/org/jboss/soa/
dsp/trunk/samples/example-deployer/deployer/src/org/jboss/soa/dsp/
dsp/trunk/samples/example-deployer/deployer/src/org/jboss/soa/dsp/example/
dsp/trunk/samples/example-deployer/deployer/src/org/jboss/soa/dsp/example/DSPExampleForm.java
dsp/trunk/samples/example-deployer/deployer/src/org/jboss/soa/dsp/example/DeployServlet.java
dsp/trunk/samples/example-deployer/deployer/src/org/jboss/soa/dsp/example/DeployStore.java
dsp/trunk/samples/example-deployer/deployer/src/org/jboss/soa/dsp/example/UndeployServlet.java
dsp/trunk/samples/example-deployer/deployer/src/org/jboss/soa/dsp/example/WSDeployer.java
dsp/trunk/samples/example-deployer/deployer/src/org/jboss/soa/dsp/example/WelcomeServlet.java
dsp/trunk/samples/example-deployer/provider/
dsp/trunk/samples/example-deployer/provider/src/
dsp/trunk/samples/example-deployer/provider/src/org/
dsp/trunk/samples/example-deployer/provider/src/org/jboss/
dsp/trunk/samples/example-deployer/provider/src/org/jboss/soa/
dsp/trunk/samples/example-deployer/provider/src/org/jboss/soa/dsp/
dsp/trunk/samples/example-deployer/provider/src/org/jboss/soa/dsp/example/
dsp/trunk/samples/example-deployer/provider/src/org/jboss/soa/dsp/example/provider/
dsp/trunk/samples/example-deployer/provider/src/org/jboss/soa/dsp/example/provider/ExampleServiceProvider.java
dsp/trunk/samples/example-deployer/provider/src/org/jboss/soa/dsp/example/provider/ExampleWebServiceFactory.java
Log:
Changed way the example is distributed and built, to enable environment properties to be
changed by the user prior to building the example.
Added: dsp/trunk/samples/example-deployer/deployer/resources/META-INF/MANIFEST.MF
===================================================================
--- dsp/trunk/samples/example-deployer/deployer/resources/META-INF/MANIFEST.MF
(rev 0)
+++ dsp/trunk/samples/example-deployer/deployer/resources/META-INF/MANIFEST.MF 2011-01-07
14:16:35 UTC (rev 1220)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Added:
dsp/trunk/samples/example-deployer/deployer/resources/WEB-INF/classes/dsp.properties
===================================================================
--- dsp/trunk/samples/example-deployer/deployer/resources/WEB-INF/classes/dsp.properties
(rev 0)
+++
dsp/trunk/samples/example-deployer/deployer/resources/WEB-INF/classes/dsp.properties 2011-01-07
14:16:35 UTC (rev 1220)
@@ -0,0 +1,5 @@
+#dsp.server.config.locator = org.jboss.soa.dsp.server.tomcat.TomcatServerConfigLocator
+#dsp.service.deployer = org.jboss.soa.dsp.deployer.tomcat.TomcatServiceDeployer
+
+dsp.server.config.locator = org.jboss.soa.dsp.server.jboss.ServerConfigFactory
+dsp.service.deployer = org.jboss.soa.dsp.deployer.jboss.JBossServiceDeployer
Added: dsp/trunk/samples/example-deployer/deployer/resources/WEB-INF/web.xml
===================================================================
--- dsp/trunk/samples/example-deployer/deployer/resources/WEB-INF/web.xml
(rev 0)
+++ dsp/trunk/samples/example-deployer/deployer/resources/WEB-INF/web.xml 2011-01-07
14:16:35 UTC (rev 1220)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID"
version="2.5">
+ <display-name>DSPExample</display-name>
+ <welcome-file-list>
+ <welcome-file>WelcomeServlet</welcome-file>
+ </welcome-file-list>
+ <servlet>
+ <description></description>
+ <display-name>WelcomeServlet</display-name>
+ <servlet-name>WelcomeServlet</servlet-name>
+ <servlet-class>org.jboss.soa.dsp.example.WelcomeServlet</servlet-class>
+ </servlet>
+ <servlet>
+ <description></description>
+ <display-name>DeployServlet</display-name>
+ <servlet-name>DeployServlet</servlet-name>
+ <servlet-class>org.jboss.soa.dsp.example.DeployServlet</servlet-class>
+ </servlet>
+ <servlet>
+ <description></description>
+ <display-name>UndeployServlet</display-name>
+ <servlet-name>UndeployServlet</servlet-name>
+ <servlet-class>org.jboss.soa.dsp.example.UndeployServlet</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>WelcomeServlet</servlet-name>
+ <url-pattern>/WelcomeServlet</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>DeployServlet</servlet-name>
+ <url-pattern>/DeployServlet</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>UndeployServlet</servlet-name>
+ <url-pattern>/UndeployServlet</url-pattern>
+ </servlet-mapping>
+</web-app>
\ No newline at end of file
Added: dsp/trunk/samples/example-deployer/deployer/resources/files/placeholder.txt
===================================================================
--- dsp/trunk/samples/example-deployer/deployer/resources/files/placeholder.txt
(rev 0)
+++ dsp/trunk/samples/example-deployer/deployer/resources/files/placeholder.txt 2011-01-07
14:16:35 UTC (rev 1220)
@@ -0,0 +1 @@
+Placeholder to cause 'files' folder to be included in war.
\ No newline at end of file
Added:
dsp/trunk/samples/example-deployer/deployer/src/org/jboss/soa/dsp/example/DSPExampleForm.java
===================================================================
---
dsp/trunk/samples/example-deployer/deployer/src/org/jboss/soa/dsp/example/DSPExampleForm.java
(rev 0)
+++
dsp/trunk/samples/example-deployer/deployer/src/org/jboss/soa/dsp/example/DSPExampleForm.java 2011-01-07
14:16:35 UTC (rev 1220)
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2010 Red Hat, Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.jboss.soa.dsp.example;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+public class DSPExampleForm {
+
+ public static void buildForm(PrintWriter out) throws IOException {
+
+ out.println("<h2>Deploy Web Service</h2>");
+ out.println("<form action=\"DeployServlet\"
enctype=\"multipart/form-data\" method=\"POST\">");
+ out.println("\t<input type=\"file\"
name=\"file1\"><br>");
+ out.println("\t<input type=\"Submit\"
value=\"Deploy\"><br>");
+ out.println("</form>");
+
+ java.util.Set<String> keys=DeployStore.keys();
+
+ if (keys.size() > 0) {
+
+ out.println("======================================================================<br>");
+ out.println("<h2>Undeploy Web Service</h2>");
+
+ out.println("<form action=\"UndeployServlet\"
method=\"post\">");
+ out.println("<table>");
+ out.println("<tr>");
+
+ out.println("<select name=\"seref\">");
+
+ for (String key : keys) {
+ //out.println("<td><textarea rows=\"5\" cols=\"50\"
name=\"seref\">"+key+"</textarea></td>");
+ out.println("<option
value=\""+key+"\">"+key+"</option>");
+ }
+
+ out.println("</select>");
+
+ out.println("<td><input type=\"submit\"
value=\"Undeploy\"></td>");
+ out.println("</tr>");
+ out.println("</table>");
+ out.println("</form>");
+ }
+ }
+}
Added:
dsp/trunk/samples/example-deployer/deployer/src/org/jboss/soa/dsp/example/DeployServlet.java
===================================================================
---
dsp/trunk/samples/example-deployer/deployer/src/org/jboss/soa/dsp/example/DeployServlet.java
(rev 0)
+++
dsp/trunk/samples/example-deployer/deployer/src/org/jboss/soa/dsp/example/DeployServlet.java 2011-01-07
14:16:35 UTC (rev 1220)
@@ -0,0 +1,169 @@
+/*
+ * Copyright 2010 Red Hat, Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.jboss.soa.dsp.example;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Iterator;
+import java.util.List;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.fileupload.FileUploadException;
+import org.apache.commons.fileupload.disk.DiskFileItemFactory;
+import org.apache.commons.fileupload.servlet.ServletFileUpload;
+
+
+public class DeployServlet extends HttpServlet {
+ private static final long serialVersionUID = 1L;
+
+ private static final String TMP_DIR_PATH = "/tmp";
+ private File tmpDir;
+ private static final String DESTINATION_DIR_PATH ="/files";
+ private File destinationDir;
+
+ public void init(ServletConfig config) throws ServletException {
+ super.init(config);
+ tmpDir = new File(TMP_DIR_PATH);
+ if(!tmpDir.isDirectory()) {
+ throw new ServletException(TMP_DIR_PATH + " is not a directory");
+ }
+ String realPath = getServletContext().getRealPath(DESTINATION_DIR_PATH);
+ destinationDir = new File(realPath);
+ if(!destinationDir.isDirectory()) {
+ throw new ServletException(DESTINATION_DIR_PATH+" is not a directory");
+ }
+
+ }
+
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
+ PrintWriter out = response.getWriter();
+ response.setContentType("text/html");
+ out.println("<h1>Dynamic Service Provider Example</h1>");
+ out.println();
+
+ DiskFileItemFactory fileItemFactory = new DiskFileItemFactory ();
+ /*
+ *Set the size threshold, above which content will be stored on disk.
+ */
+ fileItemFactory.setSizeThreshold(1*1024*1024); //1 MB
+ /*
+ * Set the temporary directory to store the uploaded files of size above threshold.
+ */
+ fileItemFactory.setRepository(tmpDir);
+
+ ServletFileUpload uploadHandler = new ServletFileUpload(fileItemFactory);
+ try {
+ /*
+ * Parse the request
+ */
+ List items = uploadHandler.parseRequest(request);
+ Iterator itr = items.iterator();
+ while(itr.hasNext()) {
+ FileItem item = (FileItem) itr.next();
+ /*
+ * Handle Form Fields.
+ */
+ if(item.isFormField()) {
+ out.println("File Name = "+item.getFieldName()+", Value =
"+item.getString());
+ } else if (item.getName().endsWith(".zip") == false) {
+ out.println("File must be a '.zip' archive!");
+ } else {
+ //Handle Uploaded files.
+ out.println("Uploading File: "+item.getName()+"<br>");
+
+ /*
+ * Write file to the ultimate location.
+ */
+ File file = new File(destinationDir,item.getName().substring(0,
item.getName().length()-4));
+
+ file.mkdir();
+
+ File wsdlFile=unzip(out, new java.util.zip.ZipInputStream(item.getInputStream()),
file.getAbsolutePath());
+
+ if (wsdlFile == null) {
+ out.println("ERROR: No WSDL definition found!!!<br>");
+ } else {
+ // Invoke dynamic service deployment mechanism
+ WSDeployer deployer=new WSDeployer();
+
+ DeployStore.add(deployer.deploy(file, wsdlFile));
+ }
+
+ // Display undeployment options
+ DSPExampleForm.buildForm(out);
+ }
+
+ out.close();
+ }
+ }catch(FileUploadException ex) {
+ log("Error encountered while parsing the request",ex);
+ } catch(Exception ex) {
+ log("Error encountered while uploading file",ex);
+ }
+
+ }
+
+ protected java.io.File unzip(PrintWriter out, ZipInputStream zis, String path) throws
IOException {
+ ZipEntry ze=null;
+ java.io.File wsdlFile=null;
+
+ out.println("Unzipping file ....<br>");
+
+ while ((ze=zis.getNextEntry()) != null) {
+
+ if (ze.isDirectory()) {
+ java.io.File f=new java.io.File(path+java.io.File.separatorChar+ze.getName());
+ f.mkdirs();
+ } else {
+ out.println("Unzip: "+ze.getName()+"<br>");
+ unzipEntry(zis, ze.getName(), path);
+
+ if (ze.getName().endsWith(".wsdl")) {
+ wsdlFile = new java.io.File(path+java.io.File.separatorChar+ze.getName());
+ }
+ }
+ }
+
+ out.println("Zip unpacked.<br><br>");
+ zis.close();
+
+ return(wsdlFile);
+ }
+
+ protected void unzipEntry(ZipInputStream zis, String name, String path) throws
IOException {
+ System.out.println("\t\tunzipping "+name+"<br>");
+ FileOutputStream fos = new FileOutputStream(path+java.io.File.separatorChar+name);
+ byte[] b=new byte[1024];
+ int len=0;
+
+ while ((len=zis.read(b)) != -1) {
+ fos.write(b,0,len);
+ }
+
+ fos.close();
+ }
+}
\ No newline at end of file
Added:
dsp/trunk/samples/example-deployer/deployer/src/org/jboss/soa/dsp/example/DeployStore.java
===================================================================
---
dsp/trunk/samples/example-deployer/deployer/src/org/jboss/soa/dsp/example/DeployStore.java
(rev 0)
+++
dsp/trunk/samples/example-deployer/deployer/src/org/jboss/soa/dsp/example/DeployStore.java 2011-01-07
14:16:35 UTC (rev 1220)
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2010 Red Hat, Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.jboss.soa.dsp.example;
+
+import org.jboss.soa.dsp.ServiceEndpointReference;
+
+public class DeployStore {
+
+ private static java.util.Map<String,ServiceEndpointReference>
m_serviceEndpointRefs=
+ new java.util.HashMap<String,ServiceEndpointReference>();
+
+ public static void add(ServiceEndpointReference ser) {
+ m_serviceEndpointRefs.put(ser.getDeploymentName(), ser);
+ }
+
+ public static void remove(ServiceEndpointReference ser) {
+ m_serviceEndpointRefs.remove(ser.getDeploymentName());
+ }
+
+ public static java.util.Set<String> keys() {
+ return(m_serviceEndpointRefs.keySet());
+ }
+
+ public static ServiceEndpointReference get(String key) {
+ return(m_serviceEndpointRefs.get(key));
+ }
+}
Added:
dsp/trunk/samples/example-deployer/deployer/src/org/jboss/soa/dsp/example/UndeployServlet.java
===================================================================
---
dsp/trunk/samples/example-deployer/deployer/src/org/jboss/soa/dsp/example/UndeployServlet.java
(rev 0)
+++
dsp/trunk/samples/example-deployer/deployer/src/org/jboss/soa/dsp/example/UndeployServlet.java 2011-01-07
14:16:35 UTC (rev 1220)
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2010 Red Hat, Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.jboss.soa.dsp.example;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.jboss.soa.dsp.ServiceEndpointReference;
+
+public class UndeployServlet extends HttpServlet {
+ private static final long serialVersionUID = 1L;
+
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
+ PrintWriter out = response.getWriter();
+ response.setContentType("text/html");
+ out.println("<h1>Dynamic Service Provider Example</h1>");
+ out.println();
+
+ ServiceEndpointReference
ser=DeployStore.get((String)request.getParameter("seref"));
+
+ if (ser == null) {
+ out.println("ERROR: Unable to find service endpoint reference with key
'"+
+ request.getAttribute("seref")+"'<br>");
+ } else {
+ WSDeployer deployer=new WSDeployer();
+
+ try {
+ deployer.undeploy(ser);
+
+ DeployStore.remove(ser);
+
+ } catch(Exception e) {
+ out.println("ERROR: Unable to undeploy service endpoint reference with key
'"+
+ request.getAttribute("seref")+"'<br>");
+ e.printStackTrace();
+ }
+ }
+
+ DSPExampleForm.buildForm(out);
+
+ out.close();
+ }
+}
\ No newline at end of file
Added:
dsp/trunk/samples/example-deployer/deployer/src/org/jboss/soa/dsp/example/WSDeployer.java
===================================================================
---
dsp/trunk/samples/example-deployer/deployer/src/org/jboss/soa/dsp/example/WSDeployer.java
(rev 0)
+++
dsp/trunk/samples/example-deployer/deployer/src/org/jboss/soa/dsp/example/WSDeployer.java 2011-01-07
14:16:35 UTC (rev 1220)
@@ -0,0 +1,184 @@
+/*
+ * Copyright 2010 Red Hat, Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.jboss.soa.dsp.example;
+
+import java.io.File;
+import java.net.URL;
+import java.util.ResourceBundle;
+import java.util.UUID;
+import java.util.logging.Level;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.soa.dsp.EndpointMetaData;
+import org.jboss.soa.dsp.ServiceEndpointReference;
+import org.jboss.soa.dsp.deployer.ServiceDeployer;
+import org.jboss.soa.dsp.example.provider.ExampleWebServiceFactory;
+import org.jboss.soa.dsp.server.ServerConfig;
+import org.jboss.soa.dsp.ws.BaseWebServiceEndpoint;
+import org.jboss.soa.dsp.ws.DeploymentBuilder;
+import org.jboss.soa.dsp.ws.WSDLParser;
+import org.jboss.soa.dsp.ws.WSDLReference;
+import org.jboss.soa.dsp.ws.WebServiceProviderGenerator;
+
+public class WSDeployer {
+
+ private static java.util.logging.Logger
_log=java.util.logging.Logger.getLogger(WSDeployer.class.getPackage().getName());
+
+ private static final String DSP_SERVER_CONFIG_LOCATOR =
"dsp.server.config.locator";
+ private static final String DSP_SERVICE_DEPLOYER = "dsp.service.deployer";
+
+ public WSDeployer() {
+ }
+
+ /**
+ * Deploy the web service, using the artifacts contained within the supplied the root
folder
+ * and based on the WSDL definition located in the supplied WSDL file.
+ *
+ * @param root The root folder containing the artifacts to be included in the web
service
+ * @param wsdlFile The WSDL definition upon which the web service interface will be
based
+ * @return The service endpoint reference of the deployed web service
+ */
+ public ServiceEndpointReference deploy(java.io.File root, java.io.File wsdlFile) throws
Exception {
+ ServiceEndpointReference ref=null;
+
+ ClassLoader cl=WSDeployer.class.getClassLoader();
+
+ javax.wsdl.factory.WSDLFactory factory=javax.wsdl.factory.WSDLFactory.newInstance();
+ javax.wsdl.Definition wsdl=factory.newWSDLReader().readWSDL(null,
wsdlFile.getAbsolutePath());
+
+ WSDLReference wsdlRef=new WSDLReference(wsdl, wsdlFile.toURI());
+
+ WebServiceProviderGenerator providerFactory = new WebServiceProviderGenerator();
+
+ javax.wsdl.Service
service=(javax.wsdl.Service)wsdl.getServices().values().iterator().next();
+
+ _log.fine("SERVICE="+service);
+
+ javax.wsdl.Port port=(javax.wsdl.Port)service.getPorts().values().iterator().next();
+
+ _log.fine("PORT="+port);
+
+ EndpointMetaData metaData=new EndpointMetaData(service.getQName(),
+ port.getName(), new QName("http://www.example.org",
"ProcessId"),
+ UUID.randomUUID().toString());
+
+ File warArchive = null;
+ try {
+ BaseWebServiceEndpoint providerImpl =
+ providerFactory.createProvider(metaData, wsdlRef, cl,
+ null, ExampleWebServiceFactory.class);
+
+ _log.fine("Provider="+providerImpl);
+
+ ServerConfig serverConfig=getServerConfig();
+
+ ServiceDeployer deployer=getServiceDeployer();
+
+ warArchive = new DeploymentBuilder(serverConfig)
+ .setEndpoint(metaData.getEndpointId())
+ .setWSDL(wsdlFile, root)
+ .setProvider(providerImpl)
+ .process(deployer.getBuildProcessor())
+ .build();
+
+ providerFactory.writeClass(warArchive);
+
+ _log.fine("War Archive="+warArchive);
+
+ URL serviceUrl = new
WSDLParser(wsdlRef.getDefinition()).getServiceLocationURL(metaData.getServiceName(),
+ metaData.getPortName());
+
+ _log.fine("Service URL="+serviceUrl);
+
+ ref = deployer.deploy(metaData, providerImpl.getClass(),
+ serviceUrl, cl, warArchive, getServerConfig());
+
+ } catch (Throwable t) {
+ _log.log(Level.SEVERE, "Failed", t);
+ }
+
+ _log.fine("DEPLOYED endpoint ref="+ref);
+
+ return(ref);
+ }
+
+ public void undeploy(ServiceEndpointReference ref) throws Exception {
+ ServiceDeployer deployer=getServiceDeployer();
+
+ deployer.undeploy(ref, getServerConfig());
+ }
+
+ protected ServerConfig getServerConfig() {
+ ServerConfig ret=null;
+
+ // Get service config factory class from properties file
+ ResourceBundle res=ResourceBundle.getBundle("dsp");
+
+ if (res != null) {
+ String locator=res.getString(DSP_SERVER_CONFIG_LOCATOR);
+
+ if (locator != null) {
+ try {
+ Class<?> cls=Class.forName(locator);
+
+ org.jboss.soa.dsp.server.ServerConfigLocator scl=
+ (org.jboss.soa.dsp.server.ServerConfigLocator)cls.newInstance();
+
+ ret = scl.getServerConfig();
+
+ } catch(Exception e) {
+ _log.log(Level.SEVERE, "Failed to get server config from locator
'"+locator+"'", e);
+ }
+ } else {
+ _log.severe("Failed to find server locator property
'"+DSP_SERVER_CONFIG_LOCATOR+"'");
+ }
+ } else {
+ _log.severe("Unable to find dsp.properties");
+ }
+
+ return(ret);
+ }
+
+ protected ServiceDeployer getServiceDeployer() {
+ ServiceDeployer ret=null;
+
+ // Get service config factory class from properties file
+ ResourceBundle res=ResourceBundle.getBundle("dsp");
+
+ if (res != null) {
+ String deployer=res.getString(DSP_SERVICE_DEPLOYER);
+
+ if (deployer != null) {
+ try {
+ Class<?> cls=Class.forName(deployer);
+
+ ret = (ServiceDeployer)cls.newInstance();
+
+ } catch(Exception e) {
+ _log.log(Level.SEVERE, "Failed to get service deployer
'"+deployer+"'", e);
+ }
+ } else {
+ _log.severe("Failed to find service deployer property
'"+DSP_SERVICE_DEPLOYER+"'");
+ }
+ } else {
+ _log.severe("Unable to find dsp.properties");
+ }
+
+ return(ret);
+ }
+}
Added:
dsp/trunk/samples/example-deployer/deployer/src/org/jboss/soa/dsp/example/WelcomeServlet.java
===================================================================
---
dsp/trunk/samples/example-deployer/deployer/src/org/jboss/soa/dsp/example/WelcomeServlet.java
(rev 0)
+++
dsp/trunk/samples/example-deployer/deployer/src/org/jboss/soa/dsp/example/WelcomeServlet.java 2011-01-07
14:16:35 UTC (rev 1220)
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2010 Red Hat, Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.jboss.soa.dsp.example;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class WelcomeServlet extends HttpServlet {
+ private static final long serialVersionUID = 1L;
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
+ PrintWriter out = response.getWriter();
+ response.setContentType("text/html");
+ out.println("<h1>Dynamic Service Provider Example</h1>");
+ out.println();
+
+ DSPExampleForm.buildForm(out);
+
+ out.close();
+ }
+}
\ No newline at end of file
Added:
dsp/trunk/samples/example-deployer/provider/src/org/jboss/soa/dsp/example/provider/ExampleServiceProvider.java
===================================================================
---
dsp/trunk/samples/example-deployer/provider/src/org/jboss/soa/dsp/example/provider/ExampleServiceProvider.java
(rev 0)
+++
dsp/trunk/samples/example-deployer/provider/src/org/jboss/soa/dsp/example/provider/ExampleServiceProvider.java 2011-01-07
14:16:35 UTC (rev 1220)
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2010 Red Hat, Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.jboss.soa.dsp.example.provider;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.soa.dsp.InvocationAdapter;
+import org.jboss.soa.dsp.MessageAdapter;
+import org.jboss.soa.dsp.ServiceProvider;
+import org.jboss.soa.dsp.ws.WSInvocationAdapter;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+public class ExampleServiceProvider implements ServiceProvider {
+
+ public void invoke(InvocationAdapter<?> arg0) throws Exception {
+ System.out.println("EXAMPLE SERVICE PROVIDER: invoke "+arg0);
+
+ arg0.createFault(null, new QName("http://www.example.org",
"ExampleFault"),
+ new MessageAdapter() {
+
+ public Map<String, Node> getHeaderParts() {
+ return new HashMap<String,Node>();
+ }
+
+ public Element getMessage() {
+ Element ret=null;
+
+ try {
+ ret = javax.xml.parsers.DocumentBuilderFactory.newInstance().
+ newDocumentBuilder().newDocument().createElement("ExampleFaultDetails");
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+
+ return(ret);
+ }
+
+ public Element getPart(String arg0) {
+ return null;
+ }
+
+ public void setHeaderPart(String arg0, Element arg1) {
+ }
+
+ public void setPart(String arg0, Element arg1) {
+ }
+
+ });
+ }
+
+}
Added:
dsp/trunk/samples/example-deployer/provider/src/org/jboss/soa/dsp/example/provider/ExampleWebServiceFactory.java
===================================================================
---
dsp/trunk/samples/example-deployer/provider/src/org/jboss/soa/dsp/example/provider/ExampleWebServiceFactory.java
(rev 0)
+++
dsp/trunk/samples/example-deployer/provider/src/org/jboss/soa/dsp/example/provider/ExampleWebServiceFactory.java 2011-01-07
14:16:35 UTC (rev 1220)
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2010 Red Hat, Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.jboss.soa.dsp.example.provider;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.soa.dsp.ServiceProvider;
+import org.jboss.soa.dsp.ws.SOAPMessageAdapter;
+import org.jboss.soa.dsp.ws.WSInvocationAdapter;
+import org.jboss.soa.dsp.ws.WebServiceProviderFactory;
+
+public class ExampleWebServiceFactory implements WebServiceProviderFactory {
+
+ public ServiceProvider getServiceProvider() {
+ return(new ExampleServiceProvider());
+ }
+
+ public WSInvocationAdapter getInvocationAdapter(String operationName,
+ QName serviceName, String portName, SOAPMessageAdapter soapAdapter) {
+ return(new WSInvocationAdapter(operationName,
+ serviceName, portName, soapAdapter));
+ }
+}