KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > osgi > internal > baseadaptor > BundleUninstall


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.osgi.internal.baseadaptor;
13
14 import java.io.*;
15 import org.eclipse.osgi.baseadaptor.BaseData;
16 import org.eclipse.osgi.framework.adaptor.BundleData;
17 import org.eclipse.osgi.framework.adaptor.BundleOperation;
18 import org.osgi.framework.BundleEvent;
19 import org.osgi.framework.BundleException;
20
21 public class BundleUninstall implements BundleOperation {
22     private BaseData data;
23     private BaseStorage storage;
24
25     public BundleUninstall(BaseData data, BaseStorage storage) {
26         this.data = data;
27         this.storage = storage;
28     }
29
30     /**
31      * Perform the change to persistent storage.
32      *
33      * @return Bundle object for the target bundle.
34      * @throws BundleException If a failure occured modifiying peristent storage.
35      */

36     public BundleData begin() throws BundleException {
37         return data;
38     }
39
40     /**
41      * Commit the change to persistent storage.
42      *
43      * @param postpone If true, the bundle's persistent
44      * storage cannot be immediately reclaimed.
45      * @throws BundleException If a failure occured modifiying peristent storage.
46      */

47     public void commit(boolean postpone) throws BundleException {
48         BaseStorageHook storageHook = (BaseStorageHook) data.getStorageHook(BaseStorageHook.KEY);
49         try {
50             storageHook.delete(postpone, BaseStorageHook.DEL_BUNDLE_STORE);
51         } catch (IOException e) {
52             // nothing we can do
53
}
54         storage.processExtension(data, BaseStorage.EXTENSION_UNINSTALLED);
55         data.setLastModified(System.currentTimeMillis());
56         storage.updateState(data, BundleEvent.UNINSTALLED);
57     }
58
59     /**
60      * Undo the change to persistent storage.
61      *
62      * @throws BundleException If a failure occured modifiying peristent storage.
63      */

64     public void undo() throws BundleException {
65         // do nothing
66
}
67
68 }
69
Popular Tags