Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 83e1351aa38b72caf332afdcf589b344d3c9a4cb (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
/*******************************************************************************
 * Copyright (c) 2005, 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.baseadaptor;

import java.io.IOException;
import org.eclipse.osgi.baseadaptor.BaseData;
import org.eclipse.osgi.framework.adaptor.BundleData;
import org.eclipse.osgi.framework.adaptor.BundleOperation;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleException;

public class BundleUninstall implements BundleOperation {
	private BaseData data;
	private BaseStorage storage;

	public BundleUninstall(BaseData data, BaseStorage storage) {
		this.data = data;
		this.storage = storage;
	}

	/**
	 * Perform the change to persistent storage.
	 *
	 * @return Bundle object for the target bundle.
	 * @throws BundleException If a failure occured modifiying peristent storage.
	 */
	public BundleData begin() throws BundleException {
		return data;
	}

	/**
	 * Commit the change to persistent storage.
	 *
	 * @param postpone If true, the bundle's persistent
	 * storage cannot be immediately reclaimed.
	 * @throws BundleException If a failure occured modifiying peristent storage.
	 */
	public void commit(boolean postpone) throws BundleException {
		BaseStorageHook storageHook = (BaseStorageHook) data.getStorageHook(BaseStorageHook.KEY);
		try {
			storageHook.delete(postpone, BaseStorageHook.DEL_BUNDLE_STORE);
		} catch (IOException e) {
			// nothing we can do
		}
		storage.processExtension(data, BaseStorage.EXTENSION_UNINSTALLED);
		data.setLastModified(System.currentTimeMillis());
		storage.updateState(data, BundleEvent.UNINSTALLED);
		data.setDirty(true);
		try {
			data.save();
		} catch (IOException e) {
			throw new BundleException(AdaptorMsg.ADAPTOR_STORAGE_EXCEPTION, e);
		}
	}

	/**
	 * Undo the change to persistent storage.
	 *
	 * @throws BundleException If a failure occured modifiying peristent storage.
	 */
	public void undo() throws BundleException {
		// do nothing
	}

}

Back to the top