Merge branch 'resource-container'
authorMarkus Jung <markus.jung@samsung.com>
Mon, 29 Feb 2016 00:23:09 +0000 (09:23 +0900)
committerMarkus Jung <markus.jung@samsung.com>
Mon, 29 Feb 2016 04:20:47 +0000 (13:20 +0900)
Conflicts:
service/resource-container/examples/ContainerSample.cpp
service/resource-container/include/RCSBundleInfo.h
service/resource-container/src/BundleResource.cpp
service/resource-container/src/ResourceContainerImpl.cpp
service/resource-encapsulation/src/serverBuilder/src/RCSResourceObject.cpp

Change-Id: I84024311d8285a0356bcdccfec20bb38d41a9d98
Signed-off-by: Markus Jung <markus.jung@samsung.com>
19 files changed:
1  2 
service/SConscript
service/resource-container/android/resource-container/src/main/jni/JniBundleResource.cpp
service/resource-container/android/resource-container/src/main/jni/JniBundleResource.h
service/resource-container/bundle-api/include/BundleResource.h
service/resource-container/examples/BMISensorBundle/src/BMISensorResource.cpp
service/resource-container/examples/ContainerSampleClient.cpp
service/resource-container/examples/DiscomfortIndexSensorBundle/src/DiscomfortIndexSensorResource.cpp
service/resource-container/examples/android/RCSampleServerApp/app/build.gradle
service/resource-container/include/RCSBundleInfo.h
service/resource-container/src/BundleResource.cpp
service/resource-container/src/Configuration.cpp
service/resource-container/src/DiscoverResourceUnit.cpp
service/resource-container/src/DiscoverResourceUnit.h
service/resource-container/src/JavaBundleResource.cpp
service/resource-container/src/RemoteResourceUnit.cpp
service/resource-container/src/ResourceContainerImpl.cpp
service/resource-container/src/ResourceContainerImpl.h
service/resource-encapsulation/src/resourceClient/RCSRemoteResourceObject.cpp
service/resource-encapsulation/src/serverBuilder/src/RCSResourceObject.cpp

Simple merge
index 0000000,b5f85d5..1bed71c
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,361 +1,361 @@@
 -void JniBundleResource::handleSetAttributesRequest(RCSResourceAttributes &attrs){
+ //******************************************************************
+ //
+ // Copyright 2015 Samsung Electronics All Rights Reserved.
+ //
+ //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ //
+ // Licensed under the Apache License, Version 2.0 (the "License");
+ // you may not use this file except in compliance with the License.
+ // You may obtain a copy of the License at
+ //
+ //      http://www.apache.org/licenses/LICENSE-2.0
+ //
+ // Unless required by applicable law or agreed to in writing, software
+ // distributed under the License is distributed on an "AS IS" BASIS,
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ // See the License for the specific language governing permissions and
+ // limitations under the License.
+ //
+ //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ #include "JniBundleResource.h"
+ #include "JniRcsResourceAttributes.h"
+ #include "JavaClasses.h"
+ #include "JavaLocalRef.h"
+ #include "JNIEnvWrapper.h"
+ #include "JniRcsValue.h"
+ #include <jni.h>
+ #include <string.h>
+ #include <iostream>
+ #include "Log.h"
+ #define LOG_TAG "JNI-JniBundleResource"
+ using namespace OIC::Service;
+ using namespace std;
+ namespace
+ {
+     jclass g_cls_RCSBundleInfo;
+     jfieldID g_field_mNativeHandle;
+ }
+ void initRCSJniBundleResource(JNIEnvWrapper *env)
+ {
+     auto clsJniBundleResource = env->FindClass(PACKAGE_NAME "/BundleResource");
+     g_field_mNativeHandle = env->GetFieldID(clsJniBundleResource, "mNativeHandle", "J");
+ }
+ JniBundleResource::JniBundleResource()
+ {
+ }
+ void JniBundleResource::initAttributes()
+ {
+ }
+ JniBundleResource::JniBundleResource(JNIEnv *env, jobject obj, jobject bundleResource,
+                                        string bundleId, jobjectArray attributes)
+ {
+     LOGD("Creating android resource, bundleId: %s", bundleId.c_str());
+     (void) obj;
+     m_env = env;
+     int stringCount = m_env->GetArrayLength(attributes);
+     LOGD("string count is %d", stringCount);
+     LOGD("Get java vm.");
+     int jvmAccess = m_env->GetJavaVM(&m_jvm);
+     for (int i = 0; i < stringCount; i++)
+     {
+         jstring str = (jstring) m_env->GetObjectArrayElement(attributes, i);
+         const char *rawString = m_env->GetStringUTFChars(str, 0);
+         string s(rawString, strlen(rawString));
+         JniBundleResource::setAttribute(s, "");
+         m_env->ReleaseStringUTFChars(str, rawString);
+         m_env->DeleteLocalRef(str);
+         LOGD("Deleting and releasing resources - JNI bundle resource");
+     }
+     m_bundleId = bundleId;
+     this->m_bundleResource = m_env->NewGlobalRef(bundleResource);
+     m_bundleResourceClass = (jclass) m_env->NewGlobalRef(m_env->GetObjectClass(bundleResource));
+     LOGD("Looking for setter.");
+     m_attributeSetRequestHandler = m_env->GetMethodID(m_bundleResourceClass,
+             "handleSetAttributesRequest",
+             "(Lorg/iotivity/service/resourcecontainer/RcsResourceAttributes;)V");
+     LOGD("Looking for getter.");
+     m_attributeGetRequestHandler = m_env->GetMethodID(m_bundleResourceClass,
+             "handleGetAttributesRequest",
+             "()Lorg/iotivity/service/resourcecontainer/RcsResourceAttributes;");
+     LOGD("Looking for onUpdatedInputResource.");
+     m_superclass = (jclass) m_env->NewGlobalRef(m_env->GetSuperclass(m_bundleResourceClass));
+     m_classClass = (jclass) m_env->NewGlobalRef(m_env->FindClass("java/lang/Class"));
+     m_vectorClazz = (jclass) m_env->NewGlobalRef(m_env->FindClass("java/util/Vector"));
+     if (m_env->ExceptionCheck()) {
+         m_env->ExceptionDescribe();
+     }
+     if (m_env->ExceptionCheck()) {
+        m_env->ExceptionDescribe();
+     }
+     if(m_classClass != NULL){
+         // Find the getName() method on the class object
+         jmethodID mid = env->GetMethodID(m_classClass, "getName", "()Ljava/lang/String;");
+         // Call the getName() to get a jstring object back
+         if(m_superclass != NULL){
+             jstring strObj = (jstring)env->CallObjectMethod(m_superclass, mid);
+             // Now get the c string from the java jstring object
+             const char* str = env->GetStringUTFChars(strObj, NULL);
+             LOGD("Name of super class is %s", str);
+             //check for softsensor resource
+             if(strcmp("org.iotivity.service.resourcecontainer.BundleSoftSensorResource", str) == 0){
+                m_onUpdatedInputResource = m_env->GetMethodID(m_bundleResourceClass,
+                        "onUpdatedInputResource", "(Ljava/lang/String;Ljava/util/Vector;)V");
+                if (m_env->ExceptionCheck()) {
+                    m_env->ExceptionDescribe();
+                }
+                LOGD("Looking up vector add method.");
+                if(m_vectorClazz != NULL){
+                    m_vectorAddMethod =  m_env->GetMethodID(m_vectorClazz, "add", "(Ljava/lang/Object;)Z");
+                    if (m_env->ExceptionCheck()) {
+                        m_env->ExceptionDescribe();
+                    }
+                }
+             }
+             LOGD("Deleting and releasing resources - JNIBundleResource 2");
+             m_env->ReleaseStringUTFChars(strObj, str);
+         }
+     }
+ }
+ JniBundleResource::~JniBundleResource()
+ {
+ }
+ RCSResourceAttributes::Value JniBundleResource::handleGetAttributeRequest(
+         const std::string &attributeName)
+ {
+     LOGD("handleGetAttributeRequest called2");
+     LOGD("Attaching thread now");
+     int attached = m_jvm->AttachCurrentThread(&m_env, NULL);
+     if(attached>0)
+     {
+         LOGE("Failed to attach thread to JavaVM");
+     }
+     else{
+         if(m_attributeGetRequestHandler != NULL){
+             jstring attrName = m_env->NewStringUTF(attributeName.c_str());
+             auto responseObj =  m_env->CallObjectMethod(m_bundleResource,
+                     m_attributeGetRequestHandler, attrName);
+             if (responseObj)
+             {
+                 LOGD("parsing attributes");
+                 RCSResourceAttributes attrs = toNativeAttributes(m_env, responseObj);
+                 LOGD("Received attributes %d", attrs.size());
+             }
+         }
+     }
+     return JniBundleResource::getAttribute(attributeName);
+ }
+ void JniBundleResource::handleSetAttributeRequest(const std::string &attributeName,
+                                       RCSResourceAttributes::Value &&value)
+ {
+     if(m_attributeSetRequestHandler != NULL){
+         jstring attrName = m_env->NewStringUTF(attributeName.c_str());
+         jstring val = m_env->NewStringUTF(value.toString().c_str());
+         //LOGD("handleSetAttributeRequest calling object method %d", &m_attributeSetRequestHandler);
+         m_env->CallObjectMethod(m_bundleResource, m_attributeSetRequestHandler, attrName, val);
+     }
+     JniBundleResource::setAttribute(attributeName, std::move(value));
+ }
 -RCSResourceAttributes & JniBundleResource::handleGetAttributesRequest()
++void JniBundleResource::handleSetAttributesRequest(const RCSResourceAttributes &attrs){
+     LOGD("handleSetAttributesRequest called %d", attrs.size());
+     //m_env->CallObjectMethod(m_bundleResource, m_attributeSetRequestHandler, attrName, val);
+     //JniBundleResource::setAttribute(attributeName, std::move(value));
+     if(m_attributeSetRequestHandler != NULL && m_bundleResource != NULL){
+         int attached = m_jvm->AttachCurrentThread(&m_env, NULL);
+         if(attached>0)
+         {
+             LOGE("Failed to attach thread to JavaVM");
+         }
+         else{
+             LOGD("Creating resource attributes for JNI.");
+             m_env->MonitorEnter(m_bundleResource);
+             auto jniRcsAttributes = newAttributesObject(m_env, attrs);
+             LOGD("jobject created. calling");
+             m_env->CallVoidMethod(m_bundleResource,
+                     m_attributeSetRequestHandler, jniRcsAttributes);
+             JniBundleResource::setAttributes(attrs);
+             m_env->MonitorExit(m_bundleResource);
+             m_jvm->DetachCurrentThread();
+         }
+     }
+ }
 -                RCSResourceAttributes attrs = toNativeAttributes(m_env, responseObj);
++RCSResourceAttributes JniBundleResource::handleGetAttributesRequest()
+ {
+     LOGD("handleGetAttributesRequest");
+     if(m_attributeGetRequestHandler != NULL && m_bundleResource != NULL){
+         LOGD("attaching thread");
+         int attached = m_jvm->AttachCurrentThread(&m_env, NULL);
+         if(attached>0)
+         {
+             LOGE("Failed to attach thread to JavaVM");
+         }
+         else{
+             LOGD("attached, calling get request handler");
+             auto responseObj =  m_env->CallObjectMethod(m_bundleResource,
+                     m_attributeGetRequestHandler);
+             if (responseObj)
+             {
+                 LOGD("parsing attributes");
+                 m_env->MonitorEnter(m_bundleResource);
+                 LOGD("to native attributes");
++                const RCSResourceAttributes attrs = toNativeAttributes(m_env, responseObj);
+                 LOGD("Received attributes %d", attrs.size());
+                 JniBundleResource::setAttributes(attrs, false);
+                 m_env->MonitorExit(m_bundleResource);
+             }
+             m_jvm->DetachCurrentThread();
+         }
+         LOGD("JniBundleResource::getAttributes().size() %d",
+                 JniBundleResource::getAttributes().size());
+     }
+     return JniBundleResource::getAttributes();
+ }
+ void JniBundleResource::executeLogic(){
+     // IS CALLED AT JAVA LAYER
+ }
+ void JniBundleResource::onUpdatedInputResource(const std::string attributeName,
+         std::vector<RCSResourceAttributes::Value> values){
+     LOGD("onUpdatedInputResource");
+     if(m_vectorClazz == NULL || m_classClass == NULL){
+         return;
+     }
+     int attached = m_jvm->AttachCurrentThread(&m_env, NULL);
+     jobject valueObj;
+     if(attached>0)
+     {
+         LOGE("Failed to attach thread to JavaVM");
+     }
+     else{
+         jobject obj = m_env->NewObject(m_vectorClazz,
+                 m_env->GetMethodID(m_vectorClazz, "<init>", "()V"));
+         LOGD("Looking up vector add method.");
+         jmethodID m_vectorAddMethod =  m_env->GetMethodID(m_vectorClazz, "add",
+                 "(Ljava/lang/Object;)Z");
+         if (m_env->ExceptionCheck()) {
+             m_env->ExceptionDescribe();
+         }
+         if(m_vectorAddMethod == NULL){
+             m_jvm->DetachCurrentThread();
+             return;
+         }
+         for (int n=0;n<values.size();n++)
+         {
+            valueObj  = newRCSValueObject(m_env, values[n]);
+            m_env->CallBooleanMethod(obj, m_vectorAddMethod, valueObj);
+         }
+         // Find the getName() method on the class object
+         jmethodID mid = m_env->GetMethodID(m_classClass, "getName",
+                 "()Ljava/lang/String;");
+         // Call the getName() to get a jstring object back
+         if(m_superclass == NULL || mid == NULL){
+             m_jvm->DetachCurrentThread();
+             return;
+         }
+         jstring strObj = (jstring)m_env->CallObjectMethod(m_superclass, mid);
+         // Now get the c string from the java jstring object
+         if(strObj == NULL){
+             m_jvm->DetachCurrentThread();
+             return;
+         }
+         const char* str = m_env->GetStringUTFChars(strObj, NULL);
+         LOGD("Name of super class is %s", str);
+         jstring attrName = m_env->NewStringUTF(attributeName.c_str());
+         //check for softsensor resource
+         if(strcmp("org.iotivity.service.resourcecontainer.BundleSoftSensorResource", str) == 0){
+             jmethodID m_onUpdatedInputResource = m_env->GetMethodID(m_bundleResourceClass,
+                     "onUpdatedInputResource", "(Ljava/lang/String;Ljava/util/Vector;)V");
+             if(m_onUpdatedInputResource != NULL){
+                 m_env->MonitorEnter(m_bundleResource);
+                 m_env->CallVoidMethod(m_bundleResource,
+                 m_onUpdatedInputResource, attrName, obj);
+                 m_env->MonitorExit(m_bundleResource);
+                 if (m_env->ExceptionCheck()) {
+                     m_env->ExceptionDescribe();
+                 }
+             }
+         }
+         LOGD("Deleting and releasing resources - onUpdatedInputResource");
+         m_env->DeleteLocalRef(attrName);
+         m_env->ReleaseStringUTFChars(strObj, str);
+         if (m_env->ExceptionCheck()) {
+                m_env->ExceptionDescribe();
+         }
+         m_jvm->DetachCurrentThread();
+     }
+     LOGD("JniBundleResource::getAttributes().size() %d", JniBundleResource::getAttributes().size());
+ }
+ JNIEXPORT void
+ JNICALL Java_org_iotivity_service_resourcecontainer_BundleResource_updateNativeInstance
+ (JNIEnv* env, jobject obj, jobject updates)
+ {
+     LOGD("updateNativeInstance");
+     BundleResource* JniBundleResource =
+             reinterpret_cast<BundleResource*>(env->GetLongField(obj, g_field_mNativeHandle));
+     RCSResourceAttributes attrs = toNativeAttributes(env, updates);
+     LOGD("Received attributes %d", attrs.size());
+     JniBundleResource->setAttributes(attrs, true);
+ }
index 0000000,6ff92ea..7530db2
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,120 +1,120 @@@
 -            virtual void handleSetAttributesRequest(RCSResourceAttributes &attrs);
+ //******************************************************************
+ //
+ // Copyright 2015 Samsung Electronics All Rights Reserved.
+ //
+ //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ //
+ // Licensed under the Apache License, Version 2.0 (the "License");
+ // you may not use this file except in compliance with the License.
+ // You may obtain a copy of the License at
+ //
+ //      http://www.apache.org/licenses/LICENSE-2.0
+ //
+ // Unless required by applicable law or agreed to in writing, software
+ // distributed under the License is distributed on an "AS IS" BASIS,
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ // See the License for the specific language governing permissions and
+ // limitations under the License.
+ //
+ //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ #ifndef JNI_BUNDLERESOURCE_H_
+ #define JNI_BUNDLERESOURCE_H_
+ #include <map>
+ #include <vector>
+ #include <string>
+ #include <jni.h>
+ #include "BundleResource.h"
+ #include "SoftSensorResource.h"
+ #include "ResourceContainerImpl.h"
+ #include <jni.h>
+ class JNIEnvWrapper;
+ void initRCSJniBundleResource(JNIEnvWrapper *);
+ using namespace std;
+ namespace OIC
+ {
+     namespace Service
+     {
+         class JniBundleResource: public SoftSensorResource
+         {
+         public:
+             JniBundleResource();
+             JniBundleResource(JNIEnv *env, jobject obj, jobject bundleResource, string bundleId,
+                     jobjectArray attributes);
+             virtual ~JniBundleResource();
+             void handleSetAttributeRequest(const std::string& key,
+                     RCSResourceAttributes::Value&&);
+             RCSResourceAttributes::Value handleGetAttributeRequest(const std::string& key);
 -            virtual RCSResourceAttributes& handleGetAttributesRequest();
++            virtual void handleSetAttributesRequest(const RCSResourceAttributes &attrs);
++            virtual RCSResourceAttributes handleGetAttributesRequest();
+             /**
+             * SoftSensor logic. Has to be provided by the soft sensor developer.
+             * This function will be executed if an input attribute is updated.
+             *
+             * @return void
+             */
+             virtual void executeLogic();
+             /**
+             * Callback from the client module in the container.
+             * This function will be called if input data from remote resources are updated.
+             * SoftSensor resource can get a vector of input data from multiple input resources
+             *    which have attributeName that softsensor needs to execute its logic.
+             *
+             * @param attributeName Attribute key of input data
+             *
+             * @param values Vector of input data value
+             *
+             * @return void
+             */
+             virtual void onUpdatedInputResource(const std::string attributeName,
+                                                 std::vector<RCSResourceAttributes::Value> values);
+             virtual void initAttributes();
+         private:
+             // needs to be a GlobalRef
+             jobject m_bundleResource;
+             jobjectArray m_attributes;
+             jclass m_bundleResourceClass;
+             jmethodID m_attributeSetRequestHandler;
+             jmethodID m_attributeGetRequestHandler;
+             jmethodID m_onUpdatedInputResource;
+             jclass m_vectorClazz;
+             jmethodID m_vectorAddMethod;
+             string m_bundleId;
+             jclass m_superclass;
+             jclass m_classClass;
+             JNIEnv *m_env;
+             JavaVM *m_jvm;
+             jfieldID g_field_mNativeHandle;
+         };
+     }
+ }
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+ /*
+  * Class:     org_iotivity_service_resourcecontainer_JniBundleResource
+  * Method:    updateNativeInstance
+  * Signature: (Lorg/iotivity/service/resourcecontainer/RcsResourceAttributes;)V
+  */
+ JNIEXPORT void JNICALL Java_org_iotivity_service_resourcecontainer_BundleResource_updateNativeInstance
+   (JNIEnv *, jobject, jobject);
+ #ifdef __cplusplus
+ }
+ #endif
+ #endif
@@@ -97,8 -95,10 +97,10 @@@ namespace OI
                  *
                  * @return void
                  */
 -                void setAttributes(RCSResourceAttributes &attrs);
 +                void setAttributes(const RCSResourceAttributes &attrs);
  
 -                void setAttributes(RCSResourceAttributes &attrs, bool notify);
++                void setAttributes(const RCSResourceAttributes &attrs, bool notify);
                  /**
                  * Return the value of an attribute
                  *
  
              public:
                  std::string m_bundleId;
 -                std::string m_name, m_uri, m_resourceType, m_address;
 +                std::string m_name, m_uri, m_resourceType, m_interface, m_address;
                  std::map< std::string,
-                     std::vector< std::map< std::string, std::string > > > m_mapResourceProperty;
+                 std::vector< std::map< std::string, std::string > > > m_mapResourceProperty;
  
              private:
 -                NotificationReceiver *m_pNotiReceiver;
 +                NotificationReceiverm_pNotiReceiver;
                  RCSResourceAttributes m_resourceAttributes;
 +                std::mutex m_resourceAttributes_mutex;
          };
      }
  }
@@@ -305,16 -357,13 +356,13 @@@ void onGet(const HeaderOptions &headerO
              std::cout << "Resource URI: " << rep.getUri() << std::endl;
  
              std::cout << "Payload: " << rep.getPayload() << std::endl;
+             std::cout << "On-off: " << rep.getValueToString("on-off") << std::endl;
  
              rep.getValue("on-off", mylight.m_on_off);
-             rep.getValue("dim", mylight.m_dim);
-             rep.getValue("color", mylight.m_color);
  
              std::cout << "\ton-off: " << mylight.m_on_off << std::endl;
-             std::cout << "\tcolor: " << mylight.m_color << std::endl;
-             std::cout << "\tdim: " << mylight.m_dim << std::endl;
  
 -            putLightRepresentation(curResource);
 +            postLightRepresentation(curResource);
          }
          else
          {
index bb4fccb,80970fa..8a0f06d
mode 100644,100755..100755
@@@ -2,10 -2,10 +2,10 @@@ apply plugin: 'com.android.application
  
  android {
      compileSdkVersion 21
 -    buildToolsVersion "21.1.2"
 +    buildToolsVersion "20.0.0"
  
      defaultConfig {
-         applicationId "org.iotivity.service.sample.server"
+         applicationId "org.iotivity.service.sample.resourcecontainer"
          minSdkVersion 21
          targetSdkVersion 21
          versionCode 1
@@@ -82,8 -82,16 +82,16 @@@ namespace OI
                  */
                  virtual const std::string &getVersion() = 0;
  
-                 RCSBundleInfo() { };
-                 virtual ~RCSBundleInfo() { };
+                 /**
+                 * API for getting the activation status of the bundle
+                 *
+                 * @return activation status of the bundle
+                 *
+                 */
+                 virtual bool isActivated() = 0;
 -                RCSBundleInfo();
 -                virtual ~RCSBundleInfo();
++                RCSBundleInfo(){};
++                virtual ~RCSBundleInfo(){};
              protected:
                  std::string m_ID, m_path, m_version;
  
@@@ -58,34 -55,30 +58,41 @@@ namespace OI
              return ret;
          }
  
 -        RCSResourceAttributes &BundleResource::getAttributes()
 +        const RCSResourceAttributes BundleResource::getAttributes()
 +        {
 +            std::lock_guard<std::mutex> lock(m_resourceAttributes_mutex);
 +            return RCSResourceAttributes(m_resourceAttributes);
 +        }
 +
 +        void BundleResource::setAttributes(const RCSResourceAttributes &attrs)
          {
 -            return m_resourceAttributes;
++            setAttributes(attrs, true);
+         }
 -        void BundleResource::setAttributes(RCSResourceAttributes &attrs, bool notify)
++        void BundleResource::setAttributes(const RCSResourceAttributes &attrs, bool notify)
+         {
 -            for (RCSResourceAttributes::iterator it = attrs.begin(); it != attrs.end(); ++it)
 -            {
 -                OC_LOG_V(INFO, "BUNDLE_RESOUCE", "set attribute \(%s)'",
 -                         std::string(it->key() + "\', with " + it->value().toString()).c_str());
 +            std::lock_guard<std::mutex> lock(m_resourceAttributes_mutex);
 +
 +            for (auto &it : m_resourceAttributes){
 +                OIC_LOG_V(INFO, CONTAINER_TAG, "set attribute \(%s)'",
 +                           std::string(it.key() + "\', with " + it.value().toString()).c_str());
  
 -                m_resourceAttributes[it->key()] = it->value();
 +                m_resourceAttributes[it.key()] = it.value();
              }
  
-             // asynchronous notification
-             auto notifyFunc = [](NotificationReceiver *notificationReceiver,
-                                     std::string uri)
-             {
-                 if (notificationReceiver){
-                     notificationReceiver->onNotificationReceived(uri);
-                 }
-             };
-             auto f = std::bind(notifyFunc, m_pNotiReceiver, m_uri);
-             boost::thread notifyThread(f);
 -            if (notify && m_pNotiReceiver){
 -                OC_LOG_V(INFO, "BUNDLE_RESOUCE", "Notifying receiver");
 -                m_pNotiReceiver->onNotificationReceived(m_uri);
++            if(notify){
++                // asynchronous notification
++                auto notifyFunc = [](NotificationReceiver *notificationReceiver,
++                                        std::string uri)
++                {
++                    if (notificationReceiver){
++                        notificationReceiver->onNotificationReceived(uri);
++                    }
++                };
++                auto f = std::bind(notifyFunc, m_pNotiReceiver, m_uri);
++                boost::thread notifyThread(f);
+             }
 -        }
  
 -        void BundleResource::setAttributes(RCSResourceAttributes &attrs)
 -        {
 -            setAttributes(attrs, false);
          }
  
          void BundleResource::setAttribute(const std::string &key,
@@@ -70,12 -71,15 +71,15 @@@ namespace OI
  
          bool Configuration::isHasInput(std::string &bundleId) const
          {
              try
              {
 -                OC_LOG_V(INFO, CONTAINER_TAG, "isHasInput: (%d) %s",m_mapisHasInput.at(bundleId), bundleId.c_str() );
++                OIC_LOG_V(INFO, CONTAINER_TAG, "isHasInput: (%d) %s",m_mapisHasInput.at(bundleId), bundleId.c_str() );
                  return m_mapisHasInput.at(bundleId);
              }
              catch (std::out_of_range &e)
              {
 -                OC_LOG_V(INFO, CONTAINER_TAG, "isHasInput out of range %s.", bundleId.c_str());
++                OIC_LOG_V(INFO, CONTAINER_TAG, "isHasInput out of range %s.", bundleId.c_str());
                  return false;
              }
          }
              }
          }
  
 -            OC_LOG_V(INFO, CONTAINER_TAG, "Loading resource configuration for %s %s!", bundleId.c_str(), resourceName.c_str());
+         void Configuration::getResourceConfiguration(std::string bundleId, std::string resourceName,
+                         resourceInfo *resourceInfoOut){
+             rapidxml::xml_node< char > *bundle;
+             rapidxml::xml_node< char > *resource;
+             rapidxml::xml_node< char > *item, *subItem, *subItem2;
+             string strBundleId;
+             string strKey, strValue;
 -                        OC_LOG_V(INFO, CONTAINER_TAG, "Comparing bundle id %s - %s !", strBundleId.c_str(), bundleId.c_str());
++            OIC_LOG_V(INFO, CONTAINER_TAG, "Loading resource configuration for %s %s!", bundleId.c_str(), resourceName.c_str());
+             if (m_loaded)
+             {
+                 try
+                 {
+                     // <bundle>
+                     for (bundle = m_xmlDoc.first_node()->first_node(BUNDLE_TAG); bundle; bundle =
+                              bundle->next_sibling())
+                     {
+                         // <id>
+                         strBundleId = bundle->first_node(BUNDLE_ID)->value();
 -                            OC_LOG_V(INFO, CONTAINER_TAG, "Inspecting");
++                        OIC_LOG_V(INFO, CONTAINER_TAG, "Comparing bundle id %s - %s !", strBundleId.c_str(), bundleId.c_str());
+                         if (!strBundleId.compare(bundleId))
+                         {
 -                                                OC_LOG_V(INFO, CONTAINER_TAG, "Bundle has input (%s)", strBundleId.c_str());
++                            OIC_LOG_V(INFO, CONTAINER_TAG, "Inspecting");
+                             // <resourceInfo>
+                             for (resource = bundle->first_node(OUTPUT_RESOURCES_TAG)->first_node(OUTPUT_RESOURCE_INFO);
+                                  resource; resource = resource->next_sibling())
+                             {
+                                 for (item = resource->first_node(); item; item =
+                                          item->next_sibling())
+                                 {
+                                     strKey = item->name();
+                                     strValue = item->value();
+                                     if (!strKey.compare(OUTPUT_RESOURCE_NAME))
+                                         resourceInfoOut->name = trim_both(strValue);
+                                     else if (!strKey.compare(OUTPUT_RESOURCE_URI))
+                                         resourceInfoOut->uri = trim_both(strValue);
+                                     else if (!strKey.compare(OUTPUT_RESOURCE_ADDR))
+                                         resourceInfoOut->address = trim_both(strValue);
+                                     else if (!strKey.compare(OUTPUT_RESOURCE_TYPE))
+                                         resourceInfoOut->resourceType = trim_both(strValue);
+                                     else
+                                     {
+                                         for (subItem = item->first_node(); subItem; subItem =
+                                                  subItem->next_sibling())
+                                         {
+                                             map< string, string > propertyMap;
+                                             strKey = subItem->name();
+                                             if (strKey.compare(INPUT_RESOURCE))
+                                             {
+                                                 m_mapisHasInput[strBundleId] = true;
 -                                                OC_LOG_V(INFO, CONTAINER_TAG, "key: %s, value %s", newStrKey.c_str(), newStrValue.c_str());
++                                                OIC_LOG_V(INFO, CONTAINER_TAG, "Bundle has input (%s)", strBundleId.c_str());
+                                             }
+                                             for (subItem2 = subItem->first_node(); subItem2;
+                                                  subItem2 = subItem2->next_sibling())
+                                             {
+                                                 string newStrKey = subItem2->name();
+                                                 string newStrValue = subItem2->value();
 -                    OC_LOG(ERROR, CONTAINER_TAG, "xml parsing failed !!");
 -                    OC_LOG_V(ERROR, CONTAINER_TAG, "Exception (%s)", e.what());
++                                                OIC_LOG_V(INFO, CONTAINER_TAG, "key: %s, value %s", newStrKey.c_str(), newStrValue.c_str());
+                                                 propertyMap[trim_both(newStrKey)] = trim_both(
+                                                                                         newStrValue);
+                                             }
+                                             resourceInfoOut->resourceProperty[trim_both(strKey)].push_back(
+                                                 propertyMap);
+                                         }
+                                     }
+                                 }
+                             }
+                         }
+                     }
+                 }
+                 catch (rapidxml::parse_error &e)
+                 {
 -                OC_LOG(INFO, CONTAINER_TAG, "config is not loaded yet !!");
++                    OIC_LOG(ERROR, CONTAINER_TAG, "xml parsing failed !!");
++                    OIC_LOG_V(ERROR, CONTAINER_TAG, "Exception (%s)", e.what());
+                 }
+             }
+             else{
++                OIC_LOG(INFO, CONTAINER_TAG, "config is not loaded yet !!");
+             }
+         }
          void Configuration::getResourceConfiguration(std::string bundleId,
                  std::vector< resourceInfo > *configOutput)
          {
  
              string strBundleId;
              string strKey, strValue;
 -            OC_LOG(INFO, CONTAINER_TAG, "Loading resource configuration!");
++            OIC_LOG(INFO, CONTAINER_TAG, "Loading resource configuration!");
  
              if (m_loaded)
              {
                          // <id>
                          strBundleId = bundle->first_node(BUNDLE_ID)->value();
  
 -                        OC_LOG_V(INFO, CONTAINER_TAG, "Comparing bundle ids %s - %s !", strBundleId.c_str(), bundleId.c_str());
++                        OIC_LOG_V(INFO, CONTAINER_TAG, "Comparing bundle ids %s - %s !", strBundleId.c_str(), bundleId.c_str());
                          if (!strBundleId.compare(bundleId))
                          {
 -                            OC_LOG_V(INFO, CONTAINER_TAG, "Inspecting");
++                            OIC_LOG_V(INFO, CONTAINER_TAG, "Inspecting");
                              // <resourceInfo>
                              for (resource = bundle->first_node(OUTPUT_RESOURCES_TAG)->first_node(OUTPUT_RESOURCE_INFO);
                                   resource; resource = resource->next_sibling())
                                              if (strKey.compare(INPUT_RESOURCE))
                                              {
                                                  m_mapisHasInput[strBundleId] = true;
 -                                                OC_LOG_V(INFO, CONTAINER_TAG, "Bundle has input (%s)", strBundleId.c_str());
++                                                OIC_LOG_V(INFO, CONTAINER_TAG, "Bundle has input (%s)", strBundleId.c_str());
                                              }
  
                                              for (subItem2 = subItem->first_node(); subItem2;
                                              {
                                                  string newStrKey = subItem2->name();
                                                  string newStrValue = subItem2->value();
 -                                                OC_LOG_V(INFO, CONTAINER_TAG, "key: %s, value %s", newStrKey.c_str(), newStrValue.c_str());
++                                                OIC_LOG_V(INFO, CONTAINER_TAG, "key: %s, value %s", newStrKey.c_str(), newStrValue.c_str());
  
                                                  propertyMap[trim_both(newStrKey)] = trim_both(
                                                                                          newStrValue);
                  }
                  catch (rapidxml::parse_error &e)
                  {
 -                    OC_LOG(ERROR, CONTAINER_TAG, "xml parsing failed !!");
 -                    OC_LOG_V(ERROR, CONTAINER_TAG, "Exception (%s)", e.what());
 +                    OIC_LOG(ERROR, CONTAINER_TAG, "xml parsing failed !!");
 +                    OIC_LOG_V(ERROR, CONTAINER_TAG, "Exception (%s)", e.what());
                  }
              }
 -                OC_LOG(INFO, CONTAINER_TAG, "config is not loaded yet !!");
+             else{
++                OIC_LOG(INFO, CONTAINER_TAG, "config is not loaded yet !!");
+             }
          }
  
          void Configuration::getConfigDocument(std::string pathConfigFile)
@@@ -52,6 -52,8 +52,8 @@@ void DiscoverResourceUnit::startDiscove
          return;
      }
  
 -    OC_LOG_V(DEBUG, DISCOVER_TAG, "Start discover %s", info.resourceUri.c_str());
++    OIC_LOG_V(DEBUG, DISCOVER_TAG, "Start discover %s", info.resourceUri.c_str());
      m_Uri = info.resourceUri;
      m_ResourceType = info.resourceType;
      m_AttrubuteName = info.attributeName;
@@@ -86,14 -88,19 +88,19 @@@ void DiscoverResourceUnit::discoverdCB(
  {
      if (remoteObject && !isAlreadyDiscoveredResource(remoteObject))
      {
-         RemoteResourceUnit::Ptr newDiscoveredResource =
-             RemoteResourceUnit::createRemoteResourceInfo(remoteObject, pUpdatedCBFromServer);
 -        OC_LOG_V(DEBUG, DISCOVER_TAG, "Discovered - uri: %s", uri.c_str());
++        OIC_LOG_V(DEBUG, DISCOVER_TAG, "Discovered - uri: %s", uri.c_str());
+         if (uri.empty() || uri.compare(remoteObject->getUri()) == 0){
+             RemoteResourceUnit::Ptr newDiscoveredResource =
+                        RemoteResourceUnit::createRemoteResourceInfo(remoteObject,
+                                pUpdatedCBFromServer);
+                 m_vecRemoteResource.push_back(newDiscoveredResource);
+                 newDiscoveredResource->startMonitoring();
+                 newDiscoveredResource->startCaching();
  
-         if (uri.empty() || uri.compare(remoteObject->getUri()) == 0)
-         {
-             m_vecRemoteResource.push_back(newDiscoveredResource);
-             newDiscoveredResource->startMonitoring();
-             newDiscoveredResource->startCaching();
 -            OC_LOG_V(DEBUG, DISCOVER_TAG, "Created remote resource unit");
++            OIC_LOG_V(DEBUG, DISCOVER_TAG, "Created remote resource unit");
+         }
+         else{
 -            OC_LOG_V(DEBUG, DISCOVER_TAG, "URI is not matching - uri: %s", uri.c_str());
++            OIC_LOG_V(DEBUG, DISCOVER_TAG, "URI is not matching - uri: %s", uri.c_str());
          }
      }
      else
@@@ -84,9 -84,9 +84,9 @@@ RCSResourceAttributes::Value JavaBundle
  
      if (envStat == JNI_EDETACHED)
      {
-         if (vm->AttachCurrentThread((void **) &env, NULL) != 0)
+         if (vm->AttachCurrentThread(&env, NULL) != 0)
          {
 -            OC_LOG_V(ERROR, CONTAINER_TAG,
 +            OIC_LOG_V(ERROR, CONTAINER_TAG,
                      "[JavaBundleResource::handleGetAttributeRequest] Failed to attach ");
          }
      }
@@@ -36,11 -39,21 +39,21 @@@ RemoteResourceUnit::~RemoteResourceUnit
      {
          if(remoteObject->isCaching())
          {
-             remoteObject->stopCaching();
+             try{
+                 remoteObject->stopCaching();
+             }
+             catch(std::exception &e){
 -                OC_LOG_V(ERROR, CONTAINER_TAG, "%s", e.what());
++                OIC_LOG_V(ERROR, CONTAINER_TAG, "%s", e.what());
+             }
          }
          if(remoteObject->isMonitoring())
          {
-             remoteObject->stopMonitoring();
+             try{
+                 remoteObject->stopMonitoring();
+             }
+             catch(std::exception &e){
 -                OC_LOG_V(ERROR, CONTAINER_TAG, "%s", e.what());
++                OIC_LOG_V(ERROR, CONTAINER_TAG, "%s", e.what());
+             }
          }
      }
  }
@@@ -120,6 -120,7 +120,7 @@@ namespace OI
                  // wait for bundles to be activated
              }
              activationLock.unlock();
 -            OC_LOG(INFO, CONTAINER_TAG, "Resource container started.");
++            OIC_LOG(INFO, CONTAINER_TAG, "Resource container started.");
          }
  
          void ResourceContainerImpl::stopContainer()
          {
              string strUri = resource->m_uri;
              string strResourceType = resource->m_resourceType;
 +            string strInterface = resource->m_interface;
              RCSResourceObject::Ptr server = nullptr;
 +            int ret = EINVAL;
  
 -            OC_LOG_V(INFO, CONTAINER_TAG, "Registration of resource (%s)" ,
 +            OIC_LOG_V(INFO, CONTAINER_TAG, "Registration of resource (%s)" ,
-                      std::string(strUri + ", " + strResourceType).c_str());
+                      std::string(strUri + ", " + strResourceType + "," +
+                              resource->m_bundleId).c_str());
  
              registrationLock.lock();
              if (m_mapResources.find(strUri) == m_mapResources.end())
                          std::bind(&ResourceContainerImpl::setRequestHandler, this,
                                    std::placeholders::_1, std::placeholders::_2));
  
-                              std::string(strUri + ", " +
-                                          strResourceType).c_str());
 +                    OIC_LOG_V(INFO, CONTAINER_TAG, "Registration finished (%s)",
++                            std::string(strUri + ", " +
++                                                          strResourceType).c_str());
  
 -
 -                    if (m_config->isHasInput(resource->m_bundleId))
 +                    if (m_config && m_config->isHasInput(resource->m_bundleId))
                      {
 -                        OC_LOG_V(INFO, CONTAINER_TAG, "Resource has input (%s)",
++                        OIC_LOG_V(INFO, CONTAINER_TAG, "Resource has input (%s)",
+                               std::string(strUri + ", " +
+                               strResourceType).c_str());
                          discoverInputResource(strUri);
                      }
 -                        OC_LOG_V(INFO, CONTAINER_TAG, "Resource has no input (%s)",
+                     else{
 -                    OC_LOG_V(INFO, CONTAINER_TAG, "Registration finished (%s)",
++                        OIC_LOG_V(INFO, CONTAINER_TAG, "Resource has no input (%s)",
+                                  std::string(strUri + ", " +
+                                  strResourceType).c_str());
+                     }
++                    OIC_LOG_V(INFO, CONTAINER_TAG, "Registration finished (%s)",
+                                                 std::string(strUri + ", " +
+                                                             strResourceType).c_str());
  
                      // to get notified if bundle resource attributes are updated
 -                    resource->registerObserver((NotificationReceiver *) this);
 +                    resource->registerObserver(this);
 +                    ret = 0;
                  }
              }
              else
                       std::string(resource->m_uri + ", " +
                                   resource->m_resourceType).c_str());
  
 -            if (m_config->isHasInput(resource->m_bundleId))
 +            if (m_config && m_config->isHasInput(resource->m_bundleId))
              {
 -                OC_LOG_V(INFO, CONTAINER_TAG, "Calling undiscover (%s)",
++                OIC_LOG_V(INFO, CONTAINER_TAG, "Calling undiscover (%s)",
+                                      std::string(resource->m_uri + ", " +
+                                                  resource->m_resourceType).c_str());
                  undiscoverInputResource(strUri);
              }
  
              if (m_mapServers.find(strUri) != m_mapServers.end())
              {
 -                OC_LOG_V(INFO, CONTAINER_TAG, "Resetting server (%s)",
++                OIC_LOG_V(INFO, CONTAINER_TAG, "Resetting server (%s)",
+                                      std::string(resource->m_uri + ", " +
+                                                  resource->m_resourceType).c_str());
                  m_mapServers[strUri].reset();
  
                  m_mapResources.erase(m_mapResources.find(strUri));
 -                OC_LOG_V(INFO, CONTAINER_TAG, "Remove bundle resource (%s)",
++                OIC_LOG_V(INFO, CONTAINER_TAG, "Remove bundle resource (%s)",
+                                      std::string(resource->m_uri + ", " +
+                                                  resource->m_resourceType).c_str());
                  m_mapBundleResources[resource->m_bundleId].remove(strUri);
              }
          }
              {
                  m_config->getResourceConfiguration(bundleId, configOutput);
              }
 -                OC_LOG_V(DEBUG, CONTAINER_TAG, "no config present ");
+             else{
++                OIC_LOG_V(DEBUG, CONTAINER_TAG, "no config present ");
+             }
          }
  
          RCSGetResponse ResourceContainerImpl::getRequestHandler(const RCSRequest &request,
          {
              RCSResourceAttributes attr;
              std::string strResourceUri = request.getResourceUri();
 -            OC_LOG_V(INFO, CONTAINER_TAG, "Container get request for %s",strResourceUri.c_str());
++            OIC_LOG_V(INFO, CONTAINER_TAG, "Container get request for %s",strResourceUri.c_str());
  
              if (m_mapServers.find(strResourceUri) != m_mapServers.end()
                  && m_mapResources.find(strResourceUri) != m_mapResources.end())
  
                  }
              }
 -            OC_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, %d attributes",strResourceUri.c_str(), attr.size());
  
              return RCSGetResponse::create(std::move(attr), 200);
          }
              std::list<std::string> lstAttributes;
              std::string strResourceUri = request.getResourceUri();
  
 -            OC_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, %d attributes",strResourceUri.c_str(), attributes.size());
              if (m_mapServers.find(strResourceUri) != m_mapServers.end()
                  && m_mapResources.find(strResourceUri) != m_mapResources.end())
              {
                              }
                          }
  
 -                        OC_LOG_V(INFO, CONTAINER_TAG, "Calling handleSetAttributeRequest");
++                        OIC_LOG_V(INFO, CONTAINER_TAG, "Calling handleSetAttributeRequest");
                          m_mapResources[strResourceUri]->handleSetAttributesRequest(attr);
                      };
                      boost::thread setThread(setFunction);
  
          void ResourceContainerImpl::startBundle(const std::string &bundleId)
          {
 -            OC_LOG_V(INFO, CONTAINER_TAG, "startBundle %s",bundleId.c_str());
++            OIC_LOG_V(INFO, CONTAINER_TAG, "startBundle %s",bundleId.c_str());
              if (m_bundles.find(bundleId) != m_bundles.end())
              {
                  if (!m_bundles[bundleId]->isActivated())
  
          void ResourceContainerImpl::stopBundle(const std::string &bundleId)
          {
 -            OC_LOG_V(INFO, CONTAINER_TAG, "stopBundle %s",bundleId.c_str());
++            OIC_LOG_V(INFO, CONTAINER_TAG, "stopBundle %s",bundleId.c_str());
              if (m_bundles.find(bundleId) != m_bundles.end())
              {
                  if (m_bundles[bundleId]->isActivated())
  
          void ResourceContainerImpl::removeBundle(const std::string &bundleId)
          {
 -            OC_LOG_V(INFO, CONTAINER_TAG, "removeBundle %s",bundleId.c_str());
++            OIC_LOG_V(INFO, CONTAINER_TAG, "removeBundle %s",bundleId.c_str());
              if (m_bundles.find(bundleId) != m_bundles.end())
              {
                  BundleInfoInternal *bundleInfo = m_bundles[bundleId];
              }
              else
              {
 -                OC_LOG_V(ERROR, CONTAINER_TAG, "Bundle with ID \'(%s)",
 +                OIC_LOG_V(ERROR, CONTAINER_TAG, "Bundle with ID \'(%s)",
-                          std::string(bundleId + "\' is not registered.").c_str());
+                          std::string(bundleId + "\' is not ced.").c_str());
              }
          }
  
          std::list<std::unique_ptr<RCSBundleInfo>> ResourceContainerImpl::listBundles()
          {
 -            OC_LOG_V(INFO, CONTAINER_TAG,
++            OIC_LOG_V(INFO, CONTAINER_TAG,
+                                  "list bundles (%d)", m_bundles.size());
              std::list<std::unique_ptr<RCSBundleInfo> > ret;
              for (std::map< std::string, BundleInfoInternal * >::iterator it = m_bundles.begin();
                   it != m_bundles.end(); ++it)
          void ResourceContainerImpl::removeResourceConfig(const std::string &bundleId,
                  const std::string &resourceUri)
          {
 -            OC_LOG_V(INFO, CONTAINER_TAG, "removeResourceConfig %s, %s",bundleId.c_str(), resourceUri.c_str());
++            OIC_LOG_V(INFO, CONTAINER_TAG, "removeResourceConfig %s, %s",bundleId.c_str(), resourceUri.c_str());
              if (m_bundles.find(bundleId) != m_bundles.end())
              {
-                 if (!m_bundles[bundleId]->getJavaBundle())
+                 if (m_bundles[bundleId]->getSoBundle())
                  {
                      removeSoBundleResource(bundleId, resourceUri);
                  }
  
          std::list< string > ResourceContainerImpl::listBundleResources(const std::string &bundleId)
          {
 -            OC_LOG_V(INFO, CONTAINER_TAG, "listBundleResources %s",bundleId.c_str());
++            OIC_LOG_V(INFO, CONTAINER_TAG, "listBundleResources %s",bundleId.c_str());
              std::list < string > ret;
  
              if (m_mapBundleResources.find(bundleId) != m_mapBundleResources.end())
  
          void ResourceContainerImpl::registerSoBundle(RCSBundleInfo *bundleInfo)
          {
 -            OC_LOG_V(DEBUG, CONTAINER_TAG, "Register SO bundle");
++            OIC_LOG_V(DEBUG, CONTAINER_TAG, "Register SO bundle");
              const char *error;
  
              activator_t *bundleActivator = NULL;
              BundleInfoInternal *bundleInfoInternal = (BundleInfoInternal *) bundleInfo;
              void *bundleHandle = NULL;
              bundleHandle = dlopen(bundleInfo->getPath().c_str(), RTLD_LAZY);
 -              OC_LOG_V(ERROR, CONTAINER_TAG, "Error while loading .so bundle: (%s)", error);
+             if ((error = dlerror()) != NULL)
+             {
++              OIC_LOG_V(ERROR, CONTAINER_TAG, "Error while loading .so bundle: (%s)", error);
+             }
  
              if (bundleHandle != NULL)
              {
 -                OC_LOG_V(DEBUG, CONTAINER_TAG, "Activator name %s", bundleInfoInternal->getActivatorName().c_str());
++                OIC_LOG_V(DEBUG, CONTAINER_TAG, "Activator name %s", bundleInfoInternal->getActivatorName().c_str());
                  bundleActivator =
                      (activator_t *) dlsym(bundleHandle,
                                            ("" + bundleInfoInternal->getActivatorName()
                                             + "_externalActivateBundle").c_str());
 -                  OC_LOG_V(ERROR, CONTAINER_TAG, "Error while loading .so bundle: (%s)", error);
+                 if ((error = dlerror()) != NULL)
+                 {
 -                  OC_LOG_V(DEBUG, CONTAINER_TAG, "Looked up %s", ("" + bundleInfoInternal->getActivatorName()
++                  OIC_LOG_V(ERROR, CONTAINER_TAG, "Error while loading .so bundle: (%s)", error);
+                 }
+                 else{
++                  OIC_LOG_V(DEBUG, CONTAINER_TAG, "Looked up %s", ("" + bundleInfoInternal->getActivatorName()
+                           + "_externalActivateBundle").c_str());
+                 }
                  bundleDeactivator =
                      (deactivator_t *) dlsym(bundleHandle,
                                              ("" + bundleInfoInternal->getActivatorName()
                                               + "_externalDeactivateBundle").c_str());
 -                  OC_LOG_V(ERROR, CONTAINER_TAG, "Error while loading .so bundle: (%s)", error);
+                 if ((error = dlerror()) != NULL)
+                 {
 -                  OC_LOG_V(DEBUG, CONTAINER_TAG, "Looked up %s", ("" + bundleInfoInternal->getActivatorName()
++                  OIC_LOG_V(ERROR, CONTAINER_TAG, "Error while loading .so bundle: (%s)", error);
+                 }
+                 else{
++                  OIC_LOG_V(DEBUG, CONTAINER_TAG, "Looked up %s", ("" + bundleInfoInternal->getActivatorName()
+                           + "_externalDeactivateBundle").c_str());
+                 }
                  resourceCreator =
                      (resourceCreator_t *) dlsym(bundleHandle,
                                                  ("" + bundleInfoInternal->getActivatorName()
                                                   + "_externalCreateResource").c_str());
 -                  OC_LOG_V(ERROR, CONTAINER_TAG, "Error while loading .so bundle: (%s)", error);
+                 if ((error = dlerror()) != NULL)
+                 {
 -                  OC_LOG_V(DEBUG, CONTAINER_TAG, "Looked up %s", ("" + bundleInfoInternal->getActivatorName()
++                  OIC_LOG_V(ERROR, CONTAINER_TAG, "Error while loading .so bundle: (%s)", error);
+                 }
+                 else{
++                  OIC_LOG_V(DEBUG, CONTAINER_TAG, "Looked up %s", ("" + bundleInfoInternal->getActivatorName()
+                           + "_externalCreateResource").c_str());
+                 }
                  resourceDestroyer =
                      (resourceDestroyer_t *) dlsym(bundleHandle,
                                                    ("" + bundleInfoInternal->getActivatorName()
                                                     + "_externalDestroyResource").c_str());
 -                  OC_LOG_V(ERROR, CONTAINER_TAG, "Error while loading .so bundle: (%s)", error);
+                 if ((error = dlerror()) != NULL)
+                 {
 -                  OC_LOG_V(DEBUG, CONTAINER_TAG, "Looked up %s", ("" + bundleInfoInternal->getActivatorName()
++                  OIC_LOG_V(ERROR, CONTAINER_TAG, "Error while loading .so bundle: (%s)", error);
+                 }
+                 else{
++                  OIC_LOG_V(DEBUG, CONTAINER_TAG, "Looked up %s", ("" + bundleInfoInternal->getActivatorName()
+                           + "_externalDestroyResource").c_str());
+                 }
  
  
                  if ((error = dlerror()) != NULL)
              {
                  if ((error = dlerror()) != NULL)
                  {
 -                    OC_LOG_V(ERROR, CONTAINER_TAG, "Error while loading .so bundle: (%s)", error);
 +                    OIC_LOG_V(ERROR, CONTAINER_TAG, "Error : (%s)", error);
                  }
              }
 -            OC_LOG_V(DEBUG, CONTAINER_TAG, "Register SO bundle finished");
++            OIC_LOG_V(DEBUG, CONTAINER_TAG, "Register SO bundle finished");
+         }
+         void ResourceContainerImpl::registerExtBundle(RCSBundleInfo *bundleInfo){
 -            OC_LOG_V(INFO, CONTAINER_TAG, "Registering ext bundle (%s)",
++            OIC_LOG_V(INFO, CONTAINER_TAG, "Registering ext bundle (%s)",
+                                  std::string(bundleInfo->getID()).c_str());
 -            OC_LOG_V(INFO, CONTAINER_TAG, "Activator name (%s)",
++            OIC_LOG_V(INFO, CONTAINER_TAG, "Activator name (%s)",
+                                              std::string(bundleInfo->getActivatorName()).c_str());
+             m_bundles[bundleInfo->getID()] = ((BundleInfoInternal *)bundleInfo);
+             // in this case at least the resource configuration needs to be loaded
+             // in order to mark potential input resources for soft sensors
+             std::vector< resourceInfo > temp;
 -            OC_LOG_V(INFO, CONTAINER_TAG, "Loading resource config(%s)",
++            OIC_LOG_V(INFO, CONTAINER_TAG, "Loading resource config(%s)",
+                                                          std::string(bundleInfo->getID()).c_str());
+             getResourceConfiguration(bundleInfo->getID(),
+                             &temp);
 -            OC_LOG(INFO, CONTAINER_TAG, "Bundle registered");
++            OIC_LOG(INFO, CONTAINER_TAG, "Bundle registered");
          }
  
          void ResourceContainerImpl::activateSoBundle(const std::string &bundleId)
              auto foundDiscoverResource = m_mapDiscoverResourceUnits.find(outputResourceUri);
              if (foundDiscoverResource != m_mapDiscoverResourceUnits.end())
              {
 -                OC_LOG(DEBUG, CONTAINER_TAG, "Erase discover resource.");
++                OIC_LOG(DEBUG, CONTAINER_TAG, "Erase discover resource.");
                  m_mapDiscoverResourceUnits.erase(foundDiscoverResource);
 -                OC_LOG(DEBUG, CONTAINER_TAG, "Erase discover resource done.");
++                OIC_LOG(DEBUG, CONTAINER_TAG, "Erase discover resource done.");
              }
          }
  
          void ResourceContainerImpl::discoverInputResource(const std::string &outputResourceUri)
          {
 -            OC_LOG_V(DEBUG, CONTAINER_TAG, "Discover input resource %s", outputResourceUri.c_str());
++            OIC_LOG_V(DEBUG, CONTAINER_TAG, "Discover input resource %s", outputResourceUri.c_str());
              auto foundOutputResource = m_mapResources.find(outputResourceUri);
-             auto resourceProperty = foundOutputResource->second->m_mapResourceProperty;
+            // auto resourceProperty = foundOutputResource->second->m_mapResourceProperty;
+             resourceInfo info;
+             m_config->getResourceConfiguration(foundOutputResource->second->m_bundleId,
+                     foundOutputResource->second->m_name, &info);
+             map< string, vector< map< string, string > > > resourceProperty = info.resourceProperty;
  
              try
              {
              }
              catch (std::out_of_range &e)
              {
 -                OC_LOG_V(DEBUG, CONTAINER_TAG, "No input resource %s", outputResourceUri.c_str());
++                OIC_LOG_V(DEBUG, CONTAINER_TAG, "No input resource %s", outputResourceUri.c_str());
                  return;
              }
  
                          std::string type = makeValue(INPUT_RESOURCE_TYPE);
                          std::string attributeName = makeValue(INPUT_RESOURCE_ATTRIBUTENAME);
  
 -                        OC_LOG_V(DEBUG, CONTAINER_TAG, "Start discovery: %s, %s, %s", uri.c_str(),
++                        OIC_LOG_V(DEBUG, CONTAINER_TAG, "Start discovery: %s, %s, %s", uri.c_str(),
+                                 type.c_str(), attributeName.c_str());
                          DiscoverResourceUnit::Ptr newDiscoverUnit = std::make_shared
                                  < DiscoverResourceUnit > (outputResourceUri);
                          newDiscoverUnit->startDiscover(
  
              if (bundleActivatorClass == NULL)
              {
 -                OC_LOG_V(ERROR, CONTAINER_TAG, "Cannot register bundle (%s)",
 +                OIC_LOG_V(ERROR, CONTAINER_TAG, "Cannot register bundle (%s)",
                           std::string( bundleInfoInternal->getID()
-                                       + " bundle activator(" + bundleInfoInternal->getActivatorName()
+                                       + " bundle activator(" +
+                                       bundleInfoInternal->getActivatorName()
                                        + ") not found ").c_str());
                  return;
              }
              m_bundles[bundleInfo->getID()] = ((BundleInfoInternal *)bundleInfo);
  
  
 -            OC_LOG(INFO, CONTAINER_TAG, "Bundle registered");
 +            OIC_LOG(INFO, CONTAINER_TAG, "Bundle registered");
          }
  
          void ResourceContainerImpl::activateJavaBundle(string bundleId)
          {
 -            OC_LOG(INFO, CONTAINER_TAG, "Activating java bundle");
 +            OIC_LOG(INFO, CONTAINER_TAG, "Activating java bundle");
  
              JavaVM *vm = getJavaVM(bundleId);
              BundleInfoInternal *bundleInfoInternal = (BundleInfoInternal *) m_bundles[bundleId];
@@@ -202,20 -132,14 +202,26 @@@ namespace OI
          {
              SCOPE_LOG_F(DEBUG, TAG);
  
-             stopCaching();
-             stopMonitoring();
+             try{
+                 stopCaching();
+                 stopMonitoring();
+             }
+             catch(std::exception &e){
 -                OC_LOG_V(ERROR, TAG, "%s", e.what());
++                OIC_LOG_V(ERROR, TAG, "%s", e.what());
++            }
++
 +        }
 +
 +        RCSRemoteResourceObject::Ptr RCSRemoteResourceObject::fromOCResource(
 +                std::shared_ptr< OC::OCResource > ocResource)
 +        {
 +            if (!ocResource)
 +            {
 +                throw RCSInvalidParameterException("the oc resource must not be nullptr.");
              }
  
 +            return std::make_shared< RCSRemoteResourceObject >(
 +                    PrimitiveResource::create(ocResource));
          }
  
          bool RCSRemoteResourceObject::isMonitoring() const
@@@ -628,26 -477,16 +628,25 @@@ namespace OI
          }
  
          OCEntityHandlerResult RCSResourceObject::handleRequestGet(
 -                const std::shared_ptr< OC::OCResourceRequest >& request)
 +                const RCSRequest& request)
          {
 -            assert(request != nullptr);
 +            if (!findInterfaceHandler(request.getInterface()).isGetSupported())
 +            {
 +                return OC_EH_ERROR;
 +            }
 +
 +            auto attrs = getAttributesFromOCRequest(request.getOCRequest());
 +            auto response = invokeHandler(shared_from_this(), attrs, request.getOCRequest(),
 +                    m_getRequestHandler);
 +
 +            if (response.isSeparate()) return OC_EH_SLOW;
  
 -            auto attrs = getAttributesFromOCRequest(request);
 -            return sendResponse(*this, request, invokeHandler(attrs, request, m_getRequestHandler));
 +            return sendResponse(request, response,
 +                         findInterfaceHandler(request.getInterface()).getGetResponseBuilder());
          }
  
 -        bool RCSResourceObject::applyAcceptanceMethod(const RCSSetResponse& response,
 -                const RCSResourceAttributes& requstAttrs)
 +        RCSResourceAttributes RCSResourceObject::applyAcceptanceMethod(
 +                const RCSSetResponse& response, const RCSResourceAttributes& requestAttrs)
          {
              auto requestHandler = response.getHandler();