KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > net > Activator


1 /*******************************************************************************
2  * Copyright (c) 2007 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  * yyyymmdd bug Email and other contact information
11  * -------- -------- -----------------------------------------------------------
12  * 20070201 154100 pmoogk@ca.ibm.com - Peter Moogk, Port internet code from WTP to Eclipse base.
13  *******************************************************************************/

14 package org.eclipse.ui.internal.net;
15
16 import org.eclipse.core.net.proxy.IProxyService;
17 import org.eclipse.ui.plugin.AbstractUIPlugin;
18 import org.osgi.framework.BundleContext;
19 import org.osgi.util.tracker.ServiceTracker;
20
21 /**
22  * The activator class controls the plug-in life cycle
23  */

24 public class Activator extends AbstractUIPlugin {
25
26     // The plug-in ID
27
public static final String JavaDoc PLUGIN_ID = "org.eclipse.ui.net"; //$NON-NLS-1$
28

29     // The shared instance
30
private static Activator plugin;
31
32     private ServiceTracker tracker;
33
34     /**
35      * The constructor
36      */

37     public Activator() {
38         plugin = this;
39     }
40
41     /**
42      * Returns the shared instance
43      *
44      * @return the shared instance
45      */

46     public static Activator getDefault() {
47         return plugin;
48     }
49
50     /**
51      * Return the {@link IProxyService} or <code>null</code> if the service is
52      * not available.
53      *
54      * @return the {@link IProxyService} or <code>null</code>
55      */

56     public IProxyService getProxyService() {
57         return (IProxyService) tracker.getService();
58     }
59
60     public void start(BundleContext context) throws Exception JavaDoc {
61         super.start(context);
62         tracker = new ServiceTracker(getBundle().getBundleContext(),
63                 IProxyService.class.getName(), null);
64         tracker.open();
65     }
66
67     public void stop(BundleContext context) throws Exception JavaDoc {
68         plugin = null;
69         super.stop(context);
70         tracker.close();
71     }
72 }
73
Popular Tags