diff options
51 files changed, 1 insertions, 4107 deletions
diff --git a/bundles/org.eclipse.osgi.tests/.classpath b/bundles/org.eclipse.osgi.tests/.classpath index 728b8a713..26c1bba6f 100644 --- a/bundles/org.eclipse.osgi.tests/.classpath +++ b/bundles/org.eclipse.osgi.tests/.classpath @@ -88,14 +88,6 @@ <classpathentry kind="src" output="bundle_tests/test.filter.a" path="bundles_src/test.filter.a"/> <classpathentry kind="src" output="bundle_tests/test.link.a" path="bundles_src/test.link.a"/> <classpathentry kind="src" output="bundle_tests/test.link.a.client" path="bundles_src/test.link.a.client"/> - <classpathentry kind="src" output="bundle_tests/test.link.b" path="bundles_src/test.link.b"/> - <classpathentry kind="src" output="bundle_tests/test.link.b.client" path="bundles_src/test.link.b.client"/> - <classpathentry kind="src" output="bundle_tests/test.link.c" path="bundles_src/test.link.c"/> - <classpathentry kind="src" output="bundle_tests/test.link.c.client" path="bundles_src/test.link.c.client"/> - <classpathentry kind="src" output="bundle_tests/test.link.d" path="bundles_src/test.link.d"/> - <classpathentry kind="src" output="bundle_tests/test.link.e" path="bundles_src/test.link.e"/> - <classpathentry kind="src" output="bundle_tests/test.link.e.client" path="bundles_src/test.link.e.client"/> - <classpathentry kind="src" output="bundle_tests/test.link.postponed" path="bundles_src/test.link.postponed"/> <classpathentry kind="src" output="bundle_tests/test.bug259903.a" path="bundles_src/test.bug259903.a"/> <classpathentry kind="src" output="bundle_tests/test.bug259903.a.update" path="bundles_src/test.bug259903.a.update"/> <classpathentry kind="src" output="bundle_tests/test.bug259903.b" path="bundles_src/test.bug259903.b"/> diff --git a/bundles/org.eclipse.osgi.tests/build.properties b/bundles/org.eclipse.osgi.tests/build.properties index 083368e49..7bd2aeb17 100644 --- a/bundles/org.eclipse.osgi.tests/build.properties +++ b/bundles/org.eclipse.osgi.tests/build.properties @@ -191,22 +191,6 @@ source.bundle_tests/test.link.a.jar = bundles_src/test.link.a/ manifest.bundle_tests/test.link.a.jar = META-INF/MANIFEST.MF source.bundle_tests/test.link.a.client.jar = bundles_src/test.link.a.client/ manifest.bundle_tests/test.link.a.client.jar = META-INF/MANIFEST.MF -source.bundle_tests/test.link.b.jar = bundles_src/test.link.b/ -manifest.bundle_tests/test.link.b.jar = META-INF/MANIFEST.MF -source.bundle_tests/test.link.b.client.jar = bundles_src/test.link.b.client/ -manifest.bundle_tests/test.link.b.client.jar = META-INF/MANIFEST.MF -source.bundle_tests/test.link.c.jar = bundles_src/test.link.c/ -manifest.bundle_tests/test.link.c.jar = META-INF/MANIFEST.MF -source.bundle_tests/test.link.c.client.jar = bundles_src/test.link.c.client/ -manifest.bundle_tests/test.link.c.client.jar = META-INF/MANIFEST.MF -source.bundle_tests/test.link.d.jar = bundles_src/test.link.d/ -manifest.bundle_tests/test.link.d.jar = META-INF/MANIFEST.MF -source.bundle_tests/test.link.e.jar = bundles_src/test.link.e/ -manifest.bundle_tests/test.link.e.jar = META-INF/MANIFEST.MF -source.bundle_tests/test.link.e.client.jar = bundles_src/test.link.e.client/ -manifest.bundle_tests/test.link.e.client.jar = META-INF/MANIFEST.MF -source.bundle_tests/test.link.postponed.jar = bundles_src/test.link.postponed/ -manifest.bundle_tests/test.link.postponed.jar = META-INF/MANIFEST.MF source.bundle_tests/test.bug259903.a.jar = bundles_src/test.bug259903.a/ manifest.bundle_tests/test.bug259903.a.jar = META-INF/MANIFEST.MF source.bundle_tests/test.bug259903.a.update.jar = bundles_src/test.bug259903.a.update/ @@ -327,14 +311,6 @@ jars.compile.order = bundle_tests/ext.framework.b.jar,\ bundle_tests/test.filter.a.jar,\ bundle_tests/test.link.a.jar,\ bundle_tests/test.link.a.client.jar,\ - bundle_tests/test.link.b.jar,\ - bundle_tests/test.link.b.client.jar,\ - bundle_tests/test.link.c.jar,\ - bundle_tests/test.link.c.client.jar,\ - bundle_tests/test.link.d.jar,\ - bundle_tests/test.link.e.jar,\ - bundle_tests/test.link.e.client.jar,\ - bundle_tests/test.link.postponed.jar,\ bundle_tests/test.bug259903.a.jar,\ bundle_tests/test.bug259903.a.update.jar,\ bundle_tests/test.bug259903.b.jar,\ diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.b.client/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.tests/bundles_src/test.link.b.client/META-INF/MANIFEST.MF deleted file mode 100644 index 0b5d38f02..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.b.client/META-INF/MANIFEST.MF +++ /dev/null @@ -1,7 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: test.link.b.client -Bundle-SymbolicName: test.link.b.client -Bundle-Version: 1.0.0 -Bundle-Activator: test.link.b.client.Activator -Import-Package: org.osgi.framework, test.link.b, test.link.b.params diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.b.client/test/link/b/client/Activator.java b/bundles/org.eclipse.osgi.tests/bundles_src/test.link.b.client/test/link/b/client/Activator.java deleted file mode 100644 index 4266b3f64..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.b.client/test/link/b/client/Activator.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package test.link.b.client; - -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.net.URL; -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import test.link.b.SomeAPI; -import test.link.b.params.AParam; - -public class Activator implements BundleActivator { - - public void start(BundleContext context) throws Exception { - SomeAPI api = new SomeAPI(); - api.getBundleID(context.getBundle()); - api.getString(new AParam()); - // test class that does not exist - try { - getClass().getClassLoader().loadClass("test.link.b.DoesNotExist"); //$NON-NLS-1$ - throw new RuntimeException("Unexpected class load success"); //$NON-NLS-1$ - } catch (ClassNotFoundException e) { - // expected - } - // test resource - URL resource = this.getClass().getResource("/test/link/b/resource.txt"); //$NON-NLS-1$ - if (resource == null) - throw new RuntimeException("Did not find resource.txt"); //$NON-NLS-1$ - BufferedReader reader = new BufferedReader(new InputStreamReader(resource.openStream())); - try { - String content = reader.readLine(); - if (!"Test content".equals(content)) //$NON-NLS-1$ - throw new RuntimeException("Unexpected content in resource.txt: " + content); //$NON-NLS-1$ - } finally { - reader.close(); - } - // test resource that does not exist - URL notExist = this.getClass().getResource("/test/link/b/DoesNotExist.txt"); //$NON-NLS-1$ - if (notExist != null) - throw new RuntimeException("Should not have found resource: " + notExist.getPath()); //$NON-NLS-1$ - - } - - public void stop(BundleContext context) throws Exception { - // TODO Auto-generated method stub - - } - -} diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.b/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.tests/bundles_src/test.link.b/META-INF/MANIFEST.MF deleted file mode 100644 index 1329e3e72..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.b/META-INF/MANIFEST.MF +++ /dev/null @@ -1,8 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: test.link.b -Bundle-SymbolicName: test.link.b -Bundle-Version: 1.0.0 -Export-Package: test.link.b; attr1="value1"; uses:="org.osgi.framework, test.link.b.params", - test.link.b.params; attr2="value2" -Import-Package: org.osgi.framework diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.b/test/link/b/SomeAPI.java b/bundles/org.eclipse.osgi.tests/bundles_src/test.link.b/test/link/b/SomeAPI.java deleted file mode 100644 index 3b29bd066..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.b/test/link/b/SomeAPI.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package test.link.b; - -import org.osgi.framework.Bundle; -import test.link.b.params.AParam; - -public class SomeAPI { - public Long getBundleID(Bundle bundle) { - return new Long(bundle.getBundleId()); - } - - public String getString(AParam arg0) { - return arg0.toString(); - } -} diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.b/test/link/b/params/AParam.java b/bundles/org.eclipse.osgi.tests/bundles_src/test.link.b/test/link/b/params/AParam.java deleted file mode 100644 index 6d8710c5a..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.b/test/link/b/params/AParam.java +++ /dev/null @@ -1,17 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package test.link.b.params; - -public class AParam { - public String toString() { - return "AParam"; //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.b/test/link/b/resource.txt b/bundles/org.eclipse.osgi.tests/bundles_src/test.link.b/test/link/b/resource.txt deleted file mode 100644 index 2eec599a1..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.b/test/link/b/resource.txt +++ /dev/null @@ -1 +0,0 @@ -Test content diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.c.client/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.tests/bundles_src/test.link.c.client/META-INF/MANIFEST.MF deleted file mode 100644 index 90019f532..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.c.client/META-INF/MANIFEST.MF +++ /dev/null @@ -1,7 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: test.link.c.client -Bundle-SymbolicName: test.link.c.client -Bundle-Version: 1.0.0 -Bundle-Activator: test.link.c.client.Activator -Import-Package: test.link.c.service1, test.link.c.service2, test.link.c.service3, org.osgi.framework diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.c.client/test/link/c/client/Activator.java b/bundles/org.eclipse.osgi.tests/bundles_src/test.link.c.client/test/link/c/client/Activator.java deleted file mode 100644 index 6ea746f00..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.c.client/test/link/c/client/Activator.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package test.link.c.client; - -import org.osgi.framework.*; -import test.link.c.service1.Service1; -import test.link.c.service2.Service2; -import test.link.c.service3.Service3; - -public class Activator implements BundleActivator { - - public void start(BundleContext context) throws Exception { - Service1 service1 = (Service1) checkService(Service1.class.getName(), context); - if (service1 == null) - throw new Exception("missing Service1"); //$NON-NLS-1$ - Service2 service2 = (Service2) checkService(Service2.class.getName(), context); - if (service2 == null) - throw new Exception("missing Service2"); //$NON-NLS-1$ - Service3 service3 = (Service3) checkService(Service3.class.getName(), context); - if (service3 == null) - throw new Exception("missing Service3"); //$NON-NLS-1$ - } - - private Object checkService(String name, BundleContext context) throws BundleException { - ServiceReference ref = context.getServiceReference(name); - if (ref == null) - throw new BundleException("Missing service " + name); //$NON-NLS-1$ - Object service = context.getService(ref); - if (service != null) - context.ungetService(ref); - return service; - } - - public void stop(BundleContext context) throws Exception { - // TODO Auto-generated method stub - - } - -} diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.c/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.tests/bundles_src/test.link.c/META-INF/MANIFEST.MF deleted file mode 100644 index 4a15453af..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.c/META-INF/MANIFEST.MF +++ /dev/null @@ -1,11 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: test.link.c -Bundle-SymbolicName: test.link.c -Bundle-Version: 1.0.0 -Bundle-Activator: test.link.c.Activator -Export-Package: - test.link.c.service1; attr1="value1", - test.link.c.service2; attr2="value2"; uses:="test.link.c.service1", - test.link.c.service3; attr3="value3"; uses:="test.link.c.service2" -Import-Package: org.osgi.framework diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.c/test/link/c/Activator.java b/bundles/org.eclipse.osgi.tests/bundles_src/test.link.c/test/link/c/Activator.java deleted file mode 100644 index ae6d199ae..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.c/test/link/c/Activator.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package test.link.c; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import test.link.c.service1.Service1; -import test.link.c.service2.Service2; -import test.link.c.service3.Service3; - -public class Activator implements BundleActivator { - - public void start(BundleContext context) throws Exception { - context.registerService(Service1.class.getName(), new Service1() {}, null); - context.registerService(new String[] {Service1.class.getName(), Service2.class.getName()}, new Service2() {}, null); - context.registerService(new String[] {Service1.class.getName(), Service2.class.getName(), Service3.class.getName()}, new Service3() {}, null); - } - - public void stop(BundleContext context) throws Exception { - // nothing - } - -} diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.c/test/link/c/service1/Service1.java b/bundles/org.eclipse.osgi.tests/bundles_src/test.link.c/test/link/c/service1/Service1.java deleted file mode 100644 index 5286b6f47..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.c/test/link/c/service1/Service1.java +++ /dev/null @@ -1,15 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package test.link.c.service1; - -public interface Service1 { - -} diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.c/test/link/c/service2/Service2.java b/bundles/org.eclipse.osgi.tests/bundles_src/test.link.c/test/link/c/service2/Service2.java deleted file mode 100644 index 5186e1e52..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.c/test/link/c/service2/Service2.java +++ /dev/null @@ -1,17 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package test.link.c.service2; - -import test.link.c.service1.Service1; - -public interface Service2 extends Service1 { - -} diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.c/test/link/c/service3/Service3.java b/bundles/org.eclipse.osgi.tests/bundles_src/test.link.c/test/link/c/service3/Service3.java deleted file mode 100644 index 69c7bd03c..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.c/test/link/c/service3/Service3.java +++ /dev/null @@ -1,17 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package test.link.c.service3; - -import test.link.c.service2.Service2; - -public interface Service3 extends Service2 { - -} diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.d/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.tests/bundles_src/test.link.d/META-INF/MANIFEST.MF deleted file mode 100644 index 102d6aea2..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.d/META-INF/MANIFEST.MF +++ /dev/null @@ -1,11 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: test.link.d -Bundle-SymbolicName: test.link.d -Bundle-Version: 1.0.0 -Bundle-Activator: test.link.d.Activator -Import-Package: org.osgi.framework, - org.eclipse.osgi.tests.bundles, - org.osgi.service.framework, - org.osgi.framework.launch, - org.osgi.util.tracker diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.d/test/link/d/Activator.java b/bundles/org.eclipse.osgi.tests/bundles_src/test.link.d/test/link/d/Activator.java deleted file mode 100644 index 09f75a213..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.d/test/link/d/Activator.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package test.link.d; - -import java.util.HashMap; -import java.util.Map; -import org.eclipse.osgi.tests.bundles.AbstractBundleTests; -import org.eclipse.osgi.tests.bundles.BundleInstaller; -import org.osgi.framework.*; -import org.osgi.service.framework.CompositeBundle; -import org.osgi.service.framework.CompositeBundleFactory; -import org.osgi.util.tracker.ServiceTracker; - -public class Activator implements BundleActivator { - - public void start(BundleContext context) throws Exception { - ServiceReference installerRef = context.getServiceReference(BundleInstaller.class.getName()); - if (installerRef == null) - throw new Exception("Missing Service Permission"); //$NON-NLS-1$ - BundleInstaller installer = (BundleInstaller) context.getService(installerRef); - if (installer == null) - throw new Exception("Missing Service Permission"); //$NON-NLS-1$ - context.ungetService(installerRef); - - ServiceReference factoryRef = context.getServiceReference(CompositeBundleFactory.class.getName()); - if (factoryRef == null) - throw new Exception("Missing Service Permission"); //$NON-NLS-1$ - CompositeBundleFactory factory = (CompositeBundleFactory) context.getService(factoryRef); - if (factory == null) - throw new Exception("Missing Service Permission"); //$NON-NLS-1$ - - Map linkManifest = new HashMap(); - linkManifest.put(Constants.BUNDLE_SYMBOLICNAME, "childComposite"); //$NON-NLS-1$ - linkManifest.put(Constants.BUNDLE_VERSION, "1.0.0"); //$NON-NLS-1$ - linkManifest.put(Constants.IMPORT_PACKAGE, "org.eclipse.osgi.tests.bundles"); //$NON-NLS-1$ - linkManifest.put(CompositeBundleFactory.COMPOSITE_SERVICE_FILTER_IMPORT, "(objectClass=org.eclipse.osgi.tests.bundles.BundleInstaller)"); //$NON-NLS-1$ - CompositeBundle childComposite = null; - try { - childComposite = factory.installCompositeBundle(null, "childComposite", linkManifest); //$NON-NLS-1$ - } catch (SecurityException e) { - throw new Exception("Missing AllPermissions"); //$NON-NLS-1$ - } - - Bundle test = childComposite.getCompositeFramework().getBundleContext().installBundle(installer.getBundleLocation("test")); //$NON-NLS-1$ - if (test == null) - throw new Exception("Install of test bundle is null"); //$NON-NLS-1$ - - childComposite.start(); - - ServiceTracker trackInstaller = new ServiceTracker(childComposite.getBundleContext(), BundleInstaller.class.getName(), null); - trackInstaller.open(); - BundleInstaller childInstaller = (BundleInstaller) trackInstaller.waitForService(5000); - if (childInstaller != installer) - throw new Exception("Unexpected childInstaller: " + childInstaller); - test.start(); - Object[] expectedEvents = new Object[1]; - expectedEvents[0] = new BundleEvent(BundleEvent.STARTED, test); - AbstractBundleTests.compareResults(expectedEvents, AbstractBundleTests.simpleResults.getResults(1)); - } - - public void stop(BundleContext context) throws Exception { - // TODO Auto-generated method stub - - } - -} diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.e.client/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.tests/bundles_src/test.link.e.client/META-INF/MANIFEST.MF deleted file mode 100644 index 1de76b3b9..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.e.client/META-INF/MANIFEST.MF +++ /dev/null @@ -1,7 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: test.link.e.client -Bundle-SymbolicName: test.link.e.client -Bundle-Version: 1.0.0 -Bundle-Activator: test.link.e.client.Activator -Import-Package: test.link.e.service1, test.link.e.service2, test.link.e.service3, org.osgi.framework diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.e.client/test/link/e/client/Activator.java b/bundles/org.eclipse.osgi.tests/bundles_src/test.link.e.client/test/link/e/client/Activator.java deleted file mode 100644 index 8388603cf..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.e.client/test/link/e/client/Activator.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package test.link.e.client; - -import org.osgi.framework.*; -import test.link.e.service1.Service1; -import test.link.e.service2.Service2; -import test.link.e.service3.Service3; - -public class Activator implements BundleActivator { - - public void start(BundleContext context) throws Exception { - Service1 service1 = (Service1) checkService(Service1.class.getName(), context); - if (service1 == null) - throw new Exception("missing Service1"); //$NON-NLS-1$ - Service2 service2 = (Service2) checkService(Service2.class.getName(), context); - if (service2 == null) - throw new Exception("missing Service2"); //$NON-NLS-1$ - Service3 service3 = (Service3) checkService(Service3.class.getName(), context); - if (service3 == null) - throw new Exception("missing Service3"); //$NON-NLS-1$ - } - - private Object checkService(String name, BundleContext context) throws BundleException { - ServiceReference ref = context.getServiceReference(name); - if (ref == null) - throw new BundleException("Missing service " + name); //$NON-NLS-1$ - Object service = context.getService(ref); - if (service != null) - context.ungetService(ref); - return service; - } - - public void stop(BundleContext context) throws Exception { - // TODO Auto-generated method stub - - } - -} diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.e/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.tests/bundles_src/test.link.e/META-INF/MANIFEST.MF deleted file mode 100644 index 2370deb15..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.e/META-INF/MANIFEST.MF +++ /dev/null @@ -1,11 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: test.link.e -Bundle-SymbolicName: test.link.e -Bundle-Version: 1.0.0 -Bundle-Activator: test.link.e.Activator -Export-Package: - test.link.e.service1; attr1="value1", - test.link.e.service2; attr2="value2"; uses:="test.link.e.service1", - test.link.e.service3; attr3="value3"; uses:="test.link.e.service2" -Import-Package: org.osgi.framework diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.e/test/link/e/Activator.java b/bundles/org.eclipse.osgi.tests/bundles_src/test.link.e/test/link/e/Activator.java deleted file mode 100644 index b0c5aa000..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.e/test/link/e/Activator.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package test.link.e; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import test.link.e.service1.Service1; -import test.link.e.service2.Service2; -import test.link.e.service3.Service3; - -public class Activator implements BundleActivator { - - public void start(BundleContext context) throws Exception { - context.registerService(Service1.class.getName(), new Service1() {}, null); - context.registerService(new String[] {Service1.class.getName(), Service2.class.getName()}, new Service2() {}, null); - context.registerService(new String[] {Service1.class.getName(), Service2.class.getName(), Service3.class.getName()}, new Service3() {}, null); - } - - public void stop(BundleContext context) throws Exception { - // nothing - } - -} diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.e/test/link/e/service1/Service1.java b/bundles/org.eclipse.osgi.tests/bundles_src/test.link.e/test/link/e/service1/Service1.java deleted file mode 100644 index 232152f82..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.e/test/link/e/service1/Service1.java +++ /dev/null @@ -1,15 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package test.link.e.service1; - -public interface Service1 { - -} diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.e/test/link/e/service2/Service2.java b/bundles/org.eclipse.osgi.tests/bundles_src/test.link.e/test/link/e/service2/Service2.java deleted file mode 100644 index 39b95985f..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.e/test/link/e/service2/Service2.java +++ /dev/null @@ -1,17 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package test.link.e.service2; - -import test.link.e.service1.Service1; - -public interface Service2 extends Service1 { - -} diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.e/test/link/e/service3/Service3.java b/bundles/org.eclipse.osgi.tests/bundles_src/test.link.e/test/link/e/service3/Service3.java deleted file mode 100644 index 525bcd235..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.e/test/link/e/service3/Service3.java +++ /dev/null @@ -1,17 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package test.link.e.service3; - -import test.link.e.service2.Service2; - -public interface Service3 extends Service2 { - -} diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.postponed/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.tests/bundles_src/test.link.postponed/META-INF/MANIFEST.MF deleted file mode 100644 index cb31d5b6d..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.postponed/META-INF/MANIFEST.MF +++ /dev/null @@ -1,6 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: test.link.postponed -Bundle-SymbolicName: test.link.postponed -Bundle-Version: 1.0.0 -Fragment-Host: system.bundle diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.postponed/test/link/postponed/PostPonedCondition.java b/bundles/org.eclipse.osgi.tests/bundles_src/test.link.postponed/test/link/postponed/PostPonedCondition.java deleted file mode 100644 index db7e6820d..000000000 --- a/bundles/org.eclipse.osgi.tests/bundles_src/test.link.postponed/test/link/postponed/PostPonedCondition.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package test.link.postponed; - -import java.util.Dictionary; -import org.osgi.framework.Bundle; -import org.osgi.service.condpermadmin.Condition; -import org.osgi.service.condpermadmin.ConditionInfo; - -public class PostPonedCondition implements Condition { - - static public Condition getCondition(final Bundle bundle, final ConditionInfo info) { - return new PostPonedCondition(); - } - - public boolean isMutable() { - return true; - } - - public boolean isPostponed() { - return true; - } - - public boolean isSatisfied() { - return true; - } - - public boolean isSatisfied(Condition[] conditions, Dictionary context) { - return true; - } - -} diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/AutomatedTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/AutomatedTests.java index fddc9233d..f8be89a86 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/AutomatedTests.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/AutomatedTests.java @@ -12,7 +12,6 @@ package org.eclipse.osgi.tests; import junit.framework.*; import org.eclipse.osgi.tests.bundles.BundleTests; -import org.eclipse.osgi.tests.composites.AllCompositeTests; import org.eclipse.osgi.tests.debugoptions.DebugOptionsTestCase; import org.eclipse.osgi.tests.eventmgr.EventManagerTests; import org.eclipse.osgi.tests.filter.FilterTests; @@ -60,7 +59,6 @@ public class AutomatedTests extends TestCase { suite.addTest(EventManagerTests.suite()); suite.addTest(FilterTests.suite()); suite.addTest(PermissionTests.suite()); - suite.addTest(AllCompositeTests.suite()); suite.addTest(org.eclipse.osgi.tests.securityadmin.AllSecurityAdminTests.suite()); //disable suite.addTest(AllConsoleTests.suite()); suite.addTest(org.eclipse.osgi.tests.resource.AllTests.suite()); diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/composites/AbstractCompositeTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/composites/AbstractCompositeTests.java deleted file mode 100644 index 1413bae52..000000000 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/composites/AbstractCompositeTests.java +++ /dev/null @@ -1,233 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.osgi.tests.composites; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.HashMap; -import java.util.Map; -import junit.framework.Test; -import junit.framework.TestSuite; -import org.eclipse.osgi.tests.OSGiTestsActivator; -import org.eclipse.osgi.tests.bundles.AbstractBundleTests; -import org.eclipse.osgi.tests.bundles.BundleInstaller; -import org.osgi.framework.*; -import org.osgi.framework.launch.Framework; -import org.osgi.service.framework.*; -import org.osgi.service.packageadmin.PackageAdmin; -import org.osgi.util.tracker.ServiceTrackerCustomizer; - -public class AbstractCompositeTests extends AbstractBundleTests { - public static Test suite() { - return new TestSuite(AbstractCompositeTests.class); - } - - ServiceRegistration installerReg; - ServiceReference linkBundleFactoryRef; - CompositeBundleFactory linkBundleFactory; - - protected void setUp() throws Exception { - super.setUp(); - linkBundleFactoryRef = OSGiTestsActivator.getContext().getServiceReference(CompositeBundleFactory.class.getName()); - assertNotNull("LinkBundleFactory reference is null", linkBundleFactoryRef); //$NON-NLS-1$ - linkBundleFactory = (CompositeBundleFactory) OSGiTestsActivator.getContext().getService(linkBundleFactoryRef); - assertNotNull("LinkBundleFactory service is null", linkBundleFactory); //$NON-NLS-1$ - - installerReg = OSGiTestsActivator.getContext().registerService(BundleInstaller.class.getName(), installer, null); - } - - protected void tearDown() throws Exception { - super.tearDown(); - if (linkBundleFactoryRef != null) { - OSGiTestsActivator.getContext().ungetService(linkBundleFactoryRef); - linkBundleFactoryRef = null; - linkBundleFactory = null; - } - if (installerReg != null) - installerReg.unregister(); - } - - CompositeBundle createCompositeBundle(CompositeBundleFactory factory, String location, Map configuration, Map linkManifest, boolean start, boolean security) { - if (configuration == null) - configuration = new HashMap(); - if (security) - configuration.put(Constants.FRAMEWORK_SECURITY, "osgi"); //$NON-NLS-1$ - if (linkManifest == null) { - linkManifest = new HashMap(); - linkManifest.put(Constants.BUNDLE_SYMBOLICNAME, location); - } - CompositeBundle composite = null; - try { - composite = factory.installCompositeBundle(configuration, location, linkManifest); - } catch (BundleException e) { - fail("Unexpected exception creating composite bundle", e); //$NON-NLS-1$ - } - assertNotNull("Composite is null", composite); //$NON-NLS-1$ - assertEquals("Wrong composite location", location, composite.getLocation()); //$NON-NLS-1$ - assertEquals("Wrong state for SystemBundle", Bundle.STARTING, composite.getCompositeFramework().getState()); //$NON-NLS-1$ - SurrogateBundle surrogate = composite.getSurrogateBundle(); - assertNotNull("Surrogate is null", surrogate); //$NON-NLS-1$ - assertEquals("Wrong surrogte location", location, surrogate.getLocation()); //$NON-NLS-1$ - if (start) - startCompositeBundle(composite, false); - return composite; - } - - InputStream getBundleInput() throws BundleException { - URL bundlejar = OSGiTestsActivator.getContext().getBundle().getEntry("test_files/security/bundles/signed.jar"); //$NON-NLS-1$ - if (bundlejar == null) - throw new BundleException("Cannot find test bundle jar"); //$NON-NLS-1$ - try { - return bundlejar.openStream(); - } catch (IOException e) { - throw new BundleException("Cannot open test bundle stream", e); //$NON-NLS-1$ - } - } - - void waitForStateChange(Bundle bundle, int changeFrom) { - for (int i = 0; i < 10 && (bundle.getState() & changeFrom) != 0; i++) - try { - Thread.sleep(100); - } catch (InterruptedException e) { - // nothing - } - assertTrue("Wrong bundle state: " + bundle.getState(), (bundle.getState() & changeFrom) == 0); //$NON-NLS-1$ - - } - - Bundle installIntoCurrent(String name) { - try { - Bundle testBundle = installer.installBundle(name); - installer.resolveBundles(new Bundle[] {testBundle}); - return testBundle; - } catch (BundleException e) { - fail("failed to install test bundle", e); //$NON-NLS-1$ - } - return null; - } - - Bundle installIntoChild(Framework framework, String name) { - try { - return framework.getBundleContext().installBundle(installer.getBundleLocation(name)); - } catch (BundleException e) { - fail("failed to install test bundle", e); //$NON-NLS-1$ - } - return null; - } - - void startCompositeBundle(CompositeBundle composite, boolean expectFailure) { - boolean childFrameworkActive = composite.getCompositeFramework().getState() == Bundle.ACTIVE; - try { - composite.start(); - if (expectFailure) - fail("Expected an exception starting composite bundle"); //$NON-NLS-1$ - } catch (BundleException e) { - if (!expectFailure) - fail("Failed to start composite", e); //$NON-NLS-1$ - } - Framework childFramework = composite.getCompositeFramework(); - int expectedState = expectFailure && !childFrameworkActive ? Bundle.STARTING : Bundle.ACTIVE; - assertEquals("Wrong state for SystemBundle", expectedState, childFramework.getState()); //$NON-NLS-1$ - } - - void stopCompositeBundle(CompositeBundle composite) { - Framework childFramework = composite.getCompositeFramework(); - try { - composite.stop(); - } catch (BundleException e) { - fail("Unexpected error stopping composite", e); //$NON-NLS-1$ - } - FrameworkEvent stopEvent = null; - try { - stopEvent = childFramework.waitForStop(10000); - } catch (InterruptedException e) { - fail("Unexpected interrupted exception", e); //$NON-NLS-1$ - } - assertNotNull("Stop event is null", stopEvent); //$NON-NLS-1$ - assertEquals("Wrong stopEvent", FrameworkEvent.STOPPED, stopEvent.getType()); //$NON-NLS-1$ - - assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, childFramework.getState()); //$NON-NLS-1$ - } - - void uninstallCompositeBundle(CompositeBundle composite) { - Framework childFramework = composite.getCompositeFramework(); - try { - composite.uninstall(); - } catch (BundleException e) { - fail("Unexpected error uninstalling composite", e); //$NON-NLS-1$ - } - assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, childFramework.getState()); //$NON-NLS-1$ - } - - PackageAdmin getPackageAdmin(Bundle framework) { - BundleContext context = framework.getBundleContext(); - return (PackageAdmin) context.getService(context.getServiceReference(PackageAdmin.class.getName())); - } - - CompositeBundleFactory getFactory(Bundle framework) { - BundleContext context = framework.getBundleContext(); - assertNotNull("Child context is null.", context); //$NON-NLS-1$ - ServiceReference ref = context.getServiceReference(CompositeBundleFactory.class.getName()); - assertNotNull("Factory reference is null", ref); //$NON-NLS-1$ - CompositeBundleFactory factory = (CompositeBundleFactory) context.getService(ref); - assertNotNull("factory service is null", factory); //$NON-NLS-1$ - // just release now to make testcode simple - context.ungetService(ref); - return factory; - } - - class TestServiceListener implements ServiceListener { - final int[] results = new int[4]; - - public int[] getResults() { - return results; - } - - public void serviceChanged(ServiceEvent event) { - switch (event.getType()) { - case ServiceEvent.REGISTERED : - ++results[0]; - break; - case ServiceEvent.MODIFIED : - ++results[1]; - break; - case ServiceEvent.MODIFIED_ENDMATCH : - ++results[2]; - break; - case ServiceEvent.UNREGISTERING : - ++results[3]; - break; - } - } - } - - public class TestTrackerCustomizer implements ServiceTrackerCustomizer { - final int[] results = new int[3]; - - public int[] getResults() { - return results; - } - - public Object addingService(ServiceReference reference) { - ++results[0]; - return reference; - } - - public void modifiedService(ServiceReference reference, Object service) { - ++results[1]; - } - - public void removedService(ServiceReference reference, Object service) { - ++results[2]; - } - } -} diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/composites/AllCompositeTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/composites/AllCompositeTests.java deleted file mode 100644 index 2b01a1cfb..000000000 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/composites/AllCompositeTests.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.osgi.tests.composites; - -import junit.framework.Test; -import junit.framework.TestSuite; - -public class AllCompositeTests { - public static Test suite() { - TestSuite suite = new TestSuite(AllCompositeTests.class.getName()); - suite.addTest(CompositeCreateTests.suite()); - suite.addTest(CompositeShareTests.suite()); - suite.addTest(CompositeSecurityTests.suite()); - return suite; - } -} diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/composites/CompositeCreateTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/composites/CompositeCreateTests.java deleted file mode 100644 index 2252b2bdb..000000000 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/composites/CompositeCreateTests.java +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.osgi.tests.composites; - -import junit.framework.Test; -import junit.framework.TestSuite; -import org.osgi.framework.Bundle; -import org.osgi.service.framework.CompositeBundle; -import org.osgi.service.framework.CompositeBundleFactory; - -public class CompositeCreateTests extends AbstractCompositeTests { - public static Test suite() { - return new TestSuite(CompositeCreateTests.class); - } - - public void testCreateComposite01() { - CompositeBundle composite = createCompositeBundle(linkBundleFactory, "testCreateComposite01", null, null, true, false); //$NON-NLS-1$ - startCompositeBundle(composite, false); - stopCompositeBundle(composite); - uninstallCompositeBundle(composite); - } - - public void testCreateComposite02() { - CompositeBundle compositeLevel0 = createCompositeBundle(linkBundleFactory, "compositeLevel0", null, null, true, false); //$NON-NLS-1$ - CompositeBundleFactory factory = getFactory(compositeLevel0.getCompositeFramework()); - CompositeBundle compositeLevel1_1 = createCompositeBundle(factory, "compositeLevel1_1", null, null, true, false); //$NON-NLS-1$ - CompositeBundle compositeLevel1_2 = createCompositeBundle(factory, "compositeLevel1_2", null, null, true, false); //$NON-NLS-1$ - long idLevel1_1 = compositeLevel1_1.getBundleId(); - long idLevel1_2 = compositeLevel1_2.getBundleId(); - - stopCompositeBundle(compositeLevel0); - assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, compositeLevel1_1.getCompositeFramework().getState()); //$NON-NLS-1$ - assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, compositeLevel1_2.getCompositeFramework().getState()); //$NON-NLS-1$ - - startCompositeBundle(compositeLevel0, false); - // need to reget the bundles from child frameworks that were restarted - compositeLevel1_1 = (CompositeBundle) compositeLevel0.getCompositeFramework().getBundleContext().getBundle(idLevel1_1); - compositeLevel1_2 = (CompositeBundle) compositeLevel0.getCompositeFramework().getBundleContext().getBundle(idLevel1_2); - - assertEquals("Wrong state for SystemBundle", Bundle.ACTIVE, compositeLevel1_1.getCompositeFramework().getState()); //$NON-NLS-1$ - assertEquals("Wrong state for SystemBundle", Bundle.ACTIVE, compositeLevel1_2.getCompositeFramework().getState()); //$NON-NLS-1$ - - uninstallCompositeBundle(compositeLevel0); - assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, compositeLevel1_1.getCompositeFramework().getState()); //$NON-NLS-1$ - assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, compositeLevel1_1.getCompositeFramework().getState()); //$NON-NLS-1$ - } - - public void testCreateComposite03() { - CompositeBundle compositeLevel0 = createCompositeBundle(linkBundleFactory, "compositeLevel0", null, null, true, false); //$NON-NLS-1$ - CompositeBundleFactory factoryLevel1 = getFactory(compositeLevel0.getCompositeFramework()); - // create two level 1 composites - CompositeBundle compositeLevel1_1 = createCompositeBundle(factoryLevel1, "compositeLevel1_1", null, null, true, false); //$NON-NLS-1$ - CompositeBundle compositeLevel1_2 = createCompositeBundle(factoryLevel1, "compositeLevel1_2", null, null, true, false); //$NON-NLS-1$ - - // create two level 2 composites under 1_1 - CompositeBundleFactory factoryLevel2_1 = getFactory(compositeLevel1_1.getCompositeFramework()); - CompositeBundle compositeLevel2_1 = createCompositeBundle(factoryLevel2_1, "compositeLevel2_1", null, null, true, false); //$NON-NLS-1$ - CompositeBundle compositeLevel2_2 = createCompositeBundle(factoryLevel2_1, "compositeLevel2_2", null, null, true, false); //$NON-NLS-1$ - long idLevel2_1 = compositeLevel2_1.getBundleId(); - long idLevel2_2 = compositeLevel2_2.getBundleId(); - - // create two level 2 composites under 1_2 - CompositeBundleFactory factoryLevel2_2 = getFactory(compositeLevel1_2.getCompositeFramework()); - CompositeBundle compositeLevel2_3 = createCompositeBundle(factoryLevel2_2, "compositeLevel2_3", null, null, true, false); //$NON-NLS-1$ - CompositeBundle compositeLevel2_4 = createCompositeBundle(factoryLevel2_2, "compositeLevel2_4", null, null, true, false); //$NON-NLS-1$ - long idLevel2_3 = compositeLevel2_3.getBundleId(); - long idLevel2_4 = compositeLevel2_4.getBundleId(); - - stopCompositeBundle(compositeLevel1_1); - assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, compositeLevel2_1.getCompositeFramework().getState()); //$NON-NLS-1$ - assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, compositeLevel2_2.getCompositeFramework().getState()); //$NON-NLS-1$ - assertEquals("Wrong state for SystemBundle", Bundle.ACTIVE, compositeLevel2_3.getCompositeFramework().getState()); //$NON-NLS-1$ - assertEquals("Wrong state for SystemBundle", Bundle.ACTIVE, compositeLevel2_4.getCompositeFramework().getState()); //$NON-NLS-1$ - - startCompositeBundle(compositeLevel1_1, false); - // need to reget the bundles from child frameworks that were restarted - compositeLevel2_1 = (CompositeBundle) compositeLevel1_1.getCompositeFramework().getBundleContext().getBundle(idLevel2_1); - compositeLevel2_2 = (CompositeBundle) compositeLevel1_1.getCompositeFramework().getBundleContext().getBundle(idLevel2_2); - - assertEquals("Wrong state for SystemBundle", Bundle.ACTIVE, compositeLevel2_1.getCompositeFramework().getState()); //$NON-NLS-1$ - assertEquals("Wrong state for SystemBundle", Bundle.ACTIVE, compositeLevel2_2.getCompositeFramework().getState()); //$NON-NLS-1$ - assertEquals("Wrong state for SystemBundle", Bundle.ACTIVE, compositeLevel2_3.getCompositeFramework().getState()); //$NON-NLS-1$ - assertEquals("Wrong state for SystemBundle", Bundle.ACTIVE, compositeLevel2_4.getCompositeFramework().getState()); //$NON-NLS-1$ - - stopCompositeBundle(compositeLevel1_2); - assertEquals("Wrong state for SystemBundle", Bundle.ACTIVE, compositeLevel2_1.getCompositeFramework().getState()); //$NON-NLS-1$ - assertEquals("Wrong state for SystemBundle", Bundle.ACTIVE, compositeLevel2_2.getCompositeFramework().getState()); //$NON-NLS-1$ - assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, compositeLevel2_3.getCompositeFramework().getState()); //$NON-NLS-1$ - assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, compositeLevel2_4.getCompositeFramework().getState()); //$NON-NLS-1$ - - startCompositeBundle(compositeLevel1_2, false); - // need to reget the bundles from child frameworks that were restarted - compositeLevel2_3 = (CompositeBundle) compositeLevel1_2.getCompositeFramework().getBundleContext().getBundle(idLevel2_3); - compositeLevel2_4 = (CompositeBundle) compositeLevel1_2.getCompositeFramework().getBundleContext().getBundle(idLevel2_4); - - assertEquals("Wrong state for SystemBundle", Bundle.ACTIVE, compositeLevel2_1.getCompositeFramework().getState()); //$NON-NLS-1$ - assertEquals("Wrong state for SystemBundle", Bundle.ACTIVE, compositeLevel2_2.getCompositeFramework().getState()); //$NON-NLS-1$ - assertEquals("Wrong state for SystemBundle", Bundle.ACTIVE, compositeLevel2_3.getCompositeFramework().getState()); //$NON-NLS-1$ - assertEquals("Wrong state for SystemBundle", Bundle.ACTIVE, compositeLevel2_4.getCompositeFramework().getState()); //$NON-NLS-1$ - - uninstallCompositeBundle(compositeLevel0); - assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, compositeLevel2_1.getCompositeFramework().getState()); //$NON-NLS-1$ - assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, compositeLevel2_2.getCompositeFramework().getState()); //$NON-NLS-1$ - assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, compositeLevel2_3.getCompositeFramework().getState()); //$NON-NLS-1$ - assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, compositeLevel2_4.getCompositeFramework().getState()); //$NON-NLS-1$ - assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, compositeLevel1_1.getCompositeFramework().getState()); //$NON-NLS-1$ - assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, compositeLevel1_2.getCompositeFramework().getState()); //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/composites/CompositeSecurityTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/composites/CompositeSecurityTests.java deleted file mode 100644 index 7dea1a60c..000000000 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/composites/CompositeSecurityTests.java +++ /dev/null @@ -1,264 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2010 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.osgi.tests.composites; - -import java.security.*; -import java.util.*; -import junit.framework.Test; -import junit.framework.TestSuite; -import org.osgi.framework.*; -import org.osgi.service.condpermadmin.*; -import org.osgi.service.framework.CompositeBundle; -import org.osgi.service.framework.CompositeBundleFactory; -import org.osgi.service.permissionadmin.PermissionInfo; - -public class CompositeSecurityTests extends AbstractCompositeTests { - public static Test suite() { - return new TestSuite(CompositeSecurityTests.class); - } - - private Policy previousPolicy; - - protected void setUp() throws Exception { - if (System.getSecurityManager() != null) - fail("Cannot test with security manager set"); //$NON-NLS-1$ - previousPolicy = Policy.getPolicy(); - final Permission allPermission = new AllPermission(); - final PermissionCollection allPermissions = new PermissionCollection() { - private static final long serialVersionUID = 3258131349494708277L; - - // A simple PermissionCollection that only has AllPermission - public void add(Permission permission) { - //no adding to this policy - } - - public boolean implies(Permission permission) { - return true; - } - - public Enumeration elements() { - return new Enumeration() { - int cur = 0; - - public boolean hasMoreElements() { - return cur < 1; - } - - public Object nextElement() { - if (cur == 0) { - cur = 1; - return allPermission; - } - throw new NoSuchElementException(); - } - }; - } - }; - - Policy.setPolicy(new Policy() { - - public PermissionCollection getPermissions(CodeSource codesource) { - return allPermissions; - } - - public void refresh() { - // nothing - } - - }); - super.setUp(); - } - - protected void tearDown() throws Exception { - super.tearDown(); - if (System.getSecurityManager() != null) - System.setSecurityManager(null); - Policy.setPolicy(previousPolicy); - } - - public void testLinkSecurity01() { - Map linkManifest = new HashMap(); - linkManifest.put(Constants.BUNDLE_SYMBOLICNAME, "testLinkSecurity01"); //$NON-NLS-1$ - linkManifest.put(Constants.BUNDLE_VERSION, "1.0.0"); //$NON-NLS-1$ - linkManifest.put(Constants.IMPORT_PACKAGE, "org.eclipse.osgi.tests.bundles"); //$NON-NLS-1$ - linkManifest.put(CompositeBundleFactory.COMPOSITE_SERVICE_FILTER_IMPORT, "(objectClass=org.eclipse.osgi.tests.bundles.BundleInstaller)"); //$NON-NLS-1$ - CompositeBundle composite = createCompositeBundle(linkBundleFactory, "testLinkSecurity01", null, linkManifest, true, true); //$NON-NLS-1$ - - startCompositeBundle(composite, false); - - stopCompositeBundle(composite); - - uninstallCompositeBundle(composite); - } - - public void testLinkSecurity02() { - Map linkManifest = new HashMap(); - linkManifest.put(Constants.BUNDLE_SYMBOLICNAME, "testLinkSecurity02"); //$NON-NLS-1$ - linkManifest.put(Constants.BUNDLE_VERSION, "1.0.0"); //$NON-NLS-1$ - linkManifest.put(Constants.IMPORT_PACKAGE, "org.eclipse.osgi.tests.bundles"); //$NON-NLS-1$ - linkManifest.put(CompositeBundleFactory.COMPOSITE_SERVICE_FILTER_IMPORT, "(objectClass=org.eclipse.osgi.tests.bundles.BundleInstaller)"); //$NON-NLS-1$ - CompositeBundle composite = createCompositeBundle(linkBundleFactory, "testLinkSecurity02", null, linkManifest, true, true); //$NON-NLS-1$ - Bundle linkD = installIntoChild(composite.getCompositeFramework(), "test.link.d"); //$NON-NLS-1$ - - ConditionInfo[] conditions = new ConditionInfo[] {new ConditionInfo(BundleLocationCondition.class.getName(), new String[] {linkD.getLocation()})}; - ConditionalPermissionAdmin childCondAdmin = getCondPermAdmin(composite.getCompositeFramework().getBundleContext()); - childCondAdmin.addConditionalPermissionInfo(conditions, new PermissionInfo[] {new PermissionInfo("(test)")}); //$NON-NLS-1$ - try { - linkD.start(); - fail("Should fail to start test.link.d"); //$NON-NLS-1$ - } catch (BundleException e) { - assertEquals("Wrong exception type", BundleException.RESOLVE_ERROR, e.getType()); //$NON-NLS-1$ - } - - ConditionalPermissionUpdate update = childCondAdmin.newConditionalPermissionUpdate(); - List infos = update.getConditionalPermissionInfos(); - assertEquals("Wrong number of infos", 1, infos.size()); //$NON-NLS-1$ - infos.clear(); - - PermissionInfo packagePerm = new PermissionInfo(PackagePermission.class.getName(), "*", PackagePermission.IMPORT); //$NON-NLS-1$ - PermissionInfo servicePerm = new PermissionInfo(ServicePermission.class.getName(), "*", ServicePermission.GET + ',' + ServicePermission.REGISTER); //$NON-NLS-1$ - PermissionInfo allPerm = new PermissionInfo(AllPermission.class.getName(), "*", "*"); //$NON-NLS-1$ //$NON-NLS-2$ - PermissionInfo[] permissions = new PermissionInfo[] {packagePerm}; - infos.add(childCondAdmin.newConditionalPermissionInfo("test.link.d", conditions, permissions, ConditionalPermissionInfo.ALLOW)); //$NON-NLS-1$ - update.commit(); - - try { - linkD.start(); - fail("Should fail to start test.link.d"); //$NON-NLS-1$ - } catch (BundleException e) { - assertEquals("Wrong exception type", BundleException.ACTIVATOR_ERROR, e.getType()); //$NON-NLS-1$ - assertEquals("Unexpected exception message", "Missing Service Permission", e.getCause().getMessage()); //$NON-NLS-1$//$NON-NLS-2$ - } - - update = childCondAdmin.newConditionalPermissionUpdate(); - infos = update.getConditionalPermissionInfos(); - assertEquals("Wrong number of infos", 1, infos.size()); //$NON-NLS-1$ - infos.clear(); - permissions = new PermissionInfo[] {packagePerm, servicePerm}; - infos.add(childCondAdmin.newConditionalPermissionInfo("test.link.d", conditions, permissions, ConditionalPermissionInfo.ALLOW)); //$NON-NLS-1$ - update.commit(); - - try { - linkD.start(); - fail("Should fail to start test.link.d"); //$NON-NLS-1$ - } catch (BundleException e) { - assertEquals("Wrong exception type", BundleException.ACTIVATOR_ERROR, e.getType()); //$NON-NLS-1$ - assertEquals("Unexpected exception message", "Missing AllPermissions", e.getCause().getMessage()); //$NON-NLS-1$//$NON-NLS-2$ - } - - update = childCondAdmin.newConditionalPermissionUpdate(); - infos = update.getConditionalPermissionInfos(); - assertEquals("Wrong number of infos", 1, infos.size()); //$NON-NLS-1$ - infos.clear(); - permissions = new PermissionInfo[] {allPerm}; - infos.add(childCondAdmin.newConditionalPermissionInfo("test.link.d", conditions, permissions, ConditionalPermissionInfo.ALLOW)); //$NON-NLS-1$ - update.commit(); - - try { - linkD.start(); - } catch (BundleException e) { - fail("Unexpected exception", e); //$NON-NLS-1$ - } - - uninstallCompositeBundle(composite); - } - - public void testLinkSecurity03() { - Map linkManifest = new HashMap(); - linkManifest.put(Constants.BUNDLE_SYMBOLICNAME, "testLinkSecurity03"); //$NON-NLS-1$ - linkManifest.put(Constants.BUNDLE_VERSION, "1.0.0"); //$NON-NLS-1$ - linkManifest.put(Constants.IMPORT_PACKAGE, "org.eclipse.osgi.tests.bundles"); //$NON-NLS-1$ - linkManifest.put(CompositeBundleFactory.COMPOSITE_SERVICE_FILTER_IMPORT, "(objectClass=org.eclipse.osgi.tests.bundles.BundleInstaller)"); //$NON-NLS-1$ - CompositeBundle composite = createCompositeBundle(linkBundleFactory, "testLinkSecurity03", null, linkManifest, true, true); //$NON-NLS-1$ - - Bundle conditionBundle = installIntoChild(composite.getCompositeFramework(), "test.link.postponed"); //$NON-NLS-1$ - assertTrue("Condition bundle not resolved", getPackageAdmin(composite.getCompositeFramework()).resolveBundles(new Bundle[] {conditionBundle})); - Bundle linkD = installIntoChild(composite.getCompositeFramework(), "test.link.d"); //$NON-NLS-1$ - - ConditionInfo[] conditions = new ConditionInfo[] {new ConditionInfo(BundleLocationCondition.class.getName(), new String[] {linkD.getLocation()})}; - ConditionalPermissionAdmin childCondAdmin = getCondPermAdmin(composite.getCompositeFramework().getBundleContext()); - childCondAdmin.addConditionalPermissionInfo(conditions, new PermissionInfo[] {new PermissionInfo("(test)")}); //$NON-NLS-1$ - try { - linkD.start(); - fail("Should fail to start test.link.d"); //$NON-NLS-1$ - } catch (BundleException e) { - assertEquals("Wrong exception type", BundleException.RESOLVE_ERROR, e.getType()); //$NON-NLS-1$ - } - - ConditionalPermissionUpdate update = childCondAdmin.newConditionalPermissionUpdate(); - List infos = update.getConditionalPermissionInfos(); - assertEquals("Wrong number of infos", 1, infos.size()); //$NON-NLS-1$ - infos.clear(); - - PermissionInfo packagePerm = new PermissionInfo(PackagePermission.class.getName(), "*", PackagePermission.IMPORT); //$NON-NLS-1$ - PermissionInfo servicePerm = new PermissionInfo(ServicePermission.class.getName(), "*", ServicePermission.GET + ',' + ServicePermission.REGISTER); //$NON-NLS-1$ - PermissionInfo allPerm = new PermissionInfo(AllPermission.class.getName(), "*", "*"); //$NON-NLS-1$ //$NON-NLS-2$ - PermissionInfo[] permissions = new PermissionInfo[] {packagePerm}; - infos.add(childCondAdmin.newConditionalPermissionInfo("test.link.d", conditions, permissions, ConditionalPermissionInfo.ALLOW)); //$NON-NLS-1$ - update.commit(); - - try { - linkD.start(); - fail("Should fail to start test.link.d"); //$NON-NLS-1$ - } catch (BundleException e) { - assertEquals("Wrong exception type", BundleException.ACTIVATOR_ERROR, e.getType()); //$NON-NLS-1$ - assertEquals("Unexpected exception message", "Missing Service Permission", e.getCause().getMessage()); //$NON-NLS-1$//$NON-NLS-2$ - } - - update = childCondAdmin.newConditionalPermissionUpdate(); - infos = update.getConditionalPermissionInfos(); - assertEquals("Wrong number of infos", 1, infos.size()); //$NON-NLS-1$ - infos.clear(); - permissions = new PermissionInfo[] {packagePerm, servicePerm}; - infos.add(childCondAdmin.newConditionalPermissionInfo("test.link.d", conditions, permissions, ConditionalPermissionInfo.ALLOW)); //$NON-NLS-1$ - update.commit(); - - try { - linkD.start(); - fail("Should fail to start test.link.d"); //$NON-NLS-1$ - } catch (BundleException e) { - assertEquals("Wrong exception type", BundleException.ACTIVATOR_ERROR, e.getType()); //$NON-NLS-1$ - assertEquals("Unexpected exception message", "Missing AllPermissions", e.getCause().getMessage()); //$NON-NLS-1$//$NON-NLS-2$ - } - - update = childCondAdmin.newConditionalPermissionUpdate(); - infos = update.getConditionalPermissionInfos(); - assertEquals("Wrong number of infos", 1, infos.size()); //$NON-NLS-1$ - infos.clear(); - permissions = new PermissionInfo[] {allPerm}; - infos.add(childCondAdmin.newConditionalPermissionInfo("test.link.d", conditions, permissions, ConditionalPermissionInfo.ALLOW)); //$NON-NLS-1$ - update.commit(); - - try { - linkD.start(); - } catch (BundleException e) { - fail("Unexpected exception", e); - } - - uninstallCompositeBundle(composite); - } - - private ConditionalPermissionAdmin getCondPermAdmin(BundleContext context) { - ServiceReference permAdminRef = context.getServiceReference(ConditionalPermissionAdmin.class.getName()); - if (permAdminRef == null) { - fail("No Conditional Permission Admin service"); //$NON-NLS-1$ - return null; - } - try { - ConditionalPermissionAdmin permAdmin = (ConditionalPermissionAdmin) context.getService(permAdminRef); - if (permAdmin == null) - fail("No Conditional Permission Admin service"); //$NON-NLS-1$ - return permAdmin; - } finally { - context.ungetService(permAdminRef); - } - } -} diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/composites/CompositeShareTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/composites/CompositeShareTests.java deleted file mode 100644 index 875b3b3e6..000000000 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/composites/CompositeShareTests.java +++ /dev/null @@ -1,1073 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.osgi.tests.composites; - -import java.util.*; -import junit.framework.Test; -import junit.framework.TestSuite; -import org.eclipse.osgi.tests.OSGiTestsActivator; -import org.osgi.framework.*; -import org.osgi.framework.hooks.weaving.WeavingHook; -import org.osgi.framework.hooks.weaving.WovenClass; -import org.osgi.framework.launch.Framework; -import org.osgi.service.framework.*; -import org.osgi.service.packageadmin.PackageAdmin; -import org.osgi.util.tracker.ServiceTracker; - -public class CompositeShareTests extends AbstractCompositeTests { - public static Test suite() { - return new TestSuite(CompositeShareTests.class); - } - - public void testCompositeShare01() { - // simple test to create an empty composite bundle - // sharing one package from the parent - Map linkManifest = new HashMap(); - linkManifest.put(Constants.BUNDLE_SYMBOLICNAME, "testCompositeShare01"); //$NON-NLS-1$ - linkManifest.put(Constants.BUNDLE_VERSION, "1.0.0"); //$NON-NLS-1$ - linkManifest.put(Constants.IMPORT_PACKAGE, "org.osgi.service.application"); //$NON-NLS-1$ - CompositeBundle compositeBundle = createCompositeBundle(linkBundleFactory, "testCompositeShare01", null, linkManifest, false, false); //$NON-NLS-1$ - startCompositeBundle(compositeBundle, false); - SurrogateBundle surrogate = compositeBundle.getSurrogateBundle(); - assertNotNull("Surrogate is null", surrogate); //$NON-NLS-1$ - try { - surrogate.loadClass("org.osgi.service.application.ApplicationDescriptor"); //$NON-NLS-1$ - } catch (ClassNotFoundException e) { - fail("Unexpected class load exception", e); //$NON-NLS-1$ - } - // make sure missing classes do not endlessly loop - try { - surrogate.loadClass("does.not.exist.Here"); //$NON-NLS-1$ - fail("Expected a loadClass exception"); //$NON-NLS-1$ - } catch (ClassNotFoundException e) { - // expected - } - uninstallCompositeBundle(compositeBundle); - } - - public void testCompositeShare01a() { - // simple test to create an empty composite bundle - // sharing one package from the parent - Map linkManifest = new HashMap(); - linkManifest.put(Constants.BUNDLE_SYMBOLICNAME, getName()); - linkManifest.put(Constants.BUNDLE_VERSION, "1.0.0"); //$NON-NLS-1$ - linkManifest.put(Constants.IMPORT_PACKAGE, "org.osgi.service.application"); //$NON-NLS-1$ - CompositeBundle compositeBundle = createCompositeBundle(linkBundleFactory, getName(), null, linkManifest, false, false); - startCompositeBundle(compositeBundle, false); - - stopCompositeBundle(compositeBundle); - uninstallCompositeBundle(compositeBundle); - } - - public void testCompositeShare02() { - // simple test to create an empty composite bundle - // sharing one package from the parent and sharing one non-existing package from child - Map linkManifest = new HashMap(); - linkManifest.put(Constants.BUNDLE_SYMBOLICNAME, "testCompositeShare02"); //$NON-NLS-1$ - linkManifest.put(Constants.BUNDLE_VERSION, "1.0.0"); //$NON-NLS-1$ - linkManifest.put(Constants.IMPORT_PACKAGE, "org.osgi.service.application"); //$NON-NLS-1$ - linkManifest.put(Constants.EXPORT_PACKAGE, "foo"); //$NON-NLS-1$ - CompositeBundle compositeBundle = createCompositeBundle(linkBundleFactory, "testCompositeShare02", null, linkManifest, false, false); //$NON-NLS-1$ - - startCompositeBundle(compositeBundle, true); - SurrogateBundle surrogate = compositeBundle.getSurrogateBundle(); - assertNotNull("Companion is null", surrogate); //$NON-NLS-1$ - try { - surrogate.loadClass("org.osgi.service.application.ApplicationDescriptor"); //$NON-NLS-1$ - fail("Expected a loadClass exception"); //$NON-NLS-1$ - } catch (ClassNotFoundException e) { - // expected - } - uninstallCompositeBundle(compositeBundle); - } - - public void testCompositeShare03() { - // create a composite bundle with one bundle that exports some api to parent - Map linkManifest = new HashMap(); - linkManifest.put(Constants.BUNDLE_SYMBOLICNAME, "testCompositeShare03"); //$NON-NLS-1$ - linkManifest.put(Constants.BUNDLE_VERSION, "1.0.0"); //$NON-NLS-1$ - linkManifest.put(Constants.EXPORT_PACKAGE, "test.link.a; attr1=\"value1\"; uses:=\"org.osgi.framework, test.link.a.params\", test.link.a.params; attr2=\"value2\""); //$NON-NLS-1$ - CompositeBundle compositeBundle = createCompositeBundle(linkBundleFactory, "testCompositeShare03", null, linkManifest, false, false); //$NON-NLS-1$ - installIntoChild(compositeBundle.getCompositeFramework(), "test.link.a"); //$NON-NLS-1$ - - startCompositeBundle(compositeBundle, false); - try { - compositeBundle.loadClass("test.link.a.SomeAPI"); //$NON-NLS-1$ - } catch (ClassNotFoundException e) { - fail("Unexpected a loadClass exception", e); //$NON-NLS-1$ - } - //make sure missing classes do not endlessly loop - try { - compositeBundle.loadClass("does.not.exist.Here"); //$NON-NLS-1$ - fail("Expected a loadClass exception"); //$NON-NLS-1$ - } catch (ClassNotFoundException e) { - // expected - } - uninstallCompositeBundle(compositeBundle); - } - - public void testCompositeShare04a() { - // create a composite bundle with one bundle that exports some api to parent - // install one bundle into parent that uses API from child - Map linkManifest = new HashMap(); - linkManifest.put(Constants.BUNDLE_SYMBOLICNAME, "testCompositeShare04a"); //$NON-NLS-1$ - linkManifest.put(Constants.BUNDLE_VERSION, "1.0.0"); //$NON-NLS-1$ - linkManifest.put(Constants.EXPORT_PACKAGE, "test.link.a; attr1=\"bad value\"; uses:=\"org.osgi.framework, test.link.a.params\", test.link.a.params; attr2=\"bad value\""); //$NON-NLS-1$ - CompositeBundle compositeBundle = createCompositeBundle(linkBundleFactory, "testCompositeShare04a", null, linkManifest, false, false); //$NON-NLS-1$ - installIntoChild(compositeBundle.getCompositeFramework(), "test.link.a"); //$NON-NLS-1$ - Bundle testClient = installIntoCurrent("test.link.a.client"); //$NON-NLS-1$ - - SurrogateBundle surrogate = compositeBundle.getSurrogateBundle(); - assertNotNull("Companion is null", surrogate); //$NON-NLS-1$ - startCompositeBundle(compositeBundle, true); - try { - testClient.start(); - fail("Expected start failure"); //$NON-NLS-1$ - } catch (BundleException e) { - assertEquals("Unexpected exception type", BundleException.RESOLVE_ERROR, e.getType()); //$NON-NLS-1$ - } - // put good value back - linkManifest.put(Constants.EXPORT_PACKAGE, "test.link.a; attr1=\"value1\"; uses:=\"org.osgi.framework, test.link.a.params\", test.link.a.params; attr2=\"value2\""); //$NON-NLS-1$ - try { - compositeBundle.update(linkManifest); - } catch (BundleException e) { - fail("Unexpected composite update exception", e); //$NON-NLS-1$ - } - - startCompositeBundle(compositeBundle, false); - try { - testClient.start(); - } catch (BundleException e) { - fail("Unexpected exception", e); //$NON-NLS-1$ - } - - // put bad value back - linkManifest.put(Constants.EXPORT_PACKAGE, "test.link.a; attr1=\"bad value\"; uses:=\"org.osgi.framework, test.link.a.params\", test.link.a.params; attr2=\"bad value\""); //$NON-NLS-1$ - try { - compositeBundle.update(linkManifest); - } catch (BundleException e) { - fail("Unexpected composite update exception", e); //$NON-NLS-1$ - } - installer.refreshPackages(new Bundle[] {compositeBundle}); - startCompositeBundle(compositeBundle, true); - try { - testClient.start(); - fail("Expected start failure"); //$NON-NLS-1$ - } catch (BundleException e) { - assertEquals("Unexpected exception type", BundleException.RESOLVE_ERROR, e.getType()); //$NON-NLS-1$ - } - - uninstallCompositeBundle(compositeBundle); - } - - public void testCompositeShare04b() { - // create a composite bundle with one bundle that exports some api to parent - // install one bundle into parent that uses API from child - // test lazy uninstall - Map linkManifest = new HashMap(); - linkManifest.put(Constants.BUNDLE_SYMBOLICNAME, "testCompositeShare04b"); //$NON-NLS-1$ - linkManifest.put(Constants.BUNDLE_VERSION, "1.0.0"); //$NON-NLS-1$ - linkManifest.put(Constants.EXPORT_PACKAGE, "test.link.a; attr1=\"bad value\"; uses:=\"org.osgi.framework, test.link.a.params\", test.link.a.params; attr2=\"bad value\""); //$NON-NLS-1$ - CompositeBundle compositeBundle = createCompositeBundle(linkBundleFactory, "testCompositeShare04b", null, linkManifest, false, false); //$NON-NLS-1$ - installIntoChild(compositeBundle.getCompositeFramework(), "test.link.a"); //$NON-NLS-1$ - Bundle testClient = installIntoCurrent("test.link.a.client"); //$NON-NLS-1$ - - SurrogateBundle surrogate = compositeBundle.getSurrogateBundle(); - assertNotNull("Surrogate is null", surrogate); //$NON-NLS-1$ - startCompositeBundle(compositeBundle, true); - try { - testClient.start(); - fail("Expected start failure"); //$NON-NLS-1$ - } catch (BundleException e) { - assertEquals("Unexpected exception type", BundleException.RESOLVE_ERROR, e.getType()); //$NON-NLS-1$ - } - // put good value back - linkManifest.put(Constants.EXPORT_PACKAGE, "test.link.a; attr1=\"value1\"; uses:=\"org.osgi.framework, test.link.a.params\", test.link.a.params; attr2=\"value2\""); //$NON-NLS-1$ - try { - compositeBundle.update(linkManifest); - } catch (BundleException e) { - fail("Unexpected composite update exception", e); //$NON-NLS-1$ - } - - startCompositeBundle(compositeBundle, false); - try { - testClient.start(); - } catch (BundleException e) { - fail("Unexpected exception", e); //$NON-NLS-1$ - } - // refresh client to clear class laoder - installer.refreshPackages(new Bundle[] {testClient}); - - // put bad value back - linkManifest.put(Constants.EXPORT_PACKAGE, "test.link.a; attr1=\"bad value\"; uses:=\"org.osgi.framework, test.link.a.params\", test.link.a.params; attr2=\"bad value\""); //$NON-NLS-1$ - try { - compositeBundle.update(linkManifest); - } catch (BundleException e) { - fail("Unexpected composite update exception", e); //$NON-NLS-1$ - } - - // make sure testClient can still start before refresh - try { - testClient.start(); - } catch (BundleException e) { - fail("Unexpected exception", e); //$NON-NLS-1$ - } - - installer.refreshPackages(new Bundle[] {compositeBundle}); - startCompositeBundle(compositeBundle, true); - try { - testClient.start(); - fail("Expected start failure"); //$NON-NLS-1$ - } catch (BundleException e) { - assertEquals("Unexpected exception type", BundleException.RESOLVE_ERROR, e.getType()); //$NON-NLS-1$ - } - - // put good value back - linkManifest.put(Constants.EXPORT_PACKAGE, "test.link.a; attr1=\"value1\"; uses:=\"org.osgi.framework, test.link.a.params\", test.link.a.params; attr2=\"value2\""); //$NON-NLS-1$ - try { - compositeBundle.update(linkManifest); - } catch (BundleException e) { - fail("Unexpected composite update exception", e); //$NON-NLS-1$ - } - - startCompositeBundle(compositeBundle, false); - uninstallCompositeBundle(compositeBundle); - // make sure testClient can still start after uninstall - try { - testClient.start(); - } catch (BundleException e) { - fail("Unexpected exception", e); //$NON-NLS-1$ - } - - installer.refreshPackages(new Bundle[] {compositeBundle}); - try { - testClient.start(); - fail("Expected start failure"); //$NON-NLS-1$ - } catch (BundleException e) { - assertEquals("Unexpected exception type", BundleException.RESOLVE_ERROR, e.getType()); //$NON-NLS-1$ - } - } - - public void testCompositeShare04c() { - // create a composite bundle with one bundle that exports some api to parent - // install one bundle into parent that uses API from child - // Setup the composite to have substitutable exports - Map linkManifest = new HashMap(); - linkManifest.put(Constants.BUNDLE_SYMBOLICNAME, getName()); //$NON-NLS-1$ - linkManifest.put(Constants.BUNDLE_VERSION, "1.0.0"); //$NON-NLS-1$ - linkManifest.put(Constants.EXPORT_PACKAGE, "test.link.a; attr1=\"value1\"; uses:=\"org.osgi.framework, test.link.a.params\", test.link.a.params; attr2=\"value2\""); //$NON-NLS-1$ - linkManifest.put(Constants.IMPORT_PACKAGE, "test.link.a, test.link.a.params"); //$NON-NLS-1$ - CompositeBundle compositeBundle = createCompositeBundle(linkBundleFactory, getName(), null, linkManifest, false, false); //$NON-NLS-1$ - installIntoChild(compositeBundle.getCompositeFramework(), "test.link.a"); //$NON-NLS-1$ - Bundle testClient = installIntoCurrent("test.link.a.client"); //$NON-NLS-1$ - - SurrogateBundle surrogate = compositeBundle.getSurrogateBundle(); - assertNotNull("Companion is null", surrogate); //$NON-NLS-1$ - startCompositeBundle(compositeBundle, false); - try { - testClient.start(); - } catch (BundleException e) { - fail("Unexpected exception", e); //$NON-NLS-1$ - } - - // put bad value for export - linkManifest.put(Constants.EXPORT_PACKAGE, "test.link.a; attr1=\"bad value\"; uses:=\"org.osgi.framework, test.link.a.params\", test.link.a.params; attr2=\"bad value\""); //$NON-NLS-1$ - try { - compositeBundle.update(linkManifest); - } catch (BundleException e) { - fail("Unexpected composite update exception", e); //$NON-NLS-1$ - } - installer.refreshPackages(new Bundle[] {compositeBundle}); - startCompositeBundle(compositeBundle, true); - try { - testClient.start(); - fail("Expected start failure"); //$NON-NLS-1$ - } catch (BundleException e) { - assertEquals("Unexpected exception type", BundleException.RESOLVE_ERROR, e.getType()); //$NON-NLS-1$ - } - - uninstallCompositeBundle(compositeBundle); - } - - public void testCompositeShare04d_Bug363561() { - // create a composite bundle with one bundle that exports some api to parent - // install one bundle into parent that uses API from child - Map linkManifest = new HashMap(); - linkManifest.put(Constants.BUNDLE_SYMBOLICNAME, getName()); //$NON-NLS-1$ - linkManifest.put(Constants.BUNDLE_VERSION, "1.0.0"); //$NON-NLS-1$ - linkManifest.put(Constants.EXPORT_PACKAGE, "test.link.a; attr1=\"value1\"; uses:=\"org.osgi.framework, test.link.a.params\", test.link.a.params; attr2=\"value2\""); //$NON-NLS-1$ - CompositeBundle compositeBundle = createCompositeBundle(linkBundleFactory, "testCompositeShare04a", null, linkManifest, false, false); //$NON-NLS-1$ - Bundle constituent = installIntoChild(compositeBundle.getCompositeFramework(), "test.link.a"); //$NON-NLS-1$ - startCompositeBundle(compositeBundle, false); - - try { - constituent.uninstall(); - } catch (BundleException e) { - fail("Error on uninstall of constituent.", e); - } - stopCompositeBundle(compositeBundle); - uninstallCompositeBundle(compositeBundle); - } - - public void testCompositeShare05() { - // create a composite bundle with one bundle that exports some api to child - // install one bundle into child that uses API from parent - Map linkManifest = new HashMap(); - linkManifest.put(Constants.BUNDLE_SYMBOLICNAME, "testCompositeShare05"); //$NON-NLS-1$ - linkManifest.put(Constants.BUNDLE_VERSION, "1.0.0"); //$NON-NLS-1$ - linkManifest.put(Constants.IMPORT_PACKAGE, "test.link.a; attr1=\"bad value\", test.link.a.params; attr2=\"bad value\""); //$NON-NLS-1$ - CompositeBundle compositeBundle = createCompositeBundle(linkBundleFactory, "testCompositeShare03", null, linkManifest, false, false); //$NON-NLS-1$ - installIntoCurrent("test.link.a"); //$NON-NLS-1$ - Bundle testClient = installIntoChild(compositeBundle.getCompositeFramework(), "test.link.a.client"); //$NON-NLS-1$ - - SurrogateBundle surrogate = compositeBundle.getSurrogateBundle(); - assertNotNull("Surrogate is null", surrogate); //$NON-NLS-1$ - startCompositeBundle(compositeBundle, true); - assertFalse("Bundle should not be resolved", resolveBundle(compositeBundle.getCompositeFramework(), testClient)); - try { - testClient.start(); - } catch (BundleException e) { - fail("Unexpected exception type", e); //$NON-NLS-1$ - } - - // put good value back - linkManifest.put(Constants.IMPORT_PACKAGE, "test.link.a; attr1=\"value1\", test.link.a.params; attr2=\"value2\""); //$NON-NLS-1$ - try { - compositeBundle.update(linkManifest); - } catch (BundleException e) { - fail("Unexpected composite update exception", e); //$NON-NLS-1$ - } - - startCompositeBundle(compositeBundle, false); - try { - testClient.start(); - } catch (BundleException e) { - fail("Unexpected exception", e); //$NON-NLS-1$ - } - - // put bad value back - linkManifest.put(Constants.IMPORT_PACKAGE, "test.link.a; attr1=\"bad value\", test.link.a.params; attr2=\"bad value\""); //$NON-NLS-1$ - try { - compositeBundle.update(linkManifest); - } catch (BundleException e) { - fail("Unexpected composite update exception", e); //$NON-NLS-1$ - } - installer.refreshPackages(new Bundle[] {compositeBundle}); - startCompositeBundle(compositeBundle, true); - try { - testClient.start(); - fail("Expected start failure"); //$NON-NLS-1$ - } catch (BundleException e) { - assertEquals("Unexpected exception type", BundleException.RESOLVE_ERROR, e.getType()); //$NON-NLS-1$ - } - - uninstallCompositeBundle(compositeBundle); - } - - public void testCompositeShare06() { - // simple test to create an empty composite bundle - // sharing one package from a bundle in the parent and - // one package from the system bundle in the parent - Map linkManifest = new HashMap(); - linkManifest.put(Constants.BUNDLE_SYMBOLICNAME, "testCompositeShare06"); //$NON-NLS-1$ - linkManifest.put(Constants.BUNDLE_VERSION, "1.0.0"); //$NON-NLS-1$ - linkManifest.put(Constants.IMPORT_PACKAGE, "org.osgi.service.application, org.osgi.framework"); //$NON-NLS-1$ - CompositeBundle compositeBundle = createCompositeBundle(linkBundleFactory, "testCompositeShare06", null, linkManifest, false, false); //$NON-NLS-1$ - startCompositeBundle(compositeBundle, false); - SurrogateBundle surrogate = compositeBundle.getSurrogateBundle(); - assertNotNull("Surrogate is null", surrogate); //$NON-NLS-1$ - try { - surrogate.loadClass("org.osgi.service.application.ApplicationDescriptor"); //$NON-NLS-1$ - Class bundleClass = surrogate.loadClass("org.osgi.framework.Bundle"); //$NON-NLS-1$ - assertEquals("Bundle classes are not the same", Bundle.class, bundleClass); //$NON-NLS-1$ - } catch (ClassNotFoundException e) { - fail("Unexpected class load exception", e); //$NON-NLS-1$ - } - - uninstallCompositeBundle(compositeBundle); - } - - public void testCompositeShare07a() { - // test two way sharing - // create a composite bundle with one bundle that exports some api to child - // install one bundle into child that uses API from parent - // install a child bundle that exports some api to parent - // install one bundle into parent that uses API from child - Map linkManifest = new HashMap(); - linkManifest.put(Constants.BUNDLE_SYMBOLICNAME, "testCompositeShare07a"); //$NON-NLS-1$ - linkManifest.put(Constants.BUNDLE_VERSION, "1.0.0"); //$NON-NLS-1$ - linkManifest.put(Constants.IMPORT_PACKAGE, "test.link.a; attr1=\"value1\", test.link.a.params; attr2=\"value2\""); //$NON-NLS-1$ - linkManifest.put(Constants.EXPORT_PACKAGE, "test.link.b; attr1=\"value1\"; uses:=\"org.osgi.framework, test.link.b.params\", test.link.b.params; attr2=\"value2\""); //$NON-NLS-1$ - CompositeBundle compositeBundle = createCompositeBundle(linkBundleFactory, "testCompositeShare07a", null, linkManifest, false, false); //$NON-NLS-1$ - installIntoCurrent("test.link.a"); //$NON-NLS-1$ - Bundle testClientA = installIntoChild(compositeBundle.getCompositeFramework(), "test.link.a.client"); //$NON-NLS-1$ - installIntoChild(compositeBundle.getCompositeFramework(), "test.link.b"); //$NON-NLS-1$ - Bundle testClientB = installIntoCurrent("test.link.b.client"); //$NON-NLS-1$ - - startCompositeBundle(compositeBundle, false); - try { - testClientA.start(); - } catch (BundleException e) { - fail("Unexpected exception", e); //$NON-NLS-1$ - } - - try { - testClientB.start(); - } catch (BundleException e) { - fail("Unexpected exception", e); //$NON-NLS-1$ - } - - // use bad import package value - linkManifest.put(Constants.IMPORT_PACKAGE, "test.link.a; attr1=\"bad value\", test.link.a.params; attr2=\"bad value\""); //$NON-NLS-1$ - try { - compositeBundle.update(linkManifest); - } catch (BundleException e) { - fail("Unexpected composite update exception", e); //$NON-NLS-1$ - } - installer.refreshPackages(new Bundle[] {compositeBundle}); - startCompositeBundle(compositeBundle, true); - try { - testClientA.start(); - fail("Expected start failure"); //$NON-NLS-1$ - } catch (BundleException e) { - assertEquals("Unexpected exception type", BundleException.RESOLVE_ERROR, e.getType()); //$NON-NLS-1$ - } - try { - testClientB.start(); - fail("Expected start failure"); //$NON-NLS-1$ - } catch (BundleException e) { - assertEquals("Unexpected exception type", BundleException.RESOLVE_ERROR, e.getType()); //$NON-NLS-1$ - } - - // put good value back - linkManifest.put(Constants.IMPORT_PACKAGE, "test.link.a; attr1=\"value1\", test.link.a.params; attr2=\"value2\""); //$NON-NLS-1$ - try { - compositeBundle.update(linkManifest); - } catch (BundleException e) { - fail("Unexpected composite update exception", e); //$NON-NLS-1$ - } - - startCompositeBundle(compositeBundle, false); - try { - testClientA.start(); - } catch (BundleException e) { - fail("Unexpected exception", e); //$NON-NLS-1$ - } - - try { - testClientB.start(); - } catch (BundleException e) { - fail("Unexpected exception", e); //$NON-NLS-1$ - } - uninstallCompositeBundle(compositeBundle); - } - - public void testCompositeShare07b() { - // test two way sharing AND lazy update - // create a composite bundle with one bundle that exports some api to child - // install one bundle into child that uses API from parent - // install a child bundle that exports some api to parent - // install one bundle into parent that uses API from child - Map linkManifest = new HashMap(); - linkManifest.put(Constants.BUNDLE_SYMBOLICNAME, "testCompositeShare07b"); //$NON-NLS-1$ - linkManifest.put(Constants.BUNDLE_VERSION, "1.0.0"); //$NON-NLS-1$ - linkManifest.put(Constants.IMPORT_PACKAGE, "test.link.a; attr1=\"value1\", test.link.a.params; attr2=\"value2\""); //$NON-NLS-1$ - linkManifest.put(Constants.EXPORT_PACKAGE, "test.link.b; attr1=\"value1\"; uses:=\"org.osgi.framework, test.link.b.params\", test.link.b.params; attr2=\"value2\""); //$NON-NLS-1$ - CompositeBundle compositeBundle = createCompositeBundle(linkBundleFactory, "testCompositeShare07b", null, linkManifest, false, false); //$NON-NLS-1$ - installIntoCurrent("test.link.a"); //$NON-NLS-1$ - Bundle testClientA = installIntoChild(compositeBundle.getCompositeFramework(), "test.link.a.client"); //$NON-NLS-1$ - installIntoChild(compositeBundle.getCompositeFramework(), "test.link.b"); //$NON-NLS-1$ - Bundle testClientB = installIntoCurrent("test.link.b.client"); //$NON-NLS-1$ - - startCompositeBundle(compositeBundle, false); - try { - testClientA.start(); - testClientA.stop(); - } catch (BundleException e) { - fail("Unexpected exception", e); //$NON-NLS-1$ - } - - try { - testClientB.start(); - testClientB.stop(); - } catch (BundleException e) { - fail("Unexpected exception", e); //$NON-NLS-1$ - } - - // force a refresh packages of the composite to get new class loaders for the clients - installer.refreshPackages(new Bundle[] {compositeBundle}); - - // use bad import package value - linkManifest.put(Constants.BUNDLE_VERSION, "1.0.0.a"); //$NON-NLS-1$ - linkManifest.put(Constants.IMPORT_PACKAGE, "test.link.a; attr1=\"bad value\", test.link.a.params; attr2=\"bad value\""); //$NON-NLS-1$ - try { - compositeBundle.update(linkManifest); - } catch (BundleException e) { - fail("Unexpected composite update exception", e); //$NON-NLS-1$ - } - - // make sure we can still start the clients before a refresh; - // they should still be wired to the old content - try { - testClientA.start(); - testClientA.stop(); - } catch (BundleException e) { - fail("Unexpected exception", e); //$NON-NLS-1$ - } - - try { - testClientB.start(); - testClientB.stop(); - } catch (BundleException e) { - fail("Unexpected exception", e); //$NON-NLS-1$ - } - - installer.refreshPackages(new Bundle[] {compositeBundle}); - startCompositeBundle(compositeBundle, true); - try { - testClientA.start(); - fail("Expected start failure"); //$NON-NLS-1$ - } catch (BundleException e) { - assertEquals("Unexpected exception type", BundleException.RESOLVE_ERROR, e.getType()); //$NON-NLS-1$ - } - try { - testClientB.start(); - fail("Expected start failure"); //$NON-NLS-1$ - } catch (BundleException e) { - assertEquals("Unexpected exception type", BundleException.RESOLVE_ERROR, e.getType()); //$NON-NLS-1$ - } - - uninstallCompositeBundle(compositeBundle); - } - - public void testCompositeShare08() { - // Create a child framework to install composites into to test persistence - CompositeBundle compositeLevel0 = createCompositeBundle(linkBundleFactory, "testCompositeShare08LV0", null, null, true, false); //$NON-NLS-1$ - CompositeBundleFactory factoryLevel1 = getFactory(compositeLevel0.getCompositeFramework()); - // create a level 1 composites - CompositeBundle compositeLevel1 = createCompositeBundle(factoryLevel1, "testCompositeShare08LV1", null, null, true, false); //$NON-NLS-1$ - CompositeBundleFactory factoryLevel2 = getFactory(compositeLevel1.getCompositeFramework()); - long level1ID = compositeLevel1.getBundleId(); - - // test two way sharing - // create a composite bundle with one bundle that exports some api to child - // install one bundle into child that uses API from parent - // install a child bundle that exports some api to parent - // install one bundle into parent that uses API from child - Map linkManifest = new HashMap(); - linkManifest.put(Constants.BUNDLE_SYMBOLICNAME, "testCompositeShare08LV2"); //$NON-NLS-1$ - linkManifest.put(Constants.BUNDLE_VERSION, "1.0.0"); //$NON-NLS-1$ - linkManifest.put(Constants.IMPORT_PACKAGE, "test.link.a; attr1=\"value1\", test.link.a.params; attr2=\"value2\""); //$NON-NLS-1$ - linkManifest.put(Constants.EXPORT_PACKAGE, "test.link.b; attr1=\"value1\"; uses:=\"org.osgi.framework, test.link.b.params\", test.link.b.params; attr2=\"value2\""); //$NON-NLS-1$ - CompositeBundle compositeLevel2 = createCompositeBundle(factoryLevel2, "testCompositeShare08LV2", null, linkManifest, false, false); //$NON-NLS-1$ - long level2ID = compositeLevel2.getBundleId(); - - installIntoChild(compositeLevel1.getCompositeFramework(), "test.link.a"); //$NON-NLS-1$ - Bundle testClientA = installIntoChild(compositeLevel2.getCompositeFramework(), "test.link.a.client"); //$NON-NLS-1$ - long clientAID = testClientA.getBundleId(); - installIntoChild(compositeLevel2.getCompositeFramework(), "test.link.b"); //$NON-NLS-1$ - Bundle testClientB = installIntoChild(compositeLevel1.getCompositeFramework(), "test.link.b.client"); //$NON-NLS-1$ - long clientBID = testClientB.getBundleId(); - - startCompositeBundle(compositeLevel2, false); - try { - testClientA.start(); - } catch (BundleException e) { - fail("Unexpected exception", e); //$NON-NLS-1$ - } - - try { - testClientB.start(); - } catch (BundleException e) { - fail("Unexpected exception", e); //$NON-NLS-1$ - } - - // stop level 0 composite - stopCompositeBundle(compositeLevel0); - - // check the state of bundles installed into composite frameworks - assertEquals("Wrong state for client A", Bundle.UNINSTALLED, testClientA.getState()); //$NON-NLS-1$ - assertEquals("Wrong state for client B", Bundle.UNINSTALLED, testClientB.getState()); //$NON-NLS-1$ - - // start level 0 composite again - startCompositeBundle(compositeLevel0, false); - - // get reified level 1 and 2 composites and client A and B bundles - compositeLevel1 = (CompositeBundle) compositeLevel0.getCompositeFramework().getBundleContext().getBundle(level1ID); - compositeLevel2 = (CompositeBundle) compositeLevel1.getCompositeFramework().getBundleContext().getBundle(level2ID); - testClientA = compositeLevel2.getCompositeFramework().getBundleContext().getBundle(clientAID); - testClientB = compositeLevel1.getCompositeFramework().getBundleContext().getBundle(clientBID); - - // check the state of bundles installed into composite frameworks - assertEquals("Wrong state for client A", Bundle.ACTIVE, testClientA.getState()); //$NON-NLS-1$ - assertEquals("Wrong state for client B", Bundle.ACTIVE, testClientB.getState()); //$NON-NLS-1$ - - uninstallCompositeBundle(compositeLevel0); - } - - public void testCompositeShare09a() { - // exports packages from a bundle installed into the parent - // and imports the packages from a bundle installed into the child - // and services registered in the parent are propagated to the child - Bundle cService = installIntoCurrent("test.link.c"); //$NON-NLS-1$ - try { - cService.start(); - } catch (BundleException e) { - fail("Failed to start test.link.c", e); //$NON-NLS-1$ - } - Map linkManifest = new HashMap(); - linkManifest.put(Constants.BUNDLE_SYMBOLICNAME, "testCompositeShare09a"); //$NON-NLS-1$ - linkManifest.put(Constants.BUNDLE_VERSION, "1.0.0"); //$NON-NLS-1$ - linkManifest.put(Constants.IMPORT_PACKAGE, "test.link.c.service1,test.link.c.service2,test.link.c.service3"); //$NON-NLS-1$ - linkManifest.put(CompositeBundleFactory.COMPOSITE_SERVICE_FILTER_IMPORT, "(objectClass=test.link.c.service1.Service1),(objectClass=test.link.c.service2.Service2),(objectClass=test.link.c.service3.Service3)"); //$NON-NLS-1$ - CompositeBundle composite = createCompositeBundle(linkBundleFactory, "testCompositeShare09a", null, linkManifest, true, false); //$NON-NLS-1$ - - startCompositeBundle(composite, false); - - ServiceReference[] targetServices = composite.getSurrogateBundle().getRegisteredServices(); - assertNotNull("No target services found", targetServices); //$NON-NLS-1$ - assertEquals("Wrong number of target services", 3, targetServices.length); //$NON-NLS-1$ - - Bundle cClient = installIntoChild(composite.getCompositeFramework(), "test.link.c.client"); //$NON-NLS-1$ - - try { - cClient.start(); - cClient.stop(); - } catch (BundleException e) { - fail("Failed to start/stop the client", e); //$NON-NLS-1$ - } - - try { - cService.stop(); - } catch (BundleException e) { - fail("Failed to stop cService", e); //$NON-NLS-1$ - } - - try { - cClient.start(); - fail("Should have failed to start cClient"); //$NON-NLS-1$ - } catch (BundleException e) { - // expected - } - try { - cService.start(); - } catch (BundleException e) { - fail("Failed to start test.link.c", e); //$NON-NLS-1$ - } - try { - cClient.start(); - cClient.stop(); - } catch (BundleException e) { - fail("Failed to start/stop the client", e); //$NON-NLS-1$ - } - uninstallCompositeBundle(composite); - } - - public void testCompositeShare09b() { - // two way package and service tests - // exports packages from a bundle installed into the parent - // and imports the packages from a bundle installed into the child - // and services registered in the parent are propagated to the child - // and services registered in the child are propagated to the parent - Bundle cService = installIntoCurrent("test.link.c"); //$NON-NLS-1$ - try { - cService.start(); - } catch (BundleException e) { - fail("Failed to start test.link.c", e); //$NON-NLS-1$ - } - Map linkManifest = new HashMap(); - linkManifest.put(Constants.BUNDLE_SYMBOLICNAME, "testCompositeShare09b"); //$NON-NLS-1$ - linkManifest.put(Constants.BUNDLE_VERSION, "1.0.0"); //$NON-NLS-1$ - linkManifest.put(Constants.IMPORT_PACKAGE, "test.link.c.service1,test.link.c.service2,test.link.c.service3"); //$NON-NLS-1$ - linkManifest.put(Constants.EXPORT_PACKAGE, "test.link.e.service1; attr1=\"value1\", test.link.e.service2; attr2=\"value2\"; uses:=\"test.link.e.service1\", test.link.e.service3; attr3=\"value3\"; uses:=\"test.link.e.service2\""); //$NON-NLS-1$ - linkManifest.put(CompositeBundleFactory.COMPOSITE_SERVICE_FILTER_IMPORT, "(objectClass=test.link.c.service1.Service1),(objectClass=test.link.c.service2.Service2),(objectClass=test.link.c.service3.Service3)"); //$NON-NLS-1$ - linkManifest.put(CompositeBundleFactory.COMPOSITE_SERVICE_FILTER_EXPORT, "(objectClass=test.link.e.service1.Service1),(objectClass=test.link.e.service2.Service2),(objectClass=test.link.e.service3.Service3)"); //$NON-NLS-1$ - CompositeBundle composite = createCompositeBundle(linkBundleFactory, "testCompositeShare09b", null, linkManifest, false, false); //$NON-NLS-1$ - - Bundle eService = installIntoChild(composite.getCompositeFramework(), "test.link.e"); //$NON-NLS-1$ - startCompositeBundle(composite, false); - - try { - eService.start(); - } catch (BundleException e) { - fail("Failed to start test.link.e", e); //$NON-NLS-1$ - } - - ServiceReference[] childServices = composite.getSurrogateBundle().getRegisteredServices(); - assertNotNull("No child services found", childServices); //$NON-NLS-1$ - assertEquals("Wrong number of child services", 3, childServices.length); //$NON-NLS-1$ - - ServiceReference[] parentServices = composite.getRegisteredServices(); - assertNotNull("No parent services found", parentServices); //$NON-NLS-1$ - assertEquals("Wrong number of parent services", 3, parentServices.length); //$NON-NLS-1$ - - Bundle cClient = installIntoChild(composite.getCompositeFramework(), "test.link.c.client"); //$NON-NLS-1$ - Bundle eClient = installIntoCurrent("test.link.e.client"); //$NON-NLS-1$ - - try { - cClient.start(); - cClient.stop(); - } catch (BundleException e) { - fail("Failed to start/stop the client", e); //$NON-NLS-1$ - } - - try { - cService.stop(); - } catch (BundleException e) { - fail("Failed to stop cService", e); //$NON-NLS-1$ - } - - try { - cClient.start(); - fail("Should have failed to start cClient"); //$NON-NLS-1$ - } catch (BundleException e) { - // expected - } - try { - cService.start(); - } catch (BundleException e) { - fail("Failed to start test.link.c", e); //$NON-NLS-1$ - } - try { - cClient.start(); - cClient.stop(); - } catch (BundleException e) { - fail("Failed to start/stop the client", e); //$NON-NLS-1$ - } - - try { - eClient.start(); - eClient.stop(); - } catch (BundleException e) { - fail("Failed to start/stop the client", e); //$NON-NLS-1$ - } - - try { - eService.stop(); - } catch (BundleException e) { - fail("Failed to stop eService", e); //$NON-NLS-1$ - } - - try { - eClient.start(); - fail("Should have failed to start eClient"); //$NON-NLS-1$ - } catch (BundleException e) { - // expected - } - try { - eService.start(); - } catch (BundleException e) { - fail("Failed to start test.link.e", e); //$NON-NLS-1$ - } - try { - eClient.start(); - eClient.stop(); - } catch (BundleException e) { - fail("Failed to start/stop the client", e); //$NON-NLS-1$ - } - uninstallCompositeBundle(composite); - } - - public void testCompositeShare10() { - // test service listeners with services shared to child - String filter1 = "(key1=1)"; //$NON-NLS-1$ - String filter2 = "(key2=value1)"; //$NON-NLS-1$ - String filter3 = "(key3=true)"; //$NON-NLS-1$ - - Map linkManifest = new HashMap(); - linkManifest.put(Constants.BUNDLE_SYMBOLICNAME, "testCompositeShare10"); //$NON-NLS-1$ - linkManifest.put(Constants.BUNDLE_VERSION, "1.0.0"); //$NON-NLS-1$ - linkManifest.put(CompositeBundleFactory.COMPOSITE_SERVICE_FILTER_IMPORT, filter1 + ',' + filter2); - CompositeBundle composite = createCompositeBundle(linkBundleFactory, "testCompositeShare10", null, linkManifest, true, false); //$NON-NLS-1$ - - startCompositeBundle(composite, false); - - Hashtable props = new Hashtable(); - props.put("key1", new Integer(1)); //$NON-NLS-1$ - props.put("key2", "value1"); //$NON-NLS-1$//$NON-NLS-2$ - props.put("key3", Boolean.TRUE); //$NON-NLS-1$ - - // install listener to test with before registering the service so we can get the REGISTERED event - TestServiceListener resultListener = new TestServiceListener(); - try { - composite.getCompositeFramework().getBundleContext().addServiceListener(resultListener, "(&" + filter1 + filter2 + filter3 + ")"); //$NON-NLS-1$//$NON-NLS-2$ - } catch (InvalidSyntaxException e) { - fail("failed to add listener", e); //$NON-NLS-1$ - } - - // register a service that should match the listener filter - ServiceRegistration registration = OSGiTestsActivator.getContext().registerService(new String[] {Object.class.getName()}, new Object(), props); - try { - // expecting to have gotten 1 REGISTERED event - int[] results = resultListener.getResults(); - assertEquals("Wrong listener results", new int[] {1, 0, 0, 0}, results); //$NON-NLS-1$ - - ServiceReference[] targetServices = composite.getSurrogateBundle().getRegisteredServices(); - assertNotNull("No target services found", targetServices); //$NON-NLS-1$ - assertEquals("Wrong number of target services", 1, targetServices.length); //$NON-NLS-1$ - - // modify the service properties so they match both the link description - // and the test listener filter - props.put("key4", "value1"); //$NON-NLS-1$ //$NON-NLS-2$ - registration.setProperties(props); - // expecting to get a MODIFIED event - assertEquals("Wrong listener results", new int[] {1, 1, 0, 0}, results); //$NON-NLS-1$ - - // modify the service properties so they match the link description - // but not the test listener filter - props.put("key3", Boolean.FALSE); //$NON-NLS-1$ - registration.setProperties(props); - // expecting to get a MODIFIED_ENDMATCH event - assertEquals("Wrong listener results", new int[] {1, 1, 1, 0}, results); //$NON-NLS-1$ - - // modify the service properties so they still match teh link description - // but still do not match the test listener filter - props.put("key4", "value2"); //$NON-NLS-1$ //$NON-NLS-2$ - registration.setProperties(props); - // expecting no new events - assertEquals("Wrong listener results", new int[] {1, 1, 1, 0}, results); //$NON-NLS-1$ - - // modify the service properties so they match the link description - // and again match the test listener filter - props.put("key3", Boolean.TRUE); //$NON-NLS-1$ - registration.setProperties(props); - // expecting to get a MODIFIED event - assertEquals("Wrong listener results", new int[] {1, 2, 1, 0}, results); //$NON-NLS-1$ - - // modify the service properties so they do not match the link description - // or the test listener filter - props.put("key1", new Integer(2)); //$NON-NLS-1$ - props.put("key2", "value2"); //$NON-NLS-1$ //$NON-NLS-2$ - registration.setProperties(props); - // expecting to get an UNREGISTERING event - assertEquals("Wrong listener results", new int[] {1, 2, 1, 1}, results); //$NON-NLS-1$ - - } finally { - composite.getCompositeFramework().getBundleContext().removeServiceListener(resultListener); - if (registration != null) - registration.unregister(); - } - - uninstallCompositeBundle(composite); - } - - public void testCompositeShare11() { - // Test service trackers with shared services to child - String filter1 = "(key1=1)"; //$NON-NLS-1$ - String filter2 = "(key2=value1)"; //$NON-NLS-1$ - String filter3 = "(key3=true)"; //$NON-NLS-1$ - - Map linkManifest = new HashMap(); - linkManifest.put(Constants.BUNDLE_SYMBOLICNAME, "testCompositeShare11"); //$NON-NLS-1$ - linkManifest.put(Constants.BUNDLE_VERSION, "1.0.0"); //$NON-NLS-1$ - linkManifest.put(CompositeBundleFactory.COMPOSITE_SERVICE_FILTER_IMPORT, filter1 + ',' + filter2); - CompositeBundle composite = createCompositeBundle(linkBundleFactory, "testCompositeShare10", null, linkManifest, true, false); //$NON-NLS-1$ - - startCompositeBundle(composite, false); - - Hashtable props = new Hashtable(); - props.put("key1", new Integer(1)); //$NON-NLS-1$ - props.put("key2", "value1"); //$NON-NLS-1$//$NON-NLS-2$ - props.put("key3", Boolean.TRUE); //$NON-NLS-1$ - - // open tracker to test with before registering the service so we can get the REGISTERED event - ServiceTracker tracker = null; - TestTrackerCustomizer resultListener = new TestTrackerCustomizer(); - try { - tracker = new ServiceTracker(composite.getCompositeFramework().getBundleContext(), composite.getCompositeFramework().getBundleContext().createFilter("(&" + filter1 + filter2 + filter3 + ")"), resultListener); //$NON-NLS-1$ //$NON-NLS-2$ - tracker.open(); - } catch (InvalidSyntaxException e) { - fail("failed to add listener", e); //$NON-NLS-1$ - } - - // register a service that should match the listener filter - ServiceRegistration registration = OSGiTestsActivator.getContext().registerService(new String[] {Object.class.getName()}, new Object(), props); - try { - // expecting to have gotten 1 addingService call - int[] results = resultListener.getResults(); - assertEquals("Wrong listener results", new int[] {1, 0, 0}, results); //$NON-NLS-1$ - - ServiceReference[] targetServices = composite.getSurrogateBundle().getRegisteredServices(); - assertNotNull("No target services found", targetServices); //$NON-NLS-1$ - assertEquals("Wrong number of target services", 1, targetServices.length); //$NON-NLS-1$ - - // modify the service properties so they match both the link description - // and the test tracker filter - props.put("key4", "value1"); //$NON-NLS-1$ //$NON-NLS-2$ - registration.setProperties(props); - // expecting to get 1 modifiedService call - assertEquals("Wrong listener results", new int[] {1, 1, 0}, results); //$NON-NLS-1$ - - // modify the service properties so they match the link description - // but not the test tracker filter - props.put("key3", Boolean.FALSE); //$NON-NLS-1$ - registration.setProperties(props); - // expecting to get a removedService call - assertEquals("Wrong listener results", new int[] {1, 1, 1}, results); //$NON-NLS-1$ - - // modify the service properties so they still match the link description - // but still do not match the test listener filter - props.put("key4", "value2"); //$NON-NLS-1$ //$NON-NLS-2$ - registration.setProperties(props); - // expecting no new method calls - assertEquals("Wrong listener results", new int[] {1, 1, 1}, results); //$NON-NLS-1$ - - // modify the service properties so they match the link description - // and again match the test tracker filter - props.put("key3", Boolean.TRUE); //$NON-NLS-1$ - registration.setProperties(props); - // expecting to get an addingService call - assertEquals("Wrong listener results", new int[] {2, 1, 1}, results); //$NON-NLS-1$ - - // modify the service properties so they do not match the link description - // or the test tracker filter - props.put("key1", new Integer(2)); //$NON-NLS-1$ - props.put("key2", "value2"); //$NON-NLS-1$ //$NON-NLS-2$ - registration.setProperties(props); - // expecting to get a removedService call - assertEquals("Wrong listener results", new int[] {2, 1, 2}, results); //$NON-NLS-1$ - - } finally { - if (tracker != null) - tracker.close(); - if (registration != null) - registration.unregister(); - } - - uninstallCompositeBundle(composite); - } - - public void testBug258209_1() { - // create a composite bundle to test thread context class loaders - Map linkManifest = new HashMap(); - linkManifest.put(Constants.BUNDLE_SYMBOLICNAME, "Bug258209.01"); //$NON-NLS-1$ - linkManifest.put(Constants.BUNDLE_VERSION, "1.0.0"); //$NON-NLS-1$ - CompositeBundle compositeBundle = createCompositeBundle(linkBundleFactory, "Bug258209.01", null, linkManifest, false, false); //$NON-NLS-1$ - Bundle testTCCL = installIntoChild(compositeBundle.getCompositeFramework(), "test.tccl"); //$NON-NLS-1$ - assertTrue("Bundle should be resolved", resolveBundle(compositeBundle.getCompositeFramework(), testTCCL)); - try { - testTCCL.start(); - } catch (BundleException e) { - fail("Unexpected exception starting bundle", e); //$NON-NLS-1$ - } - assertEquals("Unexpected state", Bundle.RESOLVED, testTCCL.getState()); //$NON-NLS-1$ - // this will start the framework on the current thread; test that the correct tccl is used - startCompositeBundle(compositeBundle, false); - assertEquals("Unexpected state", Bundle.ACTIVE, testTCCL.getState()); //$NON-NLS-1$ - - // test that the correct tccl is used for framework update - Framework framework = compositeBundle.getCompositeFramework(); - try { - framework.update(); - checkActive(testTCCL); - } catch (Exception e) { - fail("Unexpected exception", e); //$NON-NLS-1$ - } - assertEquals("Unexpected state", Bundle.ACTIVE, testTCCL.getState()); //$NON-NLS-1$ - - // test that the correct tccl is used for refresh packages - PackageAdmin pa = getPackageAdmin(compositeBundle.getCompositeFramework()); - pa.refreshPackages(new Bundle[] {testTCCL}); - checkActive(testTCCL); - assertEquals("Unexpected state", Bundle.ACTIVE, testTCCL.getState()); //$NON-NLS-1$ - - // use the tccl service to start the test bundle. - BundleContext context = compositeBundle.getCompositeFramework().getBundleContext(); - ClassLoader serviceTCCL = null; - try { - serviceTCCL = (ClassLoader) context.getService(context.getServiceReferences(ClassLoader.class.getName(), "(equinox.classloader.type=contextClassLoader)")[0]);//$NON-NLS-1$ - } catch (InvalidSyntaxException e) { - fail("Unexpected", e);//$NON-NLS-1$ - } - ClassLoader current = Thread.currentThread().getContextClassLoader(); - Thread.currentThread().setContextClassLoader(serviceTCCL); - try { - testTCCL.stop(); - testTCCL.start(); - } catch (BundleException e) { - fail("Unepected", e); //$NON-NLS-1$ - } finally { - Thread.currentThread().setContextClassLoader(current); - } - // test that starting directly works - try { - testTCCL.stop(); - testTCCL.start(); - } catch (BundleException e) { - fail("Unepected", e); //$NON-NLS-1$ - } - uninstallCompositeBundle(compositeBundle); - } - - public void testBug365677() { - // create a composite bundle with one bundle that exports some api to child - // install one bundle into child that uses API from parent - // use a weavig hook in the child to add a dynamic import to the client bundle - Map linkManifest = new HashMap(); - linkManifest.put(Constants.BUNDLE_SYMBOLICNAME, getName()); //$NON-NLS-1$ - linkManifest.put(Constants.BUNDLE_VERSION, "1.0.0"); //$NON-NLS-1$ - linkManifest.put(Constants.IMPORT_PACKAGE, "org.osgi.service.application, test.link.a; attr1=\"value1\", test.link.a.params; attr2=\"value2\""); //$NON-NLS-1$ - CompositeBundle compositeBundle = createCompositeBundle(linkBundleFactory, getName(), null, linkManifest, false, false); //$NON-NLS-1$ - installIntoCurrent("test.link.a"); //$NON-NLS-1$ - final Bundle testClient = installIntoChild(compositeBundle.getCompositeFramework(), "test.link.a.client"); //$NON-NLS-1$ - - startCompositeBundle(compositeBundle, false); - // first confirm the testClient cannot load from the package that will be added dynamically - try { - testClient.loadClass("org.osgi.service.application.ApplicationDescriptor"); //$NON-NLS-1$ - fail("Expected class load exception"); //$NON-NLS-1$ - } catch (ClassNotFoundException e) { - // expected - } - - // Add a weaving hook that will add the dyanmic import - compositeBundle.getCompositeFramework().getBundleContext().registerService(WeavingHook.class, new WeavingHook() { - - public void weave(WovenClass wovenClass) { - Bundle b = wovenClass.getBundleWiring().getBundle(); - if (testClient != b) - return; - wovenClass.getDynamicImports().add("org.osgi.service.application"); - } - }, null); - - // Start client to kick the weaving hook - try { - testClient.start(); - } catch (BundleException e) { - fail("Unexpected exception", e); //$NON-NLS-1$ - } - - // Now a load of a class from the dynamically added package should work. - try { - testClient.loadClass("org.osgi.service.application.ApplicationDescriptor"); //$NON-NLS-1$ - } catch (ClassNotFoundException e) { - fail("Unexpected class load exception", e); //$NON-NLS-1$ - } - uninstallCompositeBundle(compositeBundle); - } - - private void checkActive(Bundle b) { - try { - // just a hack to make sure we are restarted - Thread.sleep(500); - if (b.getState() != Bundle.ACTIVE) - Thread.sleep(500); - } catch (Exception e) { - fail("Unexpected exception", e); //$NON-NLS-1$ - } - } - - private boolean resolveBundle(Bundle framework, Bundle bundle) { - PackageAdmin pa = getPackageAdmin(framework); - return pa.resolveBundles(new Bundle[] {bundle}); - } -} diff --git a/bundles/org.eclipse.osgi/.classpath b/bundles/org.eclipse.osgi/.classpath index 61f80c36c..5e8b31637 100644 --- a/bundles/org.eclipse.osgi/.classpath +++ b/bundles/org.eclipse.osgi/.classpath @@ -7,7 +7,6 @@ <classpathentry kind="src" path="core/adaptor"/> <classpathentry kind="src" path="container/src"/> <classpathentry kind="src" path="core/framework"/> - <classpathentry kind="src" path="core/composite"/> <classpathentry kind="src" path="resolver/src"/> <classpathentry kind="src" path="defaultAdaptor/src"/> <classpathentry kind="src" path="eclipseAdaptor/src"/> diff --git a/bundles/org.eclipse.osgi/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi/META-INF/MANIFEST.MF index db8203896..58a8719f4 100644 --- a/bundles/org.eclipse.osgi/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.osgi/META-INF/MANIFEST.MF @@ -33,7 +33,6 @@ Export-Package: org.eclipse.osgi.container;version="1.0", org.osgi.framework.wiring; version="1.1", org.osgi.resource; version="1.0", org.osgi.service.condpermadmin;version="1.1.1", - org.osgi.service.framework; version="1.0"; x-internal:=true, org.osgi.service.log; version="1.3", org.osgi.service.packageadmin;version="1.2", org.osgi.service.permissionadmin;version="1.2", @@ -58,7 +57,6 @@ Export-Package: org.eclipse.osgi.container;version="1.0", org.eclipse.osgi.framework.internal.reliablefile;x-internal:=true, org.eclipse.osgi.framework.util;x-internal:=true, org.eclipse.osgi.internal.baseadaptor;x-internal:=true, - org.eclipse.osgi.internal.composite; x-internal:=true, org.eclipse.osgi.internal.loader;x-internal:=true, org.eclipse.osgi.internal.loader.buddy; x-internal:=true, org.eclipse.osgi.internal.module;x-internal:=true, @@ -70,7 +68,6 @@ Export-Package: org.eclipse.osgi.container;version="1.0", org.eclipse.osgi.internal.provisional.verifier;x-friends:="org.eclipse.update.core,org.eclipse.ui.workbench,org.eclipse.equinox.p2.artifact.repository", org.eclipse.osgi.internal.service.security;x-friends:="org.eclipse.equinox.security.ui", org.eclipse.osgi.internal.signedcontent; x-internal:=true, - org.eclipse.osgi.service.internal.composite; x-internal:=true, org.eclipse.equinox.log.internal; x-internal:=true Export-Service: org.osgi.service.packageadmin.PackageAdmin, org.osgi.service.permissionadmin.PermissionAdmin, diff --git a/bundles/org.eclipse.osgi/build.properties b/bundles/org.eclipse.osgi/build.properties index fdcd7b508..4f050f06b 100644 --- a/bundles/org.eclipse.osgi/build.properties +++ b/bundles/org.eclipse.osgi/build.properties @@ -22,7 +22,6 @@ src.includes = about.html,\ source.. = osgi/src,\ core/adaptor/,\ core/framework/,\ - core/composite/,\ resolver/src/,\ defaultAdaptor/src/,\ eclipseAdaptor/src/,\ @@ -31,13 +30,6 @@ source.. = osgi/src,\ security/src/,\ container/src/ output.. = bin/ -jre.compilation.profile = J2SE-1.5 - -# jre.compilation.profile = CDC-1.1/Foundation-1.1 -# bootClasspath=osgi/exceptions.jar;osgi/xmlParserAPIs.jar;${CDC-1.1/Foundation-1.1} - -javacSource=1.5 -javacTarget=jsr14 # To enable building the framework using projects from OSGi repo uncomment customBuildCallbacks # and add the following to the beginning of source.. diff --git a/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/framework/adaptor/BundleData.java b/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/framework/adaptor/BundleData.java index 71efc1192..0dbcd9c34 100644 --- a/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/framework/adaptor/BundleData.java +++ b/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/framework/adaptor/BundleData.java @@ -42,10 +42,6 @@ public interface BundleData extends BundleReference { public static final int TYPE_SINGLETON = 0x00000008; /** The BundleData is for an extension classpath bundle */ public static final int TYPE_EXTCLASSPATH_EXTENSION = 0x00000010; - /** The BundleData is for a composite bundle */ - public static final int TYPE_COMPOSITEBUNDLE = 0x00000020; - /** The BundleData is for a composite bundle surrogate */ - public static final int TYPE_SURROGATEBUNDLE = 0x00000040; /** * Creates the ClassLoader for the BundleData. The ClassLoader created diff --git a/bundles/org.eclipse.osgi/core/composite/org/eclipse/osgi/internal/composite/CompositeBase.java b/bundles/org.eclipse.osgi/core/composite/org/eclipse/osgi/internal/composite/CompositeBase.java deleted file mode 100644 index 6d47cb979..000000000 --- a/bundles/org.eclipse.osgi/core/composite/org/eclipse/osgi/internal/composite/CompositeBase.java +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2010 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.osgi.internal.composite; - -import java.io.IOException; -import java.io.InputStream; -import org.eclipse.osgi.framework.adaptor.BundleData; -import org.eclipse.osgi.framework.adaptor.ClassLoaderDelegate; -import org.eclipse.osgi.framework.internal.core.BundleHost; -import org.eclipse.osgi.internal.module.CompositeResolveHelper; -import org.eclipse.osgi.service.internal.composite.CompositeModule; -import org.eclipse.osgi.service.resolver.BundleDescription; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleException; -import org.osgi.framework.launch.Framework; - -/** - * This is a base class for both composite and surrogate bundles. - */ -public abstract class CompositeBase extends BundleHost implements CompositeResolveHelper, CompositeModule { - protected static String PROP_COMPOSITE = "org.eclipse.equinox.Composite"; //$NON-NLS-1$ - protected static String PROP_PARENTFRAMEWORK = "org.eclipse.equinox.parentFramework"; //$NON-NLS-1$ - - protected final Framework companionFramework; - protected final ThreadLocal resolving = new ThreadLocal(); - - public CompositeBase(BundleData bundledata, org.eclipse.osgi.framework.internal.core.Framework framework) throws BundleException { - super(bundledata, framework); - this.companionFramework = findCompanionFramework(framework, bundledata); - } - - /* - * Finds the companion framework for the composite/surrogate. - * For surrogate bundles this is the parent framework. - * For composite bundles this is the child framework. - */ - protected abstract Framework findCompanionFramework(org.eclipse.osgi.framework.internal.core.Framework thisFramework, BundleData thisData) throws BundleException; - - /* - * Gets the companion bundle for the composite/surrogate. - * For surrogate bundles this is the composite bundle. - * For composite bundles this is the surrogate bundle. - */ - abstract protected Bundle getCompanionBundle(); - - protected boolean isSurrogate() { - return false; - } - - public BundleDescription getCompositeDescription() { - return getBundleDescription(); - } - - public ClassLoaderDelegate getDelegate() { - return getBundleLoader(); - } - - public void refreshContent() { - resolving.set(Boolean.TRUE); - try { - framework.getPackageAdmin().refreshPackages(new Bundle[] {this}, true, null); - } finally { - resolving.set(null); - } - } - - public boolean resolveContent() { - resolving.set(Boolean.TRUE); - try { - return framework.getPackageAdmin().resolveBundles(new Bundle[] {this}); - } finally { - resolving.set(null); - } - } - - public void started(CompositeModule surrogate) { - // nothing - } - - public void stopped(CompositeModule surrogate) { - // nothing - } - - public void updateContent(InputStream content) throws BundleException { - super.update(content); - } - - public void update() throws BundleException { - throw new BundleException("Cannot update composite bundles", BundleException.INVALID_OPERATION); //$NON-NLS-1$ - } - - public void update(InputStream in) throws BundleException { - try { - in.close(); - } catch (IOException e) { - // ignore - } - throw new BundleException("Cannot update composite bundles", BundleException.INVALID_OPERATION); //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.osgi/core/composite/org/eclipse/osgi/internal/composite/CompositeClassLoader.java b/bundles/org.eclipse.osgi/core/composite/org/eclipse/osgi/internal/composite/CompositeClassLoader.java deleted file mode 100644 index e0706ff41..000000000 --- a/bundles/org.eclipse.osgi/core/composite/org/eclipse/osgi/internal/composite/CompositeClassLoader.java +++ /dev/null @@ -1,162 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2010 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.osgi.internal.composite; - -import java.io.IOException; -import java.net.URL; -import java.security.ProtectionDomain; -import java.util.*; -import org.eclipse.osgi.baseadaptor.BaseData; -import org.eclipse.osgi.baseadaptor.bundlefile.BundleEntry; -import org.eclipse.osgi.baseadaptor.bundlefile.BundleFile; -import org.eclipse.osgi.baseadaptor.loader.*; -import org.eclipse.osgi.framework.adaptor.BundleData; -import org.eclipse.osgi.framework.adaptor.ClassLoaderDelegate; -import org.osgi.framework.Bundle; - -public class CompositeClassLoader extends ClassLoader implements BaseClassLoader { - - private final ClassLoaderDelegate delegate; - private final ClasspathManager manager; - private final ClassLoaderDelegate companionDelegate; - //Support to cut class / resource loading cycles in the context of one thread. The contained object is a set of classname - private final ThreadLocal beingLoaded = new ThreadLocal(); - - public CompositeClassLoader(ClassLoader parent, ClassLoaderDelegate delegate, ClassLoaderDelegate companionDelegate, BaseData data) { - super(parent); - this.delegate = delegate; - this.manager = new ClasspathManager(data, new String[0], this); - this.companionDelegate = companionDelegate; - } - - public ClasspathEntry createClassPathEntry(BundleFile bundlefile, ProtectionDomain cpDomain) { - // nothing - return null; - } - - public Class defineClass(String name, byte[] classbytes, ClasspathEntry classpathEntry, BundleEntry entry) { - // nothing - return null; - } - - public ClasspathManager getClasspathManager() { - return manager; - } - - public ProtectionDomain getDomain() { - // no domain - return null; - } - - public Object publicDefinePackage(String name, String specTitle, String specVersion, String specVendor, String implTitle, String implVersion, String implVendor, URL sealBase) { - return definePackage(name, specTitle, specVersion, specVendor, implTitle, implVersion, implVendor, sealBase); - } - - public Class publicFindLoaded(String classname) { - return findLoadedClass(classname); - } - - public Object publicGetPackage(String pkgname) { - return getPackage(pkgname); - } - - public void attachFragment(BundleData bundledata, ProtectionDomain domain, String[] classpath) { - // nothing - } - - public void close() { - // nothing - } - - public Class findLocalClass(String classname) throws ClassNotFoundException { - if (!startLoading(classname)) - throw new ClassNotFoundException(classname); - try { - return companionDelegate.findClass(classname); - } finally { - stopLoading(classname); - } - } - - public URL findLocalResource(String resource) { - if (!startLoading(resource)) - return null; - try { - return companionDelegate.findResource(resource); - } finally { - stopLoading(resource); - } - } - - public Enumeration findLocalResources(String resource) { - if (!startLoading(resource)) - return null; - try { - return companionDelegate.findResources(resource); - } catch (IOException e) { - return null; - } finally { - stopLoading(resource); - } - } - - public ClassLoaderDelegate getDelegate() { - return delegate; - } - - public URL getResource(String name) { - return delegate.findResource(name); - } - - public void initialize() { - manager.initialize(); - } - - public Class loadClass(String name) throws ClassNotFoundException { - return delegate.findClass(name); - } - - private boolean startLoading(String name) { - Set classesAndResources = (Set) beingLoaded.get(); - if (classesAndResources != null && classesAndResources.contains(name)) - return false; - - if (classesAndResources == null) { - classesAndResources = new HashSet(3); - beingLoaded.set(classesAndResources); - } - classesAndResources.add(name); - return true; - } - - private void stopLoading(String name) { - ((Set) beingLoaded.get()).remove(name); - } - - public Bundle getBundle() { - return manager.getBaseData().getBundle(); - } - - @SuppressWarnings("unchecked") - public List<URL> findEntries(String path, String filePattern, int options) { - return Collections.EMPTY_LIST; - } - - @SuppressWarnings("unchecked") - public Collection<String> listResources(String path, String filePattern, int options) { - return Collections.EMPTY_LIST; - } - - @SuppressWarnings("unchecked") - public Collection<String> listLocalResources(String path, String filePattern, int options) { - return Collections.EMPTY_LIST; - } -} diff --git a/bundles/org.eclipse.osgi/core/composite/org/eclipse/osgi/internal/composite/CompositeConfigurator.java b/bundles/org.eclipse.osgi/core/composite/org/eclipse/osgi/internal/composite/CompositeConfigurator.java deleted file mode 100644 index b545a0a70..000000000 --- a/bundles/org.eclipse.osgi/core/composite/org/eclipse/osgi/internal/composite/CompositeConfigurator.java +++ /dev/null @@ -1,246 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2012 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.osgi.internal.composite; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URLConnection; -import java.security.AllPermission; -import java.security.ProtectionDomain; -import java.util.*; -import org.eclipse.osgi.baseadaptor.*; -import org.eclipse.osgi.baseadaptor.bundlefile.BundleEntry; -import org.eclipse.osgi.baseadaptor.hooks.AdaptorHook; -import org.eclipse.osgi.baseadaptor.hooks.ClassLoadingHook; -import org.eclipse.osgi.baseadaptor.loader.*; -import org.eclipse.osgi.framework.adaptor.*; -import org.eclipse.osgi.framework.log.FrameworkLog; -import org.eclipse.osgi.internal.module.*; -import org.eclipse.osgi.service.internal.composite.CompositeModule; -import org.eclipse.osgi.service.resolver.BundleDescription; -import org.osgi.framework.*; -import org.osgi.framework.launch.Framework; -import org.osgi.service.framework.CompositeBundle; -import org.osgi.service.framework.CompositeBundleFactory; - -public class CompositeConfigurator implements SynchronousBundleListener, HookConfigurator, AdaptorHook, ClassLoadingHook, CompositeBundleFactory, CompositeResolveHelperRegistry { - - // the base adaptor - private BaseAdaptor adaptor; - // the composite bundle factory service reference - private ServiceRegistration factoryService; - // the system bundle context - private BundleContext systemContext; - // The composite resolver helpers - private final Collection helpers = new ArrayList(0); - - public void addHooks(HookRegistry hookRegistry) { - // this is an adaptor hook to register the composite factory and - // to shutdown child frameworks on shutdown - hookRegistry.addAdaptorHook(this); - // this is a class loading hook in order to create special class loaders for composites - hookRegistry.addClassLoadingHook(this); - } - - public void addProperties(Properties properties) { - // nothing - } - - public FrameworkLog createFrameworkLog() { - // nothing - return null; - } - - /** - * @throws BundleException - */ - public void frameworkStart(BundleContext context) throws BundleException { - this.systemContext = context; - context.addBundleListener(this); - addHelpers(context.getBundles()); - // this is a composite resolve helper registry; add it to the resolver - ((ResolverImpl) adaptor.getState().getResolver()).setCompositeResolveHelperRegistry(this); - // register this as the composite bundle factory - factoryService = context.registerService(new String[] {CompositeBundleFactory.class.getName()}, this, null); - } - - public void frameworkStop(BundleContext context) { - // unregister the factory - if (factoryService != null) - factoryService.unregister(); - factoryService = null; - // stop any child frameworks than may still be running. - stopFrameworks(); - context.removeBundleListener(this); - removeAllHelpers(); - } - - public void frameworkStopping(BundleContext context) { - // nothing - } - - public void handleRuntimeError(Throwable error) { - // nothing - } - - public void initialize(BaseAdaptor initAdaptor) { - this.adaptor = initAdaptor; - } - - public URLConnection mapLocationToURLConnection(String location) { - // nothing - return null; - } - - public boolean matchDNChain(String pattern, String[] dnChain) { - // nothing - return false; - } - - public CompositeBundle installCompositeBundle(Map frameworkConfig, String location, Map compositeManifest) throws BundleException { - SecurityManager sm = System.getSecurityManager(); - if (sm != null) - // must have AllPermission to do this - sm.checkPermission(new AllPermission()); - // make a local copy of the manifest first - compositeManifest = new HashMap(compositeManifest); - // make sure the manifest is valid - CompositeHelper.validateCompositeManifest(compositeManifest); - - try { - // get an in memory input stream to jar content of the composite we want to install - InputStream content = CompositeHelper.getCompositeInput(frameworkConfig, compositeManifest); - CompositeBundle result = (CompositeBundle) systemContext.installBundle(location, content); - // set the permissions - CompositeHelper.setCompositePermissions(location, systemContext); - return result; - } catch (IOException e) { - throw new BundleException("Error creating composite bundle", e); //$NON-NLS-1$ - } - } - - private void stopFrameworks() { - Bundle[] allBundles = systemContext.getBundles(); - // stop each child framework - for (int i = 0; i < allBundles.length; i++) { - if (!(allBundles[i] instanceof CompositeBundle)) - continue; - CompositeBundle composite = (CompositeBundle) allBundles[i]; - try { - Framework child = composite.getCompositeFramework(); - child.stop(); - // need to wait for each child to stop - child.waitForStop(30000); - // TODO need to figure out a way to invalid the child - } catch (Throwable t) { - // TODO consider logging - t.printStackTrace(); - } - } - } - - public CompositeResolveHelper getCompositeResolveHelper(BundleDescription bundle) { - // Composite bundles implement the resolver helper - synchronized (helpers) { - if (helpers.size() == 0) - return null; - for (Iterator iHelpers = helpers.iterator(); iHelpers.hasNext();) { - CompositeBase composite = (CompositeBase) iHelpers.next(); - if (composite.getBundleId() == bundle.getBundleId()) - // If we found a resolver helper bundle; return it - return composite; - } - return null; - } - } - - public boolean addClassPathEntry(ArrayList cpEntries, String cp, ClasspathManager hostmanager, BaseData sourcedata, ProtectionDomain sourcedomain) { - // nothing - return false; - } - - public BaseClassLoader createClassLoader(ClassLoader parent, ClassLoaderDelegate delegate, BundleProtectionDomain domain, BaseData data, String[] bundleclasspath) { - if ((data.getType() & (BundleData.TYPE_COMPOSITEBUNDLE | BundleData.TYPE_SURROGATEBUNDLE)) == 0) - return null; - // only create composite class loaders for bundles that are of type composite | surrogate - CompositeModule compositeModule = (CompositeModule) ((CompositeBase) data.getBundle()).getCompanionBundle(); - if (compositeModule == null) { - throw new IllegalStateException("Could not find companion bundle for " + data.getBundle()); - } - ClassLoaderDelegate companionDelegate = compositeModule.getDelegate(); - if (companionDelegate == null) { - throw new IllegalStateException("Could not find the companion bundle delegate for" + compositeModule); - } - return new CompositeClassLoader(parent, delegate, companionDelegate, data); - } - - public String findLibrary(BaseData data, String libName) { - // nothing - return null; - } - - public ClassLoader getBundleClassLoaderParent() { - // nothing - return null; - } - - public void initializedClassLoader(BaseClassLoader baseClassLoader, BaseData data) { - // nothing - } - - public byte[] processClass(String name, byte[] classbytes, ClasspathEntry classpathEntry, BundleEntry entry, ClasspathManager manager) { - // nothing - return null; - } - - private void addHelpers(Bundle[] bundles) { - synchronized (helpers) { - for (int i = 0; i < bundles.length; i++) - addHelper(bundles[i]); - } - } - - private void addHelper(Bundle bundle) { - if (!(bundle instanceof CompositeBase)) - return; - synchronized (helpers) { - if (!helpers.contains(bundle)) - helpers.add(bundle); - } - } - - private void removeHelper(Bundle bundle) { - if (!(bundle instanceof CompositeBase)) - return; - synchronized (helpers) { - helpers.remove(bundle); - } - } - - private void removeAllHelpers() { - synchronized (helpers) { - helpers.clear(); - } - } - - public void bundleChanged(BundleEvent event) { - switch (event.getType()) { - case BundleEvent.INSTALLED : - addHelper(event.getBundle()); - break; - case BundleEvent.UNINSTALLED : - removeHelper(event.getBundle()); - break; - default : - break; - } - } -} diff --git a/bundles/org.eclipse.osgi/core/composite/org/eclipse/osgi/internal/composite/CompositeHelper.java b/bundles/org.eclipse.osgi/core/composite/org/eclipse/osgi/internal/composite/CompositeHelper.java deleted file mode 100644 index 5ef32c766..000000000 --- a/bundles/org.eclipse.osgi/core/composite/org/eclipse/osgi/internal/composite/CompositeHelper.java +++ /dev/null @@ -1,269 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.osgi.internal.composite; - -import java.io.*; -import java.util.*; -import java.util.Map.Entry; -import java.util.jar.*; -import org.eclipse.osgi.internal.baseadaptor.BaseStorageHook; -import org.eclipse.osgi.service.resolver.*; -import org.osgi.framework.*; -import org.osgi.service.permissionadmin.PermissionAdmin; -import org.osgi.service.permissionadmin.PermissionInfo; - -public class CompositeHelper { - private static final PermissionInfo[] COMPOSITE_PERMISSIONS = new PermissionInfo[] {new PermissionInfo(PackagePermission.class.getName(), "*", PackagePermission.EXPORT), new PermissionInfo(ServicePermission.class.getName(), "*", ServicePermission.REGISTER + ',' + ServicePermission.GET)}; //$NON-NLS-1$ //$NON-NLS-2$ - private static final String COMPOSITE_POLICY = "org.eclipse.osgi.composite"; //$NON-NLS-1$ - private static String ELEMENT_SEPARATOR = "; "; //$NON-NLS-1$ - private static final Object EQUALS_QUOTE = "=\""; //$NON-NLS-1$ - private static final String[] INVALID_COMPOSITE_HEADERS = new String[] {Constants.DYNAMICIMPORT_PACKAGE, Constants.FRAGMENT_HOST, Constants.REQUIRE_BUNDLE, Constants.BUNDLE_NATIVECODE, Constants.BUNDLE_CLASSPATH, Constants.BUNDLE_ACTIVATOR, Constants.BUNDLE_LOCALIZATION, Constants.BUNDLE_ACTIVATIONPOLICY}; - - private static Manifest getCompositeManifest(Map compositeManifest) { - Manifest manifest = new Manifest(); - Attributes attributes = manifest.getMainAttributes(); - attributes.putValue("Manifest-Version", "1.0"); //$NON-NLS-1$//$NON-NLS-2$ - // get the common headers Bundle-ManifestVersion, Bundle-SymbolicName and Bundle-Version - // get the manifest version from the map - String manifestVersion = (String) compositeManifest.remove(Constants.BUNDLE_MANIFESTVERSION); - // here we assume the validation got the correct version for us - attributes.putValue(Constants.BUNDLE_MANIFESTVERSION, manifestVersion); - // Ignore the Equinox composite bundle header - compositeManifest.remove(BaseStorageHook.COMPOSITE_HEADER); - attributes.putValue(BaseStorageHook.COMPOSITE_HEADER, BaseStorageHook.COMPOSITE_BUNDLE); - for (Iterator entries = compositeManifest.entrySet().iterator(); entries.hasNext();) { - Map.Entry entry = (Entry) entries.next(); - if (entry.getKey() instanceof String && entry.getValue() instanceof String) - attributes.putValue((String) entry.getKey(), (String) entry.getValue()); - } - return manifest; - } - - private static Manifest getSurrogateManifest(Dictionary compositeManifest, BundleDescription compositeDesc, ExportPackageDescription[] matchingExports) { - Manifest manifest = new Manifest(); - Attributes attributes = manifest.getMainAttributes(); - attributes.putValue("Manifest-Version", "1.0"); //$NON-NLS-1$//$NON-NLS-2$ - // Ignore the manifest version from the map - // always use bundle manifest version 2 - attributes.putValue(Constants.BUNDLE_MANIFESTVERSION, "2"); //$NON-NLS-1$ - // Ignore the Equinox composite bundle header - attributes.putValue(BaseStorageHook.COMPOSITE_HEADER, BaseStorageHook.SURROGATE_BUNDLE); - - if (compositeDesc != null && matchingExports != null) { - // convert the exports from the composite into imports - addImports(attributes, compositeDesc, matchingExports); - - // convert the matchingExports from the composite into exports - addExports(attributes, compositeDesc, matchingExports); - } - - // add the rest - for (Enumeration keys = compositeManifest.keys(); keys.hasMoreElements();) { - Object header = keys.nextElement(); - if (Constants.BUNDLE_MANIFESTVERSION.equals(header) || BaseStorageHook.COMPOSITE_HEADER.equals(header) || Constants.IMPORT_PACKAGE.equals(header) || Constants.EXPORT_PACKAGE.equals(header)) - continue; - if (header instanceof String && compositeManifest.get(header) instanceof String) - attributes.putValue((String) header, (String) compositeManifest.get(header)); - } - return manifest; - } - - static InputStream getCompositeInput(Map frameworkConfig, Map compositeManifest) throws IOException { - // use an in memory stream to store the content - ByteArrayOutputStream bytesOut = new ByteArrayOutputStream(); - // the composite bundles only consist of a manifest describing the packages they import and export - // and a framework config properties file - Manifest manifest = CompositeHelper.getCompositeManifest(compositeManifest); - JarOutputStream jarOut = new JarOutputStream(bytesOut, manifest); - try { - // store the framework config - Properties fwProps = new Properties(); - if (frameworkConfig != null) - fwProps.putAll(frameworkConfig); - JarEntry entry = new JarEntry(CompositeImpl.COMPOSITE_CONFIGURATION); - jarOut.putNextEntry(entry); - fwProps.store(jarOut, null); - jarOut.closeEntry(); - jarOut.flush(); - } finally { - try { - jarOut.close(); - } catch (IOException e) { - // nothing - } - } - return new ByteArrayInputStream(bytesOut.toByteArray()); - } - - static InputStream getSurrogateInput(Dictionary compositeManifest, BundleDescription compositeDesc, ExportPackageDescription[] matchingExports) throws IOException { - // use an in memory stream to store the content - ByteArrayOutputStream bytesOut = new ByteArrayOutputStream(); - Manifest manifest = CompositeHelper.getSurrogateManifest(compositeManifest, compositeDesc, matchingExports); - JarOutputStream jarOut = new JarOutputStream(bytesOut, manifest); - jarOut.flush(); - jarOut.close(); - return new ByteArrayInputStream(bytesOut.toByteArray()); - } - - private static void addImports(Attributes attrigutes, BundleDescription compositeDesc, ExportPackageDescription[] matchingExports) { - ExportPackageDescription[] exports = compositeDesc.getExportPackages(); - List systemExports = getSystemExports(matchingExports); - if (exports.length == 0 && systemExports.size() == 0) - return; - StringBuffer importStatement = new StringBuffer(); - Collection importedNames = new ArrayList(exports.length); - int i = 0; - for (; i < exports.length; i++) { - if (i != 0) - importStatement.append(','); - importedNames.add(exports[i].getName()); - getImportFrom(exports[i], importStatement); - } - for (Iterator iSystemExports = systemExports.iterator(); iSystemExports.hasNext();) { - ExportPackageDescription systemExport = (ExportPackageDescription) iSystemExports.next(); - if (!importedNames.contains(systemExport.getName())) { - if (i != 0) - importStatement.append(','); - i++; - importStatement.append(systemExport.getName()).append(ELEMENT_SEPARATOR).append(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE).append('=').append(Constants.SYSTEM_BUNDLE_SYMBOLICNAME); - } - } - attrigutes.putValue(Constants.IMPORT_PACKAGE, importStatement.toString()); - } - - private static List getSystemExports(ExportPackageDescription[] matchingExports) { - ArrayList list = null; - for (int i = 0; i < matchingExports.length; i++) { - if (matchingExports[i].getExporter().getBundleId() != 0) - continue; - if (list == null) - list = new ArrayList(); - list.add(matchingExports[i]); - } - return list == null ? Collections.EMPTY_LIST : list; - } - - private static void getImportFrom(ExportPackageDescription export, StringBuffer importStatement) { - importStatement.append(export.getName()).append(ELEMENT_SEPARATOR); - Version version = export.getVersion(); - importStatement.append(Constants.VERSION_ATTRIBUTE).append(EQUALS_QUOTE).append('[').append(version).append(',').append(new Version(version.getMajor(), version.getMinor(), version.getMicro() + 1)).append(')').append('\"'); - addMap(importStatement, export.getAttributes(), "="); //$NON-NLS-1$ - } - - private static void addExports(Attributes attributes, BundleDescription compositeDesc, ExportPackageDescription[] matchingExports) { - if (matchingExports.length == 0) - return; - StringBuffer exportStatement = new StringBuffer(); - for (int i = 0; i < matchingExports.length; i++) { - if (matchingExports[i].getExporter() == compositeDesc) { - // the matching export from outside is the composite bundle itself - // this must be one of our own substitutable exports, it must be ignored (bug 345640) - continue; - } - if (exportStatement.length() > 0) - exportStatement.append(','); - getExportFrom(matchingExports[i], exportStatement); - } - if (exportStatement.length() > 0) - attributes.putValue(Constants.EXPORT_PACKAGE, exportStatement.toString()); - } - - private static void getExportFrom(ExportPackageDescription export, StringBuffer exportStatement) { - exportStatement.append(export.getName()).append(ELEMENT_SEPARATOR); - exportStatement.append(Constants.VERSION_ATTRIBUTE).append(EQUALS_QUOTE).append(export.getVersion()).append('\"'); - addMap(exportStatement, export.getDirectives(), ":="); //$NON-NLS-1$ - addMap(exportStatement, export.getAttributes(), "="); //$NON-NLS-1$ - } - - private static void addMap(StringBuffer manifest, Map values, String assignment) { - if (values == null) - return; // nothing to add - for (Iterator iEntries = values.entrySet().iterator(); iEntries.hasNext();) { - manifest.append(ELEMENT_SEPARATOR); - Map.Entry entry = (Entry) iEntries.next(); - manifest.append(entry.getKey()).append(assignment).append('\"'); - Object value = entry.getValue(); - if (value instanceof String[]) { - String[] strings = (String[]) value; - for (int i = 0; i < strings.length; i++) { - if (i != 0) - manifest.append(','); - manifest.append(strings[i]); - } - } else { - manifest.append(value); - } - manifest.append('\"'); - } - } - - static void setCompositePermissions(String bundleLocation, BundleContext systemContext) { - ServiceReference ref = systemContext.getServiceReference(PermissionAdmin.class.getName()); - PermissionAdmin permAdmin = (PermissionAdmin) (ref == null ? null : systemContext.getService(ref)); - if (permAdmin == null) - throw new RuntimeException("No Permission Admin service is available"); //$NON-NLS-1$ - try { - permAdmin.setPermissions(bundleLocation, COMPOSITE_PERMISSIONS); - } finally { - systemContext.ungetService(ref); - } - } - - static void setDisabled(boolean disable, Bundle bundle, BundleContext systemContext) { - ServiceReference ref = systemContext.getServiceReference(PlatformAdmin.class.getName()); - PlatformAdmin pa = (PlatformAdmin) (ref == null ? null : systemContext.getService(ref)); - if (pa == null) - throw new RuntimeException("No Platform Admin service is available."); //$NON-NLS-1$ - try { - State state = pa.getState(false); - BundleDescription desc = state.getBundle(bundle.getBundleId()); - setDisabled(disable, desc); - } finally { - systemContext.ungetService(ref); - } - } - - static void setDisabled(boolean disable, BundleDescription bundle) { - State state = bundle.getContainingState(); - if (disable) { - state.addDisabledInfo(new DisabledInfo(COMPOSITE_POLICY, "Composite companion bundle is not resolved.", bundle)); //$NON-NLS-1$ - } else { - DisabledInfo toRemove = state.getDisabledInfo(bundle, COMPOSITE_POLICY); - if (toRemove != null) - state.removeDisabledInfo(toRemove); - } - } - - static void validateCompositeManifest(Map compositeManifest) throws BundleException { - if (compositeManifest == null) - throw new BundleException("The composite manifest cannot be null.", BundleException.MANIFEST_ERROR); //$NON-NLS-1$ - // check for symbolic name - if (compositeManifest.get(Constants.BUNDLE_SYMBOLICNAME) == null) - throw new BundleException("The composite manifest must contain a Bundle-SymbolicName header.", BundleException.MANIFEST_ERROR); //$NON-NLS-1$ - // check for invalid manifests headers - for (int i = 0; i < INVALID_COMPOSITE_HEADERS.length; i++) - if (compositeManifest.get(INVALID_COMPOSITE_HEADERS[i]) != null) - throw new BundleException("The composite manifest must not contain the header " + INVALID_COMPOSITE_HEADERS[i], BundleException.MANIFEST_ERROR); //$NON-NLS-1$ - // validate manifest version - String manifestVersion = (String) compositeManifest.get(Constants.BUNDLE_MANIFESTVERSION); - if (manifestVersion == null) { - compositeManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2"); //$NON-NLS-1$ - } else { - try { - Integer parsed = Integer.valueOf(manifestVersion); - if (parsed.intValue() > 2 || parsed.intValue() < 2) - throw new BundleException("Invalid Bundle-ManifestVersion: " + manifestVersion); //$NON-NLS-1$ - } catch (NumberFormatException e) { - throw new BundleException("Invalid Bundle-ManifestVersion: " + manifestVersion); //$NON-NLS-1$ - } - } - } -} diff --git a/bundles/org.eclipse.osgi/core/composite/org/eclipse/osgi/internal/composite/CompositeImpl.java b/bundles/org.eclipse.osgi/core/composite/org/eclipse/osgi/internal/composite/CompositeImpl.java deleted file mode 100644 index 021ee9e5a..000000000 --- a/bundles/org.eclipse.osgi/core/composite/org/eclipse/osgi/internal/composite/CompositeImpl.java +++ /dev/null @@ -1,292 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2012 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.osgi.internal.composite; - -import java.io.*; -import java.net.URL; -import java.util.Map; -import java.util.Properties; -import org.eclipse.osgi.framework.adaptor.BundleClassLoader; -import org.eclipse.osgi.framework.adaptor.BundleData; -import org.eclipse.osgi.framework.internal.core.Constants; -import org.eclipse.osgi.internal.loader.BundleLoader; -import org.eclipse.osgi.internal.loader.BundleLoaderProxy; -import org.eclipse.osgi.launch.Equinox; -import org.eclipse.osgi.service.internal.composite.CompositeModule; -import org.eclipse.osgi.service.resolver.BundleDescription; -import org.eclipse.osgi.service.resolver.ExportPackageDescription; -import org.osgi.framework.*; -import org.osgi.framework.launch.Framework; -import org.osgi.service.framework.*; - -public class CompositeImpl extends CompositeBase implements CompositeBundle { - private static String COMPOSITE_STORAGE = "store"; //$NON-NLS-1$ - public static String COMPOSITE_CONFIGURATION = "compositeConfig.properties"; //$NON-NLS-1$ - - private final ServiceTrackerManager trackerManager = new ServiceTrackerManager(); - - public CompositeImpl(BundleData bundledata, org.eclipse.osgi.framework.internal.core.Framework framework) throws BundleException { - super(bundledata, framework); - } - - protected Framework findCompanionFramework(org.eclipse.osgi.framework.internal.core.Framework thisFramework, BundleData thisData) throws BundleException { - // allocate storage area for the composite framework - File compositeStorage = thisData.getDataFile(COMPOSITE_STORAGE); - boolean firstTime = false; - if (!compositeStorage.exists()) - // the child storage area has not been allocated; this is the first time - firstTime = true; - // find the configuration properties - URL childConfig = bundledata.getEntry(COMPOSITE_CONFIGURATION); - Properties props = new Properties(); - try { - props.load(childConfig.openStream()); - } catch (IOException e) { - throw new BundleException("Could not load child configuration", e); //$NON-NLS-1$ - } - props.put(Constants.FRAMEWORK_STORAGE, compositeStorage.getAbsolutePath()); - // save the parent framework so the parent companion bundle can find it - props.put(PROP_PARENTFRAMEWORK, thisFramework.getSystemBundleContext().getBundle()); - // TODO leaks "this" out of the constructor - props.put(PROP_COMPOSITE, this); - Equinox equinox = new Equinox((Map) props); - if (!firstTime) - // if not the first time then we are done - return equinox; - equinox.init(); - installSurrogate(equinox.getBundleContext(), thisData); - return equinox; - } - - private void installSurrogate(BundleContext companionContext, BundleData thisData) throws BundleException { - Bundle surrogate; - try { - InputStream surrogateContent = CompositeHelper.getSurrogateInput(thisData.getManifest(), null, null); - surrogate = companionContext.installBundle(thisData.getLocation(), surrogateContent); - } catch (IOException e) { - throw new BundleException("Error installing parent companion composite bundle", e); //$NON-NLS-1$ - } - // disable the surrogate initially since we know we have not resolved the composite yet. - CompositeHelper.setDisabled(true, surrogate, companionContext); - // set the permissions of the surrogate bundle - CompositeHelper.setCompositePermissions(thisData.getLocation(), companionContext); - } - - private boolean updateSurrogate(BundleData thisData, BundleDescription child, ExportPackageDescription[] matchingExports) throws BundleException { - // update the surrogate content with the matching exports provided by the composite - InputStream surrogateContent; - try { - surrogateContent = CompositeHelper.getSurrogateInput(thisData.getManifest(), child, matchingExports); - } catch (IOException e) { - throw new BundleException("Error updating surrogate bundle.", e); //$NON-NLS-1$ - } - CompositeModule surrogateComposite = (CompositeModule) getSurrogateBundle(); - surrogateComposite.updateContent(surrogateContent); - // enable/disable the surrogate composite based on if we have exports handed to us - boolean disable = matchingExports == null ? true : false; - CompositeHelper.setDisabled(disable, getSurrogateBundle(), getCompositeFramework().getBundleContext()); - // return true if we can resolve the surrogate bundle - return disable ? false : surrogateComposite.resolveContent(); - } - - public Framework getCompositeFramework() { - if ((getState() & Bundle.UNINSTALLED) == 0) { - if ((companionFramework.getState() & (Bundle.INSTALLED | Bundle.RESOLVED)) != 0) - try { - companionFramework.init(); - } catch (BundleException e) { - throw new RuntimeException("Cannot initialize child framework.", e); - } - } - return companionFramework; - } - - public SurrogateBundle getSurrogateBundle() { - return (SurrogateBundle) getCompanionBundle(); - } - - protected Bundle getCompanionBundle() { - return getCompositeFramework().getBundleContext().getBundle(1); - } - - public void update(Map compositeManifest) throws BundleException { - // validate the composite manifest - CompositeHelper.validateCompositeManifest(compositeManifest); - if (isResolved()) { - // force the class loader creation before updating the surrogate to cache the current state - // this is to allow for lazy updates of composite bundles - BundleLoader loader = getBundleLoader(); - if (loader != null) - loader.createClassLoader(); - } - try { - Map frameworkConfig = getFrameworkConfig(); - // first update the parent companion and disable it - updateSurrogate(getBundleData(), null, null); - // update the content with the new manifest - updateContent(CompositeHelper.getCompositeInput(frameworkConfig, compositeManifest)); - } catch (IOException e) { - throw new BundleException("Error updating composite.", e); //$NON-NLS-1$ - } - } - - private Map getFrameworkConfig() throws IOException { - Properties result = new Properties(); - URL config = getEntry(COMPOSITE_CONFIGURATION); - result.load(config.openStream()); - return result; - } - - public void uninstall() throws BundleException { - // ensure class loader is created if needed - checkClassLoader(); - // stop first before stopping the child to let the service listener clean up - stop(Bundle.STOP_TRANSIENT); - stopChildFramework(); - super.uninstall(); - } - - private void checkClassLoader() { - BundleLoaderProxy proxy = getLoaderProxy(); - if (proxy != null && proxy.inUse() && proxy.getBundleLoader() != null) { - BundleClassLoader loader = proxy.getBundleLoader().createClassLoader(); - loader.getResource("dummy"); //$NON-NLS-1$ - } - } - - protected void startHook() throws BundleException { - // always start the child framework - companionFramework.start(); - trackerManager.startedComposite(); - } - - protected void stopHook() throws BundleException { - // bug 363561; need to make sure the class loader is created - // before stopping the composite framework - try { - checkClassLoader(); - } catch (Throwable t) { - framework.publishFrameworkEvent(FrameworkEvent.ERROR, this, t); - } - trackerManager.stoppedComposite(); - // do not stop the framework unless we are persistently stopped - if ((bundledata.getStatus() & Constants.BUNDLE_STARTED) == 0) - stopChildFramework(); - } - - public void started(CompositeModule surrogate) { - if (surrogate == getSurrogateBundle()) - trackerManager.startedSurrogate(); - } - - public void stopped(CompositeModule surrogate) { - if (surrogate == getSurrogateBundle()) - trackerManager.stoppedSurrogate(); - } - - private void stopChildFramework() throws BundleException { - companionFramework.stop(); - try { - FrameworkEvent stopped = companionFramework.waitForStop(30000); - switch (stopped.getType()) { - case FrameworkEvent.ERROR : - throw new BundleException("Error stopping the child framework.", stopped.getThrowable()); //$NON-NLS-1$ - case FrameworkEvent.WAIT_TIMEDOUT : - throw new BundleException("Timed out waiting for the child framework to stop."); //$NON-NLS-1$ - case FrameworkEvent.STOPPED : - // normal stop, just return - return; - default : - throw new BundleException("Unexpected code returned when stopping the child framework:" + stopped.getType()); //$NON-NLS-1$ - } - } catch (InterruptedException e) { - throw new BundleException("Error stopping child framework", e); //$NON-NLS-1$ - } - } - - public boolean giveExports(ExportPackageDescription[] matchingExports) { - if (matchingExports == null) { - SurrogateBundle surrogate = getSurrogateBundle(); - // disable the surrogate - CompositeHelper.setDisabled(true, getSurrogateBundle(), getCompositeFramework().getBundleContext()); - // refresh the surrogate synchronously - ((CompositeModule) surrogate).refreshContent(); - return true; - } - try { - return updateSurrogate(getBundleData(), getBundleDescription(), matchingExports); - } catch (BundleException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - return false; - } - } - - /* - * Listens to source and target bundles and source and target framework changes - */ - class ServiceTrackerManager { - static final int COMPOSITE_ACTIVE = 0x01; - static final int SURROGATE_ACTIVE = 0x02; - // @GuardedBy(this) - private int bundlesActive = 0; - // @GuardedBy(this) - private CompositeServiceTracker shareToChildServices; - // @GuardedBy(this) - private CompositeServiceTracker shareToParentServices; - - void startedComposite() throws BundleException { - open(COMPOSITE_ACTIVE); - getSurrogateBundle().start(Bundle.START_TRANSIENT); - } - - void startedSurrogate() { - open(SURROGATE_ACTIVE); - } - - void stoppedComposite() { - try { - getSurrogateBundle().stop(Bundle.STOP_TRANSIENT); - } catch (BundleException e) { - // nothing - } catch (IllegalStateException e) { - // child framework must have been stoped - } - close(COMPOSITE_ACTIVE); - } - - void stoppedSurrogate() { - close(SURROGATE_ACTIVE); - } - - private synchronized void open(int bundleActive) { - bundlesActive |= bundleActive; - if ((bundlesActive & (COMPOSITE_ACTIVE | SURROGATE_ACTIVE)) != (COMPOSITE_ACTIVE | SURROGATE_ACTIVE)) - return; - // create a service tracker to track and share services from the parent framework - shareToChildServices = new CompositeServiceTracker(getBundleContext(), getSurrogateBundle().getBundleContext(), (String) getBundleContext().getBundle().getHeaders("").get(CompositeBundleFactory.COMPOSITE_SERVICE_FILTER_IMPORT)); //$NON-NLS-1$ - shareToChildServices.open(); - // create a service tracker to track and share services from the child framework - shareToParentServices = new CompositeServiceTracker(getSurrogateBundle().getBundleContext(), getBundleContext(), (String) getBundleContext().getBundle().getHeaders("").get(CompositeBundleFactory.COMPOSITE_SERVICE_FILTER_EXPORT)); //$NON-NLS-1$ - shareToParentServices.open(); - - } - - private synchronized void close(int bundleStopped) { - bundlesActive ^= bundleStopped; - // close the service tracker to stop tracking and sharing services - if (shareToChildServices != null) - shareToChildServices.close(); - if (shareToParentServices != null) - shareToParentServices.close(); - } - } -} diff --git a/bundles/org.eclipse.osgi/core/composite/org/eclipse/osgi/internal/composite/CompositeServiceTracker.java b/bundles/org.eclipse.osgi/core/composite/org/eclipse/osgi/internal/composite/CompositeServiceTracker.java deleted file mode 100644 index a9a449b40..000000000 --- a/bundles/org.eclipse.osgi/core/composite/org/eclipse/osgi/internal/composite/CompositeServiceTracker.java +++ /dev/null @@ -1,178 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.osgi.internal.composite; - -import java.util.*; -import org.eclipse.osgi.util.ManifestElement; -import org.osgi.framework.*; -import org.osgi.util.tracker.ServiceTracker; -import org.osgi.util.tracker.ServiceTrackerCustomizer; - -class CompositeServiceTracker implements ServiceTrackerCustomizer { - final BundleContext sourceContext; - final BundleContext targetContext; - final ServiceTracker[] trackers; - final String[] filters; - /* @GuardedBy("serviceComposites") */ - final HashMap serviceComposites = new HashMap(); - - public CompositeServiceTracker(BundleContext sourceContext, BundleContext targetContext, String serviceFilters) { - this.sourceContext = sourceContext; - this.targetContext = targetContext; - filters = ManifestElement.getArrayFromList(serviceFilters, ","); //$NON-NLS-1$ - trackers = new ServiceTracker[filters.length]; - } - - synchronized void open() { - for (int i = 0; i < trackers.length; i++) { - try { - trackers[i] = new ServiceTracker(sourceContext, sourceContext.createFilter(filters[i]), this); - trackers[i].open(); - } catch (InvalidSyntaxException e) { - // TODO log - // we will skip this filter; note that trackers may have null entries - } - } - } - - synchronized void close() { - for (int i = 0; i < trackers.length; i++) { - if (trackers[i] != null) - trackers[i].close(); - } - } - - public Object addingService(ServiceReference reference) { - ServiceLink serviceLink; - int useCount; - synchronized (serviceComposites) { - serviceLink = (ServiceLink) serviceComposites.get(reference); - if (serviceLink == null) { - serviceLink = new ServiceLink(reference); - serviceComposites.put(reference, serviceLink); - } - useCount = serviceLink.incrementUse(); - } - // register service outside of the sync block - if (useCount == 1) - serviceLink.register(); - return serviceLink; - } - - public void modifiedService(ServiceReference reference, Object service) { - ServiceLink serviceLink = (ServiceLink) service; - Dictionary serviceProps = null; - synchronized (serviceComposites) { - serviceProps = serviceLink.getRefreshProperties(); - } - // set service properties out side the sync block - if (serviceProps != null) - ((ServiceLink) service).setServiceProperties(serviceProps); - } - - public void removedService(ServiceReference reference, Object service) { - int useCount; - synchronized (serviceComposites) { - useCount = ((ServiceLink) service).decrementUse(); - if (useCount == 0) - serviceComposites.remove(reference); - } - // unregister outside the sync block - if (useCount == 0) - ((ServiceLink) service).unregister(); - } - - class ServiceLink implements ServiceFactory { - private final ServiceReference reference; - private volatile ServiceRegistration registration; - /* @GuardedBy("this") */ - private Object service; - /* @GuardedBy("serviceLinks") */ - private int useCount; - - ServiceLink(ServiceReference reference) { - this.reference = reference; - } - - /* @GuardedBy("serviceLinks") */ - Dictionary getRefreshProperties() { - Dictionary result = getServiceProperties(); - if (useCount <= 1) - return result; - // need to do an expensive properties check to avoid multiple registration property changes - String[] originalKeys = registration.getReference().getPropertyKeys(); - for (int i = 0; i < originalKeys.length; i++) { - if (!Constants.OBJECTCLASS.equals(originalKeys[i]) && !Constants.SERVICE_ID.equals(originalKeys[i])) - // identity compare is done on purpose here to catch any kind of change - if (registration.getReference().getProperty(originalKeys[i]) != result.get(originalKeys[i])) - return result; - } - for (Enumeration eKeys = result.keys(); eKeys.hasMoreElements();) { - String key = (String) eKeys.nextElement(); - if (!Constants.OBJECTCLASS.equals(key) && !Constants.SERVICE_ID.equals(key)) - // identity compare is done on purpose here to catch any kind of change - if (result.get(key) != registration.getReference().getProperty(key)) - return result; - } - return null; - } - - /* @GuardedBy("serviceLinks") */ - int decrementUse() { - return --useCount; - } - - /* @GuardedBy("serviceLinks") */ - int incrementUse() { - return ++useCount; - } - - /* @GuardedBy("serviceLinks") */ - int getUse() { - return useCount; - } - - void setServiceProperties(Dictionary props) { - ServiceRegistration current = registration; - if (current != null) - current.setProperties(props); - } - - void register() { - Dictionary props = getServiceProperties(); - registration = targetContext.registerService((String[]) props.get(Constants.OBJECTCLASS), this, props); - } - - void unregister() { - ServiceRegistration current = registration; - if (current != null) - current.unregister(); - } - - private Dictionary getServiceProperties() { - String[] keys = reference.getPropertyKeys(); - Hashtable serviceProps = new Hashtable(keys.length); - for (int i = 0; i < keys.length; i++) - serviceProps.put(keys[i], reference.getProperty(keys[i])); - return serviceProps; - } - - public synchronized Object getService(Bundle bundle, ServiceRegistration reg) { - if (service == null) - service = sourceContext.getService(reference); - return service; - } - - public void ungetService(Bundle bundle, ServiceRegistration reg, Object serv) { - // nothing - } - } -} diff --git a/bundles/org.eclipse.osgi/core/composite/org/eclipse/osgi/internal/composite/SurrogateImpl.java b/bundles/org.eclipse.osgi/core/composite/org/eclipse/osgi/internal/composite/SurrogateImpl.java deleted file mode 100644 index 47f58ad62..000000000 --- a/bundles/org.eclipse.osgi/core/composite/org/eclipse/osgi/internal/composite/SurrogateImpl.java +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.osgi.internal.composite; - -import org.eclipse.osgi.framework.adaptor.BundleData; -import org.eclipse.osgi.framework.internal.core.FrameworkProperties; -import org.eclipse.osgi.internal.module.ResolverBundle; -import org.eclipse.osgi.service.internal.composite.CompositeModule; -import org.eclipse.osgi.service.resolver.BundleDescription; -import org.eclipse.osgi.service.resolver.ExportPackageDescription; -import org.osgi.framework.*; -import org.osgi.framework.launch.Framework; -import org.osgi.service.framework.CompositeBundle; -import org.osgi.service.framework.SurrogateBundle; - -public class SurrogateImpl extends CompositeBase implements SurrogateBundle { - - private final CompositeBundle composite; - - public SurrogateImpl(BundleData bundledata, org.eclipse.osgi.framework.internal.core.Framework framework) throws BundleException { - super(bundledata, framework); - this.composite = (CompositeBundle) FrameworkProperties.getProperties().get(PROP_COMPOSITE); - } - - protected Framework findCompanionFramework(org.eclipse.osgi.framework.internal.core.Framework thisFramework, BundleData thisData) { - // just get the property which was set when creating the child framework - return (Framework) FrameworkProperties.getProperties().get(PROP_PARENTFRAMEWORK); - } - - public BundleContext getCompositeBundleContext() { - return composite.getBundleContext(); - } - - protected Bundle getCompanionBundle() { - return composite; - } - - protected boolean isSurrogate() { - return true; - } - - public boolean giveExports(ExportPackageDescription[] matchingExports) { - // only allow the surrogate resolution to occur if we are in the middle of resolving the composite - if (resolving.get() == null) - return false; - if (matchingExports == null) { - // set the surrogate to disabled to prevent resolution this go around - CompositeHelper.setDisabled(true, getBundleDescription()); - return true; - } - return validExports(matchingExports); - } - - private boolean validExports(ExportPackageDescription[] matchingExports) { - // make sure each matching exports matches the export signature of the composite - CompositeModule composite = (CompositeModule) getCompanionBundle(); - BundleDescription childDesc = composite.getCompositeDescription(); - ExportPackageDescription[] childExports = childDesc.getExportPackages(); - for (int i = 0; i < matchingExports.length; i++) { - for (int j = 0; j < childExports.length; j++) { - if (matchingExports[i].getName().equals(childExports[j].getName())) { - if (!validateExport(matchingExports[i], childExports[j])) - return false; - continue; - } - } - } - return true; - } - - private boolean validateExport(ExportPackageDescription matchingExport, ExportPackageDescription childExport) { - Version matchingVersion = matchingExport.getVersion(); - Version childVersion = childExport.getVersion(); - if (!childVersion.equals(Version.emptyVersion) && !matchingVersion.equals(childVersion)) - return false; - if (!ResolverBundle.equivalentMaps(childExport.getAttributes(), matchingExport.getAttributes(), false)) - return false; - if (!ResolverBundle.equivalentMaps(childExport.getDirectives(), matchingExport.getDirectives(), false)) - return false; - return true; - } - - protected void startHook() { - ((CompositeModule) getCompanionBundle()).started(this); - } - - protected void stopHook() { - ((CompositeModule) getCompanionBundle()).stopped(this); - } - - public void uninstall() throws BundleException { - throw new BundleException("Cannot uninstall surrogate bundles", BundleException.INVALID_OPERATION); //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.osgi/core/composite/org/eclipse/osgi/service/internal/composite/CompositeModule.java b/bundles/org.eclipse.osgi/core/composite/org/eclipse/osgi/service/internal/composite/CompositeModule.java deleted file mode 100644 index 2d971053f..000000000 --- a/bundles/org.eclipse.osgi/core/composite/org/eclipse/osgi/service/internal/composite/CompositeModule.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.osgi.service.internal.composite; - -import java.io.InputStream; -import org.eclipse.osgi.framework.adaptor.ClassLoaderDelegate; -import org.eclipse.osgi.service.resolver.BundleDescription; -import org.osgi.framework.BundleException; - -/** - * An internal interface only used by the composite implementation - * - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ -public interface CompositeModule { - public void updateContent(InputStream content) throws BundleException; - - public void refreshContent(); - - public boolean resolveContent(); - - public BundleDescription getCompositeDescription(); - - public ClassLoaderDelegate getDelegate(); - - public void started(CompositeModule compositeBundle); - - public void stopped(CompositeModule compositeBundle); -} diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/AbstractBundle.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/AbstractBundle.java index 1cf9e943f..d2b51fd00 100644 --- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/AbstractBundle.java +++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/AbstractBundle.java @@ -20,8 +20,6 @@ import java.util.*; import org.eclipse.osgi.framework.adaptor.*; import org.eclipse.osgi.framework.debug.Debug; import org.eclipse.osgi.framework.util.KeyedElement; -import org.eclipse.osgi.internal.composite.CompositeImpl; -import org.eclipse.osgi.internal.composite.SurrogateImpl; import org.eclipse.osgi.internal.loader.BundleLoader; import org.eclipse.osgi.internal.permadmin.EquinoxSecurityManager; import org.eclipse.osgi.service.resolver.BundleDescription; @@ -80,10 +78,6 @@ public abstract class AbstractBundle implements Bundle, Comparable<Bundle>, Keye AbstractBundle result; if ((bundledata.getType() & BundleData.TYPE_FRAGMENT) > 0) result = new BundleFragment(bundledata, framework); - else if ((bundledata.getType() & BundleData.TYPE_COMPOSITEBUNDLE) > 0) - result = new CompositeImpl(bundledata, framework); - else if ((bundledata.getType() & BundleData.TYPE_SURROGATEBUNDLE) > 0) - result = new SurrogateImpl(bundledata, framework); else result = new BundleHost(bundledata, framework); if (setBundle) diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/loader/BundleLoaderProxy.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/loader/BundleLoaderProxy.java index fa30a83b3..a9612a91b 100644 --- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/loader/BundleLoaderProxy.java +++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/loader/BundleLoaderProxy.java @@ -19,7 +19,6 @@ import org.eclipse.osgi.framework.internal.core.*; import org.eclipse.osgi.framework.internal.core.Constants; import org.eclipse.osgi.framework.util.KeyedHashSet; import org.eclipse.osgi.framework.util.SecureAction; -import org.eclipse.osgi.internal.composite.CompositeBase; import org.eclipse.osgi.service.resolver.BundleDescription; import org.eclipse.osgi.service.resolver.ExportPackageDescription; import org.osgi.framework.*; @@ -193,7 +192,7 @@ public class BundleLoaderProxy implements RequiredBundle, BundleReference { } public boolean inUse() { - return (description.getDependents().length > 0) || ((bundle instanceof CompositeBase) && description.getResolvedImports().length > 0); + return (description.getDependents().length > 0); } boolean forceSourceCreation(ExportPackageDescription export) { diff --git a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/BaseStorageHook.java b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/BaseStorageHook.java index aa405123c..45bdeb6b2 100644 --- a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/BaseStorageHook.java +++ b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/BaseStorageHook.java @@ -43,9 +43,6 @@ public class BaseStorageHook implements StorageHook, AdaptorHook { public static final String EXTERNAL_LIB_PREFIX = "external:"; //$NON-NLS-1$ public static final String VARIABLE_DELIM_STRING = "$"; //$NON-NLS-1$ public static final char VARIABLE_DELIM_CHAR = '$'; - public static String COMPOSITE_HEADER = "Equinox-CompositeBundle"; //$NON-NLS-1$ - public static String COMPOSITE_BUNDLE = "composite"; //$NON-NLS-1$ - public static String SURROGATE_BUNDLE = "surrogate"; //$NON-NLS-1$ /** bundle's file name */ private String fileName; @@ -117,14 +114,6 @@ public class BaseStorageHook implements StorageHook, AdaptorHook { else if (extensionType.equals("extclasspath")) //$NON-NLS-1$ bundleType |= BundleData.TYPE_EXTCLASSPATH_EXTENSION; } - } else { - String composite = manifest.get(COMPOSITE_HEADER); - if (composite != null) { - if (COMPOSITE_BUNDLE.equals(composite)) - bundleType |= BundleData.TYPE_COMPOSITEBUNDLE; - else - bundleType |= BundleData.TYPE_SURROGATEBUNDLE; - } } target.setType(bundleType); target.setExecutionEnvironment(manifest.get(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT)); diff --git a/bundles/org.eclipse.osgi/hookconfigurators.properties b/bundles/org.eclipse.osgi/hookconfigurators.properties index db4cebc30..45000aa51 100644 --- a/bundles/org.eclipse.osgi/hookconfigurators.properties +++ b/bundles/org.eclipse.osgi/hookconfigurators.properties @@ -19,6 +19,5 @@ hook.configurators= \ org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter,\ org.eclipse.core.runtime.internal.stats.StatsManager,\ org.eclipse.osgi.internal.signedcontent.SignedBundleHook,\ - org.eclipse.osgi.internal.composite.CompositeConfigurator,\ org.eclipse.osgi.internal.baseadaptor.weaving.WeavingHookConfigurator builtin.hooks = true diff --git a/bundles/org.eclipse.osgi/osgi/src/org/osgi/service/framework/CompositeBundle.java b/bundles/org.eclipse.osgi/osgi/src/org/osgi/service/framework/CompositeBundle.java deleted file mode 100644 index f935f9b87..000000000 --- a/bundles/org.eclipse.osgi/osgi/src/org/osgi/service/framework/CompositeBundle.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.osgi.service.framework; - -import java.io.InputStream; -import java.util.Map; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleException; -import org.osgi.framework.launch.Framework; - -/** - * Composite bundles are composed of other bundles. The component bundles which - * make up the content of a composite bundle are installed into a child - * framework. Like a normal bundle, a composite bundle may import packages and - * use services from other bundles which are installed in the same framework as - * the composite bundle. The packages imported and the services used by a - * composite bundle are shared with the components of a composite bundle through - * a surrogate bundle installed in the child framework. Also like a normal - * bundle, a composite bundle may export packages and register services which - * can be used by bundles installed in the same framework as the composite - * bundle. The packages exported and the services registered by a composite - * bundle are acquired from the components of a composite bundle by the - * surrogate bundle installed in the child framework - * <p> - * A framework has one composite bundle for each of its child frameworks. A - * framework can have zero or more composite bundles installed. A child - * framework must have one and only one surrogate bundle which represents the - * composite bundle in the parent framework. In other words, a parent framework - * can have many child frameworks but a child framework can have only one - * parent. - * <p> - * A composite bundle does the following as specified by the composite manifest - * map: - * <ul> - * <li>Exports packages to the parent framework from the child framework. These - * packages are imported by the surrogate bundle installed in the child - * framework.</li> - * <li>Imports packages from the parent framework. These packages are exported - * by the surrogate bundle installed in the child framework.</li> - * <li>Registers services to the parent framework from the child framework. - * These services are acquired by the surrogate bundle installed in the child - * framework.</li> - * <li>Acquires services from the parent framework. These services are - * registered by the surrogate bundle installed in the child framework.</li> - * </ul> - * - * A newly created child <code>Framework</code> will be in the - * {@link Bundle#STARTING STARTING} state. This child <code>Framework</code> can - * then be used to manage and control the child framework instance. The child - * framework instance is persistent and uses a storage area associated with the - * installed composite bundle. The child framework's lifecycle is tied to its - * composite bundle's lifecycle in the following ways: - * <p> - * <ul> - * <li>If the composite bundle is marked to be persistently started (see - * StartLevel.isBundlePersistentlyStarted(Bundle)) then the child framework - * instance will automatically be started when the composite bundle's - * start-level is met.</li> - * <li>The child framework instance will be stopped if the composite bundle is - * persistently stopped or its start level is no longer met. Performing - * operations which transiently stop a composite bundle do not cause the child - * framework to stop (e.g. {@link Bundle#stop(int) stop(Bundle.STOP_TRANSIENT)}, - * {@link Bundle#update() update}, refreshPackages etc.).</li> - * <li>If the composite bundle is uninstalled, the child framework's persistent - * storage area is also uninstalled.</li> - * </ul> - * <p> - * The child framework may be persistently started and stopped by persistently - * starting and stopping the composite bundle, but it is still possible to - * initialize and start the child framework explicitly while the composite - * bundle is not persistently started. This allows for the child framework to be - * initialized and populated with a set of bundles before starting the composite - * bundle. The set of bundles installed into the child framework are the - * component bundles which comprise the composite bundle. - * <p> - * The child framework's lifecycle is also tied to the lifecycle of its - * parent framework. When the parent <code>Framework</code> enters the - * {@link Bundle#STOPPING STOPPING} state, all active child frameworks of that - * parent are shutdown using the {@link Framework#stop()} method. The parent - * framework must not enter the {@link Bundle#RESOLVED} state until all the - * child frameworks have completed their shutdown process. Just as with other - * Bundles, references to child frameworks (or the associated composite and - * surrogate bundles) become invalid after the parent framework has completed - * the shutdown process, and must not be allowed to re-initialize or re-start - * the child framework. - * - * @see SurrogateBundle - * @deprecated This API proposal was rejected by the OSGi Alliance and will - * not be part of any OSGi specification. Please transition to the - * org.osgi.framework.hooks API to control resolution, bundle, and service - * isolation. This API will be removed from Equinox in the 3.9 release - * You are cautioned against relying upon this API. - * @ThreadSafe - * @version $Revision: 6860 $ - */ -public interface CompositeBundle extends Bundle { - /** - * Returns the child framework associated with this composite bundle. - * - * @return the child framework. - */ - Framework getCompositeFramework(); - - /** - * Returns the surrogate bundle associated with this composite bundle. The - * surrogate bundle is installed in the child framework. - * - * @return the surrogate bundle. - */ - SurrogateBundle getSurrogateBundle(); - - /** - * Updates this composite bundle with the specified manifest. - * <p> - * Similar to normal bundle updates, the packages exported by a composite or - * surrogate bundle can not change as a result of calling update: the - * previous package exports must be available to other consuming bundles (in - * either the parent or child framework) until the - * PackageAdmin.refreshPackages method has been called to refresh the - * composite, or the parent Framework is re-launched. - * - * @param compositeManifest - * the new composite manifest. - * @throws BundleException - * If the update fails. - * @see CompositeBundleFactory#installCompositeBundle(Map, String, Map) - */ - void update(Map /* <String, String> */compositeManifest) throws BundleException; - - /** - * This operation is not supported for composite bundles. A - * <code>BundleException</code> of type - * {@link BundleException#INVALID_OPERATION invalid operation} must be - * thrown. - */ - void update() throws BundleException; - - /** - * This operation is not supported for composite bundles. A - * <code>BundleException</code> of type - * {@link BundleException#INVALID_OPERATION invalid operation} must be - * thrown. - */ - void update(InputStream input) throws BundleException; - - /** - * Uninstalls this composite bundle. The associated child framework - * is shutdown, and its persistent storage area is deleted. - */ - void uninstall() throws BundleException; -} diff --git a/bundles/org.eclipse.osgi/osgi/src/org/osgi/service/framework/CompositeBundleFactory.java b/bundles/org.eclipse.osgi/osgi/src/org/osgi/service/framework/CompositeBundleFactory.java deleted file mode 100644 index 67e9de76d..000000000 --- a/bundles/org.eclipse.osgi/osgi/src/org/osgi/service/framework/CompositeBundleFactory.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.osgi.service.framework; - -import java.util.Map; -import org.osgi.framework.*; -import org.osgi.framework.launch.Framework; - -/** - * Framework service that is used to create composite bundles. - * <p> - * If present, there will only be a single instance of this service registered - * with the Framework. - * - * @deprecated This API proposal was rejected by the OSGi Alliance and will - * not be part of any OSGi specification. Please transition to the - * org.osgi.framework.hooks API to control resolution, bundle, and service - * isolation. This API will be removed from Equinox in the 3.9 release - * You are cautioned against relying upon this API. - * @ThreadSafe - * @version $Revision: 6860 $ - */ -// TODO javadoc needs review -public interface CompositeBundleFactory { - /** - * Manifest header (named "CompositeServiceFilter-Import") - * identifying the service filters that are used by a composite bundle - * to select services that will be registered into a child framework by its - * associated surrogate bundle. - */ - public static final String COMPOSITE_SERVICE_FILTER_IMPORT = "CompositeServiceFilter-Import"; - - /** - * Manifest header (named "CompositeServiceFilter-Export") - * identifying the service filters that are used by a surrogate - * bundle to select services that will be registered into a parent framework - * by its associated composite bundle. - */ - public static final String COMPOSITE_SERVICE_FILTER_EXPORT = "CompositeServiceFilter-Export"; - - /** - * Installs a <code>CompositeBundle</code>. The composite bundle has a new - * child <code>Framework</code> associated with it and a surrogate bundle - * which is installed in the child framework. Composite bundles share - * packages and services between the parent framework they are installed in and - * the child framework. - * <p> - * The following steps are required to create a composite bundle: - * <ol> - * <li>If a bundle containing the same location string is already installed - * and the Bundle object is a <code>CompositeBundle</code>, then that - * composite bundle is returned; otherwise a <code>BundleException</code> - * is thrown indicating that an incompatible bundle is already installed at the - * specified location.</li> - * <li>The composite bundle's associated resources are allocated. The - * associated resources minimally consist of a unique identifier and a - * persistent storage area. If this step fails, a <code>BundleException</code> - * is thrown.</li> - * <li>The <code>compositeManifest</code> map is used to provide the headers for the - * composite bundle and its surrogate bundle. - * <p> - * If composite manifest map does not contain the following header(s) then a - * BundleException is thrown: - * <ul> - * <li> {@link Constants#BUNDLE_SYMBOLICNAME Bundle-SymbolicName} the - * symbolic name used for the composite bundle and its surrogate bundle. - * </ul> - * </p><p> - * The composite manifest map may optionally contain the following - * header(s): - * <ul> - * <li> {@link Constants#BUNDLE_VERSION Bundle-Version} the bundle version - * used for the composite bundle and its surrogate bundle.</li> - * <li> {@link Constants#IMPORT_PACKAGE Import-Package} the packages which - * are imported from the parent framework by the composite bundle and are - * exported to the child framework by the surrogate bundle.</li> - * <li>{@link Constants#EXPORT_PACKAGE Export-Package} the packages which - * are imported from the child framework by the surrogate bundle and are - * exported to the parent framework by the composite bundle.</li> - * <li>{@link #COMPOSITE_SERVICE_FILTER_IMPORT - * CompositeServiceFilter-Import} the service filters which are acquired - * from the parent framework by the composite bundle and are registered in - * the child framework by the surrogate bundle.</li> - * <li>{@link #COMPOSITE_SERVICE_FILTER_EXPORT - * CompositeServiceFilter-Export} the service filters which are acquired - * from the child framework by the surrogate bundle and are registered in - * the parent framework by the composite bundle.</li> - * <li>{@link Constants#BUNDLE_MANIFESTVERSION Bundle-ManifestVersion} the - * bundle manifest version. If this header is not specified then the default - * is to use version 2. A <code>BundleException</code> is thrown if this header is - * specified and the version is less than 2.</li> - * <li>{@link Constants#REQUIRE_BUNDLE Require-Bundle} a bundle from the parent - * which is required by the child. Support for this header is experimental: a - * <code>BundleException</code> should be thrown if the header is present and - * the framework doesn't support it. - * </ul> - * </p><p> - * The composite manifest map must not contain the following headers. If a - * composite manifest map does contain one of the following headers then a - * <code>BundleException</code> is thrown: - * <br/> - * {@link Constants#BUNDLE_ACTIVATIONPOLICY Bundle-ActivationPolicy}<br/> - * {@link Constants#BUNDLE_ACTIVATOR Bundle-Activator}<br/> - * {@link Constants#BUNDLE_CLASSPATH Bundle-ClassPath}<br/> - * {@link Constants#BUNDLE_LOCALIZATION Bundle-Localization}<br/> - * {@link Constants#BUNDLE_NATIVECODE Bundle-NativeCode}<br/> - * {@link Constants#FRAGMENT_HOST Fragment-Host}<br/> - * {@link Constants#DYNAMICIMPORT_PACKAGE DynamicImport-Package}<br/> - * <br/> - * </li> - * <li>A child framework is created which uses a storage area associated with - * the composite bundle's persistent storage. The framework configuration - * property {@link Constants#FRAMEWORK_STORAGE org.osgi.framework.storage}, - * if specified, is ignored.</li> - * <li>The child framework is initialized (see {@link Framework#init()}). - * <li>A surrogate bundle is created and installed into the child framework.</li> - * <li>The composite bundle's state is set to INSTALLED.</li> - * <li>A bundle event of type {@link BundleEvent#INSTALLED} is fired for the - * composite bundle. - * <li>The <code>CompositeBundle</code> object for the new composite - * bundle is returned. - * </ol> - * <p> - * - * @param frameworkConfig A map containing configuration parameters used to - * initialize and launch the child framework. - * @param location The bundle location used for the composite and surrogate bundles. - * @param compositeManifest A map containing the manifest used to create the composite - * and surrogate bundles - * @return A new composite bundle in INSTALLED state. - * @throws BundleException If the composite manifest is invalid or there is - * some other problem with installing the composite bundle. - * @throws SecurityException If the caller does not have - * <code>AllPermission</code>. - * @see Framework - * @see CompositeBundle - */ - CompositeBundle installCompositeBundle(Map /* <String, String> */frameworkConfig, String location, Map /* <String, String> */compositeManifest) throws BundleException; - -} diff --git a/bundles/org.eclipse.osgi/osgi/src/org/osgi/service/framework/SurrogateBundle.java b/bundles/org.eclipse.osgi/osgi/src/org/osgi/service/framework/SurrogateBundle.java deleted file mode 100644 index 932654be7..000000000 --- a/bundles/org.eclipse.osgi/osgi/src/org/osgi/service/framework/SurrogateBundle.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.osgi.service.framework; - -import java.io.InputStream; -import org.osgi.framework.*; - -/** - * A surrogate bundle is installed in a child framework, and is the child-facing - * representation of the composite bundle in the parent framework. - * <p> - * A surrogate bundle does the following as specified by the composite manifest: - * <ul> - * <li>Exports packages to the child framework from the parent framework. These - * packages are imported by the composite bundle installed in the parent - * framework.</li> - * <li>Imports packages from the child framework. These packages are exported - * by the composite bundle installed in the parent framework.</li> - * <li>Registers services from the parent framework with the child framework. - * These services are acquired by the composite bundle installed in the - * parent framework.</li> - * <li>Acquires services from the child framework. These services are - * registered by the composite bundle installed in the parent framework.</li> - * </ul> - * <p> - * @see CompositeBundle - * @deprecated This API proposal was rejected by the OSGi Alliance and will - * not be part of any OSGi specification. Please transition to the - * org.osgi.framework.hooks API to control resolution, bundle, and service - * isolation. This API will be removed from Equinox in the 3.9 release - * You are cautioned against relying upon this API. - */ -public interface SurrogateBundle extends Bundle { - /** - * Returns the bundle context of the associated composite bundle. - * @return the bundle context of the composite bundle. A value - * of <code>null</code> is returned if the composite bundle does - * not have a valid bundle context. - */ - BundleContext getCompositeBundleContext(); - - /** - * This operation is not supported for surrogate bundles. A - * <code>BundleException</code> of type - * {@link BundleException#INVALID_OPERATION invalid operation} must be - * thrown. - */ - void update() throws BundleException; - - /** - * This operation is not supported for surrogate bundles. A - * <code>BundleException</code> of type - * {@link BundleException#INVALID_OPERATION invalid operation} must be - * thrown. - */ - void update(InputStream input) throws BundleException; - - /** - * This operation is not supported for surrogate bundles. A - * <code>BundleException</code> of type - * {@link BundleException#INVALID_OPERATION invalid operation} must be - * thrown. - */ - void uninstall() throws BundleException; -} |