Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2011-01-06 18:51:07 +0000
committerThomas Watson2011-01-06 18:51:07 +0000
commit3da0d85019265c0e8c2c517091c29aa60280fb4e (patch)
tree700ab86d4a65b2a7b31dc11684e21c5101edf024
parent940730e9fde8f6a26624cee6c9d8847ba4d2a95f (diff)
downloadrt.equinox.framework-3da0d85019265c0e8c2c517091c29aa60280fb4e.tar.gz
rt.equinox.framework-3da0d85019265c0e8c2c517091c29aa60280fb4e.tar.xz
rt.equinox.framework-3da0d85019265c0e8c2c517091c29aa60280fb4e.zip
Bug 333667 - Bundle FindHook should be driven for install operations
-rw-r--r--bundles/org.eclipse.osgi/.settings/.api_filters7
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleContextImpl.java4
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Framework.java14
-rw-r--r--bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/BundleException.java24
4 files changed, 35 insertions, 14 deletions
diff --git a/bundles/org.eclipse.osgi/.settings/.api_filters b/bundles/org.eclipse.osgi/.settings/.api_filters
index ce51e1c7a..f9fee5ddc 100644
--- a/bundles/org.eclipse.osgi/.settings/.api_filters
+++ b/bundles/org.eclipse.osgi/.settings/.api_filters
@@ -481,6 +481,13 @@
<message_argument value="READ_ERROR"/>
</message_arguments>
</filter>
+<filter comment="Ignore OSGi API." id="1141899266">
+<message_arguments>
+<message_argument value="1.6"/>
+<message_argument value="3.7"/>
+<message_argument value="REJECTED_BY_HOOK"/>
+</message_arguments>
+</filter>
</resource>
<resource path="osgi/src/org/osgi/framework/BundleReference.java" type="org.osgi.framework.BundleReference">
<filter comment="Ignore OSGi API" id="403853384">
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleContextImpl.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleContextImpl.java
index 8c7322311..a6581cd2d 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleContextImpl.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleContextImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2010 IBM Corporation and others.
+ * Copyright (c) 2003, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -134,7 +134,7 @@ public class BundleContextImpl implements BundleContext, EventDispatcher<Object,
public Bundle installBundle(String location, InputStream in) throws BundleException {
checkValid();
//note AdminPermission is checked after bundle is loaded
- return framework.installBundle(location, in, bundle);
+ return framework.installBundle(location, in, this);
}
/**
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Framework.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Framework.java
index 076151f84..4226bd321 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Framework.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Framework.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2010 IBM Corporation and others.
+ * Copyright (c) 2003, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -825,7 +825,7 @@ public class Framework implements EventPublisher, Runnable {
* then the location is used to get the bundle content.
* @return The Bundle of the installed bundle.
*/
- AbstractBundle installBundle(final String location, final InputStream in, Bundle origin) throws BundleException {
+ AbstractBundle installBundle(final String location, final InputStream in, BundleContext origin) throws BundleException {
if (Debug.DEBUG_GENERAL) {
Debug.println("install from inputstream: " + location + ", " + in); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -852,13 +852,19 @@ public class Framework implements EventPublisher, Runnable {
* @exception BundleException
* If the action throws an error.
*/
- protected AbstractBundle installWorker(String location, PrivilegedExceptionAction<AbstractBundle> action, Bundle origin) throws BundleException {
+ protected AbstractBundle installWorker(String location, PrivilegedExceptionAction<AbstractBundle> action, BundleContext origin) throws BundleException {
synchronized (installLock) {
while (true) {
/* Check that the bundle is not already installed. */
AbstractBundle bundle = getBundleByLocation(location);
/* If already installed, return bundle object */
if (bundle != null) {
+ Bundle visible = origin.getBundle(bundle.getBundleId());
+ if (visible == null) {
+ BundleData data = bundle.getBundleData();
+ String msg = NLS.bind(Msg.BUNDLE_INSTALL_SAME_UNIQUEID, new Object[] {data.getSymbolicName(), data.getVersion().toString(), data.getLocation()});
+ throw new BundleException(msg, BundleException.REJECTED_BY_HOOK);
+ }
return bundle;
}
Thread current = Thread.currentThread();
@@ -889,7 +895,7 @@ public class Framework implements EventPublisher, Runnable {
/* Don't call adaptor while holding the install lock */
try {
AbstractBundle bundle = AccessController.doPrivileged(action);
- publishBundleEvent(new BundleEvent(BundleEvent.INSTALLED, bundle, origin));
+ publishBundleEvent(new BundleEvent(BundleEvent.INSTALLED, bundle, origin.getBundle()));
return bundle;
} catch (PrivilegedActionException e) {
if (e.getException() instanceof RuntimeException)
diff --git a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/BundleException.java b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/BundleException.java
index c882011ec..9cae61a77 100644
--- a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/BundleException.java
+++ b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/BundleException.java
@@ -32,7 +32,7 @@ package org.osgi.framework;
* <p>
* This exception conforms to the general purpose exception chaining mechanism.
*
- * @version $Id: b74b565a3ef7d7668cdd07202f88358f9e7611ed $
+ * @version $Id: 9e117ec9667b040f7752e342aa07d6c7d5bf0275 $
*/
public class BundleException extends Exception {
@@ -114,13 +114,6 @@ public class BundleException extends Exception {
public static final int DUPLICATE_BUNDLE_ERROR = 9;
/**
- * The framework received an error while reading the input stream for a bundle.
- *
- * @since 1.6
- */
- public static final int READ_ERROR = 10;
-
- /**
* The start transient operation failed because the start level of the
* bundle is greater than the current framework start level
*
@@ -129,6 +122,21 @@ public class BundleException extends Exception {
public static final int START_TRANSIENT_ERROR = 10;
/**
+ * The framework received an error while reading the input stream for a
+ * bundle.
+ *
+ * @since 1.6
+ */
+ public static final int READ_ERROR = 11;
+
+ /**
+ * A framework hook rejected the operation.
+ *
+ * @since 1.6
+ */
+ public static final int REJECTED_BY_HOOK = 12;
+
+ /**
* Creates a {@code BundleException} with the specified message and
* exception cause.
*

Back to the top