[jboss-cvs] JBossAS SVN: r101937 - in projects/metadata/common/trunk: src/main/java/org/jboss/metadata/serviceref and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Mar 5 04:38:55 EST 2010
Author: alessio.soldano at jboss.com
Date: 2010-03-05 04:38:54 -0500 (Fri, 05 Mar 2010)
New Revision: 101937
Modified:
projects/metadata/common/trunk/pom.xml
projects/metadata/common/trunk/src/main/java/org/jboss/metadata/serviceref/VirtualFileAdaptor.java
Log:
[JBWS-2948][JBWS-2021] Moving to recent jbossws-spi dependency, fixing VirtualFileAdaptor and making it implement WritableUnifiedVirtualFile
Modified: projects/metadata/common/trunk/pom.xml
===================================================================
--- projects/metadata/common/trunk/pom.xml 2010-03-05 09:26:59 UTC (rev 101936)
+++ projects/metadata/common/trunk/pom.xml 2010-03-05 09:38:54 UTC (rev 101937)
@@ -153,7 +153,7 @@
<dependency>
<groupId>org.jboss.ws</groupId>
<artifactId>jbossws-spi</artifactId>
- <version>1.0.6.GA</version>
+ <version>1.3.0.Beta4</version>
</dependency>
<dependency>
@@ -218,4 +218,4 @@
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
Modified: projects/metadata/common/trunk/src/main/java/org/jboss/metadata/serviceref/VirtualFileAdaptor.java
===================================================================
--- projects/metadata/common/trunk/src/main/java/org/jboss/metadata/serviceref/VirtualFileAdaptor.java 2010-03-05 09:26:59 UTC (rev 101936)
+++ projects/metadata/common/trunk/src/main/java/org/jboss/metadata/serviceref/VirtualFileAdaptor.java 2010-03-05 09:38:54 UTC (rev 101937)
@@ -22,17 +22,24 @@
package org.jboss.metadata.serviceref;
import java.io.IOException;
+import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.ObjectStreamField;
+import java.io.OutputStream;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.LinkedList;
import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+import java.util.jar.JarOutputStream;
import org.jboss.vfs.VFS;
+import org.jboss.vfs.VFSUtils;
import org.jboss.vfs.VirtualFile;
import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
+import org.jboss.wsf.spi.deployment.WritableUnifiedVirtualFile;
// $Id: VirtualFileAdaptor.java 4049 2007-08-01 11:26:30Z thomas.diesler at jboss.com $
@@ -41,9 +48,10 @@
*
* @author Thomas.Diesler at jboss.org
* @author Ales.Justin at jboss.org
+ * @author alessio.soldano at jboss.com
* @since 05-May-2006
*/
-public class VirtualFileAdaptor implements UnifiedVirtualFile
+public class VirtualFileAdaptor implements WritableUnifiedVirtualFile
{
private static final long serialVersionUID = -4509594124653184347L;
@@ -96,10 +104,19 @@
throw new IOException("Unable to get Virtualfile from URL: " + rootUrl, e);
}
file = root.getChild(path);
+
+ if (!file.exists())
+ {
+ throw new IOException("VirtualFile " + file + " does not exist");
+ }
+ else if (root.getPathName().equals(root.getPhysicalFile().getAbsolutePath()) && file.getPathName().equals(file.getPhysicalFile().getAbsolutePath()))
+ {
+ throw new IOException("VirtualFile " + file + " is not mounted");
+ }
}
return file;
}
-
+
public UnifiedVirtualFile findChild(String child) throws IOException
{
final VirtualFile virtualFile = getFile();
@@ -120,18 +137,58 @@
return null;
}
}
-
+
+ @Override
+ public void writeContent(OutputStream bos) throws IOException
+ {
+ writeContent(bos, null);
+ }
+
+ @Override
+ public void writeContent(OutputStream bos, NameFilter filter) throws IOException
+ {
+ InputStream is = null;
+ try
+ {
+ is = getFile().openStream();
+ if (is instanceof JarInputStream)
+ {
+ JarInputStream jis = (JarInputStream)is;
+ JarOutputStream os = new JarOutputStream(bos);
+ JarEntry je = null;
+ while ((je = jis.getNextJarEntry()) != null)
+ {
+ if (filter != null && filter.accept(je.getName()))
+ {
+ os.putNextEntry(je);
+ VFSUtils.copyStream(jis, os);
+ }
+ }
+ VFSUtils.safeClose(os);
+ }
+ else
+ {
+ VFSUtils.copyStream(is, bos);
+ }
+ }
+ finally
+ {
+ VFSUtils.safeClose(is);
+ }
+ }
+
private void writeObject(ObjectOutputStream out) throws IOException, URISyntaxException
{
+ VirtualFile file = getFile();
URL url = rootUrl;
if (url == null)
{
- VirtualFile parentFile = getFile().getParent();
+ VirtualFile parentFile = file.getParent();
url = parentFile != null ? parentFile.toURL() : null;
}
String pathName = path;
if (pathName == null)
- pathName = getFile().getName();
+ pathName = file.getName();
ObjectOutputStream.PutField fields = out.putFields();
fields.put("rootUrl", url);
More information about the jboss-cvs-commits
mailing list