Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: c26dbb5f63a0c27a7a0265312b08997f4b4de24c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*******************************************************************************
 * Copyright (c) 2013, 2015 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.storage.bundlefile;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.Enumeration;
import org.eclipse.osgi.container.Module;
import org.eclipse.osgi.internal.hookregistry.BundleFileWrapperFactoryHook;
import org.eclipse.osgi.storage.BundleInfo;

/**
 * A {@link BundleFile bundle file} decorator. 
 * <p/>
 * Clients wishing to modify or extend the behavior of a bundle file at runtime 
 * should extend this class instead. A hook is provided by the related {@link 
 * BundleFileWrapperFactoryHook abstract factory} class in response to a 
 * {@link BundleFileWrapperFactoryHook#wrapBundleFile(BundleFile, 
 * BundleInfo.Generation, boolean) call} from the framework.
 */
public class BundleFileWrapper extends BundleFile {
	private final BundleFile bundleFile;

	/**
	 * Creates a new <code>BundleFileWrapper</code> instance wrapping the
	 * given {@link BundleFile bundle file}.
	 * 
	 * @param bundleFile - The bundle file to wrap.
	 * @throws NullPointerException - If the bundle file is <code>null</code>.
	 */
	public BundleFileWrapper(BundleFile bundleFile) {
		super(bundleFile.getBaseFile());
		this.bundleFile = bundleFile;
	}

	@Override
	public File getFile(String path, boolean nativeCode) {
		return bundleFile.getFile(path, nativeCode);
	}

	@Override
	public BundleEntry getEntry(String path) {
		return bundleFile.getEntry(path);
	}

	@Override
	public Enumeration<String> getEntryPaths(String path) {
		return bundleFile.getEntryPaths(path);
	}

	@Override
	public Enumeration<String> getEntryPaths(String path, boolean recurse) {
		return bundleFile.getEntryPaths(path, recurse);
	}

	/**
	 * Get the wrapped bundle file.
	 * 
	 * @return The wrapped bundle file.
	 */
	public BundleFile getBundleFile() {
		return bundleFile;
	}

	@Override
	public void close() throws IOException {
		bundleFile.close();
	}

	@Override
	public void open() throws IOException {
		bundleFile.open();
	}

	@Override
	public boolean containsDir(String dir) {
		return bundleFile.containsDir(dir);
	}

	@Override
	protected URL createResourceURL(BundleEntry bundleEntry, Module hostModule, int index, String path) {
		return bundleFile.createResourceURL(bundleEntry, hostModule, index, path);
	}

}

Back to the top