86
|
1 /*
|
|
2 * $Header: /cvshome/build/org.osgi.framework/src/org/osgi/framework/BundleActivator.java,v 1.14 2007/02/21 16:49:05 hargrave Exp $
|
|
3 *
|
|
4 * Copyright (c) OSGi Alliance (2000, 2007). All Rights Reserved.
|
|
5 *
|
|
6 * Licensed under the Apache License, Version 2.0 (the "License");
|
|
7 * you may not use this file except in compliance with the License.
|
|
8 * You may obtain a copy of the License at
|
|
9 *
|
|
10 * http://www.apache.org/licenses/LICENSE-2.0
|
|
11 *
|
|
12 * Unless required by applicable law or agreed to in writing, software
|
|
13 * distributed under the License is distributed on an "AS IS" BASIS,
|
|
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15 * See the License for the specific language governing permissions and
|
|
16 * limitations under the License.
|
|
17 */
|
|
18
|
|
19 module org.osgi.framework.BundleActivator;
|
|
20 import org.osgi.framework.Bundle;
|
|
21 import org.osgi.framework.BundleContext;
|
|
22
|
|
23 import java.lang.all;
|
|
24
|
|
25 /**
|
|
26 * Customizes the starting and stopping of a bundle.
|
|
27 * <p>
|
|
28 * <code>BundleActivator</code> is an interface that may be implemented when a
|
|
29 * bundle is started or stopped. The Framework can create instances of a
|
|
30 * bundle's <code>BundleActivator</code> as required. If an instance's
|
|
31 * <code>BundleActivator.start</code> method executes successfully, it is
|
|
32 * guaranteed that the same instance's <code>BundleActivator.stop</code>
|
|
33 * method will be called when the bundle is to be stopped. The Framework must
|
|
34 * not concurrently call a <code>BundleActivator</code> object.
|
|
35 *
|
|
36 * <p>
|
|
37 * <code>BundleActivator</code> is specified through the
|
|
38 * <code>Bundle-Activator</code> Manifest header. A bundle can only specify a
|
|
39 * single <code>BundleActivator</code> in the Manifest file. Fragment bundles
|
|
40 * must not have a <code>BundleActivator</code>. The form of the Manifest
|
|
41 * header is:
|
|
42 *
|
|
43 * <p>
|
|
44 * <code>Bundle-Activator: <i>class-name</i></code>
|
|
45 *
|
|
46 * <p>
|
|
47 * where <code><i>class-name</i></code> is a fully qualified Java classname.
|
|
48 * <p>
|
|
49 * The specified <code>BundleActivator</code> class must have a public
|
|
50 * constructor that takes no parameters so that a <code>BundleActivator</code>
|
|
51 * object can be created by <code>Class.newInstance()</code>.
|
|
52 *
|
|
53 * @NotThreadSafe
|
|
54 * @version $Revision: 1.14 $
|
|
55 */
|
|
56
|
|
57 public interface BundleActivator {
|
|
58 /**
|
|
59 * Called when this bundle is started so the Framework can perform the
|
|
60 * bundle-specific activities necessary to start this bundle. This method
|
|
61 * can be used to register services or to allocate any resources that this
|
|
62 * bundle needs.
|
|
63 *
|
|
64 * <p>
|
|
65 * This method must complete and return to its caller in a timely manner.
|
|
66 *
|
|
67 * @param context The execution context of the bundle being started.
|
|
68 * @throws java.lang.Exception If this method throws an exception, this
|
|
69 * bundle is marked as stopped and the Framework will remove this
|
|
70 * bundle's listeners, unregister all services registered by this
|
|
71 * bundle, and release all services used by this bundle.
|
|
72 */
|
|
73 public void start(BundleContext context);
|
|
74
|
|
75 /**
|
|
76 * Called when this bundle is stopped so the Framework can perform the
|
|
77 * bundle-specific activities necessary to stop the bundle. In general, this
|
|
78 * method should undo the work that the <code>BundleActivator.start</code>
|
|
79 * method started. There should be no active threads that were started by
|
|
80 * this bundle when this bundle returns. A stopped bundle must not call any
|
|
81 * Framework objects.
|
|
82 *
|
|
83 * <p>
|
|
84 * This method must complete and return to its caller in a timely manner.
|
|
85 *
|
|
86 * @param context The execution context of the bundle being stopped.
|
|
87 * @throws java.lang.Exception If this method throws an exception, the
|
|
88 * bundle is still marked as stopped, and the Framework will remove
|
|
89 * the bundle's listeners, unregister all services registered by the
|
|
90 * bundle, and release all services used by the bundle.
|
|
91 */
|
|
92 public void stop(BundleContext context);
|
|
93 }
|