1 //******************************************************************
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
11 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #ifndef RESOURCECONTAINERIMPL_H_
22 #define RESOURCECONTAINERIMPL_H_
24 #include "ResourceContainer.h"
25 #include "ResourceContainerBundleAPI.h"
26 #include "BundleInfoInternal.h"
28 #include "RCSRequest.h"
29 #include "RCSResponse.h"
30 #include "ResourceObject.h"
35 using namespace OIC::Service;
42 class ResourceContainerImpl: public ResourceContainer, public ResourceContainerBundleAPI
45 ResourceContainerImpl();
46 virtual ~ResourceContainerImpl();
48 // methods from ResourceContainer
49 void startContainer(string configFile);
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);
60 // methods from ResourceContainerBundleAPI
61 void registerResource(BundleResource *resource);
62 void unregisterResource(BundleResource *resource);
64 void getBundleConfiguration(std::string bundleId, configInfo *configOutput);
65 void getResourceConfiguration(std::string bundleId,
66 std::vector< resourceInfo > *configOutput);
68 RCSGetResponse getRequestHandler(const RCSRequest &request,
69 const ResourceAttributes &attributes);
70 RCSSetResponse setRequestHandler(const RCSRequest &request,
71 const ResourceAttributes &attributes);
73 void onNotificationReceived(std::string strResourceUri);
75 static ResourceContainerImpl *getImplInstance();
76 static ResourceObject::Ptr buildResourceObject(string strUri, string strResourceType);
78 void startBundle(string bundleId);
79 void stopBundle(string bundleId);
81 void addBundle(string bundleId, string bundleUri, string bundlePath,
82 std::map<string, string> params);
83 void removeBundle(string bundleId);
85 std::list<BundleInfo *> listBundles();
87 void addResourceConfig(string bundleId, string resourceUri, std::map<string, string> params);
88 void removeResourceConfig(string bundleId, string resourceUri);
90 std::list<string> listBundleResources(string bundleId);
92 JavaVM *getJavaVM(string bundleId);
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>>
101 Configuration *m_config = NULL;
102 map<string, JavaVM *> m_bundleVM;
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);