You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jl...@apache.org on 2013/10/02 21:12:27 UTC
svn commit: r1528596 - in /tomee/tomee/trunk:
server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/
tomee/tomee-webservices/src/main/java/org/apache/tomee/webservices/
Author: jlmonteiro
Date: Wed Oct 2 19:12:26 2013
New Revision: 1528596
URL: http://svn.apache.org/r1528596
Log:
OPENEJB-2039 Implement POJO Web Services in embedded mode
Modified:
tomee/tomee/trunk/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/OpenEJBHttpWsRegistry.java
tomee/tomee/trunk/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/WsRegistry.java
tomee/tomee/trunk/tomee/tomee-webservices/src/main/java/org/apache/tomee/webservices/TomcatWsRegistry.java
Modified: tomee/tomee/trunk/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/OpenEJBHttpWsRegistry.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/OpenEJBHttpWsRegistry.java?rev=1528596&r1=1528595&r2=1528596&view=diff
==============================================================================
--- tomee/tomee/trunk/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/OpenEJBHttpWsRegistry.java (original)
+++ tomee/tomee/trunk/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/OpenEJBHttpWsRegistry.java Wed Oct 2 19:12:26 2013
@@ -17,6 +17,7 @@
*/
package org.apache.openejb.server.webservices;
+import org.apache.openejb.assembler.classic.ServletInfo;
import org.apache.openejb.server.httpd.BasicAuthHttpListenerWrapper;
import org.apache.openejb.server.httpd.HttpListener;
import org.apache.openejb.server.httpd.OpenEJBHttpRegistry;
@@ -24,18 +25,29 @@ import org.apache.openejb.server.httpd.O
import java.util.List;
public class OpenEJBHttpWsRegistry extends OpenEJBHttpRegistry implements WsRegistry {
- public List<String> setWsContainer(String virtualHost, String contextRoot, String servletName, HttpListener wsContainer) throws Exception {
- throw new UnsupportedOperationException("OpenEJB http server does not support POJO webservices");
+ public List<String> setWsContainer(HttpListener httpListener,
+ ClassLoader classLoader,
+ String context, String virtualHost, ServletInfo servletInfo,
+ String realmName, String transportGuarantee, String authMethod) throws Exception {
+
+ final String path = servletInfo.mappings.iterator().next();
+ return addWsContainer(httpListener, classLoader, context, virtualHost, path, realmName, transportGuarantee, authMethod);
}
- public void clearWsContainer(String virtualHost, String contextRoot, String servletName) {
+ public void clearWsContainer(String context, String virtualHost, ServletInfo servletInfo) {
+ final String path = servletInfo.mappings.iterator().next();
+ removeWsContainer(path);
}
- public List<String> addWsContainer(String context, String path, HttpListener httpListener, String virtualHost, // ignored
- String realmName, // ignored
- String transportGuarantee, // ignored
- String authMethod, // ignored
- ClassLoader classLoader) throws Exception {
+ public List<String> addWsContainer(HttpListener httpListener,
+ ClassLoader classLoader,
+ String context,
+ String virtualHost, // ignored
+ String path,
+ String realmName, // ignored
+ String transportGuarantee, // ignored
+ String authMethod // ignored
+ ) throws Exception {
if (path == null) throw new NullPointerException("contextRoot is null");
if (httpListener == null) throw new NullPointerException("httpListener is null");
Modified: tomee/tomee/trunk/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/WsRegistry.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/WsRegistry.java?rev=1528596&r1=1528595&r2=1528596&view=diff
==============================================================================
--- tomee/tomee/trunk/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/WsRegistry.java (original)
+++ tomee/tomee/trunk/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/WsRegistry.java Wed Oct 2 19:12:26 2013
@@ -16,16 +16,22 @@
*/
package org.apache.openejb.server.webservices;
+import org.apache.openejb.assembler.classic.ServletInfo;
import org.apache.openejb.server.httpd.HttpListener;
import java.util.List;
public interface WsRegistry {
- List<String> setWsContainer(String virtualHost, String contextRoot, String servletName, HttpListener wsContainer) throws Exception;
-
- void clearWsContainer(String virtualHost, String contextRoot, String servletName);
-
- List<String> addWsContainer(String context, String path, HttpListener httpListener, String virtualHost, String realmName, String transportGuarantee, String authMethod, ClassLoader classLoader) throws Exception;
+ List<String> setWsContainer(HttpListener httpListener,
+ ClassLoader classLoader,
+ String context, String virtualHost, ServletInfo servletInfo,
+ String realmName, String transportGuarantee, String authMethod) throws Exception;
+
+ void clearWsContainer(String context, String virtualHost, ServletInfo servletInfo);
+
+ List<String> addWsContainer(HttpListener httpListener,
+ ClassLoader classLoader,
+ String realmName, String transportGuarantee, String authMethod) throws Exception;
void removeWsContainer(String path);
}
Modified: tomee/tomee/trunk/tomee/tomee-webservices/src/main/java/org/apache/tomee/webservices/TomcatWsRegistry.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/tomee/tomee-webservices/src/main/java/org/apache/tomee/webservices/TomcatWsRegistry.java?rev=1528596&r1=1528595&r2=1528596&view=diff
==============================================================================
--- tomee/tomee/trunk/tomee/tomee-webservices/src/main/java/org/apache/tomee/webservices/TomcatWsRegistry.java (original)
+++ tomee/tomee/trunk/tomee/tomee-webservices/src/main/java/org/apache/tomee/webservices/TomcatWsRegistry.java Wed Oct 2 19:12:26 2013
@@ -33,6 +33,7 @@ import org.apache.catalina.core.Standard
import org.apache.catalina.deploy.LoginConfig;
import org.apache.catalina.deploy.SecurityCollection;
import org.apache.catalina.deploy.SecurityConstraint;
+import org.apache.openejb.assembler.classic.ServletInfo;
import org.apache.openejb.assembler.classic.WebAppBuilder;
import org.apache.openejb.loader.SystemInstance;
import org.apache.openejb.server.httpd.HttpListener;
@@ -87,7 +88,13 @@ public class TomcatWsRegistry implements
return property;
}
- public List<String> setWsContainer(String virtualHost, String contextRoot, String servletName, HttpListener wsContainer) throws Exception {
+
+ @Override
+ public List<String> setWsContainer(HttpListener httpListener,
+ ClassLoader classLoader,
+ String contextRoot, String virtualHost, ServletInfo servletInfo,
+ String realmName, String transportGuarantee, String authMethod) throws Exception {
+
if (virtualHost == null) virtualHost = engine.getDefaultHost();
Container host = engine.findChild(virtualHost);
@@ -96,7 +103,7 @@ public class TomcatWsRegistry implements
}
if (!contextRoot.startsWith("/")) {
- contextRoot= "/" + contextRoot;
+ contextRoot = "/" + contextRoot;
}
Context context = (Context) host.findChild(contextRoot);
@@ -104,9 +111,9 @@ public class TomcatWsRegistry implements
throw new IllegalArgumentException("Could not find web application context " + contextRoot + " in host " + host.getName());
}
- Wrapper wrapper = (Wrapper) context.findChild(servletName);
+ Wrapper wrapper = (Wrapper) context.findChild(servletInfo.servletName);
if (wrapper == null) {
- throw new IllegalArgumentException("Could not find servlet " + servletName + " in web application context " + context.getName());
+ throw new IllegalArgumentException("Could not find servlet " + servletInfo.servletName + " in web application context " + context.getName());
}
// for Pojo web services, we need to change the servlet class which is the service implementation
@@ -117,7 +124,7 @@ public class TomcatWsRegistry implements
wrapper.unload();
}
- setWsContainer(context, wrapper, wsContainer);
+ setWsContainer(context, wrapper, httpListener);
// add service locations
List<String> addresses = new ArrayList<String>();
@@ -130,7 +137,9 @@ public class TomcatWsRegistry implements
return addresses;
}
- public void clearWsContainer(String virtualHost, String contextRoot, String servletName) {
+
+ @Override
+ public void clearWsContainer(String contextRoot, String virtualHost, ServletInfo servletInfo) {
if (virtualHost == null) virtualHost = engine.getDefaultHost();
Container host = engine.findChild(virtualHost);
@@ -143,9 +152,9 @@ public class TomcatWsRegistry implements
throw new IllegalArgumentException("Could not find web application context " + contextRoot + " in host " + host.getName());
}
- Wrapper wrapper = (Wrapper) context.findChild(servletName);
+ Wrapper wrapper = (Wrapper) context.findChild(servletInfo.servletName);
if (wrapper == null) {
- throw new IllegalArgumentException("Could not find servlet " + servletName + " in web application context " + context.getName());
+ throw new IllegalArgumentException("Could not find servlet " + servletInfo.servletName + " in web application context " + context.getName());
}
// clear the webservice ref in the servlet context
@@ -156,7 +165,14 @@ public class TomcatWsRegistry implements
}
}
- public List<String> addWsContainer(String webContext, String path, HttpListener httpListener, String virtualHost, String realmName, String transportGuarantee, String authMethod, ClassLoader classLoader) throws Exception {
+
+ // String webContext, String path, HttpListener httpListener, String virtualHost, String realmName, String transportGuarantee, String authMethod, ClassLoader classLoader
+
+ @Override
+ public List<String> addWsContainer(HttpListener httpListener,
+ ClassLoader classLoader,
+ String context, String virtualHost, String path,
+ String realmName, String transportGuarantee, String authMethod) throws Exception {
if (path == null) throw new NullPointerException("contextRoot is null");
if (httpListener == null) throw new NullPointerException("httpListener is null");
@@ -175,12 +191,12 @@ public class TomcatWsRegistry implements
// build contexts
// - old way (/*)
if (WEBSERVICE_OLDCONTEXT_ACTIVE) {
- deployInFakeWebapp(path, classLoader, authMethod, transportGuarantee, realmName, host, httpListener, addresses, webContext);
+ deployInFakeWebapp(path, classLoader, authMethod, transportGuarantee, realmName, host, httpListener, addresses, context);
}
// - new way (/<webappcontext>/webservices/<name>) if webcontext is specified
- if (webContext != null) {
- String root = webContext;
+ if (context != null) {
+ String root = context;
if (!root.startsWith("/")) {
root = '/' + root;
}
@@ -200,7 +216,7 @@ public class TomcatWsRegistry implements
addServlet(host, webAppContext, WEBSERVICE_SUB_CONTEXT + path, httpListener, path, addresses, false);
}
} else if (!WEBSERVICE_OLDCONTEXT_ACTIVE) { // deploying in a jar
- deployInFakeWebapp(path, classLoader, authMethod, transportGuarantee, realmName, host, httpListener, addresses, webContext);
+ deployInFakeWebapp(path, classLoader, authMethod, transportGuarantee, realmName, host, httpListener, addresses, context);
}
}
return addresses;