[jboss-osgi-commits] JBoss-OSGI SVN: r99983 - projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer.
jboss-osgi-commits at lists.jboss.org
jboss-osgi-commits at lists.jboss.org
Wed Jan 27 05:18:46 EST 2010
Author: thomas.diesler at jboss.com
Date: 2010-01-27 05:18:45 -0500 (Wed, 27 Jan 2010)
New Revision: 99983
Modified:
projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleMetaData.java
projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleMetaDataDeployer.java
projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleRealDeployer.java
Log:
Fix duplicate bundle installation
Modified: projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleMetaData.java
===================================================================
--- projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleMetaData.java 2010-01-27 10:00:11 UTC (rev 99982)
+++ projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleMetaData.java 2010-01-27 10:18:45 UTC (rev 99983)
@@ -24,6 +24,7 @@
//$Id$
import org.jboss.deployers.vfs.spi.deployer.helpers.AbstractManifestMetaData;
+import org.osgi.framework.Version;
/**
* The Bundle metadata.
@@ -34,7 +35,8 @@
public class BundleMetaData extends AbstractManifestMetaData
{
private String symbolicName;
- private String bundleLocation;
+ private Version version;
+ private String location;
// exteralizable usage
public BundleMetaData()
@@ -51,18 +53,28 @@
return symbolicName;
}
- public String getBundleLocation()
+ public Version getVersion()
{
- return bundleLocation;
+ return version;
}
- public void setBundleLocation(String bundleLocation)
+ public void setVersion(Version version)
{
- this.bundleLocation = bundleLocation;
+ this.version = version;
}
+ public String getLocation()
+ {
+ return location;
+ }
+
+ public void setLocation(String location)
+ {
+ this.location = location;
+ }
+
public String toString()
{
- return "Bundle[name=" + symbolicName + "]";
+ return "Bundle[" + symbolicName + "-" + version + "]";
}
}
Modified: projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleMetaDataDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleMetaDataDeployer.java 2010-01-27 10:00:11 UTC (rev 99982)
+++ projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleMetaDataDeployer.java 2010-01-27 10:18:45 UTC (rev 99983)
@@ -32,11 +32,12 @@
import org.jboss.osgi.spi.OSGiConstants;
import org.jboss.virtual.VirtualFile;
import org.osgi.framework.Constants;
+import org.osgi.framework.Version;
/**
* Create {@link BundleMetaData} from Manifest Headers.
*
- * If the manifest does not contain a header (named "Bundle-SymbolicName") this deployer does nothing.
+ * If the manifest does not contain a header Bundle-SymbolicName this deployer does nothing.
*
* @author Thomas.Diesler at jboss.org
* @since 03-Feb-2009
@@ -60,7 +61,7 @@
Deployment dep = unit.getAttachment(Deployment.class);
String location = (dep != null ? dep.getLocation() : unit.getName());
- metaData.setBundleLocation(location);
+ metaData.setLocation(location);
// Add a marker that this is an OSGi deployment
unit.addAttachment(OSGiConstants.KEY_BUNDLE_SYMBOLIC_NAME, symbolicName);
@@ -71,11 +72,16 @@
@Override
protected BundleMetaData createMetaData(Manifest manifest) throws Exception
{
+ BundleMetaData metaData = null;
Attributes attribs = manifest.getMainAttributes();
String symbolicName = attribs.getValue(Constants.BUNDLE_SYMBOLICNAME);
if (symbolicName != null)
- return new BundleMetaData(symbolicName);
+ {
+ metaData = new BundleMetaData(symbolicName);
+ String version = attribs.getValue(Constants.BUNDLE_VERSION);
+ metaData.setVersion(Version.parseVersion(version));
+ }
- return null;
+ return metaData;
}
}
Modified: projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleRealDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleRealDeployer.java 2010-01-27 10:00:11 UTC (rev 99982)
+++ projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleRealDeployer.java 2010-01-27 10:18:45 UTC (rev 99983)
@@ -23,6 +23,7 @@
//$Id$
+import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
@@ -69,17 +70,31 @@
public void deploy(DeploymentUnit unit, BundleMetaData metadata) throws DeploymentException
{
- String location = metadata.getBundleLocation();
+ String location = metadata.getLocation();
if (location == null)
throw new IllegalStateException("Cannot obtain bundle location for: " + metadata);
+ // Normalize the bundle install path
+ String path = location;
try
{
+ URL url = new URL(location);
+ path = url.getPath();
+ if (path.endsWith("/"))
+ path = path.substring(0, path.length() - 1);
+ }
+ catch (MalformedURLException ex)
+ {
+ // ignore
+ }
+
+ try
+ {
boolean skipBundle = false;
for (URL skip : skipBundles)
{
String skipPath = skip.getPath();
- if (skipPath.equals(location))
+ if (skipPath.equals(path))
{
skipBundle = true;
break;
@@ -89,7 +104,6 @@
{
Bundle bundle = systemContext.installBundle(location);
unit.addAttachment(Bundle.class, bundle);
-
log.info("Installed: " + bundle);
}
}
More information about the jboss-osgi-commits
mailing list