[jbossws-commits] JBossWS SVN: r6634 - in stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro: metadata and 1 other directory.
jbossws-commits at lists.jboss.org
jbossws-commits at lists.jboss.org
Wed Apr 23 11:27:15 EDT 2008
Author: richard.opalka at jboss.com
Date: 2008-04-23 11:27:15 -0400 (Wed, 23 Apr 2008)
New Revision: 6634
Added:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/metadata/FakeServletContext.java
Removed:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/FakeServletContext.java
Modified:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/metadata/RuntimeModelDeploymentAspect.java
Log:
fixed imports + refactoring - no functional change
Deleted: stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/FakeServletContext.java
===================================================================
--- stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/FakeServletContext.java 2008-04-23 13:32:55 UTC (rev 6633)
+++ stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/FakeServletContext.java 2008-04-23 15:27:15 UTC (rev 6634)
@@ -1,164 +0,0 @@
-package org.jboss.wsf.stack.metro;
-
-import com.sun.xml.ws.transport.http.ResourceLoader;
-
-import javax.servlet.ServletContext;
-import javax.servlet.RequestDispatcher;
-import javax.servlet.Servlet;
-import javax.servlet.ServletException;
-import java.net.URL;
-import java.net.MalformedURLException;
-import java.util.Set;
-import java.util.Enumeration;
-import java.io.InputStream;
-import java.io.IOException;
-
-public class FakeServletContext implements ServletContext
-{
- private ResourceLoader resourceLoader;
-
-
- public FakeServletContext(ResourceLoader resourceLoader)
- {
- this.resourceLoader = resourceLoader;
- }
-
-
- public ServletContext getContext(String string)
- {
- throw new IllegalArgumentException("Not implemented");
- }
-
- public String getContextPath()
- {
- throw new IllegalArgumentException("Not implemented");
- }
-
- public int getMajorVersion()
- {
- throw new IllegalArgumentException("Not implemented");
- }
-
- public int getMinorVersion()
- {
- throw new IllegalArgumentException("Not implemented");
- }
-
- public String getMimeType(String string)
- {
- throw new IllegalArgumentException("Not implemented");
- }
-
- public Set getResourcePaths(String string)
- {
- throw new IllegalArgumentException("Not implemented");
- }
-
- public URL getResource(String name)
- {
- try
- {
- return resourceLoader.getResource(name);
-
- } catch (Throwable e)
- {
- return null;
- }
- }
-
- public InputStream getResourceAsStream(String string)
- {
- try
- {
- return getResource(string).openStream();
- } catch (Throwable e)
- {
- return null;
- }
- }
-
- public RequestDispatcher getRequestDispatcher(String string)
- {
- throw new IllegalArgumentException("Not implemented");
- }
-
- public RequestDispatcher getNamedDispatcher(String string)
- {
- throw new IllegalArgumentException("Not implemented");
- }
-
- public Servlet getServlet(String string) throws ServletException
- {
- throw new IllegalArgumentException("Not implemented");
- }
-
- public Enumeration getServlets()
- {
- throw new IllegalArgumentException("Not implemented");
- }
-
- public Enumeration getServletNames()
- {
- throw new IllegalArgumentException("Not implemented");
- }
-
- public void log(String string)
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void log(Exception exception, String string)
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void log(String string, Throwable throwable)
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public String getRealPath(String string)
- {
- throw new IllegalArgumentException("Not implemented");
- }
-
- public String getServerInfo()
- {
- throw new IllegalArgumentException("Not implemented");
- }
-
- public String getInitParameter(String string)
- {
- throw new IllegalArgumentException("Not implemented");
- }
-
- public Enumeration getInitParameterNames()
- {
- throw new IllegalArgumentException("Not implemented");
- }
-
- public Object getAttribute(String string)
- {
- throw new IllegalArgumentException("Not implemented");
- }
-
- public Enumeration getAttributeNames()
- {
- throw new IllegalArgumentException("Not implemented");
- }
-
- public void setAttribute(String string, Object object)
- {
- throw new IllegalArgumentException("Not implemented");
- }
-
- public void removeAttribute(String string)
- {
- throw new IllegalArgumentException("Not implemented");
- }
-
- public String getServletContextName()
- {
- throw new IllegalArgumentException("Not implemented");
- }
-}
Added: stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/metadata/FakeServletContext.java
===================================================================
--- stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/metadata/FakeServletContext.java (rev 0)
+++ stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/metadata/FakeServletContext.java 2008-04-23 15:27:15 UTC (rev 6634)
@@ -0,0 +1,193 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.metro.metadata;
+
+import com.sun.xml.ws.transport.http.ResourceLoader;
+
+import javax.servlet.ServletContext;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import java.net.URL;
+import java.util.Set;
+import java.util.Enumeration;
+import java.io.InputStream;
+
+/**
+ * This ServletContext implementation provides access to resources only.
+ * Other methods are not implemented at all.
+ *
+ * @author richard.opalka at jboss.com
+ */
+public class FakeServletContext implements ServletContext
+{
+ private ResourceLoader resourceLoader;
+
+ public FakeServletContext(ResourceLoader resourceLoader)
+ {
+ this.resourceLoader = resourceLoader;
+ }
+
+ public URL getResource(String name)
+ {
+ try
+ {
+ return resourceLoader.getResource(name);
+ }
+ catch (Throwable e)
+ {
+ return null;
+ }
+ }
+
+ public InputStream getResourceAsStream(String string)
+ {
+ try
+ {
+ return getResource(string).openStream();
+ }
+ catch (Throwable e)
+ {
+ return null;
+ }
+ }
+
+ public ServletContext getContext(String string)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getContextPath()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getMajorVersion()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getMinorVersion()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getMimeType(String string)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @SuppressWarnings("unchecked")
+ public Set getResourcePaths(String string)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public RequestDispatcher getRequestDispatcher(String string)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public RequestDispatcher getNamedDispatcher(String string)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Servlet getServlet(String string) throws ServletException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @SuppressWarnings("unchecked")
+ public Enumeration getServlets()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @SuppressWarnings("unchecked")
+ public Enumeration getServletNames()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void log(String string)
+ {
+ // does nothing
+ }
+
+ public void log(Exception exception, String string)
+ {
+ // does nothing
+ }
+
+ public void log(String string, Throwable throwable)
+ {
+ // does nothing
+ }
+
+ public String getRealPath(String string)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getServerInfo()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getInitParameter(String string)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @SuppressWarnings("unchecked")
+ public Enumeration getInitParameterNames()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object getAttribute(String string)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @SuppressWarnings("unchecked")
+ public Enumeration getAttributeNames()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setAttribute(String string, Object object)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void removeAttribute(String string)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getServletContextName()
+ {
+ throw new UnsupportedOperationException();
+ }
+}
Property changes on: stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/metadata/FakeServletContext.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/metadata/RuntimeModelDeploymentAspect.java
===================================================================
--- stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/metadata/RuntimeModelDeploymentAspect.java 2008-04-23 13:32:55 UTC (rev 6633)
+++ stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/metadata/RuntimeModelDeploymentAspect.java 2008-04-23 15:27:15 UTC (rev 6634)
@@ -31,13 +31,17 @@
import com.sun.xml.ws.transport.http.ResourceLoader;
import com.sun.xml.ws.transport.http.servlet.ServletAdapter;
import com.sun.xml.ws.transport.http.servlet.ServletAdapterList;
+
import org.jboss.logging.Logger;
import org.jboss.wsf.common.ResourceLoaderAdapter;
-import org.jboss.wsf.spi.deployment.*;
+import org.jboss.wsf.spi.deployment.ArchiveDeployment;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.DeploymentAspect;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
import org.jboss.wsf.spi.WSFRuntime;
import org.jboss.wsf.stack.metro.DeploymentDescriptorParserExt;
import org.jboss.wsf.stack.metro.DeploymentDescriptorParserJBWS;
-import org.jboss.wsf.stack.metro.FakeServletContext;
import org.jboss.wsf.stack.metro.MessageStreamAdapter;
import org.jboss.wsf.stack.metro.log.MessageLogPipelineHook;
@@ -47,7 +51,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.Map;
import java.util.List;
/**
@@ -68,9 +72,7 @@
public class RuntimeModelDeploymentAspect extends DeploymentAspect
{
private static final org.jboss.logging.Logger log = Logger.getLogger(RuntimeModelDeploymentAspect.class);
-
protected static final String JAXWS_RI_RUNTIME = "/WEB-INF/sun-jaxws.xml";
-
public static final String PARAM_SUN_JAXWS_URL = "jbossws-sun-jaxws-url";
public void start(Deployment deployment, WSFRuntime runtime)
@@ -80,7 +82,6 @@
throw new IllegalArgumentException("Null runtimeLoader");
ClassLoader origClassLoader = Thread.currentThread().getContextClassLoader();
-
try
{
// Metro uses the thread context classloader in several places
@@ -93,7 +94,7 @@
}
else
{
- vfsRoot = new ResourceLoaderAdapter(runtimeLoader);
+ vfsRoot = new ResourceLoaderAdapter(runtimeLoader);
}
ResourceLoader resourceLoader = new VFSResourceLoader(vfsRoot);
@@ -106,62 +107,63 @@
DeploymentDescriptorParserExt<ServletAdapter> parser =
createDeploymentDescriptorParser(runtimeLoader, container, resourceLoader, adapterList);
- //URL sunJaxWsXml = getDDUrlFromResourceLoader(resourceLoaderAdapter);
URL sunJaxWsXml = getDDUrlFromContext(deployment);
List<ServletAdapter> adapters = parser.parse(sunJaxWsXml.toExternalForm(), sunJaxWsXml.openStream());
for(ServletAdapter adapter : adapters)
{
- for(Endpoint ep : deployment.getService().getEndpoints() )
+ for(Endpoint ep : deployment.getService().getEndpoints())
{
// TODO matching need to be improved
- if(ep.getShortName().equals(adapter.getName())&&
- ep.getTargetBeanClass().equals(adapter.getEndpoint().getImplementationClass()))
+ boolean nameEquals = ep.getShortName().equals(adapter.getName());
+ boolean beanEquals = ep.getTargetBeanClass().equals(adapter.getEndpoint().getImplementationClass());
+ if(nameEquals && beanEquals)
{
+ MessageStreamAdapter msgStreamAdapter = MessageStreamAdapter.FACTORY.createAdapter(adapter.getName(), null, adapter.getEndpoint());
+ // TODO JBWS-1869: Support stream based RequestHandler API
+ ep.addAttachment(MessageStreamAdapter.class, msgStreamAdapter);
ep.addAttachment(ServletAdapter.class, adapter);
-
- // JBWS-1869: Support stream based RequestHandler API
- ep.addAttachment(
- MessageStreamAdapter.class,
- MessageStreamAdapter.FACTORY.createAdapter(adapter.getName(), null, adapter.getEndpoint())
- );
break;
}
}
}
-
}
catch (Throwable e)
{
throw new WebServiceException("Failed to build METRO runtime model", e);
}
- finally{
+ finally
+ {
Thread.currentThread().setContextClassLoader(origClassLoader);
}
-
}
- private URL getDDUrlFromContext(Deployment deployment)
- throws MalformedURLException
+ @SuppressWarnings("unchecked")
+ private URL getDDUrlFromContext(Deployment deployment) throws MalformedURLException
{
- HashMap<String, String> contextProperties =
- (HashMap<String, String>)deployment.getProperty("org.jboss.ws.webapp.ContextParameterMap");
- URL sunJaxWsXml = new URL(contextProperties.get(PARAM_SUN_JAXWS_URL));
- return sunJaxWsXml;
+ Map<String, String> contextProperties =
+ (Map<String, String>)deployment.getProperty("org.jboss.ws.webapp.ContextParameterMap");
+
+ return new URL(contextProperties.get(PARAM_SUN_JAXWS_URL));
}
/**
* Externalized for integration
*/
- protected DeploymentDescriptorParserExt<ServletAdapter> createDeploymentDescriptorParser(
- ClassLoader classLoader, JBossWSContainer container,
- ResourceLoader resourceLoader, DeploymentDescriptorParser.AdapterFactory<ServletAdapter> adapterList)
- throws MalformedURLException
+ protected DeploymentDescriptorParserExt<ServletAdapter> createDeploymentDescriptorParser
+ (
+ ClassLoader classLoader,
+ JBossWSContainer container,
+ ResourceLoader resourceLoader,
+ DeploymentDescriptorParser.AdapterFactory<ServletAdapter> adapterList
+ )
+ throws MalformedURLException
{
- DeploymentDescriptorParserExt<ServletAdapter> parser =
- new DeploymentDescriptorParserJBWS<ServletAdapter>(classLoader, resourceLoader, container, adapterList);
- return parser;
+ return new DeploymentDescriptorParserJBWS<ServletAdapter>
+ (
+ classLoader, resourceLoader, container, adapterList
+ );
}
/**
@@ -169,20 +171,17 @@
*/
protected URL getDDUrlFromResourceLoader(UnifiedVirtualFile vfsRoot) throws IOException
{
- URL sunJaxWsXml = vfsRoot.findChild(JAXWS_RI_RUNTIME).toURL();
- return sunJaxWsXml;
+ return vfsRoot.findChild(JAXWS_RI_RUNTIME).toURL();
}
-
/**
* Provides access to {@link javax.servlet.ServletContext} via {@link com.sun.xml.ws.api.server.Container}.
* Pipes can get ServletContext from Container and use it to load some resources.
*/
- static class JBossWSContainer extends Container
+ private static class JBossWSContainer extends Container
{
private ResourceLoader resourceLoader;
-
- private final Module module = new Module()
+ private Module module = new Module()
{
private final List<BoundEndpoint> endpoints = new ArrayList<BoundEndpoint>();
@@ -198,21 +197,22 @@
this.resourceLoader = loader;
}
+ @SuppressWarnings("unchecked")
public <T> T getSPI(Class<T> spiType)
{
if (spiType == Module.class)
{
return spiType.cast(module);
}
- else if(spiType == ResourceInjector.class)
+ if(spiType == ResourceInjector.class)
{
return (T)ResourceInjector.STANDALONE;
}
- else if (spiType == ServerPipelineHook.class)
+ if (spiType == ServerPipelineHook.class)
{
return (T)new MessageLogPipelineHook();
}
- else if(spiType == ServletContext.class)
+ if(spiType == ServletContext.class)
{
return (T)new FakeServletContext(resourceLoader);
}
More information about the jbossws-commits
mailing list