Author: heiko.braun(a)jboss.com
Date: 2008-03-08 14:49:51 -0500 (Sat, 08 Mar 2008)
New Revision: 5898
Removed:
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpSpec.java
Modified:
framework/branches/hbraun/framework-3.0.iml
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/DefaultSPIProvider.java
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/deployment/DefaultEndpoint.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/HttpTransportManager.java
framework/branches/hbraun/version.properties
Log:
HttpSpec moved to SPI
Modified: framework/branches/hbraun/framework-3.0.iml
===================================================================
--- framework/branches/hbraun/framework-3.0.iml 2008-03-08 19:49:28 UTC (rev 5897)
+++ framework/branches/hbraun/framework-3.0.iml 2008-03-08 19:49:51 UTC (rev 5898)
@@ -183,15 +183,6 @@
<SOURCES />
</library>
</orderEntry>
- <orderEntry type="module-library">
- <library>
- <CLASSES>
- <root url="jar://$MODULE_DIR$/thirdparty/saaj-api.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-08
19:49:28 UTC (rev 5897)
+++
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/DefaultSPIProvider.java 2008-03-08
19:49:51 UTC (rev 5898)
@@ -29,6 +29,7 @@
import org.jboss.wsf.framework.http.DefaultHttpServerFactory;
import org.jboss.wsf.framework.invocation.DefaultResourceInjectorFactory;
import org.jboss.wsf.framework.management.DefaultEndpointMetricsFactory;
+import org.jboss.wsf.framework.management.ServerConfigFactoryImpl;
import org.jboss.wsf.framework.serviceref.DefaultServiceRefHandlerFactory;
import org.jboss.wsf.framework.serviceref.DefaultServiceRefMetaDataParserFactory;
import org.jboss.wsf.framework.transport.DefaultTransportManagerFactory;
@@ -113,6 +114,10 @@
{
returnType = (T)loadService(spiType,
DefaultTransportManagerFactory.class.getName());
}
+ else if (ServerConfigFactory.class.equals(spiType))
+ {
+ returnType = (T)loadService(spiType, ServerConfigFactoryImpl.class.getName());
+ }
// SPI provided by either container or stack integration
@@ -132,10 +137,7 @@
{
returnType = (T)loadService(spiType, null);
}
- else if (ServerConfigFactory.class.equals(spiType))
- {
- returnType = (T)loadService(spiType, null);
- }
+
else if (ServiceRefBinderFactory.class.equals(spiType))
{
returnType = (T)loadService(spiType, null);
Modified:
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/deployment/DefaultEndpoint.java
===================================================================
---
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/deployment/DefaultEndpoint.java 2008-03-08
19:49:28 UTC (rev 5897)
+++
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/deployment/DefaultEndpoint.java 2008-03-08
19:49:51 UTC (rev 5898)
@@ -137,10 +137,11 @@
// build implicit name
try
{
- String domain = "org.jboss.ws";
- String nameAtt = getShortName()!=null ? getShortName() : targetBean;
-
- name = new ObjectName(domain, "name", nameAtt);
+ name = new ObjectName(
+ Endpoint.SEPID_DOMAIN,
+ Endpoint.SEPID_PROPERTY_ENDPOINT, targetBean
+ );
+
} catch (MalformedObjectNameException e)
{
//
Modified:
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 2008-03-08
19:49:28 UTC (rev 5897)
+++
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpDeamon.java 2008-03-08
19:49:51 UTC (rev 5898)
@@ -23,6 +23,7 @@
import org.jboss.logging.Logger;
import org.mortbay.jetty.Server;
+import org.mortbay.jetty.Handler;
import org.mortbay.jetty.handler.ContextHandlerCollection;
import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.ServletHolder;
@@ -114,6 +115,11 @@
}
}
+ public void removeServletContext(String contextPath, String urlPattern)
+ {
+ LOG.warn("Cannot remove context: " + contextPath + "/" +
urlPattern + "(Not implemented)");
+ }
+
public static HttpDeamon getInstance(int port)
{
CLASS_LOCK.lock();
Modified:
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 2008-03-08
19:49:28 UTC (rev 5897)
+++
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpListenerRef.java 2008-03-08
19:49:51 UTC (rev 5898)
@@ -32,11 +32,16 @@
public class HttpListenerRef implements ListenerRef
{
private String webContext;
+ private String urlPattern;
private URI address;
- public HttpListenerRef(String webContext, URI address)
+ public HttpListenerRef(String webContext, String urlPattern, URI address)
{
+ if(!webContext.startsWith("/") || !urlPattern.startsWith("/"))
+ throw new IllegalArgumentException("Both webContext and urlPattern need to
start with '/'");
+
this.webContext = webContext;
+ this.urlPattern = urlPattern;
this.address = address;
}
@@ -52,6 +57,6 @@
public String getUUID()
{
- return this.webContext;
+ return this.webContext+this.urlPattern;
}
}
Deleted:
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 2008-03-08
19:49:28 UTC (rev 5897)
+++
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpSpec.java 2008-03-08
19:49:51 UTC (rev 5898)
@@ -1,59 +0,0 @@
-/*
- * 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 HttpSpec(String webContext, String urlPattern)
- {
- if(!webContext.startsWith("/"))
- throw new IllegalArgumentException("webContext needs to start with
'/'");
-
- this.webContext = webContext;
- this.urlPattern = urlPattern;
- }
-
- public Protocol getProtocol()
- {
- return Protocol.HTTP;
- }
-
- public String getWebContext()
- {
- return webContext;
- }
-
- public String getUrlPattern()
- {
- return urlPattern;
- }
-}
Modified:
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 2008-03-08
19:49:28 UTC (rev 5897)
+++
framework/branches/hbraun/src/main/java/org/jboss/wsf/framework/transport/HttpTransportManager.java 2008-03-08
19:49:51 UTC (rev 5898)
@@ -21,12 +21,21 @@
*/
package org.jboss.wsf.framework.transport;
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
+import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.invocation.EndpointAssociation;
+import org.jboss.wsf.spi.invocation.RequestHandler;
+import org.jboss.wsf.spi.management.EndpointRegistry;
+import org.jboss.wsf.spi.management.EndpointRegistryFactory;
import org.jboss.wsf.spi.transport.ListenerRef;
import org.jboss.wsf.spi.transport.TransportManager;
+import org.jboss.wsf.spi.transport.HttpSpec;
-import javax.management.ObjectName;
import javax.servlet.Servlet;
+import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
@@ -42,8 +51,8 @@
{
private HttpDeamon httpDeamon;
- private static final int DEFAULT_PORT = 20000;
- private static final String DEFAULT_HOST = "localhost";
+ public static final int DEFAULT_PORT = 20000;
+ public static final String DEFAULT_HOST = "localhost";
private int port;
private String host;
@@ -63,27 +72,30 @@
}
public ListenerRef createListener(Endpoint endpoint, HttpSpec transportProperties)
- {
+ {
Servlet listener = new EndpointServlet(endpoint);
this.httpDeamon.addServletContext(
transportProperties.getWebContext(),
transportProperties.getUrlPattern(),
listener
);
-
+
return createListenerRef(transportProperties);
}
private ListenerRef createListenerRef(HttpSpec transportProperties)
{
-
+
assert transportProperties.getWebContext().startsWith("/");
-
+ assert transportProperties.getUrlPattern()!=null;
+
try
{
String ctx = transportProperties.getWebContext();
- URI address = new URI("http://"+host+":"+port + ctx);
- return new HttpListenerRef(ctx, address);
+ String urlPattern = transportProperties.getUrlPattern();
+
+ URI address = new URI("http://"+host+":"+port + ctx +
urlPattern);
+ return new HttpListenerRef(ctx, urlPattern, address);
} catch (URISyntaxException e)
{
throw new RuntimeException("Failed to create ListenerRef");
@@ -92,19 +104,37 @@
public void destroyListener(ListenerRef ref)
{
-
+ String context = ref.getUUID().substring(0,
ref.getUUID().lastIndexOf("/"));
+ String urlPattern =
ref.getUUID().substring(ref.getUUID().lastIndexOf("/"));
+ this.httpDeamon.removeServletContext(context, urlPattern);
}
+ /**
+ * Core listener component
+ */
public class EndpointServlet extends HttpServlet
{
- ObjectName endpointName;
+ // provide logging
+ private final Logger log = Logger.getLogger(EndpointServlet.class);
+ protected Endpoint endpoint;
+ protected EndpointRegistry epRegistry;
+
+ private boolean started;
+
+ public void init(ServletConfig servletConfig) throws ServletException
+ {
+ super.init(servletConfig);
+ SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+ epRegistry =
spiProvider.getSPI(EndpointRegistryFactory.class).getEndpointRegistry();
+ }
+
public EndpointServlet(Endpoint endpoint)
{
if(null==endpoint.getName())
throw new IllegalArgumentException("Endpoint objectName is null");
-
- this.endpointName = endpoint.getName();
+
+ this.endpoint = endpoint;
}
protected void doGet(HttpServletRequest request, HttpServletResponse response)
@@ -112,14 +142,37 @@
{
response.setContentType("text/plain");
response.setStatus(HttpServletResponse.SC_OK);
- response.getWriter().println(endpointName);
+ response.getWriter().println(endpoint.getName());
}
+ public void service(HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException
+ {
+ // arguable solution ...
+ // the endpoint should be started when the transport listener is created
+ if(!started) startEndpoint();
- protected void doPost(HttpServletRequest httpServletRequest, HttpServletResponse
httpServletResponse)
- throws ServletException, IOException
+ try
+ {
+ EndpointAssociation.setEndpoint(endpoint);
+ RequestHandler requestHandler = endpoint.getRequestHandler();
+ requestHandler.handleHttpRequest(endpoint, req, res, getServletContext());
+ }
+ finally
+ {
+ EndpointAssociation.removeEndpoint();
+ }
+ }
+
+ private void startEndpoint()
{
- throw new ServletException("POST not yet implemented");
- }
+ // Start the endpoint
+ Deployment dep = endpoint.getService().getDeployment();
+ if (dep.getType() == Deployment.DeploymentType.JAXRPC_JSE ||
+ dep.getType() == Deployment.DeploymentType.JAXWS_JSE)
+ {
+ if (endpoint.getState() == Endpoint.EndpointState.CREATED)
+ endpoint.getLifecycleHandler().start(endpoint);
+ }
+ }
}
}
Modified: framework/branches/hbraun/version.properties
===================================================================
--- framework/branches/hbraun/version.properties 2008-03-08 19:49:28 UTC (rev 5897)
+++ framework/branches/hbraun/version.properties 2008-03-08 19:49:51 UTC (rev 5898)
@@ -15,7 +15,7 @@
# Thirdparty library versions
jbossws-common=snapshot
-jbossws-spi=1.1.0.DEV
+jbossws-spi=snapshot
junit=3.8.1
dom4j=1.6.1