activationLock.lock();
- if (!configFile.empty())
- {
- m_config = new Configuration(configFile);
-
- if (m_config->isLoaded())
+ try{
+ if (!configFile.empty())
{
- configInfo bundles;
- m_config->getConfiguredBundles(&bundles);
+ m_config = new Configuration(configFile);
- for (unsigned int i = 0; i < bundles.size(); i++)
+ if (m_config->isLoaded())
{
- shared_ptr<BundleInfoInternal> bundleInfo(new BundleInfoInternal);
- bundleInfo->setPath(bundles[i][BUNDLE_PATH]);
- bundleInfo->setVersion(bundles[i][BUNDLE_VERSION]);
- bundleInfo->setID(bundles[i][BUNDLE_ID]);
- if (!bundles[i][BUNDLE_ACTIVATOR].empty())
+ configInfo bundles;
+ m_config->getConfiguredBundles(&bundles);
+
+ for (unsigned int i = 0; i < bundles.size(); i++)
{
- string activatorName = bundles[i][BUNDLE_ACTIVATOR];
- std::replace(activatorName.begin(), activatorName.end(), '.', '/');
- bundleInfo->setActivatorName(activatorName);
- bundleInfo->setLibraryPath(bundles[i][BUNDLE_LIBRARY_PATH]);
- }
+ shared_ptr<BundleInfoInternal> bundleInfo(new BundleInfoInternal);
+ bundleInfo->setPath(bundles[i][BUNDLE_PATH]);
+ bundleInfo->setVersion(bundles[i][BUNDLE_VERSION]);
+ bundleInfo->setID(bundles[i][BUNDLE_ID]);
+ if (!bundles[i][BUNDLE_ACTIVATOR].empty())
+ {
+ string activatorName = bundles[i][BUNDLE_ACTIVATOR];
+ std::replace(activatorName.begin(), activatorName.end(), '.', '/');
+ bundleInfo->setActivatorName(activatorName);
+ bundleInfo->setLibraryPath(bundles[i][BUNDLE_LIBRARY_PATH]);
+ }
- OIC_LOG_V(INFO, CONTAINER_TAG, "Init Bundle:(%s)",
- std::string(bundles[i][BUNDLE_ID] + ";" +
- bundles[i][BUNDLE_PATH]).c_str());
+ OIC_LOG_V(INFO, CONTAINER_TAG, "Init Bundle:(%s)",
+ std::string(bundles[i][BUNDLE_ID] + ";" +
+ bundles[i][BUNDLE_PATH]).c_str());
- registerBundle(bundleInfo);
- activateBundle(bundleInfo);
+ registerBundle(bundleInfo);
+ activateBundle(bundleInfo);
+ }
+ }
+ else
+ {
+ OIC_LOG_V(ERROR, CONTAINER_TAG, "Container started with invalid configfile path.");
}
}
else
{
- OIC_LOG_V(ERROR, CONTAINER_TAG, "Container started with invalid configfile path.");
+ OIC_LOG_V(INFO, CONTAINER_TAG, "No configuration file for the container provided.");
}
- }
- else
- {
- OIC_LOG_V(INFO, CONTAINER_TAG, "No configuration file for the container provided.");
- }
- map<std::string, boost::thread >::iterator activatorIterator;
-
- for (activatorIterator = m_activators.begin(); activatorIterator != m_activators.end();
- activatorIterator++)
- {
- activatorIterator->second.timed_join(
- boost::posix_time::seconds(BUNDLE_ACTIVATION_WAIT_SEC));
- // wait for bundles to be activated
+ OIC_LOG(INFO, CONTAINER_TAG, "Resource container started.");
+ }catch(...){
+ OIC_LOG(INFO, CONTAINER_TAG, "Resource container failed starting.");
}
activationLock.unlock();
- OIC_LOG(INFO, CONTAINER_TAG, "Resource container started.");
}
void ResourceContainerImpl::stopContainer()
{
OIC_LOG_V(INFO, CONTAINER_TAG, "Activating bundle: (%s)",
std::string(m_bundles[id]->getID()).c_str());
+
activationLock.lock();
- auto f = std::bind(&ResourceContainerImpl::activateBundleThread, this,
- id);
- boost::thread activator(f);
- activator.timed_join(boost::posix_time::seconds(BUNDLE_SET_GET_WAIT_SEC));
+ try{
+ activateBundleThread(id);
+ }
+ catch(...){
+ OIC_LOG_V(INFO, CONTAINER_TAG, "Activating bundle: (%s) failed",
+ std::string(m_bundles[id]->getID()).c_str());
+ }
activationLock.unlock();
OIC_LOG_V(INFO, CONTAINER_TAG, "Bundle activated: (%s)",
std::string(m_bundles[id]->getID()).c_str());
{
RCSResourceAttributes attr;
std::string strResourceUri = request.getResourceUri();
+ const std::map< std::string, std::string > &queryParams = request.getQueryParams();
+
OIC_LOG_V(INFO, CONTAINER_TAG, "Container get request for %s",strResourceUri.c_str());
if (m_mapServers.find(strResourceUri) != m_mapServers.end()
{
if (m_mapResources[strResourceUri])
{
- auto getFunction = [this, &attr, &strResourceUri]()
+ auto getFunction = [this, &attr, &strResourceUri, queryParams]()
{
- attr = m_mapResources[strResourceUri]->handleGetAttributesRequest();
+ attr = m_mapResources[strResourceUri]->handleGetAttributesRequest(queryParams);
};
boost::thread getThread(getFunction);
getThread.timed_join(boost::posix_time::seconds(BUNDLE_SET_GET_WAIT_SEC));
}
}
- OIC_LOG_V(INFO, CONTAINER_TAG, "Container get request for %s finished, %d attributes",strResourceUri.c_str(), attr.size());
+ OIC_LOG_V(INFO, CONTAINER_TAG, "Container get request for %s finished, %zu attributes",strResourceUri.c_str(), attr.size());
return RCSGetResponse::create(std::move(attr), 200);
}
RCSResourceAttributes attr;
std::list<std::string> lstAttributes;
std::string strResourceUri = request.getResourceUri();
+ const std::map< std::string, std::string > &queryParams = request.getQueryParams();
- OIC_LOG_V(INFO, CONTAINER_TAG, "Container set request for %s, %d attributes",strResourceUri.c_str(), attributes.size());
+ OIC_LOG_V(INFO, CONTAINER_TAG, "Container set request for %s, %zu attributes",strResourceUri.c_str(), attributes.size());
if (m_mapServers.find(strResourceUri) != m_mapServers.end()
&& m_mapResources.find(strResourceUri) != m_mapResources.end())
{
if (m_mapResources[strResourceUri])
{
- auto setFunction = [this, &lstAttributes, &strResourceUri, &attributes, &attr]()
+ auto setFunction = [this, &lstAttributes, &strResourceUri, &attributes, &attr, queryParams]()
{
lstAttributes = m_mapResources[strResourceUri]->getAttributeNames();
}
OIC_LOG_V(INFO, CONTAINER_TAG, "Calling handleSetAttributeRequest");
- m_mapResources[strResourceUri]->handleSetAttributesRequest(attr);
+ m_mapResources[strResourceUri]->handleSetAttributesRequest(attr, queryParams);
};
boost::thread setThread(setFunction);
setThread.timed_join(boost::posix_time::seconds(BUNDLE_SET_GET_WAIT_SEC));