[jbossws-commits] JBossWS SVN: r12824 - in stack/cxf/branches/cxf-2.3: modules and 33 other directories.
jbossws-commits at lists.jboss.org
jbossws-commits at lists.jboss.org
Sat Aug 21 04:10:37 EDT 2010
Author: alessio.soldano at jboss.com
Date: 2010-08-21 04:10:36 -0400 (Sat, 21 Aug 2010)
New Revision: 12824
Added:
stack/cxf/branches/cxf-2.3/modules/addons/
stack/cxf/branches/cxf-2.3/modules/addons/pom.xml
stack/cxf/branches/cxf-2.3/modules/addons/transports/
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/pom.xml
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpContextAdaptor.java
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpExchangeAdaptor.java
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpHandlerAdaptor.java
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpServerDestination.java
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpServerEngine.java
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpServerEngineFactory.java
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpServerTransportFactory.java
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/PathUtils.java
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/resources/
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/resources/META-INF/
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/resources/META-INF/cxf/
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/resources/META-INF/cxf/bus-extensions.xml
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/resources/META-INF/cxf/cxf-extension-httpserver.xml
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/resources/META-INF/cxf/cxf.extension
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/test/
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/test/java/
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/test/java/org/
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/test/java/org/jboss/
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/test/java/org/jboss/wsf/
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/test/java/org/jboss/wsf/stack/
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/test/java/org/jboss/wsf/stack/cxf/
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/test/java/org/jboss/wsf/stack/cxf/addons/
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/test/java/org/jboss/wsf/stack/cxf/addons/transports/
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/test/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/test/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpServerEngineTest.java
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/test/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/PathUtilsTest.java
stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/test/resources/
Modified:
stack/cxf/branches/cxf-2.3/modules/client/pom.xml
stack/cxf/branches/cxf-2.3/modules/client/src/main/resources/META-INF/bus-extensions.xml
stack/cxf/branches/cxf-2.3/modules/client/src/main/resources/META-INF/cxf/cxf-extension-jbossws.xml
stack/cxf/branches/cxf-2.3/modules/resources/src/main/resources/resources/jbossws-deploy-macros.xml
stack/cxf/branches/cxf-2.3/pom.xml
stack/cxf/branches/cxf-2.3/src/main/scripts/assembly-deploy-artifacts.xml
Log:
[JBWS-3079] Adding new module for CXF httpserver transport
Property changes on: stack/cxf/branches/cxf-2.3/modules/addons
___________________________________________________________________
Name: svn:ignore
+ target
.project
.classpath
.settings
Added: stack/cxf/branches/cxf-2.3/modules/addons/pom.xml
===================================================================
--- stack/cxf/branches/cxf-2.3/modules/addons/pom.xml (rev 0)
+++ stack/cxf/branches/cxf-2.3/modules/addons/pom.xml 2010-08-21 08:10:36 UTC (rev 12824)
@@ -0,0 +1,22 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <name>JBoss Web Services - Stack CXF Add-ons</name>
+ <artifactId>jbossws-cxf-addons</artifactId>
+ <packaging>pom</packaging>
+
+ <!-- Parent -->
+ <parent>
+ <groupId>org.jboss.ws.cxf</groupId>
+ <artifactId>jbossws-cxf</artifactId>
+ <version>3.4.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <!-- Modules -->
+ <modules>
+ <module>transports/http/httpserver</module>
+ </modules>
+
+</project>
Property changes on: stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver
___________________________________________________________________
Name: svn:ignore
+ target
.project
.classpath
.settings
Added: stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/pom.xml
===================================================================
--- stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/pom.xml (rev 0)
+++ stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/pom.xml 2010-08-21 08:10:36 UTC (rev 12824)
@@ -0,0 +1,131 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <name>JBoss Web Services - Stack CXF httpserver transport</name>
+ <artifactId>jbossws-cxf-transports-httpserver</artifactId>
+ <packaging>jar</packaging>
+
+ <parent>
+ <groupId>org.jboss.ws.cxf</groupId>
+ <artifactId>jbossws-cxf-addons</artifactId>
+ <version>3.4.0-SNAPSHOT</version>
+ <relativePath>../../../pom.xml</relativePath>
+ </parent>
+
+ <!-- Dependencies -->
+ <dependencies>
+
+ <!-- CXF dependencies -->
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-frontend-jaxws</artifactId>
+ </dependency>
+
+ <!-- Spring -->
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-aop</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-asm</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-expression</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-jms</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-tx</artifactId>
+ </dependency>
+
+ <!--
+ useStrictFiltering requires dependency in all included modules
+ http://jira.codehaus.org/browse/MASSEMBLY-317
+ -->
+
+ <dependency>
+ <groupId>org.jboss.spec.javax.xml.ws</groupId>
+ <artifactId>jboss-jaxws-api_2.2_spec</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymockclassextension</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.spec.javax.servlet</groupId>
+ <artifactId>jboss-servlet-api_3.0_spec</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <profiles>
+ <!--
+ Name: enforce
+ Descr: Enforce artifact dependencies
+ -->
+ <profile>
+ <id>enforce</id>
+ <activation>
+ <property>
+ <name>!skip-enforce</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>ban-bad-dependencies</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <bannedDependencies>
+ <searchTransitive>true</searchTransitive>
+ <excludes>
+ <exclude>org.apache.cxf:cxf-rt-bindings-corba</exclude>
+ <exclude>org.apache.cxf:cxf-rt-javascript</exclude>
+ <exclude>org.apache.geronimo.specs</exclude>
+ <exclude>org.codehaus.jra:jra</exclude>
+ <exclude>org.slf4j:slf4j-jdk14</exclude>
+ </excludes>
+ </bannedDependencies>
+ </rules>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
Added: stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpContextAdaptor.java
===================================================================
--- stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpContextAdaptor.java (rev 0)
+++ stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpContextAdaptor.java 2010-08-21 08:10:36 UTC (rev 12824)
@@ -0,0 +1,80 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.wsf.stack.cxf.addons.transports.httpserver;
+
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.ws.spi.http.HttpContext;
+import javax.xml.ws.spi.http.HttpHandler;
+
+/**
+ * A javax.xml.ws.spi.http.HttpContext adaptor delegating
+ * to a com.sun.net.httpserver.HttpContext instance.
+ *
+ * @author alessio.soldano at jboss.com
+ * @since 19-Aug-2010
+ *
+ */
+ at SuppressWarnings("restriction")
+public class HttpContextAdaptor extends HttpContext
+{
+ private com.sun.net.httpserver.HttpContext delegate;
+ private String path;
+
+ public HttpContextAdaptor(com.sun.net.httpserver.HttpContext delegate, String path)
+ {
+ this.delegate = delegate;
+ this.path = path;
+ }
+
+ @Override
+ public String getPath()
+ {
+ return path;
+ }
+
+ @Override
+ public Object getAttribute(String name)
+ {
+ Map<String, Object> map = delegate.getAttributes();
+ return map != null ? map.get(name) : null;
+ }
+
+ @Override
+ public Set<String> getAttributeNames()
+ {
+ Map<String, Object> map = delegate.getAttributes();
+ return map != null ? map.keySet() : null;
+ }
+
+ @Override
+ public void setHandler(HttpHandler handler)
+ {
+ if (handler instanceof com.sun.net.httpserver.HttpHandler)
+ {
+ delegate.setHandler((com.sun.net.httpserver.HttpHandler) handler);
+ }
+ super.setHandler(handler);
+ }
+
+}
Added: stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpExchangeAdaptor.java
===================================================================
--- stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpExchangeAdaptor.java (rev 0)
+++ stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpExchangeAdaptor.java 2010-08-21 08:10:36 UTC (rev 12824)
@@ -0,0 +1,231 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.wsf.stack.cxf.addons.transports.httpserver;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+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;
+
+import org.apache.commons.lang.NotImplementedException;
+import org.apache.cxf.io.AbstractWrappedOutputStream;
+
+import com.sun.net.httpserver.HttpServer;
+import com.sun.net.httpserver.HttpsServer;
+
+/**
+ * A javax.xml.ws.spi.http.HttpContext adaptor delegating
+ * to a com.sun.net.httpserver.HttpContext instance.
+ *
+ * @author alessio.soldano at jboss.com
+ * @since 19-Aug-2010
+ *
+ */
+ at SuppressWarnings("restriction")
+public class HttpExchangeAdaptor extends HttpExchange
+{
+ private com.sun.net.httpserver.HttpExchange delegate;
+ private HttpContextAdaptor contextAdaptor;
+ private OutputStream wrappeddOutputStream;
+ private int status;
+
+ public HttpExchangeAdaptor(com.sun.net.httpserver.HttpExchange delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public Map<String, List<String>> getRequestHeaders()
+ {
+ return delegate.getRequestHeaders();
+ }
+
+ @Override
+ public String getRequestHeader(String name)
+ {
+ return delegate.getRequestHeaders().getFirst(name);
+ }
+
+ @Override
+ public Map<String, List<String>> getResponseHeaders()
+ {
+ return delegate.getResponseHeaders();
+ }
+
+ @Override
+ public void addResponseHeader(String name, String value)
+ {
+ delegate.getResponseHeaders().add(name, value);
+ }
+
+ @Override
+ public String getRequestURI()
+ {
+ return delegate.getRequestURI().toString();
+ }
+
+ @Override
+ public String getContextPath()
+ {
+ return PathUtils.getContextPath(delegate.getRequestURI());
+ }
+
+ @Override
+ public String getRequestMethod()
+ {
+ return delegate.getRequestMethod();
+ }
+
+ @Override
+ public HttpContext getHttpContext()
+ {
+ if (contextAdaptor == null)
+ {
+ contextAdaptor = new HttpContextAdaptor(delegate.getHttpContext(), PathUtils.getPath(delegate.getRequestURI()));
+ }
+ return contextAdaptor;
+ }
+
+ @Override
+ public void close() throws IOException
+ {
+ delegate.close();
+ }
+
+ @Override
+ public InputStream getRequestBody() throws IOException
+ {
+ return delegate.getRequestBody();
+ }
+
+ @Override
+ public OutputStream getResponseBody() throws IOException
+ {
+ if (wrappeddOutputStream == null)
+ {
+ wrappeddOutputStream = new AbstractWrappedOutputStream()
+ {
+ /**
+ * On first write we need to send the response headers and
+ * the status as that won't be possible after getting the
+ * response body stream from the delegate
+ */
+ @Override
+ protected void onFirstWrite() throws IOException
+ {
+ if (status == 0) //assume no status -> 200 OK
+ {
+ status = HttpURLConnection.HTTP_OK;
+ }
+ delegate.sendResponseHeaders(status, 0);
+ this.wrappedStream = delegate.getResponseBody();
+ }
+ };
+ }
+ return wrappeddOutputStream;
+ }
+
+ @Override
+ public void setStatus(int status)
+ {
+ //do not immediately set status to the delegate, as that would flush it to the
+ //client together with the headers, preventing other headers from being added
+ this.status = status;
+ }
+
+ @Override
+ public InetSocketAddress getRemoteAddress()
+ {
+ return delegate.getRemoteAddress();
+ }
+
+ @Override
+ public InetSocketAddress getLocalAddress()
+ {
+ return delegate.getLocalAddress();
+ }
+
+ @Override
+ public String getProtocol()
+ {
+ return delegate.getProtocol();
+ }
+
+ @Override
+ public String getScheme()
+ {
+ String scheme = delegate.getRequestURI().getScheme();
+ if (scheme == null)
+ {
+ //fallback for relative urls (e.g. "/foo/bar?wsdl") with no scheme provided by the container
+ HttpServer server = delegate.getHttpContext().getServer();
+ scheme = server instanceof HttpsServer ? "https" : "http";
+ }
+ return scheme;
+ }
+
+ @Override
+ public String getPathInfo()
+ {
+ return null;
+ }
+
+ @Override
+ public String getQueryString()
+ {
+ return delegate.getRequestURI().getQuery();
+ }
+
+ @Override
+ public Object getAttribute(String name)
+ {
+ return delegate.getAttribute(name);
+ }
+
+ @Override
+ public Set<String> getAttributeNames()
+ {
+ NotImplementedException e = new NotImplementedException();
+ e.printStackTrace();
+ throw e;
+ }
+
+ @Override
+ public Principal getUserPrincipal()
+ {
+ return delegate.getPrincipal();
+ }
+
+ @Override
+ public boolean isUserInRole(String role)
+ {
+ return false;
+ }
+}
Added: stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpHandlerAdaptor.java
===================================================================
--- stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpHandlerAdaptor.java (rev 0)
+++ stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpHandlerAdaptor.java 2010-08-21 08:10:36 UTC (rev 12824)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.wsf.stack.cxf.addons.transports.httpserver;
+
+import java.io.IOException;
+
+import org.apache.cxf.transport.http_jaxws_spi.HttpHandlerImpl;
+import org.apache.cxf.transport.http_jaxws_spi.JAXWSHttpSpiDestination;
+
+import com.sun.net.httpserver.HttpExchange;
+import com.sun.net.httpserver.HttpHandler;
+
+/**
+ * A com.sun.net.httpserver.HttpHandler adapted to javax.xml.ws.spi.http.HttpHandler
+ * through CXF org.apache.cxf.transport.http_jaxws_spi.HttpHandlerImpl.
+ *
+ * @author alessio.soldano at jboss.com
+ * @sine 19-Aug-2010
+ *
+ */
+ at SuppressWarnings("restriction")
+public class HttpHandlerAdaptor extends HttpHandlerImpl implements HttpHandler {
+
+ public HttpHandlerAdaptor(JAXWSHttpSpiDestination destination)
+ {
+ super(destination);
+ }
+
+ @Override
+ public void handle(HttpExchange ex) throws IOException
+ {
+ try
+ {
+ this.handle(new HttpExchangeAdaptor(ex));
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ throw e;
+ }
+ catch (RuntimeException e)
+ {
+ e.printStackTrace();
+ throw e;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+
+}
\ No newline at end of file
Added: stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpServerDestination.java
===================================================================
--- stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpServerDestination.java (rev 0)
+++ stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpServerDestination.java 2010-08-21 08:10:36 UTC (rev 12824)
@@ -0,0 +1,112 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.wsf.stack.cxf.addons.transports.httpserver;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.http_jaxws_spi.JAXWSHttpSpiDestination;
+
+/**
+ * HTTP destination to be used with the JDK6 httpserver; this extends the
+ * basic JAXWSHttpSpiDestination with all the mechanisms for properly
+ * handling destination and factory life-cycles.
+ *
+ * @author alessio.soldano at jboss.com
+ * @since 19-Aug-2010
+ *
+ */
+public class HttpServerDestination extends JAXWSHttpSpiDestination
+{
+ static final Logger LOG = LogUtils.getL7dLogger(HttpServerDestination.class);
+
+ private static final long serialVersionUID = 1L;
+
+ private HttpServerTransportFactory factory;
+ private HttpServerEngineFactory serverEngineFactory;
+ private HttpServerEngine engine;
+ private URL url;
+
+ public HttpServerDestination(Bus b, HttpServerTransportFactory factory, EndpointInfo ei) throws IOException
+ {
+ super(b, ei);
+ this.factory = factory;
+ this.serverEngineFactory = factory.getServerEngineFactory();
+ this.url = new URL(ei.getAddress());
+ }
+
+ @Override
+ protected Logger getLogger()
+ {
+ return LOG;
+ }
+
+ public void finalizeConfig() throws IOException
+ {
+ engine = serverEngineFactory.retrieveHttpServerEngine(url.getPort());
+ if (engine == null)
+ {
+ engine = serverEngineFactory.createHttpServerEngine(url.getHost(), url.getPort(), url.getProtocol());
+ }
+ if (!url.getProtocol().equals(engine.getProtocol()))
+ {
+ throw new IllegalStateException("Port " + engine.getPort() + " is configured with wrong protocol \""
+ + engine.getProtocol() + "\" for \"" + url + "\"");
+ }
+ }
+
+ /**
+ * Activate receipt of incoming messages.
+ */
+ protected void activate() {
+ LOG.log(Level.FINE, "Activating receipt of incoming messages");
+ String addr = endpointInfo.getAddress();
+ try {
+ new URL(addr);
+ } catch (Exception e) {
+ throw new Fault(e);
+ }
+ engine.addHandler(addr, new HttpHandlerAdaptor(this));
+ }
+
+ /**
+ * Deactivate receipt of incoming messages.
+ */
+ protected void deactivate() {
+ LOG.log(Level.FINE, "Deactivating receipt of incoming messages");
+ engine.removeHandler(endpointInfo.getAddress());
+ }
+
+ @Override
+ public void shutdown()
+ {
+ factory.removeDestination(endpointInfo);
+ super.shutdown();
+ }
+
+}
Added: stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpServerEngine.java
===================================================================
--- stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpServerEngine.java (rev 0)
+++ stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpServerEngine.java 2010-08-21 08:10:36 UTC (rev 12824)
@@ -0,0 +1,136 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.wsf.stack.cxf.addons.transports.httpserver;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.common.logging.LogUtils;
+
+import com.sun.net.httpserver.HttpHandler;
+import com.sun.net.httpserver.HttpServer;
+
+/**
+ * A server engine that internally uses the JDK6 httpserver
+ *
+ * @author alessio.soldano at jboss.com
+ * @since 19-Aug-2010
+ *
+ */
+ at SuppressWarnings("restriction")
+public class HttpServerEngine
+{
+ private static final Logger LOG = LogUtils.getL7dLogger(HttpServerEngine.class);
+ private static final int DELAY = Integer.getInteger(System.getProperty(HttpServerEngineFactory.class.getName() + ".STOP_DELAY"), 1);
+ private static final int BACKLOG = 0;
+
+ private Bus bus;
+ private HttpServerEngineFactory factory;
+ private String host;
+ private int port;
+ private int handlerCount;
+ private String protocol = "http";
+ private HttpServer server;
+
+ public HttpServerEngine(HttpServerEngineFactory fac, Bus bus, String host, int port)
+ {
+ this.bus = bus;
+ this.factory = fac;
+ this.host = host;
+ this.port = port;
+ }
+
+ public Bus getBus()
+ {
+ return bus;
+ }
+
+ public String getProtocol()
+ {
+ return protocol;
+ }
+
+ public int getPort()
+ {
+ return port;
+ }
+
+ public String getHost()
+ {
+ return host;
+ }
+
+ public synchronized void addHandler(String address, HttpHandler handler)
+ {
+ if (server == null) //start the server on first call
+ {
+ InetSocketAddress isa = host != null ? new InetSocketAddress(host, port) : new InetSocketAddress(port);
+ try
+ {
+ server = HttpServer.create(isa, BACKLOG);
+ server.start();
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ server.createContext(PathUtils.getContextPath(address), handler);
+ handlerCount++;
+ }
+
+ public synchronized void removeHandler(String address)
+ {
+ server.removeContext(PathUtils.getContextPath(address));
+ handlerCount--;
+ }
+
+ /**
+ * This method is called by the ServerEngine Factory to destroy the server
+ */
+ protected void stop() throws Exception
+ {
+ if (server != null)
+ {
+ server.stop(DELAY);
+ }
+ }
+
+ /**
+ * This method will shut down the server engine and
+ * remove it from the factory's cache.
+ */
+ public void shutdown()
+ {
+ if (factory != null && handlerCount == 0)
+ {
+ factory.destroyForPort(port);
+ }
+ else
+ {
+ LOG.log(Level.WARNING, "FAILED_TO_SHUTDOWN_ENGINE_MSG", port);
+ }
+ }
+}
Added: stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpServerEngineFactory.java
===================================================================
--- stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpServerEngineFactory.java (rev 0)
+++ stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpServerEngineFactory.java 2010-08-21 08:10:36 UTC (rev 12824)
@@ -0,0 +1,151 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.wsf.stack.cxf.addons.transports.httpserver;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.annotation.Resource;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.buslifecycle.BusLifeCycleListener;
+import org.apache.cxf.buslifecycle.BusLifeCycleManager;
+import org.apache.cxf.common.logging.LogUtils;
+
+/**
+ * A server engine factory for the JDK6-based httpserver engine
+ *
+ * @author alessio.soldano at jboss.com
+ * @since 19-Aug-2010
+ *
+ */
+public class HttpServerEngineFactory implements BusLifeCycleListener
+{
+ private static final Logger LOG = LogUtils.getL7dLogger(HttpServerEngineFactory.class);
+ private static Map<Integer, HttpServerEngine> portMap = new HashMap<Integer, HttpServerEngine>();
+
+ private BusLifeCycleManager lifeCycleManager;
+ private Bus bus;
+
+ public HttpServerEngineFactory(Bus b)
+ {
+ setBus(b);
+ }
+
+ /**
+ * This call is used to set the bus. It should only be called once.
+ * @param bus
+ */
+ @Resource(name = "cxf")
+ public final void setBus(Bus bus)
+ {
+ assert this.bus == null || this.bus == bus;
+ this.bus = bus;
+ if (bus != null)
+ {
+ bus.setExtension(this, HttpServerEngineFactory.class);
+ lifeCycleManager = bus.getExtension(BusLifeCycleManager.class);
+ if (null != lifeCycleManager)
+ {
+ lifeCycleManager.registerLifeCycleListener(this);
+ }
+ }
+ }
+
+ public Bus getBus()
+ {
+ return bus;
+ }
+
+ /**
+ * Retrieve a previously configured HttpServerEngine for the
+ * given port. If none exists, this call returns null.
+ */
+ public synchronized HttpServerEngine retrieveHttpServerEngine(int port)
+ {
+ return portMap.get(port);
+ }
+
+ public synchronized HttpServerEngine createHttpServerEngine(String host, int port, String protocol)
+ throws IOException
+ {
+ LOG.fine("Creating HttpServer Engine for port " + port + ".");
+ HttpServerEngine ref = retrieveHttpServerEngine(port);
+ if (null == ref)
+ {
+ ref = new HttpServerEngine(this, bus, host, port);
+ portMap.put(port, ref);
+ }
+ // checking the protocol
+ if (!protocol.equals(ref.getProtocol()))
+ {
+ throw new IOException("Protocol mismatch for port " + port + ": " + "engine's protocol is "
+ + ref.getProtocol() + ", the url protocol is " + protocol);
+ }
+ return ref;
+ }
+
+ /**
+ * This method removes the Server Engine from the port map and stops it.
+ */
+ public synchronized void destroyForPort(int port)
+ {
+ HttpServerEngine ref = portMap.remove(port);
+ if (ref != null)
+ {
+ LOG.fine("Stopping HttpServer Engine on port " + port + ".");
+ try
+ {
+ ref.stop();
+ }
+ catch (Exception e)
+ {
+ LOG.log(Level.WARNING, "", e);
+ }
+ }
+ }
+
+ public void initComplete()
+ {
+ // do nothing here
+ }
+
+ public void postShutdown()
+ {
+ // shut down the httpserver in the portMap
+ // To avoid the CurrentModificationException,
+ // do not use portMap.vaules directly
+ HttpServerEngine[] engines = portMap.values().toArray(new HttpServerEngine[0]);
+ for (HttpServerEngine engine : engines)
+ {
+ engine.shutdown();
+ }
+ }
+
+ public void preShutdown()
+ {
+ // do nothing here
+ }
+}
Added: stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpServerTransportFactory.java
===================================================================
--- stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpServerTransportFactory.java (rev 0)
+++ stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpServerTransportFactory.java 2010-08-21 08:10:36 UTC (rev 12824)
@@ -0,0 +1,118 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.wsf.stack.cxf.addons.transports.httpserver;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.Destination;
+import org.apache.cxf.transport.DestinationFactory;
+import org.apache.cxf.transport.http.AbstractHTTPTransportFactory;
+
+/**
+ * A Destination/Transport factory for the JDK6 httpserver
+ *
+ * @author alessio.soldano at jboss.com
+ * @since 19-Aug-2010
+ *
+ */
+public class HttpServerTransportFactory extends AbstractHTTPTransportFactory implements DestinationFactory
+{
+ private Map<String, HttpServerDestination> destinations = new ConcurrentHashMap<String, HttpServerDestination>();
+
+ public HttpServerTransportFactory()
+ {
+ super();
+ }
+
+ @Resource
+ public void setBus(Bus b)
+ {
+ super.setBus(b);
+ }
+
+ @PostConstruct
+ public void finalizeConfig()
+ {
+ if (null == bus)
+ {
+ return;
+ }
+ // This call will register the server engine factory
+ // with the Bus.
+ getServerEngineFactory();
+ }
+
+ protected HttpServerEngineFactory getServerEngineFactory()
+ {
+ HttpServerEngineFactory serverEngineFactory = getBus().getExtension(HttpServerEngineFactory.class);
+ // If it's not there, then create it and register it.
+ // Spring may override it later, but we need it here for default
+ // with no spring configuration.
+ if (serverEngineFactory == null)
+ {
+ serverEngineFactory = new HttpServerEngineFactory(bus);
+ serverEngineFactory.setBus(getBus());
+ }
+ return serverEngineFactory;
+ }
+
+ public Destination getDestination(EndpointInfo endpointInfo) throws IOException
+ {
+ String addr = endpointInfo.getAddress();
+ HttpServerDestination destination = addr == null ? null : destinations.get(addr);
+ if (destination == null)
+ {
+ destination = createDestination(endpointInfo);
+ }
+ return destination;
+ }
+
+ private synchronized HttpServerDestination createDestination(EndpointInfo endpointInfo) throws IOException
+ {
+ String addr = endpointInfo.getAddress();
+ HttpServerDestination destination = addr == null ? null : destinations.get(addr);
+ if (destination == null)
+ {
+ destination = new HttpServerDestination(getBus(), this, endpointInfo);
+ destinations.put(endpointInfo.getAddress(), destination);
+ configure(destination);
+ destination.finalizeConfig();
+ }
+ return destination;
+ }
+
+ /**
+ * This function removes the destination for a particular endpoint.
+ */
+ void removeDestination(EndpointInfo ei)
+ {
+ destinations.remove(ei.getAddress());
+ }
+
+}
Added: stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/PathUtils.java
===================================================================
--- stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/PathUtils.java (rev 0)
+++ stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/PathUtils.java 2010-08-21 08:10:36 UTC (rev 12824)
@@ -0,0 +1,108 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.wsf.stack.cxf.addons.transports.httpserver;
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+
+public class PathUtils
+{
+ /**
+ * Get the final path section of an address (for servlet
+ * container, this is typically a url-pattern for an endpoint)
+ *
+ * @param addr
+ * @return
+ */
+ public static String getPath(String addr)
+ {
+ return getPathInternal(getPathFromString(addr));
+ }
+
+ public static String getPath(URI addr)
+ {
+ return getPathInternal(addr.getPath());
+ }
+
+ private static String getPathInternal(String rawpath)
+ {
+ String path = removeTrailingSlash(rawpath);
+ if (path == null || path.length() == 0)
+ {
+ return path;
+ }
+ int idx = path.lastIndexOf("/");
+ return idx > 0 ? path.substring(path.lastIndexOf("/")) : "";
+ }
+
+ /**
+ * Get the context path section of an address
+ *
+ * @param addr
+ * @return
+ */
+ public static String getContextPath(String addr)
+ {
+ return getContextPathInternal(getPathFromString(addr));
+ }
+
+ public static String getContextPath(URI addr)
+ {
+ return getContextPathInternal(addr.getPath());
+ }
+
+ private static String getContextPathInternal(String rawpath)
+ {
+ String path = removeTrailingSlash(rawpath);
+ if (path == null || path.length() == 0)
+ {
+ return "/";
+ }
+ int idx = path.lastIndexOf("/");
+ return idx > 0 ? path.substring(0, idx) : path;
+ }
+
+ private static String getPathFromString(String addr)
+ {
+ String path = null;
+ try
+ {
+ path = new URL(addr).getPath();
+ }
+ catch (MalformedURLException e)
+ {
+ //ignore
+ }
+ return path;
+ }
+
+ private static String removeTrailingSlash(String path)
+ {
+ if (path != null && path.length() > 0 && path.lastIndexOf('/') == path.length() - 1)
+ {
+ path = path.substring(0, path.length() - 1);
+ }
+ return path;
+ }
+
+}
Added: stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/resources/META-INF/cxf/bus-extensions.xml
===================================================================
--- stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/resources/META-INF/cxf/bus-extensions.xml (rev 0)
+++ stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/resources/META-INF/cxf/bus-extensions.xml 2010-08-21 08:10:36 UTC (rev 12824)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<extensions xmlns="http://cxf.apache.org/bus/extension">
+
+ <extension class="org.jboss.wsf.stack.cxf.addons.transports.httpserver.HttpServerTransportFactory" deferred="false">
+ <namespace>http://cxf.apache.org/transports/http</namespace>
+ <namespace>http://cxf.apache.org/transports/http/configuration</namespace>
+ <namespace>http://schemas.xmlsoap.org/wsdl/http</namespace>
+ <namespace>http://schemas.xmlsoap.org/wsdl/http/</namespace>
+ </extension>
+</extensions>
Added: stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/resources/META-INF/cxf/cxf-extension-httpserver.xml
===================================================================
--- stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/resources/META-INF/cxf/cxf-extension-httpserver.xml (rev 0)
+++ stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/resources/META-INF/cxf/cxf-extension-httpserver.xml 2010-08-21 08:10:36 UTC (rev 12824)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:foo="http://cxf.apache.org/configuration/foo"
+ xsi:schemaLocation="
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+ <import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
+
+ <bean class="org.jboss.wsf.stack.cxf.addons.transports.httpserver.HttpServerTransportFactory"
+ id="org.jboss.wsf.stack.cxf.addons.transports.httpserver.HttpServerTransportFactory"
+ lazy-init="true">
+ <property name="bus" ref="cxf"/>
+ <property name="transportIds">
+ <list>
+ <value>http://cxf.apache.org/transports/http</value>
+ <value>http://cxf.apache.org/transports/http/configuration</value>
+ <value>http://schemas.xmlsoap.org/wsdl/http</value>
+ <value>http://schemas.xmlsoap.org/wsdl/http/</value>
+ </list>
+ </property>
+ </bean>
+
+</beans>
Added: stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/resources/META-INF/cxf/cxf.extension
===================================================================
--- stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/resources/META-INF/cxf/cxf.extension (rev 0)
+++ stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/main/resources/META-INF/cxf/cxf.extension 2010-08-21 08:10:36 UTC (rev 12824)
@@ -0,0 +1 @@
+META-INF/cxf/cxf-extension-httpserver.xml
\ No newline at end of file
Added: stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/test/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpServerEngineTest.java
===================================================================
--- stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/test/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpServerEngineTest.java (rev 0)
+++ stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/test/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/HttpServerEngineTest.java 2010-08-21 08:10:36 UTC (rev 12824)
@@ -0,0 +1,144 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.wsf.stack.cxf.addons.transports.httpserver;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import javax.xml.ws.spi.http.HttpExchange;
+
+import junit.framework.TestCase;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.configuration.Configurer;
+import org.apache.cxf.configuration.spring.ConfigurerImpl;
+import org.easymock.classextension.EasyMock;
+import org.easymock.classextension.IMocksControl;
+
+/**
+ * Tests for HttpServerEngine
+ *
+ * @author alessio.soldano at jboss.com
+ * @since 20-Aug-2010
+ *
+ */
+public class HttpServerEngineTest extends TestCase {
+
+ private Bus bus;
+ private IMocksControl control;
+ private HttpServerEngineFactory factory;
+
+
+ public void setUp() throws Exception
+ {
+ control = EasyMock.createNiceControl();
+ bus = control.createMock(Bus.class);
+ Configurer configurer = new ConfigurerImpl();
+ bus.getExtension(Configurer.class);
+ EasyMock.expectLastCall().andReturn(configurer).anyTimes();
+ }
+
+ public void testEngineRetrieval() throws Exception
+ {
+ control.replay();
+ factory = new HttpServerEngineFactory(bus);
+ HttpServerEngine engine = factory.createHttpServerEngine("localhost", 9234, "http");
+ assertTrue(engine == factory.retrieveHttpServerEngine(9234));
+ factory.destroyForPort(1234);
+ control.verify();
+ }
+
+ public void testHttpAndHttps() throws Exception
+ {
+ control.replay();
+ factory = new HttpServerEngineFactory(bus);
+ HttpServerEngine engine = factory.createHttpServerEngine("localhost", 9234, "http");
+ assertTrue("http".equals(engine.getProtocol()));
+ System.out.println("[JBWS-3079] FIXME: Add support for https protocol");
+// HttpServerEngine engine2 = factory.createHttpServerEngine("localhost", 9235, "https");
+// assertTrue("https".equals(engine2.getProtocol()));
+ factory.destroyForPort(9234);
+// factory.destroyForPort(9235);
+
+ control.verify();
+ }
+
+ public void testHandler() throws Exception
+ {
+ MyTestHandler handler1 = new MyTestHandler();
+ MyTestHandler handler2 = new MyTestHandler();
+ control.replay();
+ factory = new HttpServerEngineFactory(bus);
+ String urlStr1 = "http://localhost:9234/hello/test";
+ String urlStr2 = "http://localhost:9234/hello233/test";
+ HttpServerEngine engine = factory.createHttpServerEngine("localhost", 9234, "http");
+ engine.addHandler(urlStr1, handler1);
+ engine.addHandler(urlStr2, handler2);
+ pingServer(new URL(urlStr1));
+ pingServer(new URL(urlStr2));
+ assertEquals(1, handler1.count);
+ assertEquals(1, handler2.count);
+ engine.removeHandler(urlStr1);
+ engine.removeHandler(urlStr2);
+ engine.shutdown();
+ factory.destroyForPort(9234);
+
+ control.verify();
+ }
+
+ private void pingServer(URL url)
+ {
+ try
+ {
+ HttpURLConnection connection1 = (HttpURLConnection) url.openConnection();
+ connection1.getInputStream();
+ connection1.disconnect();
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private class MyTestHandler extends HttpHandlerAdaptor
+ {
+ volatile int count;
+
+ public MyTestHandler()
+ {
+ super(null);
+ }
+
+ @Override
+ public void handle(HttpExchange exchange) throws IOException {
+ count++;
+ exchange.setStatus(200);
+ OutputStream os = exchange.getResponseBody();
+ os.write("Hello".getBytes());
+ os.flush();
+ exchange.close();
+ }
+ }
+
+}
Added: stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/test/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/PathUtilsTest.java
===================================================================
--- stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/test/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/PathUtilsTest.java (rev 0)
+++ stack/cxf/branches/cxf-2.3/modules/addons/transports/http/httpserver/src/test/java/org/jboss/wsf/stack/cxf/addons/transports/httpserver/PathUtilsTest.java 2010-08-21 08:10:36 UTC (rev 12824)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.wsf.stack.cxf.addons.transports.httpserver;
+
+import java.net.URI;
+
+import junit.framework.TestCase;
+
+public class PathUtilsTest extends TestCase
+{
+ public void testPath() {
+ assertEquals("", PathUtils.getPath("http://localhost:8080"));
+ assertEquals("", PathUtils.getPath("http://localhost:8080/foo"));
+ assertEquals("", PathUtils.getPath("http://localhost:8080/foo/"));
+ assertEquals("/bar", PathUtils.getPath("http://localhost:8080/foo/bar"));
+ assertEquals("/bar", PathUtils.getPath("http://localhost:8080/foo/bar/"));
+ assertEquals("/bar", PathUtils.getPath("http://localhost:8080/foo/bar?wsdl"));
+ assertEquals("/bar", PathUtils.getPath("http://localhost:8080/foo/bar/?wsdl"));
+ assertEquals("/bar", PathUtils.getPath("http://localhost:8080/foo/fooagain/bar"));
+ assertEquals("/bar", PathUtils.getPath("http://localhost:8080/foo/fooagain/bar?wsdl"));
+ assertEquals("/bar", PathUtils.getPath("http://localhost:8080/foo/fooagain/bar?wsdl&xsd=ff"));
+ assertEquals("/bar", PathUtils.getPath("http://localhost/foo/bar"));
+ assertEquals("/bar", PathUtils.getPath("https://localhost/foo/bar"));
+
+ }
+
+ public void testContextPath() {
+ assertEquals("/", PathUtils.getContextPath("http://localhost:8080"));
+ assertEquals("/foo", PathUtils.getContextPath("http://localhost:8080/foo"));
+ assertEquals("/foo", PathUtils.getContextPath("http://localhost:8080/foo/"));
+ assertEquals("/foo", PathUtils.getContextPath("http://localhost:8080/foo/bar"));
+ assertEquals("/foo", PathUtils.getContextPath("http://localhost:8080/foo/bar/"));
+ assertEquals("/foo/bar", PathUtils.getContextPath("http://localhost:8080/foo/bar/baragain"));
+ assertEquals("/foo", PathUtils.getContextPath("http://localhost:8080/foo/bar?wsdl&xsd=kk"));
+ assertEquals("/foo", PathUtils.getContextPath("http://localhost:8080/foo/bar/?wsdl&xsd=kk"));
+ assertEquals("/foo", PathUtils.getContextPath("http://localhost/foo/bar"));
+ assertEquals("/foo", PathUtils.getContextPath("https://localhost/foo/bar"));
+ }
+
+ public void testURIPath() throws Exception {
+ assertEquals("", PathUtils.getPath(new URI("http", "", "localhost", 8080, "", "", "")));
+ assertEquals("", PathUtils.getPath(new URI("http", "", "localhost", 8080, "/foo", "", "")));
+ assertEquals("", PathUtils.getPath(new URI("http", "", "localhost", 8080, "/foo/", "", "")));
+ assertEquals("/bar", PathUtils.getPath(new URI("http", "", "localhost", 8080, "/foo/bar", "", "")));
+ assertEquals("/bar", PathUtils.getPath(new URI("http", "", "localhost", 8080, "/foo/bar/", "", "")));
+ assertEquals("/bar", PathUtils.getPath(new URI("http", "", "localhost", 8080, "/foo/bar", "wsdl", "")));
+ assertEquals("/bar", PathUtils.getPath(new URI("http", "", "localhost", 8080, "/foo/bar/", "wsdl", "")));
+ assertEquals("/bar", PathUtils.getPath(new URI("http", "", "localhost", 8080, "/foo/fooagain/bar", "", "")));
+ assertEquals("/bar", PathUtils.getPath(new URI("http", "", "localhost", 8080, "/foo/fooagain/bar", "wsdl", "")));
+ assertEquals("/bar", PathUtils.getPath(new URI("http", "", "localhost", 8080, "/foo/fooagain/bar", "wsdl&xsd=ff", "")));
+ assertEquals("/bar", PathUtils.getPath(new URI("http", "", "localhost", 0, "/foo/bar", "", "")));
+ assertEquals("/bar", PathUtils.getPath(new URI("https", "", "localhost", 0, "/foo/bar", "", "")));
+ }
+
+ public void testURIContextPath() throws Exception {
+ assertEquals("/", PathUtils.getContextPath(new URI("http", "", "localhost", 8080, "", "", "")));
+ assertEquals("/foo", PathUtils.getContextPath(new URI("http", "", "localhost", 8080, "/foo", "", "")));
+ assertEquals("/foo", PathUtils.getContextPath(new URI("http", "", "localhost", 8080, "/foo/", "", "")));
+ assertEquals("/foo", PathUtils.getContextPath(new URI("http", "", "localhost", 8080, "/foo/bar", "", "")));
+ assertEquals("/foo", PathUtils.getContextPath(new URI("http", "", "localhost", 8080, "/foo/bar/", "", "")));
+ assertEquals("/foo/bar", PathUtils.getContextPath(new URI("http", "", "localhost", 8080, "/foo/bar/baragain", "", "")));
+ assertEquals("/foo", PathUtils.getContextPath(new URI("http", "", "localhost", 8080, "/foo/bar", "wsdl&xsd=kk", "")));
+ assertEquals("/foo", PathUtils.getContextPath(new URI("http", "", "localhost", 8080, "/foo/bar/", "wsdl&xsd=kk", "")));
+ assertEquals("/foo", PathUtils.getContextPath(new URI("http", "", "localhost", 0, "/foo/bar", "", "")));
+ assertEquals("/foo", PathUtils.getContextPath(new URI("https", "", "localhost", 0, "/foo/bar", "", "")));
+ }
+}
Modified: stack/cxf/branches/cxf-2.3/modules/client/pom.xml
===================================================================
--- stack/cxf/branches/cxf-2.3/modules/client/pom.xml 2010-08-20 10:09:09 UTC (rev 12823)
+++ stack/cxf/branches/cxf-2.3/modules/client/pom.xml 2010-08-21 08:10:36 UTC (rev 12824)
@@ -29,6 +29,11 @@
<artifactId>jbossws-cxf-factories</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.jboss.ws.cxf</groupId>
+ <artifactId>jbossws-cxf-transports-httpserver</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!-- CXF dependencies -->
<dependency>
Modified: stack/cxf/branches/cxf-2.3/modules/client/src/main/resources/META-INF/bus-extensions.xml
===================================================================
--- stack/cxf/branches/cxf-2.3/modules/client/src/main/resources/META-INF/bus-extensions.xml 2010-08-20 10:09:09 UTC (rev 12823)
+++ stack/cxf/branches/cxf-2.3/modules/client/src/main/resources/META-INF/bus-extensions.xml 2010-08-21 08:10:36 UTC (rev 12824)
@@ -20,12 +20,5 @@
<extensions xmlns="http://cxf.apache.org/bus/extension">
<extension class="org.apache.cxf.endpoint.ServerLifeCycleManagerImpl" interface="org.apache.cxf.endpoint.ServerLifeCycleManager" />
<extension class="org.apache.cxf.endpoint.ClientLifeCycleManagerImpl" interface="org.apache.cxf.endpoint.ClientLifeCycleManager" />
- <!-- The following is to be removed when providing a http transport factory implementation (for instance, using Jetty, see cxf-rt-transports-http-jetty.jar) -->
- <extension class="org.apache.cxf.transport.servlet.ServletTransportFactory" deferred="false">
- <namespace>http://cxf.apache.org/transports/http</namespace>
- <namespace>http://cxf.apache.org/transports/http/configuration</namespace>
- <namespace>http://schemas.xmlsoap.org/wsdl/http</namespace>
- <namespace>http://schemas.xmlsoap.org/wsdl/http/</namespace>
- </extension>
</extensions>
Modified: stack/cxf/branches/cxf-2.3/modules/client/src/main/resources/META-INF/cxf/cxf-extension-jbossws.xml
===================================================================
--- stack/cxf/branches/cxf-2.3/modules/client/src/main/resources/META-INF/cxf/cxf-extension-jbossws.xml 2010-08-20 10:09:09 UTC (rev 12823)
+++ stack/cxf/branches/cxf-2.3/modules/client/src/main/resources/META-INF/cxf/cxf-extension-jbossws.xml 2010-08-21 08:10:36 UTC (rev 12824)
@@ -18,19 +18,4 @@
</cxf:bus>
-->
- <!-- The following is to be removed when providing a http transport factory implementation (for instance, using Jetty, see cxf-rt-transports-http-jetty.jar) -->
- <bean class="org.apache.cxf.transport.servlet.ServletTransportFactory"
- id="org.apache.cxf.transport.servlet.ServletTransportFactory"
- lazy-init="true">
- <property name="bus" ref="cxf"/>
- <property name="transportIds">
- <list>
- <value>http://cxf.apache.org/transports/http</value>
- <value>http://cxf.apache.org/transports/http/configuration</value>
- <value>http://schemas.xmlsoap.org/wsdl/http</value>
- <value>http://schemas.xmlsoap.org/wsdl/http/</value>
- </list>
- </property>
- </bean>
-
</beans>
\ No newline at end of file
Modified: stack/cxf/branches/cxf-2.3/modules/resources/src/main/resources/resources/jbossws-deploy-macros.xml
===================================================================
--- stack/cxf/branches/cxf-2.3/modules/resources/src/main/resources/resources/jbossws-deploy-macros.xml 2010-08-20 10:09:09 UTC (rev 12823)
+++ stack/cxf/branches/cxf-2.3/modules/resources/src/main/resources/resources/jbossws-deploy-macros.xml 2010-08-21 08:10:36 UTC (rev 12824)
@@ -39,6 +39,7 @@
<include name="**/jbossws-cxf-client*.jar"/>
<include name="**/jbossws-framework.jar"/>
<include name="**/jbossws-spi.jar"/>
+ <include name="**/jbossws-cxf-transports-httpserver.jar"/>
<include name="**/jdom.jar"/>
<include name="**/jetty*.jar"/>
<include name="**/neethi.jar"/>
@@ -87,6 +88,7 @@
</patternset>
<patternset id="jbossws.service.lib.patternset">
+ <include name="**/jbossws-cxf-transports-httpserver.jar"/>
<include name="**/jbossws-cxf-client*.jar"/>
<include name="**/jbossws-cxf-factories.jar"/>
<include name="**/jbossws-cxf-server*.jar"/>
Modified: stack/cxf/branches/cxf-2.3/pom.xml
===================================================================
--- stack/cxf/branches/cxf-2.3/pom.xml 2010-08-20 10:09:09 UTC (rev 12823)
+++ stack/cxf/branches/cxf-2.3/pom.xml 2010-08-21 08:10:36 UTC (rev 12824)
@@ -41,6 +41,7 @@
<module>modules/endorsed</module>
<module>modules/management</module>
<module>modules/resources</module>
+ <module>modules/addons</module>
</modules>
<!-- Properties -->
@@ -312,6 +313,10 @@
</exclusion>
<exclusion>
<groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-javamail_1.4_spec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jaxws_2.1_spec</artifactId>
</exclusion>
<exclusion>
@@ -1161,6 +1166,11 @@
<artifactId>jboss-jms-api_1.1_spec</artifactId>
<version>${jms.api.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymockclassextension</artifactId>
+ <version>2.4</version>
+ </dependency>
</dependencies>
</dependencyManagement>
Modified: stack/cxf/branches/cxf-2.3/src/main/scripts/assembly-deploy-artifacts.xml
===================================================================
--- stack/cxf/branches/cxf-2.3/src/main/scripts/assembly-deploy-artifacts.xml 2010-08-20 10:09:09 UTC (rev 12823)
+++ stack/cxf/branches/cxf-2.3/src/main/scripts/assembly-deploy-artifacts.xml 2010-08-21 08:10:36 UTC (rev 12824)
@@ -23,6 +23,7 @@
<useStrictFiltering>true</useStrictFiltering>
<includes>
<include>org.jboss.ws.cxf:jbossws-cxf-factories:jar</include>
+ <include>org.jboss.ws.cxf:jbossws-cxf-transports-httpserver:jar</include>
<include>org.apache.cxf:cxf-*</include>
<include>org.apache.cxf.xjcplugins:cxf-*</include>
<include>com.sun.xml.bind:jaxb-impl:jar</include>
More information about the jbossws-commits
mailing list