Similarly to what Jitendra Kotamraju did for Grizzly, I've just created a small project for using the JDK6 httpserver with this HTTP SPI, basically allowing any JAXWS 2.2 stack implementation to be used on top of it (not just the JAXWS RI as mentioned here). The project only runtime dependency is the JAXWS 2.2 API, so it's completely vendor agnostic (the project testsuite uses Apache CXF just for the sake of testing with a JAXWS 2.2 impl).
So, the following is now possible using any JAXWS 2.2 compliant implementation:
import com.sun.net.httpserver.HttpServer;
import javax.xml.ws.spi.http.HttpContext;
import org.jboss.ws.httpserver_httpspi.
HttpServerContextFactory;
..
HttpServer server = HttpServer.create(new InetSocketAddress(8080), 0);
HttpContext context = HttpServerContextFactory.createHttpContext(server, "/ctx", "/echo");
Endpoint endpoint = Endpoint.create(new EndpointBean());
endpoint.publish(context); // Use httpserver context for publishing
server.start();
//invoke endpoint
endpoint.stop();
server.stop(0);
The binaries for the project are on JBoss' Maven repository.
4 comments:
Hi Alessio, the code snippet in your blog doesn't seem to have any dependencies on the small project you created (unless I'm missing something), so I'm not sure how the project you created plays a role in this. Can you explain further? Thanks!
Hi Glen,
sorry, I simply copied the snippet from a test I have in the same package of the HttpServerContextFactory... hence no import for that. I've just modified the snippet to make the dependency more clear. Thanks for pointing this out :-)
Cheers
Alessio
btw, the source code of the mentioned test is at http://anonsvn.jboss.org/repos/jbossws/projects/jaxws-httpserver-httpspi/trunk/src/test/java/org/jboss/ws/httpserver_httpspi/EndpointAPITest.java
For the records, the project has been released in its first final version:
Sources
Maven artifacts
Post a Comment