Author: heiko.braun(a)jboss.com
Date: 2007-10-23 07:33:35 -0400 (Tue, 23 Oct 2007)
New Revision: 4861
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/RequestHandlerImpl.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:
Fix resource and classloading
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:21:04 UTC (rev 4860)
+++
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/DeploymentDescriptorParserExt.java 2007-10-23
11:33:35 UTC (rev 4861)
@@ -402,7 +402,8 @@
URL wsdl;
try
{
- wsdl = loader.getResource('/' + wsdlFile);
+ //wsdl = loader.getResource('/' + wsdlFile);
+ wsdl = loader.getResource(wsdlFile);
}
catch (MalformedURLException e)
{
Modified:
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/RequestHandlerImpl.java
===================================================================
---
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/RequestHandlerImpl.java 2007-10-23
11:21:04 UTC (rev 4860)
+++
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/RequestHandlerImpl.java 2007-10-23
11:33:35 UTC (rev 4861)
@@ -96,27 +96,31 @@
}
else
{
- res.setStatus(405);
- res.setContentType("text/plain");
- Writer out = res.getWriter();
- out.write("HTTP GET not supported");
- out.close();
+ sendResponse(405, "HTTP GET not supported", res);
}
}
else
{
- res.setStatus(404);
- res.setContentType("text/plain");
- Writer out = res.getWriter();
- out.write("Not found");
- out.close();
+ sendResponse(404, "Not found", res);
}
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
logger.log(Level.SEVERE, e.getMessage(), e);
throw new ServletException(e.getMessage());
}
}
+ private static void sendResponse(int status, String message, HttpServletResponse res)
+ throws IOException
+ {
+ res.setStatus(status);
+ res.setContentType("text/plain");
+ Writer out = res.getWriter();
+ out.write(message);
+ out.close();
+ }
+
private void doPost(ServletAdapter target, ServletContext context, HttpServletRequest
req, HttpServletResponse res)
{
try
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:21:04 UTC (rev 4860)
+++
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/metadata/RuntimeModelDeploymentAspect.java 2007-10-23
11:33:35 UTC (rev 4861)
@@ -50,7 +50,9 @@
import java.util.logging.Logger;
/**
- * Creates a METRO runtime model and associates it with the deployment.
+ * Creates a METRO runtime model and associates it with the deployment.
+ * Doing so requires a valid runtime loader present, that will act as a temporary
+ * thread local classloader.
*
* @author Heiko.Braun(a)jboss.com
* @version $Revision$
@@ -68,9 +70,14 @@
if(null == runtimeLoader)
throw new IllegalArgumentException("Null runtimeLoader");
+ ClassLoader origClassLoader = Thread.currentThread().getContextClassLoader();
JBossWSContainer container = new JBossWSContainer();
+
try
{
+ // Metro uses the thread contetx classloader in several places
+ Thread.currentThread().setContextClassLoader(runtimeLoader);
+
ResourceLoaderAdapter resourceLoaderAdapter = new
ResourceLoaderAdapter(runtimeLoader);
ResourceLoader resourceLoader = new VFSResourceLoader(resourceLoaderAdapter);
@@ -85,12 +92,7 @@
URL sunJaxWsXml = getDDUrlFromContext(deployment);
List<ServletAdapter> adapters = parser.parse(sunJaxWsXml.toExternalForm(),
sunJaxWsXml.openStream());
-
- // Created on the fly in SunJaxwsDeploymentAspect
- //DDEndpoints dd = deployment.getAttachment(DDEndpoints.class);
-
- // TODO: the whole matching can be skipped when we use the DD model directly
- // See SunJaxwsDeploymentAspect -> dep.addAttachment(DDEndpoints.class,
dd);
+
for(ServletAdapter adapter : adapters)
{
for(Endpoint ep : deployment.getService().getEndpoints() )
@@ -111,6 +113,9 @@
logger.log(Level.SEVERE, WsservletMessages.LISTENER_PARSING_FAILED(e), e);
throw new WebServiceException("listener.parsingFailed", e);
}
+ finally{
+ Thread.currentThread().setContextClassLoader(origClassLoader);
+ }
}
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:21:04 UTC (rev 4860)
+++
stack/metro/branches/hbraun/src/main/java/org/jboss/wsf/stack/sunri/metadata/VFSResourceLoader.java 2007-10-23
11:33:35 UTC (rev 4861)
@@ -22,15 +22,15 @@
package org.jboss.wsf.stack.sunri.metadata;
import com.sun.xml.ws.transport.http.ResourceLoader;
+import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
import java.net.URL;
-import java.net.MalformedURLException;
+import java.util.HashSet;
import java.util.Set;
-import java.util.HashSet;
-import java.io.IOException;
-import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
-
/**
* @author Heiko.Braun(a)jboss.com
* @version $Revision$
@@ -49,6 +49,9 @@
{
try
{
+ if(path.startsWith("/"))
+ path = path.substring(1, path.length());
+
return vfs.findChild(path).toURL();
}
catch (IOException e)
@@ -59,13 +62,48 @@
public URL getCatalogFile() throws MalformedURLException
{
- System.out.println("!!! getCatalogFile() not implemented");
- return null;
+ URL resource = null;
+ try
+ {
+ resource = getResource("/WEB-INF/jax-ws-catalog.xml");
+ }
+ catch (MalformedURLException e)
+ {
+ // ingore
+ }
+ return resource;
}
public Set<String> getResourcePaths(String path)
{
- System.out.println("!!! getResourcePaths() not implemented");
- return new HashSet<String>();
+ Set<String> resources = new HashSet<String>();
+
+ try
+ {
+ URL rootUrl = getResource(path);
+ File root = new File( rootUrl.toURI() );
+
+ if(root.exists()) // in memory VFS roots?
+ {
+ File[] files = root.listFiles();
+ if (files == null) {
+ return null;
+ }
+ for( File f : files) {
+ if(f.isDirectory()) {
+ resources.add(path+f.getName()+'/');
+ } else {
+ resources.add(path+f.getName());
+ }
+ }
+ }
+
+ }
+ catch (Exception e)
+ {
+ System.out.println("!!! WARN: Failed to read resource path: " +
e.getMessage());
+ }
+
+ return resources;
}
}
Show replies by date