Author: jim.ma
Date: 2014-01-14 04:10:13 -0500 (Tue, 14 Jan 2014)
New Revision: 18231
Added:
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/UndertowHeaderMap.java
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/UndertowHttpContext.java
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/UndertowHttpExchange.java
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/UndertowHttpHandler.java
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/UndertowServer.java
Modified:
projects/jaxws-httpserver-httpspi/trunk/pom.xml
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/HttpContextDelegate.java
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/HttpExchangeDelegate.java
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/HttpHandlerDelegate.java
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/HttpServerContextFactory.java
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/PathUtils.java
projects/jaxws-httpserver-httpspi/trunk/src/test/java/org/jboss/ws/httpserver_httpspi/EndpointAPITest.java
Log:
[JBWS-3702]:Undertow jaxws http spi implemention
Modified: projects/jaxws-httpserver-httpspi/trunk/pom.xml
===================================================================
--- projects/jaxws-httpserver-httpspi/trunk/pom.xml 2014-01-13 10:05:29 UTC (rev 18230)
+++ projects/jaxws-httpserver-httpspi/trunk/pom.xml 2014-01-14 09:10:13 UTC (rev 18231)
@@ -30,6 +30,7 @@
<junit.version>4.8.1</junit.version>
<cxf.version>2.3.0</cxf.version>
<servlet-api.version>1.0.0.Beta2</servlet-api.version>
+ <io.undertow.version>1.0.0.Beta30</io.undertow.version>
</properties>
<!-- Dependencies -->
@@ -39,6 +40,19 @@
<artifactId>jboss-jaxws-api_2.2_spec</artifactId>
<version>${jaxws.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>io.undertow</groupId>
+ <artifactId>undertow-core</artifactId>
+ <version>${io.undertow.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>io.undertow</groupId>
+ <artifactId>undertow-build-config</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
<!-- test dependencies -->
<dependency>
Modified:
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/HttpContextDelegate.java
===================================================================
---
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/HttpContextDelegate.java 2014-01-13
10:05:29 UTC (rev 18230)
+++
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/HttpContextDelegate.java 2014-01-14
09:10:13 UTC (rev 18231)
@@ -35,7 +35,6 @@
* @since 22-Aug-2010
*
*/
-@SuppressWarnings("restriction")
public class HttpContextDelegate extends HttpContext
{
private com.sun.net.httpserver.HttpContext delegate;
Modified:
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/HttpExchangeDelegate.java
===================================================================
---
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/HttpExchangeDelegate.java 2014-01-13
10:05:29 UTC (rev 18230)
+++
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/HttpExchangeDelegate.java 2014-01-14
09:10:13 UTC (rev 18231)
@@ -45,7 +45,6 @@
* @since 22-Aug-2010
*
*/
-@SuppressWarnings("restriction")
public class HttpExchangeDelegate extends HttpExchange
{
private com.sun.net.httpserver.HttpExchange delegate;
Modified:
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/HttpHandlerDelegate.java
===================================================================
---
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/HttpHandlerDelegate.java 2014-01-13
10:05:29 UTC (rev 18230)
+++
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/HttpHandlerDelegate.java 2014-01-14
09:10:13 UTC (rev 18231)
@@ -34,7 +34,6 @@
* @sine 22-Aug-2010
*
*/
-@SuppressWarnings("restriction")
public class HttpHandlerDelegate implements HttpHandler {
private javax.xml.ws.spi.http.HttpHandler delegate;
Modified:
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/HttpServerContextFactory.java
===================================================================
---
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/HttpServerContextFactory.java 2014-01-13
10:05:29 UTC (rev 18230)
+++
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/HttpServerContextFactory.java 2014-01-14
09:10:13 UTC (rev 18231)
@@ -21,9 +21,10 @@
*/
package org.jboss.ws.httpserver_httpspi;
-import com.sun.net.httpserver.HttpServer;
import javax.xml.ws.spi.http.HttpContext;
+import com.sun.net.httpserver.HttpServer;
+
/**
* A factory for building JDK6 httpserver' flavor of
*
@@ -31,11 +32,15 @@
* @since 22-Aug-2010
*
*/
-@SuppressWarnings("restriction")
public class HttpServerContextFactory
{
public static HttpContext createHttpContext(HttpServer server, String contextPath,
String path)
{
return new HttpContextDelegate(server.createContext(contextPath + path), path);
}
+
+ public static HttpContext createHttpContext(UndertowServer server, String contextPath,
String path)
+ {
+ return new UndertowHttpContext(server.getPathHandler(), contextPath, path);
+ }
}
Modified:
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/PathUtils.java
===================================================================
---
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/PathUtils.java 2014-01-13
10:05:29 UTC (rev 18230)
+++
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/PathUtils.java 2014-01-14
09:10:13 UTC (rev 18231)
@@ -44,6 +44,11 @@
return getPathInternal(addr.getPath());
}
+ public static String getPathFromRequest(String requestPath)
+ {
+ return getPathInternal(requestPath);
+ }
+
private static String getPathInternal(String rawpath)
{
String path = removeTrailingSlash(rawpath);
@@ -66,6 +71,11 @@
return getContextPathInternal(getPathFromString(addr));
}
+ public static String getContextPathFromRequest(String requestPath)
+ {
+ return getContextPathInternal(requestPath);
+ }
+
public static String getContextPath(URI addr)
{
return getContextPathInternal(addr.getPath());
@@ -96,7 +106,7 @@
return path;
}
- private static String removeTrailingSlash(String path)
+ public static String removeTrailingSlash(String path)
{
if (path != null && path.length() > 0 &&
path.lastIndexOf('/') == path.length() - 1)
{
Added:
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/UndertowHeaderMap.java
===================================================================
---
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/UndertowHeaderMap.java
(rev 0)
+++
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/UndertowHeaderMap.java 2014-01-14
09:10:13 UTC (rev 18231)
@@ -0,0 +1,208 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2014, 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.ws.httpserver_httpspi;
+
+import io.undertow.util.HeaderMap;
+import io.undertow.util.HeaderValues;
+import io.undertow.util.HttpString;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+
+
+public class UndertowHeaderMap implements Map<String, List<String>>
+{
+
+ private HeaderMap headerMap;
+
+ public UndertowHeaderMap(HeaderMap headerMap) {
+ this.headerMap = headerMap;
+ }
+
+ @Override
+ public int size()
+ {
+ return headerMap.size();
+ }
+
+ @Override
+ public boolean isEmpty()
+ {
+ return headerMap.size() > 0;
+ }
+
+ @Override
+ public boolean containsKey(Object key)
+ {
+ return headerMap.contains(key.toString());
+ }
+
+ @Override
+ public boolean containsValue(Object value)
+ {
+ Iterator<HeaderValues> ite = headerMap.iterator();
+ while (ite.hasNext())
+ {
+ HeaderValues values = ite.next();
+ if (values.contains(value))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public List<String> get(Object key)
+ {
+ HeaderValues values = headerMap.get(key.toString());
+ List<String> result = new ArrayList<String>();
+ if (values != null)
+ {
+ for (String value : values.toArray())
+ {
+ result.add(value);
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public List<String> put(String key, List<String> value)
+ {
+ List<String> previous = get(key);
+ if (previous.isEmpty())
+ {
+ previous = null;
+ }
+ headerMap.addAll(new HttpString(key), value);
+ return previous;
+
+ }
+
+ @Override
+ public List<String> remove(Object key)
+ {
+ List<String> previous = get(key);
+ if (previous.isEmpty())
+ {
+ previous = null;
+ }
+ headerMap.remove(key.toString());
+ return previous;
+ }
+
+ @Override
+ public void putAll(Map<? extends String, ? extends List<String>> m)
+ {
+ for (String key : m.keySet())
+ {
+ headerMap.putAll(new HttpString(key), m.get(key));
+ }
+
+ }
+
+ @Override
+ public void clear()
+ {
+ headerMap.clear();
+
+ }
+
+ @Override
+ public Set<String> keySet()
+ {
+ Set<String> result = new HashSet<String>();
+ for (HeaderValues value : headerMap)
+ {
+ result.add(value.getHeaderName().toString());
+ }
+ return result;
+ }
+
+ @Override
+ public Collection<List<String>> values()
+ {
+ List<List<String>> collections = new
ArrayList<List<String>>();
+ for (HeaderValues value : headerMap)
+ {
+ List<String> values = new ArrayList<String>();
+ for (String headerValue : value)
+ {
+ values.add(headerValue);
+ }
+ collections.add(values);
+ }
+ return collections;
+ }
+
+ @Override
+ public Set<java.util.Map.Entry<String, List<String>>> entrySet()
+ {
+ Set<java.util.Map.Entry<String, List<String>>> result = new
HashSet<java.util.Map.Entry<String, List<String>>>();
+ for (HeaderValues headerValues : headerMap)
+ {
+ final String key = headerValues.getHeaderName().toString();
+ final List<String> headerValueList = new ArrayList<String>();
+ for (String value : headerValues)
+ {
+ headerValueList.add(value);
+ }
+ result.add(new Entry<String, List<String>>() {
+
+ @Override
+ public String getKey()
+ {
+ return key;
+ }
+
+ @Override
+ public List<String> getValue()
+ {
+ return headerValueList;
+ }
+
+ @Override
+ public List<String> setValue(List<String> value)
+ {
+ List<String> previous = headerMap.get(key);
+ if (previous.isEmpty())
+ {
+ previous = null;
+ }
+ headerMap.addAll(new HttpString(key), value);
+
+ return previous;
+
+ }
+ });
+ }
+ return result;
+ }
+
+}
Property changes on:
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/UndertowHeaderMap.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Added:
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/UndertowHttpContext.java
===================================================================
---
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/UndertowHttpContext.java
(rev 0)
+++
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/UndertowHttpContext.java 2014-01-14
09:10:13 UTC (rev 18231)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2014, 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.ws.httpserver_httpspi;
+
+import io.undertow.server.handlers.PathHandler;
+
+import java.util.Set;
+
+import javax.xml.ws.spi.http.HttpContext;
+import javax.xml.ws.spi.http.HttpHandler;
+
+/**
+ * @author <a href="mailto:ema@redhat.com">Jim Ma</a>
+ *
+ */
+//TODO:Look at HttpHandlerImpl - avoid to create duplicate UndertowHttpContext to publish
endpoint
+public class UndertowHttpContext extends HttpContext
+{
+ private String handlerpath;
+ private PathHandler pathHandler;
+ private String path;
+
+ public UndertowHttpContext(PathHandler pathHandler, String contextPath, String path)
+ {
+ this.pathHandler = pathHandler;
+ this.path = path;
+ this.handlerpath = contextPath + path;
+ }
+
+ @Override
+ public void setHandler(HttpHandler handler)
+ {
+ pathHandler.addExactPath(handlerpath, new UndertowHttpHandler(handler));
+ }
+
+ @Override
+ public String getPath()
+ {
+ return this.path;
+ }
+
+ @Override
+ public Object getAttribute(String name)
+ {
+ // TODO
+ return null;
+ }
+
+ @Override
+ public Set<String> getAttributeNames()
+ {
+ // TODO
+ return null;
+ }
+
+}
Property changes on:
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/UndertowHttpContext.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Added:
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/UndertowHttpExchange.java
===================================================================
---
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/UndertowHttpExchange.java
(rev 0)
+++
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/UndertowHttpExchange.java 2014-01-14
09:10:13 UTC (rev 18231)
@@ -0,0 +1,209 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2014, 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.ws.httpserver_httpspi;
+
+import io.undertow.server.HttpServerExchange;
+import io.undertow.server.handlers.PathHandler;
+import io.undertow.util.HeaderValues;
+import io.undertow.util.HttpString;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+import java.security.Principal;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.ws.spi.http.HttpContext;
+import javax.xml.ws.spi.http.HttpExchange;
+
+/**
+ * @author <a href="mailto:ema@redhat.com">Jim Ma</a>
+ *
+ */
+public class UndertowHttpExchange extends HttpExchange
+{
+ private HttpServerExchange undertowExchange;
+
+ private UndertowHttpContext context;
+
+ public UndertowHttpExchange(HttpServerExchange serverExchange)
+ {
+ undertowExchange = serverExchange;
+ }
+
+ @Override
+ public Map<String, List<String>> getRequestHeaders()
+ {
+ return new UndertowHeaderMap(undertowExchange.getRequestHeaders());
+ }
+
+ @Override
+ public String getRequestHeader(String name)
+ {
+ HeaderValues headerValues = undertowExchange.getRequestHeaders().get(name);
+ if (headerValues != null && headerValues.size() > 0)
+ {
+ String result = "";
+ for (String headerValue : headerValues)
+ {
+ result = result + headerValue;
+ }
+ return result;
+ }
+ return null;
+ }
+
+ @Override
+ public Map<String, List<String>> getResponseHeaders()
+ {
+ return new UndertowHeaderMap(undertowExchange.getResponseHeaders());
+ }
+
+ @Override
+ public void addResponseHeader(String name, String value)
+ {
+ undertowExchange.getResponseHeaders().add(new HttpString(name), value);
+
+ }
+
+ @Override
+ public String getRequestURI()
+ {
+ return undertowExchange.getRequestURI();
+ }
+
+ @Override
+ public String getContextPath()
+ {
+ return PathUtils.getContextPathFromRequest(undertowExchange.getRequestPath());
+ }
+
+ @Override
+ public String getRequestMethod()
+ {
+ return undertowExchange.getRequestMethod().toString();
+ }
+
+ @Override
+ public HttpContext getHttpContext()
+ {
+ if (context == null)
+ {
+ context = new UndertowHttpContext(new PathHandler(),
PathUtils.getContextPathFromRequest(undertowExchange.getRequestPath()),
+ PathUtils.getPathFromRequest(undertowExchange.getRequestPath()));
+ }
+ return context;
+ }
+
+ @Override
+ public void close() throws IOException
+ {
+ undertowExchange.endExchange();
+ }
+
+ @Override
+ public InputStream getRequestBody() throws IOException
+ {
+ return undertowExchange.getInputStream();
+ }
+
+ @Override
+ public OutputStream getResponseBody() throws IOException
+ {
+ return undertowExchange.getOutputStream();
+ }
+
+ @Override
+ public void setStatus(int status)
+ {
+ undertowExchange.setResponseCode(status);
+
+ }
+
+ @Override
+ public InetSocketAddress getRemoteAddress()
+ {
+ return undertowExchange.getSourceAddress();
+ }
+
+ @Override
+ public InetSocketAddress getLocalAddress()
+ {
+ return undertowExchange.getDestinationAddress();
+ }
+
+ @Override
+ public String getProtocol()
+ {
+ return undertowExchange.getProtocol().toString();
+ }
+
+ @Override
+ public String getScheme()
+ {
+ return undertowExchange.getRequestScheme();
+ }
+
+ @Override
+ public String getPathInfo()
+ {
+ return undertowExchange.getRequestPath();
+ }
+
+ @Override
+ public String getQueryString()
+ {
+ return undertowExchange.getQueryString();
+ }
+
+ @Override
+ public Object getAttribute(String name)
+ {
+ // TODO
+ return null;
+ }
+
+ @Override
+ public Set<String> getAttributeNames()
+ {
+ // TODO
+ return null;
+ }
+
+ @Override
+ public Principal getUserPrincipal()
+ {
+ //TODO
+ return null;
+ }
+
+ @Override
+ public boolean isUserInRole(String role)
+ {
+ //TODO
+ return false;
+ }
+
+}
Property changes on:
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/UndertowHttpExchange.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Added:
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/UndertowHttpHandler.java
===================================================================
---
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/UndertowHttpHandler.java
(rev 0)
+++
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/UndertowHttpHandler.java 2014-01-14
09:10:13 UTC (rev 18231)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2014, 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.ws.httpserver_httpspi;
+
+import io.undertow.server.HttpHandler;
+import io.undertow.server.HttpServerExchange;
+
+/**
+ * @author <a href="mailto:ema@redhat.com">Jim Ma</a>
+ *
+ */
+public class UndertowHttpHandler implements HttpHandler
+{
+
+ private javax.xml.ws.spi.http.HttpHandler spihandler;
+
+ public UndertowHttpHandler(javax.xml.ws.spi.http.HttpHandler handler)
+ {
+ spihandler = handler;
+ }
+
+ @Override
+ public void handleRequest(HttpServerExchange exchange) throws Exception
+ {
+ spihandler.handle(new UndertowHttpExchange(exchange));
+ }
+
+}
Property changes on:
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/UndertowHttpHandler.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Added:
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/UndertowServer.java
===================================================================
---
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/UndertowServer.java
(rev 0)
+++
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/UndertowServer.java 2014-01-14
09:10:13 UTC (rev 18231)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2014, 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.ws.httpserver_httpspi;
+
+import io.undertow.Undertow;
+import io.undertow.Undertow.Builder;
+import io.undertow.server.handlers.BlockingHandler;
+import io.undertow.server.handlers.PathHandler;
+
+/**
+ * @author <a href="mailto:ema@redhat.com">Jim Ma</a>
+ *
+ */
+public class UndertowServer
+{
+ private Builder builder;
+ private PathHandler pathHandler;
+ private Undertow undertow;
+
+ public UndertowServer(int port, String host)
+ {
+ builder = Undertow.builder().addListener(port, host);
+ pathHandler = new PathHandler();
+ }
+
+ public Builder getBuilder()
+ {
+ return builder;
+ }
+
+ public PathHandler getPathHandler()
+ {
+ return pathHandler;
+ }
+
+ public void start()
+ {
+ undertow = builder.setHandler(new BlockingHandler(pathHandler)).build();
+ undertow.start();
+ }
+
+ public void stop()
+ {
+ if (undertow != null)
+ {
+ undertow.stop();
+ }
+ }
+
+}
Property changes on:
projects/jaxws-httpserver-httpspi/trunk/src/main/java/org/jboss/ws/httpserver_httpspi/UndertowServer.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Modified:
projects/jaxws-httpserver-httpspi/trunk/src/test/java/org/jboss/ws/httpserver_httpspi/EndpointAPITest.java
===================================================================
---
projects/jaxws-httpserver-httpspi/trunk/src/test/java/org/jboss/ws/httpserver_httpspi/EndpointAPITest.java 2014-01-13
10:05:29 UTC (rev 18230)
+++
projects/jaxws-httpserver-httpspi/trunk/src/test/java/org/jboss/ws/httpserver_httpspi/EndpointAPITest.java 2014-01-14
09:10:13 UTC (rev 18231)
@@ -25,7 +25,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.net.InetSocketAddress;
import java.net.URL;
import javax.activation.DataHandler;
@@ -49,25 +48,24 @@
* @since 22-Aug-2010
*
*/
-@SuppressWarnings("restriction")
public class EndpointAPITest extends Assert
{
private static int currentPort = 9876;
- private com.sun.net.httpserver.HttpServer server;
+ private UndertowServer server;
@Before
public void setUp() throws IOException
{
currentPort++;
- server = com.sun.net.httpserver.HttpServer.create(new
InetSocketAddress(currentPort), 0);
+ server = new UndertowServer(currentPort, "localhost");
}
@After
public void tearDown()
{
- server.stop(0);
+ server.stop();
server = null;
}
@@ -108,7 +106,6 @@
invokeEndpoint(address);
endpoint.stop();
- server.removeContext(contextPath + path);
}
}