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_
26 #include "ResourceContainer.h"
27 #include "ResourceContainerBundleAPI.h"
28 #include "BundleInfoInternal.h"
30 #include "RCSRequest.h"
31 #include "RCSResponse.h"
32 #include "ResourceObject.h"
40 using namespace OIC::Service;
47 class ResourceContainerImpl: public ResourceContainer, public ResourceContainerBundleAPI
50 ResourceContainerImpl();
51 virtual ~ResourceContainerImpl();
53 // methods from ResourceContainer
54 void startContainer(const std::string &configFile);
56 void activateBundle(BundleInfo *bundleInfo);
57 void deactivateBundle(BundleInfo *bundleInfo);
58 void activateBundle(const std::string &bundleId);
59 void deactivateBundle(const std::string &bundleId);
60 void registerBundle(BundleInfo *bundleinfo);
61 void unregisterBundle(BundleInfo *bundleinfo);
62 void unregisterBundleSo(const std::string &id);
65 // methods from ResourceContainerBundleAPI
66 void registerResource(BundleResource *resource);
67 void unregisterResource(BundleResource *resource);
69 void getBundleConfiguration(const std::string &bundleId, configInfo *configOutput);
70 void getResourceConfiguration(const std::string &bundleId,
71 std::vector< resourceInfo > *configOutput);
73 RCSGetResponse getRequestHandler(const RCSRequest &request,
74 const ResourceAttributes &attributes);
75 RCSSetResponse setRequestHandler(const RCSRequest &request,
76 const ResourceAttributes &attributes);
78 void onNotificationReceived(const std::string &strResourceUri);
80 static ResourceContainerImpl *getImplInstance();
81 static ResourceObject::Ptr buildResourceObject(const std::string &strUri, const std::string &strResourceType);
83 void startBundle(const std::string &bundleId);
84 void stopBundle(const std::string &bundleId);
86 void addBundle(const std::string &bundleId, const std::string &bundleUri, const std::string &bundlePath,
87 std::map<string, string> params);
88 void removeBundle(const std::string &bundleId);
90 std::list<BundleInfo *> listBundles();
92 void addResourceConfig(const std::string &bundleId, const std::string &resourceUri, std::map<string, string> params);
93 void removeResourceConfig(const std::string &bundleId, const std::string &resourceUri);
95 std::list<string> listBundleResources(const std::string &bundleId);
98 JavaVM *getJavaVM(string bundleId);
99 void unregisterBundleJava(string id);
104 map< std::string, BundleInfoInternal * > m_bundles; // <bundleID, bundleInfo>
105 map< std::string, ResourceObject::Ptr > m_mapServers; //<uri, serverPtr>
106 map< std::string, BundleResource * > m_mapResources; //<uri, resourcePtr>
107 map< std::string, list<string> > m_mapBundleResources; //<bundleID, vector<uri>>
109 Configuration *m_config;
112 void activateSoBundle(const std::string &bundleId);
113 void deactivateSoBundle(const std::string &bundleId);
114 void addSoBundleResource(const std::string &bundleId, resourceInfo newResourceInfo);
115 void removeSoBundleResource(const std::string &bundleId, const std::string &resourceUri);
116 void registerSoBundle(BundleInfo *bundleInfo);
119 map<string, JavaVM *> m_bundleVM;
121 void registerJavaBundle(BundleInfo *bundleInfo);
122 void activateJavaBundle(string bundleId);
123 void deactivateJavaBundle(string bundleId);