KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > internal > runtime > PlatformActivator


1 /*******************************************************************************
2  * Copyright (c) 2003, 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  * Julian Chen - fix for bug #92572, jclRM
11  *******************************************************************************/

12 package org.eclipse.core.internal.runtime;
13
14 import org.eclipse.core.runtime.*;
15 import org.eclipse.equinox.internal.app.CommandLineArgs;
16 import org.osgi.framework.*;
17
18 /**
19  * Activator for the Eclipse runtime.
20  */

21 public class PlatformActivator extends Plugin implements BundleActivator {
22     private static BundleContext context;
23     private ServiceRegistration entryLocatorRegistration;
24
25     public static BundleContext getContext() {
26         return context;
27     }
28
29     public void start(BundleContext runtimeContext) throws Exception JavaDoc {
30         PlatformActivator.context = runtimeContext;
31         InternalPlatform.getDefault().start(runtimeContext);
32         startAppContainer();
33         InternalPlatform.getDefault().setRuntimeInstance(this);
34         super.start(runtimeContext);
35     }
36
37     public void stop(BundleContext runtimeContext) {
38         // unregister the EntryLocator to prevent the Framework from calling it
39
unregisterEntryLocator();
40         // Stop the platform orderly.
41
InternalPlatform.getDefault().stop(runtimeContext);
42         InternalPlatform.getDefault().setRuntimeInstance(null);
43     }
44
45     private void startAppContainer() {
46         // just using a class out of app admin to force it to lazy-start
47
CommandLineArgs.getApplicationArgs();
48     }
49
50     private void unregisterEntryLocator() {
51         if (entryLocatorRegistration != null) {
52             entryLocatorRegistration.unregister();
53             entryLocatorRegistration = null;
54         }
55     }
56 }
57
Popular Tags