update container and sample bundles for so bundle dynamic configuraion
[platform/upstream/iotivity.git] / service / resource-manipulation / src / resourceContainer / include / ResourceContainerImpl.h
1 //******************************************************************
2 //
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 #ifndef RESOURCECONTAINERIMPL_H_
22 #define RESOURCECONTAINERIMPL_H_
23
24 #include "ResourceContainer.h"
25 #include "ResourceContainerBundleAPI.h"
26 #include "BundleInfoInternal.h"
27
28 #include "RCSRequest.h"
29 #include "RCSResponse.h"
30 #include "ResourceObject.h"
31
32 #include "jni.h"
33 #include <map>
34
35 using namespace OIC::Service;
36
37 namespace OIC
38 {
39     namespace Service
40     {
41
42         class ResourceContainerImpl: public ResourceContainer, public ResourceContainerBundleAPI
43         {
44             public:
45                 ResourceContainerImpl();
46                 virtual ~ResourceContainerImpl();
47
48                 // methods from ResourceContainer
49                 void startContainer(string configFile);
50                 void stopContainer();
51                 void activateBundle(BundleInfo *bundleInfo);
52                 void deactivateBundle(BundleInfo *bundleInfo);
53                 void activateBundle(string bundleId);
54                 void deactivateBundle(string bundleId);
55                 void registerBundle(BundleInfo *bundleinfo);
56                 void unregisterBundle(BundleInfo *bundleinfo);
57                 void unregisterBundleSo(string id);
58                 void unregisterBundleJava(string id);
59
60                 // methods from ResourceContainerBundleAPI
61                 void registerResource(BundleResource *resource);
62                 void unregisterResource(BundleResource *resource);
63
64                 void getBundleConfiguration(std::string bundleId, configInfo *configOutput);
65                 void getResourceConfiguration(std::string bundleId,
66                                               std::vector< resourceInfo > *configOutput);
67
68                 RCSGetResponse getRequestHandler(const RCSRequest &request,
69                                                  const ResourceAttributes &attributes);
70                 RCSSetResponse setRequestHandler(const RCSRequest &request,
71                                                  const ResourceAttributes &attributes);
72
73                 void onNotificationReceived(std::string strResourceUri);
74
75                 static ResourceContainerImpl *getImplInstance();
76                 static ResourceObject::Ptr buildResourceObject(string strUri, string strResourceType);
77
78                 void startBundle(string bundleId);
79                 void stopBundle(string bundleId);
80
81                 void addBundle(string bundleId, string bundleUri, string bundlePath,
82                                std::map<string, string> params);
83                 void removeBundle(string bundleId);
84
85                 std::list<BundleInfo *> listBundles();
86
87                 void addResourceConfig(string bundleId, string resourceUri, std::map<string, string> params);
88                 void removeResourceConfig(string bundleId, string resourceUri);
89
90                 std::list<string> listBundleResources(string bundleId);
91
92                 JavaVM *getJavaVM(string bundleId);
93
94
95             private:
96                 map< std::string, BundleInfoInternal * > m_bundles; // <bundleID, bundleInfo>
97                 map< std::string, ResourceObject::Ptr > m_mapServers; //<uri, serverPtr>
98                 map< std::string, BundleResource * > m_mapResources; //<uri, resourcePtr>
99                 map< std::string, list<string> > m_mapBundleResources; //<bundleID, vector<uri>>
100                 string m_configFile;
101                 Configuration *m_config = NULL;
102                 map<string, JavaVM *> m_bundleVM;
103
104                 void registerJavaBundle(BundleInfo *bundleInfo);
105                 void registerSoBundle(BundleInfo *bundleInfo);
106                 void activateJavaBundle(string bundleId);
107                 void activateSoBundle(string bundleId);
108                 void deactivateJavaBundle(string bundleId);
109                 void deactivateSoBundle(string bundleId);
110                 void addSoBundleResource(string bundleId, resourceInfo newResourceInfo);
111                 void removeSoBundleResource(string bundleId, string resourceUri);
112         };
113     }
114 }
115 #endif