Author: heiko.braun(a)jboss.com
Date: 2007-10-23 10:22:45 -0400 (Tue, 23 Oct 2007)
New Revision: 4863
Removed:
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/WSServletContextListenerExt.java
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/WSServletContextListenerJBWS.java
Modified:
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/DeploymentDescriptorParserExt.java
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/SunJaxwsDeploymentAspect.java
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/metadata/RuntimeModelDeploymentAspect.java
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/metadata/VFSResourceLoader.java
Log:
Allow resource reading from META-INF
Modified:
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/DeploymentDescriptorParserExt.java
===================================================================
---
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/DeploymentDescriptorParserExt.java 2007-10-23
11:39:27 UTC (rev 4862)
+++
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/DeploymentDescriptorParserExt.java 2007-10-23
14:22:45 UTC (rev 4863)
@@ -75,9 +75,7 @@
import com.sun.xml.ws.util.xml.XmlUtil;
/**
- * A copy of DeploymentDescriptorParser that externalizes
- *
- * {@link createInvoker(Class)}
+ * A copy of DeploymentDescriptorParser
*
*
* @see com.sun.xml.ws.transport.http.servlet.WSServletContextListener
@@ -94,6 +92,8 @@
private final ResourceLoader loader;
private final AdapterFactory<A> adapterFactory;
+ private static final org.jboss.logging.Logger log =
org.jboss.logging.Logger.getLogger(DeploymentDescriptorParserExt.class);
+
/**
* Endpoint names that are declared.
* Used to catch double definitions.
@@ -123,8 +123,22 @@
this.container = container;
this.adapterFactory = adapterFactory;
- collectDocs("/WEB-INF/wsdl/");
- logger.fine("war metadata=" + docs);
+ // toggle EJB and WEB deployments
+ String resourcePath = "/META-INF/";
+ try
+ {
+ loader.getResource(resourcePath);
+ log.warn("bypass collectDocs(), it doesnt work for EJB endpoints");
+ }
+ catch (MalformedURLException e)
+ {
+ resourcePath = "/WEB-INF/";
+ log.debug("Collecting docs from " + resourcePath);
+
+ collectDocs(resourcePath+"wsdl/");
+ logger.fine("metadata=" + docs);
+ }
+
}
/**
@@ -393,11 +407,11 @@
if (wsdlFile != null)
{
- if (!wsdlFile.startsWith(JAXWS_WSDL_DD_DIR))
+ /*if (!wsdlFile.startsWith(JAXWS_WSDL_DD_DIR))
{
logger.warning("Ignoring wrong wsdl=" + wsdlFile + ". It
should start with " + JAXWS_WSDL_DD_DIR + ". Going to generate and publish a new
WSDL.");
return null;
- }
+ }*/
URL wsdl;
try
@@ -413,6 +427,10 @@
{
throw new
LocatableWebServiceException(ServerMessages.RUNTIME_PARSER_WSDL_NOT_FOUND(wsdlFile),
xsr);
}
+
+ // bypass the docs init
+ docs.put(wsdl.toExternalForm(), SDDocumentSource.create(wsdl));
+
SDDocumentSource docInfo = docs.get(wsdl.toExternalForm());
assert docInfo != null;
return docInfo;
Modified:
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/SunJaxwsDeploymentAspect.java
===================================================================
---
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/SunJaxwsDeploymentAspect.java 2007-10-23
11:39:27 UTC (rev 4862)
+++
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/SunJaxwsDeploymentAspect.java 2007-10-23
14:22:45 UTC (rev 4863)
@@ -28,6 +28,7 @@
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.stack.sunri.metadata.sunjaxws.DDEndpoint;
import org.jboss.wsf.stack.sunri.metadata.sunjaxws.DDEndpoints;
+import org.jboss.wsf.stack.sunri.metadata.RuntimeModelDeploymentAspect;
import javax.xml.ws.BindingType;
import javax.xml.ws.soap.SOAPBinding;
@@ -81,7 +82,7 @@
contextParams = new HashMap<String, String>();
dep.setProperty(propKey, contextParams);
}
- contextParams.put(WSServletContextListenerJBWS.PARAM_SUN_JAXWS_URL,
dd.createFileURL().toExternalForm());
+ contextParams.put(RuntimeModelDeploymentAspect.PARAM_SUN_JAXWS_URL,
dd.createFileURL().toExternalForm());
}
}
Deleted:
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/WSServletContextListenerExt.java
===================================================================
---
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/WSServletContextListenerExt.java 2007-10-23
11:39:27 UTC (rev 4862)
+++
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/WSServletContextListenerExt.java 2007-10-23
14:22:45 UTC (rev 4863)
@@ -1,189 +0,0 @@
-/*
- * 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.sunri;
-
-// $Id$
-
-import com.sun.istack.NotNull;
-import com.sun.xml.ws.api.server.BoundEndpoint;
-import com.sun.xml.ws.api.server.Container;
-import com.sun.xml.ws.api.server.Module;
-import com.sun.xml.ws.api.server.ResourceInjector;
-import com.sun.xml.ws.resources.WsservletMessages;
-import com.sun.xml.ws.transport.http.DeploymentDescriptorParser.AdapterFactory;
-import com.sun.xml.ws.transport.http.servlet.ServletAdapter;
-import com.sun.xml.ws.transport.http.servlet.ServletAdapterList;
-import com.sun.xml.ws.transport.http.servlet.WSServlet;
-import com.sun.xml.ws.transport.http.servlet.WSServletDelegate;
-
-import javax.servlet.*;
-import javax.xml.ws.WebServiceException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * A copy of WSServletContextListener that externalizes
- *
- * getDDUrlFromResourceLoader()
- * createDeploymentDescriptorParser()
- *
- * @author WS Development Team
- * @author Thomas.Diesler(a)jboss.org
- * @since 10-May-2007
- */
-public class WSServletContextListenerExt implements ServletContextAttributeListener,
ServletContextListener
-{
- private WSServletDelegate delegate;
-
- public void attributeAdded(ServletContextAttributeEvent event)
- {
- }
-
- public void attributeRemoved(ServletContextAttributeEvent event)
- {
- }
-
- public void attributeReplaced(ServletContextAttributeEvent event)
- {
- }
-
- public void contextInitialized(ServletContextEvent event)
- {
- if (logger.isLoggable(Level.INFO))
- {
- logger.info(WsservletMessages.LISTENER_INFO_INITIALIZE());
- }
- ServletContext context = event.getServletContext();
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- if (classLoader == null)
- {
- classLoader = getClass().getClassLoader();
- }
-
- ServletContainer container = new ServletContainer(context);
- try
- {
- ServletResourceLoader resourceLoader = new ServletResourceLoader(context);
- ServletAdapterList adapterList = new ServletAdapterList();
-
- // Parse the descriptor file and build endpoint infos
- DeploymentDescriptorParserExt<ServletAdapter> parser =
createDeploymentDescriptorParser(classLoader, container, resourceLoader, adapterList);
-
- URL sunJaxWsXml = getDeploymentDescriptorURL(context);
- List<ServletAdapter> adapters = parser.parse(sunJaxWsXml.toExternalForm(),
sunJaxWsXml.openStream());
-
- delegate = new WSServletDelegate(adapters, context);
-
- context.setAttribute(WSServlet.JAXWS_RI_RUNTIME_INFO, delegate);
- }
- catch (Throwable e)
- {
- logger.log(Level.SEVERE, WsservletMessages.LISTENER_PARSING_FAILED(e), e);
- context.removeAttribute(WSServlet.JAXWS_RI_RUNTIME_INFO);
- throw new WebServiceException("listener.parsingFailed", e);
- }
- }
-
- public void contextDestroyed(ServletContextEvent event)
- {
- if (delegate != null)
- { // the deployment might have failed.
- delegate.destroy();
- }
-
- if (logger.isLoggable(Level.INFO))
- {
- logger.info(WsservletMessages.LISTENER_INFO_DESTROY());
- }
- }
-
- /**
- * Externalized for integration
- */
- protected DeploymentDescriptorParserExt<ServletAdapter>
createDeploymentDescriptorParser(ClassLoader classLoader, ServletContainer container,
- ServletResourceLoader resourceLoader, AdapterFactory<ServletAdapter>
adapterList) throws MalformedURLException
- {
- DeploymentDescriptorParserExt<ServletAdapter> parser = new
DeploymentDescriptorParserExt<ServletAdapter>(classLoader, resourceLoader,
container, adapterList);
- return parser;
- }
-
- /**
- * Externalized for integration
- */
- protected URL getDeploymentDescriptorURL(ServletContext context) throws
MalformedURLException
- {
- URL sunJaxWsXml = context.getResource(JAXWS_RI_RUNTIME);
- return sunJaxWsXml;
- }
-
- /**
- * Provides access to {@link ServletContext} via {@link Container}. Pipes
- * can get ServletContext from Container and use it to load some resources.
- */
- static class ServletContainer extends Container
- {
- private final ServletContext servletContext;
-
- private final Module module = new Module()
- {
- private final List<BoundEndpoint> endpoints = new
ArrayList<BoundEndpoint>();
-
- public @NotNull
- List<BoundEndpoint> getBoundEndpoints()
- {
- return endpoints;
- }
- };
-
- ServletContainer(ServletContext servletContext)
- {
- this.servletContext = servletContext;
- }
-
- public <T> T getSPI(Class<T> spiType)
- {
- if (spiType == ServletContext.class)
- {
- return (T)servletContext;
- }
- else if (spiType == Module.class)
- {
- return spiType.cast(module);
- }
- else if(spiType == ResourceInjector.class)
- {
- return (T)ResourceInjector.STANDALONE;
- }
-
- logger.log(Level.WARNING, "Unable to resolve SPI for type: " +
spiType);
- return null;
- }
- }
-
- protected static final String JAXWS_RI_RUNTIME = "/WEB-INF/sun-jaxws.xml";
-
- private static final Logger logger =
Logger.getLogger(com.sun.xml.ws.util.Constants.LoggingDomain + ".server.http");
-}
Deleted:
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/WSServletContextListenerJBWS.java
===================================================================
---
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/WSServletContextListenerJBWS.java 2007-10-23
11:39:27 UTC (rev 4862)
+++
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/WSServletContextListenerJBWS.java 2007-10-23
14:22:45 UTC (rev 4863)
@@ -1,81 +0,0 @@
-/*
- * 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.sunri;
-
-// $Id$
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import javax.servlet.ServletContext;
-import javax.xml.ws.WebServiceException;
-
-import com.sun.xml.ws.resources.WsservletMessages;
-import com.sun.xml.ws.transport.http.HttpAdapter;
-import com.sun.xml.ws.transport.http.DeploymentDescriptorParser.AdapterFactory;
-import com.sun.xml.ws.transport.http.servlet.ServletAdapter;
-
-/**
- * Parses {@code sun-jaxws.xml} and sets up
- * {@link HttpAdapter}s for all deployed endpoints.
- *
- * <p>
- * This code is the entry point at the server side.
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 18-May-2007
- */
-public class WSServletContextListenerJBWS extends WSServletContextListenerExt
-{
- public static final String PARAM_SUN_JAXWS_URL = "jbossws-sun-jaxws-url";
-
- /**
- * Fall back to the 'jbossws-sun-jaxws-url' init parameter for the URL
location
- * of sun-jaxws.xml
- */
- @Override
- protected URL getDeploymentDescriptorURL(ServletContext context) throws
MalformedURLException
- {
- URL sunJaxWsXml = super.getDeploymentDescriptorURL(context);
- if (sunJaxWsXml == null)
- {
- String urlStr = context.getInitParameter(PARAM_SUN_JAXWS_URL);
- if (urlStr != null && urlStr.length() > 0)
- sunJaxWsXml = new URL(urlStr);
- }
- if (sunJaxWsXml == null)
- throw new
WebServiceException(WsservletMessages.NO_SUNJAXWS_XML(JAXWS_RI_RUNTIME));
-
- return sunJaxWsXml;
- }
-
- /**
- * Externalized for integration
- */
- @Override
- protected DeploymentDescriptorParserExt<ServletAdapter>
createDeploymentDescriptorParser(ClassLoader classLoader, ServletContainer container,
- ServletResourceLoader resourceLoader, AdapterFactory<ServletAdapter>
adapterList) throws MalformedURLException
- {
- DeploymentDescriptorParserExt<ServletAdapter> parser = new
DeploymentDescriptorParserJBWS<ServletAdapter>(classLoader, resourceLoader,
container, adapterList);
- return parser;
- }
-}
Modified:
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/metadata/RuntimeModelDeploymentAspect.java
===================================================================
---
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/metadata/RuntimeModelDeploymentAspect.java 2007-10-23
11:39:27 UTC (rev 4862)
+++
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/metadata/RuntimeModelDeploymentAspect.java 2007-10-23
14:22:45 UTC (rev 4863)
@@ -37,7 +37,6 @@
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
import org.jboss.wsf.stack.sunri.DeploymentDescriptorParserExt;
-import org.jboss.wsf.stack.sunri.WSServletContextListenerJBWS;
import javax.xml.ws.WebServiceException;
import java.io.IOException;
@@ -57,11 +56,12 @@
*/
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 create(Deployment deployment)
{
ClassLoader runtimeLoader = deployment.getRuntimeClassLoader();
@@ -114,7 +114,6 @@
Thread.currentThread().setContextClassLoader(origClassLoader);
}
-
}
private URL getDDUrlFromContext(Deployment deployment)
@@ -122,7 +121,7 @@
{
HashMap<String, String> contextProperties =
(HashMap<String,
String>)deployment.getProperty("org.jboss.ws.webapp.ContextParameterMap");
- URL sunJaxWsXml = new
URL(contextProperties.get(WSServletContextListenerJBWS.PARAM_SUN_JAXWS_URL));
+ URL sunJaxWsXml = new URL(contextProperties.get(PARAM_SUN_JAXWS_URL));
return sunJaxWsXml;
}
Modified:
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/metadata/VFSResourceLoader.java
===================================================================
---
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/metadata/VFSResourceLoader.java 2007-10-23
11:39:27 UTC (rev 4862)
+++
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/metadata/VFSResourceLoader.java 2007-10-23
14:22:45 UTC (rev 4863)
@@ -31,6 +31,11 @@
import java.net.URL;
import java.util.HashSet;
import java.util.Set;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.jar.JarFile;
+import java.util.jar.JarEntry;
/**
* @author Heiko.Braun(a)jboss.com
@@ -54,7 +59,7 @@
{
if(path.startsWith("/"))
path = path.substring(1, path.length());
-
+
return vfs.findChild(path).toURL();
}
catch (IOException e)
@@ -84,14 +89,43 @@
try
{
URL rootUrl = getResource(path);
- File root = new File( rootUrl.toURI() );
-
- if(root.exists()) // in memory VFS roots?
+ if(rootUrl.getProtocol().equals("jar"))
{
- File[] files = root.listFiles();
- if (files == null) {
- return null;
- }
+ /*String urlString = rootUrl.toExternalForm();
+ String jarRoot = urlString.substring(4,
urlString.indexOf("jar!")+3);
+
+ File jar = new File(jarRoot);
+ assert jar.exists();
+ JarFile jarFile = new JarFile(jar);
+
+ List<String> jarResources = getJARResources(jarFile, path);
+
+ resources.addAll(jarResources);*/
+ log.warn("Cannot collect resourcePaths from EJB jar");
+ }
+ else
+ {
+ File root = new File( rootUrl.toURI() );
+ List<String> fileResources = getFileResources(root, path);
+ resources.addAll(fileResources);
+ }
+ }
+ catch (Exception e)
+ {
+ log.error("Failed to read resource paths from '"+path+"':
", e);
+ }
+
+ return resources;
+ }
+
+ private static List<String> getFileResources(File root, String path)
+ {
+ List<String> resources = new ArrayList<String>();
+
+ if(root.exists())
+ {
+ File[] files = root.listFiles();
+ if (files != null) {
for( File f : files) {
if(f.isDirectory()) {
resources.add(path+f.getName()+'/');
@@ -100,12 +134,25 @@
}
}
}
+ }
+ return resources;
+ }
+ private static List<String> getJARResources(JarFile jarFile, String path) {
+ List<String> resources = new ArrayList<String>();
+
+ Enumeration entries = jarFile.entries();
+ while (entries.hasMoreElements()) {
+ JarEntry entry = (JarEntry) entries.nextElement();
+ String entryName = entry.getName();
+
+ if (entryName.matches(".*?\\.xml$")
+ || entryName.matches(".*?\\.wsdl$")
+ || entryName.matches(".*?\\.xsd$"))
+ {
+ resources.add(entryName);
+ }
}
- catch (Exception e)
- {
- log.error("Failed to read resource paths", e);
- }
return resources;
}