KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > osgi > framework > adaptor > BundleOperation


1 /*******************************************************************************
2  * Copyright (c) 2003, 2005 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.framework.adaptor;
13
14 import org.osgi.framework.BundleException;
15
16 /**
17  * Bundle Storage interface for managing a persistent storage life
18  * cycle operation upon a bundle.
19  *
20  * <p>This class is used to provide methods to manage a life cycle
21  * operation on a bundle in persistent storage. BundleOperation objects
22  * are returned by the FrameworkAdaptor object and are called by OSGi
23  * to complete the persistent storage life cycle operation.
24  *
25  * <p>For example
26  * <pre>
27  * Bundle bundle;
28  * BundleOperation storage = adaptor.installBundle(location, source);
29  * try {
30  * bundle = storage.begin();
31  *
32  * // Perform some implementation specific work
33  * // which may fail.
34  *
35  * storage.commit(false);
36  * // bundle has been successfully installed
37  * } catch (BundleException e) {
38  * storage.undo();
39  * throw e; // rethrow the error
40  * }
41  * return bundle;
42  * </pre>
43  * <p>
44  * Clients may implement this interface.
45  * </p>
46  * @since 3.1
47  */

48 public abstract interface BundleOperation {
49
50     /**
51      * Begin the operation on the bundle (install, update, uninstall).
52      *
53      * @return BundleData object for the target bundle.
54      * @throws BundleException If a failure occured modifiying peristent storage.
55      */

56     public abstract BundleData begin() throws BundleException;
57
58     /**
59      * Commit the operation performed.
60      *
61      * @param postpone If true, the bundle's persistent
62      * storage cannot be immediately reclaimed. This may occur if the
63      * bundle is still exporting a package.
64      * @throws BundleException If a failure occured modifiying peristent storage.
65      */

66     public abstract void commit(boolean postpone) throws BundleException;
67
68     /**
69      * Undo the change to persistent storage.
70      * <p>This method can be called before calling commit or if commit
71      * throws an exception to undo any changes in progress.
72      *
73      * @throws BundleException If a failure occured modifiying peristent storage.
74      */

75     public abstract void undo() throws BundleException;
76
77 }
78
Popular Tags