Author: heiko.braun(a)jboss.com
Date: 2008-03-07 14:12:05 -0500 (Fri, 07 Mar 2008)
New Revision: 5888
Added:
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/DefaultTransportManagerFactory.java
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpDeamon.java
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpListenerRef.java
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpSpec.java
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpTransportManager.java
framework/branches/hbraun/src/test/java/org/jboss/test/ws/framework/
framework/branches/hbraun/src/test/java/org/jboss/test/ws/framework/transport/
framework/branches/hbraun/src/test/java/org/jboss/test/ws/framework/transport/HttpDeamonTestCase.java
framework/branches/hbraun/src/test/java/org/jboss/test/ws/framework/transport/TransportManagerTestCase.java
Modified:
framework/branches/hbraun/ant-import/build-thirdparty.xml
framework/branches/hbraun/framework.iml
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/DefaultSPIProvider.java
framework/branches/hbraun/version.properties
Log:
Transport impl, first cut. Added HttpDeamon
Modified: framework/branches/hbraun/ant-import/build-thirdparty.xml
===================================================================
--- framework/branches/hbraun/ant-import/build-thirdparty.xml 2008-03-07 19:10:52 UTC (rev
5887)
+++ framework/branches/hbraun/ant-import/build-thirdparty.xml 2008-03-07 19:12:05 UTC (rev
5888)
@@ -48,6 +48,8 @@
<get
src="${jboss.repository}/jboss/jboss-javaee/${jboss-javaee}/lib/jboss-javaee.jar"
dest="${thirdparty.dir}/jboss-javaee.jar" usetimestamp="true"
verbose="true"/>
<get
src="${jboss.repository}/jboss/jbossxb/${jboss-jbossxb}/lib/jboss-xml-binding.jar"
dest="${thirdparty.dir}/jboss-xml-binding.jar" usetimestamp="true"
verbose="true"/>
<get
src="${jboss.repository}/jboss/jbossxb/${jboss-jbossxb}/lib/jboss-xml-binding-sources.jar"
dest="${thirdparty.dir}/jboss-xml-binding-sources.jar"
usetimestamp="true" verbose="true"/>
+ <get src="${jboss.repository}/jetty/${jetty}/lib/jetty.jar"
dest="${thirdparty.dir}/jetty.jar" usetimestamp="true"
verbose="true"/>
+ <get src="${jboss.repository}/jetty/${jetty}/lib/jetty-util.jar"
dest="${thirdparty.dir}/jetty-util.jar" usetimestamp="true"
verbose="true"/>
<get src="${jboss.repository}/sun-jaf/${sun-jaf}/lib/activation.jar"
dest="${thirdparty.dir}/activation.jar" usetimestamp="true"
verbose="true"/>
<get src="${jboss.repository}/sun-jaxb/${sun-jaxb}/lib/jaxb-api.jar"
dest="${thirdparty.dir}/jaxb-api.jar" usetimestamp="true"
verbose="true"/>
<get
src="${jboss.repository}/sun-jaxrpc/${sun-jaxrpc}/lib/jaxrpc-api.jar"
dest="${thirdparty.dir}/jaxrpc-api.jar" usetimestamp="true"
verbose="true"/>
@@ -73,6 +75,8 @@
<pathelement location="${thirdparty.dir}/jbossws-spi.jar"/>
<pathelement location="${thirdparty.dir}/jaxws-api.jar"/>
<pathelement location="${thirdparty.dir}/jaxrpc-api.jar"/>
+ <pathelement location="${thirdparty.dir}/jetty.jar"/>
+ <pathelement location="${thirdparty.dir}/jetty-util.jar"/>
<pathelement location="${thirdparty.dir}/jsr181-api.jar"/>
<pathelement location="${thirdparty.dir}/saaj-api.jar"/>
</path>
Modified: framework/branches/hbraun/framework.iml
===================================================================
--- framework/branches/hbraun/framework.iml 2008-03-07 19:10:52 UTC (rev 5887)
+++ framework/branches/hbraun/framework.iml 2008-03-07 19:12:05 UTC (rev 5888)
@@ -1,11 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4" relativePaths="true"
type="JAVA_MODULE">
<component name="ModuleRootManager" />
- <component name="NewModuleRootManager"
inherit-compiler-output="true">
+ <component name="NewModuleRootManager"
inherit-compiler-output="false">
+ <output url="file://$MODULE_DIR$/output/classes" />
<exclude-output />
+ <output-test url="file://$MODULE_DIR$/output/test/classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java"
isTestSource="false" />
- <sourceFolder url="file://$MODULE_DIR$/src/test/java"
isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/test/java"
isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
@@ -154,6 +156,43 @@
</library>
</orderEntry>
<orderEntry type="module" module-name="spi" />
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root
url="jar://$MODULE_DIR$/thirdparty/commons-logging-api.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/commons-logging.jar!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module" module-name="jetty-6.1.8" />
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jetty-util.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jetty.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
<orderEntryProperties />
</component>
</module>
Modified:
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/DefaultSPIProvider.java
===================================================================
---
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/DefaultSPIProvider.java 2008-03-07
19:10:52 UTC (rev 5887)
+++
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/DefaultSPIProvider.java 2008-03-07
19:12:05 UTC (rev 5888)
@@ -31,8 +31,10 @@
import org.jboss.wsf.framework.management.DefaultEndpointMetricsFactory;
import org.jboss.wsf.framework.serviceref.DefaultServiceRefHandlerFactory;
import org.jboss.wsf.framework.serviceref.DefaultServiceRefMetaDataParserFactory;
+import org.jboss.wsf.framework.transport.DefaultTransportManagerFactory;
import org.jboss.wsf.spi.SPIProvider;
import org.jboss.wsf.spi.WSFException;
+import org.jboss.wsf.spi.transport.TransportManagerFactory;
import org.jboss.wsf.spi.deployment.DeploymentAspectManagerFactory;
import org.jboss.wsf.spi.deployment.DeploymentModelFactory;
import org.jboss.wsf.spi.deployment.LifecycleHandlerFactory;
@@ -106,7 +108,7 @@
else if (ServiceRefMetaDataParserFactory.class.equals(spiType))
{
returnType = (T)loadService(spiType,
DefaultServiceRefMetaDataParserFactory.class.getName());
- }
+ }
// SPI provided by either container or stack integration
@@ -138,6 +140,10 @@
{
returnType = (T)loadService(spiType, null);
}
+ else if (TransportManagerFactory.class.equals(spiType))
+ {
+ returnType = (T)loadService(spiType, null);
+ }
if (returnType == null)
throw new WSFException("Failed to provide SPI '" + spiType +
"'");
Added:
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/DefaultTransportManagerFactory.java
===================================================================
---
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/DefaultTransportManagerFactory.java
(rev 0)
+++
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/DefaultTransportManagerFactory.java 2008-03-07
19:12:05 UTC (rev 5888)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.framework.transport;
+
+import org.jboss.wsf.spi.transport.TransportManagerFactory;
+import org.jboss.wsf.spi.transport.TransportManager;
+import org.jboss.wsf.spi.transport.Protocol;
+
+/**
+ * @author Heiko.Braun <heiko.braun(a)jboss.com>
+ */
+public class DefaultTransportManagerFactory implements TransportManagerFactory
+{
+
+ public TransportManager createTransportManager(Protocol protocol)
+ {
+ TransportManager manager = null;
+
+ switch(protocol)
+ {
+ case HTTP:
+ manager = new HttpTransportManager();
+ break;
+ default:
+ throw new IllegalArgumentException("No TransportManager for protocol:
" + protocol);
+ }
+
+ return manager;
+ }
+}
Property changes on:
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/DefaultTransportManagerFactory.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpDeamon.java
===================================================================
---
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpDeamon.java
(rev 0)
+++
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpDeamon.java 2008-03-07
19:12:05 UTC (rev 5888)
@@ -0,0 +1,177 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.framework.transport;
+
+import org.jboss.logging.Logger;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.handler.ContextHandlerCollection;
+import org.mortbay.jetty.servlet.Context;
+import org.mortbay.jetty.servlet.ServletHolder;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+/**
+ * @author Heiko.Braun <heiko.braun(a)jboss.com>
+ */
+public class HttpDeamon
+{
+ private static final Logger LOG = Logger.getLogger(HttpDeamon.class);
+ private static final Lock CLASS_LOCK = new ReentrantLock();
+ private static HttpDeamon INSTANCE = null;
+
+ private final int port;
+
+ // Jetty stuff below
+ private Server server = null;
+ private final ContextHandlerCollection contexts;
+
+ private HttpDeamon(int port)
+ {
+ this.port = port;
+ this.server = new Server(port);
+
+ this.contexts = new ContextHandlerCollection();
+ this.server.setHandler(contexts);
+
+ Context root = new Context(contexts,"/");
+ root.addServlet(new ServletHolder(new HelloServlet("JBossWS
HttpDeamon")), "/*");
+ }
+
+ public int getPort()
+ {
+ return port;
+ }
+
+ public void start()
+ {
+ try
+ {
+ this.server.start();
+ } catch (Exception e)
+ {
+ LOG.error("Failed to start Jetty", e);
+ }
+ }
+
+ public void stop()
+ {
+ try
+ {
+ this.server.stop();
+ } catch (Exception e)
+ {
+ LOG.error("Failed to stop Jetty", e);
+ }
+ }
+
+ /**
+ * Add a servlet for a contextand url pattern.
+ *
+ * @param name
+ * @param urlPattern
+ * @param servletClass
+ */
+ public void addServletContext(String name, String urlPattern, Servlet servletClass)
+ {
+ try
+ {
+ Context context = new Context();
+ context.setContextPath(name);
+ ServletHolder holder = new ServletHolder(servletClass);
+ context.addServlet(holder, urlPattern);
+ context.start();
+ this.contexts.addHandler(context);
+
+ } catch (Exception e)
+ {
+ throw new RuntimeException("Failed to start webcontext: " +name, e );
+ }
+ }
+
+ public static HttpDeamon getInstance(int port)
+ {
+ CLASS_LOCK.lock();
+ try
+ {
+ if (INSTANCE == null)
+ {
+ INSTANCE = new HttpDeamon(port);
+
+ try
+ {
+ INSTANCE.start();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Failed to start HttpDeamon", e);
+ }
+
+ Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
+ public void run()
+ {
+ try
+ {
+ INSTANCE.stop();
+ } catch (Exception e)
+ {
+ //
+ }
+ }
+ }, "HttpDeamonShutDownHook"));
+ }
+ else
+ {
+ LOG.warn("There is already a HttpDeamon running on port: " +
INSTANCE.getPort());
+ }
+ return INSTANCE;
+ }
+ finally
+ {
+ CLASS_LOCK.unlock();
+ }
+ }
+
+ public static class HelloServlet extends HttpServlet
+ {
+ String greeting="Hello";
+ public HelloServlet()
+ {}
+
+ public HelloServlet(String hi)
+ {greeting=hi;}
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ response.setContentType("text/plain");
+ response.setStatus(HttpServletResponse.SC_OK);
+ response.getWriter().println(greeting);
+ }
+ }
+}
Property changes on:
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpDeamon.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpListenerRef.java
===================================================================
---
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpListenerRef.java
(rev 0)
+++
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpListenerRef.java 2008-03-07
19:12:05 UTC (rev 5888)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.framework.transport;
+
+import org.jboss.wsf.spi.transport.ListenerRef;
+import org.jboss.wsf.spi.transport.Protocol;
+
+import java.net.URI;
+
+/**
+ * @author Heiko.Braun <heiko.braun(a)jboss.com>
+ */
+public class HttpListenerRef implements ListenerRef
+{
+ private String webContext;
+ private URI address;
+
+ public HttpListenerRef(String webContext, URI address)
+ {
+ this.webContext = webContext;
+ this.address = address;
+ }
+
+ public Protocol getProtocol()
+ {
+ return Protocol.HTTP;
+ }
+
+ public URI getAddress()
+ {
+ return address;
+ }
+
+ public String getUUID()
+ {
+ return this.webContext;
+ }
+}
Property changes on:
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpListenerRef.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpSpec.java
===================================================================
---
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpSpec.java
(rev 0)
+++
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpSpec.java 2008-03-07
19:12:05 UTC (rev 5888)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.framework.transport;
+
+import org.jboss.wsf.spi.transport.TransportSpec;
+import org.jboss.wsf.spi.transport.Protocol;
+
+
+/**
+ * @author Heiko.Braun <heiko.braun(a)jboss.com>
+ */
+public class HttpSpec implements TransportSpec
+{
+ private String webContext;
+ private String urlPattern;
+
+ public Protocol getProtocol()
+ {
+ return Protocol.HTTP;
+ }
+
+ public String getWebContext()
+ {
+ return webContext;
+ }
+
+ public void setWebContext(String webContext)
+ {
+ this.webContext = webContext;
+ }
+
+ public String getUrlPattern()
+ {
+ return urlPattern;
+ }
+
+ public void setUrlPattern(String urlPattern)
+ {
+ this.urlPattern = urlPattern;
+ }
+}
Property changes on:
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpSpec.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpTransportManager.java
===================================================================
---
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpTransportManager.java
(rev 0)
+++
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpTransportManager.java 2008-03-07
19:12:05 UTC (rev 5888)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.framework.transport;
+
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.transport.ListenerRef;
+import org.jboss.wsf.spi.transport.TransportManager;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+/**
+ * @author Heiko.Braun <heiko.braun(a)jboss.com>
+ */
+public class HttpTransportManager implements TransportManager<HttpSpec>
+{
+ private Map<String, Object> contexts = new HashMap<String, Object>();
+
+ public ListenerRef createListener(Endpoint endpoint, HttpSpec transportProperties)
+ {
+ contexts.put(transportProperties.getWebContext(), new Object());
+ System.out.println( "Created webcontext: /" +
transportProperties.getWebContext());
+
+ return createListenerRef(transportProperties);
+ }
+
+ private ListenerRef createListenerRef(HttpSpec transportProperties)
+ {
+ try
+ {
+ String ctx = transportProperties.getWebContext();
+ URI address = new URI("http://localhost/" + ctx);
+ return new HttpListenerRef(ctx, address);
+ } catch (URISyntaxException e)
+ {
+ throw new RuntimeException("Failed to create ListenerRef");
+ }
+ }
+
+ public void destroyListener(ListenerRef ref)
+ {
+ Object result = contexts.remove(ref.getUUID());
+ if(result==null)
+ {
+ throw new IllegalArgumentException("No such webcontext: " +
ref.getUUID());
+ }
+
+ System.out.println("Removed webcontext: /" + ref.getUUID());
+ }
+
+
+}
Property changes on:
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpTransportManager.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
framework/branches/hbraun/src/test/java/org/jboss/test/ws/framework/transport/HttpDeamonTestCase.java
===================================================================
---
framework/branches/hbraun/src/test/java/org/jboss/test/ws/framework/transport/HttpDeamonTestCase.java
(rev 0)
+++
framework/branches/hbraun/src/test/java/org/jboss/test/ws/framework/transport/HttpDeamonTestCase.java 2008-03-07
19:12:05 UTC (rev 5888)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.test.ws.framework.transport;
+
+import junit.framework.TestCase;
+import org.jboss.wsf.framework.transport.HttpDeamon;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.net.URLConnection;
+
+/**
+ * @author Heiko.Braun <heiko.braun(a)jboss.com>
+ */
+public class HttpDeamonTestCase extends TestCase
+{
+ private static HttpDeamon SERVER = HttpDeamon.getInstance(20000);
+
+ public void testRootContext() throws Exception
+ {
+ String response = GETRequest("");
+ assertEquals("JBossWS HttpDeamon", response.toString());
+ }
+
+ public void testContextCreation() throws Exception
+ {
+ SERVER.addServletContext("/endpoint", "/*", new
EndpointServlet());
+ assertEquals("I'm a web service endpoint",
GETRequest("endpoint"));
+ }
+
+ private static String GETRequest(String context)
+ throws IOException
+ {
+ URLConnection con = new
URL("http://localhost:20000/"+context).openConnection();
+ con.connect();
+
+ BufferedReader in = new BufferedReader(
+ new InputStreamReader(
+ con.getInputStream()
+ )
+ );
+
+ String inputLine;
+ StringBuffer sb = new StringBuffer();
+ while ((inputLine = in.readLine()) != null)
+ sb.append(inputLine);
+ in.close();
+ return sb.toString();
+ }
+
+ private class EndpointServlet extends HttpServlet
+ {
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ response.setContentType("text/html");
+ response.setStatus(HttpServletResponse.SC_OK);
+ response.getWriter().println("I'm a web service endpoint");
+ }
+ }
+}
+
Property changes on:
framework/branches/hbraun/src/test/java/org/jboss/test/ws/framework/transport/HttpDeamonTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
framework/branches/hbraun/src/test/java/org/jboss/test/ws/framework/transport/TransportManagerTestCase.java
===================================================================
---
framework/branches/hbraun/src/test/java/org/jboss/test/ws/framework/transport/TransportManagerTestCase.java
(rev 0)
+++
framework/branches/hbraun/src/test/java/org/jboss/test/ws/framework/transport/TransportManagerTestCase.java 2008-03-07
19:12:05 UTC (rev 5888)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.test.ws.framework.transport;
+
+import junit.framework.TestCase;
+import org.jboss.wsf.framework.DefaultSPIProviderResolver;
+import org.jboss.wsf.framework.transport.HttpSpec;
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.deployment.DeploymentModelFactory;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.transport.ListenerRef;
+import org.jboss.wsf.spi.transport.Protocol;
+import org.jboss.wsf.spi.transport.TransportManager;
+import org.jboss.wsf.spi.transport.TransportManagerFactory;
+
+/**
+ * @author Heiko.Braun <heiko.braun(a)jboss.com>
+ */
+public class TransportManagerTestCase extends TestCase
+{
+ private Endpoint EP;
+ private TransportManagerFactory TM_FACTORY;
+
+ protected void setUp() throws Exception
+ {
+ SPIProvider framework = DefaultSPIProviderResolver.getInstance().getProvider();
+ DeploymentModelFactory fac = framework.getSPI(DeploymentModelFactory.class);
+ EP = fac.newEndpoint("MyEndpointBean.class");
+ TM_FACTORY = framework.getSPI(TransportManagerFactory.class);
+ }
+
+ public void testHttpTransportManager() throws Exception
+ {
+ TransportManager transportManager =
TM_FACTORY.createTransportManager(Protocol.HTTP);
+ HttpSpec spec = new HttpSpec();
+ spec.setWebContext("myWebContext");
+
+ ListenerRef ref = transportManager.createListener(EP, spec);
+ assertEquals(spec.getProtocol(), ref.getProtocol());
+ System.out.println(ref.getProtocol() +": "+ref.getAddress());
+ transportManager.destroyListener(ref);
+
+
+ }
+}
Property changes on:
framework/branches/hbraun/src/test/java/org/jboss/test/ws/framework/transport/TransportManagerTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: framework/branches/hbraun/version.properties
===================================================================
--- framework/branches/hbraun/version.properties 2008-03-07 19:10:52 UTC (rev 5887)
+++ framework/branches/hbraun/version.properties 2008-03-07 19:12:05 UTC (rev 5888)
@@ -15,7 +15,7 @@
# Thirdparty library versions
jbossws-common=snapshot
-jbossws-spi=1.0.1.GA
+jbossws-spi=1.1.0.DEV
junit=3.8.1
dom4j=1.6.1
@@ -24,6 +24,7 @@
jboss-javaee=5.0.0.Beta3
jboss-microcontainer=2.0.0.Beta3
jboss-jbossxb=1.0.0.GA
+jetty=6.1.8
sun-jaf=1.1
sun-jaxb=2.1.4
sun-jaxrpc=1.1