Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.osgi/defaultAdaptor/src/org')
-rw-r--r--bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/baseadaptor/bundlefile/BundleFileWrapperChain.java87
-rw-r--r--bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/BaseStorage.java5
-rw-r--r--bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader.java13
3 files changed, 99 insertions, 6 deletions
diff --git a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/baseadaptor/bundlefile/BundleFileWrapperChain.java b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/baseadaptor/bundlefile/BundleFileWrapperChain.java
new file mode 100644
index 000000000..29f2fd2dc
--- /dev/null
+++ b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/baseadaptor/bundlefile/BundleFileWrapperChain.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * 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.baseadaptor.bundlefile;
+
+import org.eclipse.osgi.baseadaptor.hooks.BundleFileWrapperFactoryHook;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Enumeration;
+import org.eclipse.osgi.baseadaptor.BaseData;
+
+/**
+ * Used to chain the BundleFile objects returned from {@link BundleFileWrapperFactoryHook}.
+ * This class is useful for traversing the chain of wrapped bundle files.
+ */
+public class BundleFileWrapperChain extends BundleFile {
+ private final BundleFile wrapped;
+ private final BundleFileWrapperChain next;
+
+ public BundleFileWrapperChain(BundleFile wrapped, BundleFileWrapperChain next) {
+ this.wrapped = wrapped;
+ this.next = next;
+ }
+
+ public void close() throws IOException {
+ wrapped.close();
+ }
+
+ public boolean containsDir(String dir) {
+ return wrapped.containsDir(dir);
+ }
+
+ public BundleEntry getEntry(String path) {
+ return wrapped.getEntry(path);
+ }
+
+ public Enumeration getEntryPaths(String path) {
+ return wrapped.getEntryPaths(path);
+ }
+
+ public File getFile(String path, boolean nativeCode) {
+ return wrapped.getFile(path, nativeCode);
+ }
+
+ public void open() throws IOException {
+ wrapped.open();
+ }
+
+ public File getBaseFile() {
+ return wrapped.getBaseFile();
+ }
+
+ public URL getResourceURL(String path, BaseData hostData, int index) {
+ return wrapped.getResourceURL(path, hostData, index);
+ }
+
+ public String toString() {
+ return wrapped.toString();
+ }
+
+ /**
+ * The BundleFile that is wrapped
+ * @return the BunldeFile that is wrapped
+ */
+ public BundleFile getWrapped() {
+ return wrapped;
+ }
+
+ /**
+ * The next WrapperBundleFile in the chain. A <code>null</code> value
+ * is returned if this is the end of the chain.
+ * @return the next WrapperBundleFile
+ */
+ public BundleFileWrapperChain getNext() {
+ return next;
+ }
+}
diff --git a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/BaseStorage.java b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/BaseStorage.java
index f4c31091b..109340568 100644
--- a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/BaseStorage.java
+++ b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/BaseStorage.java
@@ -684,10 +684,11 @@ public class BaseStorage implements SynchronousBundleListener {
// try creating a wrapper bundlefile out of it.
BundleFileWrapperFactoryHook[] wrapperFactories = adaptor.getHookRegistry().getBundleFileWrapperFactoryHooks();
+ BundleFileWrapperChain wrapped = wrapperFactories.length == 0 ? null : new BundleFileWrapperChain(result, null);
for (int i = 0; i < wrapperFactories.length; i++) {
BundleFile wrapperBundle = wrapperFactories[i].wrapBundleFile(result, content, data, base);
- if (wrapperBundle != null)
- result = wrapperBundle;
+ if (wrapperBundle != null && wrapperBundle != result)
+ result = wrapped = new BundleFileWrapperChain(wrapperBundle, wrapped);
}
return result;
}
diff --git a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader.java b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader.java
index f7cc29304..80ca4006e 100644
--- a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader.java
+++ b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2005, 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
@@ -18,8 +18,7 @@ import java.security.*;
import java.security.cert.Certificate;
import java.util.Enumeration;
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.bundlefile.*;
import org.eclipse.osgi.baseadaptor.loader.*;
import org.eclipse.osgi.framework.adaptor.BundleData;
import org.eclipse.osgi.framework.adaptor.ClassLoaderDelegate;
@@ -223,7 +222,13 @@ public class DefaultClassLoader extends ClassLoader implements BaseClassLoader {
// this is done just incase someone sets the security manager later
permissions = ALLPERMISSIONS;
Certificate[] certs = null;
- SignedContent signedContent = (bundlefile instanceof SignedContent) ? (SignedContent) bundlefile : null;
+ SignedContent signedContent = null;
+ if (bundlefile instanceof BundleFileWrapperChain) {
+ BundleFileWrapperChain wrapper = (BundleFileWrapperChain) bundlefile;
+ while (wrapper != null && (!(wrapper.getWrapped() instanceof SignedContent)))
+ wrapper = wrapper.getNext();
+ signedContent = wrapper == null ? null : (SignedContent) wrapper.getWrapped();
+ }
if (CLASS_CERTIFICATE && signedContent != null && signedContent.isSigned()) {
SignerInfo[] signers = signedContent.getSignerInfos();
if (signers.length > 0)

Back to the top