[jboss-cvs] JBossAS SVN: r95167 - in projects/jboss-osgi: projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Oct 20 06:33:38 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-10-20 06:33:38 -0400 (Tue, 20 Oct 2009)
New Revision: 95167
Modified:
projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/AbstractMicrocontainerService.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/common/Deployment.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/AbstractDeployerService.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentImpl.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/internal/SystemPackagesPluginImpl.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi161/bundle/OSGI161Activator.java
Log:
[JBOSGI-183] Initial implementation of OSGi Deployers
Expose VirtualFile on Deployment
Modified: projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/AbstractMicrocontainerService.java
===================================================================
--- projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/AbstractMicrocontainerService.java 2009-10-20 09:40:47 UTC (rev 95166)
+++ projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/AbstractMicrocontainerService.java 2009-10-20 10:33:38 UTC (rev 95167)
@@ -53,7 +53,6 @@
import org.jboss.osgi.spi.OSGiConstants;
import org.jboss.osgi.spi.management.MicrocontainerServiceMBean;
import org.jboss.osgi.spi.service.MicrocontainerService;
-import org.jboss.virtual.VFS;
import org.jboss.virtual.VirtualFile;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
@@ -148,8 +147,8 @@
for (Deployment dep : depArr)
{
- VirtualFile file = VFS.createNewRoot(dep.getLocation());
- VFSDeployment vfsdep = deploymentFactory.createVFSDeployment(file);
+ VirtualFile root = dep.getRoot();
+ VFSDeployment vfsdep = deploymentFactory.createVFSDeployment(root);
dep.addAttachment(VFSDeployment.class, vfsdep);
registry.registerDeployment(dep);
depList.add(vfsdep);
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 2009-10-20 09:40:47 UTC (rev 95166)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java 2009-10-20 10:33:38 UTC (rev 95167)
@@ -28,9 +28,9 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.jar.Attributes;
-import java.util.jar.JarFile;
import java.util.jar.Manifest;
+import org.jboss.virtual.VFS;
import org.jboss.virtual.VFSUtils;
import org.jboss.virtual.VirtualFile;
import org.osgi.framework.BundleException;
@@ -44,13 +44,16 @@
*/
public class BundleInfo
{
- private URL location;
+ private VirtualFile root;
private Manifest manifest;
private String symbolicName;
private String version;
public static BundleInfo createBundleInfo(String location) throws BundleException
{
+ if (location == null)
+ throw new IllegalArgumentException("Location cannot be null");
+
// Try location as URL
URL url = null;
try
@@ -85,51 +88,47 @@
public static BundleInfo createBundleInfo(URL url) throws BundleException
{
- Manifest manifest;
+ if (url == null)
+ throw new IllegalArgumentException("URL cannot be null");
+
+ VirtualFile root;
try
{
- JarFile jarFile = new JarFile(url.getPath());
- manifest = jarFile.getManifest();
- jarFile.close();
+ root = VFS.getRoot(url);
}
- catch (IOException ex)
+ catch (IOException e)
{
- throw new BundleException("Cannot get manifest from: " + url, ex);
-
+ throw new BundleException("Invalid bundle location=" + url, e);
}
-
- return new BundleInfo(url, manifest);
+ return createBundleInfo(root);
}
- public static BundleInfo createBundleInfo(VirtualFile vFile) throws BundleException
+ public static BundleInfo createBundleInfo(VirtualFile root) throws BundleException
{
- URL url;
- Manifest manifest;
+ if (root == null)
+ throw new IllegalArgumentException("VirtualFile cannot be null");
+
+ return new BundleInfo(root);
+ }
+
+ private BundleInfo(VirtualFile root) throws BundleException
+ {
+ if (root == null)
+ throw new IllegalArgumentException("VirtualFile cannot be null");
+ this.root = root;
+
try
{
- manifest = VFSUtils.getManifest(vFile);
- url = vFile.toURL();
+ manifest = VFSUtils.getManifest(root);
}
catch (Exception ex)
{
- throw new BundleException("Cannot get manifest from: " + vFile, ex);
+ throw new BundleException("Cannot get manifest from: " + root, ex);
}
- return new BundleInfo(url, manifest);
- }
-
- private BundleInfo(URL location, Manifest manifest) throws BundleException
- {
- if (location == null)
- throw new IllegalArgumentException("Location cannot be null");
- if (manifest == null)
- throw new IllegalArgumentException("Manifest cannot be null");
- this.manifest = manifest;
- this.location = location;
-
symbolicName = getManifestHeader(Constants.BUNDLE_SYMBOLICNAME);
if (symbolicName == null)
- throw new BundleException("Cannot obtain Bundle-SymbolicName for: " + location);
+ throw new BundleException("Cannot obtain Bundle-SymbolicName for: " + root);
version = getManifestHeader(Constants.BUNDLE_VERSION);
if (version == null)
@@ -151,8 +150,23 @@
*/
public URL getLocation()
{
- return location;
+ try
+ {
+ return root.toURL();
+ }
+ catch (Exception e)
+ {
+ throw new IllegalStateException("Cannot obtain URL from: " + root);
+ }
}
+
+ /**
+ * Get the bundle root file
+ */
+ public VirtualFile getRoot()
+ {
+ return root;
+ }
/**
* Get the bundle symbolic name
@@ -171,8 +185,24 @@
}
@Override
+ public boolean equals(Object obj)
+ {
+ if (!(obj instanceof BundleInfo))
+ return false;
+
+ BundleInfo other = (BundleInfo)obj;
+ return root.equals(other.root);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return toString().hashCode();
+ }
+
+ @Override
public String toString()
{
- return "[" + symbolicName + "-" + version + ",url=" + location + "]";
+ return "[" + symbolicName + "-" + version + ",url=" + root + "]";
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/common/Deployment.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/common/Deployment.java 2009-10-20 09:40:47 UTC (rev 95166)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/common/Deployment.java 2009-10-20 10:33:38 UTC (rev 95167)
@@ -23,7 +23,9 @@
import java.net.URL;
+import org.jboss.virtual.VirtualFile;
+
//$Id$
/**
@@ -35,6 +37,11 @@
public interface Deployment extends Attachments
{
/**
+ * Get the root virtual file
+ */
+ public VirtualFile getRoot();
+
+ /**
* Get the bundle location
*/
public URL getLocation();
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/AbstractDeployerService.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/AbstractDeployerService.java 2009-10-20 09:40:47 UTC (rev 95166)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/AbstractDeployerService.java 2009-10-20 10:33:38 UTC (rev 95167)
@@ -22,17 +22,13 @@
package org.jboss.osgi.deployment.deployer;
import java.io.File;
-import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
-import java.util.jar.Attributes;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
import org.jboss.osgi.deployment.common.Deployment;
import org.jboss.osgi.deployment.internal.DeploymentImpl;
+import org.jboss.osgi.spi.util.BundleInfo;
import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
//$Id$
@@ -80,25 +76,7 @@
private Deployment createDeploymentInternal(URL url) throws BundleException
{
- Manifest manifest;
- try
- {
- JarFile jarFile = new JarFile(url.getPath());
- manifest = jarFile.getManifest();
- jarFile.close();
- }
- catch (IOException ex)
- {
- throw new BundleException("Cannot get manifest from: " + url);
-
- }
-
- Attributes attribs = manifest.getMainAttributes();
- String symbolicName = attribs.getValue(Constants.BUNDLE_SYMBOLICNAME);
- if (symbolicName == null)
- throw new BundleException("Cannot obtain Bundle-SymbolicName for: " + url);
-
- String version = attribs.getValue(Constants.BUNDLE_VERSION);
- return new DeploymentImpl(url, symbolicName, version);
+ BundleInfo info = BundleInfo.createBundleInfo(url);
+ return new DeploymentImpl(info);
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentImpl.java 2009-10-20 09:40:47 UTC (rev 95166)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentImpl.java 2009-10-20 10:33:38 UTC (rev 95167)
@@ -27,6 +27,7 @@
import org.jboss.osgi.deployment.common.Deployment;
import org.jboss.osgi.deployment.common.DeploymentBase;
import org.jboss.osgi.spi.util.BundleInfo;
+import org.jboss.virtual.VirtualFile;
//$Id$
@@ -40,36 +41,24 @@
{
private static final long serialVersionUID = 1L;
- private URL location;
- private String symbolicName;
- private String version;
+ private BundleInfo info;
private int startLevel;
private boolean autoStart;
- private Object metadata;
public DeploymentImpl(BundleInfo info)
{
if (info == null)
throw new IllegalArgumentException("Bundle info cannot be null");
- this.symbolicName = info.getSymbolicName();
- this.location = info.getLocation();
- this.version = info.getVersion().toString();
+ this.info = info;
}
- public DeploymentImpl(URL location, String symbolicName, String version)
+ /**
+ * Get the root virtual file
+ */
+ public VirtualFile getRoot()
{
- if (location == null)
- throw new IllegalArgumentException("Location cannot be null");
- if (symbolicName == null)
- throw new IllegalArgumentException("Symbolic name cannot be null");
-
- if (version == null)
- version = "0.0.0";
-
- this.symbolicName = symbolicName;
- this.location = location;
- this.version = version;
+ return info.getRoot();
}
/**
@@ -77,7 +66,7 @@
*/
public URL getLocation()
{
- return location;
+ return info.getLocation();
}
/**
@@ -85,7 +74,7 @@
*/
public String getSymbolicName()
{
- return symbolicName;
+ return info.getSymbolicName();
}
/**
@@ -93,7 +82,7 @@
*/
public String getVersion()
{
- return version;
+ return info.getVersion();
}
/**
@@ -128,22 +117,6 @@
this.autoStart = autoStart;
}
- /**
- * Get extra meta data associated with this deployment
- */
- public Object getMetadata()
- {
- return metadata;
- }
-
- /**
- * Set extra meta data associated with this deployment
- */
- public void setMetadata(Object metadata)
- {
- this.metadata = metadata;
- }
-
@Override
public boolean equals(Object obj)
{
@@ -151,7 +124,7 @@
return false;
DeploymentImpl other = (DeploymentImpl)obj;
- return symbolicName.equals(other.symbolicName) && version.equals(other.version);
+ return info.equals(other.info);
}
@Override
@@ -163,6 +136,9 @@
@Override
public String toString()
{
+ String symbolicName = getSymbolicName();
+ String version = getVersion();
+ URL location = getLocation();
return "[" + symbolicName + "-" + version + ",url=" + location + "]";
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/internal/SystemPackagesPluginImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/internal/SystemPackagesPluginImpl.java 2009-10-20 09:40:47 UTC (rev 95166)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/internal/SystemPackagesPluginImpl.java 2009-10-20 10:33:38 UTC (rev 95167)
@@ -86,6 +86,7 @@
allPackages.add("javax.xml.transform.stream");
allPackages.add("org.jboss.osgi.microcontainer");
+ allPackages.add("org.jboss.virtual");
allPackages.add("org.w3c.dom");
allPackages.add("org.w3c.dom.bootstrap");
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi161/bundle/OSGI161Activator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi161/bundle/OSGI161Activator.java 2009-10-20 09:40:47 UTC (rev 95166)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi161/bundle/OSGI161Activator.java 2009-10-20 10:33:38 UTC (rev 95167)
@@ -53,6 +53,7 @@
String loggerClass = log.getClass().getName();
List<String> expected = new ArrayList<String>();
+ expected.add("org.apache.commons.logging.impl.SLF4JLog");
expected.add("org.apache.commons.logging.impl.Log4JLogger");
expected.add("org.apache.commons.logging.impl.SLF4JLocationAwareLog");
More information about the jboss-cvs-commits
mailing list