[jboss-cvs] JBossAS SVN: r101772 - in projects/jboss-osgi/projects: runtime/framework/trunk/core and 13 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Mar 3 08:09:06 EST 2010
Author: thomas.diesler at jboss.com
Date: 2010-03-03 08:09:03 -0500 (Wed, 03 Mar 2010)
New Revision: 101772
Added:
projects/jboss-osgi/projects/vfs/trunk/api/src/main/java/org/jboss/osgi/vfs/VirtualFileAssembly.java
projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/AssemblyAdaptor21.java
projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/VFSEntryPathsEnumeration.java
projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/VFSFindEntriesEnumeration.java
Removed:
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/VFSEntryPathsEnumeration.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/VFSFindEntriesEnumeration.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/metadata/
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/core/pom.xml
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/AbstractDeployedBundleState.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleContextWrapper.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentAttachmentDeployer.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/launch/OSGiFramework.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/util/URLHelper.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/test/java/org/jboss/test/osgi/FrameworkTest.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/test/java/org/jboss/test/osgi/resolver/AbstractImportExportTest.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTest.java
projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml
projects/jboss-osgi/projects/testing/trunk/pom.xml
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiTest.java
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java
projects/jboss-osgi/projects/vfs/trunk/api/src/main/java/org/jboss/osgi/vfs/AbstractVFS.java
projects/jboss-osgi/projects/vfs/trunk/api/src/main/java/org/jboss/osgi/vfs/VFSAdaptor.java
projects/jboss-osgi/projects/vfs/trunk/api/src/main/java/org/jboss/osgi/vfs/VirtualFile.java
projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/VFSAdaptor21.java
projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/VirtualFileAdaptor21.java
projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSAdaptor30.java
projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VirtualFileAdaptor30.java
Log:
Use VFS abstration in jboss-osgi-testing
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/pom.xml 2010-03-03 11:31:45 UTC (rev 101771)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/pom.xml 2010-03-03 13:09:03 UTC (rev 101772)
@@ -251,6 +251,11 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.jboss.osgi.vfs</groupId>
+ <artifactId>jboss-osgi-vfs21</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-log4j</artifactId>
<scope>test</scope>
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2010-03-03 11:31:45 UTC (rev 101771)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2010-03-03 13:09:03 UTC (rev 101772)
@@ -51,7 +51,7 @@
import org.jboss.osgi.framework.plugins.ServiceManagerPlugin;
import org.jboss.osgi.spi.NotImplementedException;
import org.jboss.osgi.spi.util.ConstantsHelper;
-import org.jboss.virtual.VirtualFile;
+import org.jboss.osgi.vfs.VirtualFile;
import org.osgi.framework.AdminPermission;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/AbstractDeployedBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/AbstractDeployedBundleState.java 2010-03-03 11:31:45 UTC (rev 101771)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/AbstractDeployedBundleState.java 2010-03-03 13:09:03 UTC (rev 101772)
@@ -37,7 +37,7 @@
import org.jboss.osgi.framework.metadata.OSGiMetaData;
import org.jboss.osgi.framework.plugins.PackageAdminPlugin;
import org.jboss.osgi.vfs.AbstractVFS;
-import org.jboss.virtual.VirtualFile;
+import org.jboss.osgi.vfs.VirtualFile;
import org.osgi.framework.AdminPermission;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
@@ -83,7 +83,7 @@
// The framework is expected to preserve the location passed into installBundle(String)
Deployment dep = unit.getAttachment(Deployment.class);
location = (dep != null ? dep.getLocation() : unit.getName());
- rootFile = (dep != null ? (VirtualFile)AbstractVFS.adapt(dep.getRoot()) : ((VFSDeploymentUnit)unit).getRoot());
+ rootFile = (dep != null ? dep.getRoot() : AbstractVFS.adapt(((VFSDeploymentUnit)unit).getRoot()));
bundleId = bundleIDGenerator.incrementAndGet();
@@ -179,26 +179,14 @@
if (noAdminPermission(AdminPermission.RESOURCE))
return null;
- DeploymentUnit unit = getDeploymentUnit();
- if (unit instanceof VFSDeploymentUnit)
+ try
{
- VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit)unit;
- VirtualFile root = vfsDeploymentUnit.getRoot();
- if (path.startsWith("/"))
- path = path.substring(1);
- try
- {
- VirtualFile child = root.getChild(path);
- if (child != null)
- return new VFSEntryPathsEnumeration(root, child);
- }
- catch (IOException e)
- {
- throw new RuntimeException("Error determining entry paths for " + root + " path=" + path);
- }
-
+ return rootFile.getEntryPaths(path);
}
- return null;
+ catch (IOException e)
+ {
+ throw new RuntimeException("Error determining entry paths for " + rootFile + " path=" + path);
+ }
}
@Override
@@ -232,7 +220,7 @@
}
@SuppressWarnings("rawtypes")
- public Enumeration findEntries(String path, String filePattern, boolean recurse)
+ public Enumeration findEntries(String path, String pattern, boolean recurse)
{
if (path == null)
throw new IllegalArgumentException("Null path");
@@ -241,32 +229,16 @@
if (noAdminPermission(AdminPermission.RESOURCE))
return null;
- // [TODO] fragments
resolveBundle();
-
- if (filePattern == null)
- filePattern = "*";
-
- DeploymentUnit unit = getDeploymentUnit();
- if (unit instanceof VFSDeploymentUnit)
+
+ try
{
- VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit)unit;
- VirtualFile root = vfsDeploymentUnit.getRoot();
- if (path.startsWith("/"))
- path = path.substring(1);
- try
- {
- VirtualFile child = root.getChild(path);
- if (child != null)
- return new VFSFindEntriesEnumeration(root, child, filePattern, recurse);
- }
- catch (IOException e)
- {
- throw new RuntimeException("Error finding entries for " + root + " path=" + path + " pattern=" + filePattern + " recurse=" + recurse);
- }
-
+ return rootFile.findEntries(path, pattern, recurse);
}
- return null;
+ catch (IOException e)
+ {
+ throw new RuntimeException("Error finding entries for " + rootFile + " path=" + path + " pattern=" + pattern + " recurse=" + recurse);
+ }
}
/**
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleContextWrapper.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleContextWrapper.java 2010-03-03 11:31:45 UTC (rev 101771)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleContextWrapper.java 2010-03-03 13:09:03 UTC (rev 101772)
@@ -27,7 +27,7 @@
import java.io.InputStream;
import java.util.Dictionary;
-import org.jboss.virtual.VirtualFile;
+import org.jboss.osgi.vfs.VirtualFile;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2010-03-03 11:31:45 UTC (rev 101771)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2010-03-03 13:09:03 UTC (rev 101772)
@@ -74,10 +74,9 @@
import org.jboss.osgi.framework.util.URLHelper;
import org.jboss.osgi.spi.util.BundleInfo;
import org.jboss.osgi.vfs.AbstractVFS;
+import org.jboss.osgi.vfs.VFSUtils;
+import org.jboss.osgi.vfs.VirtualFile;
import org.jboss.util.platform.Java;
-import org.jboss.virtual.VFS;
-import org.jboss.virtual.VFSUtils;
-import org.jboss.virtual.VirtualFile;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleEvent;
@@ -452,7 +451,7 @@
VirtualFile root;
try
{
- root = VFS.getRoot(locationURL);
+ root = AbstractVFS.getChild(locationURL);
}
catch (IOException e)
{
@@ -508,7 +507,7 @@
Deployment dep;
try
{
- BundleInfo info = BundleInfo.createBundleInfo(AbstractVFS.adapt(root), location);
+ BundleInfo info = BundleInfo.createBundleInfo(root, location);
dep = DeploymentFactory.createDeployment(info);
dep.setAutoStart(autoStart);
}
@@ -533,7 +532,7 @@
// Create the deployment and deploy it
try
{
- VirtualFile root = (VirtualFile)AbstractVFS.adapt(dep.getRoot());
+ org.jboss.virtual.VirtualFile root = (org.jboss.virtual.VirtualFile)AbstractVFS.adapt(dep.getRoot());
VFSDeployment deployment = VFSDeploymentFactory.getInstance().createVFSDeployment(root);
MutableAttachments att = (MutableAttachments)deployment.getPredeterminedManagedObjects();
att.addAttachment(Deployment.class, dep);
@@ -685,9 +684,9 @@
try
{
URL storageLocation = getBundleStorageLocation(in);
- VirtualFile root = VFS.getRoot(storageLocation);
+ VirtualFile root = AbstractVFS.getChild(storageLocation);
- BundleInfo info = BundleInfo.createBundleInfo(AbstractVFS.adapt(root), location);
+ BundleInfo info = BundleInfo.createBundleInfo(root, location);
Deployment dep = DeploymentFactory.createDeployment(info);
dep.addAttachment(AbstractBundleState.class, bundleState);
dep.setBundleUpdate(true);
Deleted: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/VFSEntryPathsEnumeration.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/VFSEntryPathsEnumeration.java 2010-03-03 11:31:45 UTC (rev 101771)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/VFSEntryPathsEnumeration.java 2010-03-03 13:09:03 UTC (rev 101772)
@@ -1,101 +0,0 @@
-/*
-* 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.osgi.framework.bundle;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.List;
-
-import org.jboss.virtual.VirtualFile;
-
-/**
- * VFSEntryPathsEnumeration.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-class VFSEntryPathsEnumeration implements Enumeration<String>
-{
- /** The paths */
- private Iterator<String> paths;
-
- /**
- * Fix the path
- *
- * @param file the file to fix
- * @param rootPath the root path
- * @return the fixxed path
- */
- private String fixPath(VirtualFile file, String rootPath)
- {
- try
- {
- String result = file.getPathName();
- int length = rootPath.length();
- if (length != 0)
- result = result.substring(length);
- if (file.isLeaf() == false && result.endsWith("/") == false)
- result += "/";
- return result;
- }
- catch (IOException e)
- {
- throw new RuntimeException("Error fixing path for " + file, e);
- }
- }
-
- /**
- * Create a new VFSEntryPathsEnumeration.
- *
- * @param root the root file
- * @param file the file to enumerate
- * @throws IOException for any error
- */
- public VFSEntryPathsEnumeration(VirtualFile root, VirtualFile file) throws IOException
- {
- if (root == null)
- throw new IllegalArgumentException("Null root");
- if (file == null)
- throw new IllegalArgumentException("Null file");
-
- String rootPath = root.getPathName();
- ArrayList<String> paths = new ArrayList<String>();
- paths.add(fixPath(file, rootPath));
-
- List<VirtualFile> children = file.getChildrenRecursively();
- for (VirtualFile child : children)
- paths.add(fixPath(child, rootPath));
- this.paths = paths.iterator();
- }
-
- public boolean hasMoreElements()
- {
- return paths.hasNext();
- }
-
- public String nextElement()
- {
- return paths.next();
- }
-}
Deleted: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/VFSFindEntriesEnumeration.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/VFSFindEntriesEnumeration.java 2010-03-03 11:31:45 UTC (rev 101771)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/VFSFindEntriesEnumeration.java 2010-03-03 13:09:03 UTC (rev 101772)
@@ -1,134 +0,0 @@
-/*
-* 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.osgi.framework.bundle;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.jboss.virtual.VirtualFile;
-import org.jboss.virtual.VirtualFileVisitor;
-import org.jboss.virtual.VisitorAttributes;
-import org.jboss.virtual.plugins.vfs.helpers.MatchAllVirtualFileFilter;
-
-/**
- * VFSFindEntriesEnumeration.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-class VFSFindEntriesEnumeration implements Enumeration<URL>
-{
- /** The paths */
- private Iterator<URL> paths;
-
- /**
- * Convert file pattern (RFC 1960-based Filter) into a RegEx pattern
- *
- * @param filePattern the file pattern
- * @return Regular expressions pattern
- */
- private static Pattern convertToPattern(String filePattern)
- {
- filePattern = filePattern.replace("*", ".*");
- return Pattern.compile("^" + filePattern + "$");
- }
-
- /**
- * Create a new VFSFindEntriesEnumeration.
- *
- * @param root the root file
- * @param file the file to enumerate
- * @param filePattern the file pattern
- * @param recurse whether to recurse
- * @throws IOException for any error
- */
- public VFSFindEntriesEnumeration(VirtualFile root, VirtualFile file, String filePattern, boolean recurse) throws IOException
- {
- if (root == null)
- throw new IllegalArgumentException("Null root");
- if (file == null)
- throw new IllegalArgumentException("Null file");
-
- String rootPath = root.getPathName();
- VisitorAttributes attributes = new VisitorAttributes();
- attributes.setIncludeRoot(false);
- attributes.setLeavesOnly(true);
- if (recurse)
- attributes.setRecurseFilter(MatchAllVirtualFileFilter.INSTANCE);
- VisitorImpl visitor = new VisitorImpl(rootPath, filePattern, attributes);
- file.visit(visitor);
- this.paths = visitor.paths.iterator();
- }
-
- public boolean hasMoreElements()
- {
- return paths.hasNext();
- }
-
- public URL nextElement()
- {
- return paths.next();
- }
-
- static class VisitorImpl implements VirtualFileVisitor
- {
- ArrayList<URL> paths = new ArrayList<URL>();
-
- Pattern filter;
- String rootPath;
- VisitorAttributes attributes;
-
- VisitorImpl(String rootPath, String filter, VisitorAttributes attributes)
- {
- this.rootPath = rootPath;
- this.filter = convertToPattern(filter);
- this.attributes = attributes;
- }
-
- public VisitorAttributes getAttributes()
- {
- return attributes;
- }
-
- public void visit(VirtualFile virtualFile)
- {
- // See if the filter matches
- Matcher matcher = filter.matcher(virtualFile.getName());
- if (matcher.find() == false)
- return;
-
- try
- {
- paths.add(virtualFile.toURL());
- }
- catch (Exception e)
- {
- throw new RuntimeException("Error visiting " + virtualFile, e);
- }
- }
- }
-}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java 2010-03-03 11:31:45 UTC (rev 101771)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java 2010-03-03 13:09:03 UTC (rev 101772)
@@ -45,6 +45,7 @@
import org.jboss.osgi.framework.metadata.NativeLibrary;
import org.jboss.osgi.framework.metadata.NativeLibraryMetaData;
import org.jboss.osgi.framework.plugins.BundleStoragePlugin;
+import org.jboss.osgi.vfs.AbstractVFS;
import org.jboss.virtual.VFSUtils;
import org.jboss.virtual.VirtualFile;
@@ -251,7 +252,7 @@
if (libraryFile == null)
{
// Get the virtual file for entry for the library
- VirtualFile fileSource = bundleState.getRoot().getChild(libpath);
+ VirtualFile fileSource = (VirtualFile)AbstractVFS.adapt(bundleState.getRoot().getChild(libpath));
// Create a unique local file location
libraryFile = getUniqueLibraryFile(bundleState, libpath);
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentAttachmentDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentAttachmentDeployer.java 2010-03-03 11:31:45 UTC (rev 101771)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentAttachmentDeployer.java 2010-03-03 13:09:03 UTC (rev 101772)
@@ -34,6 +34,8 @@
import org.jboss.osgi.framework.bundle.OSGiBundleState;
import org.jboss.osgi.framework.bundle.OSGiFragmentState;
import org.jboss.osgi.framework.classloading.OSGiClassLoaderPolicy;
+import org.jboss.osgi.vfs.AbstractVFS;
+import org.jboss.virtual.VirtualFile;
import org.osgi.framework.Bundle;
/**
@@ -94,7 +96,7 @@
OSGiBundleState hostState = fragState.getFragmentHost();
DeploymentUnit hostUnit = hostState.getDeploymentUnit();
OSGiClassLoaderPolicy hostPolicy = (OSGiClassLoaderPolicy)hostUnit.getAttachment(ClassLoaderPolicy.class);
- hostPolicy.attachFragment(fragState.getRoot());
+ hostPolicy.attachFragment((VirtualFile)AbstractVFS.adapt(fragState.getRoot()));
}
}
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/launch/OSGiFramework.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/launch/OSGiFramework.java 2010-03-03 11:31:45 UTC (rev 101771)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/launch/OSGiFramework.java 2010-03-03 13:09:03 UTC (rev 101772)
@@ -29,7 +29,7 @@
import org.jboss.logging.Logger;
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
import org.jboss.osgi.framework.bundle.OSGiBundleWrapper;
-import org.jboss.virtual.VirtualFile;
+import org.jboss.osgi.vfs.VirtualFile;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.framework.FrameworkEvent;
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/util/URLHelper.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/util/URLHelper.java 2010-03-03 11:31:45 UTC (rev 101771)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/util/URLHelper.java 2010-03-03 13:09:03 UTC (rev 101772)
@@ -24,7 +24,7 @@
import java.net.MalformedURLException;
import java.net.URL;
-import org.jboss.virtual.VirtualFile;
+import org.jboss.osgi.vfs.VirtualFile;
/**
* A helper for URL convertions that does not throw checked exceptions.
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/test/java/org/jboss/test/osgi/FrameworkTest.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/test/java/org/jboss/test/osgi/FrameworkTest.java 2010-03-03 11:31:45 UTC (rev 101771)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/test/java/org/jboss/test/osgi/FrameworkTest.java 2010-03-03 13:09:03 UTC (rev 101772)
@@ -37,6 +37,7 @@
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
import org.jboss.osgi.framework.metadata.OSGiMetaData;
import org.jboss.osgi.spi.util.ConstantsHelper;
+import org.jboss.osgi.vfs.AbstractVFS;
import org.jboss.test.kernel.junit.MicrocontainerTest;
import org.jboss.virtual.AssembledDirectory;
import org.jboss.virtual.VirtualFile;
@@ -179,7 +180,7 @@
protected Bundle installBundle(VirtualFile bundleFile) throws BundleException
{
- return getBundleManager().installBundle(bundleFile).getBundleInternal();
+ return getBundleManager().installBundle(AbstractVFS.adapt(bundleFile)).getBundleInternal();
}
/**
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java 2010-03-03 11:31:45 UTC (rev 101771)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java 2010-03-03 13:09:03 UTC (rev 101772)
@@ -45,6 +45,7 @@
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
import org.jboss.osgi.framework.bundle.OSGiBundleState;
import org.jboss.osgi.framework.metadata.OSGiMetaData;
+import org.jboss.osgi.vfs.AbstractVFS;
import org.jboss.test.kernel.junit.MicrocontainerTestDelegate;
import org.jboss.virtual.AssembledDirectory;
import org.jboss.virtual.VFS;
@@ -192,7 +193,7 @@
*/
public Bundle addBundle(VirtualFile file) throws Exception
{
- AbstractBundleState bundleState = getBundleManager().installBundle(file);
+ AbstractBundleState bundleState = getBundleManager().installBundle(AbstractVFS.adapt(file));
return bundleState.getBundleInternal();
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/test/java/org/jboss/test/osgi/resolver/AbstractImportExportTest.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/test/java/org/jboss/test/osgi/resolver/AbstractImportExportTest.java 2010-03-03 11:31:45 UTC (rev 101771)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/test/java/org/jboss/test/osgi/resolver/AbstractImportExportTest.java 2010-03-03 13:09:03 UTC (rev 101772)
@@ -27,8 +27,8 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import org.jboss.osgi.vfs.VirtualFile;
import org.jboss.test.osgi.classloader.support.a.A;
-import org.jboss.virtual.VirtualFile;
import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.service.packageadmin.PackageAdmin;
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTest.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTest.java 2010-03-03 11:31:45 UTC (rev 101771)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTest.java 2010-03-03 13:09:03 UTC (rev 101772)
@@ -37,8 +37,8 @@
import org.jboss.osgi.framework.resolver.RequiredBundle;
import org.jboss.osgi.framework.resolver.Resolver;
import org.jboss.osgi.framework.resolver.ResolverBundle;
+import org.jboss.osgi.vfs.VirtualFile;
import org.jboss.test.osgi.classloader.support.a.A;
-import org.jboss.virtual.VirtualFile;
import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.Version;
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml 2010-03-03 11:31:45 UTC (rev 101771)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml 2010-03-03 13:09:03 UTC (rev 101772)
@@ -58,6 +58,7 @@
<version.jboss.osgi.reflect>2.2.0</version.jboss.osgi.reflect>
<version.jboss.osgi.spi>1.0.5-SNAPSHOT</version.jboss.osgi.spi>
<version.jboss.osgi.testing>1.0.0-SNAPSHOT</version.jboss.osgi.testing>
+ <version.jboss.osgi.vfs>1.0.0-SNAPSHOT</version.jboss.osgi.vfs>
<version.jboss.osgi.xml.binding>2.0.2.Beta4</version.jboss.osgi.xml.binding>
<version.jboss.test>1.1.4.GA</version.jboss.test>
<version.ops4j.pax.web>0.7.2</version.ops4j.pax.web>
@@ -269,6 +270,11 @@
<artifactId>jboss-osgi-testing</artifactId>
<version>${version.jboss.osgi.testing}</version>
</dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.vfs</groupId>
+ <artifactId>jboss-osgi-vfs21</artifactId>
+ <version>${version.jboss.osgi.vfs}</version>
+ </dependency>
</dependencies>
</dependencyManagement>
Modified: projects/jboss-osgi/projects/testing/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/pom.xml 2010-03-03 11:31:45 UTC (rev 101771)
+++ projects/jboss-osgi/projects/testing/trunk/pom.xml 2010-03-03 13:09:03 UTC (rev 101772)
@@ -68,7 +68,7 @@
</dependency>
<dependency>
<groupId>org.jboss.osgi.vfs</groupId>
- <artifactId>jboss-osgi-vfs21</artifactId>
+ <artifactId>jboss-osgi-vfs</artifactId>
<version>${version.jboss.osgi.vfs}</version>
</dependency>
<dependency>
@@ -133,6 +133,12 @@
<version>${version.jboss.osgi.felix}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.vfs</groupId>
+ <artifactId>jboss-osgi-vfs21</artifactId>
+ <version>${version.jboss.osgi.vfs}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
Modified: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiTest.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiTest.java 2010-03-03 11:31:45 UTC (rev 101771)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiTest.java 2010-03-03 13:09:03 UTC (rev 101772)
@@ -28,8 +28,7 @@
import javax.naming.NamingException;
import org.jboss.logging.Logger;
-import org.jboss.virtual.VFS;
-import org.jboss.virtual.VirtualFile;
+import org.jboss.osgi.vfs.VirtualFile;
import org.junit.After;
import org.junit.Before;
import org.osgi.framework.Bundle;
@@ -52,8 +51,6 @@
protected OSGiTest()
{
- // Prevent unknown protocol: vfsfile
- VFS.init();
}
/**
Modified: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java 2010-03-03 11:31:45 UTC (rev 101771)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java 2010-03-03 13:09:03 UTC (rev 101772)
@@ -39,9 +39,9 @@
import org.jboss.osgi.spi.util.ConstantsHelper;
import org.jboss.osgi.testing.internal.EmbeddedRuntime;
import org.jboss.osgi.testing.internal.RemoteRuntime;
-import org.jboss.virtual.AssembledDirectory;
-import org.jboss.virtual.VFS;
-import org.jboss.virtual.VirtualFile;
+import org.jboss.osgi.vfs.AbstractVFS;
+import org.jboss.osgi.vfs.VirtualFile;
+import org.jboss.osgi.vfs.VirtualFileAssembly;
import org.osgi.framework.Bundle;
/**
@@ -220,12 +220,12 @@
public VirtualFile assembleBundle(String name, String[] resources, Class<?>... packages) throws Exception
{
- AssembledDirectory assembledDirectory = AssembledDirectory.createAssembledDirectory(name, "");
+ VirtualFileAssembly assembly = AbstractVFS.createVirtualFileAssembly(name);
for (String path : resources)
- addPath(assembledDirectory, path, "");
+ addPath(assembly, path, "");
for (Class<?> reference : packages)
- addPackage(assembledDirectory, reference);
- return assembledDirectory;
+ addPackage(assembly, reference);
+ return assembly;
}
public void assertBundleState(int expState, int wasState)
@@ -259,17 +259,18 @@
}
}
- private void addPath(AssembledDirectory dir, String path, String name) throws Exception
+ private void addPath(VirtualFileAssembly dir, String path, String name) throws Exception
{
URL url = getClass().getResource(path);
if (url == null)
throw new AssertionFailedError(path + " not found");
- VirtualFile file = VFS.getVirtualFile(url, name);
+ VirtualFile root = AbstractVFS.getChild(url);
+ VirtualFile file = root.getChild(name);
dir.addPath(file);
}
- private void addPackage(AssembledDirectory dir, Class<?> reference) throws Exception
+ private void addPackage(VirtualFileAssembly dir, Class<?> reference) throws Exception
{
String packagePath = packageNameToPath(reference.getName());
dir.addResources(reference, new String[] { packagePath + "/*.class" }, new String[0]);
Modified: projects/jboss-osgi/projects/vfs/trunk/api/src/main/java/org/jboss/osgi/vfs/AbstractVFS.java
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/api/src/main/java/org/jboss/osgi/vfs/AbstractVFS.java 2010-03-03 11:31:45 UTC (rev 101771)
+++ projects/jboss-osgi/projects/vfs/trunk/api/src/main/java/org/jboss/osgi/vfs/AbstractVFS.java 2010-03-03 13:09:03 UTC (rev 101772)
@@ -22,6 +22,7 @@
package org.jboss.osgi.vfs;
import java.io.IOException;
+import java.net.URISyntaxException;
import java.net.URL;
/**
@@ -41,6 +42,11 @@
return getVFSAdaptor().getChild(url);
}
+ public static VirtualFileAssembly createVirtualFileAssembly(String name) throws IOException, URISyntaxException
+ {
+ return getVFSAdaptor().createVirtualFileAssembly(name);
+ }
+
public static VirtualFile adapt(Object virtualFile)
{
return getVFSAdaptor().adapt(virtualFile);
Modified: projects/jboss-osgi/projects/vfs/trunk/api/src/main/java/org/jboss/osgi/vfs/VFSAdaptor.java
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/api/src/main/java/org/jboss/osgi/vfs/VFSAdaptor.java 2010-03-03 11:31:45 UTC (rev 101771)
+++ projects/jboss-osgi/projects/vfs/trunk/api/src/main/java/org/jboss/osgi/vfs/VFSAdaptor.java 2010-03-03 13:09:03 UTC (rev 101772)
@@ -22,6 +22,7 @@
package org.jboss.osgi.vfs;
import java.io.IOException;
+import java.net.URISyntaxException;
import java.net.URL;
/**
@@ -44,6 +45,8 @@
*/
VirtualFile getChild(URL url) throws IOException;
+ VirtualFileAssembly createVirtualFileAssembly(String name) throws IOException, URISyntaxException;
+
/**
* Adapt a concrete instance of a jboss-vfs VirtualFile.
* @param virtualFile The VirtualFile instance
Modified: projects/jboss-osgi/projects/vfs/trunk/api/src/main/java/org/jboss/osgi/vfs/VirtualFile.java
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/api/src/main/java/org/jboss/osgi/vfs/VirtualFile.java 2010-03-03 11:31:45 UTC (rev 101771)
+++ projects/jboss-osgi/projects/vfs/trunk/api/src/main/java/org/jboss/osgi/vfs/VirtualFile.java 2010-03-03 13:09:03 UTC (rev 101772)
@@ -26,6 +26,8 @@
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
+import java.util.Enumeration;
+import java.util.List;
/**
* A basic abstraction of a VirtualFile used by the OSGi layer.
@@ -46,6 +48,24 @@
String getName();
/**
+ * Get the VFS relative path name (org/jboss/X.java)
+ *
+ * @return the VFS relative path name
+ * @throws IllegalStateException if the file is closed
+ */
+ String getPathName();
+
+ /**
+ * Whether it is a simple leaf of the VFS,
+ * i.e. whether it can contain other files
+ *
+ * @return true if a simple file.
+ * @throws IOException for any problem accessing the virtual file system
+ * @throws IllegalStateException if the file is closed
+ */
+ boolean isFile() throws IOException;
+
+ /**
* Get the VF URL (file://root/org/jboss/X.java)
*
* @return the full URL to the VF in the VFS.
@@ -67,6 +87,36 @@
VirtualFile getChild(String string) throws IOException;
/**
+ * Get all the children recursively<p>
+ *
+ * This always uses {@link VisitorAttributes#RECURSE}
+ *
+ * @return the children
+ * @throws IOException for any problem accessing the virtual file system
+ * @throws IllegalStateException if the file is closed
+ */
+ List<VirtualFile> getChildrenRecursively() throws IOException;
+
+ /**
+ * Returns entries in this bundle and its attached fragments. This bundle's
+ * class loader is not used to search for entries. Only the contents of this
+ * bundle and its attached fragments are searched for the specified entries.
+ *
+ * @see Bundle.findEntries(String path, String pattern, boolean recurse)
+ */
+ Enumeration<URL> findEntries(String path, String pattern, boolean recurse) throws IOException;
+
+ /**
+ * Returns an Enumeration of all the paths (<code>String</code> objects)
+ * to entries within this bundle whose longest sub-path matches the
+ * specified path. This bundle's class loader is not used to search for
+ * entries. Only the contents of this bundle are searched.
+ *
+ * @see Bundle.getEntryPaths(String path)
+ */
+ Enumeration<String> getEntryPaths(String path) throws IOException;
+
+ /**
* Access the file contents.
*
* @return an InputStream for the file contents.
Added: projects/jboss-osgi/projects/vfs/trunk/api/src/main/java/org/jboss/osgi/vfs/VirtualFileAssembly.java
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/api/src/main/java/org/jboss/osgi/vfs/VirtualFileAssembly.java (rev 0)
+++ projects/jboss-osgi/projects/vfs/trunk/api/src/main/java/org/jboss/osgi/vfs/VirtualFileAssembly.java 2010-03-03 13:09:03 UTC (rev 101772)
@@ -0,0 +1,60 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.osgi.vfs;
+
+import java.io.IOException;
+
+
+/**
+ * A basic abstraction of a VirtualFileAssembly used by the OSGi layer.
+ *
+ * This abstraction should be removed once we settle on a single jboss-vfs version.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 02-Mar-2010
+ */
+public interface VirtualFileAssembly extends VirtualFile
+{
+ /**
+ * Add files recursively from root, using the no jars filter.
+ *
+ * @param root the root
+ * @throws IOException for any error
+ */
+ void addPath(VirtualFile file) throws IOException;
+
+ /**
+ * Locate the .class resource of baseResource. From this resource, determine the base of the resource
+ * i.e. what jar or classpath directory it lives in.
+ *
+ * Once the base of the resource is found, scan all files recursively within the base using the include and exclude
+ * patterns. A mirror file structure will be created within this AssembledDirectory. Ths is very useful when you
+ * want to create a virtual jar that contains a subset of .class files in your classpath.
+ *
+ * The include/exclude patterns follow the Ant file pattern matching syntax. See ant.apache.org for more details.
+ *
+ * @param baseResource the base resource
+ * @param includes the includes
+ * @param excludes the excludes
+ */
+ void addResources(Class<?> reference, String[] includes, String[] excludes);
+}
Added: projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/AssemblyAdaptor21.java
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/AssemblyAdaptor21.java (rev 0)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/AssemblyAdaptor21.java 2010-03-03 13:09:03 UTC (rev 101772)
@@ -0,0 +1,56 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.osgi.vfs21;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+
+import org.jboss.osgi.vfs.VirtualFile;
+import org.jboss.osgi.vfs.VirtualFileAssembly;
+import org.jboss.virtual.AssembledDirectory;
+
+/**
+ * An adaptor to the jboss-vfs-2.1.x VirtualFile.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 02-Mar-2010
+ */
+class AssemblyAdaptor21 extends VirtualFileAdaptor21 implements VirtualFileAssembly
+{
+ private AssembledDirectory delegate;
+
+ public AssemblyAdaptor21(AssembledDirectory assembly) throws IOException, URISyntaxException
+ {
+ super(assembly);
+ this.delegate = assembly;
+ }
+
+ public void addPath(VirtualFile file) throws IOException
+ {
+ delegate.addPath(((VirtualFileAdaptor21)file).getDelegate());
+ }
+
+ public void addResources(Class<?> reference, String[] includes, String[] excludes)
+ {
+ delegate.addResources(reference, includes, excludes);
+ }
+}
Modified: projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/VFSAdaptor21.java
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/VFSAdaptor21.java 2010-03-03 11:31:45 UTC (rev 101771)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/VFSAdaptor21.java 2010-03-03 13:09:03 UTC (rev 101772)
@@ -22,10 +22,13 @@
package org.jboss.osgi.vfs21;
import java.io.IOException;
+import java.net.URISyntaxException;
import java.net.URL;
import org.jboss.osgi.vfs.VFSAdaptor;
import org.jboss.osgi.vfs.VirtualFile;
+import org.jboss.osgi.vfs.VirtualFileAssembly;
+import org.jboss.virtual.AssembledDirectory;
/**
* An adaptor to the jboss-vfs-2.1.x VFS.
@@ -41,6 +44,12 @@
return new VirtualFileAdaptor21(root);
}
+ public VirtualFileAssembly createVirtualFileAssembly(String name) throws IOException, URISyntaxException
+ {
+ AssembledDirectory assembly = AssembledDirectory.createAssembledDirectory(name, "");
+ return new AssemblyAdaptor21(assembly);
+ }
+
public VirtualFile adapt(Object virtualFile)
{
if (virtualFile == null)
@@ -54,6 +63,9 @@
public Object adapt(VirtualFile virtualFile)
{
+ if (virtualFile == null)
+ return null;
+
VirtualFileAdaptor21 adaptor = (VirtualFileAdaptor21)virtualFile;
return adaptor.getDelegate();
}
Added: projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/VFSEntryPathsEnumeration.java
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/VFSEntryPathsEnumeration.java (rev 0)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/VFSEntryPathsEnumeration.java 2010-03-03 13:09:03 UTC (rev 101772)
@@ -0,0 +1,99 @@
+/*
+* 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.osgi.vfs21;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * An enumeration of VFS entry paths.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author thomas.diesler at jboss.com
+ * @version $Revision: 1.1 $
+ */
+class VFSEntryPathsEnumeration implements Enumeration<String>
+{
+ /** The paths */
+ private Iterator<String> paths;
+
+ /**
+ * Create a new VFSEntryPathsEnumeration.
+ *
+ * @param root the root file
+ * @param file the file to enumerate
+ * @throws IOException for any error
+ */
+ public VFSEntryPathsEnumeration(VirtualFile root, VirtualFile file) throws IOException
+ {
+ if (root == null)
+ throw new IllegalArgumentException("Null root");
+ if (file == null)
+ throw new IllegalArgumentException("Null file");
+
+ String rootPath = root.getPathName();
+ ArrayList<String> paths = new ArrayList<String>();
+ paths.add(fixPath(rootPath, file));
+
+ List<VirtualFile> children = file.getChildrenRecursively();
+ for (VirtualFile child : children)
+ paths.add(fixPath(rootPath, child));
+
+ this.paths = paths.iterator();
+ }
+
+ public boolean hasMoreElements()
+ {
+ return paths.hasNext();
+ }
+
+ public String nextElement()
+ {
+ return paths.next();
+ }
+
+ private String fixPath(String rootPath, VirtualFile file)
+ {
+ try
+ {
+ String result = file.getPathName();
+
+ int length = rootPath.length();
+ if (length != 0)
+ result = result.substring(length);
+
+ if (file.isLeaf() == false && result.endsWith("/") == false)
+ result += "/";
+
+ return result;
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException("Error fixing path for " + file, e);
+ }
+ }
+}
Added: projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/VFSFindEntriesEnumeration.java
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/VFSFindEntriesEnumeration.java (rev 0)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/VFSFindEntriesEnumeration.java 2010-03-03 13:09:03 UTC (rev 101772)
@@ -0,0 +1,133 @@
+/*
+* 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.osgi.vfs21;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileVisitor;
+import org.jboss.virtual.VisitorAttributes;
+import org.jboss.virtual.plugins.vfs.helpers.MatchAllVirtualFileFilter;
+
+/**
+ * An enumeration of VFS entries.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author thomas.diesler at jboss.com
+ * @version $Revision: 1.1 $
+ */
+class VFSFindEntriesEnumeration implements Enumeration<URL>
+{
+ /** The paths */
+ private Iterator<URL> paths;
+
+ /**
+ * Create a new VFSFindEntriesEnumeration.
+ *
+ * @param root the root file
+ * @param file the file to enumerate
+ * @param filePattern the file pattern
+ * @param recurse whether to recurse
+ * @throws IOException for any error
+ */
+ public VFSFindEntriesEnumeration(VirtualFile root, VirtualFile file, String filePattern, boolean recurse) throws IOException
+ {
+ if (root == null)
+ throw new IllegalArgumentException("Null root");
+ if (file == null)
+ throw new IllegalArgumentException("Null file");
+
+ String rootPath = root.getPathName();
+ VisitorAttributes attributes = new VisitorAttributes();
+ attributes.setIncludeRoot(false);
+ attributes.setLeavesOnly(true);
+ if (recurse)
+ attributes.setRecurseFilter(MatchAllVirtualFileFilter.INSTANCE);
+
+ VisitorImpl visitor = new VisitorImpl(rootPath, filePattern, attributes);
+ file.visit(visitor);
+
+ this.paths = visitor.paths.iterator();
+ }
+
+ public boolean hasMoreElements()
+ {
+ return paths.hasNext();
+ }
+
+ public URL nextElement()
+ {
+ return paths.next();
+ }
+
+ static class VisitorImpl implements VirtualFileVisitor
+ {
+ ArrayList<URL> paths = new ArrayList<URL>();
+
+ Pattern filter;
+ String rootPath;
+ VisitorAttributes attributes;
+
+ VisitorImpl(String rootPath, String filter, VisitorAttributes attributes)
+ {
+ this.rootPath = rootPath;
+ this.filter = convertToPattern(filter);
+ this.attributes = attributes;
+ }
+
+ public VisitorAttributes getAttributes()
+ {
+ return attributes;
+ }
+
+ public void visit(VirtualFile virtualFile)
+ {
+ // See if the filter matches
+ Matcher matcher = filter.matcher(virtualFile.getName());
+ if (matcher.find() == false)
+ return;
+
+ try
+ {
+ paths.add(virtualFile.toURL());
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Error visiting " + virtualFile, e);
+ }
+ }
+
+ // Convert file pattern (RFC 1960-based Filter) into a RegEx pattern
+ private static Pattern convertToPattern(String filePattern)
+ {
+ filePattern = filePattern.replace("*", ".*");
+ return Pattern.compile("^" + filePattern + "$");
+ }
+
+ }
+}
Modified: projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/VirtualFileAdaptor21.java
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/VirtualFileAdaptor21.java 2010-03-03 11:31:45 UTC (rev 101771)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/VirtualFileAdaptor21.java 2010-03-03 13:09:03 UTC (rev 101772)
@@ -26,6 +26,10 @@
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
import org.jboss.osgi.vfs.VirtualFile;
@@ -38,7 +42,7 @@
class VirtualFileAdaptor21 implements VirtualFile
{
private org.jboss.virtual.VirtualFile delegate;
-
+
public VirtualFileAdaptor21(org.jboss.virtual.VirtualFile delegate)
{
this.delegate = delegate;
@@ -53,7 +57,17 @@
{
return delegate.getName();
}
-
+
+ public String getPathName()
+ {
+ return delegate.getPathName();
+ }
+
+ public boolean isFile() throws IOException
+ {
+ return delegate.isLeaf();
+ }
+
public URL toURL() throws MalformedURLException, URISyntaxException
{
return delegate.toURL();
@@ -64,13 +78,54 @@
org.jboss.virtual.VirtualFile child = delegate.getChild(path);
if (child == null)
return null;
-
+
return new VirtualFileAdaptor21(child);
}
+ public List<VirtualFile> getChildrenRecursively() throws IOException
+ {
+ List<VirtualFile> files = new ArrayList<VirtualFile>();
+ for (org.jboss.virtual.VirtualFile child : delegate.getChildrenRecursively())
+ files.add(new VirtualFileAdaptor21(child));
+
+ return Collections.unmodifiableList(files);
+ }
+
+ public Enumeration<URL> findEntries(String path, String pattern, boolean recurse) throws IOException
+ {
+ if (path == null)
+ throw new IllegalArgumentException("Null path");
+
+ if (pattern == null)
+ pattern = "*";
+
+ if (path.startsWith("/"))
+ path = path.substring(1);
+
+ org.jboss.virtual.VirtualFile child = delegate.getChild(path);
+ if (child == null)
+ return null;
+
+ return new VFSFindEntriesEnumeration(delegate, child, pattern, recurse);
+ }
+
+ public Enumeration<String> getEntryPaths(String path) throws IOException
+ {
+ if (path == null)
+ throw new IllegalArgumentException("Null path");
+
+ if (path.startsWith("/"))
+ path = path.substring(1);
+
+ org.jboss.virtual.VirtualFile child = delegate.getChild(path);
+ if (child == null)
+ return null;
+
+ return new VFSEntryPathsEnumeration(delegate, child);
+ }
+
public InputStream openStream() throws IOException
{
return delegate.openStream();
}
}
-
Modified: projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSAdaptor30.java
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSAdaptor30.java 2010-03-03 11:31:45 UTC (rev 101771)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSAdaptor30.java 2010-03-03 13:09:03 UTC (rev 101772)
@@ -27,6 +27,7 @@
import org.jboss.osgi.vfs.VFSAdaptor;
import org.jboss.osgi.vfs.VirtualFile;
+import org.jboss.osgi.vfs.VirtualFileAssembly;
/**
* An adaptor to the jboss-vfs-3.0.x VFS.
@@ -50,6 +51,11 @@
return new VirtualFileAdaptor30(root);
}
+ public VirtualFileAssembly createVirtualFileAssembly(String name) throws IOException, URISyntaxException
+ {
+ throw new IllegalArgumentException("not implemented");
+ }
+
public VirtualFile adapt(Object virtualFile)
{
if (virtualFile == null)
@@ -63,6 +69,9 @@
public Object adapt(VirtualFile virtualFile)
{
+ if (virtualFile == null)
+ return null;
+
VirtualFileAdaptor30 adaptor = (VirtualFileAdaptor30)virtualFile;
return adaptor.getDelegate();
}
Modified: projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VirtualFileAdaptor30.java
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VirtualFileAdaptor30.java 2010-03-03 11:31:45 UTC (rev 101771)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VirtualFileAdaptor30.java 2010-03-03 13:09:03 UTC (rev 101772)
@@ -26,6 +26,10 @@
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
import org.jboss.osgi.vfs.VirtualFile;
@@ -54,6 +58,16 @@
return delegate.getName();
}
+ public String getPathName()
+ {
+ return delegate.getPathName();
+ }
+
+ public boolean isFile() throws IOException
+ {
+ return delegate.isFile();
+ }
+
public URL toURL() throws MalformedURLException, URISyntaxException
{
return delegate.toURL();
@@ -68,6 +82,25 @@
return new VirtualFileAdaptor30(child);
}
+ public List<VirtualFile> getChildrenRecursively() throws IOException
+ {
+ List<VirtualFile> files = new ArrayList<VirtualFile>();
+ for (org.jboss.vfs.VirtualFile child : delegate.getChildrenRecursively())
+ files.add(new VirtualFileAdaptor30(child));
+
+ return Collections.unmodifiableList(files);
+ }
+
+ public Enumeration<URL> findEntries(String path, String pattern, boolean recurse) throws IOException
+ {
+ throw new IllegalArgumentException("not implemented");
+ }
+
+ public Enumeration<String> getEntryPaths(String path)
+ {
+ throw new IllegalArgumentException("not implemented");
+ }
+
public InputStream openStream() throws IOException
{
return delegate.openStream();
More information about the jboss-cvs-commits
mailing list