JBoss-OSGI SVN: r102131 - in projects/jboss-osgi/projects/vfs/trunk: vfs30/src/main/java/org/jboss/osgi/vfs30 and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-09 09:57:53 -0500 (Tue, 09 Mar 2010)
New Revision: 102131
Removed:
projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/AssemblyAdaptor21.java
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/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:
Remove VirtualFileAssembly
Deleted: 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 14:56:02 UTC (rev 102130)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/AssemblyAdaptor21.java 2010-03-09 14:57:53 UTC (rev 102131)
@@ -1,109 +0,0 @@
-/*
-* 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.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.
- *
- * @author thomas.diesler(a)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 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());
- }
-
- 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-09 14:56:02 UTC (rev 102130)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/VFSAdaptor21.java 2010-03-09 14:57:53 UTC (rev 102131)
@@ -22,13 +22,10 @@
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,33 +38,42 @@
public VirtualFile getChild(URL url) throws IOException
{
org.jboss.virtual.VirtualFile root = org.jboss.virtual.VFS.getRoot(url);
- return new VirtualFileAdaptor21(root);
+ return new VirtualFileAdaptor21(root, 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)
return null;
-
+
if (virtualFile instanceof org.jboss.virtual.VirtualFile == false)
throw new IllegalArgumentException("Not a org.jboss.virtual.VirtualFile: " + virtualFile);
+
+ org.jboss.virtual.VirtualFile file = (org.jboss.virtual.VirtualFile)virtualFile;
+ org.jboss.virtual.VirtualFile root = file;
+ try
+ {
+ org.jboss.virtual.VirtualFile parent = file.getParent();
+ while (parent != null)
+ {
+ root = parent;
+ parent = parent.getParent();
+ }
+ }
+ catch (IOException ex)
+ {
+ throw new IllegalStateException("Cannot obtain root", ex);
+ }
- return new VirtualFileAdaptor21((org.jboss.virtual.VirtualFile)virtualFile);
+ return new VirtualFileAdaptor21(root, file);
}
public Object adapt(VirtualFile virtualFile)
{
if (virtualFile == null)
return null;
-
+
VirtualFileAdaptor21 adaptor = (VirtualFileAdaptor21)virtualFile;
return adaptor.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 14:56:02 UTC (rev 102130)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/VirtualFileAdaptor21.java 2010-03-09 14:57:53 UTC (rev 102131)
@@ -32,6 +32,7 @@
import java.util.List;
import org.jboss.osgi.vfs.VirtualFile;
+import org.jboss.virtual.VFSUtils;
/**
* An adaptor to the jboss-vfs-2.1.x VirtualFile.
@@ -41,13 +42,18 @@
*/
class VirtualFileAdaptor21 implements VirtualFile
{
+ private org.jboss.virtual.VirtualFile root;
private org.jboss.virtual.VirtualFile delegate;
- VirtualFileAdaptor21(org.jboss.virtual.VirtualFile delegate)
+ VirtualFileAdaptor21(org.jboss.virtual.VirtualFile root, org.jboss.virtual.VirtualFile delegate)
{
+ if (root == null)
+ throw new IllegalStateException("Null root");
if (delegate == null)
throw new IllegalStateException("Null delegate");
+
this.delegate = delegate;
+ this.root = root;
}
org.jboss.virtual.VirtualFile getDelegate()
@@ -62,7 +68,17 @@
public String getPathName()
{
- return delegate.getPathName();
+ String pathName = "";
+ try
+ {
+ pathName = VFSUtils.getRealURL(root).getPath();
+ }
+ catch (Exception ex)
+ {
+ // ignore
+ }
+ pathName += delegate.getPathName();
+ return pathName;
}
public boolean isFile() throws IOException
@@ -70,6 +86,11 @@
return delegate.isLeaf();
}
+ public boolean isDirectory() throws IOException
+ {
+ return delegate.isLeaf() == false;
+ }
+
public URL toURL() throws MalformedURLException, URISyntaxException
{
return delegate.toURL();
@@ -80,20 +101,26 @@
delegate.close();
}
+ public VirtualFile getParent() throws IOException
+ {
+ org.jboss.virtual.VirtualFile parent = delegate.getParent();
+ return parent != null ? new VirtualFileAdaptor21(root, parent) : null;
+ }
+
public VirtualFile getChild(String path) throws IOException
{
org.jboss.virtual.VirtualFile child = delegate.getChild(path);
if (child == null)
return null;
- return new VirtualFileAdaptor21(child);
+ return new VirtualFileAdaptor21(root, 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));
+ files.add(new VirtualFileAdaptor21(root, child));
return Collections.unmodifiableList(files);
}
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-09 14:56:02 UTC (rev 102130)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSAdaptor30.java 2010-03-09 14:57:53 UTC (rev 102131)
@@ -27,7 +27,6 @@
import org.jboss.osgi.vfs.VFSAdaptor;
import org.jboss.osgi.vfs.VirtualFile;
-import org.jboss.osgi.vfs.VirtualFileAssembly;
import org.jboss.vfs.util.automount.Automounter;
/**
@@ -55,11 +54,6 @@
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)
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 14:56:02 UTC (rev 102130)
+++ projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VirtualFileAdaptor30.java 2010-03-09 14:57:53 UTC (rev 102131)
@@ -71,11 +71,22 @@
return delegate.isFile();
}
+ public boolean isDirectory() throws IOException
+ {
+ return delegate.isDirectory();
+ }
+
public URL toURL() throws MalformedURLException, URISyntaxException
{
return delegate.toURL();
}
+ public VirtualFile getParent()
+ {
+ org.jboss.vfs.VirtualFile parent = delegate.getParent();
+ return parent != null ? new VirtualFileAdaptor30(parent) : null;
+ }
+
public VirtualFile getChild(String path) throws IOException
{
org.jboss.vfs.VirtualFile child = delegate.getChild(path);
@@ -137,4 +148,22 @@
if (Automounter.isMounted(delegate))
Automounter.cleanup(delegate);
}
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ return delegate.equals(obj);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return delegate.hashCode();
+ }
+
+ @Override
+ public String toString()
+ {
+ return delegate.toString();
+ }
}
14 years, 3 months
JBoss-OSGI SVN: r102130 - projects/jboss-osgi/projects/vfs/trunk/api/src/main/java/org/jboss/osgi/vfs.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-09 09:56:02 -0500 (Tue, 09 Mar 2010)
New Revision: 102130
Removed:
projects/jboss-osgi/projects/vfs/trunk/api/src/main/java/org/jboss/osgi/vfs/ManifestBuilder.java
projects/jboss-osgi/projects/vfs/trunk/api/src/main/java/org/jboss/osgi/vfs/VirtualFileAssembly.java
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/VFSAdaptor.java
projects/jboss-osgi/projects/vfs/trunk/api/src/main/java/org/jboss/osgi/vfs/VirtualFile.java
Log:
Remove VirtualFileAssembly
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-09 14:54:52 UTC (rev 102129)
+++ projects/jboss-osgi/projects/vfs/trunk/api/src/main/java/org/jboss/osgi/vfs/AbstractVFS.java 2010-03-09 14:56:02 UTC (rev 102130)
@@ -22,7 +22,6 @@
package org.jboss.osgi.vfs;
import java.io.IOException;
-import java.net.URISyntaxException;
import java.net.URL;
/**
@@ -42,11 +41,6 @@
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);
Deleted: projects/jboss-osgi/projects/vfs/trunk/api/src/main/java/org/jboss/osgi/vfs/ManifestBuilder.java
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/api/src/main/java/org/jboss/osgi/vfs/ManifestBuilder.java 2010-03-09 14:54:52 UTC (rev 102129)
+++ projects/jboss-osgi/projects/vfs/trunk/api/src/main/java/org/jboss/osgi/vfs/ManifestBuilder.java 2010-03-09 14:56:02 UTC (rev 102130)
@@ -1,138 +0,0 @@
-/*
-* 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.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.jar.Attributes;
-import java.util.jar.Manifest;
-
-import org.osgi.framework.Constants;
-
-/**
- * A simple OSGi manifest builder.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 08-Mar-2010
- */
-public final class ManifestBuilder
-{
- private StringWriter sw;
- private PrintWriter pw;
- private List<String> importPackages = new ArrayList<String>();
- private List<String> exportPackages = new ArrayList<String>();
-
- public static ManifestBuilder newInstance()
- {
- return new ManifestBuilder();
- }
-
- private ManifestBuilder()
- {
- sw = new StringWriter();
- pw = new PrintWriter(sw);
- pw.println(Attributes.Name.MANIFEST_VERSION + ": 1.0");
- }
-
- public ManifestBuilder addBundleManifestVersion(int version)
- {
- pw.println(Constants.BUNDLE_MANIFESTVERSION + ": " + version);
- return this;
- }
-
- public ManifestBuilder addBundleSymbolicName(String symbolicName)
- {
- pw.println(Constants.BUNDLE_SYMBOLICNAME + ": " + symbolicName);
- return this;
- }
-
- public ManifestBuilder addBundleActivator(String bundleActivator)
- {
- pw.println(Constants.BUNDLE_ACTIVATOR + ": " + bundleActivator);
- return this;
- }
-
- public ManifestBuilder addImportPackages(String... packages)
- {
- for (String aux : packages)
- importPackages.add(aux);
-
- return this;
- }
-
- public ManifestBuilder addExportPackages(String... packages)
- {
- for (String aux : packages)
- exportPackages.add(aux);
-
- return this;
- }
-
- public ManifestBuilder addManifestHeader(String key, String value)
- {
- pw.println(key + ": " + value);
- return this;
- }
-
- public Manifest getManifest()
- {
- if (exportPackages.size() > 0)
- {
- pw.print(Constants.EXPORT_PACKAGE + ": ");
- for (int i = 0; i < exportPackages.size(); i++)
- {
- if (i > 0)
- pw.print(",");
-
- pw.print(exportPackages.get(i));
- }
- pw.println();
- }
-
- if (importPackages.size() > 0)
- {
- pw.print(Constants.IMPORT_PACKAGE + ": ");
- for (int i = 0; i < importPackages.size(); i++)
- {
- if (i > 0)
- pw.print(",");
-
- pw.print(importPackages.get(i));
- }
- pw.println();
- }
-
- try
- {
- Manifest manifest = new Manifest(new ByteArrayInputStream(sw.toString().getBytes()));
- return manifest;
- }
- catch (IOException ex)
- {
- throw new IllegalStateException("Cannot create manifest", ex);
- }
- }
-}
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-09 14:54:52 UTC (rev 102129)
+++ projects/jboss-osgi/projects/vfs/trunk/api/src/main/java/org/jboss/osgi/vfs/VFSAdaptor.java 2010-03-09 14:56:02 UTC (rev 102130)
@@ -22,7 +22,6 @@
package org.jboss.osgi.vfs;
import java.io.IOException;
-import java.net.URISyntaxException;
import java.net.URL;
/**
@@ -45,8 +44,6 @@
*/
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-09 14:54:52 UTC (rev 102129)
+++ projects/jboss-osgi/projects/vfs/trunk/api/src/main/java/org/jboss/osgi/vfs/VirtualFile.java 2010-03-09 14:56:02 UTC (rev 102130)
@@ -56,8 +56,7 @@
String getPathName();
/**
- * Whether it is a simple leaf of the VFS,
- * i.e. whether it can contain other files
+ * Whether it is a file in the VFS.
*
* @return true if a simple file.
* @throws IOException for any problem accessing the virtual file system
@@ -66,6 +65,15 @@
boolean isFile() throws IOException;
/**
+ * Whether it is a directory in the VFS.
+ *
+ * @return true if a directory.
+ * @throws IOException for any problem accessing the virtual file system
+ * @throws IllegalStateException if the file is closed
+ */
+ boolean isDirectory() throws IOException;
+
+ /**
* Get the VF URL (file://root/org/jboss/X.java)
*
* @return the full URL to the VF in the VFS.
@@ -76,6 +84,15 @@
URL toURL() throws MalformedURLException, URISyntaxException;
/**
+ * Get the parent
+ *
+ * @return the parent or null if there is no parent
+ * @throws IOException for any problem accessing the virtual file system
+ * @throws IllegalStateException if the file is closed
+ */
+ VirtualFile getParent() throws IOException;
+
+ /**
* Get a child
*
* @param path the path
Deleted: 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 14:54:52 UTC (rev 102129)
+++ projects/jboss-osgi/projects/vfs/trunk/api/src/main/java/org/jboss/osgi/vfs/VirtualFileAssembly.java 2010-03-09 14:56:02 UTC (rev 102130)
@@ -1,93 +0,0 @@
-/*
-* 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.File;
-import java.io.IOException;
-import java.util.jar.Manifest;
-
-
-/**
- * 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(a)jboss.com
- * @since 02-Mar-2010
- */
-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;
-
- /**
- * 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
- */
- @Deprecated
- void addResources(Class<?> reference, String[] includes, String[] excludes);
-}
14 years, 3 months
JBoss-OSGI SVN: r102129 - projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-09 09:54:52 -0500 (Tue, 09 Mar 2010)
New Revision: 102129
Modified:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java
Log:
Better error on missing manifest
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java 2010-03-09 14:16:03 UTC (rev 102128)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java 2010-03-09 14:54:52 UTC (rev 102129)
@@ -107,8 +107,10 @@
try
{
manifest = VFSUtils.getManifest(rootFile);
+ if (manifest == null)
+ throw new BundleException("Cannot get manifest from: " + rootURL);
}
- catch (Exception ex)
+ catch (IOException ex)
{
throw new BundleException("Cannot get manifest from: " + rootURL, ex);
}
14 years, 3 months
JBoss-OSGI SVN: r102117 - projects/jboss-osgi/projects/vfs/trunk/api/src/main/java/org/jboss/osgi/vfs.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-09 04:34:17 -0500 (Tue, 09 Mar 2010)
New Revision: 102117
Added:
projects/jboss-osgi/projects/vfs/trunk/api/src/main/java/org/jboss/osgi/vfs/ManifestBuilder.java
Log:
wip
Added: projects/jboss-osgi/projects/vfs/trunk/api/src/main/java/org/jboss/osgi/vfs/ManifestBuilder.java
===================================================================
--- projects/jboss-osgi/projects/vfs/trunk/api/src/main/java/org/jboss/osgi/vfs/ManifestBuilder.java (rev 0)
+++ projects/jboss-osgi/projects/vfs/trunk/api/src/main/java/org/jboss/osgi/vfs/ManifestBuilder.java 2010-03-09 09:34:17 UTC (rev 102117)
@@ -0,0 +1,138 @@
+/*
+* 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.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+import org.osgi.framework.Constants;
+
+/**
+ * A simple OSGi manifest builder.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Mar-2010
+ */
+public final class ManifestBuilder
+{
+ private StringWriter sw;
+ private PrintWriter pw;
+ private List<String> importPackages = new ArrayList<String>();
+ private List<String> exportPackages = new ArrayList<String>();
+
+ public static ManifestBuilder newInstance()
+ {
+ return new ManifestBuilder();
+ }
+
+ private ManifestBuilder()
+ {
+ sw = new StringWriter();
+ pw = new PrintWriter(sw);
+ pw.println(Attributes.Name.MANIFEST_VERSION + ": 1.0");
+ }
+
+ public ManifestBuilder addBundleManifestVersion(int version)
+ {
+ pw.println(Constants.BUNDLE_MANIFESTVERSION + ": " + version);
+ return this;
+ }
+
+ public ManifestBuilder addBundleSymbolicName(String symbolicName)
+ {
+ pw.println(Constants.BUNDLE_SYMBOLICNAME + ": " + symbolicName);
+ return this;
+ }
+
+ public ManifestBuilder addBundleActivator(String bundleActivator)
+ {
+ pw.println(Constants.BUNDLE_ACTIVATOR + ": " + bundleActivator);
+ return this;
+ }
+
+ public ManifestBuilder addImportPackages(String... packages)
+ {
+ for (String aux : packages)
+ importPackages.add(aux);
+
+ return this;
+ }
+
+ public ManifestBuilder addExportPackages(String... packages)
+ {
+ for (String aux : packages)
+ exportPackages.add(aux);
+
+ return this;
+ }
+
+ public ManifestBuilder addManifestHeader(String key, String value)
+ {
+ pw.println(key + ": " + value);
+ return this;
+ }
+
+ public Manifest getManifest()
+ {
+ if (exportPackages.size() > 0)
+ {
+ pw.print(Constants.EXPORT_PACKAGE + ": ");
+ for (int i = 0; i < exportPackages.size(); i++)
+ {
+ if (i > 0)
+ pw.print(",");
+
+ pw.print(exportPackages.get(i));
+ }
+ pw.println();
+ }
+
+ if (importPackages.size() > 0)
+ {
+ pw.print(Constants.IMPORT_PACKAGE + ": ");
+ for (int i = 0; i < importPackages.size(); i++)
+ {
+ if (i > 0)
+ pw.print(",");
+
+ pw.print(importPackages.get(i));
+ }
+ pw.println();
+ }
+
+ try
+ {
+ Manifest manifest = new Manifest(new ByteArrayInputStream(sw.toString().getBytes()));
+ return manifest;
+ }
+ catch (IOException ex)
+ {
+ throw new IllegalStateException("Cannot create manifest", ex);
+ }
+ }
+}
14 years, 3 months
JBoss-OSGI SVN: r102112 - in projects/jboss-osgi/projects/testing/trunk: src/main/java/org/jboss/osgi/testing and 2 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-09 01:40:50 -0500 (Tue, 09 Mar 2010)
New Revision: 102112
Added:
projects/jboss-osgi/projects/testing/trunk/src/test/java/org/jboss/test/osgi/testing/SimpleAssemblyTestCase.java
Modified:
projects/jboss-osgi/projects/testing/trunk/pom.xml
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiRuntime.java
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java
projects/jboss-osgi/projects/testing/trunk/src/test/java/org/jboss/test/osgi/testing/SimpleTestCase.java
Log:
wip
Modified: projects/jboss-osgi/projects/testing/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/pom.xml 2010-03-09 06:40:07 UTC (rev 102111)
+++ projects/jboss-osgi/projects/testing/trunk/pom.xml 2010-03-09 06:40:50 UTC (rev 102112)
@@ -42,6 +42,7 @@
<properties>
<version.apache.aries.jmx>1.0.0-incubating-SNAPSHOT</version.apache.aries.jmx>
<version.apache.felix.log>1.0.0</version.apache.felix.log>
+ <version.jboss.shrinkwrap>1.0.0-alpha-6</version.jboss.shrinkwrap>
<version.jboss.osgi.common>1.0.4-SNAPSHOT</version.jboss.osgi.common>
<version.jboss.osgi.felix>2.0.2.SP1-SNAPSHOT</version.jboss.osgi.felix>
<version.jboss.osgi.jmx>1.0.4-SNAPSHOT</version.jboss.osgi.jmx>
@@ -72,6 +73,11 @@
<version>${version.jboss.osgi.vfs}</version>
</dependency>
<dependency>
+ <groupId>org.jboss.shrinkwrap</groupId>
+ <artifactId>shrinkwrap-api</artifactId>
+ <version>${version.jboss.shrinkwrap}</version>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
Modified: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiRuntime.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiRuntime.java 2010-03-09 06:40:07 UTC (rev 102111)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiRuntime.java 2010-03-09 06:40:50 UTC (rev 102112)
@@ -28,6 +28,7 @@
import javax.naming.NamingException;
import org.jboss.osgi.spi.capability.Capability;
+import org.jboss.osgi.vfs.VirtualFile;
import org.osgi.framework.BundleException;
import org.osgi.framework.Version;
import org.osgi.jmx.framework.BundleStateMBean;
@@ -59,6 +60,11 @@
void removeCapability(Capability capability);
/**
+ * Install an {@link OSGiBundle} from the given virtual file.
+ */
+ OSGiBundle installBundle(VirtualFile vfsfile) throws BundleException, IOException;
+
+ /**
* Install an {@link OSGiBundle} from the given location.
*/
OSGiBundle installBundle(String location) throws BundleException;
Modified: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java 2010-03-09 06:40:07 UTC (rev 102111)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java 2010-03-09 06:40:50 UTC (rev 102112)
@@ -23,6 +23,7 @@
// $Id$
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -40,6 +41,7 @@
import org.jboss.osgi.testing.OSGiRuntime;
import org.jboss.osgi.testing.OSGiServiceReference;
import org.jboss.osgi.testing.OSGiTestHelper;
+import org.jboss.osgi.vfs.VirtualFile;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
@@ -65,6 +67,17 @@
super(helper);
}
+ public OSGiBundle installBundle(VirtualFile file) throws BundleException, IOException
+ {
+ BundleInfo info = BundleInfo.createBundleInfo(file);
+
+ BundleContext context = getSystemContext();
+ Bundle auxBundle = context.installBundle(info.getLocation(), file.openStream());
+ OSGiBundle bundle = new EmbeddedBundle(this, auxBundle);
+
+ return registerBundle(bundle.getLocation(), bundle);
+ }
+
public OSGiBundle installBundle(String location) throws BundleException
{
BundleInfo info = BundleInfo.createBundleInfo(location);
Modified: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java 2010-03-09 06:40:07 UTC (rev 102111)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java 2010-03-09 06:40:50 UTC (rev 102112)
@@ -43,11 +43,13 @@
import org.jboss.osgi.jmx.MBeanProxy;
import org.jboss.osgi.jmx.ObjectNameFactory;
import org.jboss.osgi.jmx.ServiceStateMBeanExt;
+import org.jboss.osgi.spi.NotImplementedException;
import org.jboss.osgi.spi.util.BundleInfo;
import org.jboss.osgi.testing.OSGiBundle;
import org.jboss.osgi.testing.OSGiRuntime;
import org.jboss.osgi.testing.OSGiServiceReference;
import org.jboss.osgi.testing.OSGiTestHelper;
+import org.jboss.osgi.vfs.VirtualFile;
import org.osgi.framework.BundleException;
import org.osgi.jmx.framework.BundleStateMBean;
import org.osgi.jmx.framework.ServiceStateMBean;
@@ -70,6 +72,11 @@
super(helper);
}
+ public OSGiBundle installBundle(VirtualFile file) throws BundleException, IOException
+ {
+ throw new NotImplementedException();
+ }
+
public OSGiBundle installBundle(String location) throws BundleException
{
try
Added: projects/jboss-osgi/projects/testing/trunk/src/test/java/org/jboss/test/osgi/testing/SimpleAssemblyTestCase.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/test/java/org/jboss/test/osgi/testing/SimpleAssemblyTestCase.java (rev 0)
+++ projects/jboss-osgi/projects/testing/trunk/src/test/java/org/jboss/test/osgi/testing/SimpleAssemblyTestCase.java 2010-03-09 06:40:50 UTC (rev 102112)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.osgi.testing;
+
+//$Id: SimpleTestCase.java 101150 2010-02-19 10:50:46Z thomas.diesler(a)jboss.com $
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.Closeable;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.List;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import org.jboss.osgi.testing.OSGiBundle;
+import org.jboss.osgi.testing.OSGiRuntime;
+import org.jboss.osgi.testing.OSGiTest;
+import org.jboss.osgi.vfs.AbstractVFS;
+import org.jboss.osgi.vfs.ManifestBuilder;
+import org.jboss.osgi.vfs.VirtualFile;
+import org.jboss.osgi.vfs.VirtualFileAssembly;
+import org.jboss.test.osgi.testing.bundle.SimpleActivator;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+
+/**
+ * A test that deployes a bundle and verifies its state
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 12-Feb-2009
+ */
+public class SimpleAssemblyTestCase extends OSGiTest
+{
+ @Test
+ public void testSimpleAssembly() throws Exception
+ {
+ OSGiRuntime runtime = getDefaultRuntime();
+ try
+ {
+ VirtualFileAssembly assembly = AbstractVFS.createVirtualFileAssembly("example-simple.jar");
+ assembly.addClass(SimpleActivator.class);
+
+ ManifestBuilder mb = ManifestBuilder.newInstance();
+ mb.addBundleManifestVersion(2);
+ mb.addBundleSymbolicName("example-simple");
+ mb.addBundleActivator(SimpleActivator.class.getName());
+ mb.addImportPackages("org.jboss.osgi.common.log", "org.osgi.framework", "org.osgi.service.log");
+
+ Manifest manifest = mb.getManifest();
+ assembly.addManifest(manifest);
+
+ OSGiBundle bundle = runtime.installBundle(assembly);
+ assertBundleState(Bundle.INSTALLED, bundle.getState());
+ }
+ finally
+ {
+ runtime.shutdown();
+ }
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/testing/trunk/src/test/java/org/jboss/test/osgi/testing/SimpleTestCase.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/test/java/org/jboss/test/osgi/testing/SimpleTestCase.java 2010-03-09 06:40:07 UTC (rev 102111)
+++ projects/jboss-osgi/projects/testing/trunk/src/test/java/org/jboss/test/osgi/testing/SimpleTestCase.java 2010-03-09 06:40:50 UTC (rev 102112)
@@ -23,9 +23,13 @@
//$Id$
+import static org.junit.Assert.*;
+
import org.jboss.osgi.testing.OSGiBundle;
import org.jboss.osgi.testing.OSGiRuntime;
+import org.jboss.osgi.testing.OSGiServiceReference;
import org.jboss.osgi.testing.OSGiTest;
+import org.jboss.test.osgi.testing.bundle.SimpleService;
import org.junit.Test;
import org.osgi.framework.Bundle;
@@ -51,7 +55,19 @@
// Start the bundle
bundle.start();
assertBundleState(Bundle.ACTIVE, bundle.getState());
+
+ // Check service is registered
+ OSGiServiceReference sref = runtime.getServiceReference(SimpleService.class.getName());
+ assertNotNull("Service registered", sref);
+ // Stop the bundle
+ bundle.stop();
+ assertBundleState(Bundle.RESOLVED, bundle.getState());
+
+ // Check service is registered
+ sref = runtime.getServiceReference(SimpleService.class.getName());
+ assertNull("Service not registered", sref);
+
// Uninstall the bundle
bundle.uninstall();
assertBundleState(Bundle.UNINSTALLED, bundle.getState());
14 years, 3 months
JBoss-OSGI SVN: r102111 - in projects/jboss-osgi/projects/vfs/trunk: api and 4 other directories.
by jboss-osgi-commits@lists.jboss.org
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/jboss-osgi/projec...</connection>
@@ -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;
}
14 years, 3 months
JBoss-OSGI SVN: r102057 - projects/jboss-osgi/trunk/reactor/jbossmc-javadoc.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-08 06:01:07 -0500 (Mon, 08 Mar 2010)
New Revision: 102057
Modified:
projects/jboss-osgi/trunk/reactor/jbossmc-javadoc/pom.xml
Log:
Add jboss-vfs
Modified: projects/jboss-osgi/trunk/reactor/jbossmc-javadoc/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/jbossmc-javadoc/pom.xml 2010-03-08 10:58:40 UTC (rev 102056)
+++ projects/jboss-osgi/trunk/reactor/jbossmc-javadoc/pom.xml 2010-03-08 11:01:07 UTC (rev 102057)
@@ -34,11 +34,23 @@
<version.jboss.classloading>2.2.0-SNAPSHOT</version.jboss.classloading>
<version.jboss.deployers>2.2.0-SNAPSHOT</version.jboss.deployers>
<version.jboss.kernel>2.2.0-SNAPSHOT</version.jboss.kernel>
+ <version.jboss.vfs>3.0.0-SNAPSHOT</version.jboss.vfs>
</properties>
<!-- Dependencies -->
<dependencies>
<dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-vfs</artifactId>
+ <version>${version.jboss.vfs}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-vfs</artifactId>
+ <version>${version.jboss.vfs}</version>
+ <classifier>sources</classifier>
+ </dependency>
+ <dependency>
<groupId>org.jboss.cl</groupId>
<artifactId>jboss-classloader</artifactId>
<version>${version.jboss.classloading}</version>
14 years, 4 months
JBoss-OSGI SVN: r102055 - projects/jboss-osgi/trunk/reactor/jbossmc-javadoc/scripts.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-08 05:58:30 -0500 (Mon, 08 Mar 2010)
New Revision: 102055
Modified:
projects/jboss-osgi/trunk/reactor/jbossmc-javadoc/scripts/assembly-javadoc-src.xml
Log:
Add jboss-vfs
Modified: projects/jboss-osgi/trunk/reactor/jbossmc-javadoc/scripts/assembly-javadoc-src.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/jbossmc-javadoc/scripts/assembly-javadoc-src.xml 2010-03-08 10:33:39 UTC (rev 102054)
+++ projects/jboss-osgi/trunk/reactor/jbossmc-javadoc/scripts/assembly-javadoc-src.xml 2010-03-08 10:58:30 UTC (rev 102055)
@@ -23,6 +23,7 @@
<include>*:jboss-deployers-vfs:jar:sources</include>
<include>*:jboss-deployers-vfs-spi:jar:sources</include>
<include>*:jboss-kernel:jar:sources</include>
+ <include>*:jboss-vfs:jar:sources</include>
</includes>
<unpack>true</unpack>
</dependencySet>
14 years, 4 months
JBoss-OSGI SVN: r102050 - projects/jboss-osgi/projects/runtime/framework/trunk/bundle.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-08 03:49:13 -0500 (Mon, 08 Mar 2010)
New Revision: 102050
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/pom.xml
Log:
Fix framework vfs depenencies
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/pom.xml 2010-03-08 08:08:50 UTC (rev 102049)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/pom.xml 2010-03-08 08:49:13 UTC (rev 102050)
@@ -1,17 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- ====================================================================== -->
-<!-- -->
-<!-- JBoss, the OpenSource J2EE webOS -->
-<!-- -->
-<!-- Distributable under LGPL license. -->
-<!-- See terms of license at http://www.gnu.org. -->
-<!-- -->
+<!-- -->
+<!-- JBoss, the OpenSource J2EE webOS -->
+<!-- -->
+<!-- Distributable under LGPL license. -->
+<!-- See terms of license at http://www.gnu.org. -->
+<!-- -->
<!-- ====================================================================== -->
<!-- $Id$ -->
-<!-- Set these VM properties in your IDE debugger -Dlog4j.output.dir=${workspace_loc:jboss-osgi-framework/target} -Dlog4j.configuration=log4j-console.xml -->
+<!--
+ Set these VM properties in your IDE debugger
+ -Dlog4j.output.dir=${workspace_loc:jboss-osgi-framework/target}
+ -Dlog4j.configuration=log4j-console.xml
+-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -284,10 +288,139 @@
</property>
</systemProperties>
<excludes>
- <!-- excludes listed here need to have a jira issue associated <exclude>org/jboss/test/osgi/service/ServiceMixUnitTestCase.class</exclude> -->
+ <!-- excludes listed here need to have a jira issue associated
+ <exclude>org/jboss/test/osgi/service/ServiceMixUnitTestCase.class</exclude>
+ -->
</excludes>
</configuration>
</plugin>
</plugins>
</build>
+
+ <profiles>
+ <!--
+ Name: embedded-testing
+ Descr: Setup for embedded integration testing
+ -->
+ <profile>
+ <id>embedded-testing</id>
+ <activation>
+ <property>
+ <name>!target.container</name>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.osgi.framework</groupId>
+ <artifactId>jboss-osgi-framework-vfs21</artifactId>
+ <version>${version}</version>
+ </dependency>
+ </dependencies>
+ </profile>
+
+ <!--
+ Name: runtime-testing
+ Descr: Setup for runtime integration testing
+ -->
+ <profile>
+ <id>runtime-testing</id>
+ <activation>
+ <property>
+ <name>target.container</name>
+ <value>runtime</value>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.osgi.framework</groupId>
+ <artifactId>jboss-osgi-framework-vfs21</artifactId>
+ <version>${version}</version>
+ </dependency>
+ </dependencies>
+ </profile>
+
+ <!--
+ Name: jboss501
+ Descr: Setup for jboss501 integration testing
+ -->
+ <profile>
+ <id>jboss501</id>
+ <activation>
+ <property>
+ <name>target.container</name>
+ <value>jboss501</value>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.osgi.framework</groupId>
+ <artifactId>jboss-osgi-framework-vfs21</artifactId>
+ <version>${version}</version>
+ </dependency>
+ </dependencies>
+ </profile>
+
+ <!--
+ Name: jboss510
+ Descr: Setup for jboss510 integration testing
+ -->
+ <profile>
+ <id>jboss510</id>
+ <activation>
+ <property>
+ <name>target.container</name>
+ <value>jboss510</value>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.osgi.framework</groupId>
+ <artifactId>jboss-osgi-framework-vfs21</artifactId>
+ <version>${version}</version>
+ </dependency>
+ </dependencies>
+ </profile>
+
+ <!--
+ Name: jboss600
+ Descr: Setup for jboss600 integration testing
+ -->
+ <profile>
+ <id>jboss600</id>
+ <activation>
+ <property>
+ <name>target.container</name>
+ <value>jboss600</value>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.osgi.framework</groupId>
+ <artifactId>jboss-osgi-framework-vfs21</artifactId>
+ <version>${version}</version>
+ </dependency>
+ </dependencies>
+ </profile>
+
+ <!--
+ Name: jboss601
+ Descr: Setup for jboss601 integration testing
+ -->
+ <profile>
+ <id>jboss601</id>
+ <activation>
+ <property>
+ <name>target.container</name>
+ <value>jboss601</value>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.osgi.framework</groupId>
+ <artifactId>jboss-osgi-framework-vfs30</artifactId>
+ <version>${version}</version>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
</project>
14 years, 4 months
JBoss-OSGI SVN: r102049 - projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/internal.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-08 03:08:50 -0500 (Mon, 08 Mar 2010)
New Revision: 102049
Modified:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/internal/OSGiBootstrapBean.java
Log:
[JBOSGI-297] OSGiBootstrapBean spinning on System.in read
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/internal/OSGiBootstrapBean.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/internal/OSGiBootstrapBean.java 2010-03-08 06:04:20 UTC (rev 102048)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/internal/OSGiBootstrapBean.java 2010-03-08 08:08:50 UTC (rev 102049)
@@ -199,7 +199,7 @@
try
{
int inByte = br.read();
- while (inByte != 0)
+ while (inByte != -1)
{
inByte = br.read();
}
14 years, 4 months