[jboss-cvs] JBossAS SVN: r74631 - projects/metadata/trunk/src/main/java/org/jboss/metadata/serviceref.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jun 16 13:10:54 EDT 2008
Author: alesj
Date: 2008-06-16 13:10:54 -0400 (Mon, 16 Jun 2008)
New Revision: 74631
Modified:
projects/metadata/trunk/src/main/java/org/jboss/metadata/serviceref/VirtualFileAdaptor.java
Log:
Add URL ctor.
Remove unneccesary .. and . stripping.
Modified: projects/metadata/trunk/src/main/java/org/jboss/metadata/serviceref/VirtualFileAdaptor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/serviceref/VirtualFileAdaptor.java 2008-06-16 17:02:01 UTC (rev 74630)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/serviceref/VirtualFileAdaptor.java 2008-06-16 17:10:54 UTC (rev 74631)
@@ -21,45 +21,60 @@
*/
package org.jboss.metadata.serviceref;
+import java.io.IOException;
+import java.net.URL;
+
+import org.jboss.virtual.VFS;
import org.jboss.virtual.VirtualFile;
import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
-import java.io.IOException;
-import java.net.URL;
-
// $Id: VirtualFileAdaptor.java 4049 2007-08-01 11:26:30Z thomas.diesler at jboss.com $
/**
* A JBoss50 VirtualFile adaptor
*
* @author Thomas.Diesler at jboss.org
+ * @author Ales.Justin at jboss.org
* @since 05-May-2006
*/
public class VirtualFileAdaptor implements UnifiedVirtualFile
{
private static final long serialVersionUID = 6547394037548338042L;
- private VirtualFile root;
+ private URL url;
+ private transient VirtualFile root;
+ @Deprecated
public VirtualFileAdaptor(VirtualFile root)
{
this.root = root;
}
+ public VirtualFileAdaptor(URL url)
+ {
+ if (url == null)
+ throw new IllegalArgumentException("Null url");
+ this.url = url;
+ }
+
+ /**
+ * Get the virtual file root.
+ * Create file from url if it doesn't exist yet.
+ *
+ * @return virtual file root
+ * @throws IOException for any error
+ */
+ protected VirtualFile getRoot() throws IOException
+ {
+ if (root == null)
+ root = VFS.getRoot(url);
+ return root;
+ }
+
+ @SuppressWarnings("deprecation")
public UnifiedVirtualFile findChild(String child) throws IOException
{
- VirtualFile vf = root;
- while (child.startsWith("./"))
- {
- child = child.substring(2);
- }
- while (child.startsWith("../"))
- {
- child = child.substring(3);
- vf = vf.getParent();
- }
-
- vf = vf.findChild(child);
+ VirtualFile vf = getRoot().findChild(child);
return new VirtualFileAdaptor(vf);
}
@@ -67,7 +82,9 @@
{
try
{
- return root.toURL();
+ if (url == null)
+ url = getRoot().toURL();
+ return url;
}
catch (Exception e)
{
More information about the jboss-cvs-commits
mailing list