Performed refactoring and code cleanup on service provider plug-in.
[platform/upstream/iotivity.git] / service / simulator / java / eclipse-plugin / ServiceProviderPlugin / src / oic / simulator / serviceprovider / Activator.java
1 package oic.simulator.serviceprovider;
2
3 import oic.simulator.serviceprovider.manager.ImageManager;
4 import oic.simulator.serviceprovider.manager.LogManager;
5 import oic.simulator.serviceprovider.manager.ResourceManager;
6
7 import org.eclipse.ui.plugin.AbstractUIPlugin;
8 import org.osgi.framework.BundleContext;
9
10 /**
11  * The activator class controls the plug-in life cycle
12  */
13 public class Activator extends AbstractUIPlugin {
14
15     // The plug-in ID
16     public static final String     PLUGIN_ID = "ServiceProviderPlugin"; //$NON-NLS-1$
17
18     // The shared instance
19     private static Activator       plugin;
20
21     private static ResourceManager resourceManager;
22
23     private static LogManager      logManager;
24
25     private static ImageManager    imageManager;
26
27     public Activator() {
28     }
29
30     public void start(BundleContext context) throws Exception {
31         super.start(context);
32         plugin = this;
33         setResourceManager(new ResourceManager());
34         setLogManager(new LogManager());
35         imageManager = ImageManager.getInstance();
36     }
37
38     public void stop(BundleContext context) throws Exception {
39         plugin = null;
40
41         // Stopping Resource Manager
42         if (null != resourceManager) {
43             resourceManager.shutdown();
44             resourceManager = null;
45         }
46         // Stopping Log Manager
47         if (null != logManager) {
48             logManager.shutdown();
49             logManager = null;
50         }
51         super.stop(context);
52     }
53
54     public static Activator getDefault() {
55         return plugin;
56     }
57
58     public ResourceManager getResourceManager() {
59         return resourceManager;
60     }
61
62     private static void setResourceManager(ResourceManager manager) {
63         Activator.resourceManager = manager;
64     }
65
66     public LogManager getLogManager() {
67         return logManager;
68     }
69
70     private static void setLogManager(LogManager logManager) {
71         Activator.logManager = logManager;
72     }
73
74     public ImageManager getImageManager() {
75         return imageManager;
76     }
77 }