[jboss-cvs] JBossAS SVN: r101338 - in projects/ejb3/components/vfs/trunk: impl-vfs2 and 35 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Feb 23 13:18:17 EST 2010
Author: johnbailey
Date: 2010-02-23 13:18:14 -0500 (Tue, 23 Feb 2010)
New Revision: 101338
Added:
projects/ejb3/components/vfs/trunk/impl-vfs2/src/main/java/org/jboss/ejb3/vfs/impl/vfs2/UnifiedVirtualFileFactoryImpl.java
projects/ejb3/components/vfs/trunk/impl-vfs2/src/main/java/org/jboss/ejb3/vfs/impl/vfs2/VirtualFileFilterAdapter.java
projects/ejb3/components/vfs/trunk/impl-vfs2/src/main/resources/META-INF/
projects/ejb3/components/vfs/trunk/impl-vfs2/src/main/resources/META-INF/services/
projects/ejb3/components/vfs/trunk/impl-vfs2/src/main/resources/META-INF/services/org.jboss.ejb3.vfs.spi.UnifiedVirtualFileFactory
projects/ejb3/components/vfs/trunk/impl-vfs2/src/test/java/org/
projects/ejb3/components/vfs/trunk/impl-vfs2/src/test/java/org/jboss/
projects/ejb3/components/vfs/trunk/impl-vfs2/src/test/java/org/jboss/test/
projects/ejb3/components/vfs/trunk/impl-vfs2/src/test/java/org/jboss/test/ejb3/
projects/ejb3/components/vfs/trunk/impl-vfs2/src/test/java/org/jboss/test/ejb3/vfs/
projects/ejb3/components/vfs/trunk/impl-vfs2/src/test/java/org/jboss/test/ejb3/vfs/impl/
projects/ejb3/components/vfs/trunk/impl-vfs2/src/test/java/org/jboss/test/ejb3/vfs/impl/vfs2/
projects/ejb3/components/vfs/trunk/impl-vfs2/src/test/java/org/jboss/test/ejb3/vfs/impl/vfs2/UnifiedVirtualFileFactoryImplUnitTest.java
projects/ejb3/components/vfs/trunk/impl-vfs2/src/test/java/org/jboss/test/ejb3/vfs/impl/vfs2/VirtualFileFilterUnitTest.java
projects/ejb3/components/vfs/trunk/impl-vfs2/src/test/resources/vfs/
projects/ejb3/components/vfs/trunk/impl-vfs2/src/test/resources/vfs/other.txt
projects/ejb3/components/vfs/trunk/impl-vfs2/src/test/resources/vfs/test.txt
projects/ejb3/components/vfs/trunk/impl-vfs2/src/test/resources/vfs/test.xml
projects/ejb3/components/vfs/trunk/impl-vfs2/src/test/resources/vfs/test/
projects/ejb3/components/vfs/trunk/impl-vfs2/src/test/resources/vfs/test/other.txt
projects/ejb3/components/vfs/trunk/impl-vfs2/src/test/resources/vfs/test/test.txt
projects/ejb3/components/vfs/trunk/impl-vfs2/src/test/resources/vfs/test/test.xml
projects/ejb3/components/vfs/trunk/impl-vfs3/src/main/java/org/jboss/ejb3/vfs/impl/vfs3/UnifiedVirtualFileFactoryImpl.java
projects/ejb3/components/vfs/trunk/impl-vfs3/src/main/resources/META-INF/
projects/ejb3/components/vfs/trunk/impl-vfs3/src/main/resources/META-INF/services/
projects/ejb3/components/vfs/trunk/impl-vfs3/src/main/resources/META-INF/services/org.jboss.ejb3.vfs.spi.UnifiedVirtualFileFactory
projects/ejb3/components/vfs/trunk/impl-vfs3/src/test/java/org/
projects/ejb3/components/vfs/trunk/impl-vfs3/src/test/java/org/jboss/
projects/ejb3/components/vfs/trunk/impl-vfs3/src/test/java/org/jboss/test/
projects/ejb3/components/vfs/trunk/impl-vfs3/src/test/java/org/jboss/test/ejb3/
projects/ejb3/components/vfs/trunk/impl-vfs3/src/test/java/org/jboss/test/ejb3/vfs/
projects/ejb3/components/vfs/trunk/impl-vfs3/src/test/java/org/jboss/test/ejb3/vfs/impl/
projects/ejb3/components/vfs/trunk/impl-vfs3/src/test/java/org/jboss/test/ejb3/vfs/impl/vfs3/
projects/ejb3/components/vfs/trunk/impl-vfs3/src/test/java/org/jboss/test/ejb3/vfs/impl/vfs3/UnifiedVirtualFileFactoryImplUnitTest.java
projects/ejb3/components/vfs/trunk/impl-vfs3/src/test/java/org/jboss/test/ejb3/vfs/impl/vfs3/VirtualFileFilterUnitTest.java
projects/ejb3/components/vfs/trunk/impl-vfs3/src/test/resources/vfs/
projects/ejb3/components/vfs/trunk/impl-vfs3/src/test/resources/vfs/other.txt
projects/ejb3/components/vfs/trunk/impl-vfs3/src/test/resources/vfs/test.txt
projects/ejb3/components/vfs/trunk/impl-vfs3/src/test/resources/vfs/test.xml
projects/ejb3/components/vfs/trunk/impl-vfs3/src/test/resources/vfs/test/
projects/ejb3/components/vfs/trunk/impl-vfs3/src/test/resources/vfs/test/other.txt
projects/ejb3/components/vfs/trunk/impl-vfs3/src/test/resources/vfs/test/test.txt
projects/ejb3/components/vfs/trunk/impl-vfs3/src/test/resources/vfs/test/test.xml
projects/ejb3/components/vfs/trunk/spi/src/main/java/org/jboss/ejb3/vfs/spi/UnifiedVirtualFileFactory.java
projects/ejb3/components/vfs/trunk/spi/src/main/java/org/jboss/ejb3/vfs/spi/VirtualFileFilter.java
projects/ejb3/components/vfs/trunk/spi/src/main/java/org/jboss/ejb3/vfs/spi/util/
projects/ejb3/components/vfs/trunk/spi/src/main/java/org/jboss/ejb3/vfs/spi/util/ServiceLoader.java
Removed:
projects/ejb3/components/vfs/trunk/impl-vfs3/src/main/java/org/jboss/virtual/VirtualFile.java
projects/ejb3/components/vfs/trunk/impl-vfs3/src/main/java/org/jboss/virtual/VirtualFileFilter.java
Modified:
projects/ejb3/components/vfs/trunk/build/pom.xml
projects/ejb3/components/vfs/trunk/impl-vfs2/pom.xml
projects/ejb3/components/vfs/trunk/impl-vfs2/src/main/java/org/jboss/ejb3/vfs/impl/vfs2/VirtualFileWrapper.java
projects/ejb3/components/vfs/trunk/impl-vfs3/pom.xml
projects/ejb3/components/vfs/trunk/impl-vfs3/src/main/java/org/jboss/ejb3/vfs/impl/vfs3/VirtualFileFilterAdapter.java
projects/ejb3/components/vfs/trunk/impl-vfs3/src/main/java/org/jboss/ejb3/vfs/impl/vfs3/VirtualFileWrapper.java
projects/ejb3/components/vfs/trunk/spi/pom.xml
projects/ejb3/components/vfs/trunk/spi/src/main/java/org/jboss/ejb3/vfs/spi/VirtualFile.java
Log:
[EJBTHREE-2007] - Continued the work on the EJB3 VFS abstraction layer.
Modified: projects/ejb3/components/vfs/trunk/build/pom.xml
===================================================================
--- projects/ejb3/components/vfs/trunk/build/pom.xml 2010-02-23 17:09:39 UTC (rev 101337)
+++ projects/ejb3/components/vfs/trunk/build/pom.xml 2010-02-23 18:18:14 UTC (rev 101338)
@@ -17,7 +17,7 @@
<!-- Artifact Configuration -->
<groupId>org.jboss.ejb3.vfs</groupId>
- <artifactId>vfs-build</artifactId>
+ <artifactId>jboss-ejb3-vfs-build</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>JBoss EJB 3.x VFS Abstraction Build Parent</name>
<description>JBoss EJB 3.x Virtual File System Abstraction Build Parent</description>
Modified: projects/ejb3/components/vfs/trunk/impl-vfs2/pom.xml
===================================================================
--- projects/ejb3/components/vfs/trunk/impl-vfs2/pom.xml 2010-02-23 17:09:39 UTC (rev 101337)
+++ projects/ejb3/components/vfs/trunk/impl-vfs2/pom.xml 2010-02-23 18:18:14 UTC (rev 101338)
@@ -8,7 +8,7 @@
<!-- Define Parent -->
<parent>
<groupId>org.jboss.ejb3.vfs</groupId>
- <artifactId>vfs-build</artifactId>
+ <artifactId>jboss-ejb3-vfs-build</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../build/pom.xml</relativePath>
</parent>
@@ -17,36 +17,45 @@
<modelVersion>4.0.0</modelVersion>
<!-- Artifact Information -->
- <artifactId>vfs-impl-vfs2</artifactId>
+ <artifactId>jboss-ejb3-vfs-impl-vfs2</artifactId>
<packaging>jar</packaging>
<name>JBoss EJB 3.x VFS Abstraction Implementation for JBoss VFS2</name>
<description>JBoss EJB 3.x Virtual File System Abstraction Implementation for JBoss VFS2</description>
<!-- Build Configuration -->
<build>
-
</build>
<properties>
-
<!-- Versioning -->
-
-
+ <version.jboss.vfs>2.1.3.SP1</version.jboss.vfs>
+ <version.jboss.metadata.common>2.0.0-alpha-10</version.jboss.metadata.common>
+ <version.jboss.test>1.1.4.GA</version.jboss.test>
</properties>
<dependencies>
-
<dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-vfs</artifactId>
- <version>2.1.3.SP1</version>
- </dependency>
-
- <dependency>
<groupId>org.jboss.ejb3.vfs</groupId>
<artifactId>vfs-spi</artifactId>
<version>${version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-vfs</artifactId>
+ <version>${version.jboss.vfs}</version>
</dependency>
+ <dependency>
+ <groupId>org.jboss.metadata</groupId>
+ <artifactId>jboss-metadata-common</artifactId>
+ <version>${version.jboss.metadata.common}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.test</groupId>
+ <artifactId>jboss-test</artifactId>
+ <version>${version.jboss.test}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
+
</project>
Added: projects/ejb3/components/vfs/trunk/impl-vfs2/src/main/java/org/jboss/ejb3/vfs/impl/vfs2/UnifiedVirtualFileFactoryImpl.java
===================================================================
--- projects/ejb3/components/vfs/trunk/impl-vfs2/src/main/java/org/jboss/ejb3/vfs/impl/vfs2/UnifiedVirtualFileFactoryImpl.java (rev 0)
+++ projects/ejb3/components/vfs/trunk/impl-vfs2/src/main/java/org/jboss/ejb3/vfs/impl/vfs2/UnifiedVirtualFileFactoryImpl.java 2010-02-23 18:18:14 UTC (rev 101338)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, 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.ejb3.vfs.impl.vfs2;
+
+import org.jboss.ejb3.vfs.spi.VirtualFile;
+import org.jboss.ejb3.vfs.spi.UnifiedVirtualFileFactory;
+import org.jboss.metadata.serviceref.VirtualFileAdaptor;
+import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
+
+/**
+ * {@link UnifiedVirtualFileFactory} implementation for VFS2
+ *
+ * @author John Bailey
+ */
+public class UnifiedVirtualFileFactoryImpl extends UnifiedVirtualFileFactory
+{
+ @Override
+ public UnifiedVirtualFile create(VirtualFile virtualFile)
+ {
+ if(virtualFile instanceof VirtualFileWrapper)
+ return new VirtualFileAdaptor(((VirtualFileWrapper) virtualFile).getWrapped());
+ return null;
+ }
+}
Added: projects/ejb3/components/vfs/trunk/impl-vfs2/src/main/java/org/jboss/ejb3/vfs/impl/vfs2/VirtualFileFilterAdapter.java
===================================================================
--- projects/ejb3/components/vfs/trunk/impl-vfs2/src/main/java/org/jboss/ejb3/vfs/impl/vfs2/VirtualFileFilterAdapter.java (rev 0)
+++ projects/ejb3/components/vfs/trunk/impl-vfs2/src/main/java/org/jboss/ejb3/vfs/impl/vfs2/VirtualFileFilterAdapter.java 2010-02-23 18:18:14 UTC (rev 101338)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, 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.ejb3.vfs.impl.vfs2;
+
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilter;
+
+/**
+ * A VirtualFileFilter that provides an adapter between the EJB3 VFS abstraction
+ * layer and VFS2.
+ */
+public class VirtualFileFilterAdapter implements VirtualFileFilter
+{
+ /* EJB3 VFS Filter */
+ private final org.jboss.ejb3.vfs.spi.VirtualFileFilter delegate;
+
+ /**
+ * Constructs a new instance with a VFS abstract VirtualFileFilter
+ *
+ * @param delegate
+ */
+ public VirtualFileFilterAdapter(org.jboss.ejb3.vfs.spi.VirtualFileFilter delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public boolean accepts(VirtualFile file)
+ {
+ return delegate.accepts(new VirtualFileWrapper(file));
+ }
+}
Modified: projects/ejb3/components/vfs/trunk/impl-vfs2/src/main/java/org/jboss/ejb3/vfs/impl/vfs2/VirtualFileWrapper.java
===================================================================
--- projects/ejb3/components/vfs/trunk/impl-vfs2/src/main/java/org/jboss/ejb3/vfs/impl/vfs2/VirtualFileWrapper.java 2010-02-23 17:09:39 UTC (rev 101337)
+++ projects/ejb3/components/vfs/trunk/impl-vfs2/src/main/java/org/jboss/ejb3/vfs/impl/vfs2/VirtualFileWrapper.java 2010-02-23 18:18:14 UTC (rev 101338)
@@ -27,6 +27,8 @@
import java.io.InputStream;
/**
+ * EJB3 VFS2 adapter VirtualFile implementation
+ *
* @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
*/
public class VirtualFileWrapper implements VirtualFile
@@ -45,6 +47,12 @@
}
@Override
+ public String getPathName()
+ {
+ return delegate.getPathName();
+ }
+
+ @Override
public VirtualFile getParent() throws IOException
{
return new VirtualFileWrapper(delegate.getParent());
@@ -61,4 +69,9 @@
{
return delegate.openStream();
}
+
+ public org.jboss.virtual.VirtualFile getWrapped()
+ {
+ return delegate;
+ }
}
Added: projects/ejb3/components/vfs/trunk/impl-vfs2/src/main/resources/META-INF/services/org.jboss.ejb3.vfs.spi.UnifiedVirtualFileFactory
===================================================================
--- projects/ejb3/components/vfs/trunk/impl-vfs2/src/main/resources/META-INF/services/org.jboss.ejb3.vfs.spi.UnifiedVirtualFileFactory (rev 0)
+++ projects/ejb3/components/vfs/trunk/impl-vfs2/src/main/resources/META-INF/services/org.jboss.ejb3.vfs.spi.UnifiedVirtualFileFactory 2010-02-23 18:18:14 UTC (rev 101338)
@@ -0,0 +1 @@
+org.jboss.ejb3.vfs.impl.vfs2.UnifiedVirtualFileFactoryImpl
\ No newline at end of file
Added: projects/ejb3/components/vfs/trunk/impl-vfs2/src/test/java/org/jboss/test/ejb3/vfs/impl/vfs2/UnifiedVirtualFileFactoryImplUnitTest.java
===================================================================
--- projects/ejb3/components/vfs/trunk/impl-vfs2/src/test/java/org/jboss/test/ejb3/vfs/impl/vfs2/UnifiedVirtualFileFactoryImplUnitTest.java (rev 0)
+++ projects/ejb3/components/vfs/trunk/impl-vfs2/src/test/java/org/jboss/test/ejb3/vfs/impl/vfs2/UnifiedVirtualFileFactoryImplUnitTest.java 2010-02-23 18:18:14 UTC (rev 101338)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, 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.test.ejb3.vfs.impl.vfs2;
+
+import org.jboss.ejb3.vfs.impl.vfs2.UnifiedVirtualFileFactoryImpl;
+import org.jboss.ejb3.vfs.impl.vfs2.VirtualFileWrapper;
+import org.jboss.ejb3.vfs.spi.UnifiedVirtualFileFactory;
+import org.jboss.ejb3.vfs.spi.VirtualFile;
+import org.jboss.metadata.serviceref.VirtualFileAdaptor;
+import org.jboss.test.BaseTestCase;
+import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
+
+/**
+ * TestCase to verify the functionality of the {@link UnifiedVirtualFileFactoryImpl}.
+ *
+ * @author John Bailey
+ */
+public class UnifiedVirtualFileFactoryImplUnitTest extends BaseTestCase
+{
+ public UnifiedVirtualFileFactoryImplUnitTest(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Test to verify the {@link UnifiedVirtualFileFactory} correctly finds the
+ * VFS2 impl service reference.
+ */
+ public void testGetInstance() throws Exception
+ {
+ final UnifiedVirtualFileFactory factory = UnifiedVirtualFileFactory.getInstance();
+ assertTrue(factory instanceof UnifiedVirtualFileFactoryImpl);
+ }
+
+ /**
+ * Test to verify the {@link UnifiedVirtualFileFactory} correctly builds {@link UnifiedVirtualFile}
+ * instances from a {@link VirtualFile} instance;
+ */
+ public void testCreate() throws Exception
+ {
+ final VirtualFile virtualFile = new VirtualFileWrapper(null);
+ final UnifiedVirtualFile unifiedVirtualFile = UnifiedVirtualFileFactory.getInstance().create(virtualFile);
+ assertNotNull(unifiedVirtualFile);
+ assertTrue(unifiedVirtualFile instanceof VirtualFileAdaptor);
+ }
+}
Added: projects/ejb3/components/vfs/trunk/impl-vfs2/src/test/java/org/jboss/test/ejb3/vfs/impl/vfs2/VirtualFileFilterUnitTest.java
===================================================================
--- projects/ejb3/components/vfs/trunk/impl-vfs2/src/test/java/org/jboss/test/ejb3/vfs/impl/vfs2/VirtualFileFilterUnitTest.java (rev 0)
+++ projects/ejb3/components/vfs/trunk/impl-vfs2/src/test/java/org/jboss/test/ejb3/vfs/impl/vfs2/VirtualFileFilterUnitTest.java 2010-02-23 18:18:14 UTC (rev 101338)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, 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.test.ejb3.vfs.impl.vfs2;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.List;
+
+import org.jboss.ejb3.vfs.impl.vfs2.VirtualFileFilterAdapter;
+import org.jboss.ejb3.vfs.spi.VirtualFileFilter;
+import org.jboss.test.BaseTestCase;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VisitorAttributes;
+import org.jboss.virtual.plugins.vfs.helpers.FilterVirtualFileVisitor;
+
+/**
+ * Test to verify the {@link VirtualFileFilterAdapter} correctly delegates to the {@link VirtualFileFilter}
+ * defined in the VFS2 abstraction.
+ *
+ * @author John Bailey
+ *
+ */
+public class VirtualFileFilterUnitTest extends BaseTestCase
+{
+ public VirtualFileFilterUnitTest(String name)
+ {
+ super(name);
+ }
+
+ public void testFilterAdapter() throws Exception
+ {
+ final VirtualFileFilter filter = getFilter();
+ final VirtualFileFilterAdapter filterAdapter = new VirtualFileFilterAdapter(filter);
+ final VirtualFile virtuFile = getRoot();
+ final FilterVirtualFileVisitor visitor = new FilterVirtualFileVisitor(filterAdapter, VisitorAttributes.RECURSE_LEAVES_ONLY);
+ virtuFile.visit(visitor);
+
+ final List<VirtualFile> matched = visitor.getMatched();
+
+ assertEquals(4, matched.size());
+ }
+
+ private VirtualFileFilter getFilter()
+ {
+ return new VirtualFileFilter()
+ {
+ @Override
+ public boolean accepts(org.jboss.ejb3.vfs.spi.VirtualFile file)
+ {
+ try {
+ return file.isLeaf() && file.getName().startsWith("test");
+ }
+ catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ };
+ }
+
+ private VirtualFile getRoot() throws Exception
+ {
+ VFS.init();
+ final URL url = getResource("/vfs");
+ final VirtualFile root = VFS.createNewRoot(url);
+ return root;
+ }
+}
Added: projects/ejb3/components/vfs/trunk/impl-vfs2/src/test/resources/vfs/other.txt
===================================================================
Added: projects/ejb3/components/vfs/trunk/impl-vfs2/src/test/resources/vfs/test/other.txt
===================================================================
Added: projects/ejb3/components/vfs/trunk/impl-vfs2/src/test/resources/vfs/test/test.txt
===================================================================
Added: projects/ejb3/components/vfs/trunk/impl-vfs2/src/test/resources/vfs/test/test.xml
===================================================================
Added: projects/ejb3/components/vfs/trunk/impl-vfs2/src/test/resources/vfs/test.txt
===================================================================
Added: projects/ejb3/components/vfs/trunk/impl-vfs2/src/test/resources/vfs/test.xml
===================================================================
Modified: projects/ejb3/components/vfs/trunk/impl-vfs3/pom.xml
===================================================================
--- projects/ejb3/components/vfs/trunk/impl-vfs3/pom.xml 2010-02-23 17:09:39 UTC (rev 101337)
+++ projects/ejb3/components/vfs/trunk/impl-vfs3/pom.xml 2010-02-23 18:18:14 UTC (rev 101338)
@@ -8,7 +8,7 @@
<!-- Define Parent -->
<parent>
<groupId>org.jboss.ejb3.vfs</groupId>
- <artifactId>vfs-build</artifactId>
+ <artifactId>jboss-ejb3-vfs-build</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../build/pom.xml</relativePath>
</parent>
@@ -17,7 +17,7 @@
<modelVersion>4.0.0</modelVersion>
<!-- Artifact Information -->
- <artifactId>vfs-impl-vfs3</artifactId>
+ <artifactId>jboss-ejb3-vfs-impl-vfs3</artifactId>
<packaging>jar</packaging>
<name>JBoss EJB 3.x VFS Abstraction Implementation for JBoss VFS3</name>
<description>JBoss EJB 3.x Virtual File System Abstraction Implementation for JBoss VFS3</description>
@@ -29,23 +29,34 @@
</build>
<properties>
-
<!-- Versioning -->
-
-
+ <version.jboss.vfs>3.0.0.CR1</version.jboss.vfs>
+ <version.jboss.metadata.common>2.0.0.Alpha11</version.jboss.metadata.common>
+ <version.jboss.test>1.1.4.GA</version.jboss.test>
</properties>
<dependencies>
<dependency>
+ <groupId>org.jboss.ejb3.vfs</groupId>
+ <artifactId>vfs-spi</artifactId>
+ <version>${version}</version>
+ </dependency>
+ <dependency>
<groupId>org.jboss</groupId>
<artifactId>jboss-vfs</artifactId>
- <version>3.0.0.CR1-SNAPSHOT</version>
+ <version>${version.jboss.vfs}</version>
</dependency>
-
<dependency>
- <groupId>org.jboss.ejb3.vfs</groupId>
- <artifactId>vfs-spi</artifactId>
- <version>${version}</version>
+ <groupId>org.jboss.metadata</groupId>
+ <artifactId>jboss-metadata-common</artifactId>
+ <version>${version.jboss.metadata.common}</version>
</dependency>
+ <dependency>
+ <groupId>org.jboss.test</groupId>
+ <artifactId>jboss-test</artifactId>
+ <version>${version.jboss.test}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
+
</project>
Added: projects/ejb3/components/vfs/trunk/impl-vfs3/src/main/java/org/jboss/ejb3/vfs/impl/vfs3/UnifiedVirtualFileFactoryImpl.java
===================================================================
--- projects/ejb3/components/vfs/trunk/impl-vfs3/src/main/java/org/jboss/ejb3/vfs/impl/vfs3/UnifiedVirtualFileFactoryImpl.java (rev 0)
+++ projects/ejb3/components/vfs/trunk/impl-vfs3/src/main/java/org/jboss/ejb3/vfs/impl/vfs3/UnifiedVirtualFileFactoryImpl.java 2010-02-23 18:18:14 UTC (rev 101338)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, 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.ejb3.vfs.impl.vfs3;
+
+import org.jboss.ejb3.vfs.spi.VirtualFile;
+import org.jboss.ejb3.vfs.spi.UnifiedVirtualFileFactory;
+import org.jboss.metadata.serviceref.VirtualFileAdaptor;
+import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
+
+/**
+ * {@link UnifiedVirtualFileFactory} implementation for VFS3
+ *
+ * @author John Bailey
+ */
+public class UnifiedVirtualFileFactoryImpl extends UnifiedVirtualFileFactory
+{
+ @Override
+ public UnifiedVirtualFile create(VirtualFile virtualFile)
+ {
+ if(virtualFile instanceof VirtualFileWrapper)
+ return new VirtualFileAdaptor(((VirtualFileWrapper) virtualFile).getWrapped());
+ return null;
+ }
+}
Modified: projects/ejb3/components/vfs/trunk/impl-vfs3/src/main/java/org/jboss/ejb3/vfs/impl/vfs3/VirtualFileFilterAdapter.java
===================================================================
--- projects/ejb3/components/vfs/trunk/impl-vfs3/src/main/java/org/jboss/ejb3/vfs/impl/vfs3/VirtualFileFilterAdapter.java 2010-02-23 17:09:39 UTC (rev 101337)
+++ projects/ejb3/components/vfs/trunk/impl-vfs3/src/main/java/org/jboss/ejb3/vfs/impl/vfs3/VirtualFileFilterAdapter.java 2010-02-23 18:18:14 UTC (rev 101338)
@@ -31,14 +31,14 @@
public class VirtualFileFilterAdapter implements VirtualFileFilter
{
/* EJB3 VFS Abstraction Filter */
- private final org.jboss.virtual.VirtualFileFilter delegate;
+ private final org.jboss.ejb3.vfs.spi.VirtualFileFilter delegate;
/**
* Constructs a new instance with a VFS abstract VirtualFileFilter
*
* @param delegate
*/
- public VirtualFileFilterAdapter(org.jboss.virtual.VirtualFileFilter delegate)
+ public VirtualFileFilterAdapter(org.jboss.ejb3.vfs.spi.VirtualFileFilter delegate)
{
this.delegate = delegate;
}
Modified: projects/ejb3/components/vfs/trunk/impl-vfs3/src/main/java/org/jboss/ejb3/vfs/impl/vfs3/VirtualFileWrapper.java
===================================================================
--- projects/ejb3/components/vfs/trunk/impl-vfs3/src/main/java/org/jboss/ejb3/vfs/impl/vfs3/VirtualFileWrapper.java 2010-02-23 17:09:39 UTC (rev 101337)
+++ projects/ejb3/components/vfs/trunk/impl-vfs3/src/main/java/org/jboss/ejb3/vfs/impl/vfs3/VirtualFileWrapper.java 2010-02-23 18:18:14 UTC (rev 101338)
@@ -21,17 +21,17 @@
*/
package org.jboss.ejb3.vfs.impl.vfs3;
-import org.jboss.virtual.VirtualFile;
-
import java.io.IOException;
import java.io.InputStream;
+import org.jboss.ejb3.vfs.spi.VirtualFile;
+
/**
- * EJB VFS adapter VirtualFile implementation
+ * EJB3 VFS3 adapter VirtualFile implementation
*
* @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
*/
-public class VirtualFileWrapper extends VirtualFile
+public class VirtualFileWrapper implements VirtualFile
{
/* VFS3 VirtualFile being wrapped */
private org.jboss.vfs.VirtualFile delegate;
@@ -53,6 +53,12 @@
}
@Override
+ public String getPathName()
+ {
+ return delegate.getPathName();
+ }
+
+ @Override
public VirtualFile getParent() throws IOException
{
return new VirtualFileWrapper(delegate.getParent());
@@ -61,7 +67,7 @@
@Override
public boolean isLeaf() throws IOException
{
- return delegate.isLeaf();
+ return delegate.isFile();
}
@Override
@@ -70,7 +76,6 @@
return delegate.openStream();
}
- @Override
public org.jboss.vfs.VirtualFile getWrapped()
{
return delegate;
Deleted: projects/ejb3/components/vfs/trunk/impl-vfs3/src/main/java/org/jboss/virtual/VirtualFile.java
===================================================================
--- projects/ejb3/components/vfs/trunk/impl-vfs3/src/main/java/org/jboss/virtual/VirtualFile.java 2010-02-23 17:09:39 UTC (rev 101337)
+++ projects/ejb3/components/vfs/trunk/impl-vfs3/src/main/java/org/jboss/virtual/VirtualFile.java 2010-02-23 18:18:14 UTC (rev 101338)
@@ -1,45 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright (c) 2010, 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.virtual;
-
-import java.io.IOException;
-
-/**
- * Temporary VirtualFile interface which matches the legacy VFS3 interface.
- *
- * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
- */
- at Deprecated
-public abstract class VirtualFile implements org.jboss.ejb3.vfs.spi.VirtualFile
-{
- /**
- * Get the parent VirtualFile
- */
- public abstract VirtualFile getParent() throws IOException;
-
- /**
- * Returns the wrapped VirtualFile instance
- *
- * @return wrapped VirtualFile
- */
- public abstract org.jboss.vfs.VirtualFile getWrapped();
-}
Deleted: projects/ejb3/components/vfs/trunk/impl-vfs3/src/main/java/org/jboss/virtual/VirtualFileFilter.java
===================================================================
--- projects/ejb3/components/vfs/trunk/impl-vfs3/src/main/java/org/jboss/virtual/VirtualFileFilter.java 2010-02-23 17:09:39 UTC (rev 101337)
+++ projects/ejb3/components/vfs/trunk/impl-vfs3/src/main/java/org/jboss/virtual/VirtualFileFilter.java 2010-02-23 18:18:14 UTC (rev 101338)
@@ -1,43 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright (c) 2010, 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.virtual;
-
-import org.jboss.virtual.VirtualFile;
-
-/**
- * VirtualFileFilter matching the VFS2 interface. Should be removed
- * when the full VFS abstraction layer is in place.
- *
- * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
- */
- at Deprecated
-public interface VirtualFileFilter
-{
- /**
- * Match the virtual file
- *
- * @param file the virtual file
- *
- * @return true when it matches
- */
- boolean accepts(VirtualFile file);
-}
Added: projects/ejb3/components/vfs/trunk/impl-vfs3/src/main/resources/META-INF/services/org.jboss.ejb3.vfs.spi.UnifiedVirtualFileFactory
===================================================================
--- projects/ejb3/components/vfs/trunk/impl-vfs3/src/main/resources/META-INF/services/org.jboss.ejb3.vfs.spi.UnifiedVirtualFileFactory (rev 0)
+++ projects/ejb3/components/vfs/trunk/impl-vfs3/src/main/resources/META-INF/services/org.jboss.ejb3.vfs.spi.UnifiedVirtualFileFactory 2010-02-23 18:18:14 UTC (rev 101338)
@@ -0,0 +1 @@
+org.jboss.ejb3.vfs.impl.vfs3.UnifiedVirtualFileFactoryImpl
\ No newline at end of file
Added: projects/ejb3/components/vfs/trunk/impl-vfs3/src/test/java/org/jboss/test/ejb3/vfs/impl/vfs3/UnifiedVirtualFileFactoryImplUnitTest.java
===================================================================
--- projects/ejb3/components/vfs/trunk/impl-vfs3/src/test/java/org/jboss/test/ejb3/vfs/impl/vfs3/UnifiedVirtualFileFactoryImplUnitTest.java (rev 0)
+++ projects/ejb3/components/vfs/trunk/impl-vfs3/src/test/java/org/jboss/test/ejb3/vfs/impl/vfs3/UnifiedVirtualFileFactoryImplUnitTest.java 2010-02-23 18:18:14 UTC (rev 101338)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, 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.test.ejb3.vfs.impl.vfs3;
+
+import org.jboss.ejb3.vfs.impl.vfs3.UnifiedVirtualFileFactoryImpl;
+import org.jboss.ejb3.vfs.impl.vfs3.VirtualFileWrapper;
+import org.jboss.ejb3.vfs.spi.UnifiedVirtualFileFactory;
+import org.jboss.ejb3.vfs.spi.VirtualFile;
+import org.jboss.metadata.serviceref.VirtualFileAdaptor;
+import org.jboss.test.BaseTestCase;
+import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
+
+/**
+ * TestCase to verify the functionality of the {@link UnifiedVirtualFileFactoryImpl}.
+ *
+ * @author John Bailey
+ */
+public class UnifiedVirtualFileFactoryImplUnitTest extends BaseTestCase
+{
+ public UnifiedVirtualFileFactoryImplUnitTest(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Test to verify the {@link UnifiedVirtualFileFactory} correctly finds the
+ * VFS3 impl service reference.
+ */
+ public void testGetInstance() throws Exception
+ {
+ final UnifiedVirtualFileFactory factory = UnifiedVirtualFileFactory.getInstance();
+ assertTrue(factory instanceof UnifiedVirtualFileFactoryImpl);
+ }
+
+ /**
+ * Test to verify the {@link UnifiedVirtualFileFactory} correctly builds {@link UnifiedVirtualFile}
+ * instances from a {@link VirtualFile} instance;
+ */
+ public void testCreate() throws Exception
+ {
+ final VirtualFile virtualFile = new VirtualFileWrapper(null);
+ final UnifiedVirtualFile unifiedVirtualFile = UnifiedVirtualFileFactory.getInstance().create(virtualFile);
+ assertNotNull(unifiedVirtualFile);
+ assertTrue(unifiedVirtualFile instanceof VirtualFileAdaptor);
+ }
+}
Added: projects/ejb3/components/vfs/trunk/impl-vfs3/src/test/java/org/jboss/test/ejb3/vfs/impl/vfs3/VirtualFileFilterUnitTest.java
===================================================================
--- projects/ejb3/components/vfs/trunk/impl-vfs3/src/test/java/org/jboss/test/ejb3/vfs/impl/vfs3/VirtualFileFilterUnitTest.java (rev 0)
+++ projects/ejb3/components/vfs/trunk/impl-vfs3/src/test/java/org/jboss/test/ejb3/vfs/impl/vfs3/VirtualFileFilterUnitTest.java 2010-02-23 18:18:14 UTC (rev 101338)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, 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.test.ejb3.vfs.impl.vfs3;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.List;
+
+import org.jboss.ejb3.vfs.impl.vfs3.VirtualFileFilterAdapter;
+import org.jboss.ejb3.vfs.spi.VirtualFileFilter;
+import org.jboss.test.BaseTestCase;
+import org.jboss.vfs.VFS;
+import org.jboss.vfs.VirtualFile;
+import org.jboss.vfs.VisitorAttributes;
+import org.jboss.vfs.util.FilterVirtualFileVisitor;
+
+/**
+ * Test to verify the {@link VirtualFileFilterAdapter} correctly delegates to the {@link VirtualFileFilter}
+ * defined in the VFS3 abstraction.
+ *
+ * @author John Bailey
+ *
+ */
+public class VirtualFileFilterUnitTest extends BaseTestCase
+{
+ public VirtualFileFilterUnitTest(String name)
+ {
+ super(name);
+ }
+
+ public void testFilterAdapter() throws Exception
+ {
+ final VirtualFileFilter filter = getFilter();
+ final VirtualFileFilterAdapter filterAdapter = new VirtualFileFilterAdapter(filter);
+ final VirtualFile virtuFile = getRoot();
+ final FilterVirtualFileVisitor visitor = new FilterVirtualFileVisitor(filterAdapter, VisitorAttributes.RECURSE_LEAVES_ONLY);
+ virtuFile.visit(visitor);
+
+ final List<VirtualFile> matched = visitor.getMatched();
+
+ assertEquals(4, matched.size());
+ }
+
+ private VirtualFileFilter getFilter()
+ {
+ return new VirtualFileFilter()
+ {
+ @Override
+ public boolean accepts(org.jboss.ejb3.vfs.spi.VirtualFile file)
+ {
+ try {
+ return file.isLeaf() && file.getName().startsWith("test");
+ }
+ catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ };
+ }
+
+ private VirtualFile getRoot() throws Exception
+ {
+ final URL url = getResource("/vfs");
+ final VirtualFile root = VFS.getChild(url);
+ return root;
+ }
+}
Added: projects/ejb3/components/vfs/trunk/impl-vfs3/src/test/resources/vfs/other.txt
===================================================================
Added: projects/ejb3/components/vfs/trunk/impl-vfs3/src/test/resources/vfs/test/other.txt
===================================================================
Added: projects/ejb3/components/vfs/trunk/impl-vfs3/src/test/resources/vfs/test/test.txt
===================================================================
Added: projects/ejb3/components/vfs/trunk/impl-vfs3/src/test/resources/vfs/test/test.xml
===================================================================
Added: projects/ejb3/components/vfs/trunk/impl-vfs3/src/test/resources/vfs/test.txt
===================================================================
Added: projects/ejb3/components/vfs/trunk/impl-vfs3/src/test/resources/vfs/test.xml
===================================================================
Modified: projects/ejb3/components/vfs/trunk/spi/pom.xml
===================================================================
--- projects/ejb3/components/vfs/trunk/spi/pom.xml 2010-02-23 17:09:39 UTC (rev 101337)
+++ projects/ejb3/components/vfs/trunk/spi/pom.xml 2010-02-23 18:18:14 UTC (rev 101338)
@@ -8,7 +8,7 @@
<!-- Define Parent -->
<parent>
<groupId>org.jboss.ejb3.vfs</groupId>
- <artifactId>vfs-build</artifactId>
+ <artifactId>jboss-ejb3-vfs-build</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../build/pom.xml</relativePath>
</parent>
@@ -17,7 +17,7 @@
<modelVersion>4.0.0</modelVersion>
<!-- Artifact Information -->
- <artifactId>vfs-spi</artifactId>
+ <artifactId>jboss-ejb3-vfs-spi</artifactId>
<packaging>jar</packaging>
<name>JBoss EJB 3.x VFS Abstraction SPI</name>
<description>JBoss EJB 3.x Virtual File System Abstraction Service Provider Interface</description>
@@ -31,9 +31,10 @@
<properties>
<!-- Versioning -->
-
+
- </properties>
+ <version.jbossws.spi>1.0.3.GA</version.jbossws.spi>
+ </properties>
<dependencies>
@@ -45,6 +46,11 @@
<!--
Dependencies: External to EJB3
-->
+ <dependency>
+ <groupId>org.jboss.ws</groupId>
+ <artifactId>jbossws-spi</artifactId>
+ <version>${version.jbossws.spi}</version>
+ </dependency>
</dependencies>
</project>
Added: projects/ejb3/components/vfs/trunk/spi/src/main/java/org/jboss/ejb3/vfs/spi/UnifiedVirtualFileFactory.java
===================================================================
--- projects/ejb3/components/vfs/trunk/spi/src/main/java/org/jboss/ejb3/vfs/spi/UnifiedVirtualFileFactory.java (rev 0)
+++ projects/ejb3/components/vfs/trunk/spi/src/main/java/org/jboss/ejb3/vfs/spi/UnifiedVirtualFileFactory.java 2010-02-23 18:18:14 UTC (rev 101338)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, 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.ejb3.vfs.spi;
+
+import java.util.Iterator;
+
+import org.jboss.ejb3.vfs.spi.util.ServiceLoader;
+import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
+
+/**
+ * Factory used to create {@link UnifiedVirtualFile} instances from a {@link VirtualFile}.
+ *
+ * @author John Bailey
+ */
+public abstract class UnifiedVirtualFileFactory
+{
+ /**
+ * Get a factory instance.
+ *
+ * @return factory instance
+ */
+ public static UnifiedVirtualFileFactory getInstance() {
+ ServiceLoader<UnifiedVirtualFileFactory> factoryLoader = ServiceLoader.load(UnifiedVirtualFileFactory.class);
+
+ Iterator<UnifiedVirtualFileFactory> factoryIterator = factoryLoader.iterator();
+
+ UnifiedVirtualFileFactory factory = null;
+ if(factoryIterator.hasNext())
+ {
+ factory = factoryIterator.next();
+ if(factoryIterator.hasNext())
+ {
+ throw new RuntimeException("More the one service found found for " + UnifiedVirtualFileFactory.class + ", please ensure only one factory implementation is found on the classpath.");
+ }
+ }
+ else
+ {
+ throw new RuntimeException("No service found for " + UnifiedVirtualFileFactory.class);
+ }
+
+ return factory;
+ }
+
+ /**
+ * Create a {@link UnifiedVirtualFile} instance from a provided {@link VirtualFile}
+ *
+ * @param virtualFile VirtualFile to {@link VirtualFileAdaptor} from
+ * @return the {@link UnifiedVirtualFile}
+ */
+ public abstract UnifiedVirtualFile create(VirtualFile virtualFile);
+}
Modified: projects/ejb3/components/vfs/trunk/spi/src/main/java/org/jboss/ejb3/vfs/spi/VirtualFile.java
===================================================================
--- projects/ejb3/components/vfs/trunk/spi/src/main/java/org/jboss/ejb3/vfs/spi/VirtualFile.java 2010-02-23 17:09:39 UTC (rev 101337)
+++ projects/ejb3/components/vfs/trunk/spi/src/main/java/org/jboss/ejb3/vfs/spi/VirtualFile.java 2010-02-23 18:18:14 UTC (rev 101338)
@@ -25,15 +25,19 @@
import java.io.InputStream;
/**
+ * VirtualFile abstraction
+ *
* @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
*/
public interface VirtualFile
{
String getName();
+ String getPathName();
+
VirtualFile getParent() throws IOException;
-
+
boolean isLeaf() throws IOException;
-
+
InputStream openStream() throws IOException;
}
Added: projects/ejb3/components/vfs/trunk/spi/src/main/java/org/jboss/ejb3/vfs/spi/VirtualFileFilter.java
===================================================================
--- projects/ejb3/components/vfs/trunk/spi/src/main/java/org/jboss/ejb3/vfs/spi/VirtualFileFilter.java (rev 0)
+++ projects/ejb3/components/vfs/trunk/spi/src/main/java/org/jboss/ejb3/vfs/spi/VirtualFileFilter.java 2010-02-23 18:18:14 UTC (rev 101338)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, 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.ejb3.vfs.spi;
+
+/**
+ * VirtualFileFilter matching the VFS2 interface. Should be removed
+ * when the full VFS abstraction layer is in place.
+ *
+ * @author John Bailey
+ */
+public interface VirtualFileFilter
+{
+ /**
+ * Match the virtual file
+ *
+ * @param file the virtual file
+ *
+ * @return true when it matches
+ */
+ boolean accepts(VirtualFile file);
+}
Added: projects/ejb3/components/vfs/trunk/spi/src/main/java/org/jboss/ejb3/vfs/spi/util/ServiceLoader.java
===================================================================
--- projects/ejb3/components/vfs/trunk/spi/src/main/java/org/jboss/ejb3/vfs/spi/util/ServiceLoader.java (rev 0)
+++ projects/ejb3/components/vfs/trunk/spi/src/main/java/org/jboss/ejb3/vfs/spi/util/ServiceLoader.java 2010-02-23 18:18:14 UTC (rev 101338)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.ejb3.vfs.spi.util;
+
+import java.util.Iterator;
+
+import javax.imageio.spi.ServiceRegistry;
+
+
+/**
+ * Service loader following the API from http://java.sun.com/javase/6/docs/api/java/util/ServiceLoader.html which is compatible with JDK 5.
+ *
+ * @author John Bailey
+ * @param <S> the service
+ */
+public class ServiceLoader<S> implements Iterable<S>
+{
+ /**
+ * @See <a href="http://java.sun.com/javase/6/docs/api/java/util/ServiceLoader.html#load%28java.lang.Class%29">ServiceLoader.load(Class)</a>
+ */
+ public static <S> ServiceLoader<S> load(Class<S> serviceClass)
+ {
+ return load(serviceClass, Thread.currentThread().getContextClassLoader());
+ }
+
+ /**
+ * @See <a href="http://java.sun.com/javase/6/docs/api/java/util/ServiceLoader.html#load%28java.lang.Class,%20java.lang.ClassLoader%29">ServiceLoader.load(Class, ClassL oader)</a>
+ */
+ public static <S> ServiceLoader<S> load(Class<S> service, ClassLoader loader)
+ {
+ return new ServiceLoader<S>(service, loader);
+ }
+
+ private final Class<S> serviceClass;
+ private final ClassLoader loader;
+ private Iterator<S> serviceIterator;
+
+ /**
+ * ServiceLoader constructor
+ * @param serviceClass the service class
+ * @param loader classloader to load service from
+ */
+ private ServiceLoader(Class<S> serviceClass, ClassLoader loader)
+ {
+ this.serviceClass = serviceClass;
+ this.loader = loader;
+ reload();
+ }
+
+ /**
+ * @See <a href="http://java.sun.com/javase/6/docs/api/java/util/ServiceLoader.html#iterator%28%29">ServiceLoader.iterator</a>
+ */
+ public Iterator<S> iterator()
+ {
+ return serviceIterator;
+ }
+
+ /**
+ * @See <a href="http://java.sun.com/javase/6/docs/api/java/util/ServiceLoader.html#reload%29">ServiceLoader.reload</a>
+ */
+ public void reload()
+ {
+ serviceIterator = ServiceRegistry.lookupProviders(serviceClass, loader);
+ }
+}
More information about the jboss-cvs-commits
mailing list