e49f52356d37f248e0d7c61295ae6908e36d06b9
[platform/upstream/iotivity.git] / service / simulator / java / eclipse-plugin / ServiceProviderPlugin / src / oic / simulator / serviceprovider / Activator.java
1 /*
2  * Copyright 2015 Samsung Electronics All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package oic.simulator.serviceprovider;
18
19 import org.eclipse.ui.plugin.AbstractUIPlugin;
20 import org.osgi.framework.BundleContext;
21
22 import oic.simulator.serviceprovider.manager.ImageManager;
23 import oic.simulator.serviceprovider.manager.LogManager;
24 import oic.simulator.serviceprovider.manager.ResourceManager;
25
26 /**
27  * The activator class controls the plug-in life cycle.
28  */
29 public class Activator extends AbstractUIPlugin {
30
31     // The plug-in ID
32     public static final String     PLUGIN_ID = "ServiceProviderPlugin";
33
34     // The shared instance
35     private static Activator       plugin;
36
37     private static ResourceManager resourceManager;
38
39     private static LogManager      logManager;
40
41     private static ImageManager    imageManager;
42
43     public Activator() {
44     }
45
46     public void start(BundleContext context) throws Exception {
47         super.start(context);
48         plugin = this;
49         setLogManager(new LogManager());
50         setResourceManager(new ResourceManager());
51         imageManager = ImageManager.getInstance();
52     }
53
54     public void stop(BundleContext context) throws Exception {
55         plugin = null;
56
57         // Stopping Resource Manager
58         if (null != resourceManager) {
59             resourceManager.shutdown();
60             resourceManager = null;
61         }
62         // Stopping Log Manager
63         if (null != logManager) {
64             logManager.shutdown();
65             logManager = null;
66         }
67         super.stop(context);
68     }
69
70     public static Activator getDefault() {
71         return plugin;
72     }
73
74     public ResourceManager getResourceManager() {
75         return resourceManager;
76     }
77
78     private static void setResourceManager(ResourceManager manager) {
79         Activator.resourceManager = manager;
80     }
81
82     public LogManager getLogManager() {
83         return logManager;
84     }
85
86     private static void setLogManager(LogManager logManager) {
87         Activator.logManager = logManager;
88     }
89
90     public ImageManager getImageManager() {
91         return imageManager;
92     }
93 }