Author: objectiser
Date: 2010-12-01 09:14:35 -0500 (Wed, 01 Dec 2010)
New Revision: 1174
Added:
dsp/trunk/samples/deployer/src/main/java/org/jboss/soa/dsp/example/DSPExampleForm.java
dsp/trunk/samples/deployer/src/main/java/org/jboss/soa/dsp/example/DeployStore.java
dsp/trunk/samples/deployer/src/main/java/org/jboss/soa/dsp/example/UndeployServlet.java
dsp/trunk/samples/deployer/src/main/java/org/jboss/soa/dsp/example/WelcomeServlet.java
Removed:
dsp/trunk/samples/deployer/src/main/webapp/upload.html
Modified:
dsp/trunk/samples/deployer/src/main/java/org/jboss/soa/dsp/example/DeployServlet.java
dsp/trunk/samples/deployer/src/main/webapp/WEB-INF/web.xml
Log:
Add undeploy support.
Added:
dsp/trunk/samples/deployer/src/main/java/org/jboss/soa/dsp/example/DSPExampleForm.java
===================================================================
---
dsp/trunk/samples/deployer/src/main/java/org/jboss/soa/dsp/example/DSPExampleForm.java
(rev 0)
+++
dsp/trunk/samples/deployer/src/main/java/org/jboss/soa/dsp/example/DSPExampleForm.java 2010-12-01
14:14:35 UTC (rev 1174)
@@ -0,0 +1,59 @@
+/*
+ * 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.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>");
+ }
+ }
+}
Modified:
dsp/trunk/samples/deployer/src/main/java/org/jboss/soa/dsp/example/DeployServlet.java
===================================================================
---
dsp/trunk/samples/deployer/src/main/java/org/jboss/soa/dsp/example/DeployServlet.java 2010-12-01
10:08:22 UTC (rev 1173)
+++
dsp/trunk/samples/deployer/src/main/java/org/jboss/soa/dsp/example/DeployServlet.java 2010-12-01
14:14:35 UTC (rev 1174)
@@ -62,7 +62,7 @@
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 -
Deployer</h1>");
+ out.println("<h1>Dynamic Service Provider Example</h1>");
out.println();
DiskFileItemFactory fileItemFactory = new DiskFileItemFactory ();
@@ -110,10 +110,13 @@
// Invoke dynamic service deployment mechanism
WSDeployer deployer=new WSDeployer();
- deployer.deploy(file, wsdlFile);
-
+ DeployStore.add(deployer.deploy(file, wsdlFile));
}
+
+ // Display undeployment options
+ DSPExampleForm.buildForm(out);
}
+
out.close();
}
}catch(FileUploadException ex) {
@@ -123,7 +126,7 @@
}
}
-
+
protected java.io.File unzip(PrintWriter out, ZipInputStream zis, String path) throws
IOException {
ZipEntry ze=null;
java.io.File wsdlFile=null;
@@ -145,7 +148,7 @@
}
}
- out.println("Closing zip.<br>");
+ out.println("Zip unpacked.<br><br>");
zis.close();
return(wsdlFile);
Added:
dsp/trunk/samples/deployer/src/main/java/org/jboss/soa/dsp/example/DeployStore.java
===================================================================
--- dsp/trunk/samples/deployer/src/main/java/org/jboss/soa/dsp/example/DeployStore.java
(rev 0)
+++
dsp/trunk/samples/deployer/src/main/java/org/jboss/soa/dsp/example/DeployStore.java 2010-12-01
14:14:35 UTC (rev 1174)
@@ -0,0 +1,42 @@
+/*
+ * 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.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/deployer/src/main/java/org/jboss/soa/dsp/example/UndeployServlet.java
===================================================================
---
dsp/trunk/samples/deployer/src/main/java/org/jboss/soa/dsp/example/UndeployServlet.java
(rev 0)
+++
dsp/trunk/samples/deployer/src/main/java/org/jboss/soa/dsp/example/UndeployServlet.java 2010-12-01
14:14:35 UTC (rev 1174)
@@ -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/deployer/src/main/java/org/jboss/soa/dsp/example/WelcomeServlet.java
===================================================================
---
dsp/trunk/samples/deployer/src/main/java/org/jboss/soa/dsp/example/WelcomeServlet.java
(rev 0)
+++
dsp/trunk/samples/deployer/src/main/java/org/jboss/soa/dsp/example/WelcomeServlet.java 2010-12-01
14:14:35 UTC (rev 1174)
@@ -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
Modified: dsp/trunk/samples/deployer/src/main/webapp/WEB-INF/web.xml
===================================================================
--- dsp/trunk/samples/deployer/src/main/webapp/WEB-INF/web.xml 2010-12-01 10:08:22 UTC
(rev 1173)
+++ dsp/trunk/samples/deployer/src/main/webapp/WEB-INF/web.xml 2010-12-01 14:14:35 UTC
(rev 1174)
@@ -2,16 +2,36 @@
<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>/upload.html</welcome-file>
+ <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
Deleted: dsp/trunk/samples/deployer/src/main/webapp/upload.html
===================================================================
--- dsp/trunk/samples/deployer/src/main/webapp/upload.html 2010-12-01 10:08:22 UTC (rev
1173)
+++ dsp/trunk/samples/deployer/src/main/webapp/upload.html 2010-12-01 14:14:35 UTC (rev
1174)
@@ -1,10 +0,0 @@
-<html>
- <head></head>
- <body>
- <p>Commons File Upload Example</p>
- <form action="DeployServlet" enctype="multipart/form-data"
method="POST">
- <input type="file" name="file1"><br>
- <input type="Submit" value="Upload File"><br>
- </form>
- </body>
-</html>
\ No newline at end of file