Author: alessio.soldano(a)jboss.com
Date: 2009-11-19 07:06:59 -0500 (Thu, 19 Nov 2009)
New Revision: 11131
Added:
framework/trunk/src/main/java/org/jboss/wsf/framework/deployment/ResourceResolverImpl.java
Modified:
framework/trunk/pom.xml
framework/trunk/src/main/java/org/jboss/wsf/framework/deployment/ArchiveDeploymentImpl.java
Log:
[JBWS-2828] Providing implementation for ResourceResolver and moving to jbossws-spi
snapshot
Modified: framework/trunk/pom.xml
===================================================================
--- framework/trunk/pom.xml 2009-11-19 12:06:04 UTC (rev 11130)
+++ framework/trunk/pom.xml 2009-11-19 12:06:59 UTC (rev 11131)
@@ -28,7 +28,7 @@
<jaxws.api.version>2.1</jaxws.api.version>
<jboss.web.version>2.1.3.GA</jboss.web.version>
<jbossws.common.version>1.2.1.GA</jbossws.common.version>
- <jbossws.spi.version>1.2.1.GA</jbossws.spi.version>
+ <jbossws.spi.version>1.2.2-SNAPSHOT</jbossws.spi.version>
<jbossxb.version>2.0.1.GA</jbossxb.version>
</properties>
Modified:
framework/trunk/src/main/java/org/jboss/wsf/framework/deployment/ArchiveDeploymentImpl.java
===================================================================
---
framework/trunk/src/main/java/org/jboss/wsf/framework/deployment/ArchiveDeploymentImpl.java 2009-11-19
12:06:04 UTC (rev 11130)
+++
framework/trunk/src/main/java/org/jboss/wsf/framework/deployment/ArchiveDeploymentImpl.java 2009-11-19
12:06:59 UTC (rev 11131)
@@ -22,13 +22,12 @@
package org.jboss.wsf.framework.deployment;
import java.io.IOException;
-import java.net.MalformedURLException;
import java.net.URL;
-import java.util.Iterator;
import java.util.List;
import org.jboss.logging.Logger;
import org.jboss.wsf.spi.deployment.ArchiveDeployment;
+import org.jboss.wsf.spi.deployment.ResourceResolver;
import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
/**
@@ -81,81 +80,10 @@
return name;
}
+ @Deprecated
public URL getMetaDataFileURL(String resourcePath) throws IOException
{
- URL resourceURL = null;
- if (resourcePath != null && resourcePath.length() > 0)
- {
- if (resourcePath.startsWith("/"))
- resourcePath = resourcePath.substring(1);
-
- try
- {
- // assign an absolute URL
- resourceURL = new URL(resourcePath);
- }
- catch (MalformedURLException ex)
- {
- // ignore
- }
-
- if (resourceURL == null && getRootFile() != null)
- {
- try
- {
- UnifiedVirtualFile vfResource = getRootFile().findChild(resourcePath);
- resourceURL = vfResource.toURL();
- }
- catch (IOException e)
- {
- if (metadataFiles == null || metadataFiles.isEmpty())
- {
- throw e;
- }
- else
- {
- if (log.isDebugEnabled())
- log.debug("Cannot get " + resourcePath + " from root
file, trying with additional metadata files", e);
- }
-
- }
- }
- //scan additional metadata files (for instance originally attached to a
VFSDeploymentUnit)
- if (resourceURL == null && metadataFiles != null &&
!metadataFiles.isEmpty())
- {
- UnifiedVirtualFile vfResource = null;
- for (Iterator<UnifiedVirtualFile> it = getMetadataFiles().iterator();
it.hasNext() && vfResource == null;)
- {
- UnifiedVirtualFile uvf = it.next();
- URL wsdlUrl = uvf.toURL();
- String wsdlPath = wsdlUrl.getPath();
- if (wsdlPath.startsWith("/"))
- wsdlPath = wsdlPath.substring(1);
- if (resourcePath.equals(wsdlPath))
- {
- vfResource = uvf;
- }
- else
- {
- try
- {
- vfResource = uvf.findChild(resourcePath);
- }
- catch (IOException e)
- {
- if (log.isDebugEnabled())
- log.debug("Cannot get " + resourcePath + " from
" + uvf, e);
- }
- }
- }
- if (vfResource == null)
- throw new IOException("Could not find " + resourcePath + "
in the additional metadatafiles!");
-
- resourceURL = vfResource.toURL();
- }
- }
-
- return resourceURL;
+ return getResourceResolver().resolve(resourcePath);
}
public List<UnifiedVirtualFile> getMetadataFiles()
@@ -167,4 +95,9 @@
{
this.metadataFiles = metadataFiles;
}
+
+ public ResourceResolver getResourceResolver()
+ {
+ return new ResourceResolverImpl(rootFile, metadataFiles);
+ }
}
Added:
framework/trunk/src/main/java/org/jboss/wsf/framework/deployment/ResourceResolverImpl.java
===================================================================
---
framework/trunk/src/main/java/org/jboss/wsf/framework/deployment/ResourceResolverImpl.java
(rev 0)
+++
framework/trunk/src/main/java/org/jboss/wsf/framework/deployment/ResourceResolverImpl.java 2009-11-19
12:06:59 UTC (rev 11131)
@@ -0,0 +1,129 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.deployment;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.deployment.ResourceResolver;
+import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
+
+/**
+ * A resource resolver implementation using unified virtual files
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 19-Nov-2009
+ *
+ */
+public class ResourceResolverImpl implements ResourceResolver
+{
+ private static Logger log = Logger.getLogger(ResourceResolverImpl.class);
+
+ private UnifiedVirtualFile rootFile;
+ private Collection<UnifiedVirtualFile> metadataFiles;
+
+ public ResourceResolverImpl(UnifiedVirtualFile rootFile,
Collection<UnifiedVirtualFile> metadataFiles)
+ {
+ this.rootFile = rootFile;
+ this.metadataFiles = metadataFiles;
+ }
+
+ public URL resolve(String resourcePath) throws IOException
+ {
+ URL resourceURL = null;
+ if (resourcePath != null && resourcePath.length() > 0)
+ {
+ if (resourcePath.startsWith("/"))
+ resourcePath = resourcePath.substring(1);
+
+ try
+ {
+ // assign an absolute URL
+ resourceURL = new URL(resourcePath);
+ }
+ catch (MalformedURLException ex)
+ {
+ // ignore
+ }
+
+ if (resourceURL == null && rootFile != null)
+ {
+ try
+ {
+ UnifiedVirtualFile vfResource = rootFile.findChild(resourcePath);
+ resourceURL = vfResource.toURL();
+ }
+ catch (IOException e)
+ {
+ if (metadataFiles == null || metadataFiles.isEmpty())
+ {
+ throw e;
+ }
+ else
+ {
+ if (log.isDebugEnabled())
+ log.debug("Cannot get " + resourcePath + " from root
file, trying with additional metadata files", e);
+ }
+ }
+ }
+ //scan additional metadata files (for instance originally attached to a
VFSDeploymentUnit)
+ if (resourceURL == null && metadataFiles != null &&
!metadataFiles.isEmpty())
+ {
+ UnifiedVirtualFile vfResource = null;
+ for (Iterator<UnifiedVirtualFile> it = metadataFiles.iterator();
it.hasNext() && vfResource == null;)
+ {
+ UnifiedVirtualFile uvf = it.next();
+ URL wsdlUrl = uvf.toURL();
+ String wsdlPath = wsdlUrl.getPath();
+ if (wsdlPath.startsWith("/"))
+ wsdlPath = wsdlPath.substring(1);
+ if (resourcePath.equals(wsdlPath))
+ {
+ vfResource = uvf;
+ }
+ else
+ {
+ try
+ {
+ vfResource = uvf.findChild(resourcePath);
+ }
+ catch (IOException e)
+ {
+ if (log.isDebugEnabled())
+ log.debug("Cannot get " + resourcePath + " from
" + uvf, e);
+ }
+ }
+ }
+ if (vfResource == null)
+ throw new IOException("Could not find " + resourcePath + "
in the additional metadatafiles!");
+
+ resourceURL = vfResource.toURL();
+ }
+ }
+ return resourceURL;
+ }
+
+}
Property changes on:
framework/trunk/src/main/java/org/jboss/wsf/framework/deployment/ResourceResolverImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF