Author: alessio.soldano(a)jboss.com
Date: 2010-05-07 07:20:29 -0400 (Fri, 07 May 2010)
New Revision: 12187
Added:
framework/branches/jbossws-framework-3.1.2/src/main/java/org/jboss/wsf/framework/deployment/ResourceResolverImpl.java
Modified:
framework/branches/jbossws-framework-3.1.2/src/main/java/org/jboss/wsf/framework/deployment/ArchiveDeploymentImpl.java
Log:
[JBPAPP-4124] Move to Apache CXF 2.2.5 (merge revision 11131)
Modified:
framework/branches/jbossws-framework-3.1.2/src/main/java/org/jboss/wsf/framework/deployment/ArchiveDeploymentImpl.java
===================================================================
---
framework/branches/jbossws-framework-3.1.2/src/main/java/org/jboss/wsf/framework/deployment/ArchiveDeploymentImpl.java 2010-05-07
11:20:14 UTC (rev 12186)
+++
framework/branches/jbossws-framework-3.1.2/src/main/java/org/jboss/wsf/framework/deployment/ArchiveDeploymentImpl.java 2010-05-07
11:20:29 UTC (rev 12187)
@@ -22,12 +22,12 @@
package org.jboss.wsf.framework.deployment;
import java.io.IOException;
-import java.net.MalformedURLException;
import java.net.URL;
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;
/**
@@ -80,73 +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
- {
- 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 (UnifiedVirtualFile metadataFile : getMetadataFiles())
- {
- try
- {
- UnifiedVirtualFile child = metadataFile.findChild(resourcePath);
- if (child != null)
- {
- vfResource = child;
- break;
- }
- }
- catch (IOException e)
- {
- log.debug("Cannot get " + resourcePath + " from " +
metadataFile, 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()
@@ -158,4 +95,9 @@
{
this.metadataFiles = metadataFiles;
}
+
+ public ResourceResolver getResourceResolver()
+ {
+ return new ResourceResolverImpl(rootFile, metadataFiles);
+ }
}
Copied:
framework/branches/jbossws-framework-3.1.2/src/main/java/org/jboss/wsf/framework/deployment/ResourceResolverImpl.java
(from rev 11131,
framework/trunk/src/main/java/org/jboss/wsf/framework/deployment/ResourceResolverImpl.java)
===================================================================
---
framework/branches/jbossws-framework-3.1.2/src/main/java/org/jboss/wsf/framework/deployment/ResourceResolverImpl.java
(rev 0)
+++
framework/branches/jbossws-framework-3.1.2/src/main/java/org/jboss/wsf/framework/deployment/ResourceResolverImpl.java 2010-05-07
11:20:29 UTC (rev 12187)
@@ -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;
+ }
+
+}