Author: thomas.diesler(a)jboss.com
Date: 2010-03-09 01:40:07 -0500 (Tue, 09 Mar 2010)
New Revision: 102111
Modified:
projects/jboss-osgi/projects/vfs/trunk/api/pom.xml
projects/jboss-osgi/projects/vfs/trunk/api/src/main/java/org/jboss/osgi/vfs/VirtualFileAssembly.java
projects/jboss-osgi/projects/vfs/trunk/pom.xml
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/VirtualFileAdaptor21.java
projects/jboss-osgi/projects/vfs/trunk/vfs30/pom.xml
projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VirtualFileAdaptor30.java
Log:
wip
Modified: projects/jboss-osgi/projects/vfs/trunk/api/pom.xml
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/api/pom.xml 2010-03-09 06:16:57 UTC (rev
102110)
+++ projects/jboss-osgi/projects/vfs/trunk/api/pom.xml 2010-03-09 06:40:07 UTC (rev
102111)
@@ -28,4 +28,17 @@
<version>1.0.0-SNAPSHOT</version>
</parent>
+ <!-- Properties -->
+ <properties>
+ <version.osgi>4.2.0</version.osgi>
+ </properties>
+
+ <!-- Dependencies -->
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>${version.osgi}</version>
+ </dependency>
+ </dependencies>
</project>
Modified:
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 2010-03-09
06:16:57 UTC (rev 102110)
+++
projects/jboss-osgi/projects/vfs/trunk/api/src/main/java/org/jboss/osgi/vfs/VirtualFileAssembly.java 2010-03-09
06:40:07 UTC (rev 102111)
@@ -21,7 +21,9 @@
*/
package org.jboss.osgi.vfs;
+import java.io.File;
import java.io.IOException;
+import java.util.jar.Manifest;
/**
@@ -35,11 +37,41 @@
public interface VirtualFileAssembly extends VirtualFile
{
/**
+ * Add the given class to the assembly.
+ *
+ * @param clazz The class to add
+ * @throws IOException for any error
+ */
+ void addClass(Class<?> clazz) throws IOException;
+
+ /**
+ * Add the given package to the assembly.
+ *
+ * @param clazz The package to add
+ * @throws IOException for any error
+ */
+ void addPackage(Class<?> clazz) throws IOException;
+
+ /**
+ * Pack this assembly into a jar file.
+ * @throws IOException for any error
+ */
+ File pack() throws IOException;
+
+ /**
+ * Add the given manifest to the assembly
+ * @param manifest The manifest to add
+ * @throws IOException for any error
+ */
+ void addManifest(Manifest manifest) throws IOException;
+
+ /**
* Add files recursively from root, using the no jars filter.
*
* @param root the root
* @throws IOException for any error
*/
+ @Deprecated
void addPath(VirtualFile file) throws IOException;
/**
@@ -56,5 +88,6 @@
* @param includes the includes
* @param excludes the excludes
*/
+ @Deprecated
void addResources(Class<?> reference, String[] includes, String[] excludes);
}
Modified: projects/jboss-osgi/projects/vfs/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/pom.xml 2010-03-09 06:16:57 UTC (rev 102110)
+++ projects/jboss-osgi/projects/vfs/trunk/pom.xml 2010-03-09 06:40:07 UTC (rev 102111)
@@ -30,6 +30,13 @@
<version>1.0.5-SNAPSHOT</version>
</parent>
+ <!-- Modules -->
+ <modules>
+ <module>api</module>
+ <module>vfs21</module>
+ <module>vfs30</module>
+ </modules>
+
<!-- Subversion -->
<scm>
<
connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jbo...
@@ -37,10 +44,4 @@
<
url>http://fisheye.jboss.com/qsearch/JBossOSGi</url>
</scm>
- <modules>
- <module>api</module>
- <module>vfs21</module>
- <module>vfs30</module>
- </modules>
-
</project>
Modified:
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 2010-03-09
06:16:57 UTC (rev 102110)
+++
projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/AssemblyAdaptor21.java 2010-03-09
06:40:07 UTC (rev 102111)
@@ -21,12 +21,22 @@
*/
package org.jboss.osgi.vfs21;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.List;
+import java.util.jar.JarFile;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
import org.jboss.osgi.vfs.VirtualFile;
import org.jboss.osgi.vfs.VirtualFileAssembly;
import org.jboss.virtual.AssembledDirectory;
+import org.jboss.virtual.VFS;
/**
* An adaptor to the jboss-vfs-2.1.x VirtualFile.
@@ -44,6 +54,49 @@
this.delegate = assembly;
}
+ public void addClass(Class<?> clazz) throws IOException
+ {
+ delegate.addClass(clazz);
+ }
+
+ public void addPackage(Class<?> clazz) throws IOException
+ {
+ ClassLoader loader = clazz.getClassLoader();
+ String packageName = clazz.getName().replace('.', '/');
+ packageName = packageName.substring(0, packageName.lastIndexOf('/'));
+
+ URL rootURL = loader.getResource(packageName);
+ for (org.jboss.virtual.VirtualFile child : VFS.getRoot(rootURL).getChildren())
+ {
+ if (child.getName().endsWith(".class"))
+ delegate.addChild(child);
+ }
+ }
+
+ public void addManifest(Manifest manifest) throws IOException
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ manifest.write(baos);
+ AssembledDirectory dir = delegate.mkdir("META-INF");
+ dir.addBytes(baos.toByteArray(), "MANIFEST.MF");
+ }
+
+ public File pack() throws IOException
+ {
+ File tmpFile = File.createTempFile("assembly", ".jar");
+ tmpFile.deleteOnExit();
+
+ FileOutputStream fos = new FileOutputStream(tmpFile);
+ JarOutputStream jos = new JarOutputStream(fos);
+ for (org.jboss.virtual.VirtualFile child : delegate.getChildrenRecursively())
+ {
+ ZipEntry ze = new ZipEntry(child.getName());
+ jos.putNextEntry(ze);
+
+ }
+ return null;
+ }
+
public void addPath(VirtualFile file) throws IOException
{
delegate.addPath(((VirtualFileAdaptor21)file).getDelegate());
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-09
06:16:57 UTC (rev 102110)
+++
projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/VirtualFileAdaptor21.java 2010-03-09
06:40:07 UTC (rev 102111)
@@ -45,6 +45,8 @@
VirtualFileAdaptor21(org.jboss.virtual.VirtualFile delegate)
{
+ if (delegate == null)
+ throw new IllegalStateException("Null delegate");
this.delegate = delegate;
}
@@ -133,4 +135,22 @@
{
return delegate.openStream();
}
+
+ @Override
+ public int hashCode()
+ {
+ return delegate.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ return delegate.equals(obj);
+ }
+
+ @Override
+ public String toString()
+ {
+ return delegate.toString();
+ }
}
Modified: projects/jboss-osgi/projects/vfs/trunk/vfs30/pom.xml
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/vfs30/pom.xml 2010-03-09 06:16:57 UTC (rev
102110)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs30/pom.xml 2010-03-09 06:40:07 UTC (rev
102111)
@@ -30,7 +30,7 @@
<!-- Properties -->
<properties>
- <version.jboss.vfs>3.0.0.CR3</version.jboss.vfs>
+ <version.jboss.vfs>3.0.0-SNAPSHOT</version.jboss.vfs>
</properties>
<!-- Dependencies -->
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-09
06:16:57 UTC (rev 102110)
+++
projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VirtualFileAdaptor30.java 2010-03-09
06:40:07 UTC (rev 102111)
@@ -46,6 +46,8 @@
VirtualFileAdaptor30(org.jboss.vfs.VirtualFile delegate)
{
+ if (delegate == null)
+ throw new IllegalStateException("Null delegate");
this.delegate = delegate;
}