Refactoring the android api for resorce-encapsulation.
authorcoderhyme <jhyo.kim@samsung.com>
Fri, 18 Sep 2015 09:50:35 +0000 (02:50 -0700)
committerMadan Lanka <lanka.madan@samsung.com>
Sat, 19 Sep 2015 05:41:20 +0000 (05:41 +0000)
SConscript is added to conform to scons build.
JNI files are renamed to conform to the style.
JNI files are restructureed to make folder hierarchy simple.
android apis are refined to follow java convention.
Comments for apis are updated.

Change-Id: I1bef70c9468d767b1694f29165704a70370bbe90
Signed-off-by: coderhyme <jhyo.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2703
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
127 files changed:
service/resource-encapsulation/SConscript
service/resource-encapsulation/android/.gitignore [new file with mode: 0644]
service/resource-encapsulation/android/SConscript [new file with mode: 0644]
service/resource-encapsulation/android/android_api.iml [new file with mode: 0644]
service/resource-encapsulation/android/build.gradle [new file with mode: 0644]
service/resource-encapsulation/android/gradle.properties [new file with mode: 0644]
service/resource-encapsulation/android/gradlew [new file with mode: 0644]
service/resource-encapsulation/android/gradlew.bat [new file with mode: 0644]
service/resource-encapsulation/android/service/base.iml [new file with mode: 0644]
service/resource-encapsulation/android/service/build.gradle [new file with mode: 0644]
service/resource-encapsulation/android/service/proguard-rules.pro [new file with mode: 0644]
service/resource-encapsulation/android/service/src/androidTest/java/org/iotivity/service/RemoteResourceObjectTest.java [new file with mode: 0644]
service/resource-encapsulation/android/service/src/androidTest/java/org/iotivity/service/ResourceObjectBuilderTest.java [new file with mode: 0644]
service/resource-encapsulation/android/service/src/androidTest/java/org/iotivity/service/ResourceObjectTest.java [new file with mode: 0644]
service/resource-encapsulation/android/service/src/androidTest/java/org/iotivity/service/TestBase.java [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/AndroidManifest.xml [moved from service/resource-encapsulation/sdk/java/AndroidManifest.xml with 100% similarity]
service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/RcsDestroyedObjectException.java [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/RcsException.java [moved from service/resource-encapsulation/sdk/java/src/org/iotivity/ResourceEncapsulation/common/RCSException.java with 74% similarity]
service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/RcsIllegalStateException.java [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/RcsObject.java [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/RcsPlatformException.java [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/RcsResourceAttributes.java [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/RcsValue.java [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/client/RcsAddress.java [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/client/RcsDiscoveryManager.java [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/client/RcsRemoteResourceObject.java [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsBundleInfo.java [moved from service/resource-encapsulation/sdk/java/src/org/iotivity/ResourceEncapsulation/server/RCSBundleInfo.java with 54% similarity]
service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsGetResponse.java [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsLockedAttributes.java [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsRequest.java [moved from service/resource-encapsulation/sdk/java/src/org/iotivity/ResourceEncapsulation/server/RCSRequest.java with 75% similarity]
service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsResourceContainer.java [moved from service/resource-encapsulation/sdk/java/src/org/iotivity/ResourceEncapsulation/server/RCSResourceContainer.java with 65% similarity]
service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsResourceObject.java [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsResponse.java [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsSetResponse.java [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsUnlockedException.java [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/jni/Android.mk [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/jni/Application.mk [moved from service/resource-encapsulation/sdk/java/jni/Application.mk with 100% similarity]
service/resource-encapsulation/android/service/src/main/jni/JniMain.cpp [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/jni/JniRcsBundleInfo.cpp [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/jni/JniRcsBundleInfo.h [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/jni/JniRcsDiscoveryManager.cpp [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/jni/JniRcsDiscoveryManager.h [moved from service/resource-encapsulation/sdk/java/src/org/iotivity/ResourceEncapsulation/utils/EntityHandlerResult.java with 59% similarity]
service/resource-encapsulation/android/service/src/main/jni/JniRcsLockedAttributes.cpp [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/jni/JniRcsLockedAttributes.h [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/jni/JniRcsObject.cpp [moved from service/resource-encapsulation/sdk/java/src/org/iotivity/ResourceEncapsulation/common/AttriubtesGetValueTypes.java with 55% similarity]
service/resource-encapsulation/android/service/src/main/jni/JniRcsObject.h [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/jni/JniRcsRemoteResourceObject.cpp [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/jni/JniRcsRemoteResourceObject.h [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/jni/JniRcsResourceAttributes.cpp [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/jni/JniRcsResourceAttributes.h [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/jni/JniRcsResourceContainer.cpp [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/jni/JniRcsResourceContainer.h [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/jni/JniRcsResourceObject.cpp [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/jni/JniRcsResourceObject.h [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/jni/JniRcsValue.cpp [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/jni/JniRcsValue.h [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/jni/util/JNIEnvWrapper.h [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/jni/util/JavaClasses.cpp [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/jni/util/JavaClasses.h [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/jni/util/JavaExceptions.cpp [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/jni/util/JavaExceptions.h [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/jni/util/JavaGlobalRef.h [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/jni/util/JavaLocalRef.h [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/jni/util/Log.h [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/jni/util/ScopedEnv.h [new file with mode: 0644]
service/resource-encapsulation/android/service/src/main/jni/util/Verify.h [new file with mode: 0644]
service/resource-encapsulation/android/settings.gradle [new file with mode: 0644]
service/resource-encapsulation/examples/linux/NestedAttributeClient.cpp
service/resource-encapsulation/examples/linux/SampleResourceClient.cpp
service/resource-encapsulation/include/RCSAddress.h
service/resource-encapsulation/include/RCSDiscoveryManager.h
service/resource-encapsulation/include/RCSRemoteResourceObject.h
service/resource-encapsulation/include/RCSResourceAttributes.h
service/resource-encapsulation/include/RCSResourceObject.h
service/resource-encapsulation/sdk/java/jni/Android.mk [deleted file]
service/resource-encapsulation/sdk/java/jni/jniutil/inc/jni_re_jvm.h [deleted file]
service/resource-encapsulation/sdk/java/jni/jniutil/inc/jni_re_utils.h [deleted file]
service/resource-encapsulation/sdk/java/jni/jniutil/src/jni_re_jvm.cpp [deleted file]
service/resource-encapsulation/sdk/java/jni/jniutil/src/jni_re_utils.cpp [deleted file]
service/resource-encapsulation/sdk/java/jni/re/include/jni_re_attribute_updated_listener.h [deleted file]
service/resource-encapsulation/sdk/java/jni/re/include/jni_re_cache_update_listener.h [deleted file]
service/resource-encapsulation/sdk/java/jni/re/include/jni_re_discover_resource_listener.h [deleted file]
service/resource-encapsulation/sdk/java/jni/re/include/jni_re_get_request_listener.h [deleted file]
service/resource-encapsulation/sdk/java/jni/re/include/jni_re_getattributes_listener.h [deleted file]
service/resource-encapsulation/sdk/java/jni/re/include/jni_re_listener_manager.h [deleted file]
service/resource-encapsulation/sdk/java/jni/re/include/jni_re_listener_manager_server.h [deleted file]
service/resource-encapsulation/sdk/java/jni/re/include/jni_re_rcs_bundle_info.h [deleted file]
service/resource-encapsulation/sdk/java/jni/re/include/jni_re_rcs_discovery_manager.h [deleted file]
service/resource-encapsulation/sdk/java/jni/re/include/jni_re_rcs_remoteresourceobject.h [deleted file]
service/resource-encapsulation/sdk/java/jni/re/include/jni_re_rcs_resource_container.h [deleted file]
service/resource-encapsulation/sdk/java/jni/re/include/jni_re_resource_attributes.h [deleted file]
service/resource-encapsulation/sdk/java/jni/re/include/jni_re_resource_builder.h [deleted file]
service/resource-encapsulation/sdk/java/jni/re/include/jni_re_resource_object.h [deleted file]
service/resource-encapsulation/sdk/java/jni/re/include/jni_re_resource_statechange_listener.h [deleted file]
service/resource-encapsulation/sdk/java/jni/re/include/jni_re_set_request_listener.h [deleted file]
service/resource-encapsulation/sdk/java/jni/re/include/jni_re_setattributes_listener.h [deleted file]
service/resource-encapsulation/sdk/java/jni/re/src/jni_re_attribute_updated_listener.cpp [deleted file]
service/resource-encapsulation/sdk/java/jni/re/src/jni_re_cache_update_listener.cpp [deleted file]
service/resource-encapsulation/sdk/java/jni/re/src/jni_re_discover_resource_listener.cpp [deleted file]
service/resource-encapsulation/sdk/java/jni/re/src/jni_re_get_request_listener.cpp [deleted file]
service/resource-encapsulation/sdk/java/jni/re/src/jni_re_getattributes_listener.cpp [deleted file]
service/resource-encapsulation/sdk/java/jni/re/src/jni_re_rcs_bundle_info.cpp [deleted file]
service/resource-encapsulation/sdk/java/jni/re/src/jni_re_rcs_discovery_manager.cpp [deleted file]
service/resource-encapsulation/sdk/java/jni/re/src/jni_re_rcs_remoteresourceobject.cpp [deleted file]
service/resource-encapsulation/sdk/java/jni/re/src/jni_re_rcs_resource_container.cpp [deleted file]
service/resource-encapsulation/sdk/java/jni/re/src/jni_re_resource_attributes.cpp [deleted file]
service/resource-encapsulation/sdk/java/jni/re/src/jni_re_resource_builder.cpp [deleted file]
service/resource-encapsulation/sdk/java/jni/re/src/jni_re_resource_object.cpp [deleted file]
service/resource-encapsulation/sdk/java/jni/re/src/jni_re_resource_statechange_listener.cpp [deleted file]
service/resource-encapsulation/sdk/java/jni/re/src/jni_re_set_request_listener.cpp [deleted file]
service/resource-encapsulation/sdk/java/jni/re/src/jni_re_setattributes_listener.cpp [deleted file]
service/resource-encapsulation/sdk/java/project.properties [deleted file]
service/resource-encapsulation/sdk/java/src/org/iotivity/ResourceEncapsulation/client/RCSAddress.java [deleted file]
service/resource-encapsulation/sdk/java/src/org/iotivity/ResourceEncapsulation/client/RCSDiscoveryManager.java [deleted file]
service/resource-encapsulation/sdk/java/src/org/iotivity/ResourceEncapsulation/client/RCSRemoteResourceObject.java [deleted file]
service/resource-encapsulation/sdk/java/src/org/iotivity/ResourceEncapsulation/common/RCSResourceAttributes.java [deleted file]
service/resource-encapsulation/sdk/java/src/org/iotivity/ResourceEncapsulation/server/Builder.java [deleted file]
service/resource-encapsulation/sdk/java/src/org/iotivity/ResourceEncapsulation/server/RCSGetResponse.java [deleted file]
service/resource-encapsulation/sdk/java/src/org/iotivity/ResourceEncapsulation/server/RCSResourceObject.java [deleted file]
service/resource-encapsulation/sdk/java/src/org/iotivity/ResourceEncapsulation/server/RCSSetResponse.java [deleted file]
service/resource-encapsulation/sdk/java/src/org/iotivity/ResourceEncapsulation/utils/DiscoveryType.java [deleted file]
service/resource-encapsulation/src/resourceClient/RCSRemoteResourceObject.cpp
service/resource-encapsulation/src/resourceContainer/SConscript
service/resource-encapsulation/src/serverBuilder/include/RequestHandler.h
service/resource-encapsulation/src/serverBuilder/src/RCSResourceObject.cpp
service/resource-encapsulation/src/serverBuilder/src/RequestHandler.cpp
service/resource-encapsulation/unittests/ResourceClientTest.cpp

index 62265f4..cb38c26 100644 (file)
@@ -122,3 +122,5 @@ if target_os == 'linux':
     SConscript('src/resourceBroker/unittest/SConscript')
     SConscript('src/resourceClient/unittests/SConscript')
 
+if target_os == 'android':
+       SConscript('android/SConscript')
diff --git a/service/resource-encapsulation/android/.gitignore b/service/resource-encapsulation/android/.gitignore
new file mode 100644 (file)
index 0000000..49ffed7
--- /dev/null
@@ -0,0 +1,9 @@
+.gradle
+/local.properties
+/.idea/workspace.xml
+/.idea/libraries
+.DS_Store
+/build/*
+/service/build/*
+/service/src/main/obj/*
+/service/src/main/libs/*
diff --git a/service/resource-encapsulation/android/SConscript b/service/resource-encapsulation/android/SConscript
new file mode 100644 (file)
index 0000000..23a3951
--- /dev/null
@@ -0,0 +1,57 @@
+import os
+import platform
+Import('env')
+
+android_home = env.get('ANDROID_HOME')
+
+ANDROID_TARGET_ARCH = env.get('TARGET_ARCH')
+if env.get('RELEASE'):
+       ANDROID_RELEASE="release"
+else:
+       ANDROID_RELEASE="debug"
+
+os.environ['ANDROID_HOME'] = env.get('ANDROID_HOME')
+os.environ['ANDROID_NDK_HOME'] = env.get('ANDROID_NDK')
+
+if not os.path.exists(android_home + '/platforms/android-21') or not os.path.exists(android_home + '/build-tools/20.0.0'):
+    print '''
+***************************************** Info ********************************
+*   Either 'Android API 21' is not installed or 'Android SDK Build Tools      *
+*   20.0.0' is not installed. The Android SDK Manager will now open. Please   *
+*   be sure to deselect all options, then select the following 2 packages:    *
+*       1. Under "Tools" select "Android SDK Build-tools" Revision 20.        *
+*       2. Under "Android 5.0.1 (API 21)" select "SDK Platform"               *
+*       3. Continue by selecting "Install 2 Packages"                         *
+*                                                                             *
+*   NOTE: If you have an http proxy, please press ctrl+c now and edit/create  *
+*         the following file in your $HOME directory as follows:              *
+*                                                                             *
+* Edit/Create file: "$HOME/.android/androidtool.cfg"                          *
+*                                                                             *
+*    http.proxyPort=<YOUR_PORT_NUMBER>                                        *
+*    sdkman.monitor.density=108                                               *
+*    http.proxyHost=<YOUR_HTTP_PROXY_ADDRESS>                                 *
+*    sdkman.show.update.only=true                                             *
+*    sdkman.ask.adb.restart=false                                             *
+*    sdkman.force.http=true                                                   *
+*    sdkman.show.updateonly=true                                              *
+*                                                                             *
+*******************************************************************************
+
+...Opening Android SDK Manager now. Once you are finished, the build will continue.
+'''
+    os.system(android_home + '/tools/android')
+
+
+def ensure_libs(target, source, env):
+    return target, [source, env.get('BUILD_DIR') + 'librcs_server.so', 
+                    env.get('BUILD_DIR') + 'librcs_client.so',
+                    env.get('BUILD_DIR') + 'librcs_container.so']
+
+jdk_env = Environment(ENV=os.environ)
+jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + 
+    ' build -bservice/resource-encapsulation/android/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s --stacktrace' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE),
+    emitter = ensure_libs)
+jdk_env['BUILD_DIR'] = env.get('BUILD_DIR')
+jdk_env.Gradle(target="service/objs", 
+    source="service/src/main/java/org/iotivity/service/RcsResourceAttributes.java")
diff --git a/service/resource-encapsulation/android/android_api.iml b/service/resource-encapsulation/android/android_api.iml
new file mode 100644 (file)
index 0000000..0bb6048
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
+  <component name="FacetManager">
+    <facet type="java-gradle" name="Java-Gradle">
+      <configuration>
+        <option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
+      </configuration>
+    </facet>
+  </component>
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <excludeFolder url="file://$MODULE_DIR$/.gradle" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+</module>
+
diff --git a/service/resource-encapsulation/android/build.gradle b/service/resource-encapsulation/android/build.gradle
new file mode 100644 (file)
index 0000000..cbfddfd
--- /dev/null
@@ -0,0 +1,40 @@
+/******************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************/
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+    repositories {
+        jcenter()
+    }
+    dependencies {
+        classpath 'com.android.tools.build:gradle:1.3.0'
+
+        // NOTE: Do not place your application dependencies here; they belong
+        // in the individual module build.gradle files
+    }
+}
+
+allprojects {
+    repositories {
+        jcenter {
+            url "http://jcenter.bintray.com/"
+        }
+    }
+}
diff --git a/service/resource-encapsulation/android/gradle.properties b/service/resource-encapsulation/android/gradle.properties
new file mode 100644 (file)
index 0000000..dff37f4
--- /dev/null
@@ -0,0 +1,40 @@
+#
+# //******************************************************************
+# //
+# // Copyright 2015 Intel Corporation.
+# //
+# //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+# //
+# // 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.
+# //
+# //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#
+
+# Project-wide Gradle settings.
+
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+# Default value: -Xmx10248m -XX:MaxPermSize=256m
+# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
+
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
diff --git a/service/resource-encapsulation/android/gradlew b/service/resource-encapsulation/android/gradlew
new file mode 100644 (file)
index 0000000..91a7e26
--- /dev/null
@@ -0,0 +1,164 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+##  Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+    echo "$*"
+}
+
+die ( ) {
+    echo
+    echo "$*"
+    echo
+    exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+  CYGWIN* )
+    cygwin=true
+    ;;
+  Darwin* )
+    darwin=true
+    ;;
+  MINGW* )
+    msys=true
+    ;;
+esac
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched.
+if $cygwin ; then
+    [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+fi
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >&-
+APP_HOME="`pwd -P`"
+cd "$SAVED" >&-
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+        # IBM's JDK on AIX uses strange locations for the executables
+        JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+        JAVACMD="$JAVA_HOME/bin/java"
+    fi
+    if [ ! -x "$JAVACMD" ] ; then
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+    fi
+else
+    JAVACMD="java"
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+    MAX_FD_LIMIT=`ulimit -H -n`
+    if [ $? -eq 0 ] ; then
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+            MAX_FD="$MAX_FD_LIMIT"
+        fi
+        ulimit -n $MAX_FD
+        if [ $? -ne 0 ] ; then
+            warn "Could not set maximum file descriptor limit: $MAX_FD"
+        fi
+    else
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+    fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+    # We build the pattern for arguments to be converted via cygpath
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+    SEP=""
+    for dir in $ROOTDIRSRAW ; do
+        ROOTDIRS="$ROOTDIRS$SEP$dir"
+        SEP="|"
+    done
+    OURCYGPATTERN="(^($ROOTDIRS))"
+    # Add a user-defined pattern to the cygpath arguments
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+    fi
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
+    i=0
+    for arg in "$@" ; do
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
+
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+        else
+            eval `echo args$i`="\"$arg\""
+        fi
+        i=$((i+1))
+    done
+    case $i in
+        (0) set -- ;;
+        (1) set -- "$args0" ;;
+        (2) set -- "$args0" "$args1" ;;
+        (3) set -- "$args0" "$args1" "$args2" ;;
+        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+    esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+    JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/service/resource-encapsulation/android/gradlew.bat b/service/resource-encapsulation/android/gradlew.bat
new file mode 100644 (file)
index 0000000..8a0b282
--- /dev/null
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem  Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/service/resource-encapsulation/android/service/base.iml b/service/resource-encapsulation/android/service/base.iml
new file mode 100644 (file)
index 0000000..3bf0877
--- /dev/null
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="android_api" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
+  <component name="FacetManager">
+    <facet type="android-gradle" name="Android-Gradle">
+      <configuration>
+        <option name="GRADLE_PROJECT_PATH" value=":base" />
+      </configuration>
+    </facet>
+    <facet type="android" name="Android">
+      <configuration>
+        <option name="SELECTED_BUILD_VARIANT" value="debug" />
+        <option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
+        <option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
+        <option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
+        <option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
+        <option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugTestSources" />
+        <option name="ALLOW_USER_CONFIGURATION" value="false" />
+        <option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
+        <option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
+        <option name="RES_FOLDERS_RELATIVE_PATH" value="" />
+        <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
+        <option name="LIBRARY_PROJECT" value="true" />
+      </configuration>
+    </facet>
+  </component>
+  <component name="NewModuleRootManager" inherit-compiler-output="false">
+    <output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
+    <output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/debug" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/test/debug" isTestSource="true" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/test/debug" isTestSource="true" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/test/debug" isTestSource="true" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/test/debug" isTestSource="true" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/test/debug" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/test/debug" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
+      <excludeFolder url="file://$MODULE_DIR$/build/native-libs" />
+      <excludeFolder url="file://$MODULE_DIR$/build/outputs" />
+      <excludeFolder url="file://$MODULE_DIR$/build/tmp" />
+    </content>
+    <orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+</module>
+
diff --git a/service/resource-encapsulation/android/service/build.gradle b/service/resource-encapsulation/android/service/build.gradle
new file mode 100644 (file)
index 0000000..50c7205
--- /dev/null
@@ -0,0 +1,107 @@
+/******************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************/
+
+apply plugin: 'com.android.library'
+
+android {
+    compileSdkVersion 21
+    buildToolsVersion "20.0.0"
+    archivesBaseName = "iotivity"
+
+    libraryVariants.all { variant ->
+        variant.outputs.each { output ->
+            def outputFile = output.outputFile
+            if (outputFile != null && outputFile.name.endsWith('.aar')) {
+                def fileName = "${archivesBaseName}-${TARGET_ARCH}-${outputFile.name}"
+                output.outputFile = new File(outputFile.parent, fileName)
+            }
+        }
+    }
+
+    defaultConfig {
+        minSdkVersion 21
+        targetSdkVersion 21
+        versionCode 1
+        versionName "1.0"
+    }
+    buildTypes {
+        release {
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+        }
+    }
+
+    lintOptions {
+       abortOnError false
+    }
+
+    sourceSets {
+        main {
+            manifest.srcFile 'src/main/AndroidManifest.xml'
+            jni.srcDirs = [] //disable automatic ndk-build call
+            jniLibs.srcDir new File(buildDir, 'native-libs')
+        }
+        androidTest.setRoot('src/androidTest')
+    }
+}
+
+
+dependencies {
+    compile fileTree(dir: 'libs', include: ['*.jar'])
+
+    androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.0'
+    androidTestCompile 'com.google.dexmaker:dexmaker:1.0'
+    androidTestCompile 'org.mockito:mockito-core:1.10.19'
+}
+
+////////////////
+////NDK Support
+////////////////
+//If using this, Android studio will fail run the following to set the environment variable for android studio:
+//launchctl setenv ANDROID_NDK_HOME
+//otherwise remove the dependsOn part and run ./gradlew buildNative from the command line
+task copyNativeLibs(type: Copy, dependsOn: 'buildNative') {
+    dependsOn 'buildNative'
+    from(new File('src/main/libs')) { include '**/*.so' exclude '**/libgnustl_shared.so' }
+    into new File(buildDir, 'native-libs')
+}
+
+tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn copyNativeLibs }
+
+clean.dependsOn 'cleanCopyNativeLibs'
+
+tasks.withType(com.android.build.gradle.tasks.PackageApplication) {
+    pkgTask ->
+    pkgTask.jniFolders = new HashSet<File>()
+    pkgTask.jniFolders.add(new File(buildDir, 'native-libs'))
+}
+
+task buildNative(type: Exec) {
+    if (System.env.ANDROID_NDK_HOME != null) {
+        //for windows use 'ndk-build.cmd'
+        //def ndkBuild = new File(System.env.ANDROID_NDK_HOME, 'ndk-build.cmd')
+        def ndkBuild = new File(System.env.ANDROID_NDK_HOME, 'ndk-build')
+        commandLine ndkBuild, "APP_ABI=$TARGET_ARCH", "APP_OPTIM=$RELEASE", '-C', file('src/main').absolutePath
+    } else {
+        println '##################'
+        println 'Skipping NDK build'
+        println 'Reason: ANDROID_NDK_HOME not set.'
+        println '##################'
+    }
+}
diff --git a/service/resource-encapsulation/android/service/proguard-rules.pro b/service/resource-encapsulation/android/service/proguard-rules.pro
new file mode 100644 (file)
index 0000000..c5f9a5b
--- /dev/null
@@ -0,0 +1,17 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in C:/android/sdk/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}
diff --git a/service/resource-encapsulation/android/service/src/androidTest/java/org/iotivity/service/RemoteResourceObjectTest.java b/service/resource-encapsulation/android/service/src/androidTest/java/org/iotivity/service/RemoteResourceObjectTest.java
new file mode 100644 (file)
index 0000000..3355d7b
--- /dev/null
@@ -0,0 +1,186 @@
+package org.iotivity.service;
+
+import org.mockito.Mockito;
+
+import static org.iotivity.service.client.RcsRemoteResourceObject.CacheState;
+import static org.iotivity.service.client.RcsRemoteResourceObject.OnCacheUpdatedListener;
+import static org.iotivity.service.client.RcsRemoteResourceObject.OnRemoteAttributesReceivedListener;
+import static org.iotivity.service.client.RcsRemoteResourceObject.OnStateChangedListener;
+import static org.iotivity.service.client.RcsRemoteResourceObject.ResourceState;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.timeout;
+import static org.mockito.Mockito.verify;
+
+public class RemoteResourceObjectTest extends TestBase {
+
+    private RcsResourceAttributes createAttrs() {
+        RcsResourceAttributes attrs = new RcsResourceAttributes();
+        attrs.put("key", new RcsValue(3));
+        attrs.put("b", new RcsValue(new RcsResourceAttributes()));
+        attrs.put("myKey", new RcsValue("string-value"));
+
+        return attrs;
+    }
+
+    public void testGetRemoteAttributesGetsAttributesOfServer() throws RcsException {
+        OnRemoteAttributesReceivedListener listener =
+                Mockito.mock(OnRemoteAttributesReceivedListener.class);
+
+        setServerAttrbutes(createAttrs());
+
+        mClient.getRemoteAttributes(listener);
+
+        verify(listener, timeout(1000)).onAttributesReceived(eq(createAttrs()), anyInt());
+    }
+
+    public void testGetRemoteAttributesSetsAttributesOfServer() throws RcsException {
+        OnRemoteAttributesReceivedListener listener =
+                Mockito.mock(OnRemoteAttributesReceivedListener.class);
+
+        mServer.setAttribute("key", new RcsValue(0));
+
+        RcsResourceAttributes attrs = new RcsResourceAttributes();
+        attrs.put("key", new RcsValue(3));
+
+        mClient.setRemoteAttributes(attrs, listener);
+
+        verify(listener, timeout(1000)).onAttributesReceived(any(RcsResourceAttributes.class),
+                anyInt());
+
+        assertEquals(3, mServer.getAttributeValue("key").asInt());
+    }
+
+    public void testMonitoringIsNotStartedByDefault() throws RcsException {
+        assertFalse(mClient.isMonitoring());
+    }
+
+    public void testIsMonitoringReturnsTrueAfterStartMonitoring() throws RcsException {
+        OnStateChangedListener listener = Mockito.mock(OnStateChangedListener.class);
+        mClient.startMonitoring(listener);
+
+        assertTrue(mClient.isMonitoring());
+    }
+
+    public void testStartMonitoringThrowsIfTryingToStartAgain() throws RcsException {
+        OnStateChangedListener listener = Mockito.mock(OnStateChangedListener.class);
+        mClient.startMonitoring(listener);
+
+        try {
+            mClient.startMonitoring(listener);
+            fail("No exception thrown");
+        } catch (RcsIllegalStateException e) {
+        }
+    }
+
+    public void testDefaultResourceStateIsNone() throws RcsException {
+        assertEquals(ResourceState.NONE, mClient.getState());
+    }
+
+    public void testCachingIsNotStartedByDefault() throws RcsException {
+        assertFalse(mClient.isCaching());
+    }
+
+    public void testIsCachingReturnsTrueAfterStartCaching() throws RcsException {
+        mClient.startCaching();
+
+        assertTrue(mClient.isCaching());
+    }
+
+    public void testStartCachingThrowsIfTryingToStartAgain() throws RcsException {
+        mClient.startCaching();
+
+        try {
+            mClient.startCaching();
+            fail("No exception thrown");
+        } catch (RcsIllegalStateException e) {
+        }
+    }
+
+    public void testDefaultCacheStateIsNone() throws RcsException {
+        assertEquals(CacheState.NONE, mClient.getCacheState());
+    }
+
+    public void testCacheStateIsUnreadyAfterStartCaching() throws RcsException {
+        mClient.startCaching();
+
+        assertEquals(CacheState.UNREADY, mClient.getCacheState());
+    }
+
+    public void testCacheStateIsReadyAfterCacheUpdated() throws RcsException {
+        OnCacheUpdatedListener listener = Mockito.mock(OnCacheUpdatedListener.class);
+        mClient.startCaching(listener);
+
+        verify(listener, timeout(1000)).onCacheUpdated(any(RcsResourceAttributes.class));
+
+        assertEquals(CacheState.READY, mClient.getCacheState());
+    }
+
+    public void testIsCachedAvailableReturnsTrueWhenCacheIsReady() throws RcsException {
+        OnCacheUpdatedListener listener = Mockito.mock(OnCacheUpdatedListener.class);
+        mClient.startCaching(listener);
+
+        verify(listener, timeout(1000)).onCacheUpdated(any(RcsResourceAttributes.class));
+
+        assertTrue(mClient.isCachedAvailable());
+    }
+
+    public void testGetCachedAttributesThrowsIfCachingIsNotStarted() throws RcsException {
+        try {
+            mClient.getCachedAttributes();
+            fail("No exception thrown");
+        } catch (RcsIllegalStateException e) {
+        }
+    }
+
+    public void testCachedAttributesHasSameAttributesWithServer() throws RcsException {
+        setServerAttrbutes(createAttrs());
+
+        OnCacheUpdatedListener listener = Mockito.mock(OnCacheUpdatedListener.class);
+        mClient.startCaching(listener);
+
+        verify(listener, timeout(1000)).onCacheUpdated(any(RcsResourceAttributes.class));
+
+        assertEquals(createAttrs(), mClient.getCachedAttributes());
+    }
+
+    public void testGetCachedAttributeThrowsIfCachingIsNotStarted() throws RcsException {
+        try {
+            mClient.getCachedAttribute("some_key");
+            fail("No exception thrown");
+        } catch (RcsIllegalStateException e) {
+        }
+    }
+
+    public void testGetCachedAttributeReturnsNullIfKeyIsInvalid() throws RcsException {
+        OnCacheUpdatedListener listener = Mockito.mock(OnCacheUpdatedListener.class);
+        mClient.startCaching(listener);
+
+        verify(listener, timeout(1000)).onCacheUpdated(any(RcsResourceAttributes.class));
+
+        assertNull(mClient.getCachedAttribute("some_key"));
+    }
+
+    public void testHasSameUriWithServer() throws RcsException {
+        assertEquals(RESOURCEURI, mClient.getUri());
+    }
+
+    public void testHasSameTypeWithServer() throws RcsException {
+        assertEquals(RESOURCETYPE, mClient.getTypes()[0]);
+    }
+
+    public void testHasSameInterfaceWithServer() throws RcsException {
+        assertEquals(RESOURCEINTERFACE, mClient.getInterfaces()[0]);
+    }
+
+    public void testThrowsIfObjectIsDestroyed() throws RcsException {
+        mClient.destroy();
+
+        try {
+            mClient.getUri();
+            fail("No exception thrown");
+        } catch (RcsDestroyedObjectException e) {
+        }
+    }
+}
diff --git a/service/resource-encapsulation/android/service/src/androidTest/java/org/iotivity/service/ResourceObjectBuilderTest.java b/service/resource-encapsulation/android/service/src/androidTest/java/org/iotivity/service/ResourceObjectBuilderTest.java
new file mode 100644 (file)
index 0000000..db6d420
--- /dev/null
@@ -0,0 +1,38 @@
+package org.iotivity.service;
+
+import android.test.InstrumentationTestCase;
+
+import org.iotivity.service.server.RcsResourceObject;
+
+public class ResourceObjectBuilderTest extends InstrumentationTestCase {
+    private static final String RESOURCEURI = "/a/TemperatureSensor";
+    private static final String RESOURCETYPE = "Resource.Hosting";
+    private static final String RESOURCEINTERFACE = "oic.if.baseline";
+
+    private RcsResourceObject mObject;
+
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+
+        mObject.destroy();
+        mObject = null;
+    }
+
+    public void testResourceServerHasPropertiesSetByBuilder() throws RcsException {
+        mObject = new RcsResourceObject.Builder(RESOURCEURI, RESOURCETYPE,
+                RESOURCEINTERFACE).setDiscoverable(false).setObservable(true).build();
+
+        assertTrue(mObject.isObservable());
+    }
+
+    public void testResourceServerHasAttrsSetByBuilder() throws RcsException {
+        RcsResourceAttributes attrs = new RcsResourceAttributes();
+        attrs.put("key", new RcsValue(100));
+
+        mObject = new RcsResourceObject.Builder(RESOURCEURI, RESOURCETYPE,
+                RESOURCEINTERFACE).setAttributes(attrs).build();
+
+        assertEquals(new RcsValue(100), mObject.getAttributeValue("key"));
+    }
+}
diff --git a/service/resource-encapsulation/android/service/src/androidTest/java/org/iotivity/service/ResourceObjectTest.java b/service/resource-encapsulation/android/service/src/androidTest/java/org/iotivity/service/ResourceObjectTest.java
new file mode 100644 (file)
index 0000000..d4deaa8
--- /dev/null
@@ -0,0 +1,198 @@
+package org.iotivity.service;
+
+import org.iotivity.service.client.RcsRemoteResourceObject.OnRemoteAttributesReceivedListener;
+import org.iotivity.service.server.RcsGetResponse;
+import org.iotivity.service.server.RcsRequest;
+import org.iotivity.service.server.RcsResourceObject.AutoNotifyPolicy;
+import org.iotivity.service.server.RcsResourceObject.GetRequestHandler;
+import org.iotivity.service.server.RcsResourceObject.OnAttributeUpdatedListener;
+import org.iotivity.service.server.RcsResourceObject.SetRequestHandler;
+import org.iotivity.service.server.RcsResourceObject.SetRequestHandlerPolicy;
+import org.iotivity.service.server.RcsSetResponse;
+import org.mockito.Mockito;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.timeout;
+import static org.mockito.Mockito.verify;
+
+public class ResourceObjectTest extends TestBase {
+    private static final String NEW_KEY = "new" + KEY;
+
+    private OnRemoteAttributesReceivedListener mOnRemoteAttributesReceivedListener;
+    private SetRequestHandler mSetRequestHandler;
+    private GetRequestHandler mGetRequestHandler;
+    private OnAttributeUpdatedListener mOnAttributeUpdatedListener;
+
+    private void setSetRequestHandlerReturn(RcsSetResponse setResponse) {
+        doReturn(setResponse).when(mSetRequestHandler).
+                onSetRequested(any(RcsRequest.class), any(RcsResourceAttributes.class));
+    }
+
+    private void setGetRequestHandlerReturn(RcsGetResponse getResponse) {
+        doReturn(getResponse).when(mGetRequestHandler).onGetRequested(
+                any(RcsRequest.class), any(RcsResourceAttributes.class));
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        mOnRemoteAttributesReceivedListener = Mockito.mock(OnRemoteAttributesReceivedListener.class);
+
+        mGetRequestHandler = Mockito.mock(GetRequestHandler.class);
+        mSetRequestHandler = Mockito.mock(SetRequestHandler.class);
+        mOnAttributeUpdatedListener = Mockito.mock(OnAttributeUpdatedListener.class);
+    }
+
+    public void testDefalutAutoNotifyPolicyIsUpdated() throws RcsException {
+        assertEquals(AutoNotifyPolicy.UPDATED, mServer.getAutoNotifyPolicy());
+    }
+
+    public void testAutoNotifyPolicyCanBeSet() throws RcsException {
+        mServer.setAutoNotifyPolicy(AutoNotifyPolicy.NEVER);
+        assertEquals(AutoNotifyPolicy.NEVER, mServer.getAutoNotifyPolicy());
+
+        mServer.setAutoNotifyPolicy(AutoNotifyPolicy.UPDATED);
+        assertEquals(AutoNotifyPolicy.UPDATED, mServer.getAutoNotifyPolicy());
+
+        mServer.setAutoNotifyPolicy(AutoNotifyPolicy.ALWAYS);
+        assertEquals(AutoNotifyPolicy.ALWAYS, mServer.getAutoNotifyPolicy());
+    }
+
+    public void testDefalutSetRequestHandlerPolicyIsNever() throws RcsException {
+        assertEquals(SetRequestHandlerPolicy.NEVER, mServer.getSetRequestHandlerPolicy());
+    }
+
+    public void testSetRequestHandlerPolicyCanBeSet() throws RcsException {
+        mServer.setSetRequestHandlerPolicy(SetRequestHandlerPolicy.ACCEPT);
+        assertEquals(SetRequestHandlerPolicy.ACCEPT, mServer.getSetRequestHandlerPolicy());
+
+        mServer.setSetRequestHandlerPolicy(SetRequestHandlerPolicy.NEVER);
+        assertEquals(SetRequestHandlerPolicy.NEVER, mServer.getSetRequestHandlerPolicy());
+    }
+
+    public void testGetRequestHandlerCalledIfReceived() throws RcsException {
+        setGetRequestHandlerReturn(RcsGetResponse.defaultAction());
+
+        mServer.setGetRequestHandler(mGetRequestHandler);
+
+        mClient.getRemoteAttributes(mOnRemoteAttributesReceivedListener);
+
+        verify(mGetRequestHandler, timeout(1000)).onGetRequested(any(RcsRequest.class),
+                any(RcsResourceAttributes.class));
+    }
+
+    public void testGetRequestHandlerCanReturnCustomAttrsAsResponse() throws RcsException {
+        RcsResourceAttributes newAttrs = new RcsResourceAttributes();
+        newAttrs.put(NEW_KEY, new RcsValue(RAW_VALUE + 1));
+
+        setGetRequestHandlerReturn(RcsGetResponse.create(newAttrs));
+
+        mServer.setGetRequestHandler(mGetRequestHandler);
+        mClient.getRemoteAttributes(mOnRemoteAttributesReceivedListener);
+
+        verify(mGetRequestHandler, timeout(1000)).onGetRequested(any(RcsRequest.class),
+                any(RcsResourceAttributes.class));
+
+        verify(mOnRemoteAttributesReceivedListener, timeout(1000)).onAttributesReceived(
+                eq(newAttrs), anyInt());
+    }
+
+    public void testSetRequestHandlerCalledIfReceived() throws RcsException {
+        setSetRequestHandlerReturn(RcsSetResponse.defaultAction());
+
+        mServer.setSetRequestHandler(mSetRequestHandler);
+
+        mClient.setRemoteAttributes(new RcsResourceAttributes(), mOnRemoteAttributesReceivedListener);
+
+        verify(mSetRequestHandler, timeout(1000)).onSetRequested(any(RcsRequest.class),
+                any(RcsResourceAttributes.class));
+    }
+
+    public void testIgnoreSetRequestIfSetRequestHandlerReturnsIgnore() throws RcsException {
+        setSetRequestHandlerReturn(RcsSetResponse.ignore());
+
+        mServer.setSetRequestHandler(mSetRequestHandler);
+
+        RcsResourceAttributes newAttrs = new RcsResourceAttributes();
+        newAttrs.put(KEY, new RcsValue(RAW_VALUE + 1));
+
+        mClient.setRemoteAttributes(newAttrs, mOnRemoteAttributesReceivedListener);
+
+        verify(mSetRequestHandler, timeout(1000)).onSetRequested(any(RcsRequest.class),
+                eq(newAttrs));
+
+        assertEquals(RAW_VALUE, mServer.getAttributeValue(KEY).asInt());
+    }
+
+    public void testAcceptSetRequestIfSetRequestHandlerReturnsAccept() throws RcsException {
+        setSetRequestHandlerReturn(RcsSetResponse.accept());
+
+        mServer.setSetRequestHandlerPolicy(SetRequestHandlerPolicy.NEVER);
+        mServer.setSetRequestHandler(mSetRequestHandler);
+
+        RcsResourceAttributes newAttrs = new RcsResourceAttributes();
+        newAttrs.put(NEW_KEY, new RcsValue(RAW_VALUE + 1));
+
+        mClient.setRemoteAttributes(newAttrs, mOnRemoteAttributesReceivedListener);
+
+        verify(mSetRequestHandler, timeout(1000)).onSetRequested(any(RcsRequest.class),
+                eq(newAttrs));
+
+        assertEquals(RAW_VALUE + 1, mServer.getAttributeValue(NEW_KEY).asInt());
+    }
+
+    public void testSetRequestHandlerCanReturnCustomAttrsAsResponse() throws RcsException {
+        final RcsResourceAttributes newAttrs = new RcsResourceAttributes();
+        newAttrs.put(NEW_KEY, new RcsValue(RAW_VALUE + 1));
+
+        setSetRequestHandlerReturn(RcsSetResponse.create(newAttrs));
+
+        mServer.setSetRequestHandler(mSetRequestHandler);
+        mClient.setRemoteAttributes(new RcsResourceAttributes(), mOnRemoteAttributesReceivedListener);
+
+        verify(mSetRequestHandler, timeout(1000)).onSetRequested(any(RcsRequest.class),
+                any(RcsResourceAttributes.class));
+
+        verify(mOnRemoteAttributesReceivedListener, timeout(1000)).onAttributesReceived(
+                eq(newAttrs), anyInt());
+    }
+
+    public void testOnAttributeUpdatedListenerIsCalledIfValueUpdated() throws RcsException {
+        final RcsValue newValue = new RcsValue(RAW_VALUE + 1);
+        final RcsResourceAttributes newAttrs = new RcsResourceAttributes();
+        newAttrs.put(KEY, newValue);
+
+        mServer.addAttributeUpdatedListener(KEY, mOnAttributeUpdatedListener);
+        mClient.setRemoteAttributes(newAttrs, mOnRemoteAttributesReceivedListener);
+
+        verify(mOnAttributeUpdatedListener, timeout(1000)).onAttributeUpdated(eq(VALUE),
+                eq(newValue));
+    }
+
+    public void testOnAttributeUpdatedListenerIsNotCalledIRemoved() throws RcsException {
+        final RcsValue newValue = new RcsValue(RAW_VALUE + 1);
+        final RcsResourceAttributes newAttrs = new RcsResourceAttributes();
+        newAttrs.put(KEY, newValue);
+
+        mServer.addAttributeUpdatedListener(KEY, mOnAttributeUpdatedListener);
+        mServer.removeAttribute(KEY);
+        mClient.setRemoteAttributes(newAttrs, mOnRemoteAttributesReceivedListener);
+
+        verify(mOnAttributeUpdatedListener, never()).onAttributeUpdated(eq(VALUE), eq(newValue));
+    }
+
+    public void testThrowIfObjectIsDestroyed() throws RcsException {
+        mServer.destroy();
+        try {
+            mServer.removeAttribute("");
+            fail("No exception thrown");
+        } catch (RcsDestroyedObjectException e) {
+        }
+
+    }
+}
diff --git a/service/resource-encapsulation/android/service/src/androidTest/java/org/iotivity/service/TestBase.java b/service/resource-encapsulation/android/service/src/androidTest/java/org/iotivity/service/TestBase.java
new file mode 100644 (file)
index 0000000..5f9686c
--- /dev/null
@@ -0,0 +1,82 @@
+package org.iotivity.service;
+
+import android.test.InstrumentationTestCase;
+
+import org.iotivity.service.client.RcsAddress;
+import org.iotivity.service.client.RcsDiscoveryManager;
+import org.iotivity.service.client.RcsDiscoveryManager.OnResourceDiscoveredListener;
+import org.iotivity.service.client.RcsRemoteResourceObject;
+import org.iotivity.service.server.RcsResourceObject;
+
+public abstract class TestBase extends InstrumentationTestCase {
+    protected static final String RESOURCEURI = "/a/TemperatureSensor";
+    protected static final String RESOURCETYPE = "Resource.Hosting";
+    protected static final String RESOURCEINTERFACE = "oic.if.baseline";
+
+    protected static final String KEY = "key";
+    protected static final RcsValue VALUE = new RcsValue(100);
+    protected static final int RAW_VALUE = 100;
+
+    private final Object mCond = new Object();
+
+    protected RcsResourceObject mServer;
+    protected RcsRemoteResourceObject mClient;
+
+    private OnResourceDiscoveredListener mOnResourceDiscoveredListener = new OnResourceDiscoveredListener() {
+        @Override
+        public void onResourceDiscovered(RcsRemoteResourceObject RcsRemoteResourceObject) {
+            if (mClient != null) return;
+
+            mClient = RcsRemoteResourceObject;
+            synchronized (mCond) {
+                mCond.notify();
+            }
+        }
+    };
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        mServer = new RcsResourceObject.Builder(RESOURCEURI, RESOURCETYPE,
+                RESOURCEINTERFACE).build();
+        mServer.setAttribute(KEY, VALUE);
+
+        WaitUntilDiscovered();
+
+        assertNotNull(mClient);
+    }
+
+    private void WaitUntilDiscovered() throws RcsException {
+        while (mClient == null) {
+            try {
+                RcsDiscoveryManager.DiscoveryTask discoveryTask = RcsDiscoveryManager.getInstance().
+                        discoverResourceByType(RcsAddress.multicast(),
+                                "/oic/res", RESOURCETYPE, mOnResourceDiscoveredListener);
+
+                synchronized (mCond) {
+                    mCond.wait(100);
+                }
+
+                discoveryTask.cancel();
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    protected void setServerAttrbutes(RcsResourceAttributes attrs) throws RcsException {
+        RcsResourceObject.AttributesLock lock = mServer.getAttributesLock();
+        lock.lock().putAll(attrs);
+        lock.apply();
+        lock.unlock();
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+
+        mServer.destroy();
+        mClient.destroy();
+    }
+}
diff --git a/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/RcsDestroyedObjectException.java b/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/RcsDestroyedObjectException.java
new file mode 100644 (file)
index 0000000..e5ed6f9
--- /dev/null
@@ -0,0 +1,15 @@
+package org.iotivity.service;
+
+/**
+ * Thrown when trying to access a destroyed resource object.
+ *
+ */
+public class RcsDestroyedObjectException extends RcsException {
+
+    private static final long serialVersionUID = -4107062696447237658L;
+
+    public RcsDestroyedObjectException(String message) {
+        super(message);
+    }
+
+}
  * limitations under the License.
  *
  ******************************************************************/
+
 /**
  * @file
  *This file provides RCSException class for RE layer
  */
-
-package org.iotivity.ResourceEncapsulation.common;
+package org.iotivity.service;
 
 /**
- * This is the Exception class for the Resource Encapsulation APIs
+ * An exception that indicates there was an error with execution of Rcs APIs.
  */
-public class RCSException extends Exception {
+public class RcsException extends Exception {
+
+    private static final long serialVersionUID = 7044421943523001940L;
 
-    public RCSException(String exception) {
-        super(exception);
+    public RcsException(String message) {
+        super(message);
     }
 }
diff --git a/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/RcsIllegalStateException.java b/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/RcsIllegalStateException.java
new file mode 100644 (file)
index 0000000..5602313
--- /dev/null
@@ -0,0 +1,15 @@
+package org.iotivity.service;
+
+/**
+ * Thrown when an action is attempted at a time when not in the correct state.
+ *
+ */
+public class RcsIllegalStateException extends RcsException {
+
+    private static final long serialVersionUID = 6142669404885957616L;
+
+    public RcsIllegalStateException(String message) {
+        super(message);
+    }
+
+}
diff --git a/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/RcsObject.java b/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/RcsObject.java
new file mode 100644 (file)
index 0000000..4369fb6
--- /dev/null
@@ -0,0 +1,58 @@
+/******************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************/
+package org.iotivity.service;
+
+public class RcsObject {
+    static {
+        System.loadLibrary("gnustl_shared");
+        System.loadLibrary("oc_logger");
+        System.loadLibrary("connectivity_abstraction");
+        System.loadLibrary("ca-interface");
+        System.loadLibrary("octbstack");
+        System.loadLibrary("oc");
+        System.loadLibrary("rcs_client");
+        System.loadLibrary("rcs_server");
+        System.loadLibrary("rcs_common");
+        System.loadLibrary("rcs_container");
+        System.loadLibrary("rcs_jni");
+    }
+
+    private long mNativeHandle;
+
+    private native void nativeDispose();
+
+    protected RcsObject() {
+    }
+
+    @Override
+    protected void finalize() throws Throwable {
+        super.finalize();
+
+        dispose();
+    }
+
+    protected void dispose() {
+        if (mNativeHandle != 0L) nativeDispose();
+    }
+
+    protected boolean hasHandle() {
+        return mNativeHandle != 0L;
+    }
+}
diff --git a/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/RcsPlatformException.java b/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/RcsPlatformException.java
new file mode 100644 (file)
index 0000000..fd07e1e
--- /dev/null
@@ -0,0 +1,22 @@
+package org.iotivity.service;
+
+/**
+ * Thrown when an operation that has base-layer dependency is failed.
+ *
+ */
+public class RcsPlatformException extends RcsException {
+
+    private static final long serialVersionUID = -6093438347973754721L;
+
+    private final int mReasonCode;
+
+    public RcsPlatformException(String message, int reasonCode) {
+        super(message);
+
+        mReasonCode = reasonCode;
+    }
+
+    public int getReasonCode() {
+        return mReasonCode;
+    }
+}
diff --git a/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/RcsResourceAttributes.java b/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/RcsResourceAttributes.java
new file mode 100644 (file)
index 0000000..41849a9
--- /dev/null
@@ -0,0 +1,204 @@
+/******************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************/
+
+package org.iotivity.service;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ *
+ * RCSResourceAttributes represents the attributes for a resource.
+ *
+ * @see RcsValue
+ */
+public final class RcsResourceAttributes extends RcsObject {
+
+    private native boolean nativeIsEmpty();
+
+    private native int nativeSize();
+
+    private native boolean nativeRemove(String key);
+
+    private native void nativeClear();
+
+    private native boolean nativeContains(String key);
+
+    private native void nativeAddKeys(Set<String> set);
+
+    private native RcsValue nativeExtract(String key);
+
+    private native void nativeExtractAll(Map<String, RcsValue> map);
+
+    private final Map<String, RcsValue> mCache = new HashMap<>();
+
+    public RcsResourceAttributes() {
+    }
+
+    /**
+     * Returns a unmodifiable Set view of the keys contained in this attributes.
+     *
+     * @return an unmodifiable set view of the keys in this attributes
+     */
+    public Set<String> keySet() {
+        if (hasHandle()) {
+            final Set<String> keySet = new HashSet<>(mCache.keySet());
+
+            nativeAddKeys(keySet);
+
+            return Collections.unmodifiableSet(keySet);
+        }
+
+        return Collections.unmodifiableSet(mCache.keySet());
+    }
+
+    /**
+     * Returns the value to which the specified key is mapped, or null if this
+     * contains no mapping for the key.
+     *
+     * @param key
+     *            the key whose associated value is to be returned
+     *
+     * @return the value to which the specified key is mapped, or null if this
+     *         contains no mapping for the key
+     *
+     * @throws NullPointerException
+     *             if key is null
+     */
+    public RcsValue get(String key) {
+        if (key == null) throw new NullPointerException("key is null");
+
+        if (!mCache.containsKey(key) && hasHandle() && nativeContains(key)) {
+            mCache.put(key, nativeExtract(key));
+        }
+        return mCache.get(key);
+    }
+
+    /**
+     * Sets the specified value with the specified key.
+     * If the object previously contained a mapping for the key, the old value
+     * is replaced by the specified value.
+     *
+     *
+     * @param key
+     *            key with which the specified value is to be associated
+     *
+     * @param value
+     *            value to be associated with the specified key
+     *
+     */
+    public void put(String key, RcsValue value) {
+        if (key == null) throw new NullPointerException("key is null");
+        if (value == null) throw new NullPointerException("value is null");
+
+        mCache.put(key, value);
+        if (hasHandle()) nativeRemove(key);
+    }
+
+    public void put(String key, Object object) {
+        put(key, new RcsValue(object));
+    }
+
+    /**
+     * Returns true if this contains no key-value mappings.
+     *
+     * @return true if this contains no key-value mappings
+     */
+    public boolean isEmpty() {
+        return mCache.isEmpty() && (!hasHandle() || nativeIsEmpty());
+    }
+
+    /**
+     * Returns the number of key-value mappings.
+     *
+     * @return the number of key-value mappings
+     */
+    public int size() {
+        if (hasHandle()) return mCache.size() + nativeSize();
+        return mCache.size();
+    }
+
+    /**
+     * Removes the mapping for a key from this attributes if it is present.
+     *
+     * @param key
+     *            key whose mapping is to be removed
+     *
+     * @return true if the key is present and the the value mapped is removed.
+     */
+    public boolean remove(String key) {
+        if (key == null) throw new NullPointerException("key is null");
+
+        // XXX make sure both cache and native values to be removed.
+        final boolean cacheRemove = mCache.remove(key) != null;
+        final boolean nativeRemove = hasHandle() && nativeRemove(key);
+
+        return cacheRemove || nativeRemove;
+    }
+
+    /**
+     * Removes all of the mappings.
+     */
+    public void clear() {
+        mCache.clear();
+        nativeClear();
+    }
+
+    /**
+     * Returns true if this contains a mapping for the specified key.
+     *
+     * @param key
+     *            key whose presence is to be tested
+     *
+     * @return true if this contains a mapping for the specified key.
+     */
+    public boolean contains(String key) {
+        if (key == null) throw new NullPointerException("key is null");
+
+        return mCache.containsKey(key) || nativeContains(key);
+    }
+
+    private void esnureAllExtracted() {
+        if (hasHandle()) nativeExtractAll(mCache);
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (o == this) return true;
+        if (!(o instanceof RcsResourceAttributes)) return false;
+
+        final RcsResourceAttributes rhs = (RcsResourceAttributes) o;
+
+        esnureAllExtracted();
+        rhs.esnureAllExtracted();
+
+        return mCache.equals(rhs.mCache);
+    }
+
+    @Override
+    public int hashCode() {
+        esnureAllExtracted();
+        return mCache.hashCode();
+    }
+
+}
diff --git a/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/RcsValue.java b/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/RcsValue.java
new file mode 100644 (file)
index 0000000..7e916fe
--- /dev/null
@@ -0,0 +1,879 @@
+/******************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************/
+
+package org.iotivity.service;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Value holds a value among various types at a time.
+ *
+ * Type helps identify type information of Value.
+ *
+ * @see RCSResourceAttributes
+ * @see Type
+ */
+public final class RcsValue {
+
+    private static class NullType {
+        @Override
+        public String toString() {
+            return "";
+        }
+    }
+
+    /**
+     * Identifiers for types of Value.
+     *
+     * @see Type
+     */
+    public static enum TypeId {
+        NULL, BOOLEAN, INTEGER, DOUBLE, STRING, ATTRIBUTES, ARRAY;
+    }
+
+    /**
+     * A Helper class to identify types of Value.
+     *
+     * @see RCSResourceAttributes
+     * @see Value
+     * @see TypeId
+     */
+    public static class Type {
+        private final TypeId mTypeId;
+
+        Type(TypeId typeId) {
+            mTypeId = typeId;
+        }
+
+        /**
+         * Returns type identifier.
+         *
+         * @return Identifier of type
+         *
+         * @see getBaseTypeId
+         */
+        public final TypeId getTypeId() {
+            return mTypeId;
+        }
+
+        protected TypeId getBaseTypeId() {
+            return mTypeId;
+        }
+
+        protected int getDepth() {
+            return 0;
+        }
+
+        /**
+         * Returns the type identifier of a base type of sequence.
+         *
+         * For non sequence types, it is equivalent to calling getId.
+         *
+         * @return identifier of type
+         *
+         * @see getDepth
+         * @see getId
+         */
+        public static TypeId getBaseTypeId(Type t) {
+            return t.getBaseTypeId();
+        }
+
+        /**
+         * Returns the depth of a type.
+         *
+         * The return will be zero for non sequence types.
+         *
+         * @see getBaseTypeId
+         */
+        public static int getDepth(Type t) {
+            return t.getDepth();
+        }
+
+        /**
+         * Factory method to create Type instance from an object.
+         *
+         * @return An instance that has TypeId for obj.
+         *
+         * @note object must be a supported type by Value.
+         *
+         * @throws NullPointerException
+         *             if obj is null.
+         * @throws IllegalArgumentException
+         *             if obj is not supported type.
+         *
+         */
+        public static Type typeOf(Object obj) {
+            if (obj == null) {
+                throw new NullPointerException("object is null");
+            }
+
+            return typeOf(obj.getClass());
+        }
+
+        /**
+         * Factory method to create Type instance from a clss.
+         *
+         * @return An instance that has TypeId for class.
+         *
+         * @note class must be a supported type by Value.
+         *
+         * @throws NullPointerException
+         *             if cls is null.
+         * @throws IllegalArgumentException
+         *             if cls is not supported type.
+         *
+         */
+        public static Type typeOf(Class<?> cls) {
+            if (cls == null) {
+                throw new NullPointerException("class is null");
+            }
+
+            if (sTypes.containsKey(cls)) return sTypes.get(cls);
+
+            throw new IllegalArgumentException(
+                    cls.getSimpleName() + " is not supported type.");
+        }
+    }
+
+    private static class ArrayType extends Type {
+        private final TypeId mBaseTypeId;
+        private final int    mDimension;
+
+        ArrayType(TypeId baseTypeId, int dimension) {
+            super(TypeId.ARRAY);
+
+            mBaseTypeId = baseTypeId;
+            mDimension = dimension;
+        }
+
+        @Override
+        protected TypeId getBaseTypeId() {
+            return mBaseTypeId;
+        }
+
+        @Override
+        protected int getDepth() {
+            return mDimension;
+        }
+    }
+
+    private static final NullType sNullValue = new NullType();
+
+    private static Map<Class<?>, Type> sTypes;
+
+    private final Object mObject;
+    private Type         mType;
+
+    static {
+        final Map<Class<?>, Type> types = new HashMap<Class<?>, Type>();
+
+        types.put(NullType.class, new Type(TypeId.NULL));
+        types.put(Boolean.class, new Type(TypeId.BOOLEAN));
+        types.put(Integer.class, new Type(TypeId.INTEGER));
+        types.put(Double.class, new Type(TypeId.DOUBLE));
+        types.put(String.class, new Type(TypeId.STRING));
+        types.put(RcsResourceAttributes.class, new Type(TypeId.ATTRIBUTES));
+
+        types.put(boolean[].class, new ArrayType(TypeId.BOOLEAN, 1));
+        types.put(int[].class, new ArrayType(TypeId.INTEGER, 1));
+        types.put(double[].class, new ArrayType(TypeId.DOUBLE, 1));
+        types.put(String[].class, new ArrayType(TypeId.STRING, 1));
+        types.put(RcsResourceAttributes[].class,
+                new ArrayType(TypeId.ATTRIBUTES, 1));
+
+        types.put(boolean[][].class, new ArrayType(TypeId.BOOLEAN, 2));
+        types.put(int[][].class, new ArrayType(TypeId.INTEGER, 2));
+        types.put(double[][].class, new ArrayType(TypeId.DOUBLE, 2));
+        types.put(String[][].class, new ArrayType(TypeId.STRING, 2));
+        types.put(RcsResourceAttributes[][].class,
+                new ArrayType(TypeId.ATTRIBUTES, 2));
+
+        types.put(boolean[][][].class, new ArrayType(TypeId.BOOLEAN, 3));
+        types.put(int[][][].class, new ArrayType(TypeId.INTEGER, 3));
+        types.put(double[][][].class, new ArrayType(TypeId.DOUBLE, 3));
+        types.put(String[][][].class, new ArrayType(TypeId.STRING, 3));
+        types.put(RcsResourceAttributes[][][].class,
+                new ArrayType(TypeId.ATTRIBUTES, 3));
+
+        sTypes = Collections.unmodifiableMap(types);
+
+    }
+
+    static boolean isSupportedType(Class<?> cls) {
+        return sTypes.containsKey(cls);
+    }
+
+    static void verifySupportedType(Class<?> cls) {
+        if (!isSupportedType(cls)) {
+            throw new IllegalArgumentException(
+                    cls.getSimpleName() + " is not supported type.");
+        }
+    }
+
+    /**
+     * Constructs a new value with an object.
+     *
+     * @param value
+     *            An object
+     *
+     * @throws NullPointerException
+     *             if value is null.
+     * @throws IllegalArgumentException
+     *             if value is not supported type.
+     */
+    public RcsValue(Object value) {
+        if (value == null) throw new NullPointerException("value is null!");
+
+        verifySupportedType(value.getClass());
+
+        mObject = value;
+    }
+
+    /**
+     * Constructs a new value that holds null value.
+     *
+     */
+    public RcsValue() {
+        this(sNullValue);
+    }
+
+    /**
+     * Constructs a new value that holds null value.
+     *
+     * @param value
+     *            a boolean
+     */
+    public RcsValue(boolean value) {
+        this((Object) value);
+    }
+
+    /**
+     * Constructs a new value that holds an int value.
+     *
+     * @param value
+     *            an int
+     */
+    public RcsValue(int value) {
+        this((Object) value);
+    }
+
+    /**
+     * Constructs a new value that holds a double value.
+     *
+     * @param value
+     *            a double
+     */
+    public RcsValue(double value) {
+        this((Object) value);
+    }
+
+    /**
+     * Constructs a new value that holds a String value.
+     *
+     * @param value
+     *            a String
+     *
+     * @throws NullPointerException
+     *             if value is null.
+     */
+    public RcsValue(String value) {
+        this((Object) value);
+    }
+
+    /**
+     * Constructs a new value that holds a RcsResourceAttributes value.
+     *
+     * @param value
+     *            a RcsResourceAttributes
+     *
+     * @throws NullPointerException
+     *             if value is null.
+     */
+    public RcsValue(RcsResourceAttributes value) {
+        this((Object) value);
+    }
+
+    /**
+     * Constructs a new value that holds a boolean array.
+     *
+     * @param value
+     *            a boolean array
+     *
+     * @throws NullPointerException
+     *             if value is null.
+     */
+    public RcsValue(boolean[] value) {
+        this((Object) value);
+    }
+
+    /**
+     * Constructs a new value that holds a two-dimensional boolean array.
+     *
+     * @param value
+     *            a two-dimensional boolean array
+     *
+     * @throws NullPointerException
+     *             if value is null.
+     */
+    public RcsValue(boolean[][] value) {
+        this((Object) value);
+    }
+
+    /**
+     * Constructs a new value that holds a three-dimensional boolean array.
+     *
+     * @param value
+     *            a three-dimensional boolean array
+     *
+     * @throws NullPointerException
+     *             if value is null.
+     */
+    public RcsValue(boolean[][][] value) {
+        this((Object) value);
+    }
+
+    /**
+     * Constructs a new value that holds an int array.
+     *
+     * @param value
+     *            an int array
+     *
+     * @throws NullPointerException
+     *             if value is null.
+     */
+    public RcsValue(int[] value) {
+        this((Object) value);
+    }
+
+    /**
+     * Constructs a new value that holds a two-dimensional int array.
+     *
+     * @param value
+     *            a two-dimensional int array
+     *
+     * @throws NullPointerException
+     *             if value is null.
+     */
+    public RcsValue(int[][] value) {
+        this((Object) value);
+    }
+
+    /**
+     * Constructs a new value that holds a three-dimensional int array.
+     *
+     * @param value
+     *            a three-dimensional int array
+     *
+     * @throws NullPointerException
+     *             if value is null.
+     */
+    public RcsValue(int[][][] value) {
+        this((Object) value);
+    }
+
+    /**
+     * Constructs a new value that holds a double array.
+     *
+     * @param value
+     *            a double array
+     *
+     * @throws NullPointerException
+     *             if value is null.
+     */
+    public RcsValue(double[] value) {
+        this((Object) value);
+    }
+
+    /**
+     * Constructs a new value that holds a two-dimensional double array.
+     *
+     * @param value
+     *            a two-dimensional double array
+     *
+     * @throws NullPointerException
+     *             if value is null.
+     */
+    public RcsValue(double[][] value) {
+        this((Object) value);
+    }
+
+    /**
+     * Constructs a new value that holds a three-dimensional double array.
+     *
+     * @param value
+     *            a three-dimensional double array
+     *
+     * @throws NullPointerException
+     *             if value is null.
+     */
+    public RcsValue(double[][][] value) {
+        this((Object) value);
+    }
+
+    /**
+     * Constructs a new value that holds a String array.
+     *
+     * @param value
+     *            a String array
+     *
+     * @throws NullPointerException
+     *             if value is null.
+     */
+    public RcsValue(String[] value) {
+        this((Object) value);
+    }
+
+    /**
+     * Constructs a new value that holds a two-dimensional String array.
+     *
+     * @param value
+     *            a two-dimensional String array
+     *
+     * @throws NullPointerException
+     *             if value is null.
+     */
+    public RcsValue(String[][] value) {
+        this((Object) value);
+    }
+
+    /**
+     * Constructs a new value that holds a three-dimensional String array.
+     *
+     * @param value
+     *            a three-dimensional String array
+     *
+     * @throws NullPointerException
+     *             if value is null.
+     */
+    public RcsValue(String[][][] value) {
+        this((Object) value);
+    }
+
+    /**
+     * Constructs a new value that holds a RcsResourceAttributes array.
+     *
+     * @param value
+     *            a RcsResourceAttributes array
+     *
+     * @throws NullPointerException
+     *             if value is null.
+     */
+    public RcsValue(RcsResourceAttributes[] value) {
+        this((Object) value);
+    }
+
+    /**
+     * Constructs a new value that holds a two-dimensional RcsResourceAttributes
+     * array.
+     *
+     * @param value
+     *            a two-dimensional RcsResourceAttributes array
+     *
+     * @throws NullPointerException
+     *             if value is null.
+     */
+    public RcsValue(RcsResourceAttributes[][] value) {
+        this((Object) value);
+    }
+
+    /**
+     * Constructs a new value that holds a three-dimensional
+     * RcsResourceAttributes array.
+     *
+     * @param value
+     *            a three-dimensional RcsResourceAttributes array
+     *
+     * @throws NullPointerException
+     *             if value is null.
+     */
+    public RcsValue(RcsResourceAttributes[][][] value) {
+        this((Object) value);
+    }
+
+    /**
+     * Returns the value it represents is null.
+     *
+     * @return true if the value is null.
+     */
+    public boolean isNull() {
+        return isNullObject(mObject);
+    }
+
+    /**
+     * Returns the object represents null for RcsValue.
+     *
+     * @param o
+     *            an object to be tested
+     *
+     * @return true if the object represents null.
+     */
+    public static boolean isNullObject(Object o) {
+        return o == sNullValue;
+    }
+
+    /**
+     * Returns type information.
+     *
+     * @return type information for the value.
+     */
+    public Type getType() {
+        if (mType == null) mType = Type.typeOf(mObject);
+        return mType;
+    }
+
+    /**
+     * Returns the value as T.
+     *
+     * @return a value as T
+     *
+     * @throws ClassCastException
+     *             if the value is not of T.
+     */
+    @SuppressWarnings("unchecked")
+    public <T> T get() {
+        return (T) mObject;
+    }
+
+    @SuppressWarnings("unchecked")
+    private <T> T getOrNull() {
+        try {
+            return (T) mObject;
+        } catch (final ClassCastException e) {
+            return null;
+        }
+    }
+
+    /**
+     * Returns the value as an Object.
+     *
+     * @return an Object
+     */
+    public Object asObject() {
+        return mObject;
+    }
+
+    /**
+     * Returns the value as a boolean, false if the value is not the desired
+     * type.
+     *
+     * @return a boolean value
+     *
+     */
+    public boolean asBoolean() {
+        return asBoolean(false);
+    }
+
+    /**
+     * Returns the value as a boolean.
+     *
+     * @param defaultValue
+     *            value to return if the value is not boolean.
+     *
+     * @return a boolean value
+     *
+     */
+    public boolean asBoolean(boolean defaultValue) {
+        try {
+            return get();
+        } catch (final ClassCastException e) {
+            return defaultValue;
+        }
+    }
+
+    /**
+     * Returns the value as an int, 0 if the value is not the desired type.
+     *
+     * @return an int value
+     *
+     */
+    public int asInt() {
+        return asInt(0);
+    }
+
+    /**
+     * Returns the value as an int.
+     *
+     * @param defaultValue
+     *            value to return if the value is not int.
+     *
+     * @return an int value
+     *
+     */
+    public int asInt(int defaultValue) {
+        try {
+            return get();
+        } catch (final ClassCastException e) {
+            return defaultValue;
+        }
+    }
+
+    /**
+     * Returns the value as a double, 0 if the value is not the desired type.
+     *
+     * @return a double value
+     *
+     */
+    public double asDouble() {
+        return asDouble(0);
+    }
+
+    /**
+     * Returns the value as a double.
+     *
+     * @param defaultValue
+     *            value to return if the value is not double.
+     *
+     * @return a double value
+     *
+     */
+    public double asDouble(double defaultValue) {
+        try {
+            return get();
+        } catch (final ClassCastException e) {
+            return defaultValue;
+        }
+    }
+
+    /**
+     * Returns the value as a string, null if the value is not the desired type.
+     *
+     * @return a string value
+     *
+     */
+    public String asString() {
+        return asString(null);
+    }
+
+    /**
+     * Returns the value as a String.
+     *
+     * @param defaultValue
+     *            value to return if the value is not String.
+     *
+     * @return a String value
+     *
+     */
+    public String asString(String defaultValue) {
+        try {
+            return get();
+        } catch (final ClassCastException e) {
+            return defaultValue;
+        }
+    }
+
+    /**
+     * Returns the value as a RcsResourceAttributes,
+     * null if the value is not the desired type.
+     *
+     * @return a RcsResourceAttributes value
+     *
+     */
+    public RcsResourceAttributes asAttributes() {
+        return getOrNull();
+    }
+
+    /**
+     * Returns the value as a boolean array, null if the value is not the
+     * desired type.
+     *
+     * @return a boolean array
+     *
+     */
+    public boolean[] asBooleanArray() {
+        return getOrNull();
+    }
+
+    /**
+     * Returns the value as a two-dimensional boolean array, null if the value
+     * is not the desired type.
+     *
+     * @return a two-dimensional boolean array
+     *
+     */
+    public boolean[][] asBoolean2DArray() {
+        return getOrNull();
+    }
+
+    /**
+     * Returns the value as a three-dimensional boolean array, null if the value
+     * is not the desired type.
+     *
+     * @return a three-dimensional boolean array
+     *
+     */
+    public boolean[][][] asBoolean3DArray() {
+        return getOrNull();
+    }
+
+    /**
+     * Returns the value as an int array, null if the value is not the
+     * desired type.
+     *
+     * @return an int array
+     *
+     */
+    public int[] asIntArray() {
+        return getOrNull();
+    }
+
+    /**
+     * Returns the value as a two-dimensional int array, null if the value
+     * is not the desired type.
+     *
+     * @return a two-dimensional int array
+     *
+     */
+    public int[][] asInt2DArray() {
+        return getOrNull();
+    }
+
+    /**
+     * Returns the value as a three-dimensional int array, null if the value
+     * is not the desired type.
+     *
+     * @return a three-dimensional int array
+     *
+     */
+    public int[][][] asInt3DArray() {
+        return getOrNull();
+    }
+
+    /**
+     * Returns the value as a double array, null if the value is not the
+     * desired type.
+     *
+     * @return a double array
+     *
+     */
+    public double[] asDoubleArray() {
+        return getOrNull();
+    }
+
+    /**
+     * Returns the value as a two-dimensional double array, null if the value
+     * is not the desired type.
+     *
+     * @return a two-dimensional double array
+     *
+     */
+    public double[][] asDouble2DArray() {
+        return getOrNull();
+    }
+
+    /**
+     * Returns the value as a three-dimensional double array, null if the value
+     * is not the desired type.
+     *
+     * @return a three-dimensional double array
+     *
+     */
+    public double[][][] asDouble3DArray() {
+        return getOrNull();
+    }
+
+    /**
+     * Returns the value as a string array, null if the value is not the
+     * desired type.
+     *
+     * @return a string array
+     *
+     */
+    public String[] asStringArray() {
+        return getOrNull();
+    }
+
+    /**
+     * Returns the value as a two-dimensional string array, null if the value
+     * is not the desired type.
+     *
+     * @return a two-dimensional string array
+     *
+     */
+    public String[][] asString2DArray() {
+        return getOrNull();
+    }
+
+    /**
+     * Returns the value as a three-dimensional string array, null if the value
+     * is not the desired type.
+     *
+     * @return a three-dimensional string array
+     *
+     */
+    public String[][][] asString3DArray() {
+        return getOrNull();
+    }
+
+    /**
+     * Returns the value as an attributes array, null if the value is not the
+     * desired type.
+     *
+     * @return an attributes array
+     *
+     */
+    public RcsResourceAttributes[] asAttributesArray() {
+        return getOrNull();
+    }
+
+    /**
+     * Returns the value as a two-dimensional attributes array, null if the
+     * value is not the desired type.
+     *
+     * @return a two-dimensional attributes array
+     *
+     */
+    public RcsResourceAttributes[][] asAttributes2DArray() {
+        return getOrNull();
+    }
+
+    /**
+     * Returns the value as a three-dimensional attributes array, null if the
+     * value is not the desired type.
+     *
+     * @return a three-dimensional attributes array
+     *
+     */
+    public RcsResourceAttributes[][][] asAttributes3DArray() {
+        return getOrNull();
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (o == this) return true;
+        if (!(o instanceof RcsValue)) return false;
+
+        final RcsValue rhs = (RcsValue) o;
+
+        return mObject.equals(rhs.mObject);
+    }
+
+    @Override
+    public int hashCode() {
+        return mObject.hashCode();
+    }
+
+    @Override
+    public String toString() {
+        return mObject.toString();
+    }
+
+}
diff --git a/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/client/RcsAddress.java b/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/client/RcsAddress.java
new file mode 100644 (file)
index 0000000..4864b81
--- /dev/null
@@ -0,0 +1,64 @@
+/******************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************/
+
+package org.iotivity.service.client;
+
+/**
+ * This class provides a set of APIs for constructing RCSAddress object.
+ *
+ * <p>
+ * RCSAddress object is the first parameter for Discover Resource APIs of
+ * RCSDiscoveryManager Class.
+ * <p>
+ * {@link RcsDiscoveryManager}
+ */
+public final class RcsAddress {
+    private final String mAddress;
+
+    private RcsAddress(String addr) {
+        mAddress = addr;
+    }
+
+    /**
+     * Factory method for multicast.
+     *
+     */
+    public static RcsAddress multicast() {
+        return new RcsAddress(null);
+    }
+
+    /**
+     * Factory method for unicast.
+     *
+     * @param address
+     *            A physical address for the target.
+     *
+     * @throws NullPointerException
+     *             If address is null.
+     */
+    public static RcsAddress unicast(String address) {
+        if (address == null) throw new NullPointerException("address is null.");
+        return new RcsAddress(address);
+    }
+
+    String getAddress() {
+        return mAddress;
+    }
+}
diff --git a/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/client/RcsDiscoveryManager.java b/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/client/RcsDiscoveryManager.java
new file mode 100644 (file)
index 0000000..6e6e934
--- /dev/null
@@ -0,0 +1,188 @@
+/******************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************/
+
+package org.iotivity.service.client;
+
+import org.iotivity.service.RcsException;
+import org.iotivity.service.RcsObject;
+import org.iotivity.service.RcsPlatformException;
+
+/**
+ * This class contains the resource discovery methods.
+ *
+ * @see RcsRemoteResourceObject
+ */
+public final class RcsDiscoveryManager {
+
+    static {
+        System.loadLibrary("gnustl_shared");
+        System.loadLibrary("oc_logger");
+        System.loadLibrary("connectivity_abstraction");
+        System.loadLibrary("ca-interface");
+        System.loadLibrary("octbstack");
+        System.loadLibrary("oc");
+        System.loadLibrary("rcs_client");
+        System.loadLibrary("rcs_server");
+        System.loadLibrary("rcs_common");
+        System.loadLibrary("rcs_container");
+        System.loadLibrary("rcs_jni");
+    }
+
+    public static class DiscoveryTask extends RcsObject {
+        private DiscoveryTask() {
+        }
+
+        public void cancel() {
+            dispose();
+        }
+    }
+
+    /**
+     * Interface definition for a callback to be invoked when a resource is
+     * discovered.
+     *
+     */
+    public interface OnResourceDiscoveredListener {
+
+        /**
+         * Called when a resource is discovered.
+         *
+         * @param rcsRemoteResourceObject
+         *            a discovered remote resource
+         *
+         */
+        void onResourceDiscovered(
+                RcsRemoteResourceObject rcsRemoteResourceObject);
+
+    }
+
+    private static final RcsDiscoveryManager sInstance = new RcsDiscoveryManager();
+
+    private native DiscoveryTask nativeDiscoverResource(String address,
+            String relativeUri, String resourceType,
+            OnResourceDiscoveredListener listener);
+
+    private RcsDiscoveryManager() {
+    }
+
+    public static RcsDiscoveryManager getInstance() {
+        return sInstance;
+    }
+
+    /**
+     * Requests discovery for the resource of interest, regardless of uri and
+     * resource type
+     *
+     * @param address
+     *            the target address
+     *
+     * @return a task object indicating this request.
+     *
+     * @throws RcsPlatformException
+     *             if the operation failed.
+     * @throws NullPointerException
+     *             if address or listener is null.
+     *
+     */
+    public DiscoveryTask discoverResource(RcsAddress address,
+            OnResourceDiscoveredListener listener) throws RcsException {
+        return discoverResourceByType(address, null, null, listener);
+    }
+
+    /**
+     * Requests discovery for the resource of interest, regardless of resource
+     * type.
+     *
+     * @param address
+     *            the target address
+     * @param uri
+     *            the relative uri of resource to be searched
+     * 
+     * @return a task object indicating this request.
+     *
+     * @throws RcsPlatformException
+     *             if the operation failed.
+     * @throws NullPointerException
+     *             if address or listener is null.
+     *
+     */
+    public DiscoveryTask discoverResource(RcsAddress address, String uri,
+            OnResourceDiscoveredListener listener) throws RcsException {
+        return discoverResourceByType(address, uri, null, listener);
+    }
+
+    /**
+     * Requests discovery for the resource of interest by resource type.
+     *
+     * @param address
+     *            the target address
+     * @param resourceType
+     *            the resource type
+     *
+     * @return a task object indicating this request.
+     *
+     * @throws RcsPlatformException
+     *             if the operation failed.
+     * @throws NullPointerException
+     *             if address or listener is null.
+     *
+     *
+     */
+    public DiscoveryTask discoverResourceByType(RcsAddress address,
+            String resourceType, OnResourceDiscoveredListener listener)
+                    throws RcsException {
+        return discoverResourceByType(address, null, resourceType, listener);
+    }
+
+    /**
+     * Requests discovery for the resource of interest by resource type with
+     * provided relative uri.
+     *
+     * @param address
+     *            the target address
+     * @param uri
+     *            the relative uri of resource to be searched
+     * @param resourceType
+     *            the resource type
+     *
+     * @return a task object indicating this request.
+     *
+     * @throws RcsPlatformException
+     *             if the operation failed.
+     * @throws NullPointerException
+     *             if address or listener is null.
+     *
+     *
+     */
+    public DiscoveryTask discoverResourceByType(RcsAddress address, String uri,
+            String resourceType, OnResourceDiscoveredListener listener)
+                    throws RcsException {
+        if (listener == null) {
+            throw new NullPointerException("listener is null.");
+        }
+        if (address == null) {
+            throw new NullPointerException("address is null.");
+        }
+
+        return nativeDiscoverResource(address.getAddress(), uri, resourceType,
+                listener);
+    }
+
+}
diff --git a/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/client/RcsRemoteResourceObject.java b/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/client/RcsRemoteResourceObject.java
new file mode 100644 (file)
index 0000000..0577dab
--- /dev/null
@@ -0,0 +1,585 @@
+/******************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************/
+
+package org.iotivity.service.client;
+
+import org.iotivity.service.RcsDestroyedObjectException;
+import org.iotivity.service.RcsException;
+import org.iotivity.service.RcsIllegalStateException;
+import org.iotivity.service.RcsObject;
+import org.iotivity.service.RcsPlatformException;
+import org.iotivity.service.RcsResourceAttributes;
+import org.iotivity.service.RcsValue;
+import org.iotivity.service.server.RcsResourceObject;
+
+/**
+ *
+ * This represents a remote resource and provides simple ways to interact with
+ * it.
+ * Basically this is a client of a remote resource that runs on other device.
+ *
+ * The class supports features to help get information of a remote resource
+ * such as monitoring and caching.
+ *
+ * @see RcsDiscoveryManager
+ *
+ */
+public final class RcsRemoteResourceObject extends RcsObject {
+
+    private native boolean nativeIsMonitoring();
+
+    private native boolean nativeIsCaching();
+
+    private native boolean nativeIsObservable();
+
+    private native void nativeStartMonitoring(OnStateChangedListener listener);
+
+    private native void nativeStopMonitoring();
+
+    private native ResourceState nativeGetState();
+
+    private native void nativeStartCaching(OnCacheUpdatedListener listener);
+
+    private native void nativeStopCaching();
+
+    private native CacheState nativeGetCacheState();
+
+    private native boolean nativeIsCachedAvailable();
+
+    private native RcsResourceAttributes nativeGetCachedAttributes();
+
+    private native void nativeGetRemoteAttributes(
+            OnRemoteAttributesReceivedListener listener);
+
+    private native void nativeSetRemoteAttributes(
+            RcsResourceAttributes attributes,
+            OnRemoteAttributesReceivedListener listener);
+
+    private native String nativeGetUri();
+
+    private native String nativeGetAddress();
+
+    private native String[] nativeGetTypes();
+
+    private native String[] nativeGetInterfaces();
+
+    private RcsRemoteResourceObject() {
+    }
+
+    /**
+     * This represents states of monitoring.
+     *
+     * @see #startMonitoring()
+     * @see #getState()
+     * @see OnStateChangedListener
+     *
+     */
+    public enum ResourceState {
+
+        NONE, /** < Monitoring is not started. */
+        REQUESTED, /**
+                    * < Monitoring is started and checking state is in progress.
+                    * This is the default state after startMonitoring.
+                    */
+        ALIVE, /** < The resource is alive. */
+        LOST_SIGNAL, /** < Failed to reach the resource. */
+        DESTROYED /** < The resource is deleted. */
+    }
+
+    /**
+     * This represents states of caching.
+     *
+     * @see #startCaching()
+     * @see #getCacheState()
+     */
+    public enum CacheState {
+
+        NONE, /** < Caching is not started. */
+        UNREADY, /**
+                  * < Caching is started, but the data is not ready yet. This is
+                  * the default state after startCaching.
+                  */
+        READY, /** < The data is ready. */
+        LOST_SIGNAL /** < Failed to reach the resource. */
+    }
+
+    /**
+     * Interface definition for a callback to be invoked when the cache is
+     * updated.
+     *
+     * @see #startCaching(OnCacheUpdatedListener)
+     */
+    public interface OnCacheUpdatedListener {
+
+        /**
+         * Called when the cache is updated.
+         *
+         * @param attributes
+         *            the updated attributes
+         *
+         */
+        public void onCacheUpdated(RcsResourceAttributes attributes);
+
+    }
+
+    /**
+     * Interface definition for a callback to be invoked when the response of
+     * getRemoteAttributes and setRemoteAttributes is received.
+     *
+     * @see #getRemoteAttributes(OnRemoteAttributesReceivedListener)
+     * @see #setRemoteAttributes(RcsResourceAttributes,
+     *      OnRemoteAttributesReceivedListener)
+     */
+    public interface OnRemoteAttributesReceivedListener {
+
+        /**
+         * Called when a response for the getRemoteAttributes request or
+         * setRemoteAttributes request is received.
+         *
+         * @param attributes
+         *            the resource attributes received from the remote resource
+         *
+         */
+        public void onAttributesReceived(RcsResourceAttributes attributes,
+                int errorCode);
+
+    }
+
+    /**
+     * Interface definition for a callback to be invoked when the monitoring
+     * state is changed.
+     *
+     * @see #startMonitoring(OnStateChangedListener)
+     */
+    public interface OnStateChangedListener {
+
+        /**
+         * Called when the monitoring state is changed.
+         *
+         * @param resourceState
+         *            updated state
+         *
+         */
+        public void onStateChanged(ResourceState resourceState);
+    }
+
+    private void assertAlive() throws RcsException {
+        if (!hasHandle()) {
+            throw new RcsDestroyedObjectException(
+                    "The object is already destroyed!");
+        }
+    }
+
+    /**
+     * Returns whether monitoring is enabled.
+     *
+     * @return true if monitoring the resource.
+     *
+     * @throws RcsDestroyedObjectException
+     *             if the object is already destroyed
+     *
+     * @see #startMonitoring(OnStateChangedListener)
+     */
+    public boolean isMonitoring() throws RcsException {
+        assertAlive();
+        return nativeIsMonitoring();
+    }
+
+    /**
+     * Returns whether caching is enabled.
+     *
+     * @return true if caching the resource.
+     *
+     * @throws RcsDestroyedObjectException
+     *             if the object is already destroyed
+     *
+     * @see #startCaching()
+     * @see #startCaching(OnCacheUpdatedListener)
+     *
+     */
+    public boolean isCaching() throws RcsException {
+        assertAlive();
+        return nativeIsCaching();
+    }
+
+    /**
+     * Returns whether resource is observable.
+     *
+     * @return true if resource is observable.
+     *
+     * @throws RcsDestroyedObjectException
+     *             if the object is already destroyed
+     *
+     * @see RcsResourceObject.Builder#setObservable(boolean)
+     */
+    public boolean isObservable() throws RcsException {
+        assertAlive();
+        return nativeIsObservable();
+    }
+
+    /**
+     * Starts monitoring the resource.
+     * <p>
+     * Monitoring provides a feature to check the presence of a resource, even
+     * when the server is not announcing Presence using startPresnece.
+     *
+     * @param listener
+     *            the listener to receive new state.
+     *
+     * @throws NullPointerException
+     *             if listener is null
+     * @throws RcsIllegalStateException
+     *             if monitoring is already started
+     * @throws RcsDestroyedObjectException
+     *             if the object is already destroyed
+     *
+     * @see ResourceState
+     * @see #isMonitoring()
+     * @see #stopMonitoring()
+     */
+    public void startMonitoring(OnStateChangedListener listener)
+            throws RcsException {
+        assertAlive();
+        if (listener == null) {
+            throw new NullPointerException("listener is null.");
+        }
+
+        nativeStartMonitoring(listener);
+    }
+
+    /**
+     * Stops monitoring the resource.
+     * <p>
+     * It does nothing if monitoring is not started.
+     *
+     * @throws RcsDestroyedObjectException
+     *             if the object is already destroyed
+     *
+     * @see #startMonitoring(OnStateChangedListener)
+     * @see #isMonitoring()
+     */
+    public void stopMonitoring() throws RcsException {
+        assertAlive();
+        nativeStopMonitoring();
+    }
+
+    /**
+     * Returns the current state of the resource.
+     *
+     * @return ResourceState - current resource state
+     *
+     * @throws RcsDestroyedObjectException
+     *             if the object is already destroyed
+     *
+     * @see #startMonitoring(OnStateChangedListener)
+     * @see #isMonitoring()
+     * @see OnStateChangedListener
+     */
+    public ResourceState getState() throws RcsException {
+        assertAlive();
+        return nativeGetState();
+    }
+
+    /**
+     * Starts caching attributes of the resource.
+     *
+     * This will start data caching for the resource. Once caching started it
+     * will look for the data updation on the resource and updates the cache
+     * data accordingly.
+     *
+     * It is equivalent to calling startCaching(CacheUpdatedCallback) with null.
+     *
+     * @throws RcsDestroyedObjectException
+     *             if the object is already destroyed
+     *
+     * @see #startCaching(OnCacheUpdatedListener)
+     * @see #isCaching()
+     * @see #getCacheState()
+     * @see #getCachedAttribute(String)
+     * @see #getCachedAttributes()
+     * @see OnCacheUpdatedListener
+     */
+    public void startCaching() throws RcsException {
+        assertAlive();
+        startCaching(null);
+    }
+
+    /**
+     * Starts caching attributes of the resource.
+     *
+     * This will start data caching for the resource. Once caching started it
+     * will look for the data updation on the resource and updates the cache
+     * data accordingly.
+     *
+     * @param listener
+     *            the listener to be notified when attributes are updated or
+     *            null if no need
+     *
+     * @throws RcsDestroyedObjectException
+     *             if the object is already destroyed
+     *
+     * @see #startCaching()
+     * @see #isCaching()
+     * @see #getCacheState()
+     * @see #getCachedAttribute(String)
+     * @see #getCachedAttributes()
+     * @see OnCacheUpdatedListener
+     */
+    public void startCaching(OnCacheUpdatedListener listener)
+            throws RcsException {
+        assertAlive();
+        nativeStartCaching(listener);
+    }
+
+    /**
+     * Stops caching.
+     *
+     * It does nothing if caching is not started.
+     *
+     * @throws RcsDestroyedObjectException
+     *             if the object is already destroyed
+     *
+     * @see #startCaching()
+     * @see #startCaching(OnCacheUpdatedListener)
+     * @see #isCaching()
+     *
+     */
+    public void stopCaching() throws RcsException {
+        assertAlive();
+        nativeStopCaching();
+    }
+
+    /**
+     * Returns the current cache state.
+     *
+     * @return current cache state.
+     *
+     * @throws RcsDestroyedObjectException
+     *             if the object is already destroyed
+     *
+     * @see #startCaching()
+     * @see #startCaching(OnCacheUpdatedListener)
+     * @see #isCaching()
+     */
+    public CacheState getCacheState() throws RcsException {
+        assertAlive();
+        return nativeGetCacheState();
+    }
+
+    /**
+     * Returns whether cached data is available.
+     *
+     * Cache will be available always once cache state had been READY even if
+     * current state is LOST_SIGNAL.
+     *
+     * @return true if cache data is available.
+     *
+     * @throws RcsDestroyedObjectException
+     *             if the object is already destroyed
+     *
+     * @see #startCaching()
+     * @see #startCaching(OnCacheUpdatedListener)
+     * @see #isCaching()
+     * @see #getCacheState()
+     *
+     */
+    public boolean isCachedAvailable() throws RcsException {
+        assertAlive();
+        return nativeIsCachedAvailable();
+    }
+
+    /**
+     * Returns the cached attributes.
+     * This works only when cache is available.
+     *
+     * @return the cached attributes.
+     *
+     * @throws RcsIllegalStateException
+     *             if cache is not available
+     * @throws RcsDestroyedObjectException
+     *             if the object is already destroyed
+     *
+     * @see #startCaching()
+     * @see #startCaching(OnCacheUpdatedListener)
+     * @see #isCaching()
+     * @see #getCacheState()
+     * @see #isCachedAvailable()
+     * @see #getCachedAttribute(String)
+     *
+     */
+    public RcsResourceAttributes getCachedAttributes() throws RcsException {
+        assertAlive();
+        return nativeGetCachedAttributes();
+    }
+
+    /**
+     * Returns the cached value to which the specified key is mapped, or null if
+     * RcsResourceAttributes contains no mapping for the key.
+     *
+     * This works only when cache is available.
+     *
+     * @param key
+     *            the key whose associated value is to be returned
+     *
+     * @return the value to which the specified key is mapped, or null if no
+     *         mapping for the key
+     *
+     * @throws NullPointerException
+     *             if key is null
+     * @throws RcsIllegalStateException
+     *             if cache is not available
+     * @throws RcsDestroyedObjectException
+     *             if the object is already destroyed
+     *
+     * @see #startCaching()
+     * @see #startCaching(OnCacheUpdatedListener)
+     * @see #isCaching()
+     * @see #getCacheState()
+     * @see #isCachedAvailable()
+     * @see #getCachedAttributes()
+     *
+     */
+    public RcsValue getCachedAttribute(String key) throws RcsException {
+        assertAlive();
+        if (key == null) {
+            throw new NullPointerException("key is null.");
+        }
+
+        return getCachedAttributes().get(key);
+    }
+
+    /**
+     * Sends a request for the resource attributes directly to the server.
+     *
+     * @param listener
+     *            the listener to receive the response
+     *
+     * @throws NullPointerException
+     *             if listener is null
+     * @throws RcsDestroyedObjectException
+     *             if the object is already destroyed
+     * @throws RcsPlatformException
+     *             if the operation failed
+     *
+     * @see OnRemoteAttributesReceivedListener
+     */
+    public void getRemoteAttributes(OnRemoteAttributesReceivedListener listener)
+            throws RcsException {
+        assertAlive();
+        if (listener == null) {
+            throw new NullPointerException("listener is null.");
+        }
+
+        nativeGetRemoteAttributes(listener);
+    }
+
+    /**
+     * Sends a set request with resource attributes to the server.
+     *
+     * The SetRequest behavior depends on the server, whether updating its
+     * attributes or not.
+     *
+     * @param attributes
+     *            attributes to set for the remote resource.
+     *
+     * @throws NullPointerException
+     *             if attributes or listener is null
+     * @throws RcsDestroyedObjectException
+     *             if the object is already destroyed
+     * @throws RcsPlatformException
+     *             if the operation failed
+     *
+     * @see OnRemoteAttributesReceivedListener
+     */
+    public void setRemoteAttributes(RcsResourceAttributes attributes,
+            OnRemoteAttributesReceivedListener listener) throws RcsException {
+        assertAlive();
+
+        if (attributes == null) {
+            throw new NullPointerException("attributes is null.");
+        }
+        if (listener == null) {
+            throw new NullPointerException("listener is null.");
+        }
+
+        nativeSetRemoteAttributes(attributes, listener);
+    }
+
+    /**
+     * Returns the uri of the resource.
+     *
+     * @return uri of the resource
+     *
+     * @throws RcsDestroyedObjectException
+     *             if the object is already destroyed
+     */
+    public String getUri() throws RcsException {
+        assertAlive();
+        return nativeGetUri();
+    }
+
+    /**
+     * Returns the address of the resource .
+     *
+     * @return address of the resource
+     *
+     * @throws RcsDestroyedObjectException
+     *             if the object is already destroyed
+     */
+    public String getAddress() throws RcsException {
+        assertAlive();
+        return nativeGetAddress();
+    }
+
+    /**
+     * Returns the resource types of the resource.
+     *
+     * @return resource types
+     *
+     * @throws RcsDestroyedObjectException
+     *             if the object is already destroyed
+     */
+    public String[] getTypes() throws RcsException {
+        assertAlive();
+        return nativeGetTypes();
+    }
+
+    /**
+     * Returns the resource interfaces of the resource.
+     *
+     * @return resource interfaces
+     *
+     * @throws RcsDestroyedObjectException
+     *             if the object is already destroyed
+     */
+    public String[] getInterfaces() throws RcsException {
+        assertAlive();
+        return nativeGetInterfaces();
+    }
+
+    /**
+     * Reclaims all resources used by this object.
+     * This must be called if the resource is not used any longer.
+     *
+     */
+    public void destroy() {
+        super.dispose();
+    }
+}
  * limitations under the License.
  *
  ******************************************************************/
+
 /**
  * @file
  * This file contains RCSBundleInfo class, which provides APIs related to Bundle information.
  */
+package org.iotivity.service.server;
 
-package org.iotivity.ResourceEncapsulation.server;
+import org.iotivity.service.RcsObject;
 
 /**
  * This class provides APIs for getting and setting the Bundle Information
  */
-public class RCSBundleInfo {
-
-    private long    m_nativeHandle;
-    private boolean m_nativeNeedsDelete;
-
-    // native methods
+public class RcsBundleInfo extends RcsObject {
     private native String nativeGetID();
 
     private native String nativeGetPath();
@@ -43,42 +40,34 @@ public class RCSBundleInfo {
 
     private native String nativeGetVersion();
 
-    private native void nativeSetID(String id);
-
-    private native void nativeSetPath(String path);
-
-    private native void nativeSetActivatorName(String activatorName);
-
-    private native void nativeSetLibraryPath(String libraryPath);
-
-    private native void nativeSetVersion(String version);
-
-    private RCSBundleInfo(long nativeHandle) {
-        this.m_nativeHandle = nativeHandle;
+    private RcsBundleInfo() {
     }
 
     /**
      * API for getting the Id of the bundle
      *
      * @return string - Id of the bundle
+     *
      */
     public String getID() {
-        return this.nativeGetID();
+        return nativeGetID();
     }
 
     /**
      * API for getting the path of the bundle
      *
      * @return path - path of the bundle
+     *
      */
     public String getPath() {
-        return this.nativeGetPath();
+        return nativeGetPath();
     }
 
     /**
      * API for setting the Activator name for the bundle
      *
      * @return string - Name of the activator
+     *
      */
     public String getActivatorName() {
         return nativeGetActivatorName();
@@ -88,6 +77,7 @@ public class RCSBundleInfo {
      * API for getting the library path for the bundle
      *
      * @return string - Library path in string form
+     *
      */
     public String getLibraryPath() {
         return nativeGetLibraryPath();
@@ -97,58 +87,10 @@ public class RCSBundleInfo {
      * API for getting the version of the bundle
      *
      * @return string - version of the bundle
+     *
      */
     public String getVersion() {
         return nativeGetVersion();
     }
 
-    /**
-     * API for setting the Id of the bundle
-     *
-     * @param id
-     *            - Id of the bundle in string form
-     */
-    public void setID(String id) {
-        this.nativeSetID(id);
-    }
-
-    /**
-     * API for setting the path of the bundle
-     *
-     * @param path
-     *            - path of the bundle in string form
-     */
-    public void setPath(String path) {
-        this.nativeSetPath(path);
-    }
-
-    /**
-     * API for setting the Activator name for the bundle
-     *
-     * @param activatorName
-     *            - Activator name in string form
-     */
-    public void setActivatorName(String activatorName) {
-        this.nativeSetActivatorName(activatorName);
-    }
-
-    /**
-     * API for setting the library path for the bundle
-     *
-     * @param libraryPath
-     *            - Library path in string form
-     */
-    public void setLibraryPath(String libraryPath) {
-        this.nativeSetLibraryPath(libraryPath);
-    }
-
-    /**
-     * API for setting the version of the bundle
-     *
-     * @param version
-     *            - version of the bundle in string form
-     */
-    public void setVersion(String version) {
-        this.nativeSetVersion(version);
-    }
 }
diff --git a/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsGetResponse.java b/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsGetResponse.java
new file mode 100644 (file)
index 0000000..7809275
--- /dev/null
@@ -0,0 +1,101 @@
+/******************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************/
+
+package org.iotivity.service.server;
+
+import org.iotivity.service.RcsResourceAttributes;
+
+/**
+ * This class provides methods to create the response for a received get
+ * request.
+ *
+ * @see RcsResourceObject
+ * @see RcsSetResponse
+ */
+public class RcsGetResponse extends RcsResponse {
+
+    /**
+     * Creates a default RcsResourceObject. The response will have
+     * RCSResponse.DEFAULT_ERROR_CODE for the errorCode. The attributes of
+     * RCSResourceObject will be set as the result attributes.
+     *
+     */
+    public static RcsGetResponse defaultAction() {
+        return new RcsGetResponse();
+    }
+
+    /**
+     * Creates a RcsResourceObject with error code passed. The
+     * attributes of the RCSResourceObject will be set as the result attributes.
+     *
+     * @param errorCode
+     *            The error code to set in response.
+     *
+     */
+    public static RcsGetResponse create(int errorCode) {
+        return new RcsGetResponse(errorCode);
+
+    }
+
+    /**
+     * Creates a RcsResourceObject with custom attributes. This sends the passed
+     * attributes as the result attributes instead of the one the
+     * RCSResourceObject holds.
+     *
+     * @param attributes
+     *            The attributes to send in response.
+     *
+     */
+    public static RcsGetResponse create(RcsResourceAttributes attributes) {
+        return new RcsGetResponse(attributes);
+    }
+
+    /**
+     * Creates a RcsResourceObject with error code passed. This sends
+     * the passed attributes as the result attributes instead of one the
+     * RCSResourceObject holds.
+     *
+     * @param attributes
+     *            The attributes to send in response.
+     * @param errorCode
+     *            The error code for response.
+     *
+     */
+    public static RcsGetResponse create(RcsResourceAttributes attributes,
+            int errorCode) {
+        return new RcsGetResponse(attributes, errorCode);
+    }
+
+    private RcsGetResponse() {
+        super();
+    }
+
+    private RcsGetResponse(int errorCode) {
+        super(errorCode);
+    }
+
+    private RcsGetResponse(RcsResourceAttributes attrs) {
+        super(attrs);
+    }
+
+    private RcsGetResponse(RcsResourceAttributes attrs, int errorCode) {
+        super(attrs, errorCode);
+    }
+}
diff --git a/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsLockedAttributes.java b/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsLockedAttributes.java
new file mode 100644 (file)
index 0000000..13381d2
--- /dev/null
@@ -0,0 +1,208 @@
+/******************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************/
+
+package org.iotivity.service.server;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.iotivity.service.RcsException;
+import org.iotivity.service.RcsObject;
+import org.iotivity.service.RcsResourceAttributes;
+import org.iotivity.service.RcsValue;
+
+public final class RcsLockedAttributes extends RcsObject {
+
+    private static native boolean nativeIsEmpty(RcsResourceObject resourceObj);
+
+    private static native int nativeSize(RcsResourceObject resourceObj);
+
+    private static native boolean nativeRemove(RcsResourceObject resourceObj,
+            String key);
+
+    private static native boolean nativeClear(RcsResourceObject resourceObj);
+
+    private static native boolean nativeContains(RcsResourceObject resourceObj,
+            String key);
+
+    private static native void nativeAddKeys(RcsResourceObject resourceObj,
+            Set<String> set);
+
+    private static native RcsValue nativeAsJavaObject(
+            RcsResourceObject resourceObj, String key);
+
+    private static native void nativeApply(RcsResourceObject resourceObj,
+            Map<String, RcsValue> cache);
+
+    private native void nativeLock(RcsResourceObject resourceObj);
+
+    private native void nativeUnlock();
+
+    private final RcsResourceObject mResourceObject;
+
+    private boolean mIsUnlocked;
+
+    private Map<String, RcsValue> mCache = new HashMap<>();
+
+    RcsLockedAttributes(RcsResourceObject resourceObject) throws RcsException {
+        if (resourceObject == null) {
+            throw new RcsException("Illegal opertaion!");
+        }
+
+        mResourceObject = resourceObject;
+
+        nativeLock(resourceObject);
+    }
+
+    void setUnlockState() {
+        mIsUnlocked = true;
+        mCache = null;
+
+        nativeUnlock();
+    }
+
+    void apply() {
+        nativeApply(mResourceObject, mCache);
+        mCache.clear();
+    }
+
+    private void ensureLocked() throws RcsException {
+        if (mIsUnlocked) {
+            throw new RcsUnlockedException("This attributes is unlocked!");
+        }
+    }
+
+    public Set<String> keySet() throws RcsException {
+        ensureLocked();
+
+        final Set<String> keySet = new HashSet<>(mCache.keySet());
+
+        nativeAddKeys(mResourceObject, keySet);
+
+        return Collections.unmodifiableSet(keySet);
+    }
+
+    public RcsValue get(String key) throws RcsException {
+        ensureLocked();
+
+        if (key == null) throw new NullPointerException("key is null");
+
+        if (!mCache.containsKey(key) && nativeContains(mResourceObject, key)) {
+            mCache.put(key, nativeAsJavaObject(mResourceObject, key));
+        }
+        return mCache.get(key);
+    }
+
+    public RcsLockedAttributes putAll(RcsResourceAttributes attributes) {
+        final Set<String> keys = attributes.keySet();
+
+        for (final String k : keys) {
+            mCache.put(k, attributes.get(k));
+        }
+        return this;
+    }
+
+    /**
+     * set a attribute value.
+     *
+     * @param key
+     *            - Key of the element to be added.
+     *
+     * @param value
+     *            - value to be set.
+     *
+     */
+    public RcsLockedAttributes put(String key, RcsValue value)
+            throws RcsException {
+        ensureLocked();
+
+        if (key == null) throw new NullPointerException("key is null");
+        if (value == null) throw new NullPointerException("value is null");
+
+        mCache.put(key, value);
+
+        return this;
+    }
+
+    /**
+     * Returns whether attribute is empty.
+     *
+     * @return boolean
+     */
+    public boolean isEmpty() throws RcsException {
+        ensureLocked();
+
+        return mCache.isEmpty() && nativeIsEmpty(mResourceObject);
+    }
+
+    /**
+     * Returns the number of elements.
+     *
+     */
+    public int size() throws RcsException {
+        ensureLocked();
+
+        return mCache.size() + nativeSize(mResourceObject);
+    }
+
+    /**
+     * Removes a single attribute
+     *
+     * @param key
+     *            Key to be removed.
+     *
+     * @return true if an attribute is removed, false otherwise.
+     */
+    public boolean remove(String key) throws RcsException {
+        ensureLocked();
+
+        if (key == null) throw new NullPointerException("key is null");
+
+        // XXX make sure both cache and native values to be removed.
+        final boolean cacheRemove = mCache.remove(key) != null;
+        final boolean nativeRemove = nativeRemove(mResourceObject, key);
+
+        return cacheRemove || nativeRemove;
+    }
+
+    public void clear() {
+        nativeClear(mResourceObject);
+    }
+
+    /**
+     * Checks the container has an attribute with a Key equivalent to the
+     * provided key.
+     *
+     * @param key
+     *            Key to check.
+     *
+     * @return true if an attribute with requests key exists, false otherwise.
+     */
+    public boolean contains(String key) throws RcsException {
+        ensureLocked();
+
+        if (key == null) throw new NullPointerException("key is null");
+
+        return mCache.containsKey(key) || nativeContains(mResourceObject, key);
+    }
+}
  * limitations under the License.
  *
  ******************************************************************/
-/**
- * @file
- * This file provides RCSRequest class which will describes the request.
- */
 
-package org.iotivity.ResourceEncapsulation.server;
+package org.iotivity.service.server;
 
 /**
  * This class describes the request.
  */
-public class RCSRequest {
+public class RcsRequest {
 
-    private String m_resourceUri;
+    private final String mUri;
 
-    private RCSRequest(String resourceUri) {
-        m_resourceUri = resourceUri;
+    private RcsRequest(String resourceUri) {
+        mUri = resourceUri;
     }
 
     /**
@@ -41,6 +37,6 @@ public class RCSRequest {
      * @return Uri of the request in string form
      */
     public String getResourceUri() {
-        return m_resourceUri;
+        return mUri;
     }
 }
  * limitations under the License.
  *
  ******************************************************************/
+
 /**
  * @file
  * This file contains the Resource Container APIs
  */
-
-package org.iotivity.ResourceEncapsulation.server;
+package org.iotivity.service.server;
 
 import java.util.List;
 import java.util.Map;
 
+// TODO null check for parameters
 /**
  * This class provides APIs for managing the container and bundles in the
  * container.
  */
-public class RCSResourceContainer {
+public class RcsResourceContainer {
 
     static {
         System.loadLibrary("gnustl_shared");
         System.loadLibrary("oc_logger");
-        System.loadLibrary("oc_logger_core");
         System.loadLibrary("connectivity_abstraction");
         System.loadLibrary("ca-interface");
         System.loadLibrary("octbstack");
         System.loadLibrary("oc");
-        System.loadLibrary("ocstack-jni");
         System.loadLibrary("rcs_client");
         System.loadLibrary("rcs_server");
         System.loadLibrary("rcs_common");
         System.loadLibrary("rcs_container");
-        System.loadLibrary("re-jni");
+        System.loadLibrary("rcs_jni");
     }
 
-    private static RCSResourceContainer rcsResourceContainerInstance;
+    private static RcsResourceContainer sInstance = new RcsResourceContainer();
 
-    // native methods
     private native void nativeStartContainer(String configFile);
 
     private native void nativeStopContainer();
 
     private native void nativeAddBundle(String bundleId, String bundleUri,
-            String bundlePath, Map<String, String> params);
+            String bundlePath, String activator, Map<String, String> params);
 
     private native void nativeRemoveBundle(String bundleId);
 
-    private native List<RCSBundleInfo> nativeListBundles();
+    private native List<RcsBundleInfo> nativeListBundles();
 
     private native void nativeStartBundle(String bundleId);
 
@@ -78,15 +76,9 @@ public class RCSResourceContainer {
     /**
      * API for getting the Instance of ResourceContainer class
      *
-     * @return RCSResourceContainer - Instance of the "RCSResourceContainer"
-     *         class
-     *
      */
-    public static RCSResourceContainer getInstance() {
-        if (null == rcsResourceContainerInstance) {
-            rcsResourceContainerInstance = new RCSResourceContainer();
-        }
-        return rcsResourceContainerInstance;
+    public static RcsResourceContainer getInstance() {
+        return sInstance;
     }
 
     /**
@@ -96,123 +88,127 @@ public class RCSResourceContainer {
      * This API start the container with the provided Configuration file.
      *
      * @param configFile
-     *            configuration File that contains the Bundle/Bundles
+     *            configuration File that contains the Bundle/Bundles
      *            information.
      *
      */
     public void startContainer(String configFile) {
-        this.nativeStartContainer(configFile);
+        nativeStartContainer(configFile);
     }
 
     /**
      * API for stopping the Container
      */
     public void stopContainer() {
-        this.nativeStopContainer();
+        nativeStopContainer();
     }
 
     /**
      * API for getting the list of all bundles in the container
      *
-     * @return list -List of BundleInfo objects each associated with a bundle
+     * @return list<RCSBundleInfo> -List of BundleInfo objects each associated
+     *         with a bundle
      *
-     *         {@link RCSBundleInfo}
+     *         {@link RcsBundleInfo}
      */
-    public List<RCSBundleInfo> listBundles() {
-        return this.nativeListBundles();
+    public List<RcsBundleInfo> listBundles() {
+        return nativeListBundles();
     }
 
     /**
      * API for adding the bundle to the Container
      *
      * @param bundleId
-     *            Id of the Bundle
+     *            Id of the Bundle
      * @param bundleUri
-     *            Uri of the bundle
+     *            Uri of the bundle
      * @param bundlePath
-     *            - Path of the bundle
+     *            Path of the bundle
+     * @param activator
+     *            Activation prefix for .so bundles, or activator class name for
+     *            .jar bundles
      * @param params
-     *            key-value pairs in string form for other Bundle parameters
+     *            key-value pairs in string form for other Bundle parameters
      *
      *            <p>
      *            It is dynamic configuration
      */
     public void addBundle(String bundleId, String bundleUri, String bundlePath,
-            Map<String, String> params) {
-        this.nativeAddBundle(bundleId, bundleUri, bundlePath, params);
+            String activator, Map<String, String> params) {
+        nativeAddBundle(bundleId, bundleUri, bundlePath, activator, params);
     }
 
     /**
      * API for removing the bundle from the container
      *
      * @param bundleId
-     *            Id of the Bundle
+     *            Id of the Bundle
      *
      */
     public void removeBundle(String bundleId) {
-        this.nativeRemoveBundle(bundleId);
+        nativeRemoveBundle(bundleId);
     }
 
     /**
      * API for starting the bundle.
      *
      * @param bundleId
-     *            Id of the Bundle
+     *            Id of the Bundle
      *
      */
     public void startBundle(String bundleId) {
-        this.nativeStartBundle(bundleId);
+        nativeStartBundle(bundleId);
     }
 
     /**
      * API for Stopping the bundle
      *
      * @param bundleId
-     *            Id of the Bundle
+     *            Id of the Bundle
      *
      */
     public void stopBundle(String bundleId) {
-        this.nativeStopBundle(bundleId);
+        nativeStopBundle(bundleId);
     }
 
     /**
      * API for adding the Resource configuration information to the bundle
      *
      * @param bundleId
-     *            Id of the Bundle
+     *            Id of the Bundle
      * @param resourceUri
-     *            URI of the resource
+     *            URI of the resource
      * @param params
-     *            key-value pairs in string form for other Bundle parameters
+     *            key-value pairs in string form for other Bundle parameters
      *
      */
     public void addResourceConfig(String bundleId, String resourceUri,
             Map<String, String> params) {
-        this.nativeAddResourceConfig(bundleId, resourceUri, params);
+        nativeAddResourceConfig(bundleId, resourceUri, params);
     }
 
     /**
      * API for removing the Resource configuration information from the bundle
      *
      * @param bundleId
-     *            Id of the Bundle
+     *            Id of the Bundle
      * @param resourceUri
-     *            URI of the resource
+     *            URI of the resource
      *
      */
     public void removeResourceConfig(String bundleId, String resourceUri) {
-        this.nativeRemoveResourceConfig(bundleId, resourceUri);
+        nativeRemoveResourceConfig(bundleId, resourceUri);
     }
 
     /**
      * API for getting the list of Bundle Resources
      *
      * @param bundleId
-     *            Id of the Bundle
+     *            Id of the Bundle
      *
-     * @return List All the bundle resources
+     * @return List<String> All the bundle resources
      */
     public List<String> listBundleResources(String bundleId) {
-        return this.nativeListBundleResources(bundleId);
+        return nativeListBundleResources(bundleId);
     }
 }
diff --git a/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsResourceObject.java b/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsResourceObject.java
new file mode 100644 (file)
index 0000000..7586113
--- /dev/null
@@ -0,0 +1,707 @@
+/******************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************/
+/**
+ * @file   RCSResourceObject.java
+ *
+ *  This file contains the resource object APIs provided to the developers.
+ *        RCSResourceObject is a part of the server builder module.
+ *
+ */
+
+package org.iotivity.service.server;
+
+import java.lang.ref.WeakReference;
+
+import org.iotivity.service.RcsDestroyedObjectException;
+import org.iotivity.service.RcsException;
+import org.iotivity.service.RcsIllegalStateException;
+import org.iotivity.service.RcsObject;
+import org.iotivity.service.RcsPlatformException;
+import org.iotivity.service.RcsResourceAttributes;
+import org.iotivity.service.RcsValue;
+
+/**
+ * RCSResourceObject represents a resource. It handles any requests from clients
+ * automatically with attributes.
+ * <p>
+ * It also provides an auto notification mechanism that notifies to the
+ * observers. Requests are handled automatically by defaultAction of
+ * RCSGetResponse and RCSSetResponse. Developer can override them and send your
+ * own response.
+ * <p>
+ * For simple resources, developer may want to know whenever attributes are
+ * changed by a set request. In this case, add an AttributeUpdatedListener with
+ * a key interested in instead of overriding SetRequestHandler.
+ *
+ * @see Builder
+ */
+public final class RcsResourceObject extends RcsObject {
+    /**
+     * This class provides APIs for resource creation, setting properties and
+     * attributes for the constructed resource. It provides the build() API
+     * which
+     * builds a resource and returns RCSResourceObject.
+     *
+     * {@link RcsResourceObject}
+     */
+    public static class Builder {
+        private final String          mUri;
+        private final String          mType;
+        private final String          mInterface;
+        private boolean               mIsObservable    = true;
+        private boolean               mIsDiscovervable = true;
+        private RcsResourceAttributes mAttributes;
+
+        /**
+         * Constructor
+         *
+         * @param uri
+         *            Resource URI value to be set
+         * @param resourceType
+         *            Resource type value to be set
+         * @param resourceInterface
+         *            Interface value to be set
+         *
+         * @throws NullPointerException
+         *             If any parameter is null.
+         */
+        public Builder(String uri, String resourceType,
+                String resourceInterface) {
+
+            if (uri == null) {
+                throw new NullPointerException("uri is null.");
+            }
+            if (resourceType == null) {
+                throw new NullPointerException("resourceType is null.");
+            }
+            if (resourceInterface == null) {
+                throw new NullPointerException("resourceInterface is null.");
+            }
+
+            mUri = uri;
+            mType = resourceType;
+            mInterface = resourceInterface;
+        }
+
+        /**
+         * Sets the discoverable(OC_DISCOVERABLE) property for the resource.
+         *
+         * @param isDiscoverable
+         *            Whether to be discovered or not
+         *
+         */
+        public Builder setDiscoverable(boolean isDiscoverable) {
+            mIsDiscovervable = isDiscoverable;
+            return this;
+        }
+
+        /**
+         * Sets the observable(OC_OBSERVABLE) property of the resource.
+         *
+         * @param isObservable
+         *            Whether to be observed or not
+         *
+         */
+        public Builder setObservable(boolean isObservable) {
+            mIsObservable = isObservable;
+            return this;
+        }
+
+        /**
+         * API for setting attributes of the resource.
+         *
+         * @param attributes
+         *            Attributes to set
+         *
+         */
+        public Builder setAttributes(RcsResourceAttributes attributes) {
+            mAttributes = attributes;
+            return this;
+        }
+
+        /**
+         * Creates a RCSResourceObject.
+         *
+         * @throws RcsPlatformException
+         *             If registering a resource is failed.
+         *
+         */
+        public RcsResourceObject build() {
+            return nativeBuild(mUri, mType, mInterface, mIsObservable,
+                    mIsDiscovervable, mAttributes);
+        }
+    }
+
+    /**
+     * This provides the way to get the attributes of RcsResourceObject with
+     * lock.
+     * When a thread holds the lock, the other threads will be pending until the
+     * lock is released by unlock.
+     *
+     * Here is the standard idiom for AttributesLock:
+     *
+     * <pre>
+     * {@code
+     * AttributesLock lock = rcsResourceObject.getAttributesLock();
+     *
+     * try
+     * {
+     *     lock.lock();
+     *
+     *     ....
+     *
+     *     lock.apply();
+     * } finally {
+     *     lock.unlock();
+     * }
+     * </pre>
+     */
+    public static class AttributesLock {
+
+        private final WeakReference<RcsResourceObject> mResourceObjectRef;
+
+        private RcsLockedAttributes mCurrentAttributes;
+
+        private AttributesLock(RcsResourceObject resourceObj) {
+            mResourceObjectRef = new WeakReference<RcsResourceObject>(
+                    resourceObj);
+        }
+
+        private RcsResourceObject ensureResourceObject() throws RcsException {
+
+            final RcsResourceObject object = mResourceObjectRef.get();
+            if (object == null || object.isDestroyed()) {
+                throw new RcsDestroyedObjectException(
+                        "The object is already destroyed!");
+            }
+
+            return object;
+        }
+
+        /**
+         * Locks the attributes of the RcsResourceObject and returns locked
+         * attributes that can be modified until unlocked.
+         *
+         * @return Locked attributes.
+         *
+         * @throws RcsException
+         *             If the RcsResourceObject is destroyed.
+         */
+        public RcsLockedAttributes lock() throws RcsException {
+            return mCurrentAttributes = new RcsLockedAttributes(
+                    ensureResourceObject());
+        }
+
+        /**
+         * Changes the state to unlock of the attributes of the
+         * RcsResourceObject.
+         *
+         */
+        public void unlock() {
+            if (mCurrentAttributes == null) return;
+
+            mCurrentAttributes.setUnlockState();
+            mCurrentAttributes = null;
+        }
+
+        /**
+         * Applies the modified attributes to the RcsResourceObject.
+         *
+         * @throws RcsIllegalStateException
+         *             If not in locked state.
+         */
+        public void apply() throws RcsIllegalStateException {
+            if (mCurrentAttributes == null) {
+                throw new RcsIllegalStateException("it is not locked state.");
+            }
+            mCurrentAttributes.apply();
+        }
+    }
+
+    private static native RcsResourceObject nativeBuild(String uri,
+            String resourceType, String resourceInterface, boolean isObservable,
+            boolean isDiscoverable, RcsResourceAttributes attributes);
+
+    private native void nativeSetAttribute(String key, RcsValue value);
+
+    private native RcsValue nativeGetAttributeValue(String key);
+
+    private native boolean nativeRemoveAttribute(String key);
+
+    private native boolean nativeContainsAttribute(String key);
+
+    private native RcsResourceAttributes nativeGetAttributes();
+
+    private native boolean nativeIsObservable();
+
+    private native boolean nativeIsDiscoverable();
+
+    private native void nativeNotify();
+
+    private native void nativeSetAutoNotifyPolicy(AutoNotifyPolicy policy);
+
+    private native AutoNotifyPolicy nativeGetAutoNotifyPolicy();
+
+    private native void nativeSetSetRequestHandlerPolicy(
+            SetRequestHandlerPolicy policy);
+
+    private native SetRequestHandlerPolicy nativeGetSetRequestHandlerPolicy();
+
+    private native void nativeSetGetRequestHandler(GetRequestHandler handler);
+
+    private native void nativeSetSetRequestHandler(SetRequestHandler handler);
+
+    private native void nativeAddAttributeUpdatedListener(String key,
+            OnAttributeUpdatedListener listener);
+
+    private native boolean nativeRemoveAttributeUpdatedListener(String key);
+
+    private RcsResourceObject() {
+    }
+
+    /**
+     * Represents the policy of AutoNotify function of RCSResourceObject class
+     * In accord with this policy, observers are notified of attributes that are
+     * changed or updated.
+     *
+     * <p>
+     * Attributes are changed or updated according to execution of some
+     * functions or receipt of 'set-request'.
+     *
+     * {@link RcsResourceObject}
+     */
+    public enum AutoNotifyPolicy {
+        NEVER, /** < Never notify. */
+        ALWAYS, /** < Always notify. */
+        UPDATED;
+        /** < When attributes are changed, notify. */
+    }
+
+    public enum SetRequestHandlerPolicy {
+
+        NEVER, /**
+                * < Server ignore when server is received set-request of
+                * attributes of the new key.
+                */
+        ACCEPT;
+        /**
+         * < Server creates attributes of the new key When server is received
+         * set-request of attributes of the new key.
+         */
+    }
+
+    /**
+     * Interface definition for a handler to be invoked when a get request is
+     * received.
+     */
+    public interface GetRequestHandler {
+
+        /**
+         * Called when received a get request from the client.
+         *
+         * @param request
+         *            Request information.
+         * @param attributes
+         *            The attributes of the request.
+         *
+         * @return A response to be sent.
+         *
+         * @see RcsGetResponse
+         */
+        RcsGetResponse onGetRequested(RcsRequest request,
+                RcsResourceAttributes attributes);
+
+    }
+
+    /**
+     * Interface definition for a handler to be invoked when a set request is
+     * received.
+     */
+    public interface SetRequestHandler {
+
+        /**
+         * Called when received a set request from the client.
+         *
+         * @param request
+         *            Request information.
+         * @param attributes
+         *            The attributes of the request.
+         *            It will be applied to the RcsResourceObject.
+         *
+         * @return A response indicating how to handle this request.
+         *
+         * @see RcsSetResponse
+         */
+        RcsSetResponse onSetRequested(RcsRequest request,
+                RcsResourceAttributes attributes);
+
+    }
+
+    /**
+     * Interface definition for a callback to be invoked when an attribute is
+     * updated.
+     */
+    public interface OnAttributeUpdatedListener {
+
+        /**
+         * Called when an attribute value is updated.
+         *
+         * @param oldValue
+         *            The attribute value before updated.
+         * @param newValue
+         *            The current resource attribute value.
+         */
+        void onAttributeUpdated(RcsValue oldValue, RcsValue newValue);
+    }
+
+    private void assertAlive() throws RcsException {
+        if (!hasHandle()) {
+            throw new RcsDestroyedObjectException(
+                    "The object is already destroyed!");
+        }
+    }
+
+    /**
+     * Sets a particular attribute value as a integer.
+     * The thread-safety for attributes is taken care internally.
+     *
+     * @param key
+     *            name of attribute(used to map the attribute value).
+     * @param value
+     *            value to be mapped against the key.
+     *
+     * @throws RcsException
+     *             If the object is destroyed.
+     * @throws NullPointerException
+     *             If key or value is null.
+     *
+     */
+    public void setAttribute(String key, RcsValue value) throws RcsException {
+        assertAlive();
+
+        if (key == null) throw new NullPointerException("key is null");
+        if (value == null) throw new NullPointerException("value is null");
+
+        nativeSetAttribute(key, value);
+    }
+
+    /**
+     * Returns a copied attribute value associated with the supplied key.
+     * The thread-safety for attributes is taken care internally.
+     *
+     * @param key
+     *            key of an attribute.
+     *
+     * @return An attributes value.
+     *
+     * @throws RcsException
+     *             If the object is destroyed.
+     * @throws NullPointerException
+     *             If key is null.
+     */
+    public RcsValue getAttributeValue(String key) throws RcsException {
+        assertAlive();
+
+        if (key == null) throw new NullPointerException("key is null");
+        return nativeGetAttributeValue(key);
+    }
+
+    /**
+     * API for removing a particular attribute of the resource.
+     * The thread-safety for attributes is taken care internally.
+     *
+     * @param key
+     *            Name of the attribute.
+     *
+     * @return If the key exist and matched attribute is deleted, return true.
+     *
+     * @throws RcsException
+     *             If the object is destroyed.
+     * @throws NullPointerException
+     *             If key is null.
+     */
+    public boolean removeAttribute(String key) throws RcsException {
+        assertAlive();
+
+        if (key == null) throw new NullPointerException("key is null");
+        return nativeRemoveAttribute(key);
+    }
+
+    /**
+     * API for checking whether a particular attribute is there for a resource
+     * or not.
+     * The thread-safety for attributes is taken care internally.
+     *
+     * @param key
+     *            Name of the attribute.
+     *
+     * @return If the key exist, return true.
+     *
+     * @throws RcsException
+     *             If the object is destroyed.
+     * @throws NullPointerException
+     *             If key is null.
+     */
+    public boolean containsAttribute(String key) throws RcsException {
+        assertAlive();
+
+        if (key == null) throw new NullPointerException("key is null");
+        return nativeContainsAttribute(key);
+    }
+
+    /**
+     * Returns a copied attributes of the RCSResourceObject.
+     * To modify the attributes, use AttrbutesLock.
+     *
+     * @throws RcsException
+     *             If the object is destroyed.
+     *
+     * @see getAttributesLock
+     */
+    public RcsResourceAttributes getAttributes() throws RcsException {
+        assertAlive();
+
+        return nativeGetAttributes();
+    }
+
+    /**
+     * Returns the AttributesLock for this RcsResourceObject.
+     *
+     * @throws RcsException
+     *             If the object is destroyed.
+     */
+    public AttributesLock getAttributesLock() throws RcsException {
+        assertAlive();
+
+        return new AttributesLock(this);
+    }
+
+    /**
+     * API for checking whether the particular resource is observable or not.
+     *
+     * @return true if this is observable. Otherwise false.
+     *
+     * @throws RcsException
+     *             If the object is destroyed.
+     */
+    public boolean isObservable() throws RcsException {
+        assertAlive();
+
+        return nativeIsObservable();
+    }
+
+    /**
+     * API for checking whether the particular resource is discoverable or not.
+     *
+     * @return true if this is discoverable. Otherwise false.
+     *
+     * @throws RcsException
+     *             If the object is destroyed.
+     */
+    public boolean isDiscoverable() throws RcsException {
+        assertAlive();
+
+        return nativeIsDiscoverable();
+    }
+
+    /**
+     * API for setting the resource's get request handler by the
+     * developer/application. If developer set this handler then all get request
+     * will come to the application and developer can send the response to the
+     * client using APIs of RCSGetResponse class.
+     *
+     * @throws RcsException
+     *             If the object is destroyed.
+     * @throws NullPointerException
+     *             If handler is null.
+     *
+     */
+    public void setGetRequestHandler(GetRequestHandler handler)
+            throws RcsException {
+        assertAlive();
+
+        if (handler == null) throw new NullPointerException("handler is null.");
+        nativeSetGetRequestHandler(handler);
+    }
+
+    /**
+     * API for setting the resource's set request handler by the
+     * developer/application. If developer set this handler then all set request
+     * will come to the application and developer can send the response to the
+     * client using APIs of RCSSetResponse class.
+     *
+     * @throws RcsException
+     *             If the object is destroyed.
+     * @throws NullPointerException
+     *             If handler is null.
+     *
+     */
+    public void setSetRequestHandler(SetRequestHandler handler)
+            throws RcsException {
+        assertAlive();
+
+        if (handler == null) throw new NullPointerException("handler is null.");
+
+        nativeSetSetRequestHandler(handler);
+    }
+
+    /**
+     * API for setting the Listener for a particular attribute update.
+     *
+     * @param key
+     *            The interested attribute's key
+     *
+     * @throws NullPointerException
+     *             If key or listener is null.
+     *
+     * @throws RcsException
+     *             If the object is destroyed.
+     */
+    public void addAttributeUpdatedListener(String key,
+            OnAttributeUpdatedListener listener) throws RcsException {
+        assertAlive();
+
+        if (key == null) {
+            throw new NullPointerException("key is null.");
+        }
+        if (listener == null) {
+            throw new NullPointerException("listener is null.");
+        }
+
+        nativeAddAttributeUpdatedListener(key, listener);
+    }
+
+    /**
+     * API for removing the handler for a particular attribute update.
+     *
+     * @param key
+     *            The interested attribute's key
+     *
+     * @return true if the requested attribute is removed successfully.
+     *         Otherwise false.
+     *
+     * @throws RcsException
+     *             If the object is destroyed.
+     * @throws NullPointerException
+     *             If key is null.
+     */
+    public boolean removeAttributeUpdatedListener(String key)
+            throws RcsException {
+        assertAlive();
+
+        if (key == null) throw new NullPointerException("key is null");
+        return nativeRemoveAttributeUpdatedListener(key);
+    }
+
+    /**
+     * API for notifying all observers of the RCSResourceObject with the updated
+     * attributes value
+     *
+     * @throws RcsException
+     *             If the object is destroyed.
+     * @throws RcsPlatformException
+     *             If the operation failed.
+     */
+    public void notifyObservers() throws RcsException {
+        assertAlive();
+
+        nativeNotify();
+    }
+
+    /**
+     * API for setting Auto notify policy
+     *
+     * @param policy
+     *            policy to be set
+     *
+     * @throws RcsException
+     *             If the object is destroyed.
+     *
+     */
+    public void setAutoNotifyPolicy(AutoNotifyPolicy policy)
+            throws RcsException {
+        assertAlive();
+
+        if (policy == null) throw new NullPointerException("policy is null");
+        nativeSetAutoNotifyPolicy(policy);
+    }
+
+    /**
+     * API for getting auto notify policy
+     *
+     * @return AntoNotify policy
+     *
+     * @throws RcsException
+     *             If the object is destroyed.
+     *
+     */
+    public AutoNotifyPolicy getAutoNotifyPolicy() throws RcsException {
+        assertAlive();
+
+        return nativeGetAutoNotifyPolicy();
+    }
+
+    /**
+     * API for setting the policy for a setRequestHandler.
+     *
+     * @param policy
+     *            policy to be set
+     *
+     * @throws RcsException
+     *             If the object is destroyed.
+     *
+     */
+    public void setSetRequestHandlerPolicy(SetRequestHandlerPolicy policy)
+            throws RcsException {
+        assertAlive();
+
+        if (policy == null) throw new NullPointerException("policy is null");
+        nativeSetSetRequestHandlerPolicy(policy);
+    }
+
+    /**
+     * API for getting the SetRequestHandler Policy.
+     *
+     * @return Property of setRequesthandler
+     *
+     * @throws RcsException
+     *             If the object is destroyed.
+     *
+     */
+    public SetRequestHandlerPolicy getSetRequestHandlerPolicy()
+            throws RcsException {
+        assertAlive();
+
+        return nativeGetSetRequestHandlerPolicy();
+    }
+
+    private boolean isDestroyed() {
+        return !hasHandle();
+    }
+
+    /**
+     * Unregister the resource and reclaims all resources used by this object.
+     * This must be called if the resource is not used any longer.
+     *
+     */
+    public void destroy() {
+        super.dispose();
+    }
+}
diff --git a/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsResponse.java b/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsResponse.java
new file mode 100644 (file)
index 0000000..0311553
--- /dev/null
@@ -0,0 +1,53 @@
+/******************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************/
+
+package org.iotivity.service.server;
+
+import org.iotivity.service.RcsResourceAttributes;
+
+public class RcsResponse {
+    private native static int nativeGetDefaultErrorCode();
+
+    public static final int DEFAULT_ERROR_CODE;
+
+    static {
+        DEFAULT_ERROR_CODE = nativeGetDefaultErrorCode();
+    }
+
+    private final int                   mErrorCode;
+    private final RcsResourceAttributes mAttrs;
+
+    RcsResponse() {
+        this(DEFAULT_ERROR_CODE);
+    }
+
+    RcsResponse(RcsResourceAttributes attrs) {
+        this(attrs, DEFAULT_ERROR_CODE);
+    }
+
+    RcsResponse(int errorCode) {
+        this(null, errorCode);
+    }
+
+    RcsResponse(RcsResourceAttributes attrs, int errorCode) {
+        mErrorCode = errorCode;
+        mAttrs = attrs;
+    }
+}
diff --git a/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsSetResponse.java b/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsSetResponse.java
new file mode 100644 (file)
index 0000000..95fbd2e
--- /dev/null
@@ -0,0 +1,202 @@
+/******************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************/
+
+package org.iotivity.service.server;
+
+import org.iotivity.service.RcsResourceAttributes;
+
+/**
+ * This class provides methods to create the response for a received set
+ * request.
+ *
+ * @see RcsResourceObject
+ * @see RcsSetResponse
+ */
+public final class RcsSetResponse extends RcsResponse {
+    /**
+     * Options for handling a set request.
+     *
+     * This overrides RcsResourceObject#SetRequestHandlerPolicy.
+     *
+     * @see RcsResourceObject#SetRequestHandlerPolicy
+     *
+     */
+    public enum AcceptanceMethod {
+        /**
+         * Follow RcsResourceObject#SetRequestHandlerPolicy.
+         */
+        DEFAULT,
+
+        /**
+         * Accept the request attributes even if there is an unknown key or
+         * mismatched type.
+         */
+        ACCEPT,
+
+        /**
+         * Ignore the request attributes.
+         */
+        IGNORE
+    };
+
+    private AcceptanceMethod mAcceptanceMethod = AcceptanceMethod.DEFAULT;
+
+    /**
+     * Creates a default RCSSetResponse with DEFAULT acceptance method. The
+     * response will have RCSResponse.DEFAULT_ERROR_CODE for the errorCode. The
+     * attributes of RCSResourceObject will be set as the result attributes.
+     *
+     */
+    public static RcsSetResponse defaultAction() {
+        return new RcsSetResponse();
+    }
+
+    /**
+     * Creates a default RCSSetResponse with ACCEPT acceptance method. The
+     * response will have RCSResponse.DEFAULT_ERROR_CODE for the errorCode. The
+     * attributes of RCSResourceObject will be set as the result attributes.
+     *
+     */
+    public static RcsSetResponse accept() {
+        return new RcsSetResponse()
+                .setAcceptanceMethod(AcceptanceMethod.ACCEPT);
+    }
+
+    /**
+     * Creates a RCSSetResponse with ACCEPT acceptance method and error code
+     * passed.
+     * The attributes of the RCSResourceObject will be set as the result
+     * attributes.
+     *
+     * @param errorCode
+     *            The error code to set in response.
+     *
+     */
+    public static RcsSetResponse accept(int errorCode) {
+        return new RcsSetResponse(errorCode)
+                .setAcceptanceMethod(AcceptanceMethod.ACCEPT);
+    }
+
+    /**
+     * Creates a default RCSSetResponse with IGNORE acceptance method. The
+     * response will have RCSResponse.DEFAULT_ERROR_CODE for the errorCode. The
+     * attributes of RCSResourceObject will be set as the result attributes.
+     *
+     */
+    public static RcsSetResponse ignore() {
+        return new RcsSetResponse()
+                .setAcceptanceMethod(AcceptanceMethod.IGNORE);
+    }
+
+    /**
+     * Creates a RCSSetResponse with IGNORE acceptance method and
+     * error code passed. The attributes of the RCSResourceObject will be set as
+     * the result attributes.
+     *
+     * @param errorCode
+     *            The error code to set in response.
+     *
+     */
+    public static RcsSetResponse ignore(int errorCode) {
+        return new RcsSetResponse(errorCode)
+                .setAcceptanceMethod(AcceptanceMethod.IGNORE);
+    }
+
+    /**
+     * Creates a RCSSetResponse with error code passed and has
+     * DEFAULT acceptance method. The attributes of the RCSResourceObject will
+     * be set as the result attributes.
+     *
+     * @param errorCode
+     *            The error code to set in response.
+     *
+     */
+    public static RcsSetResponse create(int errorCode) {
+        return new RcsSetResponse(errorCode);
+    }
+
+    /**
+     * Creates a RCSSetResponse with custom attributes and has DEFAULT
+     * acceptance method. This sends the passed attributes as the result
+     * attributes instead of one the RCSResourceObject holds.
+     *
+     * @param attributes
+     *            The attributes to send in response.
+     *
+     */
+    public static RcsSetResponse create(RcsResourceAttributes attributes) {
+        return new RcsSetResponse(attributes);
+    }
+
+    /**
+     * Returns the acceptance method.
+     *
+     */
+    public AcceptanceMethod getAcceptanceMethod() {
+        return mAcceptanceMethod;
+    }
+
+    /**
+     * Sets the acceptance method for the RCSSetResponse.
+     *
+     * @param method
+     *            AcceptanceMethod value to set
+     *
+     * @return The reference to this RCSSetResponse
+     *
+     */
+    public RcsSetResponse setAcceptanceMethod(AcceptanceMethod method) {
+        mAcceptanceMethod = method;
+        return this;
+    }
+
+    /**
+     * Creates a RCSSetResponse with error code passed. This sends
+     * the passed attributes as the result attributes instead of one the
+     * RCSResourceObject holds.
+     *
+     * @param attributes
+     *            The attributes to send in response.
+     * @param errorCode
+     *            The error code for response.
+     *
+     */
+    public static RcsSetResponse create(RcsResourceAttributes attributes,
+            int errorCode) {
+        return new RcsSetResponse(attributes, errorCode);
+    }
+
+    private RcsSetResponse() {
+        super();
+    }
+
+    private RcsSetResponse(int errorCode) {
+        super(errorCode);
+    }
+
+    private RcsSetResponse(RcsResourceAttributes attrs) {
+        super(attrs);
+    }
+
+    private RcsSetResponse(RcsResourceAttributes attrs, int errorCode) {
+        super(attrs, errorCode);
+    }
+
+}
diff --git a/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsUnlockedException.java b/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsUnlockedException.java
new file mode 100644 (file)
index 0000000..143ac35
--- /dev/null
@@ -0,0 +1,17 @@
+package org.iotivity.service.server;
+
+import org.iotivity.service.RcsException;
+
+/**
+ * Thrown when trying to access a unlocked RcsLockedAttributes.
+ *
+ */
+public class RcsUnlockedException extends RcsException {
+
+    private static final long serialVersionUID = 4292243643497860992L;
+
+    public RcsUnlockedException(String message) {
+        super(message);
+    }
+
+}
diff --git a/service/resource-encapsulation/android/service/src/main/jni/Android.mk b/service/resource-encapsulation/android/service/src/main/jni/Android.mk
new file mode 100644 (file)
index 0000000..58cbd01
--- /dev/null
@@ -0,0 +1,49 @@
+LOCAL_PATH := $(call my-dir)
+
+ROOT_PATH := ../../../../../../..
+IOTIVITY_LIB_PATH := $(ROOT_PATH)/out/android/$(TARGET_ARCH_ABI)/release
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := rcs_common
+LOCAL_SRC_FILES := $(IOTIVITY_LIB_PATH)/librcs_common.so
+include $(PREBUILT_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := rcs_client
+LOCAL_SRC_FILES := $(IOTIVITY_LIB_PATH)/librcs_client.so
+include $(PREBUILT_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := rcs_server
+LOCAL_SRC_FILES := $(IOTIVITY_LIB_PATH)/librcs_server.so
+include $(PREBUILT_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := rcs_container
+LOCAL_SRC_FILES := $(IOTIVITY_LIB_PATH)/librcs_container.so
+include $(PREBUILT_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+OIC_SRC_DIR := ../../../../../..
+LOCAL_MODULE := rcs_jni
+
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/util
+LOCAL_C_INCLUDES += $(OIC_SRC_DIR)/resource/c_common
+LOCAL_C_INCLUDES += $(OIC_SRC_DIR)/resource/csdk/stack/include
+LOCAL_C_INCLUDES += $(OIC_SRC_DIR)/extlibs/boost/boost_1_58_0
+LOCAL_C_INCLUDES += $(OIC_SRC_DIR)/service/resource-encapsulation/include
+LOCAL_C_INCLUDES += $(OIC_SRC_DIR)/service/resource-encapsulation/src/serverBuilder/include
+
+LOCAL_SRC_FILES += $(patsubst $(LOCAL_PATH)/%, %, $(wildcard $(LOCAL_PATH)/util/*.cpp))
+LOCAL_SRC_FILES += $(patsubst $(LOCAL_PATH)/%, %, $(wildcard $(LOCAL_PATH)/*.cpp))
+
+LOCAL_CPPFLAGS := -std=c++0x -frtti -fexceptions
+
+LOCAL_LDLIBS := -llog
+
+LOCAL_SHARED_LIBRARIES += rcs_common
+LOCAL_SHARED_LIBRARIES += rcs_client
+LOCAL_SHARED_LIBRARIES += rcs_server
+LOCAL_SHARED_LIBRARIES += rcs_container
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/service/resource-encapsulation/android/service/src/main/jni/JniMain.cpp b/service/resource-encapsulation/android/service/src/main/jni/JniMain.cpp
new file mode 100644 (file)
index 0000000..dcc4184
--- /dev/null
@@ -0,0 +1,102 @@
+/******************************************************************
+ *
+ * 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 "JniRcsDiscoveryManager.h"
+#include "JniRcsObject.h"
+#include "JniRcsRemoteResourceObject.h"
+#include "JniRcsResourceAttributes.h"
+#include "JniRcsResourceObject.h"
+#include "JniRcsResourceContainer.h"
+#include "JniRcsValue.h"
+#include "JavaClasses.h"
+#include "JavaExceptions.h"
+#include "JNIEnvWrapper.h"
+#include "Log.h"
+
+#define LOG_TAG "JNI-Main"
+
+#define JNI_CURRENT_VERSION JNI_VERSION_1_6
+
+JavaVM *g_jvm;
+
+JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
+{
+    LOGI("JNI_OnLoad");
+    JNIEnv *env;
+    g_jvm = vm;
+
+    if (g_jvm->GetEnv((void **)&env, JNI_CURRENT_VERSION) != JNI_OK)
+    {
+        LOGE("Failed to get the environment using GetEnv()");
+        return JNI_ERR;
+    }
+
+    JNIEnvWrapper envWrapper{ env };
+
+    try
+    {
+        initJavaClasses(&envWrapper);
+        initJavaExceptions(&envWrapper);
+        initRCSValue(&envWrapper);
+        initRCSResourceAttributes(&envWrapper);
+        initRCSDiscoveryManager(&envWrapper);
+        initRCSRemoteResourceObject(&envWrapper);
+        initRCSObject(&envWrapper);
+        initRCSResourceObject(&envWrapper);
+        initRCSResourceContainer(&envWrapper);
+    }
+    catch (const JavaException&)
+    {
+        if (env->ExceptionCheck()) env->ExceptionDescribe();
+        return JNI_ERR;
+    }
+
+    return JNI_CURRENT_VERSION;
+}
+
+JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved)
+{
+    LOGI("JNI_OnUnload");
+    JNIEnv *env;
+
+    if (g_jvm->GetEnv((void **)&env, JNI_CURRENT_VERSION) != JNI_OK)
+    {
+        LOGE("Failed to get the environment using GetEnv()");
+        return;
+    }
+
+    JNIEnvWrapper envWrapper{ env };
+
+    try
+    {
+        clearRCSResourceContainer(&envWrapper);
+        clearRCSResourceObject(&envWrapper);
+        clearRCSObject(&envWrapper);
+        clearRCSRemoteResourceObject(&envWrapper);
+        clearRCSDiscoveryManager(&envWrapper);
+        clearRCSResourceAttributes(&envWrapper);
+        clearRCSValue(&envWrapper);
+        clearJavaExceptions(&envWrapper);
+        clearJavaClasses(&envWrapper);
+    }
+    catch (const JavaException&)
+    {
+    }
+}
diff --git a/service/resource-encapsulation/android/service/src/main/jni/JniRcsBundleInfo.cpp b/service/resource-encapsulation/android/service/src/main/jni/JniRcsBundleInfo.cpp
new file mode 100644 (file)
index 0000000..ace4db6
--- /dev/null
@@ -0,0 +1,100 @@
+/******************************************************************
+ *
+ * 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 "JniRcsBundleInfo.h"
+
+#include "Log.h"
+#include "Verify.h"
+#include "JniRcsObject.h"
+
+#include "RCSBundleInfo.h"
+
+#define LOG_TAG "JNI-RCSBundleInfo"
+
+using namespace OIC::Service;
+
+namespace
+{
+    RCSBundleInfo* getNativeBundleInfo(JNIEnv* env, jobject obj)
+    {
+        return getNativeHandleAs< RCSBundleInfo* >(env, obj);
+    }
+}
+
+JNIEXPORT jstring JNICALL
+Java_org_iotivity_service_server_RcsBundleInfo_nativeGetID
+(JNIEnv* env, jobject obj)
+{
+    LOGI("nativeGetID");
+
+    auto bundleInfo = getNativeBundleInfo(env, obj);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    return newStringObject(env, bundleInfo->getID());
+}
+
+JNIEXPORT jstring JNICALL
+Java_org_iotivity_service_server_RcsBundleInfo_nativeGetPath
+(JNIEnv* env, jobject obj)
+{
+    LOGI("nativeGetPath");
+
+    auto bundleInfo = getNativeBundleInfo(env, obj);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    return newStringObject(env, bundleInfo->getPath());
+}
+
+JNIEXPORT jstring JNICALL
+Java_org_iotivity_service_server_RcsBundleInfo_nativeGetActivatorName
+(JNIEnv* env, jobject obj)
+{
+    LOGI("nativeGetActivatorName");
+
+    auto bundleInfo = getNativeBundleInfo(env, obj);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    return newStringObject(env, bundleInfo->getActivatorName());
+}
+
+JNIEXPORT jstring JNICALL
+Java_org_iotivity_service_server_RcsBundleInfo_nativeGetLibraryPath
+(JNIEnv* env, jobject obj)
+{
+    LOGI("nativeGetLibraryPath");
+
+    auto bundleInfo = getNativeBundleInfo(env, obj);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    return newStringObject(env, bundleInfo->getLibraryPath());
+}
+
+JNIEXPORT jstring JNICALL
+Java_org_iotivity_service_server_RcsBundleInfo_nativeGetVersion
+(JNIEnv* env, jobject obj)
+{
+    LOGI("nativeGetVersion");
+
+    auto bundleInfo = getNativeBundleInfo(env, obj);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    return newStringObject(env, bundleInfo->getVersion());
+}
+
diff --git a/service/resource-encapsulation/android/service/src/main/jni/JniRcsBundleInfo.h b/service/resource-encapsulation/android/service/src/main/jni/JniRcsBundleInfo.h
new file mode 100644 (file)
index 0000000..4f8d71e
--- /dev/null
@@ -0,0 +1,60 @@
+/******************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************/
+
+/** @file   jni_re_rcs_bundle_info.h
+ *
+ * @brief This file contains the JniBundleInfo class
+ *               & declaration of RCSBundleInfo APIs for JNI implementation
+ */
+
+#ifndef JNI_RCS_BUNDLE_INFO_H_
+#define JNI_RCS_BUNDLE_INFO_H_
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+JNIEXPORT jstring JNICALL
+Java_org_iotivity_service_server_RcsBundleInfo_nativeGetID
+(JNIEnv*, jobject);
+
+JNIEXPORT jstring JNICALL
+Java_org_iotivity_service_server_RcsBundleInfo_nativeGetPath
+(JNIEnv*, jobject);
+
+JNIEXPORT jstring JNICALL
+Java_org_iotivity_service_server_RcsBundleInfo_nativeGetActivatorName
+(JNIEnv*, jobject);
+
+JNIEXPORT jstring JNICALL
+Java_org_iotivity_service_server_RcsBundleInfo_nativeGetLibraryPath
+(JNIEnv*, jobject);
+
+JNIEXPORT jstring JNICALL
+Java_org_iotivity_service_server_RcsBundleInfo_nativeGetVersion
+(JNIEnv*, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+#endif // JNI_RCS_BUNDLE_INFO_H_
+
diff --git a/service/resource-encapsulation/android/service/src/main/jni/JniRcsDiscoveryManager.cpp b/service/resource-encapsulation/android/service/src/main/jni/JniRcsDiscoveryManager.cpp
new file mode 100644 (file)
index 0000000..0d3f82a
--- /dev/null
@@ -0,0 +1,125 @@
+/******************************************************************
+ *
+ * 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 "JniRcsDiscoveryManager.h"
+
+#include "JniRcsObject.h"
+#include "JniRcsRemoteResourceObject.h"
+#include "JavaClasses.h"
+#include "JavaExceptions.h"
+#include "JavaGlobalRef.h"
+#include "JNIEnvWrapper.h"
+#include "Log.h"
+#include "ScopedEnv.h"
+#include "Verify.h"
+
+#include "RCSDiscoveryManager.h"
+#include "RCSAddress.h"
+#include "RCSRemoteResourceObject.h"
+
+using namespace OIC::Service;
+
+#define LOG_TAG "JNI-DiscoveryManager"
+
+#define CLS_NAME_DISCOVERY_MANAGER PACKAGE_NAME "/client/RcsDiscoveryManager"
+
+#define CLS_NAME_ON_RESOURCE_DISCOVERED_LISTENER \
+    CLS_NAME_DISCOVERY_MANAGER "$OnResourceDiscoveredListener"
+
+#define CLS_NAME_DISCOVERY_TASK CLS_NAME_DISCOVERY_MANAGER "$DiscoveryTask"
+
+namespace
+{
+    jclass g_cls_DiscoveryaTask;
+
+    jmethodID g_method_onResourceDiscovered;
+
+    jmethodID g_ctor_DiscoveryTask;
+}
+
+void initRCSDiscoveryManager(JNIEnvWrapper* env)
+{
+    auto clsOnResourceDiscoveredListener = env->FindClass(CLS_NAME_ON_RESOURCE_DISCOVERED_LISTENER);
+
+    g_method_onResourceDiscovered = env->GetMethodID(clsOnResourceDiscoveredListener,
+            "onResourceDiscovered", "(" AS_SIG(CLS_NAME_REMOTERESOURCEOBJECT) ")V");
+
+    g_cls_DiscoveryaTask = env->FindClassAsGlobalRef(CLS_NAME_DISCOVERY_TASK);
+
+    g_ctor_DiscoveryTask = env->GetConstructorID(g_cls_DiscoveryaTask, "()V");
+}
+
+void clearRCSDiscoveryManager(JNIEnvWrapper* env)
+{
+    env->DeleteGlobalRef(g_cls_DiscoveryaTask);
+}
+
+void onResourceDiscovered(RCSRemoteResourceObject::Ptr resource, const JavaGlobalRef& listener)
+{
+    LOGI("onResourceDiscovered");
+
+    ScopedEnvWrapper env;
+    EXPECT(env, "env is null!");
+
+    try
+    {
+        auto newResourceObj = newRemoteResourceObject(env.get());
+
+        setSafeNativeHandle< RCSRemoteResourceObject::Ptr >(env.get(),
+                newResourceObj, std::move(resource));
+
+        env->CallVoidMethod(listener, g_method_onResourceDiscovered, newResourceObj);
+    }
+    catch (const JavaException&)
+    {
+        env->ExceptionDescribe();
+        env->ExceptionClear();
+    }
+}
+
+JNIEXPORT jobject JNICALL
+Java_org_iotivity_service_client_RcsDiscoveryManager_nativeDiscoverResource(
+        JNIEnv *env, jclass obj, jstring address, jstring uri, jstring resourceType,
+        jobject listener)
+{
+    LOGI("discoverResource");
+
+    RCSAddress rcsAddress{ address ? RCSAddress::unicast(toStdString(env, address)) :
+            RCSAddress::multicast() };
+
+    try
+    {
+        auto discoveryTask = RCSDiscoveryManager::getInstance()->discoverResourceByType(
+            std::move(rcsAddress), toStdString(env, uri), toStdString(env, resourceType),
+            std::bind(onResourceDiscovered, std::placeholders::_1, JavaGlobalRef{ env, listener }));
+
+        auto taskObj = env->NewObject(g_cls_DiscoveryaTask, g_ctor_DiscoveryTask);
+        VERIFY_NO_EXC_RET_DEF(env);
+
+        setSafeNativeHandle< decltype(discoveryTask) >(env, taskObj, std::move(discoveryTask));
+
+        return taskObj;
+    }
+    catch (const PlatformException& e) {
+        throwPlatformException(env, e);
+    }
+
+    return nullptr;
+}
  * limitations under the License.
  *
  ******************************************************************/
-/**
- * @file
- * This file provides EntityHandlerResult Enum & utility function.
- */
 
-package org.iotivity.ResourceEncapsulation.utils;
+#ifndef JNI_RCS_DISCOVERY_MANAGER_H_
+#define JNI_RCS_DISCOVERY_MANAGER_H_
 
-import org.iotivity.ResourceEncapsulation.server.*;
+#include <jni.h>
 
-/**
- * Represents the EntityHandlerResult, that application can send for a Get or a
- * Set request.
- *
- * {@link RCSResourceObject} {@link RCSGetResponse} {@link RCSSetResponse}
- */
-public enum EntityHandlerResult {
+class JNIEnvWrapper;
+
+void initRCSDiscoveryManager(JNIEnvWrapper*);
+void clearRCSDiscoveryManager(JNIEnvWrapper*);
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+JNIEXPORT jobject JNICALL
+Java_org_iotivity_service_client_RcsDiscoveryManager_nativeDiscoverResource
+(JNIEnv*, jclass, jstring address, jstring relativeURI, jstring resourceType, jobject listener);
 
-    OC_EH_OK, OC_EH_ERROR, OC_EH_RESOURCE_CREATED, OC_EH_RESOURCE_DELETED, OC_EH_SLOW, OC_EH_FORBIDDEN, OC_EH_RESOURCE_NOT_FOUND;
+#ifdef __cplusplus
 }
+#endif
+#endif //JNI_RCS_DISCOVERY_MANAGER_H_
diff --git a/service/resource-encapsulation/android/service/src/main/jni/JniRcsLockedAttributes.cpp b/service/resource-encapsulation/android/service/src/main/jni/JniRcsLockedAttributes.cpp
new file mode 100644 (file)
index 0000000..98273c9
--- /dev/null
@@ -0,0 +1,173 @@
+/******************************************************************
+ *
+ * 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 "JniRcsLockedAttributes.h"
+
+#include "JniRcsObject.h"
+#include "JniRcsResourceAttributes.h"
+#include "JniRcsValue.h"
+#include "Log.h"
+#include "Verify.h"
+
+#include "RCSResourceObject.h"
+
+#define LOG_TAG "JNI-RCSLockedAttributes"
+
+using namespace OIC::Service;
+
+namespace
+{
+    inline RCSResourceObject::Ptr& getResource(JNIEnv* env, jobject obj)
+    {
+        return getNativeHandleAs< RCSResourceObject::Ptr >(env, obj);
+    }
+}
+
+// The prerequisite for below methods is for ResourceObject's attributes being locked.
+// This is guaranteed by class named RCSResourceObject.AttributesLock on Java layer.
+
+JNIEXPORT jboolean JNICALL
+Java_org_iotivity_service_server_RcsLockedAttributes_nativeIsEmpty
+(JNIEnv* env, jclass, jobject resourceObject)
+{
+    auto res = getResource(env, resourceObject);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    return res->getAttributes().empty();
+}
+
+JNIEXPORT jint JNICALL
+Java_org_iotivity_service_server_RcsLockedAttributes_nativeSize
+(JNIEnv* env, jclass, jobject resourceObject)
+{
+    auto res = getResource(env, resourceObject);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    return res->getAttributes().size();
+}
+
+JNIEXPORT jboolean JNICALL
+Java_org_iotivity_service_server_RcsLockedAttributes_nativeRemove
+(JNIEnv* env, jclass, jobject resourceObject, jstring keyObj)
+{
+    EXPECT_RET_DEF(keyObj, "keyObj is null");
+
+    auto res = getResource(env, resourceObject);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    auto key = toStdString(env, keyObj);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    return res->getAttributes().erase(key);
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsLockedAttributes_nativeClear
+(JNIEnv* env, jclass, jobject resourceObject)
+{
+    auto res = getResource(env, resourceObject);
+    VERIFY_NO_EXC(env);
+
+    res->getAttributes().clear();
+}
+
+JNIEXPORT jboolean JNICALL
+Java_org_iotivity_service_server_RcsLockedAttributes_nativeContains
+(JNIEnv* env, jclass, jobject resourceObject, jstring keyObj)
+{
+    EXPECT_RET_DEF(keyObj, "keyObj is null");
+
+    auto res = getResource(env, resourceObject);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    auto key = toStdString(env, keyObj);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    return res->getAttributes().contains(key);
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsLockedAttributes_nativeAddKeys
+(JNIEnv* env, jclass, jobject resourceObject, jstring setObj)
+{
+    EXPECT(setObj, "set is null.");
+
+    auto res = getResource(env, resourceObject);
+    VERIFY_NO_EXC(env);
+
+    for (const auto& keyValue : res->getAttributes())
+    {
+        JavaLocalString localObj{ env, env->NewStringUTF(keyValue.key().c_str()) };
+        VERIFY_NO_EXC(env);
+
+        invoke_Collection_add(env, setObj, localObj);
+        VERIFY_NO_EXC(env);
+    }
+}
+
+JNIEXPORT jobject JNICALL
+Java_org_iotivity_service_server_RcsLockedAttributes_nativeAsJavaObject
+(JNIEnv* env, jclass, jobject resourceObject, jstring keyObj)
+{
+    EXPECT_RET_DEF(keyObj, "Key is null.");
+
+    auto res = getResource(env, resourceObject);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    auto key = toStdString(env, keyObj);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    auto& attrs = res->getAttributes();
+
+    EXPECT_RET_DEF(attrs.contains(key), "no matched value");
+
+    jobject valueObj = newRCSValueObject(env, attrs[key]);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    return valueObj;
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsLockedAttributes_nativeApply
+(JNIEnv* env, jclass, jobject resourceObject, jstring cacheObj)
+{
+    EXPECT(cacheObj, "cacheObj is null.");
+
+    auto res = getResource(env, resourceObject);
+    VERIFY_NO_EXC(env);
+
+    writeNativeAttributesFromMap(env, cacheObj, res->getAttributes());
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsLockedAttributes_nativeLock
+(JNIEnv* env, jobject obj, jobject resourceObject)
+{
+    auto res = getResource(env, resourceObject);
+    VERIFY_NO_EXC(env);
+
+    setSafeNativeHandle< RCSResourceObject::LockGuard >(env, obj, res);
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsLockedAttributes_nativeUnlock(JNIEnv* env, jobject obj)
+{
+    releaseNativeHandle(env, obj);
+}
diff --git a/service/resource-encapsulation/android/service/src/main/jni/JniRcsLockedAttributes.h b/service/resource-encapsulation/android/service/src/main/jni/JniRcsLockedAttributes.h
new file mode 100644 (file)
index 0000000..79bbb8b
--- /dev/null
@@ -0,0 +1,74 @@
+/******************************************************************
+ *
+ * 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_RCS_LOCKED_ATTRIBUTES_H_
+#define JNI_RCS_LOCKED_ATTRIBUTES_H_
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+JNIEXPORT jboolean JNICALL
+Java_org_iotivity_service_server_RcsLockedAttributes_nativeIsEmpty
+(JNIEnv*, jclass, jobject);
+
+JNIEXPORT jint JNICALL
+Java_org_iotivity_service_server_RcsLockedAttributes_nativeSize
+(JNIEnv*, jclass, jobject);
+
+JNIEXPORT jboolean JNICALL
+Java_org_iotivity_service_server_RcsLockedAttributes_nativeRemove
+(JNIEnv*, jclass, jobject, jstring keyObj);
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsLockedAttributes_nativeClear
+(JNIEnv*, jclass, jobject);
+
+JNIEXPORT jboolean JNICALL
+Java_org_iotivity_service_server_RcsLockedAttributes_nativeContains
+(JNIEnv*, jclass, jobject, jstring keyObj);
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsLockedAttributes_nativeAddKeys
+(JNIEnv*, jclass, jobject, jstring setObj);
+
+JNIEXPORT jobject JNICALL
+Java_org_iotivity_service_server_RcsLockedAttributes_nativeAsJavaObject
+(JNIEnv*, jclass, jobject, jstring keyObj);
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsLockedAttributes_nativeApply
+(JNIEnv*, jclass, jobject, jstring cacheObj);
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsLockedAttributes_nativeLock
+(JNIEnv*, jobject, jobject);
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsLockedAttributes_nativeUnlock
+(JNIEnv*, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif  //JNI_RCS_LOCKED_ATTRIBUTES_H_
  * limitations under the License.
  *
  ******************************************************************/
-/**
- * @file
- * This file provides AttriubtesGetValueTypes Enum.
- * It is passed as second parameter to get the value of the
- * RCSResourceArributes.
- */
 
-package org.iotivity.ResourceEncapsulation.common;
+#include "JniRcsObject.h"
 
-public enum AttriubtesGetValueTypes {
+#include "JavaClasses.h"
+#include "JNIEnvWrapper.h"
+#include "Log.h"
+#include "Verify.h"
 
-    Integer, VectorOfInteger, VectorOfVectorOfInteger, VectorOfVectorOfVectorOfInteger,
+#define LOG_TAG "JNI-RCSObject"
 
-    Double, VectorOfDouble, VectorOfVectorOfDouble, VectorOfVectorOfVectorOfDouble,
+jfieldID g_field_mNativeHandle;
 
-    Boolean, VectorOfBoolean, VectorOfVectorOfBoolean, VectorOfVectorOfVectorOfBoolean,
+void initRCSObject(JNIEnvWrapper* env)
+{
+    auto clsRCSObject = env->FindClass(PACKAGE_NAME "/RcsObject");
 
-    String, VectorOfString, VectorOfVectorOfString, VectorOfVectorOfVectorOfString,
+    g_field_mNativeHandle = env->GetFieldID(clsRCSObject, "mNativeHandle", "J");
+}
+
+void clearRCSObject(JNIEnvWrapper* env)
+{
+}
 
-    RCSRemoteAtttributes
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_RcsObject_nativeDispose(JNIEnv* env, jobject obj)
+{
+    LOGD("release nativeHandle!");
+    releaseNativeHandle(env, obj);
 }
diff --git a/service/resource-encapsulation/android/service/src/main/jni/JniRcsObject.h b/service/resource-encapsulation/android/service/src/main/jni/JniRcsObject.h
new file mode 100644 (file)
index 0000000..46b5671
--- /dev/null
@@ -0,0 +1,125 @@
+/******************************************************************
+ *
+ * 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_RCS_OBJECT_H_
+#define JNI_RCS_OBJECT_H_
+
+#include <jni.h>
+
+#include <memory>
+
+#include "JavaClasses.h"
+#include "JNIEnvWrapper.h"
+
+extern jfieldID g_field_mNativeHandle;
+
+void initRCSObject(JNIEnvWrapper*);
+void clearRCSObject(JNIEnvWrapper*);
+
+namespace Detail
+{
+    struct BaseHandleHolder
+    {
+        virtual ~BaseHandleHolder() {}
+    };
+
+    template< typename T >
+    struct HandleHolder: public BaseHandleHolder
+    {
+        HandleHolder(T* ptr) : m_ptr { ptr } {}
+
+        virtual ~HandleHolder() { delete m_ptr; }
+
+        T* m_ptr;
+    };
+
+    template< typename ENV >
+    void* getNativeHandle(ENV* env, jobject obj)
+    {
+        return reinterpret_cast< void* >(env->GetLongField(obj, g_field_mNativeHandle));
+    }
+}
+
+template< typename ENV >
+bool hasNativeHandle(ENV* env, jobject obj)
+{
+    return Detail::getNativeHandle(env, obj) != nullptr;
+}
+
+template< typename T, typename ENV, typename ...PARAMS >
+inline void setSafeNativeHandle(ENV* env, jobject obj, PARAMS&&... params)
+{
+    static_assert(!std::is_array< T >::value, "Array is not supported!");
+
+    std::unique_ptr< Detail::HandleHolder< T > > p(
+            new Detail::HandleHolder< T >{ new T{ std::forward< PARAMS >(params)... } });
+
+    env->SetLongField(obj, g_field_mNativeHandle, reinterpret_cast< jlong >(p.get()));
+
+    if (env->ExceptionCheck()) return;
+
+    p.release();
+}
+
+template< typename ENV >
+void releaseNativeHandle(ENV* env, jobject obj)
+{
+    auto handleHolder = reinterpret_cast< Detail::BaseHandleHolder* >(
+            env->GetLongField(obj, g_field_mNativeHandle));
+
+    delete handleHolder;
+
+    env->SetLongField(obj, g_field_mNativeHandle, 0);
+}
+
+
+template< typename T >
+inline T& getNativeHandleAs(JNIEnv* env, jobject obj)
+{
+    auto handleHolder = static_cast< Detail::HandleHolder< T >* >(Detail::getNativeHandle(env, obj));
+
+    if (!handleHolder)
+    {
+        env->ThrowNew(env->FindClass(EXC_NAME_ILLEGAL_STATE), "Internal handle is null!");
+    }
+
+   return *handleHolder->m_ptr;
+}
+
+template< typename T >
+inline T& getNativeHandleAs(JNIEnvWrapper* env, jobject obj)
+{
+    getNativeHandleAs< T >(env->get(), obj);
+    if (env->ExceptionCheck()) throw JavaException();
+}
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_RcsObject_nativeDispose(JNIEnv*, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // JNI_RCS_OBJECT_H_
diff --git a/service/resource-encapsulation/android/service/src/main/jni/JniRcsRemoteResourceObject.cpp b/service/resource-encapsulation/android/service/src/main/jni/JniRcsRemoteResourceObject.cpp
new file mode 100644 (file)
index 0000000..91e4b99
--- /dev/null
@@ -0,0 +1,510 @@
+/******************************************************************
+ *
+ * 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 "JniRcsRemoteResourceObject.h"
+
+#include "JniRcsObject.h"
+#include "JniRcsResourceAttributes.h"
+#include "JavaClasses.h"
+#include "JavaExceptions.h"
+#include "JavaGlobalRef.h"
+#include "Log.h"
+#include "ScopedEnv.h"
+#include "Verify.h"
+
+#include "RCSRemoteResourceObject.h"
+
+using namespace OIC::Service;
+
+#define LOG_TAG "JNI-RCSRemoteResourceObject"
+
+#define CLS_NAME_RESOURCE_STATE CLS_NAME_REMOTERESOURCEOBJECT "$ResourceState"
+#define CLS_NAME_CACHE_STATE CLS_NAME_REMOTERESOURCEOBJECT "$CacheState"
+
+#define CLS_NAME_ON_STATE_CHANGED_LISTENER CLS_NAME_REMOTERESOURCEOBJECT "$OnStateChangedListener"
+#define CLS_NAME_ON_CACHE_UPDATED_LISTENER CLS_NAME_REMOTERESOURCEOBJECT "$OnCacheUpdatedListener"
+#define CLS_NAME_ON_REMOTE_ATTRIBUTES_RECEIVED_LISTENER \
+    CLS_NAME_REMOTERESOURCEOBJECT "$OnRemoteAttributesReceivedListener"
+
+namespace
+{
+    jclass g_cls_RCSRemoteResourceObject;
+    jclass g_cls_ResourceState;
+
+    jmethodID g_ctor_RCSRemoteResourceObject;
+
+    jmethodID g_method_onStateChanged;
+    jmethodID g_method_onCacheUpdated;
+    jmethodID g_method_onAttributesReceived;
+
+    jobject g_obj_ResourceState_None;
+    jobject g_obj_ResourceState_Requested;
+    jobject g_obj_ResourceState_Alive;
+    jobject g_obj_ResourceState_LostSignal;
+    jobject g_obj_ResourceState_Destoryed;
+
+    jobject g_obj_CacheState_None;
+    jobject g_obj_CacheState_Unready;
+    jobject g_obj_CacheState_Ready;
+    jobject g_obj_CacheState_LostSignal;
+
+
+    inline jobjectArray toJavaStringArray(JNIEnv* env, const std::vector< std::string >& vec)
+    {
+        jobjectArray arrayObj = env->NewObjectArray(vec.size(), g_cls_String, nullptr);
+        if (!arrayObj) return nullptr;
+        for (size_t i = 0; i < vec.size(); ++i)
+        {
+            jstring strObj = env->NewStringUTF(vec[i].c_str());
+            VERIFY_NO_EXC_RET_DEF(env);
+
+            env->SetObjectArrayElement(arrayObj, i, strObj);
+            VERIFY_NO_EXC_RET_DEF(env);
+
+            env->DeleteLocalRef(strObj);
+        }
+        return arrayObj;
+    }
+
+    template < typename ENV >
+    inline jobject convertResourceState(ENV* env, ResourceState state)
+    {
+        switch (state)
+        {
+            case ResourceState::NONE: return g_obj_ResourceState_None;
+            case ResourceState::REQUESTED: return g_obj_ResourceState_Requested;
+            case ResourceState::ALIVE: return g_obj_ResourceState_Alive;
+            case ResourceState::LOST_SIGNAL: return g_obj_ResourceState_LostSignal;
+            case ResourceState::DESTROYED: return g_obj_ResourceState_Destoryed;
+        }
+
+        throwRCSException(env, "Failed to convert ResourceState");
+        return { };
+    }
+
+    inline jobject convertCacheState(JNIEnv* env, CacheState state)
+    {
+        switch (state)
+        {
+            case CacheState::NONE: return g_obj_CacheState_None;
+            case CacheState::UNREADY: return g_obj_CacheState_Unready;
+            case CacheState::READY: return g_obj_CacheState_Ready;
+            case CacheState::LOST_SIGNAL: return g_obj_CacheState_LostSignal;
+        }
+
+        throwRCSException(env, "Failed to convert CacheState");
+        return { };
+    }
+
+    inline RCSRemoteResourceObject::Ptr& getResource(JNIEnv* env, jobject obj) noexcept
+    {
+        return getNativeHandleAs< RCSRemoteResourceObject::Ptr >(env, obj);
+    }
+
+    void onStateChanged(ResourceState newState, const JavaGlobalRef& listener)
+    {
+        ScopedEnvWrapper env;
+        EXPECT(env, "env is null!");
+
+        try
+        {
+            env->CallVoidMethod(listener, g_method_onStateChanged,
+                    convertResourceState(env.get(), newState));
+        }
+        catch (const JavaException&)
+        {
+            env->ExceptionDescribe();
+            env->ExceptionClear();
+        }
+    }
+
+    void onCacheUpdated(const RCSResourceAttributes& attrs, const JavaGlobalRef& listener)
+    {
+        LOGD("onCacheUpdated");
+
+        ScopedEnvWrapper env;
+        EXPECT(env, "env is null!");
+
+        try
+        {
+            env->CallVoidMethod(listener, g_method_onCacheUpdated,
+                    newAttributesObject(env.get(), attrs));
+        }
+        catch (const JavaException&)
+        {
+            env->ExceptionDescribe();
+            env->ExceptionClear();
+        }
+    }
+
+    void onRemoteAttributesReceived(const RCSResourceAttributes& attrs, int errorCode,
+            const JavaGlobalRef& listener)
+    {
+        ScopedEnvWrapper env;
+        EXPECT(env, "env is null!");
+
+        try
+        {
+            env->CallVoidMethod(listener, g_method_onAttributesReceived,
+                    newAttributesObject(env.get(), attrs), errorCode);
+        }
+        catch (const JavaException&)
+        {
+            env->ExceptionDescribe();
+            env->ExceptionClear();
+        }
+    }
+}
+
+
+void initRCSRemoteResourceObject(JNIEnvWrapper* env)
+{
+    g_cls_RCSRemoteResourceObject = env->FindClassAsGlobalRef(CLS_NAME_REMOTERESOURCEOBJECT);
+
+    g_ctor_RCSRemoteResourceObject = env->GetConstructorID(g_cls_RCSRemoteResourceObject, "()V");
+
+    auto clsOnStateChangedListener = env->FindClass(CLS_NAME_ON_STATE_CHANGED_LISTENER);
+    g_method_onStateChanged = env->GetMethodID(clsOnStateChangedListener, "onStateChanged",
+            "(" AS_SIG(CLS_NAME_RESOURCE_STATE) ")V");
+
+    auto clsOnCacheUpdatedListener = env->FindClass(CLS_NAME_ON_CACHE_UPDATED_LISTENER);
+    g_method_onCacheUpdated = env->GetMethodID(clsOnCacheUpdatedListener, "onCacheUpdated",
+            "(" AS_SIG(CLS_NAME_RESOURCEATTRIBUTES) ")V");
+
+    auto clsOnRemoteAttributesReceivedListener =
+            env->FindClass(CLS_NAME_ON_REMOTE_ATTRIBUTES_RECEIVED_LISTENER);
+    g_method_onAttributesReceived = env->GetMethodID(clsOnRemoteAttributesReceivedListener,
+            "onAttributesReceived", "(" AS_SIG(CLS_NAME_RESOURCEATTRIBUTES) "I)V");
+
+    auto clsResourceState = env->FindClass(CLS_NAME_RESOURCE_STATE);
+
+    g_obj_ResourceState_None = env->NewGlobalRef(env->GetStaticObjectField(clsResourceState,
+            "NONE", AS_SIG(CLS_NAME_RESOURCE_STATE)));
+
+    g_obj_ResourceState_Requested = env->NewGlobalRef(env->GetStaticObjectField(clsResourceState,
+            "REQUESTED", AS_SIG(CLS_NAME_RESOURCE_STATE)));
+
+    g_obj_ResourceState_Alive = env->NewGlobalRef(env->GetStaticObjectField(clsResourceState,
+            "ALIVE", AS_SIG(CLS_NAME_RESOURCE_STATE)));
+
+    g_obj_ResourceState_LostSignal = env->NewGlobalRef(env->GetStaticObjectField(clsResourceState,
+            "LOST_SIGNAL", AS_SIG(CLS_NAME_RESOURCE_STATE)));
+
+    g_obj_ResourceState_Destoryed = env->NewGlobalRef(env->GetStaticObjectField(clsResourceState,
+            "DESTROYED", AS_SIG(CLS_NAME_RESOURCE_STATE)));
+
+    auto clsCacheState = env->FindClass(CLS_NAME_CACHE_STATE);
+
+    g_obj_CacheState_None = env->NewGlobalRef(env->GetStaticObjectField(clsCacheState,
+            "NONE", AS_SIG(CLS_NAME_CACHE_STATE)));
+
+    g_obj_CacheState_Unready = env->NewGlobalRef(env->GetStaticObjectField(clsCacheState,
+            "UNREADY", AS_SIG(CLS_NAME_CACHE_STATE)));
+
+    g_obj_CacheState_Ready = env->NewGlobalRef(env->GetStaticObjectField(clsCacheState,
+            "READY", AS_SIG(CLS_NAME_CACHE_STATE)));
+
+    g_obj_CacheState_LostSignal = env->NewGlobalRef(env->GetStaticObjectField(clsCacheState,
+            "LOST_SIGNAL", AS_SIG(CLS_NAME_CACHE_STATE)));
+
+
+}
+
+void clearRCSRemoteResourceObject(JNIEnvWrapper* env)
+{
+    env->DeleteGlobalRef(g_cls_RCSRemoteResourceObject);
+    env->DeleteGlobalRef(g_cls_ResourceState);
+
+    env->DeleteGlobalRef(g_obj_ResourceState_None);
+    env->DeleteGlobalRef(g_obj_ResourceState_Requested);
+    env->DeleteGlobalRef(g_obj_ResourceState_Alive);
+    env->DeleteGlobalRef(g_obj_ResourceState_LostSignal);
+    env->DeleteGlobalRef(g_obj_ResourceState_Destoryed);
+
+    env->DeleteGlobalRef(g_obj_CacheState_None);
+    env->DeleteGlobalRef(g_obj_CacheState_Unready);
+    env->DeleteGlobalRef(g_obj_CacheState_Ready);
+    env->DeleteGlobalRef(g_obj_CacheState_LostSignal);
+}
+
+jobject newRemoteResourceObject(JNIEnvWrapper* env)
+{
+    return env->NewObject(g_cls_RCSRemoteResourceObject, g_ctor_RCSRemoteResourceObject);
+}
+
+JNIEXPORT jboolean JNICALL
+Java_org_iotivity_service_client_RcsRemoteResourceObject_nativeIsMonitoring
+(JNIEnv* env, jobject obj)
+{
+    LOGD("nativeIsMonitoring");
+    auto res = getResource(env, obj);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    return res->isMonitoring();
+}
+
+JNIEXPORT jboolean JNICALL
+Java_org_iotivity_service_client_RcsRemoteResourceObject_nativeIsCaching
+(JNIEnv* env, jobject obj)
+{
+    LOGD("nativeIsCaching");
+    auto res = getResource(env, obj);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    return res->isCaching();
+}
+
+JNIEXPORT jboolean JNICALL
+Java_org_iotivity_service_client_RcsRemoteResourceObject_nativeIsObservable
+(JNIEnv* env, jobject obj)
+{
+    LOGD("nativeIsObservable");
+    auto res = getResource(env, obj);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    return res->isObservable();
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_client_RcsRemoteResourceObject_nativeStartMonitoring
+(JNIEnv* env, jobject obj, jobject listener)
+{
+    LOGD("nativeStartMonitoring");
+    EXPECT(listener, "listener is null.");
+
+    auto res = getResource(env, obj);
+    VERIFY_NO_EXC(env);
+
+    try
+    {
+        res->startMonitoring(
+                std::bind(onStateChanged, std::placeholders::_1, JavaGlobalRef{ env, listener }));
+    }
+    catch (const BadRequestException& e)
+    {
+        env->ThrowNew(env->FindClass(EXC_NAME_ILLEGAL_STATE), e.what());
+    }
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_client_RcsRemoteResourceObject_nativeStopMonitoring
+(JNIEnv* env, jobject obj)
+{
+    LOGD("nativeStopMonitoring");
+
+    auto res = getResource(env, obj);
+    VERIFY_NO_EXC(env);
+
+    res->stopMonitoring();
+}
+
+JNIEXPORT jobject JNICALL
+Java_org_iotivity_service_client_RcsRemoteResourceObject_nativeGetState
+(JNIEnv* env, jobject obj)
+{
+    LOGD("nativeGetState");
+
+    auto res = getResource(env, obj);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    return convertResourceState(env, res->getState());
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_client_RcsRemoteResourceObject_nativeStartCaching
+(JNIEnv* env, jobject obj, jobject listener)
+{
+    LOGD("nativeStartCaching");
+
+    auto res = getResource(env, obj);
+    VERIFY_NO_EXC(env);
+
+    try
+    {
+        if (listener)
+        {
+            res->startCaching(std::bind(onCacheUpdated,
+                    std::placeholders::_1, JavaGlobalRef{ env, listener }));
+        }
+        else
+        {
+            res->startCaching();
+        }
+    }
+    catch (const BadRequestException& e)
+    {
+        env->ThrowNew(env->FindClass(EXC_NAME_ILLEGAL_STATE), e.what());
+    }
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_client_RcsRemoteResourceObject_nativeStopCaching
+(JNIEnv* env, jobject obj)
+{
+    LOGD("nativeStopCaching");
+
+    auto res = getResource(env, obj);
+    VERIFY_NO_EXC(env);
+
+    res->stopCaching();
+}
+
+JNIEXPORT jobject JNICALL
+Java_org_iotivity_service_client_RcsRemoteResourceObject_nativeGetCacheState
+(JNIEnv* env, jobject obj)
+{
+    LOGD("nativeGetCacheState");
+
+    auto res = getResource(env, obj);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    return convertCacheState(env, res->getCacheState());
+}
+
+JNIEXPORT jboolean JNICALL
+Java_org_iotivity_service_client_RcsRemoteResourceObject_nativeIsCachedAvailable
+(JNIEnv* env, jobject obj)
+{
+    LOGD("nativeIsCachedAvailable");
+
+    auto res = getResource(env, obj);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    try
+    {
+        return res->isCachedAvailable();
+    }
+    catch (const BadRequestException& e)
+    {
+        env->ThrowNew(env->FindClass(EXC_NAME_ILLEGAL_STATE), e.what());
+        return false;
+    }
+}
+
+JNIEXPORT jobject JNICALL
+Java_org_iotivity_service_client_RcsRemoteResourceObject_nativeGetCachedAttributes
+(JNIEnv* env, jobject obj)
+{
+    LOGD("nativeGetCachedAttributes");
+
+    auto res = getResource(env, obj);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    try
+    {
+        auto attrs = res->getCachedAttributes();
+        VERIFY_NO_EXC_RET_DEF(env);
+
+        return newAttributesObject(env, attrs);
+    }
+    catch (const BadRequestException& e)
+    {
+        env->ThrowNew(env->FindClass(EXC_NAME_ILLEGAL_STATE), e.what());
+        return { };
+    }
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_client_RcsRemoteResourceObject_nativeGetRemoteAttributes
+(JNIEnv* env, jobject obj, jobject listener)
+{
+    LOGD("nativeGetRemoteAttributes");
+    EXPECT(listener, "listener is null.");
+
+    auto res = getResource(env, obj);
+    VERIFY_NO_EXC(env);
+
+    try
+    {
+        res->getRemoteAttributes(std::bind(onRemoteAttributesReceived,
+                std::placeholders::_1, std::placeholders::_2, JavaGlobalRef{ env, listener }));
+    }
+    catch (const PlatformException& e) {
+        throwPlatformException(env, e);
+    }
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_client_RcsRemoteResourceObject_nativeSetRemoteAttributes
+(JNIEnv* env, jobject obj, jobject attrsObj, jobject listener)
+{
+    LOGD("nativeSetRemoteAttributes");
+    auto res = getResource(env, obj);
+    VERIFY_NO_EXC(env);
+
+    RCSResourceAttributes attrs = toNativeAttributes(env, attrsObj);
+    VERIFY_NO_EXC(env);
+
+    try
+    {
+        res->setRemoteAttributes(attrs, std::bind(onRemoteAttributesReceived,
+                std::placeholders::_1, std::placeholders::_2, JavaGlobalRef{ env, listener }));
+    }
+    catch (const PlatformException& e) {
+        throwPlatformException(env, e);
+    }
+}
+
+JNIEXPORT jstring JNICALL
+Java_org_iotivity_service_client_RcsRemoteResourceObject_nativeGetUri
+(JNIEnv* env, jobject obj)
+{
+    LOGD("nativeGetUri");
+
+    auto res = getResource(env, obj);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    return env->NewStringUTF(res->getUri().c_str());
+}
+
+JNIEXPORT jstring JNICALL
+Java_org_iotivity_service_client_RcsRemoteResourceObject_nativeGetAddress
+(JNIEnv* env, jobject obj)
+{
+    LOGD("nativeGetAddress");
+    auto res = getResource(env, obj);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    return env->NewStringUTF(res->getAddress().c_str());
+}
+
+JNIEXPORT jobjectArray JNICALL
+Java_org_iotivity_service_client_RcsRemoteResourceObject_nativeGetTypes
+(JNIEnv* env, jobject obj)
+{
+    LOGD("nativeGetTypes");
+    auto res = getResource(env, obj);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    return toJavaStringArray(env, res->getTypes());
+}
+
+JNIEXPORT jobjectArray JNICALL
+Java_org_iotivity_service_client_RcsRemoteResourceObject_nativeGetInterfaces
+(JNIEnv* env, jobject obj)
+{
+    LOGD("nativeGetInterfaces");
+
+    auto res = getResource(env, obj);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    return toJavaStringArray(env, res->getInterfaces());
+}
+
diff --git a/service/resource-encapsulation/android/service/src/main/jni/JniRcsRemoteResourceObject.h b/service/resource-encapsulation/android/service/src/main/jni/JniRcsRemoteResourceObject.h
new file mode 100644 (file)
index 0000000..5086eac
--- /dev/null
@@ -0,0 +1,108 @@
+/******************************************************************
+ *
+ * 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_RE_RCS_REMOTE_RESOURCE_OBJECT_H_
+#define JNI_RE_RCS_REMOTE_RESOURCE_OBJECT_H_
+
+#include <jni.h>
+
+class JNIEnvWrapper;
+
+void initRCSRemoteResourceObject(JNIEnvWrapper*);
+void clearRCSRemoteResourceObject(JNIEnvWrapper*);
+
+jobject newRemoteResourceObject(JNIEnvWrapper*);
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+JNIEXPORT jboolean JNICALL
+Java_org_iotivity_service_client_RcsRemoteResourceObject_nativeIsMonitoring
+(JNIEnv*, jobject);
+
+JNIEXPORT jboolean JNICALL
+Java_org_iotivity_service_client_RcsRemoteResourceObject_nativeIsCaching
+(JNIEnv*, jobject);
+
+JNIEXPORT jboolean JNICALL
+Java_org_iotivity_service_client_RcsRemoteResourceObject_nativeIsObservable
+(JNIEnv*, jobject);
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_client_RcsRemoteResourceObject_nativeStartMonitoring
+(JNIEnv*, jobject, jobject);
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_client_RcsRemoteResourceObject_nativeStopMonitoring
+(JNIEnv*, jobject);
+
+JNIEXPORT jobject JNICALL
+Java_org_iotivity_service_client_RcsRemoteResourceObject_nativeGetState
+(JNIEnv*, jobject);
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_client_RcsRemoteResourceObject_nativeStartCaching
+(JNIEnv*, jobject, jobject cacheUpdateListener);
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_client_RcsRemoteResourceObject_nativeStopCaching
+(JNIEnv*, jobject);
+
+JNIEXPORT jobject JNICALL
+Java_org_iotivity_service_client_RcsRemoteResourceObject_nativeGetCacheState
+(JNIEnv*, jobject);
+
+JNIEXPORT jboolean JNICALL
+Java_org_iotivity_service_client_RcsRemoteResourceObject_nativeIsCachedAvailable
+(JNIEnv*, jobject);
+
+JNIEXPORT jobject JNICALL
+Java_org_iotivity_service_client_RcsRemoteResourceObject_nativeGetCachedAttributes
+(JNIEnv*, jobject);
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_client_RcsRemoteResourceObject_nativeGetRemoteAttributes
+(JNIEnv*, jobject, jobject listener);
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_client_RcsRemoteResourceObject_nativeSetRemoteAttributes
+(JNIEnv*, jobject, jobject attrs, jobject listener);
+
+JNIEXPORT jstring JNICALL
+Java_org_iotivity_service_client_RcsRemoteResourceObject_nativeGetUri
+(JNIEnv*, jobject);
+
+JNIEXPORT jstring JNICALL
+Java_org_iotivity_service_client_RcsRemoteResourceObject_nativeGetAddress
+(JNIEnv*, jobject);
+
+JNIEXPORT jobjectArray JNICALL
+Java_org_iotivity_service_client_RcsRemoteResourceObject_nativeGetTypes
+(JNIEnv*, jobject);
+
+JNIEXPORT jobjectArray JNICALL
+Java_org_iotivity_service_client_RcsRemoteResourceObject_nativeGetInterfaces
+(JNIEnv*, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+#endif // JNI_RE_RCS_REMOTE_RESOURCE_OBJECT_H_
diff --git a/service/resource-encapsulation/android/service/src/main/jni/JniRcsResourceAttributes.cpp b/service/resource-encapsulation/android/service/src/main/jni/JniRcsResourceAttributes.cpp
new file mode 100644 (file)
index 0000000..405468d
--- /dev/null
@@ -0,0 +1,271 @@
+/******************************************************************
+ *
+ * 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 "JniRcsResourceAttributes.h"
+
+#include "JniRcsObject.h"
+#include "JavaLocalRef.h"
+#include "JniRcsValue.h"
+#include "Log.h"
+#include "Verify.h"
+
+using namespace OIC::Service;
+
+#define LOG_TAG "JNI-RCSResourceAttributes"
+
+namespace
+{
+    jclass g_cls_RCSResourceAttributes;
+
+    jmethodID g_ctor_RCSResourceAttributes;
+
+    jfieldID g_field_mCache;
+}
+
+void initRCSResourceAttributes(JNIEnvWrapper* env)
+{
+    g_cls_RCSResourceAttributes = env->FindClassAsGlobalRef(CLS_NAME_RESOURCEATTRIBUTES);
+    g_ctor_RCSResourceAttributes = env->GetConstructorID(g_cls_RCSResourceAttributes, "()V");
+
+    g_field_mCache = env->GetFieldID(g_cls_RCSResourceAttributes, "mCache", AS_SIG(CLS_NAME_MAP));
+}
+
+void clearRCSResourceAttributes(JNIEnvWrapper* env)
+{
+    env->DeleteGlobalRef(g_cls_RCSResourceAttributes);
+}
+
+jobject newAttributesObject(JNIEnv* env, const RCSResourceAttributes& attrs)
+{
+    jobject obj = env->NewObject(g_cls_RCSResourceAttributes, g_ctor_RCSResourceAttributes);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    setSafeNativeHandle< RCSResourceAttributes >(env, obj, attrs);
+
+    return obj;
+}
+
+jobject newAttributesObject(JNIEnvWrapper* env, const RCSResourceAttributes& attrs)
+{
+    jobject obj = env->NewObject(g_cls_RCSResourceAttributes, g_ctor_RCSResourceAttributes);
+
+    setSafeNativeHandle< RCSResourceAttributes >(env, obj, attrs);
+
+    return obj;
+}
+
+RCSResourceAttributes toNativeAttributes(JNIEnv* env, jobject attrsObj)
+{
+    EXPECT_RET(attrsObj, "attrsObj is null!", { });
+
+    JNIEnvWrapper envWrapper{ env };
+
+    try
+    {
+        return toNativeAttributes(&envWrapper, attrsObj);
+    }
+    catch (const JavaException&)
+    {
+        return {};
+    }
+}
+
+RCSResourceAttributes toNativeAttributes(JNIEnvWrapper* env, jobject attrsObj)
+{
+    EXPECT_RET(attrsObj, "attrsObj is null!", { });
+
+    RCSResourceAttributes attrs;
+
+    if (hasNativeHandle(env, attrsObj))
+    {
+        attrs = getNativeHandleAs< RCSResourceAttributes >(env, attrsObj);
+    }
+
+    writeNativeAttributesFromMap(env,
+            JavaLocalObject{ env, env->GetObjectField(attrsObj, g_field_mCache) }, attrs);
+
+    return attrs;
+}
+
+void writeNativeAttributesFromMap(JNIEnv* env, jobject mapObj, RCSResourceAttributes& targetAttrs)
+{
+    JNIEnvWrapper envWrapper{ env };
+
+    try
+    {
+        return writeNativeAttributesFromMap(&envWrapper, mapObj, targetAttrs);
+    }
+    catch (const JavaException&)
+    {
+    }
+}
+
+void writeNativeAttributesFromMap(JNIEnvWrapper* env, jobject mapObj,
+        RCSResourceAttributes& targetAttrs)
+{
+    JavaLocalObject setObj{ env, invoke_Map_entrySet(env, mapObj) };
+    JavaLocalObject iterObj{ env, invoke_Set_iterator(env, setObj) };
+
+    while (invoke_Iterator_hasNext(env, iterObj))
+    {
+        JavaLocalObject entryObj{ env, invoke_Iterator_next(env, iterObj) };
+        JavaLocalObject keyObj{ env, invoke_MapEntry_getKey(env, entryObj) };
+        JavaLocalObject valueObj{ env, invoke_MapEntry_getValue(env, entryObj) };
+
+        auto key = toStdString(env, static_cast< jstring >(keyObj.get()));
+
+        targetAttrs[std::move(key)] = toNativeAttrsValue(env, valueObj);
+    }
+}
+
+JNIEXPORT jboolean JNICALL Java_org_iotivity_service_RcsResourceAttributes_nativeIsEmpty
+(JNIEnv* env, jobject obj)
+{
+    LOGD("isEmpty");
+    EXPECT_RET(hasNativeHandle(env, obj), "no native handle.", true);
+
+    auto& attrs = getNativeHandleAs< RCSResourceAttributes >(env, obj);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    return attrs.empty();
+}
+
+JNIEXPORT jint JNICALL Java_org_iotivity_service_RcsResourceAttributes_nativeSize
+(JNIEnv* env, jobject obj)
+{
+    LOGD("size");
+    EXPECT_RET(hasNativeHandle(env, obj), "no native handle.", 0);
+
+    auto& attrs = getNativeHandleAs< RCSResourceAttributes >(env, obj);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    return attrs.size();
+}
+
+JNIEXPORT jboolean JNICALL Java_org_iotivity_service_RcsResourceAttributes_nativeRemove
+(JNIEnv* env, jobject obj, jstring keyObj)
+{
+    LOGD("remove");
+    EXPECT_RET_DEF(keyObj, "Key is null.");
+    EXPECT_RET_DEF(hasNativeHandle(env, obj), "no native handle.");
+
+    auto& attrs = getNativeHandleAs< RCSResourceAttributes >(env, obj);
+    VERIFY_NO_EXC_RET_DEF(env);
+    const auto& key = toStdString(env, keyObj);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    auto ret = attrs.erase(key);
+
+    if (attrs.empty()) releaseNativeHandle(env, obj);
+
+    return ret;
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_RcsResourceAttributes_nativeClear
+(JNIEnv* env, jobject obj)
+{
+    LOGD("clear");
+
+    releaseNativeHandle(env, obj);
+}
+
+JNIEXPORT jboolean JNICALL Java_org_iotivity_service_RcsResourceAttributes_nativeContains
+(JNIEnv *env, jobject obj, jstring keyObj)
+{
+    LOGD("contains");
+    EXPECT_RET(keyObj, "Key is null.", false);
+    EXPECT_RET(hasNativeHandle(env, obj), "no native handle.", false);
+
+    auto& attrs = getNativeHandleAs< RCSResourceAttributes >(env, obj);
+    VERIFY_NO_EXC_RET_DEF(env);
+    const auto& key = toStdString(env, keyObj);
+    VERIFY_NO_EXC_RET_DEF(env);
+    return attrs.contains(key);
+}
+
+JNIEXPORT void JNICALL Java_org_iotivity_service_RcsResourceAttributes_nativeAddKeys
+(JNIEnv *env, jobject obj, jstring setObj)
+{
+    LOGD("addKeys");
+    EXPECT(setObj, "set is null.");
+    EXPECT(hasNativeHandle(env, obj), "no native handle.");
+
+    auto& attrs = getNativeHandleAs< RCSResourceAttributes >(env, obj);
+    VERIFY_NO_EXC(env);
+
+    for (const auto& keyValue : attrs)
+    {
+        JavaLocalString localObj{ env, env->NewStringUTF(keyValue.key().c_str()) };
+        VERIFY_NO_EXC(env);
+
+        invoke_Collection_add(env, setObj, localObj);
+        VERIFY_NO_EXC(env);
+    }
+}
+
+JNIEXPORT jobject JNICALL Java_org_iotivity_service_RcsResourceAttributes_nativeExtract
+(JNIEnv* env, jobject obj, jstring keyObj)
+{
+    LOGD("extractAsJavaObject");
+    EXPECT_RET_DEF(keyObj, "Key is null.");
+    EXPECT_RET_DEF(hasNativeHandle(env, obj), "no native handle.");
+
+    auto& attrs = getNativeHandleAs< RCSResourceAttributes >(env, obj);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    const auto& key = toStdString(env, keyObj);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    EXPECT_RET_DEF(attrs.contains(key), "no matched value");
+
+    jobject valueObj = newRCSValueObject(env, attrs[key]);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    attrs.erase(key);
+    return valueObj;
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_RcsResourceAttributes_nativeExtractAll
+(JNIEnv* env, jobject obj, jobject mapObj)
+{
+    LOGD("extractAll");
+    EXPECT(mapObj, "Map is null.");
+    EXPECT(hasNativeHandle(env, obj), "no native handle.");
+
+    auto& attrs = getNativeHandleAs< RCSResourceAttributes >(env, obj);
+    VERIFY_NO_EXC(env);
+
+    for (const auto& p : attrs) {
+        JavaLocalObject keyObj{ env, newStringObject(env, p.key()) };
+        VERIFY_NO_EXC(env);
+
+        JavaLocalObject valueObj{ env, newRCSValueObject(env, p.value()) };
+        VERIFY_NO_EXC(env);
+
+        invoke_Map_put(env, mapObj, keyObj, valueObj);
+        VERIFY_NO_EXC(env);
+    }
+
+    attrs.clear();
+    releaseNativeHandle(env, obj);
+}
+
diff --git a/service/resource-encapsulation/android/service/src/main/jni/JniRcsResourceAttributes.h b/service/resource-encapsulation/android/service/src/main/jni/JniRcsResourceAttributes.h
new file mode 100644 (file)
index 0000000..9476c67
--- /dev/null
@@ -0,0 +1,82 @@
+/******************************************************************
+ *
+ * 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_RCS_RESOURCE_ATTRIBUTES_H_
+#define JNI_RCS_RESOURCE_ATTRIBUTES_H_
+
+#include <jni.h>
+
+namespace OIC
+{
+    namespace Service
+    {
+        class RCSResourceAttributes;
+    }
+}
+
+class JNIEnvWrapper;
+
+void initRCSResourceAttributes(JNIEnvWrapper*);
+void clearRCSResourceAttributes(JNIEnvWrapper*);
+
+jobject newAttributesObject(JNIEnv*, const OIC::Service::RCSResourceAttributes&);
+jobject newAttributesObject(JNIEnvWrapper*, const OIC::Service::RCSResourceAttributes&);
+
+OIC::Service::RCSResourceAttributes toNativeAttributes(JNIEnv*, jobject);
+OIC::Service::RCSResourceAttributes toNativeAttributes(JNIEnvWrapper*, jobject);
+
+void writeNativeAttributesFromMap(JNIEnv*, jobject mapObj,
+        OIC::Service::RCSResourceAttributes& targetAttrs);
+void writeNativeAttributesFromMap(JNIEnvWrapper*, jobject mapObj,
+        OIC::Service::RCSResourceAttributes& targetAttrs);
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+JNIEXPORT jboolean JNICALL
+Java_org_iotivity_service_RcsResourceAttributes_nativeIsEmpty(JNIEnv*, jobject);
+
+JNIEXPORT jint JNICALL
+Java_org_iotivity_service_RcsResourceAttributes_nativeSize(JNIEnv*, jobject);
+
+JNIEXPORT jboolean JNICALL
+Java_org_iotivity_service_RcsResourceAttributes_nativeRemove(JNIEnv*, jobject, jstring keyObj);
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_RcsResourceAttributes_nativeClear(JNIEnv*, jobject);
+
+JNIEXPORT jboolean JNICALL
+Java_org_iotivity_service_RcsResourceAttributes_nativeContains(JNIEnv*, jobject, jstring keyObj);
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_RcsResourceAttributes_nativeAddKeys(JNIEnv*, jobject, jstring setObj);
+
+JNIEXPORT jobject JNICALL
+Java_org_iotivity_service_RcsResourceAttributes_nativeExtract(JNIEnv*, jobject, jstring keyObj);
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_RcsResourceAttributes_nativeExtractAll(JNIEnv*, jobject, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif  //JNI_RCS_RESOURCE_ATTRIBUTES_H_
diff --git a/service/resource-encapsulation/android/service/src/main/jni/JniRcsResourceContainer.cpp b/service/resource-encapsulation/android/service/src/main/jni/JniRcsResourceContainer.cpp
new file mode 100644 (file)
index 0000000..5f2b5cc
--- /dev/null
@@ -0,0 +1,281 @@
+/******************************************************************
+ *
+ * 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 "JniRcsResourceContainer.h"
+
+#include "JavaLocalRef.h"
+#include "JNIEnvWrapper.h"
+#include "Log.h"
+#include "Verify.h"
+#include "JniRcsObject.h"
+
+#include "RCSResourceContainer.h"
+#include "RCSBundleInfo.h"
+
+#define LOG_TAG "JNI-RCSResourceContainer"
+
+using namespace OIC::Service;
+
+#define CLS_NAME_BUNDLE_INFO PACKAGE_NAME "/server/RcsBundleInfo"
+
+namespace
+{
+    jclass g_cls_RCSBundleInfo;
+
+    jmethodID g_ctor_RCSBundleInfo;
+
+    std::map< std::string, std::string > convertJavaMapToParamsMap(JNIEnvWrapper* env,
+            jobject mapObj)
+    {
+        EXPECT_RET_DEF(mapObj, "map is null");
+
+        auto setObj = invoke_Map_entrySet(env, mapObj);
+        auto iterObj = invoke_Set_iterator(env, setObj);
+
+        std::map< std::string, std::string > ret;
+
+        while (invoke_Iterator_hasNext(env, iterObj))
+        {
+            JavaLocalObject entryObj{ env, invoke_Iterator_next(env, iterObj) };
+
+            JavaLocalString keyObj{ env,
+                static_cast< jstring >(invoke_MapEntry_getKey(env, entryObj)) };
+            JavaLocalString valueObj{ env,
+                static_cast< jstring >(invoke_MapEntry_getValue(env, entryObj)) };
+
+            ret.emplace(toStdString(env, keyObj), toStdString(env, valueObj));
+        }
+
+        return ret;
+    }
+}
+
+void initRCSResourceContainer(JNIEnvWrapper* env)
+{
+    g_cls_RCSBundleInfo = env->FindClassAsGlobalRef(CLS_NAME_BUNDLE_INFO);
+
+    g_ctor_RCSBundleInfo = env->GetConstructorID(g_cls_RCSBundleInfo, "()V");
+}
+
+void clearRCSResourceContainer(JNIEnvWrapper* env)
+{
+    env->DeleteGlobalRef(g_cls_RCSBundleInfo);
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsResourceContainer_nativeStartContainer
+(JNIEnv* env, jobject, jstring configFileObj)
+{
+    LOGD("nativeStartContainer");
+
+    EXPECT(configFileObj, "ConfigFile is null.");
+
+    auto configFile = toStdString(env, configFileObj);
+    VERIFY_NO_EXC(env);
+
+    RCSResourceContainer::getInstance()->startContainer(configFile);
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsResourceContainer_nativeStopContainer
+(JNIEnv* env, jobject)
+{
+    LOGD("nativeStopContainers");
+
+    RCSResourceContainer::getInstance()->stopContainer();
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsResourceContainer_nativeAddBundle
+(JNIEnv* env, jobject, jstring idObj, jstring uriObj, jstring pathObj, jstring activatorObj,
+        jobject paramsObj)
+{
+    LOGD("nativeAddBundle");
+
+    EXPECT(idObj, "BundleId is null.");
+    EXPECT(uriObj, "BundleUri is null.");
+    EXPECT(pathObj, "BundlePath is null.");
+    EXPECT(paramsObj, "Params is null.");
+    EXPECT(paramsObj, "Activator is null.");
+
+    JNIEnvWrapper envWrapper(env);
+
+    try
+    {
+        RCSResourceContainer::getInstance()->addBundle(toStdString(&envWrapper, idObj),
+                toStdString(&envWrapper, uriObj), toStdString(&envWrapper, pathObj),
+                toStdString(&envWrapper, activatorObj),
+                convertJavaMapToParamsMap(&envWrapper, paramsObj));
+    }
+    catch (const JavaException&)
+    {
+        LOGE("Failed to add bundle.");
+    }
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsResourceContainer_nativeRemoveBundle
+(JNIEnv* env, jobject, jstring idObj)
+{
+    LOGD("nativeRemoveBundle");
+
+    EXPECT(idObj, "BundleId is null.");
+
+    auto id = toStdString(env, idObj);
+    VERIFY_NO_EXC(env);
+
+    RCSResourceContainer::getInstance()->removeBundle(id);
+}
+
+
+JNIEXPORT jobject JNICALL
+Java_org_iotivity_service_server_RcsResourceContainer_nativeListBundles
+(JNIEnv* env, jobject)
+{
+    LOGD("nativeListBundles");
+
+    JNIEnvWrapper envWrapper(env);
+
+    try
+    {
+        auto listObj = newArrayList(&envWrapper);
+
+        for (auto bundleInfo : RCSResourceContainer::getInstance()->listBundles())
+        {
+            // FIXME we need a safe way to keep bundle info in java obj!!
+            // because we currently put raw pointer in the java obj.
+
+            JavaLocalObject bundleInfoObj { &envWrapper,
+                envWrapper.NewObject(g_cls_RCSBundleInfo, g_ctor_RCSBundleInfo) };
+
+            setSafeNativeHandle< RCSBundleInfo* >(&envWrapper, bundleInfoObj, bundleInfo);
+
+            invoke_Collection_add(&envWrapper, listObj, bundleInfoObj);
+        }
+    }
+    catch(const JavaException&)
+    {
+        LOGE("Failed to convert bundle info list.");
+    }
+
+    return nullptr;
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsResourceContainer_nativeStartBundle
+(JNIEnv* env, jobject, jstring idObj)
+{
+    LOGD("nativeStartBundle");
+
+    EXPECT(idObj, "BundleId is null.");
+
+    auto id = env->GetStringUTFChars(idObj, NULL);
+    VERIFY_NO_EXC(env);
+
+    RCSResourceContainer::getInstance()->startBundle(id);
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsResourceContainer_nativeStopBundle
+(JNIEnv* env, jobject, jstring idObj)
+{
+    LOGD("nativeStopBundle");
+
+    EXPECT(idObj, "BundleId is null.");
+
+    auto id = env->GetStringUTFChars(idObj, NULL);
+    VERIFY_NO_EXC(env);
+
+    RCSResourceContainer::getInstance()->stopBundle(id);
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsResourceContainer_nativeAddResourceConfig
+(JNIEnv* env, jobject, jstring idObj, jstring uriObj, jobject paramsObj)
+{
+    LOGD("nativeAddResourceConfig");
+
+    EXPECT(idObj, "BundleId is null.");
+    EXPECT(uriObj, "BundleUri is null.");
+    EXPECT(paramsObj, "Params is null.");
+
+    JNIEnvWrapper envWrapper(env);
+
+    try
+    {
+        RCSResourceContainer::getInstance()->addResourceConfig(toStdString(&envWrapper, idObj),
+                toStdString(&envWrapper, uriObj), convertJavaMapToParamsMap(&envWrapper, paramsObj));
+    }
+    catch (const JavaException&)
+    {
+        LOGE("Failed to add bundle.");
+    }
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsResourceContainer_nativeRemoveResourceConfig
+(JNIEnv* env, jobject, jstring idObj, jstring uriObj)
+{
+    LOGD("nativeRemoveResourceConfig");
+
+    EXPECT(idObj, "BundleId is null.");
+    EXPECT(uriObj, "BundleUri is null.");
+
+    auto id = toStdString(env, idObj);
+    VERIFY_NO_EXC(env);
+    auto uri = toStdString(env, uriObj);
+    VERIFY_NO_EXC(env);
+
+    RCSResourceContainer::getInstance()->removeResourceConfig(id, uri);
+}
+
+JNIEXPORT jobject JNICALL
+Java_org_iotivity_service_server_RcsResourceContainer_nativeListBundleResources
+(JNIEnv* env, jobject, jstring idObj)
+{
+    LOGD("nativeListBundleResources");
+
+    EXPECT_RET_DEF(idObj, "BundleId is null.");
+
+    JNIEnvWrapper envWrapper(env);
+
+    try
+    {
+        auto id = toStdString(&envWrapper, idObj);
+
+        auto listObj = newArrayList(&envWrapper);
+
+        for (const auto& s : RCSResourceContainer::getInstance()->listBundleResources(id))
+        {
+            JavaLocalString strObj{ &envWrapper, newStringObject(&envWrapper, s) };
+
+            invoke_Collection_add(&envWrapper, listObj, strObj);
+        }
+
+        return listObj;
+    }
+    catch(const JavaException&)
+    {
+        LOGE("Failed to convert bundle info list.");
+    }
+
+    return nullptr;
+}
+
diff --git a/service/resource-encapsulation/android/service/src/main/jni/JniRcsResourceContainer.h b/service/resource-encapsulation/android/service/src/main/jni/JniRcsResourceContainer.h
new file mode 100644 (file)
index 0000000..82ce507
--- /dev/null
@@ -0,0 +1,85 @@
+/******************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************/
+
+/** @file   jni_re_rcs_resource_container.h
+ *
+ *   @brief  This file contains the declaration of RCSResourceContainer
+ *    APIs for JNI implementation
+ */
+
+#ifndef JNI_RCS_RESOURCE_CONTAINER_H_
+#define JNI_RCS_RESOURCE_CONTAINER_H_
+
+#include <jni.h>
+
+class JNIEnvWrapper;
+
+void initRCSResourceContainer(JNIEnvWrapper*);
+void clearRCSResourceContainer(JNIEnvWrapper*);
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsResourceContainer_nativeStartContainer
+(JNIEnv*, jobject, jstring configFile);
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsResourceContainer_nativeStopContainer
+(JNIEnv*, jobject);
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsResourceContainer_nativeAddBundle
+(JNIEnv*, jobject, jstring bundleId, jstring bundleUri, jstring bundlePath, jstring activator,
+        jobject params);
+
+JNIEXPORT jobject JNICALL
+Java_org_iotivity_service_server_RcsResourceContainer_nativeListBundles
+(JNIEnv*, jobject);
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsResourceContainer_nativeRemoveBundle
+(JNIEnv*, jobject, jstring bundleId);
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsResourceContainer_nativeStartBundle
+(JNIEnv*, jobject, jstring bundleId);
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsResourceContainer_nativeStopBundle
+(JNIEnv*, jobject, jstring bundleId);
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsResourceContainer_nativeAddResourceConfig
+(JNIEnv*, jobject, jstring bundleId, jstring resourceUri, jobject params);
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsResourceContainer_nativeRemoveResourceConfig
+(JNIEnv*, jobject, jstring bundleId, jstring resourceUri);
+
+JNIEXPORT jobject JNICALL
+Java_org_iotivity_service_server_RcsResourceContainer_nativeListBundleResources
+(JNIEnv*, jobject, jstring bundleId);
+
+#ifdef __cplusplus
+}
+#endif
+#endif //JNI_RCS_RESOURCE_CONTAINER_H_
diff --git a/service/resource-encapsulation/android/service/src/main/jni/JniRcsResourceObject.cpp b/service/resource-encapsulation/android/service/src/main/jni/JniRcsResourceObject.cpp
new file mode 100644 (file)
index 0000000..34e129f
--- /dev/null
@@ -0,0 +1,667 @@
+/******************************************************************
+ *
+ * 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 "JniRcsResourceObject.h"
+
+#include "JniRcsObject.h"
+#include "JniRcsResourceAttributes.h"
+#include "JavaClasses.h"
+#include "JavaExceptions.h"
+#include "JavaGlobalRef.h"
+#include "JniRcsValue.h"
+#include "Log.h"
+#include "ScopedEnv.h"
+#include "Verify.h"
+
+#include "RCSResourceObject.h"
+#include "RCSResponse.h"
+#include "RequestHandler.h"
+
+#define LOG_TAG "JNI-RCSResourceObject"
+
+#define CLS_NAME_RCS_RESOURCE_OBJECT PACKAGE_NAME "/server/RcsResourceObject"
+#define CLS_NAME_RCS_REQUEST PACKAGE_NAME "/server/RcsRequest"
+
+#define CLS_NAME_AUTO_NOTIFY_POLICY CLS_NAME_RCS_RESOURCE_OBJECT "$AutoNotifyPolicy"
+#define CLS_NAME_SET_REQUEST_HANDLER_POLICY CLS_NAME_RCS_RESOURCE_OBJECT "$SetRequestHandlerPolicy"
+
+#define CLS_NAME_GET_REQUEST_HANDLER CLS_NAME_RCS_RESOURCE_OBJECT "$GetRequestHandler"
+#define CLS_NAME_SET_REQUEST_HANDLER CLS_NAME_RCS_RESOURCE_OBJECT "$SetRequestHandler"
+#define CLS_NAME_ON_ATTRIBUTE_UPDATESD_LISTENER \
+    CLS_NAME_RCS_RESOURCE_OBJECT "$OnAttributeUpdatedListener"
+
+#define CLS_NAME_RCS_RESPONSE PACKAGE_NAME "/server/RcsResponse"
+
+#define CLS_NAME_RCS_GET_RESPONSE PACKAGE_NAME "/server/RcsGetResponse"
+#define CLS_NAME_RCS_SET_RESPONSE PACKAGE_NAME "/server/RcsSetResponse"
+#define CLS_NAME_RCS_SET_RESPONSE_ACCEPTANCE_METHOD CLS_NAME_RCS_SET_RESPONSE "$AcceptanceMethod"
+
+using namespace OIC::Service;
+
+namespace
+{
+    jclass g_cls_RCSRequest;
+    jclass g_cls_RCSResourceObject;
+
+    jmethodID g_ctor_RCSRequest;
+    jmethodID g_ctor_RCSResourceObject;
+
+    jmethodID g_method_GetRequestHandler_onGetRequested;
+    jmethodID g_method_SetRequestHandler_onSetRequested;
+    jmethodID g_method_OnAttributeUpdatedListener_onAttributeUpdated;
+
+    jfieldID g_field_RCSResponse_mErrorCode;
+    jfieldID g_field_RCSResponse_mAttrs;
+    jfieldID g_field_RCSSetResponse_mAcceptanceMethod;
+
+    jobject g_obj_RCSSetResponse_AcceptanceMethod_DEFAULT;
+    jobject g_obj_RCSSetResponse_AcceptanceMethod_ACCEPT;
+    jobject g_obj_RCSSetResponse_AcceptanceMethod_IGNORE;
+
+    jobject g_obj_AutoNotifyPolicy_NEVER;
+    jobject g_obj_AutoNotifyPolicy_ALWAYS;
+    jobject g_obj_AutoNotifyPolicy_UPDATED;
+
+    jobject g_obj_SetRequestHandlerPolicy_NEVER;
+    jobject g_obj_SetRequestHandlerPolicy_ACCEPT;
+
+    inline RCSResourceObject::Ptr& getResource(JNIEnv* env, jobject obj)
+    {
+        return getNativeHandleAs< RCSResourceObject::Ptr >(env, obj);
+    }
+
+    inline RCSResourceObject::AutoNotifyPolicy convertAutoNotifyPolicy(JNIEnv* env, jobject obj)
+    {
+        if (env->IsSameObject(g_obj_AutoNotifyPolicy_NEVER, obj))
+        {
+            return RCSResourceObject::AutoNotifyPolicy::NEVER;
+        }
+
+        if (env->IsSameObject(g_obj_AutoNotifyPolicy_ALWAYS, obj))
+        {
+            return RCSResourceObject::AutoNotifyPolicy::ALWAYS;
+        }
+
+        if (env->IsSameObject(g_obj_AutoNotifyPolicy_UPDATED, obj))
+        {
+            return RCSResourceObject::AutoNotifyPolicy::UPDATED;
+        }
+
+        throwRCSException(env, "Failed to convert AutoNotifyPolicy");
+        return {};
+    }
+
+    inline jobject convertAutoNotifyPolicy(JNIEnv* env, RCSResourceObject::AutoNotifyPolicy policy)
+    {
+        switch(policy)
+        {
+            case RCSResourceObject::AutoNotifyPolicy::NEVER: return g_obj_AutoNotifyPolicy_NEVER;
+            case RCSResourceObject::AutoNotifyPolicy::ALWAYS: return g_obj_AutoNotifyPolicy_ALWAYS;
+            case RCSResourceObject::AutoNotifyPolicy::UPDATED: return g_obj_AutoNotifyPolicy_UPDATED;
+        }
+
+        throwRCSException(env, "Failed to convert AutoNotifyPolicy");
+        return {};
+    }
+
+    inline RCSResourceObject::SetRequestHandlerPolicy convertSetRequestHandlerPolicy(JNIEnv* env,
+            jobject obj)
+    {
+        if (env->IsSameObject(g_obj_SetRequestHandlerPolicy_NEVER, obj))
+        {
+            return RCSResourceObject::SetRequestHandlerPolicy::NEVER;
+        }
+
+        if (env->IsSameObject(g_obj_SetRequestHandlerPolicy_ACCEPT, obj))
+        {
+            return RCSResourceObject::SetRequestHandlerPolicy::ACCEPTANCE;
+        }
+
+        throwRCSException(env, "Failed to convert SetRequestHandlerPolicy");
+        return {};
+    }
+
+    inline jobject convertSetRequestHandlerPolicy(JNIEnv* env,
+            RCSResourceObject::SetRequestHandlerPolicy policy)
+    {
+        switch(policy)
+        {
+            case RCSResourceObject::SetRequestHandlerPolicy::NEVER:
+                return g_obj_SetRequestHandlerPolicy_NEVER;
+            case RCSResourceObject::SetRequestHandlerPolicy::ACCEPTANCE:
+                return g_obj_SetRequestHandlerPolicy_ACCEPT;
+        }
+
+        throwRCSException(env, "Failed to convert SetRequestHandlerPolicy");
+        return {};
+    }
+
+
+    template< typename ENV >
+    inline jobject getAttrsObj(ENV& env, jobject responseObj)
+    {
+        return env->GetObjectField(responseObj, g_field_RCSResponse_mAttrs);
+    }
+
+    template< typename ENV >
+    inline int getErrorCode(ENV& env, jobject responseObj)
+    {
+        return env->GetIntField(responseObj, g_field_RCSResponse_mErrorCode);
+    }
+
+    template< typename ENV >
+    inline RCSSetResponse::AcceptanceMethod getAcceptanceMethod(ENV& env, jobject responseObj)
+    {
+        auto methodObj = env->GetObjectField(responseObj, g_field_RCSSetResponse_mAcceptanceMethod);
+
+        if (env->IsSameObject(methodObj, g_obj_RCSSetResponse_AcceptanceMethod_IGNORE))
+        {
+            return RCSSetResponse::AcceptanceMethod::IGNORE;
+        }
+
+        if (env->IsSameObject(methodObj, g_obj_RCSSetResponse_AcceptanceMethod_ACCEPT))
+        {
+            return RCSSetResponse::AcceptanceMethod::ACCEPT;
+        }
+
+        return RCSSetResponse::AcceptanceMethod::DEFAULT;
+    }
+
+    inline jobject callHandler(ScopedEnvWrapper& env, jobject listener, jmethodID methodId,
+            const RCSRequest& request, const RCSResourceAttributes& attrs)
+    {
+        auto requestObj = env->NewObject(g_cls_RCSRequest, g_ctor_RCSRequest,
+                env->NewStringUTF(request.getResourceUri().c_str()));
+        auto attrsObj = newAttributesObject(env.get(), attrs);
+
+        return env->CallObjectMethod(listener, methodId, requestObj, attrsObj);
+    }
+
+    template< typename RESPONSE >
+    inline RESPONSE createResponse(ScopedEnvWrapper& env, jobject responseObj)
+    {
+        auto errorCode = getErrorCode(env, responseObj);
+        auto responseAttrsObj = getAttrsObj(env, responseObj);
+
+        if (responseAttrsObj)
+        {
+            return RESPONSE::create(toNativeAttributes(env.get(), responseAttrsObj), OC_EH_OK,
+                    errorCode);
+        }
+
+        return RESPONSE::create(OC_EH_OK, errorCode);
+    }
+
+    RCSGetResponse onGetRequest(const RCSRequest& request, const RCSResourceAttributes& attrs,
+            const JavaGlobalRef& listener)
+    {
+        ScopedEnvWrapper env;
+        EXPECT_RET(env, "env is null!", RCSGetResponse::create(OC_EH_ERROR, -1));
+
+        try
+        {
+            auto responseObj = callHandler(env, listener, g_method_GetRequestHandler_onGetRequested,
+                    request, attrs);
+
+            return createResponse< RCSGetResponse >(env, responseObj);
+        }
+        catch (const JavaException&)
+        {
+            env->ExceptionDescribe();
+            env->ExceptionClear();
+        }
+        return RCSGetResponse::create(OC_EH_ERROR, -1);
+    }
+
+    RCSSetResponse onSetRequest(const RCSRequest& request, const RCSResourceAttributes& attrs,
+             const JavaGlobalRef& listener)
+    {
+        ScopedEnvWrapper env;
+        EXPECT_RET(env, "env is null!", RCSSetResponse::create(OC_EH_ERROR, -1));
+
+        try
+        {
+            auto responseObj = callHandler(env, listener, g_method_SetRequestHandler_onSetRequested,
+                               request, attrs);
+
+            auto acceptanceMethod = getAcceptanceMethod(env, responseObj);
+
+            return createResponse< RCSSetResponse >(env, responseObj).
+                    setAcceptanceMethod(acceptanceMethod);
+        }
+        catch (const JavaException&)
+        {
+            env->ExceptionDescribe();
+            env->ExceptionClear();
+        }
+        return RCSSetResponse::create(OC_EH_ERROR, -1);
+    }
+
+
+    void onAttributeUpdated(const RCSResourceAttributes::Value& oldVal,
+            const RCSResourceAttributes::Value& newVal, const JavaGlobalRef& listener)
+    {
+        ScopedEnvWrapper env;
+        EXPECT(env, "env is null!");
+
+        try
+        {
+            env->CallVoidMethod(listener, g_method_OnAttributeUpdatedListener_onAttributeUpdated,
+                    newRCSValueObject(env.get(), oldVal), newRCSValueObject(env.get(), newVal));
+        }
+        catch (const JavaException&)
+        {
+            env->ExceptionDescribe();
+            env->ExceptionClear();
+        }
+    }
+
+    void initRCSResponse(JNIEnvWrapper* env)
+    {
+        auto clsRCSResponse = env->FindClass(CLS_NAME_RCS_RESPONSE);
+
+        g_field_RCSResponse_mErrorCode = env->GetFieldID(clsRCSResponse, "mErrorCode", "I");
+
+        g_field_RCSResponse_mAttrs = env->GetFieldID(clsRCSResponse, "mAttrs",
+                AS_SIG(CLS_NAME_RESOURCEATTRIBUTES));
+
+        auto clsRCSSetResponse = env->FindClass(CLS_NAME_RCS_SET_RESPONSE);
+
+        g_field_RCSSetResponse_mAcceptanceMethod = env->GetFieldID(clsRCSSetResponse,
+                "mAcceptanceMethod", AS_SIG(CLS_NAME_RCS_SET_RESPONSE_ACCEPTANCE_METHOD));
+
+        auto clsAcceptanceMethod = env->FindClass(CLS_NAME_RCS_SET_RESPONSE_ACCEPTANCE_METHOD);
+
+        g_obj_RCSSetResponse_AcceptanceMethod_DEFAULT = env->NewGlobalRef(
+                env->GetStaticObjectField(clsAcceptanceMethod, "DEFAULT",
+                        AS_SIG(CLS_NAME_RCS_SET_RESPONSE_ACCEPTANCE_METHOD)));
+
+        g_obj_RCSSetResponse_AcceptanceMethod_ACCEPT = env->NewGlobalRef(
+                env->GetStaticObjectField(clsAcceptanceMethod, "ACCEPT",
+                        AS_SIG(CLS_NAME_RCS_SET_RESPONSE_ACCEPTANCE_METHOD)));
+
+        g_obj_RCSSetResponse_AcceptanceMethod_IGNORE = env->NewGlobalRef(
+                env->GetStaticObjectField(clsAcceptanceMethod, "IGNORE",
+                        AS_SIG(CLS_NAME_RCS_SET_RESPONSE_ACCEPTANCE_METHOD)));
+    }
+}
+
+void initRCSResourceObject(JNIEnvWrapper* env)
+{
+    g_cls_RCSResourceObject = env->FindClassAsGlobalRef(CLS_NAME_RCS_RESOURCE_OBJECT);
+
+    g_ctor_RCSResourceObject = env->GetMethodID(g_cls_RCSResourceObject, "<init>", "()V");
+
+    g_cls_RCSRequest = env->FindClassAsGlobalRef(CLS_NAME_RCS_REQUEST);
+
+    g_ctor_RCSRequest = env->GetMethodID(g_cls_RCSRequest, "<init>",
+            "(" AS_SIG(CLS_NAME_STRING) ")V");
+
+    auto clsGetRequestHandler = env->FindClass(CLS_NAME_GET_REQUEST_HANDLER);
+
+    g_method_GetRequestHandler_onGetRequested = env->GetMethodID(clsGetRequestHandler,
+            "onGetRequested",
+            "(" AS_SIG(CLS_NAME_RCS_REQUEST) AS_SIG(CLS_NAME_RESOURCEATTRIBUTES) ")"
+                AS_SIG(CLS_NAME_RCS_GET_RESPONSE));
+
+    auto clsSetRequestHandler = env->FindClass(CLS_NAME_SET_REQUEST_HANDLER);
+
+    g_method_SetRequestHandler_onSetRequested = env->GetMethodID(clsSetRequestHandler,
+            "onSetRequested",
+            "(" AS_SIG(CLS_NAME_RCS_REQUEST) AS_SIG(CLS_NAME_RESOURCEATTRIBUTES) ")"
+                AS_SIG(CLS_NAME_RCS_SET_RESPONSE));
+
+    auto clsOnAttributeUpdatedListener = env->FindClass(CLS_NAME_ON_ATTRIBUTE_UPDATESD_LISTENER);
+
+    g_method_OnAttributeUpdatedListener_onAttributeUpdated = env->GetMethodID(
+            clsOnAttributeUpdatedListener, "onAttributeUpdated",
+            "(" AS_SIG(CLS_NAME_VALUE) AS_SIG(CLS_NAME_VALUE) ")V");
+
+    auto clsAutoNotifyPolicy = env->FindClass(CLS_NAME_AUTO_NOTIFY_POLICY);
+
+    g_obj_AutoNotifyPolicy_NEVER = env->NewGlobalRef(
+            env->GetStaticObjectField(clsAutoNotifyPolicy, "NEVER",
+                    AS_SIG(CLS_NAME_AUTO_NOTIFY_POLICY)));
+
+    g_obj_AutoNotifyPolicy_ALWAYS = env->NewGlobalRef(
+            env->GetStaticObjectField(clsAutoNotifyPolicy, "ALWAYS",
+                    AS_SIG(CLS_NAME_AUTO_NOTIFY_POLICY)));
+
+
+    g_obj_AutoNotifyPolicy_UPDATED = env->NewGlobalRef(
+            env->GetStaticObjectField(clsAutoNotifyPolicy, "UPDATED",
+                    AS_SIG(CLS_NAME_AUTO_NOTIFY_POLICY)));
+
+    auto clsSetRequestHandlerPolicy = env->FindClass(CLS_NAME_SET_REQUEST_HANDLER_POLICY);
+
+    g_obj_SetRequestHandlerPolicy_NEVER = env->NewGlobalRef(
+            env->GetStaticObjectField(clsSetRequestHandlerPolicy, "NEVER",
+                    AS_SIG(CLS_NAME_SET_REQUEST_HANDLER_POLICY)));
+
+    g_obj_SetRequestHandlerPolicy_ACCEPT = env->NewGlobalRef(
+            env->GetStaticObjectField(clsSetRequestHandlerPolicy, "ACCEPT",
+                    AS_SIG(CLS_NAME_SET_REQUEST_HANDLER_POLICY)));
+
+    initRCSResponse(env);
+}
+
+void clearRCSResourceObject(JNIEnvWrapper* env)
+{
+    env->DeleteGlobalRef(g_cls_RCSRequest);
+
+    env->DeleteGlobalRef(g_obj_RCSSetResponse_AcceptanceMethod_DEFAULT);
+    env->DeleteGlobalRef(g_obj_RCSSetResponse_AcceptanceMethod_ACCEPT);
+    env->DeleteGlobalRef(g_obj_RCSSetResponse_AcceptanceMethod_IGNORE);
+
+    env->DeleteGlobalRef(g_obj_AutoNotifyPolicy_NEVER);
+    env->DeleteGlobalRef(g_obj_AutoNotifyPolicy_ALWAYS);
+    env->DeleteGlobalRef(g_obj_AutoNotifyPolicy_UPDATED);
+
+    env->DeleteGlobalRef(g_obj_SetRequestHandlerPolicy_NEVER);
+    env->DeleteGlobalRef(g_obj_SetRequestHandlerPolicy_ACCEPT);
+}
+
+JNIEXPORT jint JNICALL
+Java_org_iotivity_service_server_RcsResponse_nativeGetDefaultErrorCode
+(JNIEnv*, jclass)
+{
+    return RequestHandler::DEFAULT_ERROR_CODE;
+}
+
+JNIEXPORT jobject JNICALL
+Java_org_iotivity_service_server_RcsResourceObject_nativeBuild
+(JNIEnv* env, jclass, jstring uriObj, jstring typeObj, jstring interfaceObj, jboolean isObservable,
+        jboolean isDiscoverable, jobject attrsObj)
+{
+    LOGI("nativeBuild");
+
+    EXPECT_RET_DEF(uriObj, "uri is null.");
+
+    auto uri = toStdString(env, uriObj);
+    auto type = toStdString(env, typeObj);
+    auto interface = toStdString(env, interfaceObj);
+
+    RCSResourceAttributes attrs;
+    if (attrsObj)
+    {
+        attrs = toNativeAttributes(env, attrsObj);
+        VERIFY_NO_EXC_RET_DEF(env);
+    }
+
+    try
+    {
+        auto resource = RCSResourceObject::Builder(uri, type,interface).
+                setDiscoverable(isDiscoverable). setObservable(isObservable).setAttributes(attrs).
+                build();
+
+        auto resourceObj = env->NewObject(g_cls_RCSResourceObject, g_ctor_RCSResourceObject);
+        VERIFY_NO_EXC_RET_DEF(env);
+
+        setSafeNativeHandle< decltype(resource) >(env, resourceObj, resource);
+
+        return resourceObj;
+    }
+    catch (const PlatformException& e)
+    {
+        LOGE("%s", e.what());
+        throwPlatformException(env, e);
+    }
+
+    return nullptr;
+}
+
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsResourceObject_nativeSetAttribute
+(JNIEnv* env, jobject obj, jstring keyObj, jobject valueObj)
+{
+    LOGD("nativeSetAttributeInteger");
+
+    EXPECT(keyObj, "key is null.");
+    EXPECT(valueObj, "value is null.");
+
+    auto res = getResource(env, obj);
+    VERIFY_NO_EXC(env);
+
+    res->setAttribute(toStdString(env, keyObj), toNativeAttrsValue(env, valueObj));
+}
+
+JNIEXPORT jobject JNICALL
+Java_org_iotivity_service_server_RcsResourceObject_nativeGetAttributeValue
+(JNIEnv *env, jobject obj, jstring keyObj)
+{
+    LOGD("nativeGetAttributeValue");
+
+    EXPECT_RET_DEF(keyObj, "key is null.");
+
+    auto res = getResource(env, obj);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    try
+    {
+        auto valueObj = newRCSValueObject(env, res->getAttributeValue(toStdString(env, keyObj)));
+        VERIFY_NO_EXC_RET_DEF(env);
+
+        return valueObj;
+    }
+    catch(const InvalidKeyException& e)
+    {
+        return nullptr;
+    }
+}
+
+JNIEXPORT jboolean JNICALL
+Java_org_iotivity_service_server_RcsResourceObject_nativeRemoveAttribute
+(JNIEnv* env, jobject obj, jstring keyObj)
+{
+    LOGD("nativeRemoveAttribute");
+
+    EXPECT_RET_DEF(keyObj, "key is null.");
+
+    auto res = getResource(env, obj);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    return res->removeAttribute(toStdString(env, keyObj));
+}
+
+JNIEXPORT jboolean JNICALL
+Java_org_iotivity_service_server_RcsResourceObject_nativeContainsAttribute
+(JNIEnv* env, jobject obj, jstring keyObj)
+{
+    LOGD("nativeContainsAttribute");
+
+    EXPECT_RET_DEF(keyObj, "key is null.");
+
+    auto res = getResource(env, obj);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    return res->containsAttribute(toStdString(env, keyObj));
+}
+
+JNIEXPORT jobject JNICALL
+Java_org_iotivity_service_server_RcsResourceObject_nativeGetAttributes
+(JNIEnv* env, jobject obj)
+{
+    LOGD("nativeGetAttributes");
+
+    auto res = getResource(env, obj);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    RCSResourceObject::LockGuard lock{ res };
+    return newAttributesObject(env, res->getAttributes());
+}
+
+JNIEXPORT jboolean JNICALL
+Java_org_iotivity_service_server_RcsResourceObject_nativeIsObservable
+(JNIEnv* env, jobject obj)
+{
+    LOGD("nativeIsObservable");
+
+    auto res = getResource(env, obj);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    return res->isObservable();
+}
+
+JNIEXPORT jboolean JNICALL
+Java_org_iotivity_service_server_RcsResourceObject_nativeIsDiscoverable
+(JNIEnv *env, jobject obj)
+{
+    LOGD("nativeIsDiscoverable");
+
+    auto res = getResource(env, obj);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    return res->isDiscoverable();
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsResourceObject_nativeSetGetRequestHandler
+(JNIEnv *env, jobject obj, jobject listenerObj)
+{
+    LOGD("nativeSetGetRequestHandler");
+
+    auto res = getResource(env, obj);
+    VERIFY_NO_EXC(env);
+
+    res->setGetRequestHandler(std::bind(onGetRequest, std::placeholders::_1, std::placeholders::_2,
+            JavaGlobalRef{ env, listenerObj }));
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsResourceObject_nativeSetSetRequestHandler
+(JNIEnv* env, jobject obj, jobject listenerObj)
+{
+    LOGD("nativeSetSetRequestHandler");
+
+    auto res = getResource(env, obj);
+    VERIFY_NO_EXC(env);
+
+    res->setSetRequestHandler(std::bind(onSetRequest, std::placeholders::_1, std::placeholders::_2,
+           JavaGlobalRef{ env, listenerObj }));
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsResourceObject_nativeAddAttributeUpdatedListener
+(JNIEnv* env, jobject obj, jstring keyObj, jobject listenerObj)
+{
+    LOGD("nativeAddAttributeUpdatedListener");
+
+    auto res = getResource(env, obj);
+    VERIFY_NO_EXC(env);
+
+    auto key = toStdString(env, keyObj);
+    VERIFY_NO_EXC(env);
+
+    res->addAttributeUpdatedListener(std::move(key), std::bind(onAttributeUpdated,
+            std::placeholders::_1, std::placeholders::_2, JavaGlobalRef{ env, listenerObj }));
+}
+
+JNIEXPORT jboolean JNICALL
+Java_org_iotivity_service_server_RcsResourceObject_nativeRemoveAttributeUpdatedListener
+(JNIEnv* env, jobject obj, jstring keyObj)
+{
+    LOGD("nativeAddAttributeUpdatedListener");
+
+    EXPECT_RET_DEF(keyObj, "key is null");
+
+    auto res = getResource(env, obj);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    auto key = toStdString(env, keyObj);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    return res->removeAttributeUpdatedListener(key);
+}
+
+JNIEXPORT void JNICALL Java_org_iotivity_service_server_RcsResourceObject_nativeNotify
+(JNIEnv* env, jobject obj)
+{
+    LOGD("nativeNotify");
+
+    auto res = getResource(env, obj);
+    VERIFY_NO_EXC(env);
+
+    try
+    {
+        res->notify();
+    }
+    catch (const PlatformException& e) {
+        throwPlatformException(env, e);
+    }
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsResourceObject_nativeSetAutoNotifyPolicy
+(JNIEnv* env, jobject obj, jobject policyObj)
+{
+    LOGD("nativeSetAutoNotifyPolicy");
+
+    EXPECT(policyObj, "policyObj is null");
+
+    auto res = getResource(env, obj);
+    VERIFY_NO_EXC(env);
+
+    auto policy = convertAutoNotifyPolicy(env, policyObj);
+    VERIFY_NO_EXC(env);
+
+    res->setAutoNotifyPolicy(policy);
+}
+
+JNIEXPORT jobject JNICALL
+Java_org_iotivity_service_server_RcsResourceObject_nativeGetAutoNotifyPolicy
+(JNIEnv* env, jobject obj)
+{
+    LOGD("nativeGetAutoNotifyPolicy");
+
+    auto res = getResource(env, obj);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    return convertAutoNotifyPolicy(env, res->getAutoNotifyPolicy());
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsResourceObject_nativeSetSetRequestHandlerPolicy
+(JNIEnv* env, jobject obj, jobject policyObj)
+{
+    LOGD("nativeSetSetRequestHandlerPolicy");
+
+    EXPECT(policyObj, "policyObj is null");
+
+    auto res = getResource(env, obj);
+    VERIFY_NO_EXC(env);
+
+    auto policy = convertSetRequestHandlerPolicy(env, policyObj);
+    VERIFY_NO_EXC(env);
+
+    res->setSetRequestHandlerPolicy(policy);
+}
+
+JNIEXPORT jobject JNICALL
+Java_org_iotivity_service_server_RcsResourceObject_nativeGetSetRequestHandlerPolicy
+(JNIEnv* env, jobject obj)
+{
+    LOGD("nativeGetSetRequestHandlerPolicy");
+
+    auto res = getResource(env, obj);
+    VERIFY_NO_EXC_RET_DEF(env);
+
+    return convertSetRequestHandlerPolicy(env, res->getSetRequestHandlerPolicy());
+}
diff --git a/service/resource-encapsulation/android/service/src/main/jni/JniRcsResourceObject.h b/service/resource-encapsulation/android/service/src/main/jni/JniRcsResourceObject.h
new file mode 100644 (file)
index 0000000..0c3aae6
--- /dev/null
@@ -0,0 +1,112 @@
+/******************************************************************
+ *
+ * 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_RCS_RESOURCE_OBJECT_H
+#define JNI_RCS_RESOURCE_OBJECT_H
+
+#include <jni.h>
+
+class JNIEnvWrapper;
+
+void initRCSResourceObject(JNIEnvWrapper*);
+void clearRCSResourceObject(JNIEnvWrapper*);
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+JNIEXPORT jint JNICALL
+Java_org_iotivity_service_server_RcsResponse_nativeGetDefaultErrorCode
+(JNIEnv*, jclass);
+
+JNIEXPORT jobject JNICALL
+Java_org_iotivity_service_server_RcsResourceObject_nativeBuild
+(JNIEnv*, jclass, jstring uri, jstring type, jstring interface, jboolean isObservable,
+        jboolean isDiscovervable, jobject attrs);
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsResourceObject_nativeSetAttribute
+(JNIEnv*, jobject, jstring key, jobject value);
+
+JNIEXPORT jobject JNICALL
+Java_org_iotivity_service_server_RcsResourceObject_nativeGetAttributeValue
+(JNIEnv*, jobject, jstring key);
+
+JNIEXPORT jboolean JNICALL
+Java_org_iotivity_service_server_RcsResourceObject_nativeRemoveAttribute
+(JNIEnv*, jobject, jstring key);
+
+JNIEXPORT jboolean JNICALL
+Java_org_iotivity_service_server_RcsResourceObject_nativeContainsAttribute
+(JNIEnv*, jobject, jstring key);
+
+JNIEXPORT jobject JNICALL
+Java_org_iotivity_service_server_RcsResourceObject_nativeGetAttributes
+(JNIEnv*, jobject);
+
+JNIEXPORT jboolean JNICALL
+Java_org_iotivity_service_server_RcsResourceObject_nativeIsObservable
+(JNIEnv*, jobject);
+
+JNIEXPORT jboolean JNICALL
+Java_org_iotivity_service_server_RcsResourceObject_nativeIsDiscoverable
+(JNIEnv*, jobject);
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsResourceObject_nativeSetGetRequestHandler
+(JNIEnv*, jobject, jobject handler);
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsResourceObject_nativeSetSetRequestHandler
+(JNIEnv*, jobject, jobject handler);
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsResourceObject_nativeAddAttributeUpdatedListener
+(JNIEnv*, jobject, jstring key, jobject listenr);
+
+JNIEXPORT jboolean JNICALL
+Java_org_iotivity_service_server_RcsResourceObject_nativeRemoveAttributeUpdatedListener
+(JNIEnv*, jobject, jstring key);
+
+JNIEXPORT void JNICALL Java_org_iotivity_service_server_RcsResourceObject_nativeNotify
+(JNIEnv*, jobject);
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsResourceObject_nativeSetAutoNotifyPolicy
+(JNIEnv*, jobject, jobject policyObj);
+
+JNIEXPORT jobject JNICALL
+Java_org_iotivity_service_server_RcsResourceObject_nativeGetAutoNotifyPolicy
+(JNIEnv*, jobject);
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_service_server_RcsResourceObject_nativeSetSetRequestHandlerPolicy
+(JNIEnv*, jobject, jobject policyObj);
+
+JNIEXPORT jobject JNICALL
+Java_org_iotivity_service_server_RcsResourceObject_nativeGetSetRequestHandlerPolicy
+(JNIEnv*, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+#endif // JNI_RCS_RESOURCE_OBJECT_H
+
+
diff --git a/service/resource-encapsulation/android/service/src/main/jni/JniRcsValue.cpp b/service/resource-encapsulation/android/service/src/main/jni/JniRcsValue.cpp
new file mode 100644 (file)
index 0000000..46ea958
--- /dev/null
@@ -0,0 +1,567 @@
+/******************************************************************
+ *
+ * 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 "JniRcsValue.h"
+
+#include "JniRcsObject.h"
+#include "JniRcsResourceAttributes.h"
+#include "JavaClasses.h"
+#include "JavaExceptions.h"
+#include "JavaLocalRef.h"
+#include "Log.h"
+
+using namespace OIC::Service;
+
+#define LOG_TAG "JNI-RCSValue"
+
+#define CLS_NAME_VALUE_TYPE CLS_NAME_VALUE "$Type"
+#define CLS_NAME_VALUE_TYPEID CLS_NAME_VALUE "$TypeId"
+#define CLS_NAME_VALUE_NULL_TYPE CLS_NAME_VALUE "$NullType"
+
+namespace
+{
+    jclass g_cls_RCSValue;
+    jclass g_cls_Type;
+    jclass g_cls_TypeId;
+
+    jmethodID g_ctor_RCSValue;
+
+    jmethodID g_smethod_Type_getDepth;
+    jmethodID g_smethod_Type_getBaseTypeId;
+
+    jmethodID g_method_RCSValue_getType;
+
+    jfieldID g_field_RCSValue_mObject;
+    jfieldID g_field_RCSValue_sNullValue;
+
+    jobject g_obj_TypeId_Null;
+    jobject g_obj_TypeId_Boolean;
+    jobject g_obj_TypeId_Integer;
+    jobject g_obj_TypeId_Double;
+    jobject g_obj_TypeId_String;
+    jobject g_obj_TypeId_Attributes;
+    jobject g_obj_TypeId_Array;
+
+    template< int >
+    struct Int2Type{ };
+
+    template< int DEPTH, typename BASE_TYPE >
+    struct SeqType
+    {
+        typedef std::vector< typename SeqType< DEPTH - 1, BASE_TYPE >::type > type;
+    };
+
+    template< typename BASE_TYPE >
+    struct SeqType< 0, BASE_TYPE >
+    {
+        typedef BASE_TYPE type;
+    };
+
+    template< typename T >
+    struct BaseType
+    {
+      typedef T type;
+    };
+
+    template< typename T >
+    struct BaseType< std::vector< T > >
+    {
+      typedef typename BaseType< T >::type type;
+    };
+
+
+    template< int D >
+    struct ArrayPrefix
+    {
+        static constexpr char str[] = "";
+    };
+    template< int D >
+    constexpr char ArrayPrefix< D >::str[];
+
+    template<>
+    struct ArrayPrefix< 1 >
+    {
+        static constexpr char str[] = "[";
+    };
+    constexpr char ArrayPrefix< 1 >::str[];
+
+    template<>
+    struct ArrayPrefix< 2 >
+    {
+        static constexpr char str[] = "[[";
+    };
+    constexpr char ArrayPrefix< 2 >::str[];
+
+    struct PrimitiveType {
+        static constexpr bool isPrimitive = true;
+    };
+
+    struct ObjectType {
+        static constexpr bool isPrimitive = false;
+    };
+
+    template< typename T >
+    struct JniTypeTrait;
+
+    template<>
+    struct JniTypeTrait< int >: public PrimitiveType
+    {
+        static_assert(sizeof(int) == sizeof(jint), "int and jint have different size!");
+
+        static constexpr decltype(&JNIEnvWrapper::NewIntArray) newArrayFunc =
+                &JNIEnvWrapper::NewIntArray;
+        static constexpr decltype(&JNIEnvWrapper::SetIntArrayRegion) setArrayRegionFunc =
+                      &JNIEnvWrapper::SetIntArrayRegion;
+
+        static constexpr decltype(&invoke_Integer_intValue<JNIEnvWrapper>) converter =
+                      &invoke_Integer_intValue<JNIEnvWrapper>;
+
+        static constexpr decltype(&newIntegerObject<JNIEnvWrapper>) newObjectFunc =
+                &newIntegerObject<JNIEnvWrapper>;
+
+        static constexpr char className[] = "I";
+    };
+    constexpr char JniTypeTrait< int >::className[];
+
+    template<>
+    struct JniTypeTrait< bool >: public PrimitiveType
+    {
+        static_assert(sizeof(bool) == sizeof(jboolean), "bool and jboolean have different size!");
+
+        static constexpr decltype(&JNIEnvWrapper::NewBooleanArray) newArrayFunc =
+                &JNIEnvWrapper::NewBooleanArray;
+        static constexpr decltype(&JNIEnvWrapper::SetBooleanArrayRegion) setArrayRegionFunc =
+                      &JNIEnvWrapper::SetBooleanArrayRegion;
+
+        static constexpr decltype(&invoke_Boolean_booleanValue<JNIEnvWrapper>) converter =
+                      &invoke_Boolean_booleanValue<JNIEnvWrapper>;
+
+        static constexpr decltype(&newBooleanObject<JNIEnvWrapper>) newObjectFunc =
+                &newBooleanObject<JNIEnvWrapper>;
+
+        static constexpr char className[] = "Z";
+    };
+    constexpr char JniTypeTrait< bool >::className[];
+
+    template<>
+    struct JniTypeTrait< double > : public PrimitiveType
+    {
+        static_assert(sizeof(double) == sizeof(jdouble), "double and jdouble have different size!");
+
+        static constexpr decltype(&JNIEnvWrapper::NewDoubleArray) newArrayFunc =
+                &JNIEnvWrapper::NewDoubleArray;
+        static constexpr decltype(&JNIEnvWrapper::SetDoubleArrayRegion) setArrayRegionFunc =
+                      &JNIEnvWrapper::SetDoubleArrayRegion;
+
+        static constexpr decltype(&invoke_Double_doubleValue<JNIEnvWrapper>) converter =
+                      &invoke_Double_doubleValue<JNIEnvWrapper>;
+
+        static constexpr decltype(&newDoubleObject<JNIEnvWrapper>) newObjectFunc =
+                &newDoubleObject<JNIEnvWrapper>;
+
+        static constexpr char className[] = "D";
+    };
+    constexpr char JniTypeTrait< double >::className[];
+
+    template<>
+    struct JniTypeTrait< std::string >: public ObjectType
+    {
+        static constexpr decltype(&newStringObject<JNIEnvWrapper>) newObjectFunc =
+                &newStringObject<JNIEnvWrapper>;
+
+        static constexpr char className[] = "L" CLS_NAME_STRING ";";
+    };
+    constexpr char JniTypeTrait< std::string >::className[];
+
+    template<>
+    struct JniTypeTrait< RCSResourceAttributes >: public ObjectType
+    {
+        inline static jobject newObjectFunc(JNIEnvWrapper* env, const RCSResourceAttributes& value)
+        {
+            return newAttributesObject(env, value);
+        }
+
+        inline static RCSResourceAttributes converter(JNIEnvWrapper* env, jobject obj)
+        {
+            return toNativeAttributes(env, obj);
+        }
+
+        static constexpr char className[] = "L" CLS_NAME_RESOURCEATTRIBUTES ";";
+    };
+    constexpr char JniTypeTrait< RCSResourceAttributes >::className[];
+
+    inline void toNativeValue(JNIEnvWrapper* env, jobject obj, std::string& result, Int2Type< 0 >)
+    {
+        result = toStdString(env, static_cast< jstring >(obj));
+    }
+
+    template< typename T >
+    inline void toNativeValue(JNIEnvWrapper* env, jobject obj, T& result, Int2Type< 0 >)
+    {
+        result = JniTypeTrait< T >::converter(env, obj);
+    }
+
+    template< int DEPTH, typename RET >
+    inline void toNativeValue(JNIEnvWrapper* env, jobject obj, RET& result, Int2Type< DEPTH >)
+    {
+        const auto arrayObj = static_cast< jobjectArray >(obj);
+        result.resize(env->GetArrayLength(arrayObj));
+
+        for (typename RET::size_type i = 0; i < result.size(); ++i)
+        {
+            JavaLocalObject elementObj{ env, env->GetObjectArrayElement(arrayObj, i) };
+
+            toNativeValue(env, elementObj, result[i], Int2Type< DEPTH - 1 >{ });
+        }
+    }
+
+    template< typename T >
+    inline typename std::enable_if< JniTypeTrait< T >::isPrimitive >::type
+    toNativeValue(JNIEnvWrapper* env, jobject obj, std::vector< T >& result, Int2Type< 1 >)
+    {
+        const auto arrayObj = static_cast< jobjectArray >(obj);
+        const jsize arraySize = env->GetArrayLength(arrayObj);
+
+        T* raw = static_cast< T* >(env->GetPrimitiveArrayCritical(arrayObj, nullptr));
+
+        try
+        {
+            result = std::vector< T >(raw, raw + arraySize);
+        } catch (...)
+        {
+        }
+
+        env->ReleasePrimitiveArrayCritical(arrayObj, raw, JNI_ABORT);
+    }
+
+    template< typename T >
+    inline typename std::enable_if< !JniTypeTrait< T >::isPrimitive >::type
+    toNativeValue(JNIEnvWrapper* env, jobject obj, std::vector< T >& result, Int2Type< 1 >)
+    {
+        const auto arrayObj = static_cast< jobjectArray >(obj);
+        const jsize arraySize = env->GetArrayLength(arrayObj);
+
+        result.resize(arraySize);
+
+        for (typename std::vector< T >::size_type i = 0; i < result.size(); ++i)
+        {
+            JavaLocalObject elementObj{ env,  env->GetObjectArrayElement(arrayObj, i) };
+            toNativeValue(env, elementObj, result[i], Int2Type< 0 >{ });
+        }
+    }
+
+
+    template< typename T, int DEPTH, typename RET = typename SeqType< DEPTH, T >::type >
+    inline RET toNativeValue(JNIEnvWrapper* env, jobject obj)
+    {
+        static_assert(DEPTH >= 0, "DEPTH must be positive!");
+
+        typename SeqType< DEPTH, T >::type result;
+
+        toNativeValue(env, obj, result, Int2Type< DEPTH >{ });
+
+        return result;
+    }
+
+    template< typename T >
+    inline RCSResourceAttributes::Value toNativeValue(JNIEnvWrapper* env, jobject val, int depth)
+    {
+        switch (depth)
+        {
+            case 0: return toNativeValue< T, 0 >(env, val);
+            case 1: return toNativeValue< T, 1 >(env, val);
+            case 2: return toNativeValue< T, 2 >(env, val);
+            case 3: return toNativeValue< T, 3 >(env, val);
+        }
+
+        return {};
+    }
+
+    inline RCSResourceAttributes::Value toNativeValue(JNIEnvWrapper* env, jobject val, int depth,
+            RCSResourceAttributes::TypeId typeId)
+    {
+        LOGD("toNativeValue depth is %d", depth);
+        EXPECT_RET(depth >= 0 && depth <= 3, "Unsupported depth!", {});
+
+        switch (typeId)
+         {
+             case RCSResourceAttributes::TypeId::NULL_T: return { };
+
+             case RCSResourceAttributes::TypeId::BOOL:
+                 return toNativeValue< bool >(env, val, depth);
+
+             case RCSResourceAttributes::TypeId::INT:
+                 return toNativeValue< int >(env, val, depth);
+
+             case RCSResourceAttributes::TypeId::DOUBLE:
+                 return toNativeValue< double >(env, val, depth);
+
+             case RCSResourceAttributes::TypeId::STRING:
+                 return toNativeValue< std::string >(env, val, depth);
+
+             case RCSResourceAttributes::TypeId::ATTRIBUTES:
+                 return toNativeValue< RCSResourceAttributes >(env, val, depth);
+         }
+
+        throwRCSException(env, "Failed to convert RCSValue : unknown type id");
+        return {};
+    }
+
+    template< typename T, int DEPTH, typename BASE_TYPE = typename BaseType< T >::type >
+    inline jobject createJavaObject(JNIEnvWrapper* env, const T& value, Int2Type< DEPTH >)
+    {
+        const std::string elementClsName{ std::string{ ArrayPrefix< DEPTH - 1 >::str }
+            + JniTypeTrait< BASE_TYPE >::className };
+
+        LOGD("create array %dd, %s", DEPTH, elementClsName.c_str());
+
+        auto cls = env->FindClass(elementClsName.c_str());
+
+        const jsize len = value.size();
+
+        auto array = env->NewObjectArray(len, cls, nullptr);
+
+        for(jsize i = 0; i < len; ++i)
+        {
+            auto element = createJavaObject(env, value[i], Int2Type< DEPTH - 1>{ });
+            env->SetObjectArrayElement(array, i, element);
+        }
+
+        return array;
+    }
+
+    template< typename T, typename TRAIT = JniTypeTrait< T > >
+    inline typename std::enable_if< TRAIT::isPrimitive, jobject >::type
+    createJavaObject(JNIEnvWrapper* env, const std::vector< T >& value, Int2Type< 1 >)
+    {
+        LOGD("create array with newArray");
+        const jsize len = value.size();
+
+        auto array = (env->*TRAIT::newArrayFunc)(len);
+
+        if (!value.empty()) (env->*TRAIT::setArrayRegionFunc)(array, 0, len, &value[0]);
+
+        return array;
+    }
+
+    inline jobject createJavaObject(JNIEnvWrapper* env, const std::vector< bool >& value, Int2Type< 1 >)
+    {
+        const auto len = value.size();
+        LOGD("create bool array with newArray %d", len);
+
+        auto arrayObj = env->NewBooleanArray(len);
+
+        bool* raw = static_cast< bool* >(env->GetPrimitiveArrayCritical(arrayObj, 0));
+
+        std::copy(value.begin(), value.end(), raw);
+
+        env->ReleasePrimitiveArrayCritical(arrayObj, raw, 0);
+
+        return arrayObj;
+    }
+
+    template< typename T, typename TRAIT = JniTypeTrait< T > >
+    inline jobject createJavaObject(JNIEnvWrapper* env, const T& value, Int2Type< 0 >)
+    {
+        LOGD("createJavaObject 0-depth");
+        return TRAIT::newObjectFunc(env, value);
+    }
+
+    template< int DEPTH >
+    inline jobject createJavaObject(JNIEnvWrapper* env, const RCSResourceAttributes::Value& value)
+    {
+        const auto type = value.getType();
+        const auto baseType = RCSResourceAttributes::Type::getBaseTypeId(type);
+
+        LOGD("createJavaObject with DEPTH. type is %d", static_cast< int >(baseType));
+
+        switch (baseType)
+        {
+            case RCSResourceAttributes::TypeId::NULL_T:
+                return env->GetStaticObjectField(g_cls_RCSValue, g_field_RCSValue_sNullValue);
+
+            case RCSResourceAttributes::TypeId::BOOL:
+                return createJavaObject(env, value.get< typename SeqType< DEPTH, bool >::type >(),
+                        Int2Type< DEPTH >{ });
+
+            case RCSResourceAttributes::TypeId::INT:
+                return createJavaObject(env, value.get< typename SeqType< DEPTH, int >::type >(),
+                        Int2Type< DEPTH >{ });
+
+            case RCSResourceAttributes::TypeId::DOUBLE:
+                return createJavaObject(env, value.get< typename SeqType< DEPTH, double >::type >(),
+                        Int2Type< DEPTH >{ });
+
+            case RCSResourceAttributes::TypeId::STRING:
+                return createJavaObject(env,
+                        value.get< typename SeqType< DEPTH, std::string >::type >(),
+                        Int2Type< DEPTH >{ });
+
+            case RCSResourceAttributes::TypeId::ATTRIBUTES:
+                return createJavaObject(env,
+                        value.get< typename SeqType< DEPTH, RCSResourceAttributes >::type >(),
+                        Int2Type< DEPTH >{ });
+        }
+
+        LOGE("Unknown type!");
+
+        return nullptr;
+    }
+
+    inline jobject createJavaObject(JNIEnvWrapper* env, const RCSResourceAttributes::Value& value)
+    {
+        const auto type = value.getType();
+        const auto depth = RCSResourceAttributes::Type::getDepth(type);
+
+        EXPECT_RET(depth >= 0 && depth <= 3, "Unsupported depth!", {});
+
+        switch (depth)
+        {
+            case 0: return createJavaObject< 0 >(env, value);
+            case 1: return createJavaObject< 1 >(env, value);
+            case 2: return createJavaObject< 2 >(env, value);
+            case 3: return createJavaObject< 3 >(env, value);
+        }
+
+        return nullptr;
+    }
+
+    inline RCSResourceAttributes::TypeId toNativeTypeId(JNIEnvWrapper* env, jobject typeIdObj)
+    {
+        typedef RCSResourceAttributes::TypeId TypeId;
+
+        if (env->IsSameObject(g_obj_TypeId_Null, typeIdObj)) return TypeId::NULL_T;
+        if (env->IsSameObject(g_obj_TypeId_Boolean, typeIdObj)) return TypeId::BOOL;
+        if (env->IsSameObject(g_obj_TypeId_Integer, typeIdObj)) return TypeId::INT;
+        if (env->IsSameObject(g_obj_TypeId_Double, typeIdObj)) return TypeId::DOUBLE;
+        if (env->IsSameObject(g_obj_TypeId_String, typeIdObj)) return TypeId::STRING;
+        if (env->IsSameObject(g_obj_TypeId_Attributes, typeIdObj)) return TypeId::ATTRIBUTES;
+        if (env->IsSameObject(g_obj_TypeId_Array, typeIdObj)) return TypeId::VECTOR;
+
+        throwRCSException(env, "Failed to convert RCSValue : unknown type id");
+        return TypeId::NULL_T;
+    }
+
+    jobject getTypeIdObj(JNIEnvWrapper* env, const char* name)
+    {
+        return env->NewGlobalRef(
+                env->GetStaticObjectField(g_cls_TypeId, name, AS_SIG(CLS_NAME_VALUE_TYPEID)));
+    }
+}
+
+void initRCSValue(JNIEnvWrapper* env)
+{
+    g_cls_RCSValue = env->FindClassAsGlobalRef(CLS_NAME_VALUE);
+    g_ctor_RCSValue = env->GetConstructorID(g_cls_RCSValue, "(" AS_SIG(CLS_NAME_OBJECT) ")V");
+
+    g_method_RCSValue_getType = env->GetMethodID(g_cls_RCSValue, "getType",
+            "()" AS_SIG(CLS_NAME_VALUE_TYPE));
+
+    g_field_RCSValue_mObject = env->GetFieldID(g_cls_RCSValue, "mObject", AS_SIG(CLS_NAME_OBJECT));
+
+    g_field_RCSValue_sNullValue = env->GetStaticFieldID(g_cls_RCSValue, "sNullValue",
+            AS_SIG(CLS_NAME_VALUE_NULL_TYPE));
+
+    g_cls_Type = env->FindClassAsGlobalRef(CLS_NAME_VALUE_TYPE);
+
+    g_smethod_Type_getBaseTypeId = env->GetStaticMethodID(g_cls_Type, "getBaseTypeId",
+            "(" AS_SIG(CLS_NAME_VALUE_TYPE) ")" AS_SIG(CLS_NAME_VALUE_TYPEID));
+
+    g_smethod_Type_getDepth = env->GetStaticMethodID(g_cls_Type, "getDepth",
+                "(" AS_SIG(CLS_NAME_VALUE_TYPE) ")I");
+
+    g_cls_TypeId = env->FindClassAsGlobalRef(CLS_NAME_VALUE_TYPEID);
+
+    g_obj_TypeId_Null = getTypeIdObj(env, "NULL");
+    g_obj_TypeId_Boolean = getTypeIdObj(env, "BOOLEAN");
+    g_obj_TypeId_Integer = getTypeIdObj(env, "INTEGER");
+    g_obj_TypeId_Double = getTypeIdObj(env, "DOUBLE");
+    g_obj_TypeId_String = getTypeIdObj(env, "STRING");
+    g_obj_TypeId_Attributes = getTypeIdObj(env, "ATTRIBUTES");
+    g_obj_TypeId_Array = getTypeIdObj(env, "ARRAY");
+}
+
+void clearRCSValue(JNIEnvWrapper* env)
+{
+    env->DeleteGlobalRef(g_cls_RCSValue);
+    env->DeleteGlobalRef(g_cls_Type);
+    env->DeleteGlobalRef(g_cls_TypeId);
+
+    env->DeleteGlobalRef(g_obj_TypeId_Null);
+    env->DeleteGlobalRef(g_obj_TypeId_Boolean);
+    env->DeleteGlobalRef(g_obj_TypeId_Integer);
+    env->DeleteGlobalRef(g_obj_TypeId_Double);
+    env->DeleteGlobalRef(g_obj_TypeId_String);
+    env->DeleteGlobalRef(g_obj_TypeId_Attributes);
+    env->DeleteGlobalRef(g_obj_TypeId_Array);
+}
+
+RCSResourceAttributes::Value toNativeAttrsValue(JNIEnv* env, jobject valueObj)
+{
+    JNIEnvWrapper envWrapper(env);
+
+    try
+    {
+        return toNativeAttrsValue(&envWrapper, valueObj);
+    }
+    catch (const JavaException&)
+    {
+        return { };
+    }
+}
+
+RCSResourceAttributes::Value toNativeAttrsValue(JNIEnvWrapper* env, jobject valueObj)
+{
+    auto typeObj = env->CallObjectMethod(valueObj, g_method_RCSValue_getType);
+    auto typeIdObj = env->CallStaticObjectMethod(g_cls_Type, g_smethod_Type_getBaseTypeId, typeObj);
+    auto depth = env->CallStaticIntMethod(g_cls_Type, g_smethod_Type_getDepth, typeObj);
+    auto memObj = env->GetObjectField(valueObj, g_field_RCSValue_mObject);
+
+    auto ret = toNativeValue(env, memObj, depth, toNativeTypeId(env, typeIdObj));
+
+    if (env->get()->ExceptionCheck()) throw JavaException();
+
+    return ret;
+}
+
+jobject newRCSValueObject(JNIEnv* env, const RCSResourceAttributes::Value& value)
+{
+    JNIEnvWrapper envWrapper(env);
+
+    try
+    {
+        return newRCSValueObject(&envWrapper, value);
+    }
+    catch (const JavaException&)
+    {
+        return {};
+    }
+}
+
+jobject newRCSValueObject(JNIEnvWrapper* env, const RCSResourceAttributes::Value& value)
+{
+    LOGD("newRCSValueObject");
+
+    JavaLocalObject valueObj{ env, createJavaObject(env, value) };
+
+    if (env->get()->ExceptionCheck()) throw JavaException();
+
+    return env->NewObject(g_cls_RCSValue, g_ctor_RCSValue, valueObj.get());
+}
diff --git a/service/resource-encapsulation/android/service/src/main/jni/JniRcsValue.h b/service/resource-encapsulation/android/service/src/main/jni/JniRcsValue.h
new file mode 100644 (file)
index 0000000..c27c23f
--- /dev/null
@@ -0,0 +1,39 @@
+/******************************************************************
+ *
+ * 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_RCS_VALUE_H_
+#define JNI_RCS_VALUE_H_
+
+#include <jni.h>
+
+#include "RCSResourceAttributes.h"
+
+class JNIEnvWrapper;
+
+void initRCSValue(JNIEnvWrapper*);
+void clearRCSValue(JNIEnvWrapper*);
+
+OIC::Service::RCSResourceAttributes::Value toNativeAttrsValue(JNIEnv*, jobject);
+OIC::Service::RCSResourceAttributes::Value toNativeAttrsValue(JNIEnvWrapper*, jobject);
+
+jobject newRCSValueObject(JNIEnv*, const OIC::Service::RCSResourceAttributes::Value&);
+jobject newRCSValueObject(JNIEnvWrapper*, const OIC::Service::RCSResourceAttributes::Value&);
+
+#endif // JNI_RCS_VALUE_H_
diff --git a/service/resource-encapsulation/android/service/src/main/jni/util/JNIEnvWrapper.h b/service/resource-encapsulation/android/service/src/main/jni/util/JNIEnvWrapper.h
new file mode 100644 (file)
index 0000000..2723178
--- /dev/null
@@ -0,0 +1,391 @@
+/******************************************************************
+ *
+ * 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 RCS_JNI_ENV_WRAPPER_H_
+#define RCS_JNI_ENV_WRAPPER_H_
+
+#include <jni.h>
+
+#include <exception>
+
+#include "JavaLocalRef.h"
+
+class JavaException: public std::exception
+{
+};
+
+class JNIEnvWrapper
+{
+public:
+    JNIEnvWrapper() noexcept : m_env{ } {}
+    JNIEnvWrapper(JNIEnv* env) noexcept : m_env{ env } {}
+
+    JNIEnvWrapper& operator=(JNIEnv* env) noexcept
+    {
+        m_env = env;
+        return *this;
+    }
+
+    jboolean IsSameObject(jobject lhs, jobject rhs)
+    {
+        return m_env->IsSameObject(lhs, rhs);
+    }
+
+    jclass GetObjectClass(jobject obj)
+    {
+        auto ret = m_env->GetObjectClass(obj);
+        if (m_env->ExceptionCheck()) throw JavaException();
+        return ret;
+    }
+
+    jclass FindClass(const char* name)
+    {
+        auto ret = m_env->FindClass(name);
+        if (m_env->ExceptionCheck()) throw JavaException();
+        return ret;
+    }
+
+    jclass FindClassAsGlobalRef(const char* name)
+    {
+        JavaLocalClass cls{ m_env, FindClass(name) };
+
+        return NewGlobalRef(cls);
+    }
+
+    jobject NewGlobalRef(jobject obj)
+    {
+        auto ret = m_env->NewGlobalRef(obj);
+        if (m_env->ExceptionCheck()) throw JavaException();
+        return ret;
+    }
+
+    template<typename T>
+    T NewGlobalRef(T obj)
+    {
+        auto ret = static_cast< T >(m_env->NewGlobalRef(obj));
+        if (m_env->ExceptionCheck()) throw JavaException();
+        return ret;
+    }
+
+    template<typename T>
+    T NewGlobalRef(const JavaLocalRef< T >& obj)
+    {
+        auto ret = static_cast< T >(m_env->NewGlobalRef(obj));
+        if (m_env->ExceptionCheck()) throw JavaException();
+        return ret;
+    }
+
+    void DeleteGlobalRef(jobject obj)
+    {
+        m_env->DeleteGlobalRef(obj);
+    }
+
+    jobject NewObject(jclass cls, jmethodID ctor, ...)
+    {
+        va_list args;
+        va_start(args, ctor);
+        auto ret = m_env->NewObjectV(cls, ctor,args);
+        va_end(args);
+
+        if (m_env->ExceptionCheck()) throw JavaException();
+        return ret;
+    }
+
+    jstring NewStringUTF(const char* str)
+    {
+        auto ret = m_env->NewStringUTF(str);
+        if (m_env->ExceptionCheck()) throw JavaException();
+        return ret;
+    }
+
+    const char* GetStringUTFChars(jstring str, jboolean* isCopy)
+    {
+        auto ret = m_env->GetStringUTFChars(str, isCopy);
+        if (m_env->ExceptionCheck()) throw JavaException();
+        return ret;
+    }
+
+    void ReleaseStringUTFChars(jstring str, const char* chars)
+    {
+        m_env->ReleaseStringUTFChars(str, chars);
+        if (m_env->ExceptionCheck()) throw JavaException();
+    }
+
+    jmethodID GetConstructorID(jclass cls, const char* sig)
+    {
+        auto ret = m_env->GetMethodID(cls, "<init>", sig);
+        if (m_env->ExceptionCheck()) throw JavaException();
+        return ret;
+    }
+
+    jmethodID GetMethodID(jclass cls, const char* name, const char* sig)
+    {
+        auto ret = m_env->GetMethodID(cls, name, sig);
+        if (m_env->ExceptionCheck()) throw JavaException();
+        return ret;
+    }
+
+    jmethodID GetStaticMethodID(jclass cls, const char* name, const char* sig)
+    {
+        auto ret = m_env->GetStaticMethodID(cls, name, sig);
+        if (m_env->ExceptionCheck()) throw JavaException();
+        return ret;
+    }
+
+
+    jfieldID GetFieldID(jclass cls, const char* name, const char* sig)
+    {
+        auto ret = m_env->GetFieldID(cls, name, sig);
+        if (m_env->ExceptionCheck()) throw JavaException();
+        return ret;
+    }
+
+    jfieldID GetStaticFieldID(jclass cls, const char* name, const char* sig)
+    {
+        auto ret = m_env->GetStaticFieldID(cls, name, sig);
+        if (m_env->ExceptionCheck()) throw JavaException();
+        return ret;
+    }
+
+    jobject GetStaticObjectField(jclass cls, jfieldID fieldId)
+    {
+        auto ret = m_env->GetStaticObjectField(cls, fieldId);
+        if (m_env->ExceptionCheck()) throw JavaException();
+        return ret;
+    }
+
+    jobject GetStaticObjectField(jclass cls, const char* name, const char* sig)
+    {
+        return GetStaticObjectField(cls, GetStaticFieldID(cls, name, sig));
+    }
+
+    jint GetIntField(jobject obj, jfieldID fieldId)
+    {
+        auto ret = m_env->GetIntField(obj, fieldId);
+        if (m_env->ExceptionCheck()) throw JavaException();
+        return ret;
+    }
+
+    jlong GetLongField(jobject obj, jfieldID fieldId)
+    {
+        auto ret = m_env->GetLongField(obj, fieldId);
+        if (m_env->ExceptionCheck()) throw JavaException();
+        return ret;
+    }
+
+    void SetLongField(jobject obj, jfieldID fieldId, jlong val)
+    {
+        m_env->SetLongField(obj, fieldId, val);
+        if (m_env->ExceptionCheck()) throw JavaException();
+    }
+
+    jobject GetObjectField(jobject obj, jfieldID fieldId)
+    {
+        auto ret = m_env->GetObjectField(obj, fieldId);
+        if (m_env->ExceptionCheck()) throw JavaException();
+        return ret;
+    }
+
+    jint CallStaticIntMethod(jclass cls, jmethodID methodId, ...)
+    {
+        va_list args;
+        va_start(args, methodId);
+        auto ret = m_env->CallStaticIntMethodV(cls, methodId, args);
+        va_end(args);
+        if (m_env->ExceptionCheck()) throw JavaException();
+        return ret;
+    }
+
+    jobject CallStaticObjectMethod(jclass cls, jmethodID methodId, ...)
+    {
+        va_list args;
+        va_start(args, methodId);
+        auto ret = m_env->CallStaticObjectMethodV(cls, methodId, args);
+        va_end(args);
+        if (m_env->ExceptionCheck()) throw JavaException();
+        return ret;
+    }
+
+    void CallVoidMethod(jobject obj, jmethodID methodId, ...)
+    {
+         va_list args;
+         va_start(args, methodId);
+         m_env->CallVoidMethodV(obj, methodId, args);
+         va_end(args);
+         if (m_env->ExceptionCheck()) throw JavaException();
+    }
+
+    jboolean CallBooleanMethod(jobject obj, jmethodID methodId, ...)
+    {
+        va_list args;
+        va_start(args, methodId);
+        auto ret = m_env->CallBooleanMethodV(obj, methodId, args);
+        va_end(args);
+        if (m_env->ExceptionCheck()) throw JavaException();
+        return ret;
+    }
+
+    jint CallIntMethod(jobject obj, jmethodID methodId, ...)
+    {
+         va_list args;
+         va_start(args, methodId);
+         auto ret = m_env->CallIntMethod(obj, methodId, args);
+         va_end(args);
+         if (m_env->ExceptionCheck()) throw JavaException();
+         return ret;
+    }
+
+     jdouble CallDoubleMethod(jobject obj, jmethodID methodId, ...)
+     {
+          va_list args;
+          va_start(args ,methodId);
+          auto ret = m_env->CallDoubleMethod(obj, methodId, args);
+          va_end(args);
+          if (m_env->ExceptionCheck()) throw JavaException();
+          return ret;
+     }
+
+
+    jobject CallObjectMethod(jobject obj, jmethodID methodId, ...)
+    {
+        va_list args;
+        va_start(args, methodId);
+        auto ret = m_env->CallObjectMethodV(obj, methodId, args);
+        va_end(args);
+        if (m_env->ExceptionCheck()) throw JavaException();
+        return ret;
+    }
+
+    jbooleanArray NewBooleanArray(jsize len)
+    {
+        auto ret = m_env->NewBooleanArray(len);
+        if (m_env->ExceptionCheck()) throw JavaException();
+        return ret;
+    }
+
+    jintArray NewIntArray(jsize len)
+    {
+        auto ret = m_env->NewIntArray(len);
+        if (m_env->ExceptionCheck()) throw JavaException();
+        return ret;
+    }
+
+    jdoubleArray NewDoubleArray(jsize len)
+    {
+        auto ret = m_env->NewDoubleArray(len);
+        if (m_env->ExceptionCheck()) throw JavaException();
+        return ret;
+    }
+
+    jobjectArray NewObjectArray(jsize len, jclass cls, jobject init)
+    {
+        auto ret = m_env->NewObjectArray(len, cls, init);
+        if (m_env->ExceptionCheck()) throw JavaException();
+        return ret;
+    }
+
+    jsize GetArrayLength(jarray array)
+    {
+        auto ret = m_env->GetArrayLength(array);
+        if (m_env->ExceptionCheck()) throw JavaException();
+        return ret;
+    }
+
+    jobject GetObjectArrayElement(jobjectArray array, jsize index)
+    {
+        auto ret = m_env->GetObjectArrayElement(array, index);
+        if (m_env->ExceptionCheck()) throw JavaException();
+        return ret;
+    }
+
+    void SetObjectArrayElement(jobjectArray array, jsize index, jobject val)
+    {
+        m_env->SetObjectArrayElement(array, index, val);
+        if (m_env->ExceptionCheck()) throw JavaException();
+    }
+
+    void SetBooleanArrayRegion(jbooleanArray array, jsize start, jsize len, const jboolean* buf)
+    {
+        m_env->SetBooleanArrayRegion(array, start, len, buf);
+        if (m_env->ExceptionCheck()) throw JavaException();
+    }
+
+    void SetIntArrayRegion(jintArray array, jsize start, jsize len, const jint* buf)
+    {
+        m_env->SetIntArrayRegion(array, start, len, buf);
+        if (m_env->ExceptionCheck()) throw JavaException();
+    }
+
+    void SetDoubleArrayRegion(jdoubleArray array, jsize start, jsize len, const jdouble* buf)
+    {
+        m_env->SetDoubleArrayRegion(array, start, len, buf);
+        if (m_env->ExceptionCheck()) throw JavaException();
+    }
+
+    void* GetPrimitiveArrayCritical(jarray array, jboolean* isCopy)
+    {
+        auto ret = m_env->GetPrimitiveArrayCritical(array, isCopy);
+        if (m_env->ExceptionCheck()) throw JavaException();
+        return ret;
+    }
+
+    void ReleasePrimitiveArrayCritical(jarray array, void* carray, int mode)
+    {
+        m_env->ReleasePrimitiveArrayCritical(array, carray, mode);
+        if (m_env->ExceptionCheck()) throw JavaException();
+    }
+
+    void ThrowNew(jclass cls, const char* msg) {
+        m_env->ThrowNew(cls, msg);
+        throw JavaException();
+    }
+
+    void ExceptionDescribe() const noexcept
+    {
+        m_env->ExceptionDescribe();
+    }
+
+    void ExceptionClear() noexcept
+    {
+        m_env->ExceptionClear();
+    }
+
+    jboolean ExceptionCheck() const noexcept
+    {
+        return m_env->ExceptionCheck();
+    }
+
+    operator bool() const noexcept
+    {
+        return m_env != nullptr;
+    }
+
+    JNIEnv* get() const
+    {
+        return m_env;
+    }
+
+private:
+    JNIEnv* m_env;
+};
+
+
+
+#endif // RCS_JNI_ENV_WRAPPER_H_
diff --git a/service/resource-encapsulation/android/service/src/main/jni/util/JavaClasses.cpp b/service/resource-encapsulation/android/service/src/main/jni/util/JavaClasses.cpp
new file mode 100644 (file)
index 0000000..1232d8c
--- /dev/null
@@ -0,0 +1,119 @@
+/******************************************************************
+ *
+ * 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 "JavaClasses.h"
+
+#include "JNIEnvWrapper.h"
+
+jclass g_cls_String;
+jclass g_cls_Integer;
+jclass g_cls_Double;
+jclass g_cls_Boolean;
+
+jclass g_cls_ArrayList;
+jclass g_cls_Set;
+jclass g_cls_Map;
+jclass g_cls_MapEntry;
+jclass g_cls_Iterator;
+
+jmethodID g_method_Boolean_booleanValue;
+jmethodID g_method_Integer_intValue;
+jmethodID g_method_Double_doubleValue;
+
+jmethodID g_method_Collection_add;
+
+jmethodID g_method_Set_iterator;
+
+jmethodID g_method_Map_entrySet;
+jmethodID g_method_Map_put;
+
+jmethodID g_method_MapEntry_getKey;
+jmethodID g_method_MapEntry_getValue;
+
+jmethodID g_method_Iterator_hasNext;
+jmethodID g_method_Iterator_next;
+
+jmethodID g_ctor_Boolean;
+jmethodID g_ctor_Integer;
+jmethodID g_ctor_Double;
+
+jmethodID g_ctor_ArrayList;
+
+namespace
+{
+    inline void initPrimitiveTypes(JNIEnvWrapper* env)
+    {
+        g_cls_Boolean = env->FindClassAsGlobalRef(CLS_NAME_BOOLEAN);
+        g_ctor_Boolean = env->GetConstructorID(g_cls_Boolean, "(Z)V");
+        g_method_Boolean_booleanValue = env->GetMethodID(g_cls_Boolean, "booleanValue", "()Z");
+
+        g_cls_Integer = env->FindClassAsGlobalRef(CLS_NAME_INTEGER);
+        g_ctor_Integer = env->GetConstructorID(g_cls_Integer, "(I)V");
+        g_method_Integer_intValue = env->GetMethodID(g_cls_Integer, "intValue", "()I");
+
+        g_cls_Double = env->FindClassAsGlobalRef(CLS_NAME_DOUBLE);
+        g_ctor_Double = env->GetConstructorID(g_cls_Double, "(D)V");
+        g_method_Double_doubleValue = env->GetMethodID(g_cls_Double, "doubleValue", "()D");
+
+        g_cls_String = env->FindClassAsGlobalRef(CLS_NAME_STRING);
+    }
+}
+
+void initJavaClasses(JNIEnvWrapper* env)
+{
+    initPrimitiveTypes(env);
+
+    auto clsCollection = env->FindClass(CLS_NAME_COLLECTION);
+    g_method_Collection_add = env->GetMethodID(clsCollection, "add",
+            "(" AS_SIG(CLS_NAME_OBJECT) ")Z");
+
+    g_cls_ArrayList = env->FindClassAsGlobalRef(CLS_NAME_ARRAY_LIST);
+    g_ctor_ArrayList = env->GetConstructorID(g_cls_ArrayList, "()V");
+
+    g_cls_Set = env->FindClassAsGlobalRef(CLS_NAME_SET);
+    g_method_Set_iterator = env->GetMethodID(g_cls_Set, "iterator", "()" AS_SIG(CLS_NAME_ITERATOR));
+
+    g_cls_Map = env->FindClassAsGlobalRef(CLS_NAME_MAP);
+    g_method_Map_entrySet = env->GetMethodID(g_cls_Map, "entrySet", "()" AS_SIG(CLS_NAME_SET));
+    g_method_Map_put = env->GetMethodID(g_cls_Map, "put",
+            "(" AS_SIG(CLS_NAME_OBJECT) AS_SIG(CLS_NAME_OBJECT) ")" AS_SIG(CLS_NAME_OBJECT));
+
+    g_cls_MapEntry = env->FindClassAsGlobalRef(CLS_NAME_MAP_ENTRY);
+    g_method_MapEntry_getKey = env->GetMethodID(g_cls_MapEntry, "getKey",
+            "()" AS_SIG(CLS_NAME_OBJECT));
+    g_method_MapEntry_getValue = env->GetMethodID(g_cls_MapEntry, "getValue",
+            "()" AS_SIG(CLS_NAME_OBJECT));
+
+    g_cls_Iterator = env->FindClassAsGlobalRef(CLS_NAME_ITERATOR);
+    g_method_Iterator_hasNext = env->GetMethodID(g_cls_Iterator, "hasNext", "()Z");
+    g_method_Iterator_next = env->GetMethodID(g_cls_Iterator, "next", "()" AS_SIG(CLS_NAME_OBJECT));
+}
+
+void clearJavaClasses(JNIEnvWrapper* env)
+{
+    env->DeleteGlobalRef(g_cls_Boolean);
+    env->DeleteGlobalRef(g_cls_Integer);
+    env->DeleteGlobalRef(g_cls_Double);
+    env->DeleteGlobalRef(g_cls_String);
+    env->DeleteGlobalRef(g_cls_Set);
+    env->DeleteGlobalRef(g_cls_Map);
+    env->DeleteGlobalRef(g_cls_MapEntry);
+    env->DeleteGlobalRef(g_cls_Iterator);
+}
diff --git a/service/resource-encapsulation/android/service/src/main/jni/util/JavaClasses.h b/service/resource-encapsulation/android/service/src/main/jni/util/JavaClasses.h
new file mode 100644 (file)
index 0000000..d87e3d5
--- /dev/null
@@ -0,0 +1,211 @@
+/******************************************************************
+ *
+ * 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 JAVA_CLASSES_H_
+#define JAVA_CLASSES_H_
+
+#include <jni.h>
+
+#include <string>
+
+#define PACKAGE_NAME "org/iotivity/service"
+
+#define CLS_NAME_VALUE PACKAGE_NAME "/RcsValue"
+
+#define CLS_NAME_RESOURCEATTRIBUTES PACKAGE_NAME "/RcsResourceAttributes"
+#define CLS_NAME_REMOTERESOURCEOBJECT PACKAGE_NAME "/client/RcsRemoteResourceObject"
+
+#define CLS_NAME_OBJECT "java/lang/Object"
+#define CLS_NAME_STRING "java/lang/String"
+#define CLS_NAME_INTEGER "java/lang/Integer"
+#define CLS_NAME_DOUBLE "java/lang/Double"
+#define CLS_NAME_BOOLEAN "java/lang/Boolean"
+
+#define CLS_NAME_COLLECTION "java/util/Collection"
+#define CLS_NAME_ARRAY_LIST "java/util/ArrayList"
+#define CLS_NAME_SET "java/util/Set"
+#define CLS_NAME_MAP "java/util/Map"
+#define CLS_NAME_MAP_ENTRY "java/util/Map$Entry"
+#define CLS_NAME_ITERATOR "java/util/Iterator"
+
+#define EXC_NAME_RCS PACKAGE_NAME "/RcsException"
+#define EXC_NAME_PLATFORM PACKAGE_NAME "/RcsPlatformException"
+#define EXC_NAME_ILLEGAL_STATE PACKAGE_NAME "/RcsIllegalStateException"
+
+#define AS_SIG(CLS_NAME) "L" CLS_NAME ";"
+
+class JNIEnvWrapper;
+
+extern jclass g_cls_Integer;
+extern jclass g_cls_Double;
+extern jclass g_cls_Boolean;
+extern jclass g_cls_String;
+
+extern jclass g_cls_ArrayList;
+extern jclass g_cls_Set;
+extern jclass g_cls_Map;
+extern jclass g_cls_MapEntry;
+extern jclass g_cls_Iterator;
+
+extern jmethodID g_method_Boolean_booleanValue;
+extern jmethodID g_method_Integer_intValue;
+extern jmethodID g_method_Double_doubleValue;
+
+extern jmethodID g_method_Collection_add;
+
+extern jmethodID g_method_Set_iterator;
+
+extern jmethodID g_method_Map_entrySet;
+extern jmethodID g_method_Map_put;
+
+extern jmethodID g_method_MapEntry_getKey;
+extern jmethodID g_method_MapEntry_getValue;
+
+extern jmethodID g_method_Iterator_hasNext;
+extern jmethodID g_method_Iterator_next;
+
+extern jmethodID g_ctor_Boolean;
+extern jmethodID g_ctor_Integer;
+extern jmethodID g_ctor_Double;
+
+extern jmethodID g_ctor_ArrayList;
+
+void initJavaClasses(JNIEnvWrapper*);
+void clearJavaClasses(JNIEnvWrapper*);
+
+template< typename ENV >
+inline jobject newBooleanObject(ENV* env, bool value)
+{
+    return env->NewObject(g_cls_Boolean, g_ctor_Boolean, value);
+}
+
+template< typename ENV >
+inline jobject newIntegerObject(ENV* env, int value)
+{
+    return env->NewObject(g_cls_Integer, g_ctor_Integer, value);
+}
+
+template< typename ENV >
+inline jobject newDoubleObject(ENV* env, double value)
+{
+    return env->NewObject(g_cls_Double, g_ctor_Double, value);
+}
+
+template< typename ENV >
+inline jstring newStringObject(ENV* env, const std::string& value)
+{
+    return env->NewStringUTF(value.c_str());
+}
+
+template< typename ENV >
+inline jstring newStringObjectCstr(ENV* env, const char* value)
+{
+    return env->NewStringUTF(value);
+}
+
+template< typename ENV >
+inline std::string toStdString(ENV* env, jstring obj)
+{
+    if (!obj) return "";
+
+    auto cstr = env->GetStringUTFChars(obj, nullptr);
+
+    if (!cstr) return "";
+
+    std::string result{ cstr };
+
+    env->ReleaseStringUTFChars(obj, cstr);
+
+    return result;
+}
+
+template< typename ENV >
+inline jobject newArrayList(ENV* env)
+{
+    return env->NewObject(g_cls_ArrayList, g_ctor_ArrayList);
+}
+
+template< typename ENV >
+inline bool invoke_Boolean_booleanValue(ENV* env, jobject obj)
+{
+    return env->CallBooleanMethod(obj, g_method_Boolean_booleanValue);
+}
+
+template< typename ENV >
+inline int invoke_Integer_intValue(ENV* env, jobject obj)
+{
+    return env->CallIntMethod(obj, g_method_Integer_intValue);
+}
+
+template< typename ENV >
+inline double invoke_Double_doubleValue(ENV* env, jobject obj)
+{
+    return env->CallDoubleMethod(obj, g_method_Double_doubleValue);
+}
+
+template< typename ENV >
+inline jboolean invoke_Collection_add(ENV* env, jobject collectionObj, jobject valueObj)
+{
+    return env->CallBooleanMethod(collectionObj, g_method_Collection_add, valueObj);
+}
+
+template< typename ENV >
+inline jobject invoke_Map_entrySet(ENV* env, jobject mapObj)
+{
+    return env->CallObjectMethod(mapObj, g_method_Map_entrySet);
+}
+
+template< typename ENV >
+inline jobject invoke_Map_put(ENV* env, jobject mapObj, jobject keyObj, jobject valueObj)
+{
+    return env->CallObjectMethod(mapObj, g_method_Map_put, keyObj, valueObj);
+}
+
+template< typename ENV >
+inline jobject invoke_MapEntry_getKey(ENV* env, jobject entryObj)
+{
+    return env->CallObjectMethod(entryObj, g_method_MapEntry_getKey);
+}
+
+template< typename ENV >
+inline jobject invoke_MapEntry_getValue(ENV* env, jobject entryObj)
+{
+    return env->CallObjectMethod(entryObj, g_method_MapEntry_getValue);
+}
+
+template< typename ENV >
+inline jobject invoke_Set_iterator(ENV* env, jobject setObj)
+{
+    return env->CallObjectMethod(setObj, g_method_Set_iterator);
+}
+
+template< typename ENV >
+inline bool invoke_Iterator_hasNext(ENV* env, jobject iterObj)
+{
+    return env->CallBooleanMethod(iterObj, g_method_Iterator_hasNext);
+}
+
+template< typename ENV >
+inline jobject invoke_Iterator_next(ENV* env, jobject iterObj)
+{
+    return env->CallObjectMethod(iterObj, g_method_Iterator_next);
+}
+
+#endif // JAVA_CLASSES_H_
diff --git a/service/resource-encapsulation/android/service/src/main/jni/util/JavaExceptions.cpp b/service/resource-encapsulation/android/service/src/main/jni/util/JavaExceptions.cpp
new file mode 100644 (file)
index 0000000..52c9f34
--- /dev/null
@@ -0,0 +1,57 @@
+/******************************************************************
+ *
+ * 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 "JavaExceptions.h"
+
+#include "JNIEnvWrapper.h"
+#include "Verify.h"
+
+#include "RCSException.h"
+
+namespace
+{
+    jclass g_cls_PlatformException;
+
+    jmethodID g_ctor_PlatformException;
+}
+
+void initJavaExceptions(JNIEnvWrapper* env)
+{
+    g_cls_PlatformException = env->FindClassAsGlobalRef(EXC_NAME_PLATFORM);
+    g_ctor_PlatformException = env->GetConstructorID(g_cls_PlatformException,
+            "(" AS_SIG(CLS_NAME_STRING) "I)V");
+}
+
+void clearJavaExceptions(JNIEnvWrapper* env)
+{
+    env->DeleteGlobalRef(g_cls_PlatformException);
+}
+
+void throwPlatformException(JNIEnv* env, const OIC::Service::PlatformException& e)
+{
+    auto msg = newStringObject(env, e.getReason());
+    VERIFY_NO_EXC(env);
+
+    auto exObj = env->NewObject(g_cls_PlatformException, g_ctor_PlatformException,
+            msg, e.getReasonCode());
+    VERIFY_NO_EXC(env);
+
+    env->Throw(static_cast< jthrowable >(exObj));
+}
diff --git a/service/resource-encapsulation/android/service/src/main/jni/util/JavaExceptions.h b/service/resource-encapsulation/android/service/src/main/jni/util/JavaExceptions.h
new file mode 100644 (file)
index 0000000..ca2a6cc
--- /dev/null
@@ -0,0 +1,50 @@
+/******************************************************************
+ *
+ * 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 JAVA_EXCEPTIONS_H_
+#define JAVA_EXCEPTIONS_H_
+
+#include <jni.h>
+
+#include "JavaClasses.h"
+
+namespace OIC
+{
+    namespace Service
+    {
+        class PlatformException;
+    }
+}
+
+class JNIEnvWrapper;
+
+void initJavaExceptions(JNIEnvWrapper*);
+void clearJavaExceptions(JNIEnvWrapper*);
+
+void throwPlatformException(JNIEnv*, const OIC::Service::PlatformException&);
+
+template < typename ENV >
+void throwRCSException(ENV* env, const char* msg)
+{
+    env->ThrowNew(env->FindClass(EXC_NAME_RCS), msg);
+}
+
+
+#endif // JAVA_EXCEPTIONS_H_
diff --git a/service/resource-encapsulation/android/service/src/main/jni/util/JavaGlobalRef.h b/service/resource-encapsulation/android/service/src/main/jni/util/JavaGlobalRef.h
new file mode 100644 (file)
index 0000000..d5c4000
--- /dev/null
@@ -0,0 +1,61 @@
+/******************************************************************
+ *
+ * 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 JAVA_GLOBAL_REF_H_
+#define JAVA_GLOBAL_REF_H_
+
+#include <memory>
+#include <cassert>
+
+#include "ScopedEnv.h"
+
+class JavaGlobalRef
+{
+public:
+    JavaGlobalRef(JNIEnv* env, jobject obj) noexcept :
+        m_obj{ }
+    {
+        assert(env && "JNIEnv is nullptr");
+
+        static auto deleter = [](jobject* obj)
+            {
+                if (obj && *obj)
+                {
+                    ScopedEnv env;
+                    env->DeleteGlobalRef(*obj);
+                }
+                delete obj;
+            };
+
+        m_obj.reset(new jobject{ env->NewGlobalRef(obj) }, deleter);
+    }
+
+    operator jobject() const noexcept
+    {
+        return *m_obj;
+    }
+
+private:
+    std::shared_ptr< jobject > m_obj;
+};
+
+
+
+#endif // JAVA_GLOBAL_REF_H_
diff --git a/service/resource-encapsulation/android/service/src/main/jni/util/JavaLocalRef.h b/service/resource-encapsulation/android/service/src/main/jni/util/JavaLocalRef.h
new file mode 100644 (file)
index 0000000..9a339d6
--- /dev/null
@@ -0,0 +1,70 @@
+/******************************************************************
+ *
+ * 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 JAVA_LOCAL_REF_H_
+#define JAVA_LOCAL_REF_H_
+
+#include <jni.h>
+#include <cassert>
+
+template < typename T >
+class JavaLocalRef
+{
+public:
+    JavaLocalRef(JNIEnv* env, T obj) noexcept :
+        m_env{ env },
+        m_obj{ obj }
+    {
+        assert(env && "JNIEnv is nullptr");
+    }
+
+    template< typename ENV >
+    JavaLocalRef(ENV* env, T obj) noexcept :
+        m_env{ env->get() },
+        m_obj{ obj }
+    {
+        assert(env && "JNIEnv is nullptr");
+    }
+
+    ~JavaLocalRef()
+    {
+        if (m_obj) m_env->DeleteLocalRef(m_obj);
+    }
+
+    operator bool() const noexcept { return m_obj; }
+    operator T() const noexcept { return m_obj; }
+
+    jobject get() const noexcept { return m_obj; }
+
+    JavaLocalRef(const JavaLocalRef&) = delete;
+    JavaLocalRef& operator=(const JavaLocalRef&) = delete;
+
+    JavaLocalRef& operator=(JavaLocalRef&&) = delete;
+
+private:
+    JNIEnv* m_env;
+    T m_obj;
+};
+
+typedef JavaLocalRef< jobject > JavaLocalObject;
+typedef JavaLocalRef< jstring > JavaLocalString;
+typedef JavaLocalRef< jclass > JavaLocalClass;
+
+#endif // JAVA_LOCAL_REF_H_
diff --git a/service/resource-encapsulation/android/service/src/main/jni/util/Log.h b/service/resource-encapsulation/android/service/src/main/jni/util/Log.h
new file mode 100644 (file)
index 0000000..cecabfd
--- /dev/null
@@ -0,0 +1,42 @@
+/******************************************************************
+ *
+ * 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 RCS_JNI_LOG_H
+#define RCS_JNI_LOG_H
+
+#include <android/log.h>
+
+#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
+#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
+#define LOGW(...) __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)
+#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
+
+#define LOGT_I(LOG_TAG, ...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
+#define LOGT_D(LOG_TAG, ...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
+#define LOGT_E(LOG_TAG, ...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
+
+#define EXPECT(EXP, MSG) do { if (!(EXP)) { LOGW(MSG); return; } } while(false)
+
+#define EXPECT_RET(EXP, MSG, RET_IF_FAILED) \
+    do { if (!(EXP)) { LOGW(MSG); return RET_IF_FAILED; } } while(false)
+
+#define EXPECT_RET_DEF(EXP, MSG) EXPECT_RET(EXP, MSG, { })
+
+#endif // RCS_JNI_LOG_H
diff --git a/service/resource-encapsulation/android/service/src/main/jni/util/ScopedEnv.h b/service/resource-encapsulation/android/service/src/main/jni/util/ScopedEnv.h
new file mode 100644 (file)
index 0000000..c1b9030
--- /dev/null
@@ -0,0 +1,162 @@
+/******************************************************************
+ *
+ * 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 RCS_JIN_SCOPEDENV_H_
+#define RCS_JIN_SCOPEDENV_H_
+
+#include <utility>
+
+#include <jni.h>
+
+#include "JNIEnvWrapper.h"
+#include "Log.h"
+
+extern JavaVM* g_jvm;
+
+namespace Detail
+{
+    inline std::pair<JNIEnv*, bool> getEnv()
+    {
+        JNIEnv* env{ };
+        bool needToDetach{ };
+
+        auto ret = g_jvm->GetEnv((void**) &env, JNI_VERSION_1_6);
+
+        switch (ret)
+        {
+            case JNI_OK:
+                break;
+
+            case JNI_EDETACHED:
+            {
+                auto attachRet = g_jvm->AttachCurrentThread(&env, NULL);
+
+                if (attachRet != JNI_OK)
+                {
+                    LOGT_E("JNI-ScopedEnv", "Failed to get the environment : %d", attachRet);
+                }
+                else
+                {
+                    needToDetach = true;
+                }
+                break;
+            }
+            case JNI_EVERSION:
+                LOGT_E("JNI-ScopedEnv", "JNI version not supported");
+                break;
+
+            default:
+                LOGT_E("JNI-ScopedEnv", "Failed to get the environment");
+                break;
+        }
+
+        return { env, needToDetach };
+    }
+}
+
+class ScopedEnv
+{
+public:
+    ScopedEnv() noexcept :
+        m_env { },
+        m_needToDetach{ false }
+    {
+        auto val = Detail::getEnv();
+
+        m_env = val.first;
+        m_needToDetach = val.second;
+    }
+
+    ~ScopedEnv()
+    {
+        if (m_env && m_needToDetach)
+        {
+            g_jvm->DetachCurrentThread();
+        }
+    }
+
+    ScopedEnv(const ScopedEnv&) = delete;
+    ScopedEnv& operator=(const ScopedEnv&) = delete;
+
+    operator bool() const noexcept
+    {
+        return m_env;
+    }
+
+    JNIEnv* operator->() noexcept
+    {
+        return m_env;
+    }
+
+    JNIEnv* get() noexcept
+    {
+        return m_env;
+    }
+
+private:
+    JNIEnv* m_env;
+    bool m_needToDetach;
+};
+
+class ScopedEnvWrapper
+{
+public:
+    ScopedEnvWrapper() noexcept :
+        m_env { },
+        m_needToDetach{ false }
+    {
+        auto val = Detail::getEnv();
+
+        m_env = val.first;
+        m_needToDetach = val.second;
+    }
+
+    ~ScopedEnvWrapper()
+    {
+        if (m_env && m_needToDetach)
+        {
+            g_jvm->DetachCurrentThread();
+        }
+    }
+
+    ScopedEnvWrapper(const ScopedEnvWrapper&) = delete;
+    ScopedEnvWrapper& operator=(const ScopedEnvWrapper&) = delete;
+
+    operator bool() const noexcept
+    {
+        return m_env;
+    }
+
+    JNIEnvWrapper* operator->() noexcept
+    {
+        return &m_env;
+    }
+
+    JNIEnvWrapper* get() noexcept
+    {
+        return &m_env;
+    }
+
+private:
+    JNIEnvWrapper m_env;
+    bool m_needToDetach;
+};
+
+#endif // RCS_JIN_SCOPEDENV_H_
diff --git a/service/resource-encapsulation/android/service/src/main/jni/util/Verify.h b/service/resource-encapsulation/android/service/src/main/jni/util/Verify.h
new file mode 100644 (file)
index 0000000..5a4f4c6
--- /dev/null
@@ -0,0 +1,32 @@
+/******************************************************************
+ *
+ * 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 RCS_JNI_VERIFY_H_
+#define RCS_JNI_VERIFY_H_
+
+#define VERIFY_NO_EXC(ENV) do { \
+    if ((ENV)->ExceptionCheck()) { (ENV)->ExceptionDescribe(); return; } } while(false)
+
+#define VERIFY_NO_EXC_RET(ENV, RET) do { \
+    if ((ENV)->ExceptionCheck()) { (ENV)->ExceptionDescribe(); return RET; } } while(false)
+
+#define VERIFY_NO_EXC_RET_DEF(ENV) VERIFY_NO_EXC_RET(ENV, { })
+
+#endif // RCS_JNI_VERIFY_H_
diff --git a/service/resource-encapsulation/android/settings.gradle b/service/resource-encapsulation/android/settings.gradle
new file mode 100644 (file)
index 0000000..5b8f4d4
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * //******************************************************************
+ * //
+ * // Copyright 2015 Intel Corporation.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ * //
+ * // 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 ':service'
index 0de5e53..6fe5222 100644 (file)
@@ -117,7 +117,7 @@ void onResourceDiscovered(std::shared_ptr<RCSRemoteResourceObject> foundResource
     cond.notify_all();
 }
 
-void onRemoteAttributesReceivedCallback(const RCSResourceAttributes &attributes)
+void onRemoteAttributesReceivedCallback(const RCSResourceAttributes &attributes, int /*eCode*/)
 {
     std::cout << "onRemoteAttributesReceivedCallback callback\n" << std::endl;
 
index 58b6795..197f8b0 100644 (file)
@@ -168,7 +168,7 @@ void onCacheUpdated(const RCSResourceAttributes& attributes)
     }
 }
 
-void onRemoteAttributesReceivedCallback(const RCSResourceAttributes& attributes)
+void onRemoteAttributesReceivedCallback(const RCSResourceAttributes& attributes, int)
 {
     std::cout << "onRemoteAttributesReceivedCallback callback" << std::endl;
 
index 7a571f4..093245b 100644 (file)
@@ -30,11 +30,30 @@ namespace OIC
     {
         class RCSAddressDetail;
 
+        /**
+         * This is to specify a target address to discover.
+         *
+         * @see RCSDiscoveryManager
+         */
         class RCSAddress
         {
         public:
+            /**
+             * Factory method for multicast.
+             *
+             */
             static RCSAddress multicast();
+
+            /**
+             * Factory method for unicast.
+             *
+             * @param address A physical address for the target.
+             */
             static RCSAddress unicast(const std::string& address);
+
+            /**
+             * @overload
+             */
             static RCSAddress unicast(std::string&& address);
 
         private:
index 36a633a..3f57cf4 100755 (executable)
@@ -82,7 +82,7 @@ namespace OIC
                                        ResourceDiscoveredCallback;
 
                 /**
-                 * @return Returns RCSDiscoveryManager instance.
+                 * Returns RCSDiscoveryManager instance.
                  *
                  */
                 static RCSDiscoveryManager* getInstance();
@@ -94,6 +94,7 @@ namespace OIC
                  * @param cb A callback to obtain discovered resource
                  *
                  * @throws InvalidParameterException If cb is empty.
+                 * @throws PlatformException If the operation failed.
                  *
                  * @note The callback will be invoked in an internal thread.
                  *
@@ -111,6 +112,7 @@ namespace OIC
                  * @param cb A callback to obtain discovered resource
                  *
                  * @throws InvalidParameterException If cb is empty.
+                 * @throws PlatformException If the operation failed.
                  *
                  * @note The callback will be invoked in an internal thread.
                  *
@@ -128,6 +130,7 @@ namespace OIC
                  * @param cb A callback to obtain discovered resource
                  *
                  * @throws InvalidParameterException If cb is empty.
+                 * @throws PlatformException If the operation failed.
                  *
                  * @note The callback will be invoked in an internal thread.
                  *
@@ -146,6 +149,7 @@ namespace OIC
                  * @param cb A callback to obtain discovered resource
                  *
                  * @throws InvalidParameterException If cb is empty.
+                 * @throws PlatformException If the operation failed.
                  *
                  * @note The callback will be invoked in an internal thread.
                  *
index 9ba1595..5f0cf0f 100644 (file)
@@ -70,10 +70,11 @@ namespace OIC
 
         /**
          *
-         * The resource can be discovered with discoverResource.
-         * This class is an interaction point between Resource
-         * and the developers. Developer will get the RCSRemoteResourceObject
-         * by calling RCSDiscoveryManager::discoverResource.
+         * This represents a remote resource and provides simple ways to interact with it.
+         * Basically this is a client of a remote resource that runs on other device.
+         *
+         * The class supports features to help get information of a remote resource
+         * such as monitoring and caching.
          *
          * @see RCSDiscoveryManager
          *
@@ -102,7 +103,7 @@ namespace OIC
              *
              * @see RCSResourceAttributes
              */
-            typedef std::function< void(const RCSResourceAttributes&) >
+            typedef std::function< void(const RCSResourceAttributes&, int) >
                 RemoteAttributesGetCallback;
 
             /**
@@ -110,7 +111,7 @@ namespace OIC
              *
              * @see RCSResourceAttributes
              */
-            typedef std::function< void(const RCSResourceAttributes&) >
+            typedef std::function< void(const RCSResourceAttributes&, int) >
                 RemoteAttributesSetCallback;
 
         private:
@@ -125,14 +126,14 @@ namespace OIC
             ~RCSRemoteResourceObject();
 
             /**
-             * @return Returns whether monitoring is enabled.
+             * Returns whether monitoring is enabled.
              *
              * @see startMonitoring()
              */
             bool isMonitoring() const;
 
             /**
-             * @return Returns whether caching is enabled.
+             * Returns whether caching is enabled.
              *
              * @see startCaching()
              */
@@ -140,7 +141,7 @@ namespace OIC
             bool isCaching() const;
 
             /**
-             * @return Returns whether the resource is observable.
+             * Returns whether the resource is observable.
              *
              */
             bool isObservable() const;
@@ -177,7 +178,7 @@ namespace OIC
             void stopMonitoring();
 
             /**
-             * @return Returns the current state of the resource.
+             * Returns the current state of the resource.
              *
              * @see startMonitoring
              */
@@ -186,7 +187,7 @@ namespace OIC
             /**
              * Starts caching attributes of the resource.
              *
-             * This will start data caching for the resource.
+             * This will start caching for the resource.
              * Once caching started it will look for the data updation on the resource
              * and updates the cache data accordingly.
              *
@@ -234,16 +235,16 @@ namespace OIC
             void stopCaching();
 
             /**
-             * @return Returns the current cache state.
+             * Returns the current cache state.
              *
              */
             CacheState getCacheState() const;
 
             /**
-             * @return Returns whether cached data is available.
+             * Returns whether cached data is available.
              *
-             * Cache will be available always after CacheState::READY even if current state is
-             * CacheState::LOST_SIGNAL.
+             * Cache will be available always once cache state had been CacheState::READY
+             * even if current state is CacheState::LOST_SIGNAL.
              *
              * @see getCacheState()
              */
@@ -290,7 +291,8 @@ namespace OIC
              * This API send a get request to the resource of interest and provides
              * the attributes to the caller in the RemoteAttributesReceivedCallback.
              *
-             * @throw InvalidParameterException If cb is an empty function or null.
+             * @throws PlatformException If the operation failed
+             * @throws InvalidParameterException If cb is an empty function or null.
              *
              * @see RCSResourceAttributes::Value
              *
@@ -306,7 +308,8 @@ namespace OIC
              * @param attributes Attributes to set
              * @param cb A callback to receive the response.
              *
-             * @throw InvalidParameterException If cb is an empty function or null.
+             * @throws PlatformException If the operation failed
+             * @throws InvalidParameterException If cb is an empty function or null.
              *
              * @see RCSResourceObject
              * @see RCSResourceObject::SetRequestHandlerPolicy
@@ -317,25 +320,25 @@ namespace OIC
                     RemoteAttributesSetCallback cb);
 
             /**
-             * @return Returns the uri of the resource.
+             * Returns the uri of the resource.
              *
              */
             std::string getUri() const;
 
             /**
-             * @return Returns the address of the resource .
+             * Returns the address of the resource .
              *
              */
             std::string getAddress() const;
 
             /**
-             * @return Returns the resource types of the resource.
+             * Returns the resource types of the resource.
              *
              */
             std::vector< std::string > getTypes() const;
 
             /**
-             * @return Returns the resource interfaces of the resource.
+             * Returns the resource interfaces of the resource.
              *
              */
             std::vector< std::string > getInterfaces() const;
index e062d40..670f77b 100644 (file)
@@ -145,7 +145,7 @@ namespace OIC
                 IsSupportedTypeHelper< T >::type::value, std::true_type, std::false_type>::type { };
 
             /**
-             * Identifier for types of Value.
+             * Identifiers for types of Value.
              *
              * @see Type
              */
@@ -278,7 +278,7 @@ namespace OIC
                 {
                 }
 
-                Value(const char* value);
+                Value(const char*);
 
                 Value& operator=(const Value&);
                 Value& operator=(Value&&);
index 3fb490f..14ac8df 100755 (executable)
@@ -63,7 +63,7 @@ namespace OIC
         //! @endcond
 
         /**
-         * @brief  RCSResourceObject represents a resource. It handles any requests from
+         * @brief RCSResourceObject represents a resource. It handles any requests from
          *        clients automatically with attributes.
          *        It also provides an auto notification mechanism that notifies to the observers.
          *        <br/>
@@ -142,7 +142,7 @@ namespace OIC
                          * @param discoverable Whether to be discovered.
                          *
                          */
-                        Builder &setDiscoverable(bool discoverable);
+                        BuildersetDiscoverable(bool discoverable);
 
                         /**
                          * Sets the observable property of the resource.
@@ -150,7 +150,7 @@ namespace OIC
                          * @param observable Whether to be observed.
                          *
                          */
-                        Builder &setObservable(bool observable);
+                        BuildersetObservable(bool observable);
 
                         /**
                          * Sets attribute of the resource.
@@ -158,12 +158,12 @@ namespace OIC
                          * @param attributes Resource attributes to set
                          *
                          */
-                        Builder &setAttributes(const RCSResourceAttributes &attributes);
+                        BuildersetAttributes(const RCSResourceAttributes &attributes);
 
                         /**
                          * @overload
                          */
-                        Builder &setAttributes(RCSResourceAttributes &&attributes);
+                        BuildersetAttributes(RCSResourceAttributes &&attributes);
 
                         /**
                          * Construct a RCSResourceObject.
@@ -197,7 +197,7 @@ namespace OIC
                  * The second Value means the new Value right after when it is used
                  */
                 typedef std::function < void(const RCSResourceAttributes::Value&,
-                                     const RCSResourceAttributes::Value &) > AttributeUpdatedListener;
+                                     const RCSResourceAttributes::Value&) > AttributeUpdatedListener;
 
             public:
                 RCSResourceObject(RCSResourceObject&&) = delete;
@@ -371,6 +371,8 @@ namespace OIC
 
                 /**
                  * Notifies all observers of the updated attributes.
+                 *
+                 * @throws PlatformException If the operation failed.
                  */
                 virtual void notify() const;
 
diff --git a/service/resource-encapsulation/sdk/java/jni/Android.mk b/service/resource-encapsulation/sdk/java/jni/Android.mk
deleted file mode 100644 (file)
index 6c51202..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-OIC_LIB_PATH := ../../../../../out/android/$(TARGET_ARCH_ABI)/release
-LOCAL_MODULE := android-oc_logger
-LOCAL_SRC_FILES := $(OIC_LIB_PATH)/liboc_logger.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-OIC_LIB_PATH := ../../../../../out/android/$(TARGET_ARCH_ABI)/release
-LOCAL_MODULE := android-oc_loggercore
-LOCAL_SRC_FILES := $(OIC_LIB_PATH)/liboc_logger_core.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-OIC_LIB_PATH := ../../../../../out/android/$(TARGET_ARCH_ABI)/release
-LOCAL_MODULE := android-octbstack
-LOCAL_SRC_FILES := $(OIC_LIB_PATH)/liboctbstack.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-OIC_LIB_PATH := ../../../../../out/android/$(TARGET_ARCH_ABI)/release
-LOCAL_MODULE := android-oc
-LOCAL_SRC_FILES := $(OIC_LIB_PATH)/liboc.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-OIC_LIB_PATH := ../../../../../out/android/$(TARGET_ARCH_ABI)/release
-LOCAL_MODULE := android-connectivity_abstraction
-LOCAL_SRC_FILES := $(OIC_LIB_PATH)/libconnectivity_abstraction.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-OIC_LIB_PATH := ../../../../../android/android_api/base/libs/$(TARGET_ARCH_ABI)
-LOCAL_MODULE := android-ocstack-jni
-LOCAL_SRC_FILES := $(OIC_LIB_PATH)/libocstack-jni.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-OIC_LIB_PATH := ../../../../../android/android_api/base/libs/$(TARGET_ARCH_ABI)
-LOCAL_MODULE := android-ca-interface
-LOCAL_SRC_FILES := $(OIC_LIB_PATH)/libca-interface.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-OIC_LIB_PATH := ../../../../../out/android/$(TARGET_ARCH_ABI)/release
-LOCAL_MODULE := android-resourcecommon
-LOCAL_SRC_FILES := $(OIC_LIB_PATH)/librcs_common.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-OIC_LIB_PATH := ../../../../../out/android/$(TARGET_ARCH_ABI)/release
-LOCAL_MODULE := android-resourceclient
-LOCAL_SRC_FILES := $(OIC_LIB_PATH)/librcs_client.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-OIC_LIB_PATH := ../../../../../out/android/$(TARGET_ARCH_ABI)/release
-LOCAL_MODULE := android-resourceserver
-LOCAL_SRC_FILES := $(OIC_LIB_PATH)/librcs_server.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-OIC_LIB_PATH := ../../../../../out/android/$(TARGET_ARCH_ABI)/release
-LOCAL_MODULE := android-resourcecontainer
-LOCAL_SRC_FILES := $(OIC_LIB_PATH)/librcs_container.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-OIC_SRC_DIR := ../../../..
-LOCAL_MODULE    := re-jni
-
-LOCAL_C_INCLUDES := $(LOCAL_PATH)/jniutil/inc \
-                    $(OIC_SRC_DIR)/android/android_api/base/jni \
-                    $(OIC_SRC_DIR)/resource/include \
-                    $(OIC_SRC_DIR)/resource/c_common \
-                    $(OIC_SRC_DIR)/resource/csdk/stack/include \
-                    $(OIC_SRC_DIR)/resource/oc_logger/include \
-                    $(OIC_SRC_DIR)/extlibs/boost/boost_1_58_0 \
-                    $(OIC_SRC_DIR)/extlibs/timer \
-                    $(OIC_SRC_DIR)/service/resource-encapsulation/include \
-                    $(LOCAL_PATH)/re/include
-
-LOCAL_SRC_FILES += $(patsubst $(LOCAL_PATH)/%, %, $(wildcard $(LOCAL_PATH)/jniutil/src/*.cpp))
-LOCAL_SRC_FILES += $(patsubst $(LOCAL_PATH)/%, %, $(wildcard $(LOCAL_PATH)/re/src/*.cpp))
-
-LOCAL_CPPFLAGS := -std=c++0x -frtti -fexceptions
-
-LOCAL_LDLIBS := -llog
-LOCAL_SHARED_LIBRARIES := android-ocstack-jni
-LOCAL_SHARED_LIBRARIES += android-resourcecommon
-LOCAL_SHARED_LIBRARIES += android-resourceclient
-LOCAL_SHARED_LIBRARIES += android-resourceserver
-LOCAL_SHARED_LIBRARIES += android-resourcecontainer
-LOCAL_SHARED_LIBRARIES += android-oc
-LOCAL_SHARED_LIBRARIES += android-octbstack
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/service/resource-encapsulation/sdk/java/jni/jniutil/inc/jni_re_jvm.h b/service/resource-encapsulation/sdk/java/jni/jniutil/inc/jni_re_jvm.h
deleted file mode 100644 (file)
index 52d3187..0000000
+++ /dev/null
@@ -1,153 +0,0 @@
-/******************************************************************
- *
- * 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.
- *
- ******************************************************************/
-
-/**
-  * @file   jni_re_jvm.h
-  *
-  * @brief  This file contains the essential declarations and functions required
-  *            for JNI implementation
-  */
-
-#ifndef __JNI_RE_JVM_H
-#define __JNI_RE_JVM_H
-
-#include <jni.h>
-#include <android/log.h>
-#include<string>
-
-#define RETAG "RE-JNI"
-#define JNI_CURRENT_VERSION JNI_VERSION_1_6
-
-#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, RETAG, __VA_ARGS__)
-#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, RETAG, __VA_ARGS__)
-#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, RETAG, __VA_ARGS__)
-
-extern JavaVM *g_jvm;
-
-extern jclass g_cls_Integer;
-extern jclass g_cls_Double;
-extern jclass g_cls_Boolean;
-extern jclass g_cls_String;
-extern jclass g_cls_LinkedList;
-extern jclass g_cls_Iterator;
-extern jclass g_cls_Vector;
-extern jclass g_cls_Map;
-extern jclass g_cls_Set;
-extern jclass g_cls_MapEntry;
-extern jclass g_cls_RCSRemoteResourceObject;
-extern jclass g_cls_RCSRemoteResourceAttributesObject;
-extern jclass g_cls_RCSException;
-
-extern jclass g_cls_RCSResourceObject;
-extern jclass g_cls_RCSRequest;
-extern jclass g_cls_RCSBundleInfo;
-
-extern jmethodID g_mid_Integer_ctor;
-extern jmethodID g_mid_Integer_getInt;
-extern jmethodID g_mid_Double_getDouble;
-extern jmethodID g_mid_Boolean_getBoolean;
-extern jmethodID g_mid_Double_ctor;
-extern jmethodID g_mid_Boolean_ctor;
-extern jmethodID g_mid_LinkedList_ctor;
-extern jmethodID g_mid_LinkedList_add_object;
-extern jmethodID g_mid_Vector_ctor;
-extern jmethodID g_mid_Vector_size;
-extern jmethodID g_mid_Vector_get;
-extern jmethodID g_mid_Vector_add;
-extern jmethodID g_mid_Map_entrySet;
-extern jmethodID g_mid_MapEntry_getKey;
-extern jmethodID g_mid_MapEntry_getValue;
-extern jmethodID g_mid_Set_iterator;
-extern jmethodID g_mid_Iterator_hasNext;
-extern jmethodID g_mid_Iterator_next;
-extern jmethodID g_mid_HashMap_ctor;
-extern jmethodID g_mid_HashMap_put;
-extern jmethodID g_mid_RCSRemoteResourceObject_ctor;
-extern jmethodID g_mid_RCSRemoteResourceAttributesObject_ctor;
-extern jmethodID g_mid_RCSRemoteResourceAttributesObject_ctor_bool;
-extern jmethodID g_mid_RCSException_ctor;
-
-extern jmethodID g_mid_RCSResourceObject_ctor;
-extern jmethodID g_mid_RCSRequest_ctor;
-extern jmethodID g_mid_RCSBundleInfo_ctor;
-
-typedef void(*RemoveListenerCallback)(JNIEnv *env, jobject jListener);
-
-/**
- * @brief Get the native handle field
- */
-static jfieldID REGetHandleField(JNIEnv *env, jobject jobj)
-{
-    jclass cls = env->GetObjectClass(jobj);
-    return env->GetFieldID(cls, "m_nativeHandle", "J");
-}
-
-/**
- * @brief Get the native handle
- */
-template <typename T>
-static T *REGetHandle(JNIEnv *env, jobject jobj)
-{
-    jlong handle = env->GetLongField(jobj, REGetHandleField(env, jobj));
-    return reinterpret_cast<T *>(handle);
-}
-
-/**
- * @brief Set the native handle
- */
-template <typename T>
-static void RESetHandle(JNIEnv *env, jobject jobj, T *type)
-{
-    jlong handle = reinterpret_cast<jlong>(type);
-
-    env->SetLongField(jobj, REGetHandleField(env, jobj), handle);
-}
-
-/**
- * @brief Get the JNI Environment
- */
-static JNIEnv *GetREJNIEnv(jint &ret)
-{
-    JNIEnv *env = NULL;
-
-    ret = g_jvm->GetEnv((void **)&env, JNI_CURRENT_VERSION);
-    switch (ret)
-    {
-        case JNI_OK:
-            return env;
-        case JNI_EDETACHED:
-            if (g_jvm->AttachCurrentThread(&env, NULL) < 0)
-            {
-                LOGE("Failed to get the environment");
-                return nullptr;
-            }
-            else
-            {
-                return env;
-            }
-
-        case JNI_EVERSION:
-            LOGE("JNI version not supported");
-        default:
-            LOGE("Failed to get the environment");
-            return nullptr;
-    }
-}
-#endif // __JNI_RE_JVM_H
diff --git a/service/resource-encapsulation/sdk/java/jni/jniutil/inc/jni_re_utils.h b/service/resource-encapsulation/sdk/java/jni/jniutil/inc/jni_re_utils.h
deleted file mode 100644 (file)
index 4e51f88..0000000
+++ /dev/null
@@ -1,307 +0,0 @@
-/******************************************************************
- *
- * 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.
- *
- ******************************************************************/
-
-/**
-  * @file
-  * This file contains the utility functions for JNI
-  */
-
-#ifndef __JNI_RE_UTILS_H_
-#define __JNI_RE_UTILS_H_
-
-#include "jni_re_jvm.h"
-#include "RCSRemoteResourceObject.h"
-#include "RCSResourceObject.h"
-
-#include <map>
-#include <list>
-#include <jni.h>
-
-using namespace OIC::Service;
-
-/**
- * @brief Convert Native ResourceState to Integer
- */
-int covertResourceStateToInt(ResourceState state);
-
-/**
- * @brief Convert Native CacheState to Integer
- */
-int convertCacheStateToInt(CacheState state);
-
-/**
- * @brief Native Vector to Java list
- */
-jobject convertStrVectorToJavaStrList(JNIEnv *env, std::vector<std::string> vector);
-
-/**
- * @brief Convert Native ResourceState to Java ResourceState
- */
-jobject convertNativeResourceStateToJavaResourceState(ResourceState nativeResourceState,
-        JNIEnv *env);
-
-/**
- * @brief Convert Java AutoNotifyPolicy to Native AutoNotifyPolicy
- */
-RCSResourceObject::AutoNotifyPolicy convertJavaNotifyPolicyToNativePolicy( int policy);
-
-/**
- * @brief Convert AutoNotifyPolicy to integer
- */
-int  convertAutoNotifyPolicyToInt(RCSResourceObject::AutoNotifyPolicy policy);
-
-/**
- *@brief Convert Java setRequestHandlerPolicy to Native setRequestHandlerPolicy
- */
-RCSResourceObject::SetRequestHandlerPolicy convertJavasetRequestHandlerPolicyToNativePolicy(
-    int policy);
-
-/**
- *@brief Convert setRequestHandlerPolicy to int
- */
-int convertSetRequestHandlerPolicyToInt( RCSResourceObject::SetRequestHandlerPolicy policy);
-
-/**
- *@brief Convert int to OCEntityHandlerResult
- */
-OCEntityHandlerResult convertIntToOCEntityHandlerResult(int result);
-
-/**
- *@brief Convert java map to native map
- */
-void convertJavaMapToParamsMap(JNIEnv *env, jobject hashMap,
-                               std::map<std::string, std::string> &params);
-
-/**
- *@brief Convert native string list to java list
- */
-jobject convertStrListToJavaStrList(JNIEnv *env, std::list<std::string> &list);
-
-/**
- *@brief Convert java Integer vector to native Integer vector
- */
-std::vector<int> covertJavaIntVectorToNativeVector(JNIEnv *env, jobject javaVector);
-
-/**
- *@brief Convert java  vector of Vector of Integer to native vector
- */
-std::vector<std::vector<int>> convertJavaVectorOfVectorOfIntToNativeVector(JNIEnv *env,
-                           jobject javaVector);
-
-/**
- *@brief Convert java  vector of Vector of Vector of Integer to native vector
- */
-std::vector<std::vector<std::vector<int>>> convertJavaVectorOfVectorOfVectorOfIntToNativeVector(
-    JNIEnv *env, jobject javaVector);
-
-/**
- *@brief Convert native Integer vector to Java Integer vector
- */
-jobject convertNativeIntVectorToJavaVector(JNIEnv *env, std::vector<int> &nativeVector);
-
-/**
- *@brief Convert native Vector of Vector of Integer to Java vector
- */
-jobject convertNativeVectorOfVectorOfIntToJavaVector(JNIEnv *env,
-        std::vector<std::vector<int>> &nativeVector);
-
-/**
- *@brief Convert native Vector of Vector of Vector of Integer to Java vector
- */
-jobject convertNativeVectorOfVectorOfVectorOfIntToJavaVector(JNIEnv *env,
-        std::vector<std::vector<std::vector<int>>> &nativeVector);
-
-/**
- *@brief Convert java Double vector to native vector
- */
-std::vector<double> covertJavaDoubleVectorToNativeVector(JNIEnv *env, jobject javaVector);
-
-/**
- *@brief Convert java vector of Vector of Double to native vector
- */
-std::vector<std::vector<double>> convertJavaVectorOfVectorOfDoubleToNativeVector(JNIEnv *env,
-                              jobject javaVector);
-
-/**
- *@brief Convert java  vector of Vector of Vector of Double to native vector
- */
-std::vector<std::vector<std::vector<double>>>
-convertJavaVectorOfVectorOfVectorOfDoubleToNativeVector(JNIEnv *env, jobject javaVector);
-
-/**
- *@brief Convert native Double vector to jave vector
- */
-jobject convertNativeDoubleVectorToJavaVector(JNIEnv *env, std::vector<double> &nativeVector);
-
-/**
- *@brief Convert native Vector of Vector of Double to Java vector
- */
-jobject convertNativeVectorOfVectorOfDoubleToJavaVector(JNIEnv *env,
-        std::vector<std::vector<double>> &nativeVector);
-
-/**
- *@brief Convert native Vector of Vector of Vector of Double to Java vector
- */
-jobject convertNativeVectorOfVectorOfVectorOfDoubleToJavaVector(JNIEnv *env,
-        std::vector<std::vector<std::vector<double>>> &nativeVector);
-
-/**
- *@brief Convert java Boolean vector to native vector
- */
-std::vector<bool> covertJavaBooleanVectorToNativeVector(JNIEnv *env, jobject javaVector);
-
-/**
- *@brief Convert java vector of Vector of boolean to native vector
- */
-std::vector<std::vector<bool>> convertJavaVectorOfVectorOfBooleanToNativeVector(JNIEnv *env,
-                            jobject javaVector);
-
-/**
- *@brief Convert java  vector of Vector of Vector of Boolean to native vector
- */
-std::vector<std::vector<std::vector<bool>>>
-convertJavaVectorOfVectorOfVectorOfBooleanToNativeVector(JNIEnv *env, jobject javaVector);
-
-/**
- *@brief Convert native Bool vector to Java vector
- */
-jobject convertNativeBooleanVectorToJavaVector(JNIEnv *env, std::vector<bool> &nativeVector);
-
-/**
- *@brief Convert native Vector of Vector of Boolean to Java vector
- */
-jobject convertNativeVectorOfVectorOfBooleanToJavaVector(JNIEnv *env,
-        std::vector<std::vector<bool>> &nativeVector);
-
-/**
- *@brief Convert native Vector of Vector of Vector of Boolean to Java vector
- */
-jobject convertNativeVectorOfVectorOfVectorOfBooleanToJavaVector(JNIEnv *env,
-        std::vector<std::vector<std::vector<bool>>> &nativeVector);
-
-/**
- *@brief Convert java String vector to native vector
- */
-std::vector<std::string> covertJavaStringVectorToNativeVector(JNIEnv *env, jobject javaVector);
-
-/**
- *@brief Convert java vector of Vector of String to native vector
- */
-std::vector<std::vector<std::string>> convertJavaVectorOfVectorOfStringToNativeVector(JNIEnv *env,
-                                   jobject javaVector);
-
-/**
- *@brief Convert java  vector of Vector of Vector of String to native vector
- */
-std::vector<std::vector<std::vector<std::string>>>
-convertJavaVectorOfVectorOfVectorOfStringToNativeVector(JNIEnv *env, jobject javaVector);
-
-/**
- *@brief Convert native String vector to Java vector
- */
-jobject convertNativeStringVectorToJavaVector(JNIEnv *env, std::vector<std::string> &nativeVector);
-
-/**
- *@brief Convert native Vector of Vector of String to Java vector
- */
-jobject convertNativeVectorOfVectorOfStringToJavaVector(JNIEnv *env,
-        std::vector<std::vector<std::string>> &nativeVector);
-
-/**
- *@brief Convert native Vector of Vector of Vector of String to Java vector
- */
-jobject convertNativeVectorOfVectorOfVectorOfStringToJavaVector(JNIEnv *env,
-        std::vector<std::vector<std::vector<std::string>>> &nativeVector);
-
-/**
- * @brief Throw the RCS exception to the upper layer
- */
-void throwRCSException(JNIEnv *env, std::string reason);
-
-/**
- * @class   ResourceStateWrapper
- * @brief   This class is JNI wrapper for Java ResourceState.
- *
- */
-class ResourceStateWrapper
-{
-        ResourceStateWrapper() {}
-    public :
-
-        //Field IDs
-        static jfieldID  ALIVE_ID;
-        static jfieldID  REQUESTED_ID;
-        static jfieldID  LOST_SIGNAL_ID;
-        static jfieldID  DESTROYED_ID;
-        static jfieldID  NONE_ID;
-
-        //Method IDs
-        static jmethodID ordinal_ID;
-        static jmethodID toString_ID;
-        static jmethodID valueOf_ID;
-
-        static jclass clazz;
-
-        /**
-         *  @brief Get jobject for ALIVE ResourceState
-         */
-        static jobject getALIVE(JNIEnv *env);
-
-        /**
-         *  @brief Get jobject for REQUESTED ResourceState
-         */
-        static jobject getREQUESTED(JNIEnv *env);
-
-        /**
-         *  @brief Get jobject for SIGNAL ResourceState
-         */
-        static jobject getLOST_SIGNAL(JNIEnv *env);
-
-        /**
-         *  @brief Get jobject for DESTROYED ResourceState
-         */
-        static jobject getDESTROYED(JNIEnv *env);
-
-        /**
-         *  @brief Get jobject for NONE ResourceState
-         */
-        static jobject getNONE(JNIEnv *env);
-
-        /**
-         *  @brief Returns the ordinal value of Enum Object
-         */
-        static jint ordinal(JNIEnv *env, jobject enumObj);
-
-        /**
-         *  @brief Returns the name of Enum Object
-         */
-        static jstring toString(JNIEnv *env, jobject enumObj);
-
-        /**
-         *  @brief Returns Enum Object by name
-         */
-        static jobject valueOf(JNIEnv *env, jstring enumName);
-
-        /**
-         * @brief virtual destructor
-         */
-        virtual ~ResourceStateWrapper() {};
-};
-#endif //__JNI_RE_UTILS_H_
diff --git a/service/resource-encapsulation/sdk/java/jni/jniutil/src/jni_re_jvm.cpp b/service/resource-encapsulation/sdk/java/jni/jniutil/src/jni_re_jvm.cpp
deleted file mode 100644 (file)
index d42cbc7..0000000
+++ /dev/null
@@ -1,306 +0,0 @@
-/******************************************************************
- *
- * 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 "jni_re_jvm.h"
-#include "jni_re_utils.h"
-
-JavaVM *g_jvm = NULL;
-
-jclass g_cls_Integer = NULL;
-jclass g_cls_Double = NULL;
-jclass g_cls_Boolean = NULL;
-jclass g_cls_String = NULL;
-jclass g_cls_LinkedList = NULL;
-jclass g_cls_Iterator = NULL;
-jclass g_cls_Vector = NULL;
-jclass g_cls_Map = NULL;
-jclass g_cls_Set = NULL;
-jclass g_cls_MapEntry = NULL;
-jclass g_cls_RCSRemoteResourceObject = NULL;
-jclass g_cls_RCSRemoteResourceAttributesObject = NULL;
-jclass g_cls_RCSException = NULL;
-
-jclass g_cls_RCSResourceObject = NULL;
-jclass g_cls_RCSRequest = NULL;
-jclass g_cls_RCSBundleInfo = NULL;
-
-jmethodID g_mid_Integer_ctor = NULL;
-jmethodID g_mid_Integer_getInt = NULL;
-jmethodID g_mid_Double_ctor = NULL;
-jmethodID g_mid_Double_getDouble = NULL;
-jmethodID g_mid_Boolean_getBoolean = NULL;
-jmethodID g_mid_Boolean_ctor = NULL;
-jmethodID g_mid_LinkedList_ctor = NULL;
-jmethodID g_mid_Set_iterator = NULL;
-jmethodID g_mid_LinkedList_add_object = NULL;
-jmethodID g_mid_Vector_ctor = NULL;
-jmethodID g_mid_Vector_size = NULL;
-jmethodID g_mid_Vector_get = NULL;
-jmethodID g_mid_Vector_add = NULL;
-jmethodID g_mid_Map_entrySet = NULL;
-jmethodID g_mid_MapEntry_getKey = NULL;
-jmethodID g_mid_MapEntry_getValue = NULL;
-jmethodID g_mid_Iterator_hasNext = NULL;
-jmethodID g_mid_Iterator_next = NULL;
-jmethodID g_mid_RCSRemoteResourceObject_ctor = NULL;
-jmethodID g_mid_RCSRemoteResourceAttributesObject_ctor = NULL;
-jmethodID g_mid_RCSRemoteResourceAttributesObject_ctor_bool = NULL;
-jmethodID g_mid_RCSException_ctor = NULL;
-
-jmethodID g_mid_RCSResourceObject_ctor = NULL;
-jmethodID g_mid_RCSRequest_ctor = NULL;
-jmethodID g_mid_RCSBundleInfo_ctor = NULL;
-
-// JNI OnLoad
-JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
-{
-    LOGI("JNI_OnLoad");
-    JNIEnv *env;
-    g_jvm = vm;
-
-    if (g_jvm->GetEnv((void **)&env, JNI_CURRENT_VERSION) != JNI_OK)
-    {
-        LOGE("Failed to get the environment using GetEnv()");
-        return JNI_ERR;
-    }
-
-    jclass clazz = nullptr;
-
-    //Integer
-    clazz = env->FindClass("java/lang/Integer");
-    if (!clazz) return JNI_ERR;
-    g_cls_Integer = (jclass)env->NewGlobalRef(clazz);
-    env->DeleteLocalRef(clazz);
-
-    g_mid_Integer_ctor = env->GetMethodID(g_cls_Integer, "<init>", "(I)V");
-    if (!g_mid_Integer_ctor) return JNI_ERR;
-
-    g_mid_Integer_getInt = env->GetMethodID(g_cls_Integer, "intValue", "()I");
-    if (!g_mid_Integer_getInt) return JNI_ERR;
-
-    //Double
-    clazz = env->FindClass("java/lang/Double");
-    if (!clazz) return JNI_ERR;
-    g_cls_Double = (jclass)env->NewGlobalRef(clazz);
-    env->DeleteLocalRef(clazz);
-
-    g_mid_Double_ctor = env->GetMethodID(g_cls_Double, "<init>", "(D)V");
-    if (!g_mid_Double_ctor) return JNI_ERR;
-
-    g_mid_Double_getDouble = env->GetMethodID(g_cls_Double, "doubleValue", "()D");
-    if (!g_mid_Double_getDouble) return JNI_ERR;
-
-
-    //Boolean
-    clazz = env->FindClass("java/lang/Boolean");
-    if (!clazz) return JNI_ERR;
-    g_cls_Boolean = (jclass)env->NewGlobalRef(clazz);
-    env->DeleteLocalRef(clazz);
-
-    g_mid_Boolean_ctor = env->GetMethodID(g_cls_Boolean, "<init>", "(Z)V");
-    if (!g_mid_Boolean_ctor) return JNI_ERR;
-
-    g_mid_Boolean_getBoolean = env->GetMethodID(g_cls_Boolean, "booleanValue", "()Z");
-    if (!g_mid_Boolean_getBoolean) return JNI_ERR;
-
-
-    //String
-    clazz = env->FindClass("java/lang/String");
-    if (!clazz) return JNI_ERR;
-    g_cls_String = (jclass)env->NewGlobalRef(clazz);
-    env->DeleteLocalRef(clazz);
-
-    //LinkedList
-    clazz = env->FindClass("java/util/LinkedList");
-    if (!clazz) return JNI_ERR;
-    g_cls_LinkedList = (jclass)env->NewGlobalRef(clazz);
-    env->DeleteLocalRef(clazz);
-
-    g_mid_LinkedList_ctor = env->GetMethodID(g_cls_LinkedList, "<init>", "()V");
-    if (!g_mid_LinkedList_ctor) return JNI_ERR;
-
-    g_mid_LinkedList_add_object = env->GetMethodID(g_cls_LinkedList, "add", "(Ljava/lang/Object;)Z");
-    if (!g_mid_LinkedList_add_object) return JNI_ERR;
-
-    //Map
-    clazz = env->FindClass("java/util/Map");
-    if (!clazz) return JNI_ERR;
-    g_cls_Map = (jclass)env->NewGlobalRef(clazz);
-    env->DeleteLocalRef(clazz);
-
-    g_mid_Map_entrySet = env->GetMethodID(g_cls_Map, "entrySet", "()Ljava/util/Set;");
-    if (!g_mid_Map_entrySet) return JNI_ERR;
-
-    //MapEntry
-    clazz = env->FindClass("java/util/Map$Entry");
-    if (!clazz) return JNI_ERR;
-    g_cls_MapEntry = (jclass)env->NewGlobalRef(clazz);
-    env->DeleteLocalRef(clazz);
-
-    g_mid_MapEntry_getKey = env->GetMethodID(g_cls_MapEntry, "getKey", "()Ljava/lang/Object;");
-    if (!g_mid_MapEntry_getKey) return JNI_ERR;
-    g_mid_MapEntry_getValue = env->GetMethodID(g_cls_MapEntry, "getValue", "()Ljava/lang/Object;");
-    if (!g_mid_MapEntry_getValue) return JNI_ERR;
-
-    //Set
-    clazz = env->FindClass("java/util/Set");
-    if (!clazz) return JNI_ERR;
-    g_cls_Set = (jclass)env->NewGlobalRef(clazz);
-    env->DeleteLocalRef(clazz);
-
-    g_mid_Set_iterator = env->GetMethodID(g_cls_Set, "iterator", "()Ljava/util/Iterator;");
-    if (!g_mid_Set_iterator) return JNI_ERR;
-
-    //Iterator
-    clazz = env->FindClass("java/util/Iterator");
-    if (!clazz) return JNI_ERR;
-    g_cls_Iterator = (jclass)env->NewGlobalRef(clazz);
-    env->DeleteLocalRef(clazz);
-
-    g_mid_Iterator_hasNext = env->GetMethodID(g_cls_Iterator, "hasNext", "()Z");
-    if (!g_mid_Iterator_hasNext) return JNI_ERR;
-
-    g_mid_Iterator_next = env->GetMethodID(g_cls_Iterator, "next", "()Ljava/lang/Object;");
-    if (!g_mid_Iterator_next) return JNI_ERR;
-
-    //Vector
-    clazz = env->FindClass("java/util/Vector");
-    if (!clazz) return JNI_ERR;
-    g_cls_Vector = (jclass)env->NewGlobalRef(clazz);
-    env->DeleteLocalRef(clazz);
-
-    g_mid_Vector_ctor = env->GetMethodID(g_cls_Vector, "<init>", "()V");
-    if (!g_mid_Vector_ctor) return JNI_ERR;
-
-    g_mid_Vector_size = env->GetMethodID(g_cls_Vector, "size", "()I");
-    if (!g_mid_Vector_size) return JNI_ERR;
-
-    g_mid_Vector_get = env->GetMethodID(g_cls_Vector, "get", "(I)""Ljava/lang/Object;");
-    if (!g_mid_Vector_get) return JNI_ERR;
-
-    g_mid_Vector_add =  env->GetMethodID(g_cls_Vector, "add", "(Ljava/lang/Object;)Z");
-    if (!g_mid_Vector_add) return JNI_ERR;
-
-    //RCSRemoteResourceObject
-    clazz = env->FindClass("org/iotivity/ResourceEncapsulation/client/RCSRemoteResourceObject");
-    if (!clazz) return JNI_ERR;
-    g_cls_RCSRemoteResourceObject = (jclass)env->NewGlobalRef(clazz);
-    env->DeleteLocalRef(clazz);
-
-    g_mid_RCSRemoteResourceObject_ctor = env->GetMethodID(g_cls_RCSRemoteResourceObject, "<init>",
-                                         "(J)V");
-    if (!g_mid_RCSRemoteResourceObject_ctor) return JNI_ERR;
-
-    //ResourceState enum
-    jclass tmpclazz = reinterpret_cast<jclass>
-            (env->FindClass("org/iotivity/ResourceEncapsulation/client/RCSRemoteResourceObject$ResourceState"));
-    if (!tmpclazz)
-    {
-        LOGE("Failed to get the class ResourceState");
-        return JNI_ERR;
-    }
-    ResourceStateWrapper::clazz = reinterpret_cast<jclass> (env->NewGlobalRef(tmpclazz));
-    env->DeleteLocalRef(tmpclazz);
-
-    //RCS Remote Resource Attributes
-    clazz = env->FindClass("org/iotivity/ResourceEncapsulation/common/RCSResourceAttributes");
-    if (!clazz) return JNI_ERR;
-    g_cls_RCSRemoteResourceAttributesObject = (jclass)env->NewGlobalRef(clazz);
-    env->DeleteLocalRef(clazz);
-
-    g_mid_RCSRemoteResourceAttributesObject_ctor = env->GetMethodID(
-                g_cls_RCSRemoteResourceAttributesObject, "<init>", "(J)V");
-    if (!g_mid_RCSRemoteResourceAttributesObject_ctor) return JNI_ERR;
-
-    g_mid_RCSRemoteResourceAttributesObject_ctor_bool = env->GetMethodID(
-               g_cls_RCSRemoteResourceAttributesObject, "<init>", "(JZ)V");
-    if (!g_mid_RCSRemoteResourceAttributesObject_ctor_bool) return JNI_ERR;
-
-    //RCSException
-    clazz = env->FindClass("org/iotivity/ResourceEncapsulation/common/RCSException");
-    if (!clazz) return JNI_ERR;
-    g_cls_RCSException = (jclass)env->NewGlobalRef(clazz);
-    env->DeleteLocalRef(clazz);
-
-    g_mid_RCSException_ctor = env->GetMethodID(g_cls_RCSException, "<init>", "(Ljava/lang/String;)V");
-    if (!g_mid_RCSException_ctor) return JNI_ERR;
-
-    //RCSResourceObject
-    clazz = env->FindClass("org/iotivity/ResourceEncapsulation/server/RCSResourceObject");
-    if (!clazz) return JNI_ERR;
-    g_cls_RCSResourceObject = (jclass)env->NewGlobalRef(clazz);
-    env->DeleteLocalRef(clazz);
-
-    g_mid_RCSResourceObject_ctor = env->GetMethodID(g_cls_RCSResourceObject, "<init>",
-                                   "(J)V");
-    if (!g_mid_RCSResourceObject_ctor) return JNI_ERR;
-
-    //RCSRequest
-    clazz = env->FindClass("org/iotivity/ResourceEncapsulation/server/RCSRequest");
-    if (!clazz) return JNI_ERR;
-    g_cls_RCSRequest = (jclass)env->NewGlobalRef(clazz);
-    env->DeleteLocalRef(clazz);
-
-    //RCSBundleInfo
-    clazz = env->FindClass("org/iotivity/ResourceEncapsulation/server/RCSBundleInfo");
-    if (!clazz) return JNI_ERR;
-    g_cls_RCSBundleInfo = (jclass)env->NewGlobalRef(clazz);
-    env->DeleteLocalRef(clazz);
-
-    g_mid_RCSBundleInfo_ctor = env->GetMethodID(g_cls_RCSBundleInfo, "<init>",
-                               "(J)V");
-    if (!g_mid_RCSBundleInfo_ctor) return JNI_ERR;
-
-    return JNI_CURRENT_VERSION;
-}
-
-JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved)
-{
-    LOGI("JNI_OnUnload");
-    JNIEnv *env;
-
-    if (g_jvm->GetEnv((void **)&env, JNI_CURRENT_VERSION) != JNI_OK)
-    {
-        LOGE("Failed to get the environment using GetEnv()");
-        return;
-    }
-
-    env->DeleteGlobalRef(g_cls_Integer);
-    env->DeleteGlobalRef(g_cls_Double);
-    env->DeleteGlobalRef(g_cls_Boolean);
-    env->DeleteGlobalRef(g_cls_String);
-    env->DeleteGlobalRef(g_cls_LinkedList);
-    env->DeleteGlobalRef(g_cls_Vector);
-    env->DeleteGlobalRef(g_cls_Iterator);
-    env->DeleteGlobalRef(g_cls_RCSRemoteResourceObject);
-    env->DeleteGlobalRef(g_cls_RCSRemoteResourceAttributesObject);
-    env->DeleteGlobalRef(g_cls_RCSException);
-    env->DeleteGlobalRef(g_cls_RCSResourceObject);
-    env->DeleteGlobalRef(g_cls_RCSRequest);
-    env->DeleteGlobalRef(g_cls_Map);
-    env->DeleteGlobalRef(g_cls_Set);
-    env->DeleteGlobalRef(g_cls_MapEntry);
-    env->DeleteGlobalRef(g_cls_RCSBundleInfo);
-
-    if (env)
-    {
-        if (ResourceStateWrapper::clazz != 0)
-            env->DeleteGlobalRef(ResourceStateWrapper::clazz);
-    }
-}
diff --git a/service/resource-encapsulation/sdk/java/jni/jniutil/src/jni_re_utils.cpp b/service/resource-encapsulation/sdk/java/jni/jniutil/src/jni_re_utils.cpp
deleted file mode 100644 (file)
index fa2a6f6..0000000
+++ /dev/null
@@ -1,997 +0,0 @@
-/******************************************************************
- *
- * 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 "jni_re_utils.h"
-#include "jni_re_resource_attributes.h"
-
-int covertResourceStateToInt(ResourceState state)
-{
-    switch (state)
-    {
-        case ResourceState::NONE:
-            return 0;
-
-        case ResourceState::REQUESTED:
-            return 1;
-
-        case ResourceState::ALIVE:
-            return 2;
-
-        case ResourceState::LOST_SIGNAL:
-            return 3;
-
-        case ResourceState::DESTROYED:
-            return 4;
-    }
-    return 0;
-}
-
-int convertCacheStateToInt(CacheState state)
-{
-    switch (state)
-    {
-        case CacheState::NONE:
-            return 0;
-
-        case CacheState::UNREADY:
-            return 1;
-
-        case CacheState::READY:
-            return 2;
-
-        case CacheState::LOST_SIGNAL:
-            return 3;
-    }
-    return 0;
-}
-
-jobject convertStrVectorToJavaStrList(JNIEnv *env, std::vector<std::string> vector)
-{
-    jobject jList = env->NewObject(g_cls_LinkedList, g_mid_LinkedList_ctor);
-    if (!jList) return nullptr;
-    for (size_t i = 0; i < vector.size(); ++i)
-    {
-        jstring jStr = env->NewStringUTF(vector[i].c_str());
-        if (!jStr) return nullptr;
-        env->CallBooleanMethod(jList, g_mid_LinkedList_add_object, jStr);
-        if (env->ExceptionCheck()) return nullptr;
-        env->DeleteLocalRef(jStr);
-    }
-    return jList;
-}
-
-OCEntityHandlerResult convertIntToOCEntityHandlerResult(int result)
-{
-    switch (result)
-    {
-        case 0:
-            return OCEntityHandlerResult::OC_EH_OK;
-        case 1:
-            return OCEntityHandlerResult::OC_EH_ERROR;
-        case 2:
-            return OCEntityHandlerResult::OC_EH_RESOURCE_CREATED;
-        case 3:
-            return OCEntityHandlerResult::OC_EH_RESOURCE_DELETED;
-        case 4:
-            return OCEntityHandlerResult::OC_EH_SLOW;
-        case 5:
-            return OCEntityHandlerResult::OC_EH_FORBIDDEN;
-        case 6:
-            return OCEntityHandlerResult::OC_EH_RESOURCE_NOT_FOUND;
-    }
-    return OCEntityHandlerResult::OC_EH_ERROR;
-}
-
-void throwRCSException(JNIEnv *env, std::string reason)
-{
-    jobject ex = env->NewObject(g_cls_RCSException, g_mid_RCSException_ctor,
-                                env->NewStringUTF(reason.c_str()));
-    if (!ex)
-    {
-        LOGI("throwRCSException jobject == NULL");
-    }
-    env->Throw((jthrowable)ex);
-}
-
-jfieldID  ResourceStateWrapper::ALIVE_ID = 0;
-jfieldID  ResourceStateWrapper::REQUESTED_ID = 0;
-jfieldID  ResourceStateWrapper::LOST_SIGNAL_ID = 0;
-jfieldID  ResourceStateWrapper::DESTROYED_ID = 0;
-jfieldID  ResourceStateWrapper::NONE_ID = 0;
-
-jmethodID ResourceStateWrapper::ordinal_ID = 0;
-jmethodID ResourceStateWrapper::toString_ID = 0;
-jmethodID ResourceStateWrapper::valueOf_ID = 0;
-jclass ResourceStateWrapper::clazz = 0;
-
-jobject ResourceStateWrapper::getALIVE(JNIEnv *env)
-{
-    return env->GetStaticObjectField(clazz, ALIVE_ID);
-}
-jobject ResourceStateWrapper::getREQUESTED(JNIEnv *env)
-{
-    return env->GetStaticObjectField(clazz, REQUESTED_ID);
-}
-jobject ResourceStateWrapper::getLOST_SIGNAL(JNIEnv *env)
-{
-    return env->GetStaticObjectField(clazz, LOST_SIGNAL_ID);
-}
-jobject ResourceStateWrapper::getDESTROYED(JNIEnv *env)
-{
-    return env->GetStaticObjectField(clazz, DESTROYED_ID);
-}
-jobject ResourceStateWrapper::getNONE(JNIEnv *env)
-{
-    return env->GetStaticObjectField(clazz, NONE_ID);
-}
-jint ResourceStateWrapper::ordinal(JNIEnv *env, jobject enumObj)
-{
-    return env->CallIntMethod(enumObj, ordinal_ID);
-}
-jstring ResourceStateWrapper::toString(JNIEnv *env, jobject enumObj)
-{
-    return reinterpret_cast<jstring>(env->CallObjectMethod(enumObj, toString_ID));
-}
-jobject ResourceStateWrapper::valueOf(JNIEnv *env, jstring enumName)
-{
-    return env->CallStaticObjectMethod(clazz, valueOf_ID, (jobject)enumName);
-}
-
-jobject convertNativeResourceStateToJavaResourceState(ResourceState nativeResourceState,
-        JNIEnv *env)
-{
-    LOGI("convertNativeResourceStateToJavaResourceState enter");
-
-    ResourceStateWrapper::ALIVE_ID = env->GetStaticFieldID(ResourceStateWrapper::clazz, "ALIVE",
-                   "Lorg/iotivity/ResourceEncapsulation/client/RCSRemoteResourceObject$ResourceState;");
-    ResourceStateWrapper::REQUESTED_ID = env->GetStaticFieldID(ResourceStateWrapper::clazz, "REQUESTED",
-                   "Lorg/iotivity/ResourceEncapsulation/client/RCSRemoteResourceObject$ResourceState;");
-    ResourceStateWrapper::LOST_SIGNAL_ID = env->GetStaticFieldID(ResourceStateWrapper::clazz,
-                    "LOST_SIGNAL", "Lorg/iotivity/ResourceEncapsulation/client/RCSRemoteResourceObject$ResourceState;");
-    ResourceStateWrapper::DESTROYED_ID = env->GetStaticFieldID(ResourceStateWrapper::clazz, "DESTROYED",
-                    "Lorg/iotivity/ResourceEncapsulation/client/RCSRemoteResourceObject$ResourceState;");
-    ResourceStateWrapper::NONE_ID = env->GetStaticFieldID(ResourceStateWrapper::clazz, "NONE",
-                    "Lorg/iotivity/ResourceEncapsulation/client/RCSRemoteResourceObject$ResourceState;");
-
-    ResourceStateWrapper::ordinal_ID = env->GetMethodID(ResourceStateWrapper::clazz, "ordinal", "()I");
-    ResourceStateWrapper::toString_ID = env->GetMethodID(ResourceStateWrapper::clazz, "toString",
-                                        "()Ljava/lang/String;");
-    ResourceStateWrapper::valueOf_ID = env->GetStaticMethodID(ResourceStateWrapper::clazz, "valueOf",
-                   "(Ljava/lang/String;)Lorg/iotivity/ResourceEncapsulation/client/RCSRemoteResourceObject$ResourceState;");
-
-    LOGI("convertNativeResourceStateToJavaResourceState ResourceStateWrapper::clazz == NULL first time");
-
-    switch (nativeResourceState)
-    {
-        case ResourceState::NONE:
-            return ResourceStateWrapper::getNONE(env);
-
-        case ResourceState::REQUESTED:
-            return ResourceStateWrapper::getREQUESTED(env);
-
-        case ResourceState::ALIVE:
-            return ResourceStateWrapper::getALIVE(env);
-
-        case ResourceState::LOST_SIGNAL:
-            return ResourceStateWrapper::getLOST_SIGNAL(env);
-
-        case ResourceState::DESTROYED:
-            return ResourceStateWrapper::getDESTROYED(env);
-    }
-}
-
-RCSResourceObject::AutoNotifyPolicy convertJavaNotifyPolicyToNativePolicy( int policy)
-{
-    switch (policy)
-    {
-        case 0:
-            return RCSResourceObject::AutoNotifyPolicy::NEVER;
-
-        case 1:
-            return RCSResourceObject::AutoNotifyPolicy::ALWAYS;
-
-        case 2:
-            return RCSResourceObject::AutoNotifyPolicy::UPDATED;
-    }
-}
-
-RCSResourceObject::SetRequestHandlerPolicy convertJavasetRequestHandlerPolicyToNativePolicy(
-    int policy)
-{
-    switch (policy)
-    {
-        case 0:
-            return RCSResourceObject::SetRequestHandlerPolicy::NEVER;
-
-        case 1:
-            return RCSResourceObject::SetRequestHandlerPolicy::ACCEPTANCE;
-    }
-}
-
-int convertAutoNotifyPolicyToInt(RCSResourceObject::AutoNotifyPolicy policy)
-{
-    switch (policy)
-    {
-        case RCSResourceObject::AutoNotifyPolicy::NEVER:
-            return 0;
-
-        case  RCSResourceObject::AutoNotifyPolicy::ALWAYS:
-            return 1;
-
-        case  RCSResourceObject::AutoNotifyPolicy::UPDATED:
-            return 2;
-    }
-    return 0;
-}
-
-int convertSetRequestHandlerPolicyToInt(RCSResourceObject::SetRequestHandlerPolicy policy)
-{
-    switch (policy)
-    {
-        case  RCSResourceObject::SetRequestHandlerPolicy::NEVER:
-            return 0;
-
-        case  RCSResourceObject::SetRequestHandlerPolicy::ACCEPTANCE:
-            return 1;
-    }
-    return 0;
-}
-
-void convertJavaMapToParamsMap(JNIEnv *env, jobject hashMap,
-                               std::map<std::string, std::string> &params)
-{
-    if (!hashMap)
-    {
-        return;
-    }
-
-    jobject jEntrySet = env->CallObjectMethod(hashMap, g_mid_Map_entrySet);
-    jobject jIterator = env->CallObjectMethod(jEntrySet, g_mid_Set_iterator);
-    if (!jEntrySet || !jIterator || env->ExceptionCheck())
-    {
-        return;
-    }
-
-    while (env->CallBooleanMethod(jIterator, g_mid_Iterator_hasNext))
-    {
-        jobject jEntry = env->CallObjectMethod(jIterator, g_mid_Iterator_next);
-        if (!jEntry) return;
-        jstring jKey = (jstring)env->CallObjectMethod(jEntry, g_mid_MapEntry_getKey);
-        if (!jKey) return;
-        jstring jValue = (jstring)env->CallObjectMethod(jEntry, g_mid_MapEntry_getValue);
-        if (!jValue) return;
-
-        params.insert(std::make_pair(env->GetStringUTFChars(jKey, NULL),
-                                     env->GetStringUTFChars(jValue, NULL)));
-
-        if (env->ExceptionCheck()) return;
-        env->DeleteLocalRef(jEntry);
-        env->DeleteLocalRef(jKey);
-        env->DeleteLocalRef(jValue);
-    }
-}
-
-jobject convertStrListToJavaStrList(JNIEnv *env, std::list<std::string> &nativeList)
-{
-    jobject jList = env->NewObject(g_cls_LinkedList, g_mid_LinkedList_ctor);
-    if (!jList) return nullptr;
-
-    for (std::list<std::string>::iterator it = nativeList.begin(); it != nativeList.end(); ++it)
-    {
-        jstring jStr = env->NewStringUTF((*it).c_str());
-        if (!jStr) return nullptr;
-        env->CallBooleanMethod(jList, g_mid_LinkedList_add_object, jStr);
-        if (env->ExceptionCheck()) return nullptr;
-        env->DeleteLocalRef(jStr);
-    }
-    return jList;
-}
-
-std::vector<int> covertJavaIntVectorToNativeVector(JNIEnv *env, jobject javaVector)
-{
-    std::vector<int> vectorInt;
-    LOGI("covertJavaIntVectorToNativeVector");
-
-    jint jSize = env->CallIntMethod(javaVector, g_mid_Vector_size);
-    int sizeOfVector = jSize;
-    int nativeValue;
-    jint jIndex;
-
-    for (int index = 0; index < sizeOfVector; index++)
-    {
-        jIndex = index;
-        jobject intValue = env->CallObjectMethod(javaVector, g_mid_Vector_get, jIndex);
-        nativeValue = env->CallIntMethod( intValue, g_mid_Integer_getInt);
-        vectorInt.push_back(nativeValue);
-    }
-    return vectorInt;
-}
-
-std::vector<std::vector<int>> convertJavaVectorOfVectorOfIntToNativeVector(JNIEnv *env,
-                           jobject javaVector)
-{
-    std::vector<std::vector<int>> vectorInt;
-    LOGI("covertJavaIntVectorToNativeVector");
-
-    jint jSizeOne = env->CallIntMethod(javaVector, g_mid_Vector_size);
-    int sizeOfVectorOne = jSizeOne;
-    int nativeValue;
-    jint jIndex1;
-    jint jIndex2;
-
-    for (int index1 = 0; index1 < sizeOfVectorOne; index1++)
-    {
-        jIndex1 = index1;
-
-        jobject vectorTwoObj = env->CallObjectMethod(javaVector, g_mid_Vector_get, jIndex1);
-
-        jint jSizeTwo = env->CallIntMethod(vectorTwoObj, g_mid_Vector_size);
-        int sizeOfVectorTwo = jSizeTwo;
-        std::vector<int> vectorTwo;
-        for (int index2 = 0; index2 < sizeOfVectorTwo; index2++)
-        {
-            jIndex2 = index2;
-            jobject intValue = env->CallObjectMethod(vectorTwoObj, g_mid_Vector_get, jIndex2);
-            nativeValue = env->CallIntMethod( intValue, g_mid_Integer_getInt);
-            vectorTwo.push_back(nativeValue);
-        }
-        vectorInt.push_back(vectorTwo);
-    }
-    return vectorInt;
-}
-
-std::vector<std::vector<std::vector<int>>> convertJavaVectorOfVectorOfVectorOfIntToNativeVector(
-    JNIEnv *env, jobject javaVector)
-{
-    std::vector<std::vector<std::vector<int>>> vectorInt;
-    LOGI("convertJavaVectorOfVectorOfVectorOfIntToNativeVector");
-
-    jint jSizeOne = env->CallIntMethod(javaVector, g_mid_Vector_size);
-    int sizeOfVectorOne = jSizeOne;
-    int nativeValue;
-    jint jIndex1;
-    jint jIndex2;
-    jint jIndex3;
-
-    for (int index1 = 0; index1 < sizeOfVectorOne; index1++)
-    {
-        jIndex1 = index1;
-
-        jobject vectorTwoObj = env->CallObjectMethod(javaVector, g_mid_Vector_get, jIndex1);
-
-        jint jSizeTwo = env->CallIntMethod(vectorTwoObj, g_mid_Vector_size);
-        int sizeOfVectorTwo = jSizeTwo;
-        std::vector<std::vector<int>> vectorTwo;
-        for (int index2 = 0; index2 < sizeOfVectorTwo; index2++)
-        {
-            jIndex2 = index2;
-
-            jobject vectorThreeObj = env->CallObjectMethod(vectorTwoObj, g_mid_Vector_get, jIndex2);
-
-            jint jSizeThree = env->CallIntMethod(vectorThreeObj, g_mid_Vector_size);
-            int sizeOfVectorThree = jSizeThree;
-            std::vector<int> vectorThree;
-            for (int index3 = 0; index3 < sizeOfVectorTwo; index3++)
-            {
-                jIndex3 = index3;
-                jobject intValue = env->CallObjectMethod(vectorThreeObj, g_mid_Vector_get, jIndex3);
-                nativeValue = env->CallIntMethod( intValue, g_mid_Integer_getInt);
-                vectorThree.push_back(nativeValue);
-            }
-            vectorTwo.push_back(vectorThree);
-        }
-        vectorInt.push_back(vectorTwo);
-    }
-    return vectorInt;
-}
-
-jobject convertNativeIntVectorToJavaVector(JNIEnv *env, std::vector<int> &nativeVector)
-{
-    LOGI("convertNativeIntVectorToJavaVector");
-    jobject javaVector = env->NewObject(g_cls_Vector, g_mid_Vector_ctor);
-
-    if (!javaVector) return nullptr;
-
-    for (std::vector<int>::iterator it = nativeVector.begin(); it != nativeVector.end(); ++it)
-    {
-        jint jInt = (jint)(*it);
-        jobject value = env->NewObject(g_cls_Integer, g_mid_Integer_ctor, jInt);
-        env->CallBooleanMethod(javaVector, g_mid_Vector_add, value);
-    }
-    return javaVector;
-}
-
-jobject convertNativeVectorOfVectorOfIntToJavaVector(JNIEnv *env,
-        std::vector<std::vector<int>> &nativeVector)
-{
-    LOGI("convertNativeVectorOfVectorOfIntToJavaVector");
-    jobject javaVector1 = env->NewObject(g_cls_Vector, g_mid_Vector_ctor);
-
-    if (!javaVector1) return nullptr;
-
-    std::vector<std::vector<int>>::iterator firstIt;
-    std::vector<int>::iterator secondIt;
-
-    jobject javaVector2 = env->NewObject(g_cls_Vector, g_mid_Vector_ctor);
-
-    for (firstIt = nativeVector.begin(); firstIt != nativeVector.end(); firstIt++)
-    {
-        jobject javaVector1 = env->NewObject(g_cls_Vector, g_mid_Vector_ctor);
-        for (secondIt = firstIt->begin(); secondIt != firstIt->end(); secondIt++)
-        {
-            jint jInt = (jint)(*secondIt);
-            jobject value = env->NewObject(g_cls_Integer, g_mid_Integer_ctor, jInt);
-            env->CallBooleanMethod(javaVector1, g_mid_Vector_add, value);
-        }
-        env->CallBooleanMethod(javaVector2, g_mid_Vector_add, javaVector1);
-    }
-    return javaVector2;
-}
-
-jobject convertNativeVectorOfVectorOfVectorOfIntToJavaVector(JNIEnv *env,
-        std::vector<std::vector<std::vector<int>>> &nativeVector)
-{
-
-    LOGI("convertNativeVectorOfVectorOfVectorOfIntToJavaVector");
-    jobject javaVector1 = env->NewObject(g_cls_Vector, g_mid_Vector_ctor);
-
-    std::vector<std::vector<std::vector<int>>>::iterator firstIt;
-    std::vector<std::vector<int>>::iterator secondIt;
-    std::vector<int>::iterator thirdIt;
-
-    jobject javaVector3 = env->NewObject(g_cls_Vector, g_mid_Vector_ctor);
-
-    for (firstIt = nativeVector.begin(); firstIt != nativeVector.end(); firstIt++)
-    {
-        jobject javaVector1 = env->NewObject(g_cls_Vector, g_mid_Vector_ctor);
-        for (secondIt = firstIt->begin(); secondIt != firstIt->end(); secondIt++)
-        {
-            jobject javaVector2 = env->NewObject(g_cls_Vector, g_mid_Vector_ctor);
-            for (thirdIt = secondIt->begin(); thirdIt != secondIt->end(); thirdIt++)
-            {
-                jint jInt = (jint)(*thirdIt);
-                jobject value = env->NewObject(g_cls_Integer, g_mid_Integer_ctor, jInt);
-                env->CallBooleanMethod(javaVector2, g_mid_Vector_add, value);
-            }
-            env->CallBooleanMethod(javaVector1, g_mid_Vector_add, javaVector2);
-        }
-        env->CallBooleanMethod(javaVector3, g_mid_Vector_add, javaVector1);
-    }
-    return javaVector3;
-}
-
-
-//double
-std::vector<double> covertJavaDoubleVectorToNativeVector(JNIEnv *env, jobject javaVector)
-{
-    std::vector<double> vectorDouble;
-    LOGI("covertJavaDoubleVectorToNativeVector");
-
-    jint jSize = env->CallIntMethod(javaVector, g_mid_Vector_size);
-    int sizeOfVector = jSize;
-    double nativeValue;
-    jint jIndex;
-
-    for (int index = 0; index < sizeOfVector; index++)
-    {
-        jIndex = index;
-        jobject doubleValue = env->CallObjectMethod(javaVector, g_mid_Vector_get, jIndex);
-        nativeValue = env->CallDoubleMethod( doubleValue, g_mid_Double_getDouble);
-
-        vectorDouble.push_back(nativeValue);
-    }
-    return vectorDouble;
-}
-
-std::vector<std::vector<double>> convertJavaVectorOfVectorOfDoubleToNativeVector(JNIEnv *env,
-                              jobject javaVector)
-{
-
-    std::vector<std::vector<double>> vectorDouble;
-    LOGI("convertJavaVectorOfVectorOfDoubleToNativeVector");
-
-    jint jSizeOne = env->CallIntMethod(javaVector, g_mid_Vector_size);
-    int sizeOfVectorOne = jSizeOne;
-    double nativeValue;
-    jint jIndex1;
-    jint jIndex2;
-
-    for (int index1 = 0; index1 < sizeOfVectorOne; index1++)
-    {
-        jIndex1 = index1;
-
-        jobject vectorTwoObj = env->CallObjectMethod(javaVector, g_mid_Vector_get, jIndex1);
-
-        jint jSizeTwo = env->CallIntMethod(vectorTwoObj, g_mid_Vector_size);
-        int sizeOfVectorTwo = jSizeTwo;
-        std::vector<double> vectorTwo;
-        for (int index2 = 0; index2 < sizeOfVectorTwo; index2++)
-        {
-            jIndex2 = index2;
-            jobject doubleValue = env->CallObjectMethod(vectorTwoObj, g_mid_Vector_get, jIndex2);
-            nativeValue = env->CallDoubleMethod( doubleValue, g_mid_Double_getDouble);
-            vectorTwo.push_back(nativeValue);
-        }
-        vectorDouble.push_back(vectorTwo);
-    }
-    return vectorDouble;
-}
-
-std::vector<std::vector<std::vector<double>>>
-convertJavaVectorOfVectorOfVectorOfDoubleToNativeVector(JNIEnv *env, jobject javaVector)
-{
-
-    std::vector<std::vector<std::vector<double>>> vectorDouble;
-    LOGI("convertJavaVectorOfVectorOfVectorOfDoubleToNativeVector");
-
-    jint jSizeOne = env->CallIntMethod(javaVector, g_mid_Vector_size);
-    int sizeOfVectorOne = jSizeOne;
-    double nativeValue;
-    jint jIndex1;
-    jint jIndex2;
-    jint jIndex3;
-
-    for (int index1 = 0; index1 < sizeOfVectorOne; index1++)
-    {
-        jIndex1 = index1;
-
-        jobject vectorTwoObj = env->CallObjectMethod(javaVector, g_mid_Vector_get, jIndex1);
-
-        jint jSizeTwo = env->CallIntMethod(vectorTwoObj, g_mid_Vector_size);
-        int sizeOfVectorTwo = jSizeTwo;
-        std::vector<std::vector<double>> vectorTwo;
-        for (int index2 = 0; index2 < sizeOfVectorTwo; index2++)
-        {
-            jIndex2 = index2;
-
-            jobject vectorThreeObj = env->CallObjectMethod(vectorTwoObj, g_mid_Vector_get, jIndex2);
-
-            jint jSizeThree = env->CallIntMethod(vectorThreeObj, g_mid_Vector_size);
-            int sizeOfVectorThree = jSizeThree;
-            std::vector<double> vectorThree;
-            for (int index3 = 0; index3 < sizeOfVectorTwo; index3++)
-            {
-                jIndex3 = index3;
-
-                jobject doubleValue = env->CallObjectMethod(vectorThreeObj, g_mid_Vector_get, jIndex3);
-                nativeValue = env->CallDoubleMethod( doubleValue, g_mid_Double_getDouble);
-
-                vectorThree.push_back(nativeValue);
-            }
-            vectorTwo.push_back(vectorThree);
-        }
-        vectorDouble.push_back(vectorTwo);
-    }
-    return vectorDouble;
-}
-
-jobject convertNativeDoubleVectorToJavaVector(JNIEnv *env, std::vector<double> &nativeVector)
-{
-    LOGI("convertNativeIntVectorToJavaVector");
-    jobject javaVector = env->NewObject(g_cls_Vector, g_mid_Vector_ctor);
-    if (!javaVector) return nullptr;
-
-    for (std::vector<double>::iterator it = nativeVector.begin(); it != nativeVector.end(); ++it)
-    {
-        jdouble jDouble = (jdouble)(*it);
-        jobject value = env->NewObject(g_cls_Double, g_mid_Double_ctor, jDouble);
-        env->CallBooleanMethod(javaVector, g_mid_Vector_add, value);
-    }
-    return javaVector;
-}
-
-jobject convertNativeVectorOfVectorOfDoubleToJavaVector(JNIEnv *env,
-        std::vector<std::vector<double>> &nativeVector)
-{
-    LOGI("convertNativeVectorOfVectorOfIntToJavaVector");
-
-    jobject javaVector1 = env->NewObject(g_cls_Vector, g_mid_Vector_ctor);
-    if (!javaVector1) return nullptr;
-
-    std::vector<std::vector<double>>::iterator firstIt;
-    std::vector<double>::iterator secondIt;
-
-    jobject javaVector2 = env->NewObject(g_cls_Vector, g_mid_Vector_ctor);
-
-    for (firstIt = nativeVector.begin(); firstIt != nativeVector.end(); firstIt++)
-    {
-        jobject javaVector1 = env->NewObject(g_cls_Vector, g_mid_Vector_ctor);
-        for (secondIt = firstIt->begin(); secondIt != firstIt->end(); secondIt++)
-        {
-            jdouble jDouble = (jdouble)(*secondIt);
-            jobject value = env->NewObject(g_cls_Double, g_mid_Double_ctor, jDouble);
-            env->CallBooleanMethod(javaVector1, g_mid_Vector_add, value);
-        }
-        env->CallBooleanMethod(javaVector2, g_mid_Vector_add, javaVector1);
-    }
-    return javaVector2;
-}
-
-jobject convertNativeVectorOfVectorOfVectorOfDoubleToJavaVector(JNIEnv *env,
-        std::vector<std::vector<std::vector<double>>> &nativeVector)
-{
-    LOGI("convertNativeVectorOfVectorOfVectorOfDoubleToJavaVector");
-    jobject javaVector1 = env->NewObject(g_cls_Vector, g_mid_Vector_ctor);
-
-    std::vector<std::vector<std::vector<double>>>::iterator firstIt;
-    std::vector<std::vector<double>>::iterator secondIt;
-    std::vector<double>::iterator thirdIt;
-
-    jobject javaVector3 = env->NewObject(g_cls_Vector, g_mid_Vector_ctor);
-
-    for (firstIt = nativeVector.begin(); firstIt != nativeVector.end(); firstIt++)
-    {
-        jobject javaVector1 = env->NewObject(g_cls_Vector, g_mid_Vector_ctor);
-        for (secondIt = firstIt->begin(); secondIt != firstIt->end(); secondIt++)
-        {
-            jobject javaVector2 = env->NewObject(g_cls_Vector, g_mid_Vector_ctor);
-            for (thirdIt = secondIt->begin(); thirdIt != secondIt->end(); thirdIt++)
-            {
-                jdouble jDouble = (jdouble)(*thirdIt);
-                jobject value = env->NewObject(g_cls_Double, g_mid_Double_ctor, jDouble);
-                env->CallBooleanMethod(javaVector2, g_mid_Vector_add, value);
-            }
-            env->CallBooleanMethod(javaVector1, g_mid_Vector_add, javaVector2);
-        }
-        env->CallBooleanMethod(javaVector3, g_mid_Vector_add, javaVector1);
-    }
-    return javaVector3;
-}
-
-//booean
-std::vector<bool> covertJavaBooleanVectorToNativeVector(JNIEnv *env, jobject javaVector)
-{
-    std::vector<bool> vectorBoolean;
-    LOGI("covertJavaBooleanVectorToNativeVector");
-
-    jint jSize = env->CallIntMethod(javaVector, g_mid_Vector_size);
-    int sizeOfVector = jSize;
-    bool nativeValue;
-    jint jIndex;
-
-    for (int index = 0; index < sizeOfVector; index++)
-    {
-        jIndex = index;
-        jobject boolValue = env->CallObjectMethod(javaVector, g_mid_Vector_get, jIndex);
-        nativeValue = env->CallBooleanMethod( boolValue, g_mid_Boolean_getBoolean);
-        vectorBoolean.push_back(nativeValue);
-    }
-    return vectorBoolean;
-}
-
-std::vector<std::vector<bool>> convertJavaVectorOfVectorOfBooleanToNativeVector(JNIEnv *env,
-                            jobject javaVector)
-{
-    std::vector<std::vector<bool>> vectorBoolean;
-    LOGI("convertJavaVectorOfVectorOfBooleanToNativeVector");
-
-    jint jSizeOne = env->CallIntMethod(javaVector, g_mid_Vector_size);
-    int sizeOfVectorOne = jSizeOne;
-    bool nativeValue;
-    jint jIndex1;
-    jint jIndex2;
-
-    for (int index1 = 0; index1 < sizeOfVectorOne; index1++)
-    {
-        jIndex1 = index1;
-
-        jobject vectorTwoObj = env->CallObjectMethod(javaVector, g_mid_Vector_get, jIndex1);
-
-        jint jSizeTwo = env->CallIntMethod(vectorTwoObj, g_mid_Vector_size);
-        int sizeOfVectorTwo = jSizeTwo;
-        std::vector<bool> vectorTwo;
-        for (int index2 = 0; index2 < sizeOfVectorTwo; index2++)
-        {
-            jIndex2 = index2;
-            jobject boolValue = env->CallObjectMethod(vectorTwoObj, g_mid_Vector_get, jIndex2);
-            nativeValue = env->CallBooleanMethod( boolValue, g_mid_Boolean_getBoolean);
-            vectorTwo.push_back(nativeValue);
-        }
-        vectorBoolean.push_back(vectorTwo);
-    }
-    return vectorBoolean;
-}
-
-std::vector<std::vector<std::vector<bool>>>
-convertJavaVectorOfVectorOfVectorOfBooleanToNativeVector(JNIEnv *env, jobject javaVector)
-{
-    std::vector<std::vector<std::vector<bool>>> vectorBoolean;
-    LOGI("convertJavaVectorOfVectorOfVectorOfDoubleToNativeVector");
-
-    jint jSizeOne = env->CallIntMethod(javaVector, g_mid_Vector_size);
-    int sizeOfVectorOne = jSizeOne;
-    bool nativeValue;
-    jint jIndex1;
-    jint jIndex2;
-    jint jIndex3;
-
-    for (int index1 = 0; index1 < sizeOfVectorOne; index1++)
-    {
-        jIndex1 = index1;
-
-        jobject vectorTwoObj = env->CallObjectMethod(javaVector, g_mid_Vector_get, jIndex1);
-
-        jint jSizeTwo = env->CallIntMethod(vectorTwoObj, g_mid_Vector_size);
-        int sizeOfVectorTwo = jSizeTwo;
-        std::vector<std::vector<bool>> vectorTwo;
-        for (int index2 = 0; index2 < sizeOfVectorTwo; index2++)
-        {
-            jIndex2 = index2;
-
-            jobject vectorThreeObj = env->CallObjectMethod(vectorTwoObj, g_mid_Vector_get, jIndex2);
-
-            jint jSizeThree = env->CallIntMethod(vectorThreeObj, g_mid_Vector_size);
-            int sizeOfVectorThree = jSizeThree;
-            std::vector<bool> vectorThree;
-            for (int index3 = 0; index3 < sizeOfVectorTwo; index3++)
-            {
-                jIndex3 = index3;
-
-                jobject boolValue = env->CallObjectMethod(vectorThreeObj, g_mid_Vector_get, jIndex3);
-                nativeValue = env->CallBooleanMethod( boolValue, g_mid_Boolean_getBoolean);
-
-                vectorThree.push_back(nativeValue);
-            }
-            vectorTwo.push_back(vectorThree);
-        }
-        vectorBoolean.push_back(vectorTwo);
-    }
-    return vectorBoolean;
-}
-
-jobject convertNativeBooleanVectorToJavaVector(JNIEnv *env, std::vector<bool> &nativeVector)
-{
-    LOGI("convertNativeBooleanVectorToJavaVector");
-
-    jobject javaVector = env->NewObject(g_cls_Vector, g_mid_Vector_ctor);
-    if (!javaVector) return nullptr;
-
-    for (std::vector<bool>::iterator it = nativeVector.begin(); it != nativeVector.end(); ++it)
-    {
-        jboolean jBoolean = (jboolean)(*it);
-        jobject value = env->NewObject(g_cls_Boolean, g_mid_Boolean_ctor, jBoolean);
-        env->CallBooleanMethod(javaVector, g_mid_Vector_add, value);
-    }
-    return javaVector;
-}
-
-jobject convertNativeVectorOfVectorOfBooleanToJavaVector(JNIEnv *env,
-        std::vector<std::vector<bool>> &nativeVector)
-{
-    LOGI("convertNativeVectorOfVectorOfBooleanToJavaVector");
-
-    jobject javaVector1 = env->NewObject(g_cls_Vector, g_mid_Vector_ctor);
-    if (!javaVector1) return nullptr;
-
-    std::vector<std::vector<bool>>::iterator firstIt;
-    std::vector<bool>::iterator secondIt;
-
-    jobject javaVector2 = env->NewObject(g_cls_Vector, g_mid_Vector_ctor);
-
-    for (firstIt = nativeVector.begin(); firstIt != nativeVector.end(); firstIt++)
-    {
-        jobject javaVector1 = env->NewObject(g_cls_Vector, g_mid_Vector_ctor);
-        for (secondIt = firstIt->begin(); secondIt != firstIt->end(); secondIt++)
-        {
-            jboolean jBoolean = (jboolean)(*secondIt);
-            jobject value = env->NewObject(g_cls_Boolean, g_mid_Boolean_ctor, jBoolean);
-            env->CallBooleanMethod(javaVector1, g_mid_Vector_add, value);
-        }
-        env->CallBooleanMethod(javaVector2, g_mid_Vector_add, javaVector1);
-    }
-    return javaVector2;
-}
-
-jobject convertNativeVectorOfVectorOfVectorOfBooleanToJavaVector(JNIEnv *env,
-        std::vector<std::vector<std::vector<bool>>> &nativeVector)
-{
-    LOGI("convertNativeVectorOfVectorOfVectorOfBooleanToJavaVector");
-    jobject javaVector1 = env->NewObject(g_cls_Vector, g_mid_Vector_ctor);
-
-    std::vector<std::vector<std::vector<bool>>>::iterator firstIt;
-    std::vector<std::vector<bool>>::iterator secondIt;
-    std::vector<bool>::iterator thirdIt;
-
-    jobject javaVector3 = env->NewObject(g_cls_Vector, g_mid_Vector_ctor);
-
-    for (firstIt = nativeVector.begin(); firstIt != nativeVector.end(); firstIt++)
-    {
-        jobject javaVector1 = env->NewObject(g_cls_Vector, g_mid_Vector_ctor);
-        for (secondIt = firstIt->begin(); secondIt != firstIt->end(); secondIt++)
-        {
-            jobject javaVector2 = env->NewObject(g_cls_Vector, g_mid_Vector_ctor);
-            for (thirdIt = secondIt->begin(); thirdIt != secondIt->end(); thirdIt++)
-            {
-                jboolean jBoolean = (jboolean)(*thirdIt);
-                jobject value = env->NewObject(g_cls_Boolean, g_mid_Boolean_ctor, jBoolean);
-                env->CallBooleanMethod(javaVector2, g_mid_Vector_add, value);
-            }
-            env->CallBooleanMethod(javaVector1, g_mid_Vector_add, javaVector2);
-        }
-        env->CallBooleanMethod(javaVector3, g_mid_Vector_add, javaVector1);
-    }
-    return javaVector3;
-}
-
-//String
-std::vector<std::string> covertJavaStringVectorToNativeVector(JNIEnv *env, jobject javaVector)
-{
-    std::vector<std::string> vectorString;
-    LOGI("covertJavaBooleanVectorToNativeVector");
-
-    jint jSize = env->CallIntMethod(javaVector, g_mid_Vector_size);
-    int sizeOfVector = jSize;
-    std::string nativeValue;
-    jint jIndex;
-
-    for (int index = 0; index < sizeOfVector; index++)
-    {
-        jIndex = index;
-        jstring StringValue = (jstring)env->CallObjectMethod(javaVector, g_mid_Vector_get, jIndex);
-        nativeValue = env->GetStringUTFChars(StringValue, NULL);
-        vectorString.push_back(nativeValue);
-    }
-    return vectorString;
-}
-
-std::vector<std::vector<std::string>> convertJavaVectorOfVectorOfStringToNativeVector(JNIEnv *env,
-                                   jobject javaVector)
-{
-    std::vector<std::vector<std::string>> vectorString;
-    LOGI("convertJavaVectorOfVectorOfBooleanToNativeVector");
-
-    jint jSizeOne = env->CallIntMethod(javaVector, g_mid_Vector_size);
-    int sizeOfVectorOne = jSizeOne;
-    std::string nativeValue;
-    jint jIndex1;
-    jint jIndex2;
-
-    for (int index1 = 0; index1 < sizeOfVectorOne; index1++)
-    {
-        jIndex1 = index1;
-
-        jobject vectorTwoObj = env->CallObjectMethod(javaVector, g_mid_Vector_get, jIndex1);
-
-        jint jSizeTwo = env->CallIntMethod(vectorTwoObj, g_mid_Vector_size);
-        int sizeOfVectorTwo = jSizeTwo;
-        std::vector<std::string> vectorTwo;
-        for (int index2 = 0; index2 < sizeOfVectorTwo; index2++)
-        {
-            jIndex2 = index2;
-            jstring StringValue = (jstring)env->CallObjectMethod(vectorTwoObj, g_mid_Vector_get, jIndex2);
-            nativeValue = env->GetStringUTFChars(StringValue, NULL);
-            vectorTwo.push_back(nativeValue);
-        }
-        vectorString.push_back(vectorTwo);
-    }
-    return vectorString;
-}
-
-std::vector<std::vector<std::vector<std::string>>>
-convertJavaVectorOfVectorOfVectorOfStringToNativeVector(JNIEnv *env, jobject javaVector)
-{
-    std::vector<std::vector<std::vector<std::string>>> vectorString;
-    LOGI("convertJavaVectorOfVectorOfVectorOfDoubleToNativeVector");
-
-    jint jSizeOne = env->CallIntMethod(javaVector, g_mid_Vector_size);
-    int sizeOfVectorOne = jSizeOne;
-    std::string nativeValue;
-    jint jIndex1;
-    jint jIndex2;
-    jint jIndex3;
-
-    for (int index1 = 0; index1 < sizeOfVectorOne; index1++)
-    {
-        jIndex1 = index1;
-        jobject vectorTwoObj = env->CallObjectMethod(javaVector, g_mid_Vector_get, jIndex1);
-        jint jSizeTwo = env->CallIntMethod(vectorTwoObj, g_mid_Vector_size);
-        int sizeOfVectorTwo = jSizeTwo;
-        std::vector<std::vector<std::string>> vectorTwo;
-        for (int index2 = 0; index2 < sizeOfVectorTwo; index2++)
-        {
-            jIndex2 = index2;
-
-            jobject vectorThreeObj = env->CallObjectMethod(vectorTwoObj, g_mid_Vector_get, jIndex2);
-
-            jint jSizeThree = env->CallIntMethod(vectorThreeObj, g_mid_Vector_size);
-            int sizeOfVectorThree = jSizeThree;
-            std::vector<std::string> vectorThree;
-            for (int index3 = 0; index3 < sizeOfVectorTwo; index3++)
-            {
-                jIndex3 = index3;
-
-                jstring StringValue = (jstring)env->CallObjectMethod(vectorThreeObj, g_mid_Vector_get, jIndex3);
-                nativeValue = env->GetStringUTFChars(StringValue, NULL);
-
-                vectorThree.push_back(nativeValue);
-            }
-            vectorTwo.push_back(vectorThree);
-        }
-        vectorString.push_back(vectorTwo);
-    }
-    return vectorString;
-}
-
-jobject convertNativeStringVectorToJavaVector(JNIEnv *env, std::vector<std::string> &nativeVector)
-{
-    LOGI("convertNativeStringVectorToJavaVector");
-
-    jobject javaVector = env->NewObject(g_cls_Vector, g_mid_Vector_ctor);
-    if (!javaVector) return nullptr;
-
-    for (std::vector<std::string>::iterator it = nativeVector.begin(); it != nativeVector.end(); ++it)
-    {
-        env->CallBooleanMethod(javaVector, g_mid_Vector_add, env -> NewStringUTF((*it).c_str()));
-    }
-    return javaVector;
-}
-
-jobject convertNativeVectorOfVectorOfStringToJavaVector(JNIEnv *env,
-        std::vector<std::vector<std::string>> &nativeVector)
-{
-    LOGI("convertNativeVectorOfVectorOfBooleanToJavaVector");
-
-    jobject javaVector1 = env->NewObject(g_cls_Vector, g_mid_Vector_ctor);
-    if (!javaVector1) return nullptr;
-
-    std::vector<std::vector<std::string>>::iterator firstIt;
-    std::vector<std::string>::iterator secondIt;
-
-    jobject javaVector2 = env->NewObject(g_cls_Vector, g_mid_Vector_ctor);
-
-    for (firstIt = nativeVector.begin(); firstIt != nativeVector.end(); firstIt++)
-    {
-        jobject javaVector1 = env->NewObject(g_cls_Vector, g_mid_Vector_ctor);
-        for (secondIt = firstIt->begin(); secondIt != firstIt->end(); secondIt++)
-        {
-            env->CallBooleanMethod(javaVector1, g_mid_Vector_add, env -> NewStringUTF((*secondIt).c_str()));
-        }
-        env->CallBooleanMethod(javaVector2, g_mid_Vector_add, javaVector1);
-    }
-    return javaVector2;
-}
-
-jobject convertNativeVectorOfVectorOfVectorOfStringToJavaVector(JNIEnv *env,
-        std::vector<std::vector<std::vector<std::string>>> &nativeVector)
-{
-    LOGI("convertNativeVectorOfVectorOfVectorOfStringToJavaVector");
-    jobject javaVector1 = env->NewObject(g_cls_Vector, g_mid_Vector_ctor);
-
-    std::vector<std::vector<std::vector<std::string>>>::iterator firstIt;
-    std::vector<std::vector<std::string>>::iterator secondIt;
-    std::vector<std::string>::iterator thirdIt;
-
-    jobject javaVector3 = env->NewObject(g_cls_Vector, g_mid_Vector_ctor);
-
-    for (firstIt = nativeVector.begin(); firstIt != nativeVector.end(); firstIt++)
-    {
-        jobject javaVector1 = env->NewObject(g_cls_Vector, g_mid_Vector_ctor);
-        for (secondIt = firstIt->begin(); secondIt != firstIt->end(); secondIt++)
-        {
-            jobject javaVector2 = env->NewObject(g_cls_Vector, g_mid_Vector_ctor);
-            for (thirdIt = secondIt->begin(); thirdIt != secondIt->end(); thirdIt++)
-            {
-                env->CallBooleanMethod(javaVector2, g_mid_Vector_add, env -> NewStringUTF((*thirdIt).c_str()));
-            }
-            env->CallBooleanMethod(javaVector1, g_mid_Vector_add, javaVector2);
-        }
-        env->CallBooleanMethod(javaVector3, g_mid_Vector_add, javaVector1);
-    }
-    return javaVector3;
-}
\ No newline at end of file
diff --git a/service/resource-encapsulation/sdk/java/jni/re/include/jni_re_attribute_updated_listener.h b/service/resource-encapsulation/sdk/java/jni/re/include/jni_re_attribute_updated_listener.h
deleted file mode 100644 (file)
index 174b2ff..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/******************************************************************
- *
- * 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.
- *
- ******************************************************************/
-
-/** @file   jni_re_attribute_updated_listener.h
- *
- *   @brief  This file contains JNI attribute update Listener class
- */
-
-#ifndef __JNI_RE_ATTRIBUTE_UPDATED_LISTENER_H_
-#define __JNI_RE_ATTRIBUTE_UPDATED_LISTENER_H_
-
-#include <jni.h>
-
-#include "jni_re_jvm.h"
-#include "jni_re_utils.h"
-#include "jni_re_resource_attributes.h"
-
-
-class JniRCSResourceObject;
-
-/**
- * @class   JniAttributeUpdatedListener
- * @brief   This class provides functions for handling the attribute updated callback between the Java and Native layer
- *
- */
-class JniAttributeUpdatedListener
-{
-    public:
-        /**
-         * @brief constructor
-         */
-        JniAttributeUpdatedListener(JNIEnv *env, jobject jListener,
-                                    JniRCSResourceObject *resource);
-
-        /**
-         * @brief destructor
-        */
-        ~JniAttributeUpdatedListener();
-
-        /**
-         * @brief callback function that will be passed to Native layer
-        */
-        void onAttributeUpdatedCallback(OIC::Service::RCSResourceAttributes::Value oldValue,
-                                        OIC::Service::RCSResourceAttributes::Value newValue);
-
-    private:
-        jweak m_jwListener;
-        JniRCSResourceObject *m_ownerResource;
-        void checkExAndRemoveListener(JNIEnv *env);
-};
-
-#endif //__JNI_RE_ATTRIBUTE_UPDATED_LISTENER_H_
\ No newline at end of file
diff --git a/service/resource-encapsulation/sdk/java/jni/re/include/jni_re_cache_update_listener.h b/service/resource-encapsulation/sdk/java/jni/re/include/jni_re_cache_update_listener.h
deleted file mode 100644 (file)
index 215ca32..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/******************************************************************
- *
- * 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.
- *
- ******************************************************************/
-
-/** @file   jni_re_cache_update_listener.h
- *
- *   @brief  This file contains JNI CacheUpdate Listener class
- */
-
-#ifndef __JNI_RE_CACHE_UPDATE_LISTENER_H_
-#define __JNI_RE_CACHE_UPDATE_LISTENER_H_
-
-#include <jni.h>
-
-#include "RCSRemoteResourceObject.h"
-
-#include "jni_re_jvm.h"
-#include "jni_re_rcs_remoteresourceobject.h"
-
-/**
- * @class   JniCacheUpdateListener
- * @brief   This class provides functions for handling the CacheUpdate Callback between the Java and Native layer
- *
- */
-class JniCacheUpdateListener
-{
-    public:
-        /**
-         * @brief constructor
-         */
-        JniCacheUpdateListener(JNIEnv *env, jobject jListener, JniRCSRemoteResourceObject *resource);
-
-        /**
-         * @brief destructor
-         */
-        ~JniCacheUpdateListener();
-
-        /**
-         * @brief callback function that will be passed to Native layer
-         */
-        void cacheUpdatedCallback(OIC::Service::RCSResourceAttributes attributes);
-
-    private:
-        jweak m_jwListener;
-        JniRCSRemoteResourceObject *m_ownerResource;
-        void checkExAndRemoveListener(JNIEnv *env);
-};
-#endif //__JNI_RE_CACHE_UPDATE_LISTENER_H_
diff --git a/service/resource-encapsulation/sdk/java/jni/re/include/jni_re_discover_resource_listener.h b/service/resource-encapsulation/sdk/java/jni/re/include/jni_re_discover_resource_listener.h
deleted file mode 100644 (file)
index bcc2a05..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/******************************************************************
- *
- * 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.
- *
- ******************************************************************/
-
-/** @file   jni_re_discover_resource_listener.h
- *
- *   @brief  This file contains JNI Discover Resource Listener class
- */
-
-#ifndef __JNI_RE_DISCOVER_RESOURCE_LISTENER_H_
-#define __JNI_RE_DISCOVER_RESOURCE_LISTENER_H_
-
-#include <jni.h>
-
-#include "RCSRemoteResourceObject.h"
-
-#include "jni_re_jvm.h"
-#include "jni_re_rcs_remoteresourceobject.h"
-
-typedef void(*RemoveListenerCallback)(JNIEnv *env, jobject jListener);
-
-class RCSRemoteResourceObject;
-
-/**
- * @class   JniDiscoverResourceListener
- * @brief   This class provides functions for handling the Discover Resource Callback between the Java and Native layer
- *
- */
-class JniDiscoverResourceListener
-{
-    public:
-        /**
-         * @brief constructor
-         */
-        JniDiscoverResourceListener(JNIEnv *env, jobject jListener,
-                                    RemoveListenerCallback removeListenerCallback);
-
-        /**
-         * @brief destructor
-         */
-        ~JniDiscoverResourceListener();
-
-        /**
-         * @brief callback function that will be passed to Native layer
-         */
-        void discoverResourceCallback(std::shared_ptr<OIC::Service::RCSRemoteResourceObject> resource);
-
-    private:
-        RemoveListenerCallback m_removeListenerCallback;
-        jweak m_jwListener;
-        void checkExAndRemoveListener(JNIEnv *env);
-};
-#endif //__JNI_RE_DISCOVER_RESOURCE_LISTENER_H_
diff --git a/service/resource-encapsulation/sdk/java/jni/re/include/jni_re_get_request_listener.h b/service/resource-encapsulation/sdk/java/jni/re/include/jni_re_get_request_listener.h
deleted file mode 100644 (file)
index 867d9ac..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/******************************************************************
- *
- * 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.
- *
- ******************************************************************/
-
-/** @file   jni_re_get_request_listener.h
- *
- *   @brief  This file contains JNI get request Listener class
- */
-
-#ifndef __JNI_RE_GET_REQUEST_LISTENER_H_
-#define __JNI_RE_GET_REQUEST_LISTENER_H_
-
-#include <jni.h>
-
-#include "jni_re_jvm.h"
-#include "jni_re_utils.h"
-#include "jni_re_resource_attributes.h"
-
-
-class JniRCSResourceObject;
-
-/**
- * @class   JniGetRequestListener
- * @brief   This class provides functions for handling the get request callback between the Java and Native layer
- *
- */
-class JniGetRequestListener
-{
-    public:
-        /**
-         * @brief constructor
-         */
-        JniGetRequestListener(JNIEnv *env, jobject jListener,
-                              JniRCSResourceObject *resource);
-
-        /**
-         * @brief destructor
-        */
-        ~JniGetRequestListener();
-
-        /**
-         * @brief callback function that will be passed to Native layer
-        */
-        OIC::Service::RCSGetResponse onGetRequestCallback(OIC::Service::RCSRequest request,
-                OIC::Service::RCSResourceAttributes attributes);
-
-    private:
-        jweak m_jwListener;
-        JniRCSResourceObject *m_ownerResource;
-        void checkExAndRemoveListener(JNIEnv *env);
-};
-
-#endif //__JNI_RE_GET_REQUEST_LISTENER_H_
\ No newline at end of file
diff --git a/service/resource-encapsulation/sdk/java/jni/re/include/jni_re_getattributes_listener.h b/service/resource-encapsulation/sdk/java/jni/re/include/jni_re_getattributes_listener.h
deleted file mode 100644 (file)
index ece0d0a..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/******************************************************************
- *
- * 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.
- *
- ******************************************************************/
-
-/** @file   jni_re_getattributes_listener.h
- *
- *   @brief  This file contains JNI get attributes Listener class
- */
-
-#ifndef __JNI_RE_GET_ATTRIBUTES_LISTENER_H_
-#define __JNI_RE_GET_ATTRIBUTES_LISTENER_H_
-
-#include <jni.h>
-
-#include "jni_re_jvm.h"
-#include "jni_re_utils.h"
-#include "jni_re_resource_attributes.h"
-
-class JniRCSRemoteResourceObject;
-
-/**
- * @class   JniGetAttributesListener
- * @brief   This class provides functions for handling the get attribute callback between the Java and Native layer
- *
- */
-class JniGetAttributesListener
-{
-    public:
-        /**
-         * @brief constructor
-         */
-        JniGetAttributesListener(JNIEnv *env, jobject jListener,
-                                 JniRCSRemoteResourceObject *resource);
-
-        /**
-         * @brief destructor
-        */
-        ~JniGetAttributesListener();
-
-        /**
-         * @brief callback function that will be passed to Native layer
-        */
-        void onRemoteAttributesGetCallback(OIC::Service::RCSResourceAttributes attributes);
-
-    private:
-        jweak m_jwListener;
-        JniRCSRemoteResourceObject *m_ownerResource;
-        void checkExAndRemoveListener(JNIEnv *env);
-};
-
-#endif //__JNI_RE_GET_ATTRIBUTES_LISTENER_H_
diff --git a/service/resource-encapsulation/sdk/java/jni/re/include/jni_re_listener_manager.h b/service/resource-encapsulation/sdk/java/jni/re/include/jni_re_listener_manager.h
deleted file mode 100644 (file)
index c775305..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-/******************************************************************
- *
- * 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.
- *
- ******************************************************************/
-
-/** @file   jni_re_listener_manager.h
- *
- *   @brief  This file contains JNI Listener Manager class for client (jni_re_rcs_remoteresourceobject)
- */
-
-#ifndef __JNI_RE_LISTENER_MANAGER_LISTENER_H_
-#define __JNI_RE_LISTENER_MANAGER_LISTENER_H_
-
-#include <mutex>
-#include <map>
-
-class JniRCSRemoteResourceObject;
-
-/**
- * @class   JniReListenerManager
- * @brief   This class provides functions for managing listeners
- *
- */
-template <class T>
-class JniReListenerManager
-{
-    public:
-        /**
-         * API for Adding the Listener to listener Map.
-         *
-         * @param owner - JniRCSRemoteResourceObject
-         */
-        T *addListener(JNIEnv *env, jobject jListener, JniRCSRemoteResourceObject *owner)
-        {
-            T *onEventListener = NULL;
-
-            m_mapMutex.lock();
-
-            for (auto it = m_listenerMap.begin(); it != m_listenerMap.end(); ++it)
-            {
-                if (env->IsSameObject(jListener, it->first))
-                {
-                    auto refPair = it->second;
-                    onEventListener = refPair.first;
-                    refPair.second++;
-                    it->second = refPair;
-                    m_listenerMap.insert(*it);
-                    LOGD("OnEventListener: ref. count is incremented");
-                    break;
-                }
-            }
-            if (!onEventListener)
-            {
-                onEventListener = new T(env, jListener, owner);
-                jobject jgListener = env->NewGlobalRef(jListener);
-
-                if (jgListener)
-                {
-                    m_listenerMap.insert(
-                        std::pair < jobject,
-                        std::pair<T *, int >> (jgListener, std::pair<T *, int>(onEventListener, 1)));
-                }
-                else
-                {
-                    LOGD("OnEventListener: Failed to create global listener ref.");
-                    delete onEventListener;
-                }
-                LOGD("OnEventListener: new listener");
-            }
-            m_mapMutex.unlock();
-            return onEventListener;
-        }
-
-        /**
-         * @brief API for removing the Listener from listener Map.
-         */
-        void removeListener(JNIEnv *env, jobject jListener)
-        {
-            m_mapMutex.lock();
-            for (auto it = m_listenerMap.begin(); it != m_listenerMap.end(); ++it)
-            {
-                if (env->IsSameObject(jListener, it->first))
-                {
-                    auto refPair = it->second;
-                    if (refPair.second > 1)
-                    {
-                        refPair.second--;
-                        it->second = refPair;
-                        m_listenerMap.insert(*it);
-                        LOGI("OnEventListener: ref. count is decremented");
-                    }
-                    else
-                    {
-                        env->DeleteGlobalRef(it->first);
-                        T *listener = refPair.first;
-                        delete listener;
-                        m_listenerMap.erase(it);
-
-                        LOGI("OnEventListener is removed");
-                    }
-                    break;
-                }
-            }
-            m_mapMutex.unlock();
-        }
-
-        /**
-         * @brief API for removing all the Listener from listener Map.
-         */
-        void removeAllListeners(JNIEnv *env)
-        {
-            m_mapMutex.lock();
-
-            for (auto & pair : m_listenerMap)
-            {
-                env->DeleteGlobalRef(pair.first);
-                auto refPair = pair.second;
-                delete refPair.first;
-            }
-            m_listenerMap.clear();
-
-            m_mapMutex.unlock();
-        }
-
-    private:
-        std::map<jobject, std::pair<T *, int>> m_listenerMap;
-        std::mutex m_mapMutex;
-};
-
-#endif //__JNI_RE_LISTENER_MANAGER_LISTENER_H_
diff --git a/service/resource-encapsulation/sdk/java/jni/re/include/jni_re_listener_manager_server.h b/service/resource-encapsulation/sdk/java/jni/re/include/jni_re_listener_manager_server.h
deleted file mode 100644 (file)
index 19735e9..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-/******************************************************************
- *
- * 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.
- *
- ******************************************************************/
-
-/** @file   jni_re_listener_manager_server.h
- *
- *   @brief  This file contains JNI Listener Manager class for server (jni_re_rcs_resource_object)
- */
-
-#ifndef __JNI_RE_LISTENER_MANAGER_LISTENER_H_
-#define __JNI_RE_LISTENER_MANAGER_LISTENER_H_
-
-#include <mutex>
-#include <map>
-
-class JniRemoteResourceObject;
-
-/**
- * @class   JniReListenerManagerServer
- * @brief   This class provides functions for managing listeners
- *
- */
-template <class T>
-class JniReListenerManagerServer
-{
-    public:
-        /**
-         * API for Adding the Listener to listener Map.
-         *
-         * @param owner - JniRCSResourceObject
-         */
-        T *addListener(JNIEnv *env, jobject jListener, JniRCSResourceObject *owner)
-        {
-            T *onEventListener = NULL;
-
-            m_mapMutex.lock();
-
-            for (auto it = m_listenerMap.begin(); it != m_listenerMap.end(); ++it)
-            {
-                if (env->IsSameObject(jListener, it->first))
-                {
-                    auto refPair = it->second;
-                    onEventListener = refPair.first;
-                    refPair.second++;
-                    it->second = refPair;
-                    m_listenerMap.insert(*it);
-                    LOGD("OnEventListener: ref. count is incremented");
-                    break;
-                }
-            }
-            if (!onEventListener)
-            {
-                onEventListener = new T(env, jListener, owner);
-                jobject jgListener = env->NewGlobalRef(jListener);
-
-                if (jgListener)
-                {
-                    m_listenerMap.insert(
-                        std::pair < jobject,
-                        std::pair<T *, int >> (jgListener, std::pair<T *, int>(onEventListener, 1)));
-                }
-                else
-                {
-                    LOGD("OnEventListener: Failed to create global listener ref.");
-                    delete onEventListener;
-                }
-                LOGD("OnEventListener: new listener");
-            }
-            m_mapMutex.unlock();
-            return onEventListener;
-        }
-
-        /**
-         * @brief API for removing the Listener from listener Map.
-         */
-        void removeListener(JNIEnv *env, jobject jListener)
-        {
-            m_mapMutex.lock();
-            for (auto it = m_listenerMap.begin(); it != m_listenerMap.end(); ++it)
-            {
-                if (env->IsSameObject(jListener, it->first))
-                {
-                    auto refPair = it->second;
-                    if (refPair.second > 1)
-                    {
-                        refPair.second--;
-                        it->second = refPair;
-                        m_listenerMap.insert(*it);
-                        LOGI("OnEventListener: ref. count is decremented");
-                    }
-                    else
-                    {
-                        env->DeleteGlobalRef(it->first);
-                        T *listener = refPair.first;
-                        delete listener;
-                        m_listenerMap.erase(it);
-
-                        LOGI("OnEventListener is removed");
-                    }
-                    break;
-                }
-            }
-            m_mapMutex.unlock();
-        }
-
-        /**
-         * @brief API for removing all the Listener from listener Map.
-         */
-        void removeAllListeners(JNIEnv *env)
-        {
-            m_mapMutex.lock();
-
-            for (auto & pair : m_listenerMap)
-            {
-                env->DeleteGlobalRef(pair.first);
-                auto refPair = pair.second;
-                delete refPair.first;
-            }
-            m_listenerMap.clear();
-
-            m_mapMutex.unlock();
-        }
-
-    private:
-        std::map<jobject, std::pair<T *, int>> m_listenerMap;
-        std::mutex m_mapMutex;
-};
-
-#endif //__JNI_RE_LISTENER_MANAGER_LISTENER_H_
diff --git a/service/resource-encapsulation/sdk/java/jni/re/include/jni_re_rcs_bundle_info.h b/service/resource-encapsulation/sdk/java/jni/re/include/jni_re_rcs_bundle_info.h
deleted file mode 100644 (file)
index 5cd811a..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-/******************************************************************
- *
- * 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.
- *
- ******************************************************************/
-
-/** @file   jni_re_rcs_bundle_info.h
- *
- * @brief This file contains the JniBundleInfo class
- *               & declaration of RCSBundleInfo APIs for JNI implementation
- */
-
-#ifndef __JNI_RE_RCS_BUNDLE_INFO_H_
-#define __JNI_RE_RCS_BUNDLE_INFO_H_
-
-#include <jni.h>
-
-#include <RCSBundleInfo.h>
-
-using namespace OIC::Service;
-
-/**
- * @class   JniBundleInfo
- * @brief   This class provides the API for getting the RCSBundleInfo pointer
- *
- */
-class JniBundleInfo
-{
-    public:
-        /**
-         * @brief Get the RCSBundleInfo pointer
-         *      internally get the native handle by calling REGetHandle
-         */
-        static RCSBundleInfo *getRCSBundleInfoPtr(JNIEnv *env, jobject thiz);
-};
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
-* API for getting the Id of the bundle
-*
-* @return jstring - Id of the bundle
-*
-*/
-JNIEXPORT jstring JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSBundleInfo_nativeGetID
-(JNIEnv *env, jobject jObject);
-
-/**
-* API for getting the path of the bundle
-*
-* @return jstring - path of the bundle
-*
-*/
-JNIEXPORT jstring JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSBundleInfo_nativeGetPath
-(JNIEnv *env, jobject jObject);
-
-/**
-* API for getting the Activator name for the bundle
-*
-* @return jstring - Name of the activator
-*
-*/
-JNIEXPORT jstring JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSBundleInfo_nativeGetActivatorName
-(JNIEnv *env, jobject jObject);
-
-/**
-* API for getting the library path for the bundle
-*
-* @return jstring - Library path  in string form
-*
-*/
-JNIEXPORT jstring JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSBundleInfo_nativeGetLibraryPath
-(JNIEnv *env, jobject jObject);
-
-/**
-* API for getting the version of the bundle
-*
-* @return jstring - version of the bundle
-*
-*/
-JNIEXPORT jstring JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSBundleInfo_nativeGetVersion
-(JNIEnv *env, jobject jObject);
-
-
-/**
-* API for setting the Id of the bundle
-*
-* @param id - Id of the bundle in string form
-*
-*/
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSBundleInfo_nativeSetID
-(JNIEnv *env, jobject jObject, jstring id);
-
-/**
-* API for setting the path of the bundle
-*
-* @param path - path of the bundle in string form
-*
-*/
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSBundleInfo_nativeSetPath
-(JNIEnv *env, jobject jObject, jstring path);
-
-/**
-* API for setting the Activator name for the bundle
-*
-* @param activator - Activator name in string form
-*
-*/
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSBundleInfo_nativeSetActivatorName
-(JNIEnv *env, jobject jObject, jstring activatorname);
-
-/**
-* API for setting the library path for the bundle
-*
-* @param libpath - Library path in string form
-*
-*/
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSBundleInfo_nativeSetLibraryPath
-(JNIEnv *env, jobject jObject, jstring libraryPath);
-
-/**
-* API for setting the version of the bundle
-*
-* @param version - version of the bundle in string form
-*
-*/
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSBundleInfo_nativeSetVersion
-(JNIEnv *env, jobject jObject, jstring version);
-
-#ifdef __cplusplus
-}
-#endif
-#endif //__JNI_RE_RCS_BUNDLE_INFO_H_
-
diff --git a/service/resource-encapsulation/sdk/java/jni/re/include/jni_re_rcs_discovery_manager.h b/service/resource-encapsulation/sdk/java/jni/re/include/jni_re_rcs_discovery_manager.h
deleted file mode 100644 (file)
index c58fa05..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/******************************************************************
- *
- * 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.
- *
- ******************************************************************/
-
-/** @file   jni_re_rcs_discovery_manager.h
- *
- *   @brief  This file contains the declaration of Discover Resource API
- *               for JNI implementation
- */
-
-#ifndef __JNI_RE_RCS_DISCOVERY_MANAGER_H_
-#define __JNI_RE_RCS_DISCOVERY_MANAGER_H_
-
-#include <stdio.h>
-#include <string>
-#include <mutex>
-#include <map>
-#include <jni.h>
-#include "jni_re_discover_resource_listener.h"
-
-#define LOG_TAG "JNIDM"
-
-/**
-* @brief API for adding listener to discover resource listener Map.
-*/
-JniDiscoverResourceListener *AddDiscoverResourceListener(JNIEnv *env, jobject jListener);
-
-/**
-* @brief API for removing listener from discover resource listener Map.
-*/
-void RemoveDiscoverResourceListener(JNIEnv *env, jobject jListener);
-
-/**
-* @brief discover resource listener Map.
-*/
-std::map<jobject, std::pair<JniDiscoverResourceListener *, int>> discoverResourceListenerMap;
-
-/**
- *  Mutex for thread synchronization
- */
-std::mutex discoverResourceMapLock;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * API for discovering the resource of interest in the network
- *
- * @param address - address
- * @param typeofDiscovery - multicast or unicast
- * @param relativeURI - relative URI for the resource of interest
- * @param resourceType - resource type
- * @param discoveryListener - Listener to obtain discovered resource
- *
- * NOTE: 0 - Unicast  1 - Multicast
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSDiscoveryManager_discoverResource
-(JNIEnv *env, jclass interfaceClass, jstring address, jint typeofDiscovery, jstring relativeURI,
- jstring resourceType, jobject discoveryListener);
-
-#ifdef __cplusplus
-}
-#endif
-#endif //__JNI_RE_RCS_DISCOVERY_MANAGER_H_
diff --git a/service/resource-encapsulation/sdk/java/jni/re/include/jni_re_rcs_remoteresourceobject.h b/service/resource-encapsulation/sdk/java/jni/re/include/jni_re_rcs_remoteresourceobject.h
deleted file mode 100644 (file)
index debd855..0000000
+++ /dev/null
@@ -1,319 +0,0 @@
-/******************************************************************
- *
- * 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.
- *
- ******************************************************************/
-
-/** @file   jni_re_rcs_remoteresourceobject.h
- *
- *   @brief  This file contains the JniRCSRemoteResourceObject class
- *               & declaration of RCSRemoteResourceObject APIs for JNI implementation
- */
-
-#ifndef _JNI_RE_RCS_REMOTE_RESOURCE_OBJECT_H_
-#define _JNI_RE_RCS_REMOTE_RESOURCE_OBJECT_H_
-
-#include "RCSRemoteResourceObject.h"
-
-#include "jni_re_jvm.h"
-#include "jni_re_utils.h"
-#include "jni_re_listener_manager.h"
-#include "jni_re_resource_statechange_listener.h"
-#include "jni_re_cache_update_listener.h"
-#include "jni_re_getattributes_listener.h"
-#include "jni_re_setattributes_listener.h"
-
-using namespace OIC::Service;
-
-/**
- * @class   JniRCSRemoteResourceObject
- * @brief   This class contains all the APIs for RCSRemoteResourceObject
- *
- * NOTE: JNI APIs internally call the APIs of this class.
- */
-class JniRCSRemoteResourceObject
-{
-    public:
-
-        /**
-         * @brief constructor
-         */
-        JniRCSRemoteResourceObject(std::shared_ptr< RCSRemoteResourceObject> resource);
-
-        /**
-         * @brief destructor
-         */
-        ~JniRCSRemoteResourceObject();
-
-        // ***** JNI APIs internally call the APIs of this class ***** //
-
-        bool isMonitoring();
-        bool isCaching();
-        bool isObservable();
-        void startMonitoring(JNIEnv *env, jobject jListener) ;
-        void stopMonitoring();
-        int getState();
-        void startCaching(JNIEnv *env, jobject jListener);
-        void startCaching(JNIEnv *env);
-        void stopCaching();
-        int getCacheState();
-        bool isCachedAvailable();
-        std::string getUri();
-        std::string getAddress();
-        jobject getInterfaces(JNIEnv *env);
-        jobject getTypes(JNIEnv *env);
-        void getRemoteAttributes(JNIEnv *env, jobject jListener);
-        void setRemoteAttributes(JNIEnv *env, jobject attribute, jobject jListener);
-        jobject getCachedAttributes(JNIEnv *env);
-        jstring getCachedAttribute(JNIEnv *env, jstring key, jobject object);
-
-        JniResourceStateChangeListener *addOnStateChangeListener(JNIEnv *env, jobject jListener);
-        JniCacheUpdateListener *addOnCacheUpdateListener(JNIEnv *env, jobject jListener);
-        JniGetAttributesListener *addOngetAttributesListener(JNIEnv *env, jobject jListener);
-        JniSetAttributesListener *addOnsetAttributesListener(JNIEnv *env, jobject jListener);
-
-        void removeOnStateChangeListener(JNIEnv *env, jobject jListener);
-        void removeCacheUpdateListener(JNIEnv *env, jobject jListener);
-        void removeOngetAttributesListener(JNIEnv *env, jobject jListener);
-        void removeOnsetAttributesListener(JNIEnv *env, jobject jListener);
-
-        std::shared_ptr< RCSRemoteResourceObject> getRCSResource();
-
-        static JniRCSRemoteResourceObject *getJniRCSRemoteResourceObject(JNIEnv *env, jobject thiz);
-
-    private:
-        JniReListenerManager<JniResourceStateChangeListener> m_onStateChange;
-        JniReListenerManager<JniCacheUpdateListener> m_onCacheUpdateChange;
-        JniReListenerManager<JniGetAttributesListener> m_ongetAttributes;
-        JniReListenerManager<JniSetAttributesListener> m_onsetAttributes;
-
-        std::shared_ptr< RCSRemoteResourceObject> m_sharedResource;
-
-};
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * API for checking whether monitoring is enabled or not.
- *
- * @return jboolean - boolean value (true/false)
- *
- * NOTE: If monitoring is started returns true otherwise false
- */
-JNIEXPORT jboolean JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeIsMonitoring
-(JNIEnv *env, jobject interfaceClass);
-
-/**
- * API for checking whether Caching is enabled or not.
- *
- * @return jboolean - boolean value (true/false)
- *
- * NOTE: If Caching is started returns true otherwise false
- */
-JNIEXPORT jboolean JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeIsCaching
-(JNIEnv *env, jobject interfaceClass);
-
-/**
- * API for checking whether resource is observable or not.
- *
- * @return jboolean - boolean value (true/false)
- *
- * NOTE: If resource is observable returns true otherwise false
- */
-JNIEXPORT jboolean JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeIsObservable
-(JNIEnv *env, jobject interfaceClass);
-
-/**
- * Starts monitoring the resource.
- *
- * Monitoring provides a feature to check the presence of a resource,
- * even when the server is not announcing Presence using startPresnece.
- *
- * @param stateChangedListener - Listener to obtain the changed resource state
- *
- * @throws RCSException If monitoring is already started.
- *
- * @note The callback will be invoked in an internal thread.
- *
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeStartMonitoring
-(JNIEnv *env, jobject interfaceClass, jobject stateChangedListener);
-
-/**
- * Stops monitoring the resource.
- *
- * It does nothing if monitoring is not started.
- *
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeStopMonitoring
-(JNIEnv *env, jobject interfaceClass);
-
-/**
- * Returns the current state of the resource.
- *
- */
-JNIEXPORT jint JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeGetState
-(JNIEnv *env, jobject interfaceClass);
-
-/**
- * Starts caching attributes of the resource.
- *
- * This will start data caching for the resource.
- * Once caching started it will look for the data updation on the resource.
- * If this method is called with null listener it will not notify the updated value to caller.
- * It it is called with a valid listener updated cached values will be notified to caller.
- *
- * @param cacheUpdateListener - Listener to obtain the updated cached data
- *
- * @throws RCSException If Caching is already started
- *
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeStartCaching
-(JNIEnv *env, jobject interfaceClass, jobject cacheUpdateListener);
-
-/**
- * Stops caching.
- *
- * It does nothing if caching is not started.
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeStopCaching
-(JNIEnv *env, jobject interfaceClass);
-
-/**
- * Returns the current cache state.
- *
- */
-JNIEXPORT jint JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeGetCacheState
-(JNIEnv *env, jobject interfaceClass);
-
-/**
- * Returns whether cached data is available.
- *
- * Cache will be available always after CacheState::READY even if current state is
- * LOST_SIGNAL.
- *
- */
-JNIEXPORT jboolean JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeIsCachedAvailable
-(JNIEnv *env, jobject interfaceClass);
-
-/**
- * Gets the cached RCSResourceAttributes data.
- *
- * @pre Cache should be available.
- *
- * @return The cached attributes.
- *
- * @throws RCSException If the precondition is not fulfilled.
- *
- */
-JNIEXPORT jobject JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeGetCachedAttributes
-(JNIEnv *env, jobject interfaceClass);
-
-/**
- * Gets a particular cached a ResourceAttribute Value.
- *
- * @pre Cache should be available.
- *
- * @param key - Attribute Key
- *
- * @return Requested attribute value.
- *
- * @throws RCSException If the precondition is not fulfilled or key doesn't match the key of any value.
- *
- */
-JNIEXPORT jstring JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeGetCachedAttribute
-(JNIEnv *env, jobject interfaceClass, jstring key);
-
-/**
- * Gets resource attributes directly from the server.
- *
- * This API send a get request to the resource of interest and provides
- * the attributes to the caller in the RemoteAttributesReceivedCallback.
- *
- * @param resourceAttributesListener - Listener to get the resource attributes
- *
- * @note The callback will be invoked in an internal thread.
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeGetRemoteAttributes
-(JNIEnv *env, jobject interfaceClass, jobject resourceAttributesListener);
-
-/**
- * Sends a set request with resource attributes to the server.
- *
- * The SetRequest behavior depends on the server, whether updating its attributes or not.
- *
- * @param resourceAttributes -  Attributes to set
- * @param resourceAttributesListener - Listener to obtain the updated cached data
- *
- * @note The callback will be invoked in an internal thread.
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeSetRemoteAttributes
-(JNIEnv *env, jobject interfaceClass, jobject resourceAttributes,
- jobject resourceAttributesListener);
-
-/**
- * Returns the uri of the resource.
- *
- */
-JNIEXPORT jstring JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeGetUri
-(JNIEnv *env, jobject interfaceClass);
-
-/**
- * Returns the address of the resource .
- *
- */
-JNIEXPORT jstring JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeGetAddress
-(JNIEnv *env, jobject interfaceClass);
-
-/**
- * Returns the resource types of the resource.
- *
- */
-JNIEXPORT jobject JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeGetTypes
-(JNIEnv *env, jobject interfaceClass);
-
-/**
- * Returns the resource interfaces of the resource.
- *
- */
-JNIEXPORT jobject JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeGetInterFaces
-(JNIEnv *env, jobject interfaceClass);
-
-#ifdef __cplusplus
-}
-#endif
-#endif // _JNI_RE_RCS_REMOTE_RESOURCE_OBJECT_H_
diff --git a/service/resource-encapsulation/sdk/java/jni/re/include/jni_re_rcs_resource_container.h b/service/resource-encapsulation/sdk/java/jni/re/include/jni_re_rcs_resource_container.h
deleted file mode 100644 (file)
index 3a7e138..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
-/******************************************************************
- *
- * 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.
- *
- ******************************************************************/
-
-/** @file   jni_re_rcs_resource_container.h
- *
- *   @brief  This file contains the declaration of RCSResourceContainer
- *    APIs for JNI implementation
- */
-
-#ifndef __JNI_RE_RCS_RESOURCE_CONTAINER_H_
-#define __JNI_RE_RCS_RESOURCE_CONTAINER_H_
-
-#include <jni.h>
-
-#include "jni_re_jvm.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * API for starting the Container
- *
- * @details This API start the container with the provided Configuration file.
- *
- * @param configFile - configuration File that contains the Bundle/Bundles information.
- *
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceContainer_nativeStartContainer
-(JNIEnv *env, jobject jObject, jstring configFile);
-
-
-/**
-* API for stopping the Container
-*/
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceContainer_nativeStopContainer
-(JNIEnv *env, jobject jObject);
-
-/**
- * API for adding the bundle to the Container
- *
- * @param bundleId - Id of the Bundle
- * @param bundleUri - Uri of the bundle
- * @param bundlePath - Path of the bundle
- * @param params  - key-value pairs in string form for other Bundle parameters
- *
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceContainer_nativeAddBundle
-(JNIEnv *env, jobject jObject, jstring bundleId, jstring bundleUri, jstring bundlePath,
- jobject params);
-
-
-/**
-* API for getting the list of all bundles in the container
-*
-* @return jobject -List of BundleInfo pointer each associated with a bundle
-*
-*/
-JNIEXPORT jobject JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceContainer_nativeListBundles
-(JNIEnv *env, jobject jObject);
-
-/**
- * API for removing the bundle from the container
- *
- * @param bundleId - Id of the Bundle
- *
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceContainer_nativeRemoveBundle
-(JNIEnv *env, jobject jObject, jstring bundleId);
-
-/**
- * API for starting the bundle.
- *
- * @param bundleId - Id of the Bundle
- *
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceContainer_nativeStartBundle
-(JNIEnv *env, jobject jObject, jstring bundleId);
-
-/**
-* API for Stopping the bundle
-*
-* @param bundleId - Id of the Bundle
-*
-*/
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceContainer_nativeStopBundle
-(JNIEnv *env, jobject jObject, jstring bundleId);
-
-/**
-* API for adding the Resource configuration information to the bundle
-*
-* @param bundleId - Id of the Bundle
-* @param resourceUri - URI of the resource
-* @param params  - key-value pairs in string form for other Bundle parameters
-*
-*/
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceContainer_nativeAddResourceConfig
-(JNIEnv *env, jobject jObject, jstring bundleId, jstring resourceUri, jobject params);
-
-/**
-* API for removing the Resource configuration information from the bundle
-*
-* @param bundleId - Id of the Bundle
-* @param resourceUri - URI of the resource
-*
-*/
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceContainer_nativeRemoveResourceConfig
-(JNIEnv *env, jobject jObject, jstring bundleId, jstring resourceUri);
-
-/**
-* API for getting the list of Bundle Resources
-*
-* @param bundleId - Id of the Bundle
-*
-*/
-JNIEXPORT jobject JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceContainer_nativeListBundleResources
-(JNIEnv *env, jobject jObject, jstring bundleId);
-
-#ifdef __cplusplus
-}
-#endif
-#endif //__JNI_RE_RCS_RESOURCE_CONTAINER_H_
diff --git a/service/resource-encapsulation/sdk/java/jni/re/include/jni_re_resource_attributes.h b/service/resource-encapsulation/sdk/java/jni/re/include/jni_re_resource_attributes.h
deleted file mode 100644 (file)
index 136fdf8..0000000
+++ /dev/null
@@ -1,380 +0,0 @@
-/******************************************************************
- *
- * 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.
- *
- ******************************************************************/
-
-/** @file
- * This file contains the declaration of Resource Attribute APIs
- *  for JNI implementation
- */
-
-#ifndef __JNI_RE_RCS_RESOURCE_ATTRIBUTES_H_
-#define __JNI_RE_RCS_RESOURCE_ATTRIBUTES_H_
-
-#include "jni_re_jvm.h"
-#include "jni_re_utils.h"
-
-#include <RCSResourceAttributes.h>
-
-#define JNI_EXCEPTION 1000
-#define JNI_NO_NATIVE_POINTER 1001
-#define JNI_INVALID_VALUE 1002
-#define JNI_NO_SUCH_KEY 1003
-
-struct NullType {};
-
-/**
- * @class
- * This class provides the API for getting the RCSResourceAttribute pointer
- */
-class JniResourceAttributes
-{
-    public:
-
-        /**
-         * Get the ResourceAttibute pointer
-         * internally get the native handle by calling REGetHandle
-         */
-        static RCSResourceAttributes *getResourceAttributePtr(JNIEnv *env, jobject thiz);
-};
-
-/**
- * Utility structure for jobject conversion
- */
-struct JObjectConverter : boost::static_visitor < jobject >
-{
-        JObjectConverter(JNIEnv *env) : env(env) {}
-
-        jobject operator()(const NullType &) const { return nullptr; }
-        jobject operator()(const int &val) const
-        {
-            jobject jobj = env->NewObject(
-                               g_cls_Integer,
-                               g_mid_Integer_ctor,
-                               static_cast<jint>(val));
-            return jobj;
-        }
-        jobject operator()(const double &val) const
-        {
-            jobject jobj = env->NewObject(
-                               g_cls_Double,
-                               g_mid_Double_ctor,
-                               static_cast<jdouble>(val));
-            return jobj;
-        }
-        jobject operator()(const bool &val) const
-        {
-            jobject jobj = env->NewObject(
-                               g_cls_Boolean,
-                               g_mid_Boolean_ctor,
-                               static_cast<jboolean>(val));
-            return jobj;
-        }
-        jobject operator()(const std::string &val) const
-        {
-            jstring jstr = env->NewStringUTF(val.c_str());
-            return static_cast<jobject>(jstr);
-        }
-    private:
-        JNIEnv *env;
-};
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * API for getting attribute value corresponding to requested Key
- *
- * @param key - Attribute key
- * @param dataType - dataType for the value.
- *
- * @return value of attribute
- *
- * @throws RCSException
- */
-JNIEXPORT jobject JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeGetValueN
-(JNIEnv *env, jobject interfaceObject, jstring key, jint dataType);
-
-/**
- * API for setting integer value for attribute
- *
- * @param key - Attribute key
- * @param value - Attribute value
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSetValueInt
-(JNIEnv *env, jobject interfaceObject, jstring key, jint value);
-
-/**
- * API for setting Vector of integer as attribute value
- *
- * @param key - Attribute key
- * @param value - Attribute value
- *
- * @throws RCSException - If Key is empty
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSetValueVectorOfInt
-(JNIEnv *env, jobject interfaceObject, jstring key, jobject value);
-
-/**
- * API for setting vector of vector of integer as attribute value
- *
- * @param key - Attribute key
- * @param value - Attribute value
- *
- * @throws RCSException - If Key is empty
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSetValueVectorOfVectorOfInt
-(JNIEnv *env, jobject interfaceObject, jstring key, jobject value);
-
-/**
- * API for setting vector of vector of vector of integer as attribute value
- *
- * @param key - Attribute key
- * @param value - Attribute value
- *
- * @throws RCSException - If Key is empty
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSetValueVectorOfVectorOfVectorOfInt
-(JNIEnv *env, jobject interfaceObject, jstring key, jobject value);
-
-/**
- * API for setting double as attribute value
- *
- * @param key - Attribute key
- * @param value - Attribute value
- *
- * @throws RCSException - If Key is empty
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSetValueDouble
-(JNIEnv *env, jobject interfaceObject, jstring key, jdouble value);
-
-/**
- * API for setting Vector of double as attribute value
- *
- * @param key - Attribute key
- * @param value - Attribute value
- *
- * @throws RCSException - If Key is empty
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSetValueVectorOfDouble
-(JNIEnv *env, jobject interfaceObject, jstring key, jobject value);
-
-/**
- * API for setting Vector of Vector of double as attribute value
- *
- * @param key - Attribute key
- * @param value - Attribute value
- *
- * @throws RCSException - If Key is empty
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSetValueVectorOfVectorOfDouble
-(JNIEnv *env, jobject interfaceObject, jstring key, jobject value);
-
-/**
- * API for setting Vector of Vector of Vector of double as attribute value
- *
- * @param key - Attribute key
- * @param value - Attribute value
- *
- * @throws RCSException - If Key is empty
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSetValueVectorOfVectorOfVectorOfDouble
-(JNIEnv *env, jobject interfaceObject, jstring key, jobject value);
-
-
-/**
- * API for setting boolean as attribute value
- *
- * @param key - Attribute key
- * @param value - Attribute value
- *
- * @throws RCSException - If Key is empty
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSetValueBoolean
-(JNIEnv *env, jobject interfaceObject, jstring key, jboolean value);
-
-/**
- * API for setting vector of boolean as attribute value
- *
- * @param key - Attribute key
- * @param value - Attribute value
- *
- * @throws RCSException - If Key is empty
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSetValueVectorOfBoolean
-(JNIEnv *env, jobject interfaceObject, jstring key, jobject value);
-
-/**
- * API for setting vector of vector of boolean as attribute value
- *
- * @param key - Attribute key
- * @param value - Attribute value
- *
- * @throws RCSException - If Key is empty
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSetValueVectorOfVectorOfBoolean
-(JNIEnv *env, jobject interfaceObject, jstring key, jobject value);
-
-/**
- * API for setting vector of vector of vector of boolean as attribute value
- *
- * @param key - Attribute key
- * @param value - Attribute value
- *
- * @throws RCSException - If Key is empty
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSetValueVectorOfVectorOfVectorOfBoolean
-(JNIEnv *env, jobject interfaceObject, jstring key, jobject value);
-
-/**
- * API for setting String as attribute value
- *
- * @param key - Attribute key
- * @param value - Attribute value
- *
- * @throws RCSException - If Key is empty
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSetValueString
-(JNIEnv *env, jobject interfaceObject, jstring key, jstring value);
-
-/**
- * API for setting Vector of String as attribute value
- *
- * @param key - Attribute key
- * @param value - Attribute value
- *
- * @throws RCSException - If Key is empty
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSetValueVectorOfString
-(JNIEnv *env, jobject interfaceObject, jstring key, jobject value);
-
-/**
- * API for setting Vector of Vector of String as attribute value
- *
- * @param key - Attribute key
- * @param value - Attribute value
- *
- * @throws RCSException - If Key is empty
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSetValueVectorOfVectorOfString
-(JNIEnv *env, jobject interfaceObject, jstring key, jobject value);
-
-/**
- * API for setting Vector of Vector of Vector of String as attribute value
- *
- * @param key - Attribute key
- * @param value - Attribute value
- *
- * @throws RCSException - If Key is empty
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSetValueVectorOfVectorOfVectorOfString
-(JNIEnv *env, jobject interfaceObject, jstring key, jobject value);
-
-/**
- * API for setting RCSResourceAttribute as attribute value
- *
- * @param key - Attribute key
- * @param value - Attribute value
- *
- * @throws RCSException - If Key is empty
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSetValueAttributes
-(JNIEnv *env, jobject interfaceObject, jstring key, jobject value);
-
-
-/**
- * API for checking whether attribute is empty or not
- *
- * @return  jBoolean - boolean value (true/false)
- *
- */
-JNIEXPORT jboolean JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeIsEmpty
-(JNIEnv *env, jobject interfaceObject);
-
-/**
- * API for getting the size of the attributes
- *
- * @return jint - size of attributes
- *
- */
-JNIEXPORT jint JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSize
-(JNIEnv *env, jobject interfaceObject);
-
-/**
- * API for removing a particular attribute
- *
- * @param key - Attribute key
- *
- * @return  jBoolean - boolean value (true/false)
- *
- * NOTE: If requested attribute is successfully removed it will return true otherwise false
- */
-JNIEXPORT jboolean JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeRemove
-(JNIEnv *env, jobject interfaceObject, jstring key);
-
-/**
- * API for checking a particular attribute
- *
- * @param key - Attribute key
- *
- * @return  jBoolean - boolean value (true/false)
- *
- * NOTE: If requested attribute is present it will return true otherwise false
- */
-JNIEXPORT jboolean JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeHasAttribute
-(JNIEnv *env, jobject interfaceObject, jstring key);
-
-/**
- * API for creating a new RCSResourceAttributes object and setting of Native handle
- */
-JNIEXPORT void JNICALL Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_create
-(JNIEnv *env, jobject interfaceObject);
-
-/**
- *  API for deleting the RCSResourceAttributes object
- */
-JNIEXPORT void JNICALL Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_dispose
-(JNIEnv *env, jobject interfaceObject, jboolean jNeedsDelete);
-
-#ifdef __cplusplus
-}
-#endif
-#endif  //__JNI_RE_RCS_RESOURCE_ATTRIBUTES_H_
diff --git a/service/resource-encapsulation/sdk/java/jni/re/include/jni_re_resource_builder.h b/service/resource-encapsulation/sdk/java/jni/re/include/jni_re_resource_builder.h
deleted file mode 100644 (file)
index 7699fd7..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/******************************************************************
- *
- * 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.
- *
- ******************************************************************/
-
-/**
-  * @file   jni_re_resource_builder.h
-  *
-  * @brief  This file contains the resource builder function
-  *            for JNI implementation
-  */
-
-#ifndef __JNI_RE_RESOURCEBUILDER_H
-#define __JNI_RE_RESOURCEBUILDER_H
-
-#include <jni.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/**
- * API for constructing a new RCSResourceObject.
- *
- *
- * @param resourceURI Resource URI value to be set
- * @param resourceType Resource type value to be set
- * @param resourceInterface Interface value to be set
- * @param observableFlag Whether resource should be observable or not.
- * @param discovervableFlag Whether resource should be discovervable or not.
- * @param attributes Attributes to be set
- *
- * @return RCSResourceObject object (It is the resource that is created)
- *
- * @throw RCSException
- *       It catches exception from registerResource API of OCPlatform and
- *       throws it to developer.
- */
-JNIEXPORT jobject JNICALL Java_org_iotivity_ResourceEncapsulation_server_Builder_nativeBuild
-(JNIEnv *env, jobject interfaceObject, jstring resourceURI, jstring resourceType,
- jstring resourceInterface,
- jboolean observableFlag, jboolean discovervableFlag, jobject attributes);
-
-#ifdef __cplusplus
-}
-#endif
-#endif //__JNI_RE_RESOURCEBUILDER_H
-
-
diff --git a/service/resource-encapsulation/sdk/java/jni/re/include/jni_re_resource_object.h b/service/resource-encapsulation/sdk/java/jni/re/include/jni_re_resource_object.h
deleted file mode 100644 (file)
index 6eb73a3..0000000
+++ /dev/null
@@ -1,333 +0,0 @@
-/******************************************************************
- *
- * 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.
- *
- ******************************************************************/
-
-/** @file   jni_re_resource_object.h
- *
- *   @brief  This file contains the JniResourceObject class
- *               & declaration of RCSRemoteResourceObject APIs for JNI implementation
- */
-
-#ifndef __JNI_RE_RCS_RESOURCE_OBJECT
-#define __JNI_RE_RCS_RESOURCE_OBJECT
-
-#include <jni.h>
-
-#include "jni_re_jvm.h"
-#include "RCSResourceObject.h"
-#include "jni_re_utils.h"
-#include "jni_re_get_request_listener.h"
-#include "jni_re_set_request_listener.h"
-#include "jni_re_attribute_updated_listener.h"
-#include "jni_re_listener_manager_server.h"
-
-using namespace OIC::Service;
-
-/**
- * @class   JniRCSResourceObject
- * @brief   This class contains all the APIs for RCSResourceObject
- *
- * NOTE: JNI APIs internally call the APIs of this class.
- */
-class JniRCSResourceObject
-{
-    public:
-
-        /**
-         * @brief constructor
-         */
-        JniRCSResourceObject(std::shared_ptr<RCSResourceObject> resource);
-
-        /**
-         * @brief destructor
-        */
-        ~JniRCSResourceObject();
-
-        // ***** JNI APIs internally call the APIs of this class ***** //
-
-        void setAttributeInteger(JNIEnv *env, jobject jObject, jstring key, jint value);
-        void setAttributeDouble(JNIEnv *env, jobject jObject, jstring key, jdouble value);
-        void setAttributeBool(JNIEnv *env, jobject jObject, jstring key, jboolean value);
-        void setAttributeString(JNIEnv *env, jobject jObject, jstring key, jstring value);
-        jstring getAttributeValue(JNIEnv *env, jstring jkey);
-        bool removeAttribute(JNIEnv *env, jstring key);
-        bool containsAttribute(JNIEnv *env, jstring key);
-        jobject getAttributes(JNIEnv *env, jobject jObject);
-        bool isObservable();
-        bool isDiscoverable();
-        void setGetRequestHandler(JNIEnv *env, jobject getRequestListener);
-        void setSetRequestHandler(JNIEnv *env, jobject jSetRequestListener);
-        void addAttributeUpdatedListener(JNIEnv *env, jstring key, jobject jAttributeUpdatedListener);
-        bool removeAttributeUpdatedListener(JNIEnv *env, jobject jObject, jstring key);
-        void notify();
-        void setAutoNotifyPolicy(int policy);
-        int getAutoNotifyPolicy();
-        void setSetRequestHandlerPolicy(int policy);
-        int getSetRequestHandlerPolicy();
-
-        JniGetRequestListener *addOnGetRequestListener(JNIEnv *env, jobject jListener);
-        JniSetRequestListener *addOnSetRequestListener(JNIEnv *env, jobject jListener);
-        JniAttributeUpdatedListener *addOnAttributeUpdatedListener(JNIEnv *env, jobject jListener);
-
-        void removeOnGetRequestListener(JNIEnv *env, jobject jListener);
-        void removeOnSetRequestListener(JNIEnv *env, jobject jListener);
-        void removeOnAttributeUpdatedListener(JNIEnv *env, jobject jListener);
-
-        static JniRCSResourceObject *getJniRCSResourceObject(JNIEnv *env, jobject thiz);
-
-    private:
-
-        JniReListenerManagerServer<JniGetRequestListener> m_onGetRequest;
-        JniReListenerManagerServer<JniSetRequestListener> m_onSetRequest;
-        JniReListenerManagerServer<JniAttributeUpdatedListener> m_onAttributeUpdated;
-
-        std::shared_ptr<RCSResourceObject> m_sharedResource;
-
-};
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @brief API for setting a particular attribute value as a integer
- *
- * @param key name of attribute(used to map the attribute value).
- * @param value integer value to be mapped against the key.
- *
- * It is guaranteed thread-safety about attributes.
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeSetAttributeInteger
-(JNIEnv *env, jobject jObject, jstring key, jint value);
-
-/**
- * @brief API for setting a particular attribute value as a double
- *
- * @param key name of attribute(used to map the attribute value).
- * @param value Double value to be mapped against the key.
- *
- * It is guaranteed thread-safety about attributes.
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeSetAttributeDouble
-(JNIEnv *env, jobject jObject, jstring key, jdouble value);
-
-/**
- * @brief API for setting a particular attribute value as a boolean
- *
- * @param key name of attribute(used to map the attribute value).
- * @param value boolean value to be mapped against the key.
- *
- * It is guaranteed thread-safety about attributes.
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeSetAttributeBool
-(JNIEnv *env, jobject jObject, jstring key, jboolean value);
-
-/**
- * @brief API for setting a particular attribute value as a String
- *
- * @param key name of attribute(used to map the attribute value).
- * @param value String value to be mapped against the key.
- *
- * It is guaranteed thread-safety about attributes.
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeSetAttributeString
-(JNIEnv *env, jobject jObject, jstring key, jstring value);
-
-/**
- * @brief API for retrieving the attribute value associated with the supplied key.
- *
- * @param key Name of the attribute
- *
- * @return resource attributes value as a string
- *
- * It is guaranteed thread-safety about attributes.
- */
-JNIEXPORT jstring JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeGetAttributeValue
-(JNIEnv *env, jobject jObject, jstring key);
-
-/**
- * @brief API for removing a particular attribute of the resource.
- *
- * @param key Name of the attribute.
- *
- * @return If the key exist and matched attribute is deleted, return true.
- *
- * It is guaranteed thread-safety about attributes.
- */
-JNIEXPORT jboolean JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeRemoveAttribute
-(JNIEnv *env, jobject jObject, jstring key);
-
-/**
- * @brief API for checking whether a particular attribute is there for a resource or not.
- *
- * @param key Name of the attribute.
- *
- * @return If the key exist, return true.
- *
- * It is guaranteed thread-safety about attributes.
- */
-JNIEXPORT jboolean JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeContainsAttribute
-(JNIEnv *env, jobject jObject, jstring key);
-
-
-/**
- * @brief API for getting all the attributes of the RCSResourceObject.
- *
- * @return  RCSResourceAttributes
- *
- * @see RCSResourceAttributes
- */
-JNIEXPORT jobject JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeGetAttributes
-(JNIEnv *env, jobject jObject);
-
-/**
-* @brief API for checking whether the particular resource is observable or not
-*/
-JNIEXPORT jboolean JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeIsObservable
-(JNIEnv *env, jobject jObject);
-
-/**
-* @brief API for checking whether the particular resource is discoverable or not
-*/
-JNIEXPORT jboolean JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeIsDiscoverable
-(JNIEnv *env, jobject jObject);
-
-/**
- * API for setting the resource's get request handler by the developer/application.
- * If developer set this handler then all get request will come to the application &
- * developer can send the response to the client using APIs of RCSGetResponse class.
- *
- * @param jGetRequestListener Request handler for get requests
- *
- * @see RCSGetResponse
- *
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeSetGetRequestHandler
-(JNIEnv *env, jobject jObject, jobject jGetRequestListener);
-
-/**
- * API for setting the resource's set request handler by the developer/application.
- * If developer set this handler then all set request for the resource
- * will come to the application & developer can send the response to the client
- * using APIs of RCSSetResponse class.
- *
- * @param jSetRequestListener Request handler for set requests
- *
- * @see RCSSetResponse
- *
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeSetSetRequestHandler
-(JNIEnv *env, jobject jObject, jobject jSetRequestListener);
-
-/**
- * API for setting the Listener for a particular attribute update.
- *
- * @param key The interested attribute's key
- * @param jAttributeUpdatedListener Listener for updation of the interested attribute
- *
- */
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeAddAttributeUpdatedListener
-(JNIEnv *env, jobject jObject, jstring key, jobject jAttributeUpdatedListener);
-
-/**
-* API for removing the handler for a particular attribute update.
-*
-* @param key The interested attribute's key
-*
-*/
-JNIEXPORT jboolean JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeRemoveAttributeUpdatedListener
-(JNIEnv *env, jobject jObject, jstring key);
-
-/**
- * API for notifying all observers of the RCSResourceObject
- * with the updated attributes value
- */
-JNIEXPORT void JNICALL Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeNotify
-(JNIEnv *env, jobject jObject);
-
-/**
-* API for setting Auto notify policy
-*
-* @param policy policy to be set (Its datatype is jint we will convert it to AutoNotifyPolicy enum value using jni_re_utils)
-*
-* @see AutoNotifyPolicy
-* @see jni_re_utils
-*
-*/
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeSetAutoNotifyPolicy
-(JNIEnv *env, jobject jObject, jint policy);
-
-/**
-* API for getting auto notify policy
-*
-* @returns jint AntoNotify policy as a integer in java it will be converted to AutoNotifyPolicy enum.
-*
-* @see AutoNotifyPolicy
-*
-*/
-JNIEXPORT jint JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeGetAutoNotifyPolicy
-(JNIEnv *env, jobject jObject);
-
-/**
-* API for setting the policy for a setRequestHandler.
-*
-* @param policy policy to be set (Its datatype is jint we will convert it to SetRequestHandlerPolicy enum value using jni_re_utils)
-*
-* @see SetRequestHandlerPolicy
-* @see jni_re_utils
-*
-*/
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeSetSetRequestHandlerPolicy
-(JNIEnv *env, jobject jObject, jint policy);
-
-/**
-* API for getting the SetRequestHandler Policy.
-*
-* @returns jint SetRequestHandlerPolicy policy as a integer in java it will be converted to SetRequestHandlerPolicy enum.
-*
-* @see SetRequestHandlerPolicy
-*
-*/
-JNIEXPORT jint JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeGetSetRequestHandlerPolicy
-(JNIEnv *env, jobject jObject);
-
-#ifdef __cplusplus
-}
-#endif
-#endif
-
-
diff --git a/service/resource-encapsulation/sdk/java/jni/re/include/jni_re_resource_statechange_listener.h b/service/resource-encapsulation/sdk/java/jni/re/include/jni_re_resource_statechange_listener.h
deleted file mode 100644 (file)
index 43a911e..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/******************************************************************
- *
- * 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.
- *
- ******************************************************************/
-/** @file   jni_re_resource_statechange_listener.h
- *
- *   @brief  This file contains JNI resource state change Listener class
- */
-
-#ifndef __JNI_RE_RESOURCE_STATE_CHANGE_LISTENER_H_
-#define __JNI_RE_RESOURCE_STATE_CHANGE_LISTENER_H_
-
-#include <jni.h>
-
-#include "RCSRemoteResourceObject.h"
-
-#include "jni_re_jvm.h"
-#include "jni_re_utils.h"
-
-class JniRCSRemoteResourceObject;
-
-/**
- * @class   JniResourceStateChangeListener
- * @brief   This class provides functions for handling the Resource state change callback between the Java and native layer
- *
- */
-class JniResourceStateChangeListener
-{
-    public:
-        /**
-         * @brief constructor
-         */
-        JniResourceStateChangeListener(JNIEnv *env, jobject jListener,
-                                       JniRCSRemoteResourceObject *resource);
-
-        /**
-         * @brief destructor
-        */
-        ~JniResourceStateChangeListener();
-
-        /**
-         * @brief callback function that will be passed to Native layer
-        */
-        void stateChangeCallback(OIC::Service::ResourceState state);
-
-    private:
-        jweak m_jwListener;
-        JniRCSRemoteResourceObject *m_ownerResource;
-        void checkExAndRemoveListener(JNIEnv *env);
-};
-
-#endif //__JNI_RE_RESOURCE_STATE_CHANGE_LISTENER_H_
diff --git a/service/resource-encapsulation/sdk/java/jni/re/include/jni_re_set_request_listener.h b/service/resource-encapsulation/sdk/java/jni/re/include/jni_re_set_request_listener.h
deleted file mode 100644 (file)
index 4f6b723..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/******************************************************************
- *
- * 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.
- *
- ******************************************************************/
-
-/** @file   jni_re_set_request_listener.h
- *
- *   @brief  This file contains JNI set request Listener class
- */
-
-#ifndef __JNI_RE_SET_REQUEST_LISTENER_H_
-#define __JNI_RE_SET_REQUEST_LISTENER_H_
-
-#include <jni.h>
-
-#include "jni_re_jvm.h"
-#include "jni_re_utils.h"
-#include "jni_re_resource_attributes.h"
-
-
-class JniRCSResourceObject;
-
-/**
- * @class   JniSetRequestListener
- * @brief   This class provides functions for handling the set request callback between the Java and Native layer
- *
- */
-class JniSetRequestListener
-{
-    public:
-        /**
-         * @brief constructor
-         */
-        JniSetRequestListener(JNIEnv *env, jobject jListener,
-                              JniRCSResourceObject *resource);
-
-        /**
-         * @brief destructor
-        */
-        ~JniSetRequestListener();
-
-        /**
-         * @brief callback function that will be passed to Native layer
-        */
-        OIC::Service::RCSSetResponse onSetRequestCallback(OIC::Service::RCSRequest request,
-                OIC::Service::RCSResourceAttributes attributes);
-
-    private:
-        jweak m_jwListener;
-        JniRCSResourceObject *m_ownerResource;
-        void checkExAndRemoveListener(JNIEnv *env);
-};
-
-#endif //__JNI_RE_SET_REQUEST_LISTENER_H_
diff --git a/service/resource-encapsulation/sdk/java/jni/re/include/jni_re_setattributes_listener.h b/service/resource-encapsulation/sdk/java/jni/re/include/jni_re_setattributes_listener.h
deleted file mode 100644 (file)
index c589f88..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/******************************************************************
- *
- * 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.
- *
- ******************************************************************/
-
-/** @file   jni_re_setattributes_listener.h
- *
- *   @brief  This file contains JNI set attributes Listener class
- */
-
-#ifndef __JNI_RE_SET_ATTRIBUTES_LISTENER_H_
-#define __JNI_RE_SET_ATTRIBUTES_LISTENER_H_
-
-#include <jni.h>
-
-#include "jni_re_jvm.h"
-#include "jni_re_utils.h"
-#include "jni_re_resource_attributes.h"
-
-class JniRCSRemoteResourceObject;
-
-/**
- * @class   JniSetAttributesListener
- * @brief   This class provides functions for handling the set attribute callback between the Java and native layer
- *
- */
-class JniSetAttributesListener
-{
-    public:
-        /**
-         * @brief constructor
-         */
-        JniSetAttributesListener(JNIEnv *env, jobject jListener,
-                                 JniRCSRemoteResourceObject *resource);
-
-        /**
-         * @brief destructor
-        */
-        ~JniSetAttributesListener();
-
-        /**
-         * @brief callback function that will be passed to Native layer
-        */
-        void onRemoteAttributesSetCallback(OIC::Service::RCSResourceAttributes attributes);
-
-    private:
-        jweak m_jwListener;
-        JniRCSRemoteResourceObject *m_ownerResource;
-        void checkExAndRemoveListener(JNIEnv *env);
-};
-
-#endif //__JNI_RE_SET_ATTRIBUTES_LISTENER_H_
diff --git a/service/resource-encapsulation/sdk/java/jni/re/src/jni_re_attribute_updated_listener.cpp b/service/resource-encapsulation/sdk/java/jni/re/src/jni_re_attribute_updated_listener.cpp
deleted file mode 100644 (file)
index d9f73c8..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-/******************************************************************
- *
- * 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 "jni_re_attribute_updated_listener.h"
-#include "jni_re_resource_object.h"
-
-JniAttributeUpdatedListener::JniAttributeUpdatedListener(JNIEnv *env, jobject jListener,
-        JniRCSResourceObject *owner)
-    : m_ownerResource(owner)
-{
-    m_jwListener = env->NewWeakGlobalRef(jListener);
-}
-
-JniAttributeUpdatedListener::~JniAttributeUpdatedListener()
-{
-    LOGI("JniAttributeUpdatedListener::~JniAttributeUpdatedListener()");
-    if (m_jwListener)
-    {
-        jint ret;
-        JNIEnv *env = GetREJNIEnv(ret);
-        if (NULL == env) return;
-        env->DeleteWeakGlobalRef(m_jwListener);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-    }
-}
-
-void JniAttributeUpdatedListener::onAttributeUpdatedCallback(
-    OIC::Service::RCSResourceAttributes::Value oldValue,
-    OIC::Service::RCSResourceAttributes::Value newValue)
-{
-    LOGI("JniAttributeUpdatedListener::onAttributeUpdatedCallback got a callback in JNI");
-
-    jint ret;
-    JNIEnv *env = GetREJNIEnv(ret);
-    if (NULL == env) return;
-
-    jobject jListener = env->NewLocalRef(m_jwListener);
-    if (!jListener)
-    {
-        checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-        return;
-    }
-
-    RCSResourceAttributes::TypeId oldValueTypeId = oldValue.getType().getId();
-    RCSResourceAttributes::TypeId newValueTypeId = newValue.getType().getId();
-    jstring javaOldValue;
-    jstring javaNewValue;
-    char buf[64]; // assumed large enough to cope with result
-    char bufValue[64];
-
-    if (oldValueTypeId == RCSResourceAttributes::TypeId::INT)
-    {
-        int oldVal = oldValue.get<int>();
-        sprintf(buf, "%d", oldVal);
-        javaOldValue = (env)->NewStringUTF(buf);
-
-        int newVal = newValue.get<int>();
-        sprintf(bufValue, "%d", newVal);
-        javaNewValue = (env)->NewStringUTF(bufValue);
-
-    }
-    else if (oldValueTypeId == RCSResourceAttributes::TypeId::DOUBLE)
-    {
-        double oldVal = oldValue.get<double>();
-        sprintf(buf, "%f", oldVal);
-        javaOldValue = (env)->NewStringUTF(buf);
-
-        double newVal = newValue.get<double>();
-        sprintf(bufValue, "%f", newVal);
-        javaNewValue = (env)->NewStringUTF(bufValue);
-
-    }
-    else if (oldValueTypeId == RCSResourceAttributes::TypeId::BOOL)
-    {
-        bool oldVal = oldValue.get<bool>();
-        sprintf(buf, "%d", oldVal);
-        javaOldValue = (env)->NewStringUTF(buf);
-
-        bool newVal = newValue.get<bool>();
-        sprintf(bufValue, "%d", newVal);
-        javaNewValue = (env)->NewStringUTF(bufValue);
-    }
-    else if (oldValueTypeId == RCSResourceAttributes::TypeId::STRING)
-    {
-        std::string oldVal = oldValue.get<std::string>();
-        javaOldValue = env->NewStringUTF(oldVal.c_str());
-
-        std::string newVal = newValue.get<std::string>();
-        javaNewValue = env->NewStringUTF(newVal.c_str());
-    }
-
-    //sending callback to application
-    jclass clsL = env->GetObjectClass(jListener);
-
-    if (!clsL)
-    {
-        checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-        return;
-    }
-
-    jmethodID midL = env->GetMethodID(clsL, "onAttributeUpdate",
-                                      "(Ljava/lang/String;Ljava/lang/String;)V");
-    if (!midL)
-    {
-        checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-        return;
-    }
-    env->CallVoidMethod(jListener, midL, javaOldValue, javaNewValue);
-    if (env->ExceptionCheck())
-    {
-        LOGE("Java exception is thrown");
-    }
-
-    if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-    LOGI("JniDiscoverResourceListener::cacheUpdatedCallback exit");
-
-}
-
-void JniAttributeUpdatedListener::checkExAndRemoveListener(JNIEnv *env)
-{
-    if (env->ExceptionCheck())
-    {
-        jthrowable ex = env->ExceptionOccurred();
-        env->ExceptionClear();
-        m_ownerResource->removeOnSetRequestListener(env, m_jwListener);
-        env->Throw((jthrowable)ex);
-    }
-    else
-    {
-        m_ownerResource->removeOnSetRequestListener(env, m_jwListener);
-    }
-}
diff --git a/service/resource-encapsulation/sdk/java/jni/re/src/jni_re_cache_update_listener.cpp b/service/resource-encapsulation/sdk/java/jni/re/src/jni_re_cache_update_listener.cpp
deleted file mode 100644 (file)
index abb42e6..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/******************************************************************
- *
- * 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 "jni_re_discover_resource_listener.h"
-#include "RCSRemoteResourceObject.h"
-#include "jni_re_cache_update_listener.h"
-
-JniCacheUpdateListener::JniCacheUpdateListener(JNIEnv *env, jobject jListener,
-        JniRCSRemoteResourceObject *owner)
-    :  m_ownerResource(owner)
-{
-    m_jwListener = env->NewWeakGlobalRef(jListener);
-}
-
-JniCacheUpdateListener::~JniCacheUpdateListener()
-{
-    LOGI("JniCacheUpdateListener::~JniCacheUpdateListener");
-    if (m_jwListener)
-    {
-        jint ret;
-        JNIEnv *env = GetREJNIEnv(ret);
-        if (NULL == env) return;
-        env->DeleteWeakGlobalRef(m_jwListener);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-    }
-}
-
-void JniCacheUpdateListener::cacheUpdatedCallback(OIC::Service::RCSResourceAttributes attributes)
-{
-    LOGI("JniDiscoverResourceListener::cacheUpdatedCallback enter");
-
-    jint ret;
-    JNIEnv *env = GetREJNIEnv(ret);
-    if (NULL == env) return;
-
-    jobject jListener = env->NewLocalRef(m_jwListener);
-    if (!jListener)
-    {
-        checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-        return;
-    }
-
-    jclass clsL = env->GetObjectClass(jListener);
-
-    if (!clsL)
-    {
-        checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-        return;
-    }
-
-    RCSResourceAttributes *attributesObj = new RCSResourceAttributes(attributes);
-    jlong handle = reinterpret_cast<jlong>(attributesObj);
-    jobject jAttributes = env->NewObject(g_cls_RCSRemoteResourceAttributesObject,
-                                         g_mid_RCSRemoteResourceAttributesObject_ctor,
-                                         handle, true);
-    if (!jAttributes)
-    {
-        delete attributesObj;
-        checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-        return;
-    }
-
-    jmethodID midL = env->GetMethodID(clsL, "onCacheUpdatedCallback",
-                                      "(Lorg/iotivity/ResourceEncapsulation/common/RCSResourceAttributes;)V");
-
-    if (!midL)
-    {
-        delete attributesObj;
-        checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-        return;
-    }
-    env->CallVoidMethod(jListener, midL, jAttributes);
-    if (env->ExceptionCheck())
-    {
-        LOGE("Java exception is thrown");
-        delete attributesObj;
-    }
-
-    if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-    LOGI("JniDiscoverResourceListener::cacheUpdatedCallback exit");
-}
-
-void JniCacheUpdateListener::checkExAndRemoveListener(JNIEnv *env)
-{
-    if (env->ExceptionCheck())
-    {
-        jthrowable ex = env->ExceptionOccurred();
-        env->ExceptionClear();
-        m_ownerResource->removeCacheUpdateListener(env, m_jwListener);
-        env->Throw((jthrowable)ex);
-    }
-    else
-    {
-        m_ownerResource->removeCacheUpdateListener(env, m_jwListener);
-    }
-}
diff --git a/service/resource-encapsulation/sdk/java/jni/re/src/jni_re_discover_resource_listener.cpp b/service/resource-encapsulation/sdk/java/jni/re/src/jni_re_discover_resource_listener.cpp
deleted file mode 100644 (file)
index 78bc742..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/******************************************************************
- *
- * 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 "RCSRemoteResourceObject.h"
-
-#include "jni_re_discover_resource_listener.h"
-
-JniDiscoverResourceListener::JniDiscoverResourceListener(JNIEnv *env, jobject jListener,
-        RemoveListenerCallback removeListenerCallback)
-{
-    m_jwListener = env->NewWeakGlobalRef(jListener);
-    m_removeListenerCallback = removeListenerCallback;
-}
-
-JniDiscoverResourceListener::~JniDiscoverResourceListener()
-{
-    LOGI("JniDiscoverResourceListener::~jni_DiscoverResourceListener()");
-    if (m_jwListener)
-    {
-        jint ret;
-        JNIEnv *env = GetREJNIEnv(ret);
-        if (NULL == env) return;
-        env->DeleteWeakGlobalRef(m_jwListener);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-    }
-}
-
-void JniDiscoverResourceListener::discoverResourceCallback(
-    std::shared_ptr<OIC::Service::RCSRemoteResourceObject> resource)
-{
-    LOGI("JniDiscoverResourceListener::discoverResourceCallback enter");
-
-    jint ret;
-    JNIEnv *env = GetREJNIEnv(ret);
-    if (NULL == env) return;
-
-    jobject jListener = env->NewLocalRef(m_jwListener);
-    if (!jListener)
-    {
-        checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-        return;
-    }
-
-    jobject jResource = env->NewObject(g_cls_RCSRemoteResourceObject,
-                                       g_mid_RCSRemoteResourceObject_ctor);
-    if (!jResource)
-    {
-        checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-        return;
-    }
-
-    JniRCSRemoteResourceObject *jniRCSRemoteResourceObject = new JniRCSRemoteResourceObject(resource);
-    RESetHandle<JniRCSRemoteResourceObject>(env, jResource, jniRCSRemoteResourceObject);
-    if (env->ExceptionCheck())
-    {
-        delete jniRCSRemoteResourceObject;
-        checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-        return;
-    }
-
-    jclass clsL = env->GetObjectClass(jListener);
-    if (!clsL)
-    {
-        delete jniRCSRemoteResourceObject;
-        checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-        return;
-    }
-    jmethodID midL = env->GetMethodID(clsL, "onResourceDiscovered",
-                                      "(Lorg/iotivity/ResourceEncapsulation/client/RCSRemoteResourceObject;)V");
-    if (!midL)
-    {
-        delete jniRCSRemoteResourceObject;
-        checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-        return;
-    }
-    env->CallVoidMethod(jListener, midL, jResource);
-    if (env->ExceptionCheck())
-    {
-        LOGE("Java exception is thrown");
-        delete jniRCSRemoteResourceObject;
-        checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-        return;
-    }
-
-    if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-    LOGI("JniDiscoverResourceListener::discoverResourceCallback exit");
-}
-
-void JniDiscoverResourceListener::checkExAndRemoveListener(JNIEnv *env)
-{
-    if (env->ExceptionCheck())
-    {
-        jthrowable ex = env->ExceptionOccurred();
-        env->ExceptionClear();
-        m_removeListenerCallback(env, m_jwListener);
-        env->Throw((jthrowable)ex);
-    }
-    else
-    {
-        m_removeListenerCallback(env, m_jwListener);
-    }
-}
diff --git a/service/resource-encapsulation/sdk/java/jni/re/src/jni_re_get_request_listener.cpp b/service/resource-encapsulation/sdk/java/jni/re/src/jni_re_get_request_listener.cpp
deleted file mode 100644 (file)
index ac4fe58..0000000
+++ /dev/null
@@ -1,184 +0,0 @@
-/******************************************************************
- *
- * 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 "jni_re_get_request_listener.h"
-#include "jni_re_resource_object.h"
-
-JniGetRequestListener::JniGetRequestListener(JNIEnv *env, jobject jListener,
-        JniRCSResourceObject *owner)
-    : m_ownerResource(owner)
-{
-    m_jwListener = env->NewWeakGlobalRef(jListener);
-}
-
-JniGetRequestListener::~JniGetRequestListener()
-{
-    LOGI("JniGetRequestListener::~JniGetRequestListener()");
-    if (m_jwListener)
-    {
-        jint ret;
-        JNIEnv *env = GetREJNIEnv(ret);
-        if (NULL == env) return;
-        env->DeleteWeakGlobalRef(m_jwListener);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-    }
-}
-
-OIC::Service::RCSGetResponse JniGetRequestListener::onGetRequestCallback(
-    OIC::Service::RCSRequest request, OIC::Service::RCSResourceAttributes attributes)
-{
-    LOGI("JniGetRequestListener::onGetRequestCallback enter");
-
-    jint ret;
-    JNIEnv *env = GetREJNIEnv(ret);
-    if (NULL == env)
-        LOGE("env is NULL");
-
-    jobject jListener = env->NewLocalRef(m_jwListener);
-    if (!jListener)
-    {
-        checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-        LOGE("jListener is NULL");
-    }
-
-    jclass clsL = env->GetObjectClass(jListener);
-
-    if (!clsL)
-    {
-        checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-        LOGE("clsL is NULL");
-    }
-
-    //constructing java attribute object
-    RCSResourceAttributes *attributesObj = new RCSResourceAttributes(attributes);
-    jlong handle = reinterpret_cast<jlong>(attributesObj);
-    jobject jAttributes = env->NewObject(g_cls_RCSRemoteResourceAttributesObject,
-                                         g_mid_RCSRemoteResourceAttributesObject_ctor,
-                                         handle, true);
-    if (!jAttributes)
-    {
-        delete attributesObj;
-        checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-        LOGI("onGetRequestCallback: jAttributes == null");
-    }
-
-    //constructing java RCSRequest object
-    std::string resourceUri = request.getResourceUri();
-    jstring javaUri = env->NewStringUTF(resourceUri.c_str());
-
-    g_mid_RCSRequest_ctor = env->GetMethodID(g_cls_RCSRequest, "<init>", "(Ljava/lang/String;)V");
-    jobject javaRCSRequestObject = env->NewObject( g_cls_RCSRequest, g_mid_RCSRequest_ctor, javaUri);
-
-    //getting the method ID
-
-    jmethodID midL = env->GetMethodID(clsL, "onGetRequest",
-  "(Lorg/iotivity/ResourceEncapsulation/server/RCSRequest;Lorg/iotivity/ResourceEncapsulation/common/RCSResourceAttributes;)Lorg/iotivity/ResourceEncapsulation/server/RCSGetResponse;");
-
-    if (!midL)
-    {
-        delete attributesObj;
-        checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-        LOGE(" midL is null");
-    }
-
-    //calling the Java method
-    jobject javaGetResponse = env->CallObjectMethod(jListener, midL, javaRCSRequestObject, jAttributes);
-
-    //getting the information related to Response
-    jclass GetResponseClass = env->GetObjectClass(javaGetResponse);
-
-    jmethodID midGetTypeOfGetResponse = env->GetMethodID(GetResponseClass, "getTypeOfGetResponse",
-                                        "()I");
-    jint type = env->CallIntMethod(javaGetResponse, midGetTypeOfGetResponse);
-
-    if (0 == type)
-    {
-        return OIC::Service::RCSGetResponse::defaultAction();
-    }
-    else if (1 == type)
-    {
-        LOGI("Type == 1");
-        jmethodID midGetResult = env->GetMethodID(GetResponseClass, "getResult", "()I");
-        jmethodID midGetErrorCode = env->GetMethodID(GetResponseClass, "getErrorCode", "()I");
-        jint handlerResult = env->CallIntMethod(javaGetResponse, midGetResult);
-        jint errorCode = env->CallIntMethod(javaGetResponse, midGetErrorCode);
-        OCEntityHandlerResult nativeHandlerResult = convertIntToOCEntityHandlerResult(handlerResult);
-        return OIC::Service::RCSGetResponse::create(nativeHandlerResult, errorCode);
-    }
-    else if (2 == type)
-    {
-        LOGI("Type == 2");
-        jmethodID midGetAttributes = env->GetMethodID(GetResponseClass, "getAttributes",
-                                     "()Lorg/iotivity/ResourceEncapsulation/common/RCSResourceAttributes;");
-        jobject attributes = env->CallObjectMethod(javaGetResponse, midGetAttributes);
-        RCSResourceAttributes *attributesObj =   JniResourceAttributes::getResourceAttributePtr(env,
-                attributes);
-        return OIC::Service::RCSGetResponse::create(*attributesObj);
-    }
-    else if (3 == type)
-    {
-        LOGI("Type == 3");
-        jmethodID midGetResult = env->GetMethodID(GetResponseClass, "getResult", "()I");
-        jmethodID midGetErrorCode = env->GetMethodID(GetResponseClass, "getErrorCode", "()I");
-        jint handlerResult = env->CallIntMethod(javaGetResponse, midGetResult);
-        jint errorCode = env->CallIntMethod(javaGetResponse, midGetErrorCode);
-        OCEntityHandlerResult nativeHandlerResult = convertIntToOCEntityHandlerResult(handlerResult);
-        jmethodID midGetAttributes = env->GetMethodID(GetResponseClass, "getAttributes",
-                                     "()Lorg/iotivity/ResourceEncapsulation/common/RCSResourceAttributes;");
-        jobject attributes = env->CallObjectMethod(javaGetResponse, midGetAttributes);
-        RCSResourceAttributes *attributesObj =   JniResourceAttributes::getResourceAttributePtr(env,
-                attributes);
-        return OIC::Service::RCSGetResponse::create(*attributesObj, nativeHandlerResult, errorCode);
-    }
-    else
-    {
-        LOGI("defaultAction");
-        return OIC::Service::RCSGetResponse::defaultAction();
-    }
-
-    if (env->ExceptionCheck())
-    {
-        LOGE("Java exception is thrown");
-        delete attributesObj;
-    }
-
-    checkExAndRemoveListener(env);
-    if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-    LOGI("JniGetRequestListener::onGetRequestCallback exit");
-}
-
-void JniGetRequestListener::checkExAndRemoveListener(JNIEnv *env)
-{
-    if (env->ExceptionCheck())
-    {
-        jthrowable ex = env->ExceptionOccurred();
-        env->ExceptionClear();
-        m_ownerResource->removeOnGetRequestListener(env, m_jwListener);
-        env->Throw((jthrowable)ex);
-    }
-    else
-    {
-        m_ownerResource->removeOnGetRequestListener(env, m_jwListener);
-    }
-}
diff --git a/service/resource-encapsulation/sdk/java/jni/re/src/jni_re_getattributes_listener.cpp b/service/resource-encapsulation/sdk/java/jni/re/src/jni_re_getattributes_listener.cpp
deleted file mode 100644 (file)
index 119e831..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-/******************************************************************
- *
- * 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 "jni_re_getattributes_listener.h"
-#include "jni_re_rcs_remoteresourceobject.h"
-
-JniGetAttributesListener::JniGetAttributesListener(JNIEnv *env, jobject jListener,
-        JniRCSRemoteResourceObject *owner)
-    : m_ownerResource(owner)
-{
-    m_jwListener = env->NewWeakGlobalRef(jListener);
-}
-
-JniGetAttributesListener::~JniGetAttributesListener()
-{
-    LOGI("JniGetAttributesListener::~JniGetAttributesListener()");
-    if (m_jwListener)
-    {
-        jint ret;
-        JNIEnv *env = GetREJNIEnv(ret);
-        if (NULL == env) return;
-        env->DeleteWeakGlobalRef(m_jwListener);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-    }
-}
-
-void JniGetAttributesListener::onRemoteAttributesGetCallback(OIC::Service::RCSResourceAttributes
-        attributes)
-{
-    LOGI("JniGetAttributesListener::onRemoteAttributesGetCallback enter");
-
-    jint ret;
-    JNIEnv *env = GetREJNIEnv(ret);
-    if (NULL == env) return;
-
-    jobject jListener = env->NewLocalRef(m_jwListener);
-    if (!jListener)
-    {
-        checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-        return;
-    }
-
-    jclass clsL = env->GetObjectClass(jListener);
-
-    if (!clsL)
-    {
-        checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-        return;
-    }
-
-    RCSResourceAttributes *attributesObj = new RCSResourceAttributes(attributes);
-    jlong handle = reinterpret_cast<jlong>(attributesObj);
-    jobject jAttributes = env->NewObject(g_cls_RCSRemoteResourceAttributesObject,
-                                         g_mid_RCSRemoteResourceAttributesObject_ctor,
-                                         handle, true);
-    if (!jAttributes)
-    {
-        delete attributesObj;
-        checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-        return;
-    }
-
-    jmethodID midL = env->GetMethodID(clsL, "onRemoteAttributesGetCallback",
-                                      "(Lorg/iotivity/ResourceEncapsulation/common/RCSResourceAttributes;)V");
-
-    if (!midL)
-    {
-        delete attributesObj;
-        checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-        return;
-    }
-    env->CallVoidMethod(jListener, midL, jAttributes);
-    if (env->ExceptionCheck())
-    {
-        LOGE("Java exception is thrown");
-        delete attributesObj;
-    }
-
-    checkExAndRemoveListener(env);
-    if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-    LOGI("JniGetAttributesListener::onRemoteAttributesGetCallback exit");
-}
-
-void JniGetAttributesListener::checkExAndRemoveListener(JNIEnv *env)
-{
-    if (env->ExceptionCheck())
-    {
-        jthrowable ex = env->ExceptionOccurred();
-        env->ExceptionClear();
-        m_ownerResource->removeOngetAttributesListener(env, m_jwListener);
-        env->Throw((jthrowable)ex);
-    }
-    else
-    {
-        m_ownerResource->removeOngetAttributesListener(env, m_jwListener);
-    }
-}
diff --git a/service/resource-encapsulation/sdk/java/jni/re/src/jni_re_rcs_bundle_info.cpp b/service/resource-encapsulation/sdk/java/jni/re/src/jni_re_rcs_bundle_info.cpp
deleted file mode 100644 (file)
index 873058e..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/******************************************************************
- *
- * 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 "jni_re_rcs_bundle_info.h"
-#include "jni_re_jvm.h"
-#include "jni_re_utils.h"
-
-using namespace OIC::Service;
-
-RCSBundleInfo *JniBundleInfo::getRCSBundleInfoPtr(JNIEnv *env, jobject interfaceObject)
-{
-    RCSBundleInfo *rep = REGetHandle<RCSBundleInfo>(env, interfaceObject);
-    if (env->ExceptionCheck())
-    {
-        LOGE("Failed to get native handle from RCSBundleInfo");
-    }
-    if (!rep)
-    {
-        throwRCSException(env, "JNI no native pointer");
-    }
-    return rep;
-}
-
-JNIEXPORT jstring JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSBundleInfo_nativeGetID
-(JNIEnv *env, jobject jObject)
-{
-    LOGI("RCSBundleInfo_nativeGetID");
-    RCSBundleInfo *bundleInfo = JniBundleInfo::getRCSBundleInfoPtr(env, jObject);
-    std::string nativeId = bundleInfo->getID();
-    return env->NewStringUTF(nativeId.c_str());
-}
-
-JNIEXPORT jstring JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSBundleInfo_nativeGetPath
-(JNIEnv *env, jobject jObject)
-{
-    LOGI("RCSBundleInfo_nativeGetPath");
-    RCSBundleInfo *bundleInfo = JniBundleInfo::getRCSBundleInfoPtr(env, jObject);
-    std::string nativePath = bundleInfo->getPath();
-    return env->NewStringUTF(nativePath.c_str());
-}
-
-JNIEXPORT jstring JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSBundleInfo_nativeGetActivatorName
-(JNIEnv *env, jobject jObject)
-{
-    LOGI("RCSBundleInfo_nativeGetActivatorName");
-    RCSBundleInfo *bundleInfo = JniBundleInfo::getRCSBundleInfoPtr(env, jObject);
-    std::string nativeActivatorName = bundleInfo->getActivatorName();
-    return env->NewStringUTF(nativeActivatorName.c_str());
-}
-
-JNIEXPORT jstring JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSBundleInfo_nativeGetLibraryPath
-(JNIEnv *env, jobject jObject)
-{
-    LOGI("RCSBundleInfo_nativeGetLibraryPath");
-    RCSBundleInfo *bundleInfo = JniBundleInfo::getRCSBundleInfoPtr(env, jObject);
-    std::string nativeGetLibraryPath = bundleInfo->getLibraryPath();
-    return env->NewStringUTF(nativeGetLibraryPath.c_str());
-}
-
-JNIEXPORT jstring JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSBundleInfo_nativeGetVersion
-(JNIEnv *env, jobject jObject)
-{
-    LOGI("RCSBundleInfo_nativeGetVersion");
-    RCSBundleInfo *bundleInfo = JniBundleInfo::getRCSBundleInfoPtr(env, jObject);
-    std::string nativeGetVersion = bundleInfo->getVersion();
-    return env->NewStringUTF(nativeGetVersion.c_str());
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSBundleInfo_nativeSetID
-(JNIEnv *env, jobject jObject, jstring jId)
-{
-    LOGI("RCSBundleInfo_nativeSetID");
-    std::string id = env->GetStringUTFChars(jId, NULL);
-    RCSBundleInfo *bundleInfo = JniBundleInfo::getRCSBundleInfoPtr(env, jObject);
-    bundleInfo->setID(id);
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSBundleInfo_nativeSetPath
-(JNIEnv *env, jobject jObject, jstring jPath)
-{
-    LOGI("RCSBundleInfo_nativeSetPath");
-    std::string path = env->GetStringUTFChars(jPath, NULL);
-    RCSBundleInfo *bundleInfo = JniBundleInfo::getRCSBundleInfoPtr(env, jObject);
-    bundleInfo->setPath(path);
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSBundleInfo_nativeSetActivatorName
-(JNIEnv *env, jobject jObject, jstring jActivatorName)
-{
-    LOGI("RCSBundleInfo_nativeSetActivatorName");
-    std::string activatorName = env->GetStringUTFChars(jActivatorName, NULL);
-    RCSBundleInfo *bundleInfo = JniBundleInfo::getRCSBundleInfoPtr(env, jObject);
-    bundleInfo->setActivatorName(activatorName);
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSBundleInfo_nativeSetLibraryPath
-(JNIEnv *env, jobject jObject, jstring jLibraryPath)
-{
-    LOGI("RCSBundleInfo_nativeSetLibraryPath");
-    std::string libraryPath = env->GetStringUTFChars(jLibraryPath, NULL);
-    RCSBundleInfo *bundleInfo = JniBundleInfo::getRCSBundleInfoPtr(env, jObject);
-    bundleInfo->setLibraryPath(libraryPath);
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSBundleInfo_nativeSetVersion
-(JNIEnv *env, jobject jObject, jstring jVersion)
-{
-    LOGI("RCSBundleInfo_nativeSetVersion");
-    std::string version = env->GetStringUTFChars(jVersion, NULL);
-    RCSBundleInfo *bundleInfo = JniBundleInfo::getRCSBundleInfoPtr(env, jObject);
-    bundleInfo->setVersion(version);
-}
-
diff --git a/service/resource-encapsulation/sdk/java/jni/re/src/jni_re_rcs_discovery_manager.cpp b/service/resource-encapsulation/sdk/java/jni/re/src/jni_re_rcs_discovery_manager.cpp
deleted file mode 100644 (file)
index 4476458..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-/******************************************************************
- *
- * 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 "jni_re_rcs_discovery_manager.h"
-
-#include "RCSDiscoveryManager.h"
-#include "RCSAddress.h"
-
-using namespace OIC::Service;
-
-JniDiscoverResourceListener *AddDiscoverResourceListener(JNIEnv *env, jobject jListener)
-{
-    JniDiscoverResourceListener *onResourceDiscovered = NULL;
-
-    discoverResourceMapLock.lock();
-
-    for (auto it = discoverResourceListenerMap.begin(); it != discoverResourceListenerMap.end(); ++it)
-    {
-        if (env->IsSameObject(jListener, it->first))
-        {
-            auto refPair = it->second;
-            onResourceDiscovered = refPair.first;
-            refPair.second++;
-            it->second = refPair;
-            discoverResourceListenerMap.insert(*it);
-            LOGD("onResourceDiscovered: ref. count incremented");
-            break;
-        }
-    }
-
-    if (!onResourceDiscovered)
-    {
-        onResourceDiscovered = new JniDiscoverResourceListener(env, jListener,
-                RemoveDiscoverResourceListener);
-        jobject jgListener = env->NewGlobalRef(jListener);
-
-        discoverResourceListenerMap.insert(std::pair < jobject, std::pair < JniDiscoverResourceListener *,
-                                           int >> (jgListener, std::pair<JniDiscoverResourceListener *, int>(onResourceDiscovered, 1)));
-        LOGD("onResourceDiscovered: new listener");
-    }
-    discoverResourceMapLock.unlock();
-    return onResourceDiscovered;
-}
-
-void RemoveDiscoverResourceListener(JNIEnv *env, jobject jListener)
-{
-    discoverResourceMapLock.lock();
-
-    for (auto it = discoverResourceListenerMap.begin(); it != discoverResourceListenerMap.end(); ++it)
-    {
-        if (env->IsSameObject(jListener, it->first))
-        {
-            auto refPair = it->second;
-            if (refPair.second > 1)
-            {
-                refPair.second--;
-                it->second = refPair;
-                discoverResourceListenerMap.insert(*it);
-                LOGI("OnResourceDiscoveredListener: ref. count decremented");
-            }
-            else
-            {
-                env->DeleteGlobalRef(it->first);
-                JniDiscoverResourceListener *listener = refPair.first;
-                delete listener;
-                discoverResourceListenerMap.erase(it);
-                LOGI("OnResourceDiscoveredListener removed");
-            }
-            break;
-        }
-    }
-    discoverResourceMapLock.unlock();
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSDiscoveryManager_discoverResource
-(JNIEnv *env, jclass interfaceClass, jstring jAddress, jint jTypeofDiscovery, jstring jRelativeURI,
- jstring jresourceType, jobject jDiscoveryListener)
-{
-    LOGI("NativeInterface_discoverResource entry");
-    std::string address;
-    if (jAddress)
-    {
-        address = env->GetStringUTFChars(jAddress, NULL);
-    }
-    std::string relativeUri;
-    if (jRelativeURI)
-    {
-        relativeUri = env->GetStringUTFChars(jRelativeURI, NULL);
-    }
-    std::string resourceType;
-    if (jresourceType)
-    {
-        resourceType = env->GetStringUTFChars(jresourceType, NULL);
-    }
-
-    JniDiscoverResourceListener *onResFoundListener = AddDiscoverResourceListener(env,
-            jDiscoveryListener);
-    LOGI("NativeInterface_discoverResource onResFoundListener added");
-    RCSDiscoveryManager::ResourceDiscoveredCallback discoverCallback = [onResFoundListener](
-                std::shared_ptr< OIC::Service::RCSRemoteResourceObject> resource)
-    {
-        onResFoundListener->discoverResourceCallback(resource);
-    };
-    if ( 1 == jTypeofDiscovery )
-    {
-        RCSDiscoveryManager::getInstance()->discoverResourceByType(RCSAddress::multicast(), relativeUri,
-                resourceType, discoverCallback);
-        LOGI("NativeInterface_discoverResource multicast");
-    }
-    else if ( 0 == jTypeofDiscovery)
-    {
-        RCSDiscoveryManager::getInstance()->discoverResourceByType(RCSAddress::unicast(address),
-                relativeUri, resourceType, discoverCallback );
-        LOGI("NativeInterface_discoverResource unicast");
-    }
-
-    LOGI("NativeInterface_discoverResource exit");
-
-}
diff --git a/service/resource-encapsulation/sdk/java/jni/re/src/jni_re_rcs_remoteresourceobject.cpp b/service/resource-encapsulation/sdk/java/jni/re/src/jni_re_rcs_remoteresourceobject.cpp
deleted file mode 100644 (file)
index e4e4932..0000000
+++ /dev/null
@@ -1,535 +0,0 @@
-/******************************************************************
- *
- * 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 "jni_re_rcs_remoteresourceobject.h"
-
-using namespace OIC::Service;
-JniRCSRemoteResourceObject::JniRCSRemoteResourceObject(std::shared_ptr< RCSRemoteResourceObject>
-        resource)
-    : m_sharedResource(resource)
-{}
-
-JniRCSRemoteResourceObject::~JniRCSRemoteResourceObject()
-{
-    LOGD("JniRCSRemoteResourceObject::~JniOcResource()");
-    m_sharedResource = NULL;
-
-    jint envRet;
-    JNIEnv *env = GetREJNIEnv(envRet);
-    if (NULL == env) return;
-
-    if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
-}
-
-JniRCSRemoteResourceObject *JniRCSRemoteResourceObject::getJniRCSRemoteResourceObject(JNIEnv *env,
-        jobject thiz)
-{
-    JniRCSRemoteResourceObject *resource = REGetHandle<JniRCSRemoteResourceObject>(env, thiz);
-    if (env->ExceptionCheck())
-    {
-        LOGE("Failed to get native handle from RCSRemoteResourceObject");
-    }
-    if (!resource)
-    {
-        LOGE("getJniRCSRemoteResourceObject :: no resource");
-    }
-    return resource;
-}
-
-std::string JniRCSRemoteResourceObject::getUri()
-{
-    return m_sharedResource->getUri();
-}
-
-std::string JniRCSRemoteResourceObject::getAddress()
-{
-    return m_sharedResource->getAddress();
-}
-
-jobject JniRCSRemoteResourceObject::getTypes(JNIEnv *env)
-{
-    return convertStrVectorToJavaStrList( env, m_sharedResource->getTypes());
-}
-
-jobject JniRCSRemoteResourceObject::getInterfaces(JNIEnv *env)
-{
-    return convertStrVectorToJavaStrList(env, m_sharedResource->getInterfaces());
-}
-
-bool JniRCSRemoteResourceObject::isMonitoring()
-{
-    return m_sharedResource->isMonitoring();
-}
-
-bool JniRCSRemoteResourceObject::isCaching()
-{
-    return m_sharedResource->isCaching();
-}
-
-bool JniRCSRemoteResourceObject::isObservable()
-{
-    return m_sharedResource->isObservable();
-}
-
-bool JniRCSRemoteResourceObject::isCachedAvailable()
-{
-    return m_sharedResource->isCachedAvailable();
-}
-
-int JniRCSRemoteResourceObject::getState()
-{
-    ResourceState state = m_sharedResource->getState();
-    return covertResourceStateToInt(state);
-}
-
-int JniRCSRemoteResourceObject::getCacheState()
-{
-    CacheState state = m_sharedResource->getCacheState();
-    return convertCacheStateToInt(state);
-}
-
-void JniRCSRemoteResourceObject::startMonitoring(JNIEnv *env, jobject jListener)
-{
-
-    try
-    {
-        JniResourceStateChangeListener *onResourceStateChanged = addOnStateChangeListener(env, jListener);
-        RCSRemoteResourceObject::StateChangedCallback stateChangecb = [onResourceStateChanged](
-                    OIC::Service::ResourceState state)
-        {
-            onResourceStateChanged->stateChangeCallback(state);
-        };
-        m_sharedResource->startMonitoring(stateChangecb);
-    }
-    catch (InvalidParameterException exception)
-    {
-        LOGE("native startMonitoring InvalidParameterException");
-        throwRCSException(env,  exception.what());
-    }
-    catch (BadRequestException exception)
-    {
-        LOGE("native startMonitoring : BadRequestException ");
-        throwRCSException(env,  exception.what());
-    }
-
-}
-
-void  JniRCSRemoteResourceObject::stopMonitoring()
-{
-    m_sharedResource->stopMonitoring();
-}
-
-void JniRCSRemoteResourceObject::startCaching(JNIEnv *env, jobject jListener)
-{
-    JniCacheUpdateListener *onCacheUpdated = addOnCacheUpdateListener(env, jListener);
-    RCSRemoteResourceObject::CacheUpdatedCallback cacheUpdatedCallback = [onCacheUpdated](
-                OIC::Service::RCSResourceAttributes attributes)
-    {
-        onCacheUpdated->cacheUpdatedCallback(attributes);
-    };
-    try
-    {
-        m_sharedResource->startCaching(cacheUpdatedCallback);
-    }
-    catch (BadRequestException exception)
-    {
-        throwRCSException(env,  exception.what());
-    }
-
-}
-
-void JniRCSRemoteResourceObject::startCaching(JNIEnv *env)
-{
-    try
-    {
-        m_sharedResource->startCaching();
-    }
-    catch (BadRequestException exception)
-    {
-        throwRCSException(env,  exception.what());
-    }
-}
-
-void JniRCSRemoteResourceObject::stopCaching()
-{
-    m_sharedResource->stopCaching();
-}
-
-void JniRCSRemoteResourceObject::getRemoteAttributes(JNIEnv *env, jobject jListener)
-{
-    JniGetAttributesListener *onGetAttributes = addOngetAttributesListener(env, jListener);
-    RCSRemoteResourceObject::RemoteAttributesGetCallback getArributescb = [onGetAttributes](
-                OIC::Service::RCSResourceAttributes attributes)
-    {
-        onGetAttributes->onRemoteAttributesGetCallback(attributes);
-    };
-    m_sharedResource->getRemoteAttributes(getArributescb);
-}
-
-void JniRCSRemoteResourceObject::setRemoteAttributes(JNIEnv *env, jobject attributes,
-        jobject jListener)
-{
-    JniSetAttributesListener *onSetAttributes = addOnsetAttributesListener(env, jListener);
-    RCSRemoteResourceObject::RemoteAttributesSetCallback setArributescb = [onSetAttributes](
-                OIC::Service::RCSResourceAttributes attribute)
-    {
-        onSetAttributes->onRemoteAttributesSetCallback(attribute);
-    };
-    RCSResourceAttributes *attributesObj =   JniResourceAttributes::getResourceAttributePtr(env,
-            attributes);
-    m_sharedResource->setRemoteAttributes(*attributesObj, setArributescb);
-}
-
-
-jobject JniRCSRemoteResourceObject::getCachedAttributes(JNIEnv *env)
-{
-    try
-    {
-        RCSResourceAttributes attributes = m_sharedResource->getCachedAttributes();
-        RCSResourceAttributes *attributesObj = new RCSResourceAttributes(attributes);
-        jlong handle = reinterpret_cast<jlong>(attributesObj);
-        jobject jAttributes = env->NewObject(g_cls_RCSRemoteResourceAttributesObject,
-                                             g_mid_RCSRemoteResourceAttributesObject_ctor,
-                                             handle, true);
-        return jAttributes;
-    }
-    catch (BadRequestException exception)
-    {
-        throwRCSException(env,  exception.what());
-    }
-}
-
-jstring JniRCSRemoteResourceObject::getCachedAttribute(JNIEnv *env, jstring jkey,
-        jobject interfaceObject )
-{
-    const char *str = env->GetStringUTFChars(jkey , NULL);
-    std::string s(str);
-    char buf[64]; // assumed large enough to cope with result
-    env->ReleaseStringUTFChars(jkey, str);
-    RCSResourceAttributes::Value value;
-    RCSResourceAttributes::TypeId typeId;
-    try
-    {
-        value =  m_sharedResource->getCachedAttribute(s);
-        typeId = value.getType().getId();
-    }
-    catch (BadRequestException exception)
-    {
-        throwRCSException(env,  exception.what());
-    }
-
-    if (typeId == RCSResourceAttributes::TypeId::INT)
-    {
-        int val = value.get<int>();
-        sprintf(buf, "%d", val);
-        return (env)->NewStringUTF(buf);
-    }
-    else if (typeId == RCSResourceAttributes::TypeId::DOUBLE)
-    {
-        double val = value.get<double>();
-        sprintf(buf, "%f", val);
-        return (env)->NewStringUTF(buf);
-    }
-    else if (typeId == RCSResourceAttributes::TypeId::BOOL)
-    {
-        bool val = value.get<bool>();
-        sprintf(buf, "%d", val);
-        return (env)->NewStringUTF(buf);
-    }
-    else if (typeId == RCSResourceAttributes::TypeId::STRING)
-    {
-        std::string val = value.get<std::string>();
-        jstring jstr = env->NewStringUTF(val.c_str());
-        return jstr;
-    }
-}
-JniResourceStateChangeListener *JniRCSRemoteResourceObject::addOnStateChangeListener(JNIEnv *env,
-        jobject jListener)
-{
-    return this->m_onStateChange.addListener(env, jListener, this);
-}
-
-JniCacheUpdateListener *JniRCSRemoteResourceObject::addOnCacheUpdateListener(JNIEnv *env,
-        jobject jListener)
-{
-    return this->m_onCacheUpdateChange.addListener(env, jListener, this);
-}
-
-JniGetAttributesListener *JniRCSRemoteResourceObject::addOngetAttributesListener(JNIEnv *env,
-        jobject jListener)
-{
-    return this->m_ongetAttributes.addListener(env, jListener, this);
-}
-
-JniSetAttributesListener *JniRCSRemoteResourceObject::addOnsetAttributesListener(JNIEnv *env,
-        jobject jListener)
-{
-    return this->m_onsetAttributes.addListener(env, jListener, this);
-}
-
-void JniRCSRemoteResourceObject::removeOnStateChangeListener(JNIEnv *env, jobject jListener)
-{
-    this->m_onStateChange.removeListener(env, jListener);
-}
-
-void JniRCSRemoteResourceObject::removeCacheUpdateListener(JNIEnv *env, jobject jListener)
-{
-    this->m_onCacheUpdateChange.removeListener(env, jListener);
-}
-
-void JniRCSRemoteResourceObject::removeOngetAttributesListener(JNIEnv *env, jobject jListener)
-{
-    this->m_ongetAttributes.removeListener(env, jListener);
-}
-
-void JniRCSRemoteResourceObject::removeOnsetAttributesListener(JNIEnv *env, jobject jListener)
-{
-    this->m_onsetAttributes.removeListener(env, jListener);
-}
-
-JNIEXPORT jboolean JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeIsMonitoring
-(JNIEnv *env, jobject interfaceClass)
-{
-    LOGD("RCSRemoteResourceObject_nativeIsMonitoring");
-    JniRCSRemoteResourceObject *resource = JniRCSRemoteResourceObject::getJniRCSRemoteResourceObject(
-            env, interfaceClass);
-    return (jboolean)resource->isMonitoring();
-}
-
-JNIEXPORT jboolean JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeIsCaching
-(JNIEnv *env, jobject interfaceClass)
-{
-
-    LOGD("RCSRemoteResourceObject_nativeIsCaching");
-    JniRCSRemoteResourceObject *resource = JniRCSRemoteResourceObject::getJniRCSRemoteResourceObject(
-            env, interfaceClass);
-    return (jboolean)resource->isCaching();
-}
-
-JNIEXPORT jboolean JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeIsObservable
-(JNIEnv *env, jobject interfaceClass)
-{
-    LOGD("RCSRemoteResourceObject_nativeIsObservable");
-    JniRCSRemoteResourceObject *resource = JniRCSRemoteResourceObject::getJniRCSRemoteResourceObject(
-            env, interfaceClass);
-    return (jboolean)resource->isObservable();
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeStartMonitoring
-(JNIEnv *env, jobject interfaceClass, jobject jStateChangedListener)
-{
-
-    if (!jStateChangedListener)
-    {
-        LOGE("RCSRemoteResourceObject_nativeStartMonitoring : listener is NULL");
-        throwRCSException(env,  "Invalid parameter");
-        return;
-    }
-    LOGD("RCSRemoteResourceObject_nativeStartMonitoring");
-    JniRCSRemoteResourceObject *resource = JniRCSRemoteResourceObject::getJniRCSRemoteResourceObject(
-            env, interfaceClass);
-    if (!resource) return;
-
-    resource->startMonitoring(env, jStateChangedListener);
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeStopMonitoring
-(JNIEnv *env, jobject interfaceClass)
-{
-    LOGD("RCSRemoteResourceObject_nativeStopMonitoring");
-    JniRCSRemoteResourceObject *resource = JniRCSRemoteResourceObject::getJniRCSRemoteResourceObject(
-            env, interfaceClass);
-    resource->stopMonitoring();
-}
-
-JNIEXPORT jint JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeGetState
-(JNIEnv *env, jobject interfaceClass)
-{
-    LOGD("RCSRemoteResourceObject_nativeGetState");
-    JniRCSRemoteResourceObject *resource = JniRCSRemoteResourceObject::getJniRCSRemoteResourceObject(
-            env, interfaceClass);
-    return (jint)resource->getState();
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeStartCaching
-(JNIEnv *env, jobject interfaceClass, jobject jCacheUpdateListener)
-{
-    LOGD("RCSRemoteResourceObject_nativeStartCaching");
-    JniRCSRemoteResourceObject *resource = JniRCSRemoteResourceObject::getJniRCSRemoteResourceObject(
-            env, interfaceClass);
-    if (!resource) return;
-    if (NULL == jCacheUpdateListener)
-    {
-        resource->startCaching(env);
-    }
-    else
-    {
-        resource->startCaching(env, jCacheUpdateListener);
-    }
-}
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeStopCaching
-(JNIEnv *env, jobject interfaceClass)
-{
-    LOGD("RCSRemoteResourceObject_nativeStopCaching");
-    JniRCSRemoteResourceObject *resource = JniRCSRemoteResourceObject::getJniRCSRemoteResourceObject(
-            env, interfaceClass);
-    resource->stopCaching();
-}
-
-JNIEXPORT jint JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeGetCacheState
-(JNIEnv *env, jobject interfaceClass)
-{
-    LOGD("RCSRemoteResourceObject_nativeGetCacheState");
-    JniRCSRemoteResourceObject *resource = JniRCSRemoteResourceObject::getJniRCSRemoteResourceObject(
-            env, interfaceClass);
-    return (jint)resource->getCacheState();
-}
-
-JNIEXPORT jboolean JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeIsCachedAvailable
-(JNIEnv *env, jobject interfaceClass)
-{
-
-    LOGD("RCSRemoteResourceObject_nativeIsMonitoring");
-    JniRCSRemoteResourceObject *resource = JniRCSRemoteResourceObject::getJniRCSRemoteResourceObject(
-            env, interfaceClass);
-    return (jboolean)resource->isCachedAvailable();
-}
-
-JNIEXPORT jobject JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeGetCachedAttributes
-(JNIEnv *env, jobject interfaceClass)
-{
-    LOGD("RCSRemoteResourceObject_nativeGetCachedAttributes");
-    JniRCSRemoteResourceObject *resource = JniRCSRemoteResourceObject::getJniRCSRemoteResourceObject(
-            env, interfaceClass);
-    return resource->getCachedAttributes(env);
-}
-
-JNIEXPORT jstring JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeGetCachedAttribute
-(JNIEnv *env, jobject interfaceClass, jstring jKey)
-{
-    if (!jKey)
-    {
-        LOGE("RCSRemoteResourceObject_nativeGetCachedAttributes : key is NULL");
-        throwRCSException(env,  "Key is empty");
-        return NULL;
-    }
-    LOGD("RCSRemoteResourceObject_nativeGetRemoteAttributes");
-    JniRCSRemoteResourceObject *resource = JniRCSRemoteResourceObject::getJniRCSRemoteResourceObject(
-            env, interfaceClass);
-    return resource->getCachedAttribute(env, jKey, interfaceClass);
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeGetRemoteAttributes
-(JNIEnv *env, jobject interfaceClass, jobject jResourceAttributesListener)
-{
-    LOGD("RCSRemoteResourceObject_nativeGetRemoteAttributes");
-    if (!jResourceAttributesListener)
-    {
-        LOGE("RCSRemoteResourceObject_nativeGetRemoteAttributes: listener is NULL");
-        throwRCSException(env,  "Invalid parameter");
-        return;
-    }
-    JniRCSRemoteResourceObject *resource = JniRCSRemoteResourceObject::getJniRCSRemoteResourceObject(
-            env, interfaceClass);
-    if (!resource) return;
-
-    resource->getRemoteAttributes(env, jResourceAttributesListener);
-}
-
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeSetRemoteAttributes
-(JNIEnv *env, jobject interfaceClass, jobject jresourceAttribute,
- jobject jResourceAttributesListener)
-{
-    LOGD("RCSRemoteResourceObject_nativeSetRemoteAttributes");
-    if (!jResourceAttributesListener)
-    {
-        LOGE("RCSRemoteResourceObject_nativeSetRemoteAttributes: listener is NULL");
-        throwRCSException(env,  "Invalid parameter");
-        return;
-    }
-    JniRCSRemoteResourceObject *resource = JniRCSRemoteResourceObject::getJniRCSRemoteResourceObject(
-            env, interfaceClass);
-    if (!resource) return;
-
-    resource->setRemoteAttributes(env, jresourceAttribute, jResourceAttributesListener);
-}
-
-JNIEXPORT jstring JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeGetUri
-(JNIEnv *env, jobject interfaceClass)
-{
-    LOGD("JNI RCSRemoteResourceObjectNativeInterface_getUri");
-    JniRCSRemoteResourceObject *resource = JniRCSRemoteResourceObject::getJniRCSRemoteResourceObject(
-            env, interfaceClass);
-    if (!resource) return nullptr;
-
-    return env->NewStringUTF(resource->getUri().c_str());
-}
-
-JNIEXPORT jstring JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeGetAddress
-(JNIEnv *env, jobject interfaceClass)
-{
-    LOGD("RCSRemoteResourceObject_nativeGetAddress");
-    JniRCSRemoteResourceObject *resource = JniRCSRemoteResourceObject::getJniRCSRemoteResourceObject(
-            env, interfaceClass);
-    if (!resource) return nullptr;
-
-    return env->NewStringUTF(resource->getAddress().c_str());
-}
-
-JNIEXPORT jobject JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeGetTypes
-(JNIEnv *env, jobject interfaceClass)
-{
-    LOGD("RCSRemoteResourceObject_nativeGetTypes");
-    JniRCSRemoteResourceObject *resource = JniRCSRemoteResourceObject::getJniRCSRemoteResourceObject(
-            env, interfaceClass);
-    if (!resource) return nullptr;
-    return resource->getTypes(env);
-}
-
-JNIEXPORT jobject JNICALL
-Java_org_iotivity_ResourceEncapsulation_client_RCSRemoteResourceObject_nativeGetInterFaces
-(JNIEnv *env, jobject interfaceClass)
-{
-
-    LOGD("RCSRemoteResourceObject_nativeGetInterFaces");
-    JniRCSRemoteResourceObject *resource = JniRCSRemoteResourceObject::getJniRCSRemoteResourceObject(
-            env, interfaceClass);
-    if (!resource) return nullptr;
-    return resource->getInterfaces(env);
-}
-
diff --git a/service/resource-encapsulation/sdk/java/jni/re/src/jni_re_rcs_resource_container.cpp b/service/resource-encapsulation/sdk/java/jni/re/src/jni_re_rcs_resource_container.cpp
deleted file mode 100644 (file)
index ce739f8..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-/******************************************************************
- *
- * 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 "jni_re_rcs_resource_container.h"
-#include "jni_re_utils.h"
-#include "RCSResourceContainer.h"
-#include "RCSBundleInfo.h"
-
-using namespace OIC::Service;
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceContainer_nativeStartContainer
-(JNIEnv *env, jobject jObject, jstring configFile)
-{
-    LOGD("RCSResourceContainer_nativeStartContainer");
-    RCSResourceContainer *container = RCSResourceContainer::getInstance();
-    std::string nativeFilePath = env->GetStringUTFChars(configFile, NULL);
-    container->startContainer(nativeFilePath);
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceContainer_nativeStopContainer
-(JNIEnv *env, jobject jObject)
-{
-    LOGD("RCSResourceContainer_nativeStopContainers");
-    RCSResourceContainer *container = RCSResourceContainer::getInstance();
-    container->stopContainer();
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceContainer_nativeAddBundle
-(JNIEnv *env, jobject jObject, jstring jBundleId, jstring jBundleUri, jstring jBundlePath,
- jobject jParams)
-{
-    LOGD("RCSResourceContainer_nativeAddBundle");
-    std::string bundleId = env->GetStringUTFChars(jBundleId, NULL);
-    std::string bundleUri = env->GetStringUTFChars(jBundleUri, NULL);
-    std::string bundlePath = env->GetStringUTFChars(jBundlePath, NULL);
-
-    std::map<std::string, std::string> params;
-    //convert java map to native param map
-    convertJavaMapToParamsMap(env, jParams, params);
-
-    RCSResourceContainer *container = RCSResourceContainer::getInstance();
-    container->addBundle(bundleId, bundleUri, bundlePath, params);
-}
-
-JNIEXPORT jobject JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceContainer_nativeListBundles
-(JNIEnv *env, jobject jObject)
-{
-    LOGD("RCSResourceContainer_nativeListBundles");
-
-    RCSResourceContainer *container = RCSResourceContainer::getInstance();
-    std::list<RCSBundleInfo *> nativeBundleInfoList = container->listBundles();
-
-    if (nativeBundleInfoList.size() == 0)
-    {
-        LOGD("RCSResourceContainer_nativeListBundles size of bundle list is zerooooo");
-    }
-    else
-    {
-        LOGD("RCSResourceContainer_nativeListBundles size of bundle list is not zerooooo");
-    }
-    //conversion from native list bundle to java list bundle...
-    jobject jList = env->NewObject(g_cls_LinkedList, g_mid_LinkedList_ctor);
-    if (!jList) return nullptr;
-
-    std::list<RCSBundleInfo *>::iterator bundleIt;
-
-    for (bundleIt = nativeBundleInfoList.begin(); bundleIt != nativeBundleInfoList.end(); bundleIt++)
-    {
-        jlong handle = reinterpret_cast<jlong>(*bundleIt);
-
-        //set native handle
-        jclass clazz = env->FindClass("org/iotivity/ResourceEncapsulation/server/RCSBundleInfo");
-        jfieldID fid =  env->GetFieldID(clazz, "m_nativeHandle", "J");
-
-        //create java RCSBundleInfo Object
-        jobject resourceObj = (jobject) env->NewObject(g_cls_RCSBundleInfo, g_mid_RCSBundleInfo_ctor,
-                              handle);
-
-        env->CallBooleanMethod(jList, g_mid_LinkedList_add_object, resourceObj);
-
-        if (env->ExceptionCheck()) return nullptr;
-        env->DeleteLocalRef(resourceObj);
-    }
-    return jList ;
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceContainer_nativeRemoveBundle
-(JNIEnv *env, jobject jObject, jstring jBundleId)
-{
-    LOGD("RCSResourceContainer_nativeRemoveBundle");
-    std::string bundleId = env->GetStringUTFChars(jBundleId, NULL);
-    RCSResourceContainer *container = RCSResourceContainer::getInstance();
-    container->removeBundle(bundleId);
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceContainer_nativeStartBundle
-(JNIEnv *env, jobject jObject, jstring jBundleId)
-{
-    LOGD("RCSResourceContainer_nativeStartBundle");
-    std::string bundleId = env->GetStringUTFChars(jBundleId, NULL);
-    RCSResourceContainer *container = RCSResourceContainer::getInstance();
-    container->startBundle(bundleId);
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceContainer_nativeStopBundle
-(JNIEnv *env, jobject jObject, jstring jBundleId)
-{
-    LOGD("RCSResourceContainer_nativeStopBundle");
-    std::string bundleId = env->GetStringUTFChars(jBundleId, NULL);
-    RCSResourceContainer *container = RCSResourceContainer::getInstance();
-    container->stopBundle(bundleId);
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceContainer_nativeAddResourceConfig
-(JNIEnv *env, jobject jObject, jstring jBundleId, jstring jResourceUri, jobject jParams)
-{
-    LOGD("RCSResourceContainer_nativeAddResourceConfig");
-    std::string bundleId = env->GetStringUTFChars(jBundleId, NULL);
-    std::string resourceUri = env->GetStringUTFChars(jResourceUri, NULL);
-
-    std::map<std::string, std::string> params;
-    //convert java map to native param map
-    convertJavaMapToParamsMap(env, jParams, params);
-
-    RCSResourceContainer *container = RCSResourceContainer::getInstance();
-    container->addResourceConfig(bundleId, resourceUri, params);
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceContainer_nativeRemoveResourceConfig
-(JNIEnv *env, jobject jObject, jstring jBundleId, jstring jResourceUri)
-{
-    LOGD("RCSResourceContainer_nativeRemoveResourceConfig");
-    std::string bundleId = env->GetStringUTFChars(jBundleId, NULL);
-    std::string resourceUri = env->GetStringUTFChars(jResourceUri, NULL);
-    RCSResourceContainer *container = RCSResourceContainer::getInstance();
-    container->removeResourceConfig(bundleId, resourceUri);
-}
-
-JNIEXPORT jobject JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceContainer_nativeListBundleResources
-(JNIEnv *env, jobject jObject, jstring jBundleId)
-{
-    LOGD("RCSResourceContainer_nativeListBundleResources");
-    std::string bundleId = env->GetStringUTFChars(jBundleId, NULL);
-    RCSResourceContainer *container = RCSResourceContainer::getInstance();
-    std::list<std::string> nativeList = container->listBundleResources(bundleId);
-    return convertStrListToJavaStrList(env, nativeList);
-}
-
diff --git a/service/resource-encapsulation/sdk/java/jni/re/src/jni_re_resource_attributes.cpp b/service/resource-encapsulation/sdk/java/jni/re/src/jni_re_resource_attributes.cpp
deleted file mode 100644 (file)
index b26eaf3..0000000
+++ /dev/null
@@ -1,763 +0,0 @@
-/******************************************************************
- *
- * 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 "jni_re_resource_attributes.h"
-#include "jni_re_jvm.h"
-
-using namespace std;
-
-RCSResourceAttributes *JniResourceAttributes::getResourceAttributePtr(JNIEnv *env,
-        jobject interfaceObject)
-{
-    RCSResourceAttributes *rep = REGetHandle<RCSResourceAttributes>(env, interfaceObject);
-    if (env->ExceptionCheck())
-    {
-        LOGE("Failed to get native handle from RCSResourceAttributes");
-    }
-    if (!rep)
-    {
-        throwRCSException(env, "JNI no native pointer");
-    }
-    return rep;
-}
-
-JNIEXPORT jobject JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeGetValueN
-(JNIEnv *env, jobject interfaceObject, jstring jKey, jint dataType)
-{
-    LOGD("RCSResourceAttributes_nativeGetValueN");
-    if (!jKey)
-    {
-        throwRCSException(env, "attributeKey cannot be null");
-        return nullptr;
-    }
-
-    RCSResourceAttributes *rep = JniResourceAttributes::getResourceAttributePtr(env, interfaceObject);
-    if (!rep) return nullptr;
-
-    std::string key = env->GetStringUTFChars(jKey, NULL);
-    if (!(rep->contains(key)))
-    {
-        throwRCSException(env, "Key not Found");
-    }
-    else
-    {
-        RCSResourceAttributes::Value attrValue = rep->at(key);
-        jobject jobj;
-
-        if (0 == dataType)
-        {
-            LOGD("nativeGetValueN : integer");
-            try
-            {
-                int val = attrValue.get<int>();
-                jobj = env->NewObject(g_cls_Integer, g_mid_Integer_ctor, static_cast<jint>(val));
-                return jobj;
-            }
-            catch (std::exception e)
-            {
-                throwRCSException(env, e.what());
-            }
-        }
-        else if (1 == dataType)
-        {
-            LOGD("nativeGetValueN : Vector of Integer");
-            try
-            {
-                std::vector<int> vectors = attrValue.get<std::vector<int>>();
-                return  convertNativeIntVectorToJavaVector(env, vectors);
-            }
-            catch (std::exception e)
-            {
-                throwRCSException(env, e.what());
-            }
-        }
-        else if (2 == dataType)
-        {
-            LOGD("nativeGetValueN : Vector of Vector of Integer");
-            try
-            {
-                std::vector<std::vector<int>> vectors = attrValue.get<std::vector<std::vector<int>>>();
-                return  convertNativeVectorOfVectorOfIntToJavaVector(env, vectors);
-            }
-            catch (std::exception e)
-            {
-                throwRCSException(env, e.what());
-            }
-        }
-        else if (3 == dataType)
-        {
-            LOGD("nativeGetValueN : Vector of Vector of vector Integer");
-            try
-            {
-                std::vector<std::vector<std::vector<int>>> vectors =
-                    attrValue.get<std::vector<std::vector<std::vector<int>>>>();
-                return  convertNativeVectorOfVectorOfVectorOfIntToJavaVector(env, vectors);
-            }
-            catch (std::exception e)
-            {
-                throwRCSException(env, e.what());
-            }
-        }
-        else if (4 == dataType)
-        {
-            LOGD("nativeGetValueN : Double");
-            try
-            {
-                double val = attrValue.get<double>();
-                jobj = env->NewObject(g_cls_Double, g_mid_Double_ctor, static_cast<jdouble>(val));
-                return jobj;
-            }
-            catch (std::exception e)
-            {
-                throwRCSException(env, e.what());
-            }
-        }
-        else if (5 == dataType)
-        {
-            LOGD("nativeGetValueN : Vector of Double");
-            try
-            {
-                std::vector<double> vectors = attrValue.get<std::vector<double>>();
-                return  convertNativeDoubleVectorToJavaVector(env, vectors);
-            }
-            catch (std::exception e)
-            {
-                throwRCSException(env, e.what());
-            }
-        }
-        else if (6 == dataType)
-        {
-            LOGD("nativeGetValueN : Vector of Vector of Double");
-            try
-            {
-                std::vector<std::vector<double>> vectors = attrValue.get<std::vector<std::vector<double>>>();
-                return  convertNativeVectorOfVectorOfDoubleToJavaVector(env, vectors);
-            }
-            catch (std::exception e)
-            {
-                throwRCSException(env, e.what());
-            }
-        }
-        else if (7 == dataType)
-        {
-            LOGD("nativeGetValueN : Vector of Vector of vector Double");
-            try
-            {
-                std::vector<std::vector<std::vector<double>>> vectors =
-                    attrValue.get<std::vector<std::vector<std::vector<double>>>>();
-                return  convertNativeVectorOfVectorOfVectorOfDoubleToJavaVector(env, vectors);
-            }
-            catch (std::exception e)
-            {
-                throwRCSException(env, e.what());
-            }
-        }
-        else if (8 == dataType)
-        {
-            LOGD("nativeGetValueN : Boolean");
-            try
-            {
-                bool val = attrValue.get<bool>();
-                jobj = env->NewObject(g_cls_Boolean, g_mid_Boolean_ctor, static_cast<jboolean>(val));
-                return jobj;
-            }
-            catch (std::exception e)
-            {
-                throwRCSException(env, e.what());
-            }
-        }
-        else if (9 == dataType)
-        {
-            LOGD("nativeGetValueN : Vector of Boolean");
-            try
-            {
-                std::vector<bool> vectors = attrValue.get<std::vector<bool>>();
-                return  convertNativeBooleanVectorToJavaVector(env, vectors);
-            }
-            catch (std::exception e)
-            {
-                throwRCSException(env, e.what());
-            }
-        }
-        else if (10 == dataType)
-        {
-            LOGD("nativeGetValueN : Vector of Vector of Boolean");
-            try
-            {
-                std::vector<std::vector<bool>> vectors = attrValue.get<std::vector<std::vector<bool>>>();
-                return  convertNativeVectorOfVectorOfBooleanToJavaVector(env, vectors);
-            }
-            catch (std::exception e)
-            {
-                throwRCSException(env, e.what());
-            }
-        }
-        else if (11 == dataType)
-        {
-            LOGD("nativeGetValueN : Vector of Vector of Vector of Boolean");
-            try
-            {
-                std::vector<std::vector<std::vector<bool>>> vectors =
-                    attrValue.get<std::vector<std::vector<std::vector<bool>>>>();
-                return  convertNativeVectorOfVectorOfVectorOfBooleanToJavaVector(env, vectors);
-            }
-            catch (std::exception e)
-            {
-                throwRCSException(env, e.what());
-            }
-        }
-        else if (12 == dataType)
-        {
-            LOGD("nativeGetValueN : String");
-            try
-            {
-                std::string val = attrValue.get<std::string>();
-                jstring jstr = env->NewStringUTF(val.c_str());
-                return static_cast<jobject>(jstr);
-            }
-            catch (std::exception e)
-            {
-                throwRCSException(env, e.what());
-            }
-        }
-        else if (13 == dataType)
-        {
-            LOGD("nativeGetValueN : Vector of String");
-            try
-            {
-                std::vector<std::string> vectors = attrValue.get<std::vector<std::string>>();
-                return  convertNativeStringVectorToJavaVector(env, vectors);
-            }
-            catch (std::exception e)
-            {
-                throwRCSException(env, e.what());
-            }
-        }
-        else if (14 == dataType)
-        {
-            LOGD("nativeGetValueN : Vector of Vector of String");
-            try
-            {
-                std::vector<std::vector<std::string>> vectors =
-                                                       attrValue.get<std::vector<std::vector<std::string>>>();
-                return  convertNativeVectorOfVectorOfStringToJavaVector(env, vectors);
-            }
-            catch (std::exception e)
-            {
-                throwRCSException(env, e.what());
-            }
-        }
-        else if (15 == dataType)
-        {
-            LOGD("nativeGetValueN : Vector of Vector of Vector of String");
-            try
-            {
-                std::vector<std::vector<std::vector<std::string>>> vectors =
-                    attrValue.get<std::vector<std::vector<std::vector<std::string>>>>();
-                return  convertNativeVectorOfVectorOfVectorOfStringToJavaVector(env, vectors);
-            }
-            catch (std::exception e)
-            {
-                throwRCSException(env, e.what());
-            }
-        }
-        else if (16 == dataType)
-        {
-            LOGD("nativeGetValueN : RCSResourceAttribute");
-            try
-            {
-                RCSResourceAttributes  values = attrValue.get<RCSResourceAttributes>();
-                RCSResourceAttributes *rep = new RCSResourceAttributes(values);
-                jlong handle = reinterpret_cast<jlong>(rep);
-                jobject jRepresentation = env->NewObject(g_cls_RCSRemoteResourceAttributesObject,
-                                          g_mid_RCSRemoteResourceAttributesObject_ctor_bool,
-                                          handle, true);
-                if (!jRepresentation)
-                {
-                    delete rep;
-                }
-                return jRepresentation;
-            }
-            catch (std::exception e)
-            {
-                throwRCSException(env, e.what());
-            }
-        }
-    }
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSetValueInt
-(JNIEnv *env, jobject interfaceObject, jstring jKey, jint jValue)
-{
-    LOGD("RCSResourceAttributes_setValueInteger");
-    if (!jKey)
-    {
-        throwRCSException(env, "key cannot be null");
-        return;
-    }
-
-    RCSResourceAttributes *rep = JniResourceAttributes::getResourceAttributePtr(env, interfaceObject);
-    if (!rep) return;
-
-    std::string key = env->GetStringUTFChars(jKey, NULL);
-
-    RCSResourceAttributes setAttribute;
-    setAttribute[key] = static_cast<int>(jValue);
-    *rep = setAttribute;
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSetValueVectorOfInt
-(JNIEnv *env, jobject interfaceObject, jstring jKey, jobject vectorOfInt)
-{
-    LOGD("RCSResourceAttributes_nativeSetValueVectorOfInt");
-    if (!jKey)
-    {
-        throwRCSException(env, "key cannot be null");
-        return;
-    }
-
-    RCSResourceAttributes *rep = JniResourceAttributes::getResourceAttributePtr(env, interfaceObject);
-    if (!rep) return;
-
-    std::string key = env->GetStringUTFChars(jKey, NULL);
-    RCSResourceAttributes setAttribute;
-    std::vector<int> nativeVector =  covertJavaIntVectorToNativeVector(env, vectorOfInt);
-    setAttribute[key] = nativeVector;
-    *rep = setAttribute;
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSetValueVectorOfVectorOfInt
-(JNIEnv *env, jobject interfaceObject, jstring jKey, jobject vectorOfVectorOfInt)
-{
-    LOGD("RCSResourceAttributes_nativeSetValueVectorOfVectorOfInt");
-    if (!jKey)
-    {
-        throwRCSException(env, "key cannot be null");
-        return;
-    }
-
-    RCSResourceAttributes *rep = JniResourceAttributes::getResourceAttributePtr(env, interfaceObject);
-    if (!rep) return;
-
-    std::string key = env->GetStringUTFChars(jKey, NULL);
-    RCSResourceAttributes setAttribute;
-    std::vector<std::vector<int>> nativeVector =  convertJavaVectorOfVectorOfIntToNativeVector(env,
-                               vectorOfVectorOfInt);
-    setAttribute[key] = nativeVector;
-    *rep = setAttribute;
-}
-
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSetValueVectorOfVectorOfVectorOfInt
-(JNIEnv *env, jobject interfaceObject, jstring jKey, jobject value)
-{
-    LOGD("RCSResourceAttributes_nativeSetValueVectorOfVectorOfVectorOfInt");
-    if (!jKey)
-    {
-        throwRCSException(env, "key cannot be null");
-        return;
-    }
-
-    RCSResourceAttributes *rep = JniResourceAttributes::getResourceAttributePtr(env, interfaceObject);
-    if (!rep) return;
-
-    std::string key = env->GetStringUTFChars(jKey, NULL);
-    RCSResourceAttributes setAttribute;
-    std::vector<std::vector<std::vector<int>>> nativeVector =
-        convertJavaVectorOfVectorOfVectorOfIntToNativeVector(env, value);
-    setAttribute[key] = nativeVector;
-    *rep = setAttribute;
-}
-
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSetValueDouble
-(JNIEnv *env, jobject interfaceObject, jstring jKey, jdouble jValue)
-{
-    LOGD("RCSResourceAttributes_setValueDouble");
-    if (!jKey)
-    {
-        throwRCSException(env, "key cannot be null");
-        return;
-    }
-
-    RCSResourceAttributes *rep = JniResourceAttributes::getResourceAttributePtr(env, interfaceObject);
-    if (!rep) return;
-
-    std::string key = env->GetStringUTFChars(jKey, NULL);
-
-    RCSResourceAttributes setAttribute;
-    setAttribute[key] = static_cast<double>(jValue);
-    *rep = setAttribute;
-}
-
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSetValueVectorOfDouble
-(JNIEnv *env, jobject interfaceObject, jstring jKey, jobject value)
-{
-    LOGD("RCSResourceAttributes_nativeSetValueVectorOfDouble");
-    if (!jKey)
-    {
-        throwRCSException(env, "key cannot be null");
-        return;
-    }
-
-    RCSResourceAttributes *rep = JniResourceAttributes::getResourceAttributePtr(env, interfaceObject);
-    if (!rep) return;
-
-    std::string key = env->GetStringUTFChars(jKey, NULL);
-    RCSResourceAttributes setAttribute;
-    std::vector<double> nativeVector =  covertJavaDoubleVectorToNativeVector(env, value);
-    setAttribute[key] = nativeVector;
-    *rep = setAttribute;
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSetValueVectorOfVectorOfDouble
-(JNIEnv *env, jobject interfaceObject, jstring jKey, jobject value)
-{
-
-    LOGD("RCSResourceAttributes_nativeSetValueVectorOfVectorOfDouble");
-    if (!jKey)
-    {
-        throwRCSException(env, "key cannot be null");
-        return;
-    }
-
-    RCSResourceAttributes *rep = JniResourceAttributes::getResourceAttributePtr(env, interfaceObject);
-    if (!rep) return;
-
-    std::string key = env->GetStringUTFChars(jKey, NULL);
-    RCSResourceAttributes setAttribute;
-    std::vector<std::vector<double>> nativeVector =  convertJavaVectorOfVectorOfDoubleToNativeVector(
-                                      env, value);
-    setAttribute[key] = nativeVector;
-    *rep = setAttribute;
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSetValueVectorOfVectorOfVectorOfDouble
-(JNIEnv *env, jobject interfaceObject, jstring jKey, jobject value)
-{
-
-    LOGD("RCSResourceAttributes_nativeSetValueVectorOfVectorOfVectorOfDouble");
-    if (!jKey)
-    {
-        throwRCSException(env, "key cannot be null");
-        return;
-    }
-
-    RCSResourceAttributes *rep = JniResourceAttributes::getResourceAttributePtr(env, interfaceObject);
-    if (!rep) return;
-
-    std::string key = env->GetStringUTFChars(jKey, NULL);
-    RCSResourceAttributes setAttribute;
-    std::vector<std::vector<std::vector<double>>> nativeVector =
-        convertJavaVectorOfVectorOfVectorOfDoubleToNativeVector(env, value);
-    setAttribute[key] = nativeVector;
-    *rep = setAttribute;
-}
-
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSetValueBoolean
-(JNIEnv *env, jobject interfaceObject, jstring jKey, jboolean jValue)
-{
-    LOGD("RCSResourceAttributes_setValueBoolean");
-    if (!jKey)
-    {
-        throwRCSException(env, "key cannot be null");
-        return;
-    }
-
-    RCSResourceAttributes *rep = JniResourceAttributes::getResourceAttributePtr(env, interfaceObject);
-    if (!rep) return;
-
-    std::string key = env->GetStringUTFChars(jKey, NULL);
-
-    RCSResourceAttributes setAttribute;
-    setAttribute[key] = static_cast<bool>(jValue);
-    *rep = setAttribute;
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSetValueVectorOfBoolean
-(JNIEnv *env, jobject interfaceObject, jstring jKey, jobject value)
-{
-    LOGD("RCSResourceAttributes_nativeSetValueVectorOfBoolean");
-    if (!jKey)
-    {
-        throwRCSException(env, "key cannot be null");
-        return;
-    }
-
-    RCSResourceAttributes *rep = JniResourceAttributes::getResourceAttributePtr(env, interfaceObject);
-    if (!rep) return;
-
-    std::string key = env->GetStringUTFChars(jKey, NULL);
-    RCSResourceAttributes setAttribute;
-    std::vector<bool> nativeVector =  covertJavaBooleanVectorToNativeVector(env, value);
-    setAttribute[key] = nativeVector;
-    *rep = setAttribute;
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSetValueVectorOfVectorOfBoolean
-(JNIEnv *env, jobject interfaceObject, jstring jKey, jobject value)
-{
-    LOGD("RCSResourceAttributes_nativeSetValueVectorOfVectorOfBoolean");
-    if (!jKey)
-    {
-        throwRCSException(env, "key cannot be null");
-        return;
-    }
-
-    RCSResourceAttributes *rep = JniResourceAttributes::getResourceAttributePtr(env, interfaceObject);
-    if (!rep) return;
-
-    std::string key = env->GetStringUTFChars(jKey, NULL);
-    RCSResourceAttributes setAttribute;
-    std::vector<std::vector<bool>> nativeVector =  convertJavaVectorOfVectorOfBooleanToNativeVector(env,
-                                value);
-    setAttribute[key] = nativeVector;
-    *rep = setAttribute;
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSetValueVectorOfVectorOfVectorOfBoolean
-(JNIEnv *env, jobject interfaceObject, jstring jKey, jobject value)
-{
-    LOGD("RCSResourceAttributes_nativeSetValueVectorOfVectorOfVectorOfBoolean");
-    if (!jKey)
-    {
-        throwRCSException(env, "key cannot be null");
-        return;
-    }
-
-    RCSResourceAttributes *rep = JniResourceAttributes::getResourceAttributePtr(env, interfaceObject);
-    if (!rep) return;
-
-    std::string key = env->GetStringUTFChars(jKey, NULL);
-    RCSResourceAttributes setAttribute;
-    std::vector<std::vector<std::vector<bool>>> nativeVector =
-        convertJavaVectorOfVectorOfVectorOfBooleanToNativeVector(env, value);
-    setAttribute[key] = nativeVector;
-    *rep = setAttribute;
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSetValueString
-(JNIEnv *env, jobject interfaceObject, jstring jKey, jstring jValue)
-{
-    LOGD("RCSResourceAttributes_setValueString");
-    if (!jKey)
-    {
-        throwRCSException(env, "key cannot be null");
-        return;
-    }
-
-    RCSResourceAttributes *rep = JniResourceAttributes::getResourceAttributePtr(env, interfaceObject);
-    if (!rep) return;
-
-    std::string key = env->GetStringUTFChars(jKey, NULL);
-    std::string value = env->GetStringUTFChars(jValue, NULL);
-
-    RCSResourceAttributes setAttribute;
-    setAttribute[key] = value;
-    *rep = setAttribute;
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSetValueVectorOfString
-(JNIEnv *env, jobject interfaceObject, jstring jKey, jobject value)
-{
-    LOGD("RCSResourceAttributes_nativeSetValueVectorOfString");
-    if (!jKey)
-    {
-        throwRCSException(env, "key cannot be null");
-        return;
-    }
-
-    RCSResourceAttributes *rep = JniResourceAttributes::getResourceAttributePtr(env, interfaceObject);
-    if (!rep) return;
-
-    std::string key = env->GetStringUTFChars(jKey, NULL);
-    RCSResourceAttributes setAttribute;
-    std::vector<std::string> nativeVector =  covertJavaStringVectorToNativeVector(env, value);
-    setAttribute[key] = nativeVector;
-    *rep = setAttribute;
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSetValueVectorOfVectorOfString
-(JNIEnv *env, jobject interfaceObject, jstring jKey, jobject value)
-{
-    LOGD("RCSResourceAttributes_nativeSetValueVectorOfVectorOfString");
-    if (!jKey)
-    {
-        throwRCSException(env, "key cannot be null");
-        return;
-    }
-
-    RCSResourceAttributes *rep = JniResourceAttributes::getResourceAttributePtr(env, interfaceObject);
-    if (!rep) return;
-
-    std::string key = env->GetStringUTFChars(jKey, NULL);
-    RCSResourceAttributes setAttribute;
-    std::vector<std::vector<std::string>> nativeVector =
-                                           convertJavaVectorOfVectorOfStringToNativeVector(env, value);
-    setAttribute[key] = nativeVector;
-    *rep = setAttribute;
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSetValueVectorOfVectorOfVectorOfString
-(JNIEnv *env, jobject interfaceObject, jstring jKey, jobject value)
-{
-    LOGD("RCSResourceAttributes_nativeSetValueVectorOfVectorOfVectorOfString");
-    if (!jKey)
-    {
-        throwRCSException(env, "key cannot be null");
-        return;
-    }
-
-    RCSResourceAttributes *rep = JniResourceAttributes::getResourceAttributePtr(env, interfaceObject);
-    if (!rep) return;
-
-    std::string key = env->GetStringUTFChars(jKey, NULL);
-    RCSResourceAttributes setAttribute;
-    std::vector<std::vector<std::vector<std::string>>> nativeVector =
-        convertJavaVectorOfVectorOfVectorOfStringToNativeVector(env, value);
-    setAttribute[key] = nativeVector;
-    *rep = setAttribute;
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSetValueAttributes
-(JNIEnv *env, jobject interfaceObject, jstring jKey, jobject jValue)
-{
-
-    LOGD("RCSResourceAttributes_nativeSetValueAttributes");
-    if (!jKey)
-    {
-        throwRCSException(env, "key cannot be null");
-        return;
-    }
-
-    RCSResourceAttributes *rep = JniResourceAttributes::getResourceAttributePtr(env, interfaceObject);
-    if (!rep) return;
-
-    std::string key = env->GetStringUTFChars(jKey, NULL);
-    RCSResourceAttributes setAttribute;
-    RCSResourceAttributes *value = JniResourceAttributes::getResourceAttributePtr(env, jValue);
-    if (!value) return;
-
-    setAttribute[key] = *value;
-    *rep = setAttribute;
-}
-
-JNIEXPORT jboolean JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeIsEmpty
-(JNIEnv *env, jobject interfaceObject)
-{
-    LOGD("RCSResourceAttributes_isEmpty");
-    RCSResourceAttributes *rep = JniResourceAttributes::getResourceAttributePtr(env, interfaceObject);
-    if (!rep) return false;
-
-    return static_cast<jboolean>(rep->empty());
-}
-
-JNIEXPORT jint JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeSize
-(JNIEnv *env, jobject interfaceObject)
-{
-    LOGD("RCSResourceAttributes_nativeSize");
-    RCSResourceAttributes *rep = JniResourceAttributes::getResourceAttributePtr(env, interfaceObject);
-    if (!rep) return -1;
-
-    return static_cast<jint>(rep->size());
-}
-
-JNIEXPORT jboolean JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeRemove
-(JNIEnv *env, jobject interfaceObject, jstring jAttributeKey)
-{
-    LOGD("RCSResourceAttributes_nativeRemove");
-    if (!jAttributeKey)
-    {
-        throwRCSException(env, "attributeKey cannot be null");
-        return false;
-    }
-
-    RCSResourceAttributes *rep = JniResourceAttributes::getResourceAttributePtr(env, interfaceObject);
-    if (!rep) return false;
-
-    std::string attributeKey = env->GetStringUTFChars(jAttributeKey, NULL);
-    return static_cast<jboolean>(rep->erase(attributeKey));
-}
-
-JNIEXPORT jboolean JNICALL
-Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_nativeHasAttribute
-(JNIEnv *env, jobject interfaceObject, jstring jstr)
-{
-    LOGD("RCSResourceAttributes_nativeHasAttribute");
-    if (!jstr)
-    {
-        throwRCSException(env, "attributeKey cannot be null");
-        return false;
-    }
-
-    RCSResourceAttributes *rep = JniResourceAttributes::getResourceAttributePtr(env, interfaceObject);
-    if (!rep) return false;
-
-    std::string attributeKey = env->GetStringUTFChars(jstr, NULL);
-    return static_cast<jboolean>(rep->contains(attributeKey));
-}
-
-JNIEXPORT void JNICALL Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_create
-(JNIEnv *env, jobject interfaceObject)
-{
-    LOGD("RCSResourceAttributes_create");
-    RCSResourceAttributes *rep = new RCSResourceAttributes();
-    RESetHandle<RCSResourceAttributes>(env, interfaceObject, rep);
-    if (env->ExceptionCheck())
-    {
-        LOGE("Failed to set native handle for RCSResourceAttributes");
-        delete rep;
-    }
-}
-
-JNIEXPORT void JNICALL Java_org_iotivity_ResourceEncapsulation_common_RCSResourceAttributes_dispose
-(JNIEnv *env, jobject interfaceObject, jboolean jNeedsDelete)
-{
-    LOGD("RCSResourceAttributes_dispose");
-    RCSResourceAttributes *rep = JniResourceAttributes::getResourceAttributePtr(env, interfaceObject);
-
-    if (jNeedsDelete)
-    {
-        delete rep;
-    }
-}
diff --git a/service/resource-encapsulation/sdk/java/jni/re/src/jni_re_resource_builder.cpp b/service/resource-encapsulation/sdk/java/jni/re/src/jni_re_resource_builder.cpp
deleted file mode 100644 (file)
index c9e386c..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/******************************************************************
- *
- * 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 "jni_re_jvm.h"
-#include "jni_re_resource_builder.h"
-#include "jni_re_resource_object.h"
-#include "RCSResourceObject.h"
-#include "jni_re_resource_attributes.h"
-
-using namespace OIC::Service;
-
-JNIEXPORT jobject JNICALL Java_org_iotivity_ResourceEncapsulation_server_Builder_nativeBuild
-(JNIEnv *env, jobject interfaceObject, jstring jResourceURI, jstring jResourceType,
- jstring jResourceInterface,
- jboolean jObservableFlag, jboolean jDiscovervableFlag, jobject jAttributes)
-{
-    LOGI("nativeBuild called");
-
-    std::string resourceURI;
-    if (jResourceURI)
-    {
-        resourceURI = env->GetStringUTFChars(jResourceURI, NULL);
-    }
-    std::string resourceType;
-    if (jResourceType)
-    {
-        resourceType = env->GetStringUTFChars(jResourceType, NULL);
-    }
-    std::string resourceInterface;
-    if (jResourceInterface)
-    {
-        resourceInterface = env->GetStringUTFChars(jResourceInterface, NULL);
-    }
-
-    std::shared_ptr< RCSResourceObject > NativeRCSResourceObject;
-    try
-    {
-        if (jAttributes)
-        {
-            RCSResourceAttributes *attributesObj =   JniResourceAttributes::getResourceAttributePtr(env,
-                    jAttributes);
-            NativeRCSResourceObject = RCSResourceObject::Builder(resourceURI, resourceType,
-                                      resourceInterface).setDiscoverable((bool)jObservableFlag).setObservable((
-                                                  bool)jObservableFlag).setAttributes(*attributesObj).build();
-
-            jobject jResource = env->NewObject(g_cls_RCSResourceObject, g_mid_RCSResourceObject_ctor);
-            JniRCSResourceObject *jniRCSResourceObject = new JniRCSResourceObject(NativeRCSResourceObject);
-            RESetHandle<JniRCSResourceObject>(env, jResource, jniRCSResourceObject);
-            return jResource;
-        }
-        else
-        {
-            NativeRCSResourceObject = RCSResourceObject::Builder(resourceURI, resourceType,
-                                      resourceInterface).setDiscoverable((bool)jObservableFlag).setObservable((
-                                                  bool)jObservableFlag).build();
-
-            jobject jResource = env->NewObject(g_cls_RCSResourceObject, g_mid_RCSResourceObject_ctor);
-            JniRCSResourceObject *jniRCSResourceObject = new JniRCSResourceObject(NativeRCSResourceObject);
-            RESetHandle<JniRCSResourceObject>(env, jResource, jniRCSResourceObject);
-            return jResource;
-        }
-    }
-    catch (OIC::Service::PlatformException exception)
-    {
-        LOGE("nativeBuild : platform Exception");
-        throwRCSException(env,  exception.what());
-    }
-    catch (OIC::Service::RCSException exception)
-    {
-        LOGE("nativeBuild : RCSException");
-        throwRCSException(env,  exception.what());
-    }
-}
diff --git a/service/resource-encapsulation/sdk/java/jni/re/src/jni_re_resource_object.cpp b/service/resource-encapsulation/sdk/java/jni/re/src/jni_re_resource_object.cpp
deleted file mode 100644 (file)
index 0a8e416..0000000
+++ /dev/null
@@ -1,599 +0,0 @@
-/******************************************************************
- *
- * 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 "jni_re_resource_object.h"
-#include "jni_re_get_request_listener.h"
-#include "RCSResourceObject.h"
-
-JniRCSResourceObject::JniRCSResourceObject(std::shared_ptr< RCSResourceObject>
-        resource)
-    : m_sharedResource(resource)
-{}
-
-JniRCSResourceObject::~JniRCSResourceObject()
-{
-    LOGD("JniResourceObject::~JniResourceObject()");
-    m_sharedResource = NULL;
-
-    jint envRet;
-    JNIEnv *env = GetREJNIEnv(envRet);
-    if (NULL == env) return;
-
-    if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
-}
-
-JniRCSResourceObject *JniRCSResourceObject::getJniRCSResourceObject(JNIEnv *env,
-        jobject thiz)
-{
-    JniRCSResourceObject *resource = REGetHandle<JniRCSResourceObject>(env, thiz);
-    if (env->ExceptionCheck())
-    {
-        LOGE("Failed to get native handle from RCSResourceObject");
-    }
-    if (!resource)
-    {
-        LOGE("getJniRCSResourceObject :: no resource");
-    }
-    return resource;
-}
-
-void JniRCSResourceObject::setAttributeInteger(JNIEnv *env, jobject jObject, jstring jKey,
-        jint jValue)
-{
-    LOGD("JniRCSResourceObject::setAttributeInteger");
-
-    if (!jKey)
-    {
-        throwRCSException(env, "key cannot be null");
-        return;
-    }
-    std::string key = env->GetStringUTFChars(jKey, NULL);
-    RCSResourceAttributes::Value value ;
-    RCSResourceAttributes::TypeId typeId;
-
-    try
-    {
-        value =  m_sharedResource->getAttributeValue(key);
-        if (value != NULL)
-        {
-            typeId = value.getType().getId();
-            if (typeId == RCSResourceAttributes::TypeId::INT)
-            {
-                RCSResourceObject::LockGuard lock(*m_sharedResource);
-                m_sharedResource->getAttributes()[key] = (int)jValue;
-            }
-            else
-            {
-                LOGD("JniRCSResourceObject::setAttributeInteger value is not interger type");
-            }
-        }
-    }
-    catch (BadRequestException exception)
-    {
-        throwRCSException(env,  exception.what());
-    }
-}
-
-void JniRCSResourceObject::setAttributeDouble(JNIEnv *env, jobject jObject, jstring jKey,
-        jdouble jValue)
-{
-    LOGD("JniRCSResourceObject::setAttributeDouble");
-
-    if (!jKey)
-    {
-        throwRCSException(env, "key cannot be null");
-        return;
-    }
-    std::string key = env->GetStringUTFChars(jKey, NULL);
-    RCSResourceAttributes::Value value ;
-    RCSResourceAttributes::TypeId typeId;
-
-    try
-    {
-        value =  m_sharedResource->getAttributeValue(key);
-        if (value != NULL)
-        {
-            typeId = value.getType().getId();
-            if (typeId == RCSResourceAttributes::TypeId::DOUBLE)
-            {
-                RCSResourceObject::LockGuard lock(*m_sharedResource);
-                m_sharedResource->getAttributes()[key] = (double)jValue;
-            }
-            else
-            {
-                LOGD("JniRCSResourceObject::setAttributeInteger value is not double type");
-            }
-        }
-    }
-    catch (BadRequestException exception)
-    {
-        throwRCSException(env,  exception.what());
-    }
-
-}
-
-
-void JniRCSResourceObject::setAttributeBool(JNIEnv *env, jobject jObject, jstring jKey,
-        jboolean jValue)
-{
-    LOGD("JniRCSResourceObject::setAttributeBool");
-
-    if (!jKey)
-    {
-        throwRCSException(env, "key cannot be null");
-        return;
-    }
-    std::string key = env->GetStringUTFChars(jKey, NULL);
-    RCSResourceAttributes::Value value ;
-    RCSResourceAttributes::TypeId typeId;
-
-    try
-    {
-        value =  m_sharedResource->getAttributeValue(key);
-        if (value != NULL)
-        {
-            typeId = value.getType().getId();
-            if (typeId == RCSResourceAttributes::TypeId::BOOL)
-            {
-                RCSResourceObject::LockGuard lock(*m_sharedResource);
-                m_sharedResource->getAttributes()[key] = (bool)jValue;
-            }
-            else
-            {
-                LOGD("JniRCSResourceObject::setAttributeInteger value is not bool type");
-            }
-        }
-    }
-    catch (BadRequestException exception)
-    {
-        throwRCSException(env,  exception.what());
-    }
-}
-
-void JniRCSResourceObject::setAttributeString(JNIEnv *env, jobject jObject, jstring jKey,
-        jstring jValue)
-{
-    LOGD("JniRCSResourceObject::setAttributeString");
-
-    if (!jKey)
-    {
-        throwRCSException(env, "key cannot be null");
-        return;
-    }
-    std::string key = env->GetStringUTFChars(jKey, NULL);
-    RCSResourceAttributes::Value value ;
-    RCSResourceAttributes::TypeId typeId;
-
-    try
-    {
-        value =  m_sharedResource->getAttributeValue(key);
-        if (value != NULL)
-        {
-            typeId = value.getType().getId();
-            if (typeId == RCSResourceAttributes::TypeId::STRING)
-            {
-                RCSResourceObject::LockGuard lock(*m_sharedResource);
-                std::string nativeValue = env->GetStringUTFChars(jValue, NULL);
-                m_sharedResource->getAttributes()[key] = nativeValue;
-            }
-            else
-            {
-                LOGD("JniRCSResourceObject::setAttributeInteger value is not String type");
-            }
-        }
-    }
-    catch (BadRequestException exception)
-    {
-        throwRCSException(env,  exception.what());
-    }
-}
-
-jstring JniRCSResourceObject::getAttributeValue(JNIEnv *env, jstring jKey)
-{
-    char buf[64];
-    std::string key;
-    if (jKey)
-    {
-        key = env->GetStringUTFChars(jKey, NULL);
-    }
-    else
-    {
-        LOGE("getAttributeValue Key is NULL");
-        return NULL;
-    }
-
-    RCSResourceAttributes::Value value;
-    RCSResourceAttributes::TypeId typeId;
-    try
-    {
-        value =  m_sharedResource->getAttributeValue(key);
-        typeId = value.getType().getId();
-    }
-    catch (BadRequestException exception)
-    {
-        throwRCSException(env,  exception.what());
-    }
-
-    if (typeId == RCSResourceAttributes::TypeId::INT)
-    {
-        int val = value.get<int>();
-        sprintf(buf, "%d", val);
-        return (env)->NewStringUTF(buf);
-    }
-    else if (typeId == RCSResourceAttributes::TypeId::DOUBLE)
-    {
-        double val = value.get<double>();
-        sprintf(buf, "%f", val);
-        return (env)->NewStringUTF(buf);
-    }
-    else if (typeId == RCSResourceAttributes::TypeId::BOOL)
-    {
-        bool val = value.get<bool>();
-        sprintf(buf, "%d", val);
-        return (env)->NewStringUTF(buf);
-    }
-    else if (typeId == RCSResourceAttributes::TypeId::STRING)
-    {
-        std::string val = value.get<std::string>();
-        jstring jstr = env->NewStringUTF(val.c_str());
-        return jstr;
-    }
-}
-
-bool JniRCSResourceObject::removeAttribute(JNIEnv *env, jstring jKey)
-{
-    std::string key;
-    if (jKey)
-    {
-        key = env->GetStringUTFChars(jKey, NULL);
-    }
-    return m_sharedResource->removeAttribute(key);
-}
-bool JniRCSResourceObject::containsAttribute(JNIEnv *env, jstring jKey)
-{
-    std::string key;
-    if (jKey)
-    {
-        key = env->GetStringUTFChars(jKey, NULL);
-    }
-    return m_sharedResource->containsAttribute(key);
-}
-
-jobject JniRCSResourceObject::getAttributes(JNIEnv *env, jobject jObject)
-{
-    RCSResourceObject::LockGuard lock(*m_sharedResource);
-    RCSResourceAttributes nativeAttributes = m_sharedResource->getAttributes();
-
-    RCSResourceAttributes *attributesObj = new RCSResourceAttributes(nativeAttributes);
-
-    jlong handle = reinterpret_cast<jlong>(attributesObj);
-    jobject jAttributes = env->NewObject(g_cls_RCSRemoteResourceAttributesObject,
-                                         g_mid_RCSRemoteResourceAttributesObject_ctor,
-                                         handle, true);
-    return jAttributes;
-}
-
-bool JniRCSResourceObject::isObservable()
-{
-    return m_sharedResource->isObservable();
-}
-
-bool JniRCSResourceObject::isDiscoverable()
-{
-    return m_sharedResource->isDiscoverable();
-}
-
-void JniRCSResourceObject::setGetRequestHandler(JNIEnv *env, jobject jGetRequestListener)
-{
-
-    JniGetRequestListener *onGetRequestListener = addOnGetRequestListener(env, jGetRequestListener);
-
-    OIC::Service::RCSResourceObject::GetRequestHandler getRequestCallback = [onGetRequestListener](
-                OIC::Service::RCSRequest request,
-                OIC::Service::RCSResourceAttributes attributes)
-    {
-        return onGetRequestListener->onGetRequestCallback(request, attributes);
-    };
-    m_sharedResource->setGetRequestHandler(getRequestCallback);
-}
-
-void JniRCSResourceObject::setSetRequestHandler(JNIEnv *env, jobject jSetRequestListener)
-{
-
-    JniSetRequestListener *onSetRequestListener = addOnSetRequestListener(env, jSetRequestListener);
-
-    OIC::Service::RCSResourceObject::SetRequestHandler setRequestCallback = [onSetRequestListener](
-                OIC::Service::RCSRequest request,
-                OIC::Service::RCSResourceAttributes attributes)
-    {
-        return onSetRequestListener->onSetRequestCallback(request, attributes);
-    };
-    m_sharedResource->setSetRequestHandler(setRequestCallback);
-}
-
-void JniRCSResourceObject::addAttributeUpdatedListener(JNIEnv *env, jstring jKey,
-        jobject jAttributeUpdatedListener)
-{
-    std::string nativeKey;
-    if (jKey)
-    {
-        nativeKey = env->GetStringUTFChars(jKey, NULL);
-    }
-    else
-    {
-        LOGE("addAttributeUpdatedListener is NULL");
-        return;
-    }
-    JniAttributeUpdatedListener *onAttributeUpdatedListener = addOnAttributeUpdatedListener(env,
-            jAttributeUpdatedListener);
-
-    OIC::Service::RCSResourceObject::AttributeUpdatedListener attributeUpdatedCallback
-        = [onAttributeUpdatedListener]( OIC::Service::RCSResourceAttributes::Value oldValue,
-                                        OIC::Service::RCSResourceAttributes::Value newValue)
-    {
-        onAttributeUpdatedListener->onAttributeUpdatedCallback(oldValue, newValue);
-    };
-    m_sharedResource->addAttributeUpdatedListener(nativeKey, attributeUpdatedCallback);
-}
-
-bool JniRCSResourceObject::removeAttributeUpdatedListener(JNIEnv *env, jobject jObject,
-        jstring jKey)
-{
-    std::string nativeKey;
-    if (jKey)
-    {
-        nativeKey = env->GetStringUTFChars(jKey, NULL);
-    }
-    return m_sharedResource->removeAttributeUpdatedListener(nativeKey);
-}
-
-void JniRCSResourceObject::notify()
-{
-    m_sharedResource->notify();
-}
-
-void JniRCSResourceObject::setAutoNotifyPolicy(int policy)
-{
-    RCSResourceObject::AutoNotifyPolicy nativePolicy = convertJavaNotifyPolicyToNativePolicy(policy);
-    m_sharedResource->setAutoNotifyPolicy(nativePolicy);
-}
-
-int JniRCSResourceObject::getAutoNotifyPolicy()
-{
-    return convertAutoNotifyPolicyToInt(m_sharedResource->getAutoNotifyPolicy());
-}
-
-void JniRCSResourceObject::setSetRequestHandlerPolicy(int policy)
-{
-    RCSResourceObject::SetRequestHandlerPolicy nativePolicy =
-        convertJavasetRequestHandlerPolicyToNativePolicy(policy);
-    m_sharedResource->setSetRequestHandlerPolicy(nativePolicy);
-}
-
-int JniRCSResourceObject::getSetRequestHandlerPolicy()
-{
-    return convertSetRequestHandlerPolicyToInt(m_sharedResource->getSetRequestHandlerPolicy());
-}
-
-JniGetRequestListener *JniRCSResourceObject::addOnGetRequestListener(JNIEnv *env,
-        jobject jListener)
-{
-    return this->m_onGetRequest.addListener(env, jListener, this);
-}
-
-JniSetRequestListener *JniRCSResourceObject::addOnSetRequestListener(JNIEnv *env,
-        jobject jListener)
-{
-    return this->m_onSetRequest.addListener(env, jListener, this);
-}
-
-JniAttributeUpdatedListener *JniRCSResourceObject::addOnAttributeUpdatedListener(JNIEnv *env,
-        jobject jListener)
-{
-    return this->m_onAttributeUpdated.addListener(env, jListener, this);
-}
-
-void JniRCSResourceObject::removeOnGetRequestListener(JNIEnv *env, jobject jListener)
-{
-    this->m_onGetRequest.removeListener(env, jListener);
-}
-
-void JniRCSResourceObject::removeOnSetRequestListener(JNIEnv *env, jobject jListener)
-{
-    this->m_onSetRequest.removeListener(env, jListener);
-}
-
-void JniRCSResourceObject::removeOnAttributeUpdatedListener(JNIEnv *env, jobject jListener)
-{
-    this->m_onAttributeUpdated.removeListener(env, jListener);
-}
-
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeSetAttributeInteger
-(JNIEnv *env, jobject jObject, jstring key, jint value)
-{
-    LOGD("RCSRemoteResourceObject_nativeSetAttributeInteger");
-    JniRCSResourceObject *resource = JniRCSResourceObject::getJniRCSResourceObject(env, jObject);
-    resource->setAttributeInteger(env, jObject, key, value);
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeSetAttributeDouble
-(JNIEnv *env, jobject jObject, jstring key, jdouble value)
-{
-    LOGD("RCSRemoteResourceObject_nativeSetAttributeFloat");
-    JniRCSResourceObject *resource = JniRCSResourceObject::getJniRCSResourceObject(env, jObject);
-    resource->setAttributeDouble(env, jObject, key, value);
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeSetAttributeBool
-(JNIEnv *env, jobject jObject, jstring key, jboolean value)
-{
-    LOGD("RCSRemoteResourceObject_nativeSetAttributeDouble");
-    JniRCSResourceObject *resource = JniRCSResourceObject::getJniRCSResourceObject(env, jObject);
-    resource->setAttributeBool(env, jObject, key, value);
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeSetAttributeString
-(JNIEnv *env, jobject jObject, jstring key, jstring value)
-{
-    LOGD("RCSRemoteResourceObject_nativeSetAttributeFloat");
-    JniRCSResourceObject *resource = JniRCSResourceObject::getJniRCSResourceObject(env, jObject);
-    resource->setAttributeString(env, jObject, key, value);
-}
-
-JNIEXPORT jstring JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeGetAttributeValue
-(JNIEnv *env, jobject jObject, jstring key)
-{
-    LOGD("RCSRemoteResourceObject_nativeGetAttributeValue");
-    JniRCSResourceObject *resource = JniRCSResourceObject::getJniRCSResourceObject(env, jObject);
-    return resource->getAttributeValue(env, key);
-}
-
-JNIEXPORT jboolean JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeRemoveAttribute
-(JNIEnv *env, jobject jObject, jstring key)
-{
-    LOGD("RCSRemoteResourceObject_nativeRemoveAttribute");
-    JniRCSResourceObject *resource = JniRCSResourceObject::getJniRCSResourceObject(env, jObject);
-    return (jboolean)resource->removeAttribute(env, key);
-}
-
-JNIEXPORT jboolean JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeContainsAttribute
-(JNIEnv *env, jobject jObject, jstring key)
-{
-    LOGD("RCSRemoteResourceObject_nativeContainsAttribute");
-    JniRCSResourceObject *resource = JniRCSResourceObject::getJniRCSResourceObject(env, jObject);
-    return (jboolean)resource->containsAttribute(env, key);
-}
-
-JNIEXPORT jobject JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeGetAttributes
-(JNIEnv *env, jobject jObject)
-{
-    LOGD("RCSRemoteResourceObject_nativeGetAttributes");
-    JniRCSResourceObject *resource = JniRCSResourceObject::getJniRCSResourceObject(env, jObject);
-    return resource->getAttributes(env, jObject);
-}
-
-JNIEXPORT jboolean JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeIsObservable
-(JNIEnv *env, jobject jObject)
-{
-    LOGD("RCSRemoteResourceObject_nativeIsObservable");
-    JniRCSResourceObject *resource = JniRCSResourceObject::getJniRCSResourceObject(env, jObject);
-    return (jboolean)resource->isObservable();
-}
-
-JNIEXPORT jboolean JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeIsDiscoverable
-(JNIEnv *env, jobject jObject)
-{
-    LOGD("RCSRemoteResourceObject_nativeIsDiscoverable");
-    JniRCSResourceObject *resource = JniRCSResourceObject::getJniRCSResourceObject(env, jObject);
-    return (jboolean)resource->isDiscoverable();
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeSetGetRequestHandler
-(JNIEnv *env, jobject jObject , jobject getRequestListener)
-{
-    LOGD("RCSRemoteResourceObject_nativeSetGetRequestHandler");
-    JniRCSResourceObject *resource = JniRCSResourceObject::getJniRCSResourceObject(env, jObject);
-    resource->setGetRequestHandler(env, getRequestListener);
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeSetSetRequestHandler
-(JNIEnv *env, jobject jObject , jobject setRequestListener)
-{
-    LOGD("RCSRemoteResourceObject_nativeSetSetRequestHandler");
-    JniRCSResourceObject *resource = JniRCSResourceObject::getJniRCSResourceObject(env, jObject);
-    resource->setSetRequestHandler(env, setRequestListener);
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeAddAttributeUpdatedListener
-(JNIEnv *env, jobject jObject, jstring key, jobject attributeUpdatedListener)
-{
-    LOGD("RCSRemoteResourceObject_nativeAddAttributeUpdatedListener");
-    JniRCSResourceObject *resource = JniRCSResourceObject::getJniRCSResourceObject(env, jObject);
-    resource->addAttributeUpdatedListener(env, key, attributeUpdatedListener);
-}
-
-JNIEXPORT jboolean JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeRemoveAttributeUpdatedListener
-(JNIEnv *env, jobject jObject, jstring key)
-{
-    LOGD("RCSRemoteResourceObject_nativeAddAttributeUpdatedListener");
-    JniRCSResourceObject *resource = JniRCSResourceObject::getJniRCSResourceObject(env, jObject);
-    return (jboolean)resource->removeAttributeUpdatedListener(env, jObject, key);
-}
-
-JNIEXPORT void JNICALL Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeNotify
-(JNIEnv *env, jobject jObject)
-{
-    LOGD("RCSRemoteResourceObject_nativeNotify");
-    JniRCSResourceObject *resource = JniRCSResourceObject::getJniRCSResourceObject(env, jObject);
-    resource->notify();
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeSetAutoNotifyPolicy
-(JNIEnv *env, jobject jObject, jint jPolicy)
-{
-    LOGD("RCSRemoteResourceObject_nativeSetAutoNotifyPolicy");
-    JniRCSResourceObject *resource = JniRCSResourceObject::getJniRCSResourceObject(env, jObject);
-    resource->setAutoNotifyPolicy(jPolicy);
-}
-
-JNIEXPORT jint JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeGetAutoNotifyPolicy
-(JNIEnv *env, jobject jObject)
-{
-    LOGD("RCSRemoteResourceObject_nativeGetAutoNotifyPolicy");
-    JniRCSResourceObject *resource = JniRCSResourceObject::getJniRCSResourceObject(env, jObject);
-    return (jint)resource->getAutoNotifyPolicy();
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeSetSetRequestHandlerPolicy
-(JNIEnv *env, jobject jObject, jint jPolicy)
-{
-    LOGD("RCSRemoteResourceObject_nativeSetSetRequestHandlerPolicy");
-    JniRCSResourceObject *resource = JniRCSResourceObject::getJniRCSResourceObject(env, jObject);
-    resource->setSetRequestHandlerPolicy(jPolicy);
-}
-
-JNIEXPORT jint JNICALL
-Java_org_iotivity_ResourceEncapsulation_server_RCSResourceObject_nativeGetSetRequestHandlerPolicy
-(JNIEnv *env, jobject jObject)
-{
-    LOGD("RCSRemoteResourceObject_nativeGetSetRequestHandlerPolicy");
-    JniRCSResourceObject *resource = JniRCSResourceObject::getJniRCSResourceObject(env, jObject);
-    return (jint)resource->getSetRequestHandlerPolicy();
-}
-
-
diff --git a/service/resource-encapsulation/sdk/java/jni/re/src/jni_re_resource_statechange_listener.cpp b/service/resource-encapsulation/sdk/java/jni/re/src/jni_re_resource_statechange_listener.cpp
deleted file mode 100644 (file)
index 716cda6..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/******************************************************************
- *
- * 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 "jni_re_resource_statechange_listener.h"
-#include "jni_re_rcs_remoteresourceobject.h"
-
-JniResourceStateChangeListener::JniResourceStateChangeListener(JNIEnv *env, jobject jListener,
-        JniRCSRemoteResourceObject *owner)
-    : m_ownerResource(owner)
-{
-    m_jwListener = env->NewWeakGlobalRef(jListener);
-}
-
-JniResourceStateChangeListener::~JniResourceStateChangeListener()
-{
-    LOGI("~JniResourceStateChangeListener()");
-    if (m_jwListener)
-    {
-        jint ret;
-        JNIEnv *env = GetREJNIEnv(ret);
-        if (NULL == env) return;
-        env->DeleteWeakGlobalRef(m_jwListener);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-    }
-}
-
-void JniResourceStateChangeListener::stateChangeCallback(OIC::Service::ResourceState state)
-{
-
-    LOGI("JniResourceStateChangeListener::stateChangeCallback enter");
-
-    jint ret;
-    JNIEnv *env = GetREJNIEnv(ret);
-    if (NULL == env) return;
-
-    jobject jListener = env->NewLocalRef(m_jwListener);
-    if (!jListener)
-    {
-        checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-        return;
-    }
-
-    jclass clsL = env->GetObjectClass(jListener);
-    if (!clsL)
-    {
-        checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-        return;
-    }
-    jmethodID midL = env->GetMethodID(clsL, "onStateChanged",
-            "(Lorg/iotivity/ResourceEncapsulation/client/RCSRemoteResourceObject$ResourceState;)V");
-    if (!midL)
-    {
-        checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-        return;
-    }
-    jobject resourcestate = convertNativeResourceStateToJavaResourceState(state, env);
-    env->CallVoidMethod(jListener, midL, resourcestate);
-
-    if (env->ExceptionCheck())
-    {
-        LOGE("Java exception is thrown");
-        checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-        return;
-    }
-
-    if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-}
-
-void JniResourceStateChangeListener::checkExAndRemoveListener(JNIEnv *env)
-{
-    if (env->ExceptionCheck())
-    {
-        jthrowable ex = env->ExceptionOccurred();
-        env->ExceptionClear();
-        m_ownerResource->removeOnStateChangeListener(env, m_jwListener);
-        env->Throw((jthrowable)ex);
-    }
-    else
-    {
-        m_ownerResource->removeOnStateChangeListener(env, m_jwListener);
-    }
-}
diff --git a/service/resource-encapsulation/sdk/java/jni/re/src/jni_re_set_request_listener.cpp b/service/resource-encapsulation/sdk/java/jni/re/src/jni_re_set_request_listener.cpp
deleted file mode 100644 (file)
index f2818dd..0000000
+++ /dev/null
@@ -1,214 +0,0 @@
-/******************************************************************
- *
- * 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 "jni_re_set_request_listener.h"
-#include "jni_re_resource_object.h"
-
-JniSetRequestListener::JniSetRequestListener(JNIEnv *env, jobject jListener,
-        JniRCSResourceObject *owner)
-    : m_ownerResource(owner)
-{
-    m_jwListener = env->NewWeakGlobalRef(jListener);
-}
-
-JniSetRequestListener::~JniSetRequestListener()
-{
-    LOGI("JniSetRequestListener::~JniSetRequestListener()");
-    if (m_jwListener)
-    {
-        jint ret;
-        JNIEnv *env = GetREJNIEnv(ret);
-        if (NULL == env) return;
-        env->DeleteWeakGlobalRef(m_jwListener);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-    }
-}
-
-OIC::Service::RCSSetResponse JniSetRequestListener::onSetRequestCallback(
-    OIC::Service::RCSRequest request, OIC::Service::RCSResourceAttributes attributes)
-{
-    LOGI("JniGetRequestListener::onSetRequestCallback enter");
-    jint ret;
-    JNIEnv *env = GetREJNIEnv(ret);
-    if (NULL == env)
-        LOGE("onSetRequestCallback: env is NULL");
-
-    jobject jListener = env->NewLocalRef(m_jwListener);
-    if (!jListener)
-    {
-        checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-        LOGE("onSetRequestCallback: jListener is NULL");
-    }
-
-    jclass clsL = env->GetObjectClass(jListener);
-
-    if (!clsL)
-    {
-        checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-        LOGE("onSetRequestCallback: clsL is NULL");
-    }
-
-    //constructing java attribute object..
-    RCSResourceAttributes *attributesObj = new RCSResourceAttributes(attributes);
-    jlong handle = reinterpret_cast<jlong>(attributesObj);
-    jobject jAttributes = env->NewObject(g_cls_RCSRemoteResourceAttributesObject,
-                                         g_mid_RCSRemoteResourceAttributesObject_ctor,
-                                         handle, true);
-    if (!jAttributes)
-    {
-        delete attributesObj;
-        checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-        LOGE("onGetRequestCallback: jAttributes == null");
-    }
-
-    //constructing java RCSRequest object
-    std::string resourceUri = request.getResourceUri();
-    jstring javaUri = env->NewStringUTF(resourceUri.c_str());
-
-    g_mid_RCSRequest_ctor = env->GetMethodID(g_cls_RCSRequest, "<init>", "(Ljava/lang/String;)V");
-    jobject javaRCSRequestObject = env->NewObject( g_cls_RCSRequest, g_mid_RCSRequest_ctor, javaUri);
-
-    //getting the method ID
-    jmethodID midL = env->GetMethodID(clsL, "onSetRequest",
-  "(Lorg/iotivity/ResourceEncapsulation/server/RCSRequest;Lorg/iotivity/ResourceEncapsulation/common/RCSResourceAttributes;)Lorg/iotivity/ResourceEncapsulation/server/RCSSetResponse;");
-
-    if (!midL)
-    {
-        delete attributesObj;
-        checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-        LOGI("onGetRequestCallback: midL == null");
-    }
-
-    //calling the Java method
-    jobject javaSetResponse = env->CallObjectMethod(jListener, midL, javaRCSRequestObject,
-                              jAttributes);  //todo
-
-    //getting the information related to Response
-    jclass SetResponseClass = env->GetObjectClass(javaSetResponse);
-
-    jmethodID midSetTypeOfGetResponse = env->GetMethodID(SetResponseClass, "getTypeOfGetResponse",
-                                        "()I");
-    jint type = env->CallIntMethod(javaSetResponse, midSetTypeOfGetResponse);
-
-    if (0 == type)
-    {
-        LOGI("Type == Default");
-        return OIC::Service::RCSSetResponse::defaultAction();
-    }
-    else if (1 == type)
-    {
-        LOGI("Type == 1");
-        jmethodID midGetResult = env->GetMethodID(SetResponseClass, "getResult", "()I");
-        jmethodID midGetErrorCode = env->GetMethodID(SetResponseClass, "getErrorCode", "()I");
-        jint handlerResult = env->CallIntMethod(javaSetResponse, midGetResult);
-        jint errorCode = env->CallIntMethod(javaSetResponse, midGetErrorCode);
-        OCEntityHandlerResult nativeHandlerResult = convertIntToOCEntityHandlerResult(handlerResult);
-        return OIC::Service::RCSSetResponse::create(nativeHandlerResult, errorCode);
-    }
-    else if (2 == type)
-    {
-        LOGI("Type == 2");
-        jmethodID midGetAttributes = env->GetMethodID(SetResponseClass, "getAttributes",
-                                     "()Lorg/iotivity/ResourceEncapsulation/common/RCSResourceAttributes;");
-        jobject attributes = env->CallObjectMethod(javaSetResponse, midGetAttributes);
-        RCSResourceAttributes *attributesObj =   JniResourceAttributes::getResourceAttributePtr(env,
-                attributes);
-        return OIC::Service::RCSSetResponse::create(*attributesObj);
-    }
-    else if (3 == type)
-    {
-        LOGI("Type == 3");
-        jmethodID midGetResult = env->GetMethodID(SetResponseClass, "getResult", "()I");
-        jmethodID midGetErrorCode = env->GetMethodID(SetResponseClass, "getErrorCode", "()I");
-        jint handlerResult = env->CallIntMethod(javaSetResponse, midGetResult);
-        jint errorCode = env->CallIntMethod(javaSetResponse, midGetErrorCode);
-        OCEntityHandlerResult nativeHandlerResult = convertIntToOCEntityHandlerResult(handlerResult);
-        jmethodID midGetAttributes = env->GetMethodID(SetResponseClass, "getAttributes",
-                                     "()Lorg/iotivity/ResourceEncapsulation/common/RCSResourceAttributes;");
-        jobject attributes = env->CallObjectMethod(javaSetResponse, midGetAttributes);
-        RCSResourceAttributes *attributesObj =   JniResourceAttributes::getResourceAttributePtr(env,
-                attributes);
-        return OIC::Service::RCSSetResponse::create(*attributesObj, nativeHandlerResult, errorCode);
-    }
-    else if (4 == type)
-    {
-        LOGI("Type == 4");
-        return OIC::Service::RCSSetResponse::accept();
-    }
-    else if (5 == type)
-    {
-        LOGI("Type == 5");
-        jmethodID midGetResult = env->GetMethodID(SetResponseClass, "getResult", "()I");
-        jmethodID midGetErrorCode = env->GetMethodID(SetResponseClass, "getErrorCode", "()I");
-        jint handlerResult = env->CallIntMethod(javaSetResponse, midGetResult);
-        jint errorCode = env->CallIntMethod(javaSetResponse, midGetErrorCode);
-        OCEntityHandlerResult nativeHandlerResult = convertIntToOCEntityHandlerResult(handlerResult);
-        return OIC::Service::RCSSetResponse::accept(nativeHandlerResult, errorCode);
-    }
-    else if (6 == type)
-    {
-        LOGI("Type == 6");
-        return OIC::Service::RCSSetResponse::ignore();
-    }
-    else if (7 == type)
-    {
-        LOGI("Type == 7");
-        jmethodID midGetResult = env->GetMethodID(SetResponseClass, "getResult", "()I");
-        jmethodID midGetErrorCode = env->GetMethodID(SetResponseClass, "getErrorCode", "()I");
-        jint handlerResult = env->CallIntMethod(javaSetResponse, midGetResult);
-        jint errorCode = env->CallIntMethod(javaSetResponse, midGetErrorCode);
-        OCEntityHandlerResult nativeHandlerResult = convertIntToOCEntityHandlerResult(handlerResult);
-        return OIC::Service::RCSSetResponse::ignore(nativeHandlerResult, errorCode);
-    }
-    else
-    {
-        LOGI("Default action");
-        return OIC::Service::RCSSetResponse::defaultAction();
-    }
-
-    if (env->ExceptionCheck())
-    {
-        LOGE("Java exception is thrown");
-        delete attributesObj;
-    }
-
-    checkExAndRemoveListener(env);
-    if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-    LOGI("JniGetRequestListener::onSetRequestCallback exit");
-}
-
-void JniSetRequestListener::checkExAndRemoveListener(JNIEnv *env)
-{
-    if (env->ExceptionCheck())
-    {
-        jthrowable ex = env->ExceptionOccurred();
-        env->ExceptionClear();
-        m_ownerResource->removeOnSetRequestListener(env, m_jwListener);
-        env->Throw((jthrowable)ex);
-    }
-    else
-    {
-        m_ownerResource->removeOnSetRequestListener(env, m_jwListener);
-    }
-}
diff --git a/service/resource-encapsulation/sdk/java/jni/re/src/jni_re_setattributes_listener.cpp b/service/resource-encapsulation/sdk/java/jni/re/src/jni_re_setattributes_listener.cpp
deleted file mode 100644 (file)
index 4da2491..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-/******************************************************************
- *
- * 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 "jni_re_setattributes_listener.h"
-#include "jni_re_rcs_remoteresourceobject.h"
-
-JniSetAttributesListener::JniSetAttributesListener(JNIEnv *env, jobject jListener,
-        JniRCSRemoteResourceObject *owner)
-    : m_ownerResource(owner)
-{
-    m_jwListener = env->NewWeakGlobalRef(jListener);
-}
-
-JniSetAttributesListener::~JniSetAttributesListener()
-{
-    LOGI("~JniGetAttributesListener()");
-    if (m_jwListener)
-    {
-        jint ret;
-        JNIEnv *env = GetREJNIEnv(ret);
-        if (NULL == env) return;
-        env->DeleteWeakGlobalRef(m_jwListener);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-    }
-}
-
-void JniSetAttributesListener::onRemoteAttributesSetCallback(OIC::Service::RCSResourceAttributes
-        attributes)
-{
-
-    LOGI("JniSetAttributesListener::onRemoteAttributesSetCallback : got attributes");
-
-    jint ret;
-    JNIEnv *env = GetREJNIEnv(ret);
-    if (NULL == env) return;
-
-    jobject jListener = env->NewLocalRef(m_jwListener);
-    if (!jListener)
-    {
-        checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-        return;
-    }
-
-    jclass clsL = env->GetObjectClass(jListener);
-
-    if (!clsL)
-    {
-        checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-        return;
-    }
-
-    RCSResourceAttributes *attributesObj = new RCSResourceAttributes(attributes);
-    jlong handle = reinterpret_cast<jlong>(attributesObj);
-    jobject jAttributes = env->NewObject(g_cls_RCSRemoteResourceAttributesObject,
-                                         g_mid_RCSRemoteResourceAttributesObject_ctor,
-                                         handle, true);
-    if (!jAttributes)
-    {
-        delete attributesObj;
-        checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-        return;
-    }
-
-    jmethodID midL = env->GetMethodID(clsL, "onRemoteAttributesSetCallback",
-                                      "(Lorg/iotivity/ResourceEncapsulation/common/RCSResourceAttributes;)V");
-
-    if (!midL)
-    {
-        delete attributesObj;
-        checkExAndRemoveListener(env);
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-        return;
-    }
-    env->CallVoidMethod(jListener, midL, jAttributes);
-    if (env->ExceptionCheck())
-    {
-        LOGE("Java exception is thrown");
-        delete attributesObj;
-    }
-
-    checkExAndRemoveListener(env);
-    if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
-}
-
-void JniSetAttributesListener::checkExAndRemoveListener(JNIEnv *env)
-{
-    if (env->ExceptionCheck())
-    {
-        jthrowable ex = env->ExceptionOccurred();
-        env->ExceptionClear();
-        m_ownerResource->removeOnsetAttributesListener(env, m_jwListener);
-        env->Throw((jthrowable)ex);
-    }
-    else
-    {
-        m_ownerResource->removeOnsetAttributesListener(env, m_jwListener);
-    }
-}
diff --git a/service/resource-encapsulation/sdk/java/project.properties b/service/resource-encapsulation/sdk/java/project.properties
deleted file mode 100644 (file)
index 93c8c3c..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system edit
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-#
-# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
-#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
-
-# Project target.
-target=android-21
-android.library=true
diff --git a/service/resource-encapsulation/sdk/java/src/org/iotivity/ResourceEncapsulation/client/RCSAddress.java b/service/resource-encapsulation/sdk/java/src/org/iotivity/ResourceEncapsulation/client/RCSAddress.java
deleted file mode 100644 (file)
index 294d180..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/******************************************************************
- *
- * 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.
- *
- ******************************************************************/
-/**
- * @file
- * This file provides a class for a set of APIs relating to resource address and the
- * the type of discovery request for a resource of interest.
- */
-
-package org.iotivity.ResourceEncapsulation.client;
-
-import org.iotivity.ResourceEncapsulation.utils.DiscoveryType;
-
-/**
- * This class provides a set of APIs for constructing RCSAddress object.
- *
- * <p>
- * RCSAddress object is the first parameter for Discover Resource APIs of
- * RCSDiscoveryManager Class.
- * <p>
- * {@link RCSDiscoveryManager}
- */
-public class RCSAddress {
-
-    static {
-        System.loadLibrary("gnustl_shared");
-        System.loadLibrary("oc_logger");
-        System.loadLibrary("connectivity_abstraction");
-        System.loadLibrary("ca-interface");
-        System.loadLibrary("octbstack");
-        System.loadLibrary("oc");
-        System.loadLibrary("ocstack-jni");
-        System.loadLibrary("rcs_common");
-        System.loadLibrary("rcs_client");
-        System.loadLibrary("rcs_server");
-        System.loadLibrary("rcs_container");
-        System.loadLibrary("re-jni");
-    }
-
-    private String            m_address;
-    private DiscoveryType     m_typeOfDiscovery;
-    private static RCSAddress m_rcsAddressInstance;
-
-    private RCSAddress(String addr, DiscoveryType discoveryType) {
-        m_address = addr;
-        m_typeOfDiscovery = discoveryType;
-    }
-
-    /**
-     * Constructs a RCSAddress object for multicast discovery.
-     *
-     * @return RCSAddress - Instance of RCSAddress.
-     *
-     *         {@link RCSAddress}
-     */
-    public static RCSAddress multicast() {
-        m_rcsAddressInstance = new RCSAddress("", DiscoveryType.MULTICAST);
-        return m_rcsAddressInstance;
-    }
-
-    /**
-     * Constructs a RCSAddress object for setting unicast discovery.
-     *
-     * @param address
-     *            required discovery address for the unicast resource discovery.
-     *
-     * @return RCSAddress -Instance of RCSAddress.
-     *
-     *         {@link RCSAddress}
-     */
-    public static RCSAddress unicast(String address) {
-        m_rcsAddressInstance = new RCSAddress(address, DiscoveryType.UNICAST);
-        return m_rcsAddressInstance;
-    }
-
-    // APIs used by DiscoveryManager class for getting the address information.
-
-    /**
-     * Get the discovery resource address in string format.
-     *
-     * @return String - Discovery address in string format.
-     */
-    public String getAddress() {
-        return m_address;
-    }
-
-    /**
-     * Get the resource discovery type(unicast or multicast).
-     *
-     * @return int - 0 for unicast and 1 for multicast.
-     */
-    public DiscoveryType getTypeOfDiscovery() {
-        return m_typeOfDiscovery;
-    }
-}
diff --git a/service/resource-encapsulation/sdk/java/src/org/iotivity/ResourceEncapsulation/client/RCSDiscoveryManager.java b/service/resource-encapsulation/sdk/java/src/org/iotivity/ResourceEncapsulation/client/RCSDiscoveryManager.java
deleted file mode 100644 (file)
index 67ac7a5..0000000
+++ /dev/null
@@ -1,190 +0,0 @@
-/******************************************************************
- *
- * 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.
- *
- ******************************************************************/
-/**
- * @file
- * This file provides a class for a set of APIs relating to discovery of a particular
- * resource in the network
- */
-
-package org.iotivity.ResourceEncapsulation.client;
-
-import org.iotivity.ResourceEncapsulation.common.RCSException;
-import org.iotivity.ResourceEncapsulation.utils.DiscoveryType;
-
-import android.util.Log;
-
-/**
- * This class contains the resource discovery method.
- *
- * {@link RCSRemoteResourceObject}
- */
-public class RCSDiscoveryManager {
-
-    private IDiscoverResourceListener  m_discoverListener;
-    private static RCSDiscoveryManager m_rcsDiscoveryManagerInstacne;
-    private final String               OC_RSRVD_WELL_KNOWN_URI = "/oic/res";
-    private final String               LOG_TAG                 = this.getClass()
-                                                                       .getSimpleName();
-
-    private native void discoverResource(String address, int typeOfDiscovery,
-            String relativeUri, String resourceType,
-            IDiscoverResourceListener listener);
-
-    /**
-     * Constructor for RCSDiscoveryManager. Set listener to null on constructing
-     * new RCSDiscoveryManager.
-     */
-    private RCSDiscoveryManager() {
-    }
-
-    /**
-     * Returns RCSDiscoveryManager instance if already present else creates a
-     * new instance of RCSDiscoveryManager.
-     *
-     * @return RCSDiscoveryManager - Instance of RCSDiscoveryManager.
-     */
-    public static RCSDiscoveryManager getInstance() {
-        if (null == m_rcsDiscoveryManagerInstacne) {
-            m_rcsDiscoveryManagerInstacne = new RCSDiscoveryManager();
-        }
-        return m_rcsDiscoveryManagerInstacne;
-    }
-
-    /**
-     * Provides interface for receiving the callback for discovering a resource
-     * of interest.
-     */
-    public interface IDiscoverResourceListener {
-
-        /**
-         * This callback method is called when a asynchronous response for the
-         * discoverResource request is received.
-         *
-         * @param rcsRemoteResourceObject
-         *            It is the resource for which discovery is requested..
-         *
-         *            {@link RCSDiscoveryManager}
-         *            {@link RCSRemoteResourceObject}
-         */
-        public void onResourceDiscovered(
-                RCSRemoteResourceObject rcsRemoteResourceObject);
-
-    }
-
-    /**
-     * Set listener for receiving asynchronous response for resource discovery
-     * request.
-     *
-     * @param listener
-     *            setDiscoverResourceListener to receive the discovered
-     *            resources.
-     */
-    public void setDiscoverResourceListener(IDiscoverResourceListener listener) {
-        m_discoverListener = listener;
-    }
-
-    /**
-     * API for discovering the resource of Interest, regardless of URI and
-     * resource type
-     *
-     * @param address
-     *            A RCSAddress object
-     *
-     * @throws RCSException
-     *             {@link RCSAddress}
-     */
-    public void discoverResource(RCSAddress address) throws RCSException {
-
-        Log.i(LOG_TAG, "discoverResource called");
-        discoverResourceByType(address, OC_RSRVD_WELL_KNOWN_URI, "");
-    }
-
-    /**
-     * API for discovering the resource of Interest, regardless of resource
-     * type.
-     *
-     * @param address
-     *            A RCSAddress object
-     * @param relativeURI
-     *            The relative uri of resource to be searched
-     *
-     * @throws RCSException
-     *             {@link RCSAddress}
-     */
-    public void discoverResource(RCSAddress address, String relativeURI)
-            throws RCSException {
-
-        Log.i(LOG_TAG, "discoverResource called");
-        discoverResourceByType(address, relativeURI, "");
-    }
-
-    /**
-     * API for discovering the resource of Interest by resource type.
-     *
-     * @param address
-     *            A RCSAddress object
-     * @param resourceType
-     *            Ressource Type
-     *
-     * @throws RCSException
-     *             {@link RCSAddress}
-     */
-    public void discoverResourceByType(RCSAddress address, String resourceType)
-            throws RCSException {
-
-        Log.i(LOG_TAG, "discoverResource called");
-        discoverResourceByType(address, OC_RSRVD_WELL_KNOWN_URI, resourceType);
-    }
-
-    /**
-     * API for discovering the resource of Interest by Resource type with
-     * provided relativeURI
-     *
-     * @param address
-     *            A RCSAddress object
-     * @param relativeURI
-     *            The relative uri of resource to be searched
-     * @param resourceType
-     *            Ressource Type
-     *
-     * @throws RCSException
-     *             {@link RCSAddress}
-     */
-    public void discoverResourceByType(RCSAddress address, String relativeURI,
-            String resourceType) throws RCSException {
-
-        Log.i(LOG_TAG, "discoverResource called");
-
-        if(null == address){
-            Log.e(LOG_TAG, "Empty Address");
-            throw (new RCSException("Empty Address"));
-        }
-        String addr = address.getAddress();
-
-        if(null == relativeURI || "" == relativeURI){
-            Log.e(LOG_TAG, "Empty URI");
-            throw (new RCSException("Empty URI"));
-        }
-
-        DiscoveryType typeOfDiscovery = address.getTypeOfDiscovery();
-        this.discoverResource(addr, typeOfDiscovery.ordinal(), relativeURI,
-                resourceType, m_discoverListener);
-    }
-}
diff --git a/service/resource-encapsulation/sdk/java/src/org/iotivity/ResourceEncapsulation/client/RCSRemoteResourceObject.java b/service/resource-encapsulation/sdk/java/src/org/iotivity/ResourceEncapsulation/client/RCSRemoteResourceObject.java
deleted file mode 100644 (file)
index a586a3b..0000000
+++ /dev/null
@@ -1,599 +0,0 @@
-/******************************************************************
- *
- * 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.
- *
- ******************************************************************/
-/**
- * @file
- * This file provides a class which provides a set of native functions and API's
- * of resource client, provided to the developers.
- */
-
-package org.iotivity.ResourceEncapsulation.client;
-
-import java.util.List;
-import java.util.Vector;
-
-import org.iotivity.ResourceEncapsulation.common.RCSException;
-import org.iotivity.ResourceEncapsulation.common.RCSResourceAttributes;
-
-import android.util.Log;
-
-/**
- *
- * The resource can be discovered with discoverResource. On successful resource
- * discovery an instance of this class is returned. This class is an interaction
- * point between Resource and the developers. Developer will get the
- * RCSRemoteResourceObject by calling RCSDiscoveryManager's discoverResource
- * API.
- *
- * {@link RCSDiscoveryManager}
- */
-public class RCSRemoteResourceObject {
-
-    private IStateChangedCallbackListener m_stateChangedListener;
-    private ICacheUpdateListener          m_cacheUpdateListener;
-    private IGetRemoteAttributeListener   m_getremoteAttributeListener;
-    private ISetRemoteAttributeListener   m_setremoteAttributeListener;
-    private long                          m_nativeHandle;
-    private String                        LOG_TAG = this.getClass()
-                                                          .getSimpleName();
-
-    // native methods
-    private native boolean nativeIsMonitoring();
-
-    private native boolean nativeIsCaching();
-
-    private native boolean nativeIsObservable();
-
-    private native void nativeStartMonitoring(
-            IStateChangedCallbackListener listener);
-
-    private native void nativeStopMonitoring();
-
-    private native int nativeGetState();
-
-    private native void nativeStartCaching(ICacheUpdateListener listener);
-
-    private native void nativeStopCaching();
-
-    private native int nativeGetCacheState();
-
-    private native boolean nativeIsCachedAvailable();
-
-    private native RCSResourceAttributes nativeGetCachedAttributes();
-
-    private native String nativeGetCachedAttribute(String key);
-
-    private native void nativeGetRemoteAttributes(
-            IGetRemoteAttributeListener listener);
-
-    private native void nativeSetRemoteAttributes(
-            RCSResourceAttributes attributes,
-            ISetRemoteAttributeListener listener);
-
-    private native String nativeGetUri();
-
-    private native String nativeGetAddress();
-
-    private native List<String> nativeGetTypes();
-
-    private native List<String> nativeGetInterFaces();
-
-    private RCSRemoteResourceObject(long nativeHandle) {
-        this.m_nativeHandle = nativeHandle;
-    }
-
-    /**
-     * This Enum contains Status codes for resource state.
-     *
-     * <p>
-     * Developer will get the ResoureState as a result of getState API of
-     * RCSRemoteResourceObject class and as a callback result of startMonitoring
-     * API
-     *
-     * {@link RCSRemoteResourceObject}
-     */
-    public enum ResourceState {
-
-        NONE, /* < Monitoring is not started. */
-        REQUESTED, /*
-                    * < Monitoring is started and checking state is in progress.
-                    * This is the default state after startMonitoring.
-                    */
-        ALIVE, /* < The resource is alive. */
-        LOST_SIGNAL, /* < Failed to reach the resource. */
-        DESTROYED;
-        /* < The resource is deleted. */
-
-        /*
-         * Utility API for integer to enum conversion.
-         */
-        public static ResourceState getResourceState(int ordinal) {
-
-            if (ordinal == 0)
-                return ResourceState.values()[0];
-            else if (ordinal == 1)
-                return ResourceState.values()[1];
-            else if (ordinal == 2)
-                return ResourceState.values()[2];
-            else if (ordinal == 3)
-                return ResourceState.values()[3];
-            else if (ordinal == 4)
-                return ResourceState.values()[4];
-
-            return null;
-        }
-    }
-
-    /**
-     * This Enum contains Status codes for cache state.
-     *
-     * <p>
-     * Application will get this CacheState as a result of getCacheState API of
-     * RCSRemoteResourceObject class
-     *
-     * {@link RCSRemoteResourceObject}
-     */
-    public enum CacheState {
-
-        NONE, /* < Caching is not started. */
-        UNREADY, /*
-                  * < Caching is started, but the data is not ready yet. This is
-                  * the default state after startCaching.
-                  */
-        READY, /* < The data is ready. */
-        LOST_SIGNAL;
-        /* < Failed to reach the resource. */
-
-        /*
-         * Utility API for int to enum conversion.
-         */
-        public static CacheState getCacheState(int ordinal) {
-
-            if (ordinal == 0)
-                return CacheState.values()[0];
-            else if (ordinal == 1)
-                return CacheState.values()[1];
-            else if (ordinal == 2)
-                return CacheState.values()[2];
-            else if (ordinal == 3)
-                return CacheState.values()[3];
-
-            return null;
-        }
-    }
-
-    /**
-     * Provides interface for receiving the callback on cache update.
-     */
-    public interface ICacheUpdateListener {
-
-        /**
-         * This callback method is called when a asynchronous response for
-         * startCaching request is received. Listener should be set to receive
-         * this callback.
-         *
-         * @param attributes
-         *            It is the updated resource attributes.
-         *
-         *            {@link RCSResourceAttributes}
-         */
-        public void onCacheUpdatedCallback(RCSResourceAttributes attributes);
-
-    }
-
-    /**
-     * Provides interface for receiving the callback for the getRemoteAttributes
-     * requested action.
-     */
-    public interface IGetRemoteAttributeListener {
-
-        /**
-         * This callback method is called when a asynchronous response for the
-         * getRemoteAttributes request is received.
-         *
-         * @param attributes
-         *            It is the updated resource attributes value received from
-         *            the remote resource.
-         *
-         *            {@link RCSResourceAttributes}
-         */
-        public void onRemoteAttributesGetCallback(
-                RCSResourceAttributes attributes);
-
-    }
-
-    /**
-     * Provides interface for receiving the callback for the setRemoteAttributes
-     * requested action.
-     */
-    public interface ISetRemoteAttributeListener {
-
-        /**
-         * This callback method is called when a asynchronous response for the
-         * setRemoteAttributes request is received.
-         *
-         * @param attributes
-         *            It is the updated resource attributes value received from
-         *            the remote resource.
-         *
-         *            {@link RCSResourceAttributes}
-         */
-        public void onRemoteAttributesSetCallback(
-                RCSResourceAttributes attributes);
-
-    }
-
-    /**
-     * Provides interface for receiving the callback for the startMonitoring
-     * This callback is received on remote resource state change.
-     */
-    public interface IStateChangedCallbackListener {
-
-        /**
-         * This callback method is called when a asynchronous response for the
-         * startMonitoring request is received.
-         *
-         * @param resourceState
-         *            It gives the current remote resource state.
-         *
-         *            {@link ResourceState}
-         */
-        public void onStateChanged(ResourceState resourceState);
-    }
-
-    /**
-     * Set listener for receiving asynchronous response for cache updates.
-     *
-     * @param listener
-     *            ICacheUpdateListener to receive asynchronous response for
-     *            cache updates.
-     */
-    public void setCacheUpdateListener(ICacheUpdateListener listener) {
-        m_cacheUpdateListener = listener;
-    }
-
-    /**
-     * Set listener for receiving asynchronous response for remote resource
-     * state changes.
-     *
-     * @param listener
-     *            IStateChangedCallbackListener to receive asynchronous response
-     *            for remote resource state changes.
-     */
-    public void setStateChangedListener(IStateChangedCallbackListener listener) {
-        m_stateChangedListener = listener;
-    }
-
-    /**
-     * Set listener for receiving asynchronous response for resource attributes
-     * GET request.
-     *
-     * @param listener
-     *            IGetRemoteAttributeListener to receive asynchronous response
-     *            for resource attributes SET and GET request.
-     */
-    public void setGetRemoteAttributesListener(
-            IGetRemoteAttributeListener listener) {
-        m_getremoteAttributeListener = listener;
-    }
-
-    /**
-     * Set listener for receiving asynchronous response for resource attributes
-     * SET request.
-     *
-     * @param listener
-     *            IGetRemoteAttributeListener to receive asynchronous response
-     *            for resource attributes SET and GET request.
-     */
-    public void setSetRemoteAttributesListener(
-            ISetRemoteAttributeListener listener) {
-        m_setremoteAttributeListener = listener;
-    }
-
-    /**
-     * Returns whether monitoring is enabled.
-     *
-     * @return boolean - true if monitoring the resource.
-     *
-     *         {@link #startMonitoring()}
-     */
-    public boolean isMonitoring() {
-
-        Log.i(LOG_TAG, "isMonitoring called");
-        return this.nativeIsMonitoring();
-    }
-
-    /**
-     * Returns whether caching is enabled.
-     *
-     * @return boolean - true if caching the resource.
-     *
-     *         {@link #startCaching()}
-     */
-    public boolean isCaching() {
-
-        Log.i(LOG_TAG, "isCaching called");
-        return this.nativeIsCaching();
-    }
-
-    /**
-     * Returns whether resource is observable.
-     *
-     * @return boolean - true if resource is observable.
-     *
-     */
-    public boolean isObservable() {
-
-        Log.i(LOG_TAG, "isObservable called");
-        return this.nativeIsObservable();
-    }
-
-    /**
-     * Starts monitoring the resource.
-     * <p>
-     * Monitoring provides a feature to check the presence of a resource, even
-     * when the server is not announcing Presence using startPresnece.
-     * <p>
-     * StateChangedListener should be set before calling this API
-     *
-     * @throws RCSException
-     *             If monitoring is already started.
-     *
-     *             {@link IStateChangedCallbackListener} {@link ResourceState}
-     *             {@link #isMonitoring()} {@link #stopMonitoring()}
-     */
-    public void startMonitoring() throws RCSException {
-
-        Log.i(LOG_TAG, "startMonitoring called");
-        this.nativeStartMonitoring(m_stateChangedListener);
-    }
-
-    /**
-     * Stop monitoring the resource.
-     * <p>
-     * It does nothing if monitoring is not started.
-     * <p>
-     * {@link #startMonitoring()}
-     *
-     */
-    public void stopMonitoring() {
-
-        Log.i(LOG_TAG, "stopMonitoring called");
-        this.nativeStopMonitoring();
-    }
-
-    /**
-     * Returns the current state of the resource.
-     *
-     * @return ResourceState - current resource state
-     *
-     *         {@link #startMonitoring()} {@link ResourceState}
-     */
-    public ResourceState getState() {
-
-        Log.i(LOG_TAG, "getState called");
-        int state = this.nativeGetState();
-
-        return ResourceState.getResourceState(state);
-    }
-
-    /**
-     * Starts caching attributes of the resource.
-     *
-     * This will start data caching for the resource. Once caching started it
-     * will look for the data updation on the resource and updates the cache
-     * data accordingly.
-     *
-     * @throws RCSException
-     *
-     *             <p>
-     *             If this method is called with null listener it will not
-     *             notify the updated value to caller. It it is called with a
-     *             valid listener updated cached values will be notified to
-     *             caller.
-     *
-     *             {@link #getCacheState()} {@link #getCachedAttributes()}
-     */
-    public void startCaching() throws RCSException {
-
-        if (null == m_cacheUpdateListener) {
-            Log.i(LOG_TAG, "startCaching WITHOUT callback");
-        } else {
-            Log.i(LOG_TAG, "startCaching WITH callback");
-        }
-
-        this.nativeStartCaching(m_cacheUpdateListener);
-    }
-
-    /**
-     * Stops caching.
-     *
-     * It does nothing if caching is not started.
-     *
-     * {@link #startCaching()}
-     */
-    public void stopCaching() {
-
-        Log.i(LOG_TAG, "stopCaching called");
-        this.nativeStopCaching();
-    }
-
-    /**
-     * Returns the current cache state.
-     *
-     * @return CacheState - current cache state.
-     *
-     *         {@link CacheState}
-     */
-    public CacheState getCacheState() {
-
-        Log.i(LOG_TAG, "getCacheState called");
-        return CacheState.getCacheState(this.nativeGetCacheState());
-    }
-
-    /**
-     * Returns whether cached data is available.
-     *
-     * Cache will be available always after cache state READY even if current
-     * state is LOST_SIGNAL.
-     *
-     * @return boolean - true if cache data is available.
-     *
-     *         {@link #startCaching()} {@link CacheState}
-     */
-    public boolean isCachedAvailable() {
-
-        Log.i(LOG_TAG, "isCachedAvailable called");
-        return this.nativeIsCachedAvailable();
-    }
-
-    /**
-     * Gets the cached RCSResourceAttributes data.
-     *
-     * <p>
-     * Cache should be available.
-     *
-     * @return The cached attributes.
-     *
-     * @throws RCSException
-     *             If the Cache is not started.
-     *
-     *             {@link RCSResourceAttributes} {@link #isCachedAvailable()}
-     *             {@link #startCaching()}
-     */
-    public RCSResourceAttributes getCachedAttributes() throws RCSException {
-
-        Log.i(LOG_TAG, "getCachedAttributes called");
-        return this.nativeGetCachedAttributes();
-    }
-
-    /**
-     * Gets a particular cached ResourceAttribute Value.
-     *
-     * <p>
-     * Cache should be available.
-     *
-     * @param key
-     *            particular attribute name as a string to get the value for.
-     *
-     * @return String - Requested attribute value in string.
-     *
-     * @throws RCSException
-     *             If the Cache is not started or InvalidKeyException If @a key
-     *             doesn't match the key of any value.
-     *
-     *             {@link RCSResourceAttributes} {@link #isCachedAvailable()}
-     *             {@link #startCaching()}
-     */
-    public String getCachedAttribute(String key) throws RCSException {
-
-        Log.i(LOG_TAG, "getCachedAttribute called");
-        return this.nativeGetCachedAttribute(key);
-    }
-
-    /**
-     * Gets resource attributes directly from the server.
-     *
-     * This API send a get request to the resource of interest and provides the
-     * attributes to the caller in the RemoteAttributesReceivedCallback.
-     *
-     * <p>
-     * IGetRemoteAttributeListener should be set to get the attributes
-     *
-     * @throws RCSException
-     *             {@link IGetRemoteAttributeListener}
-     */
-    public void getRemoteAttributes() throws RCSException {
-
-        Log.i(LOG_TAG, "getRemoteAttributes called");
-        this.nativeGetRemoteAttributes(m_getremoteAttributeListener);
-    }
-
-    /**
-     * Sends a set request with resource attributes to the server.
-     *
-     * The SetRequest behavior depends on the server, whether updating its
-     * attributes or not.
-     *
-     * @param attributes
-     *            Attribute value to set for the remote resource.
-     *
-     *            <p>
-     *            ISetRemoteAttributeListener should be set to call this API
-     *
-     * @throws RCSException
-     *             {@link ISetRemoteAttributeListener}
-     */
-    public void setRemoteAttributes(RCSResourceAttributes attributes)
-            throws RCSException {
-
-        Log.i(LOG_TAG, "getRemoteAttributes called");
-        this.nativeSetRemoteAttributes(attributes, m_setremoteAttributeListener);
-    }
-
-    /**
-     * Returns the uri of the resource.
-     *
-     * @return Uri of the resource
-     */
-    public String getUri() {
-
-        Log.i(LOG_TAG, "getUri called");
-        return this.nativeGetUri();
-    }
-
-    /**
-     * Returns the address of the resource .
-     *
-     * @return Address of the resource
-     */
-    public String getAddress() {
-
-        Log.i(LOG_TAG, "getAddress called");
-        return this.nativeGetAddress();
-    }
-
-    /**
-     * Returns the resource types of the resource.
-     *
-     * @return vector containing resource types
-     */
-    public Vector<String> getTypes() {
-
-        Log.i(LOG_TAG, "getTypes called");
-        List<String> types = this.nativeGetTypes();
-        Vector<String> resourceType = new Vector<String>();
-        resourceType.addAll(types);
-        return resourceType;
-    }
-
-    /**
-     * Returns the resource interfaces of the resource.
-     *
-     * @return vector containing resource Interfaces
-     */
-    public Vector<String> getInterFaces() {
-
-        Log.i(LOG_TAG, "getInterFaces called");
-        List<String> interfaces = this.nativeGetInterFaces();
-        Vector<String> resourceInterfaces = new Vector<String>();
-        resourceInterfaces.addAll(interfaces);
-        return resourceInterfaces;
-    }
-}
diff --git a/service/resource-encapsulation/sdk/java/src/org/iotivity/ResourceEncapsulation/common/RCSResourceAttributes.java b/service/resource-encapsulation/sdk/java/src/org/iotivity/ResourceEncapsulation/common/RCSResourceAttributes.java
deleted file mode 100644 (file)
index d3fd7e6..0000000
+++ /dev/null
@@ -1,562 +0,0 @@
-/******************************************************************
- *
- * 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.
- *
- ******************************************************************/
-/**
- * @file
- * This file provides a class which represents the attributes for a resource.
- */
-
-package org.iotivity.ResourceEncapsulation.common;
-
-import java.util.Vector;
-
-import org.iotivity.ResourceEncapsulation.client.RCSDiscoveryManager;
-import org.iotivity.ResourceEncapsulation.client.RCSRemoteResourceObject;
-import org.iotivity.ResourceEncapsulation.server.RCSResourceObject;
-
-/**
- * RCSResourceAttributes represents the attributes for a resource.
- *
- * An attribute value can be one of types specified in enum
- * "AttriubtesGetValueTypes"
- *
- * <p>
- * If developer on client side wants to get the RCSResourceAttributes for the
- * resource of interest following are the steps: - first call the discover API
- * of DiscoveryManager class. - After getting the RemoteResourceObject, call
- * getRemoteAttributes() API of RemoteResourceObject class
- *
- * If the developer on server side wants to get the attributes following are the
- * steps: Call the getAttributes() API of RCSResourceObject class.
- *
- * {@link RCSDiscoveryManager} {@link RCSRemoteResourceObject}
- * {@link RCSResourceObject} {@link AttriubtesGetValueTypes}
- */
-public class RCSResourceAttributes {
-
-    private long    m_nativeHandle;
-    private boolean m_nativeNeedsDelete;
-
-    // native methods
-    private native Object nativeGetValueN(String key, int type);
-
-    private native void nativeSetValueInt(String key, int value);
-
-    private native void nativeSetValueVectorOfInt(String key,
-            Vector<Integer> values);
-
-    private native void nativeSetValueVectorOfVectorOfInt(String key,
-            Vector<Vector<Integer>> values);
-
-    private native void nativeSetValueVectorOfVectorOfVectorOfInt(String key,
-            Vector<Vector<Vector<Integer>>> values);
-
-    private native void nativeSetValueDouble(String key, double value);
-
-    private native void nativeSetValueVectorOfDouble(String key,
-            Vector<Double> values);
-
-    private native void nativeSetValueVectorOfVectorOfDouble(String key,
-            Vector<Vector<Double>> values);
-
-    private native void nativeSetValueVectorOfVectorOfVectorOfDouble(
-            String key, Vector<Vector<Vector<Double>>> values);
-
-    private native void nativeSetValueBoolean(String key, boolean value);
-
-    private native void nativeSetValueVectorOfBoolean(String key,
-            Vector<Boolean> values);
-
-    private native void nativeSetValueVectorOfVectorOfBoolean(String key,
-            Vector<Vector<Boolean>> values);
-
-    private native void nativeSetValueVectorOfVectorOfVectorOfBoolean(
-            String key, Vector<Vector<Vector<Boolean>>> values);
-
-    private native void nativeSetValueString(String key, String value);
-
-    private native void nativeSetValueVectorOfString(String key,
-            Vector<String> values);
-
-    private native void nativeSetValueVectorOfVectorOfString(String key,
-            Vector<Vector<String>> values);
-
-    private native void nativeSetValueVectorOfVectorOfVectorOfString(
-            String key, Vector<Vector<Vector<String>>> values);
-
-    private native void nativeSetValueAttributes(String key,
-            RCSResourceAttributes value);
-
-    private native boolean nativeIsEmpty();
-
-    private native int nativeSize();
-
-    private native boolean nativeRemove(String key);
-
-    private native boolean nativeHasAttribute(String key);
-
-    private native void create();
-
-    private native void dispose(boolean needsDelete);
-
-    /**
-     * Constructor for RCSResourceAttributes. Invokes create() which internally
-     * constructs a new RCSResourceAttributes and sets its handle.
-     *
-     * <p>
-     * Native RCSResourceAttributes object was created using "new" and needs to
-     * be deleted
-     */
-    public RCSResourceAttributes() {
-        create();
-        this.m_nativeNeedsDelete = true;
-    }
-
-    private RCSResourceAttributes(long nativeHandle) {
-        this.m_nativeHandle = nativeHandle;
-        this.m_nativeNeedsDelete = false;
-    }
-
-    private RCSResourceAttributes(long nativeHandle, boolean nativeNeedsDelete) {
-        this.m_nativeHandle = nativeHandle;
-        this.m_nativeNeedsDelete = nativeNeedsDelete;
-    }
-
-    /**
-     * Get the Resource Attribute value.
-     *
-     * @param key
-     *            Key for which value is requested
-     *
-     * @param type
-     *            AttriubtesGetValueTypes
-     *
-     * @return Value of the attribute.
-     *
-     * @throws RCSException
-     *             In case of bad Request
-     *
-     *             {@link AttriubtesGetValueTypes}
-     */
-    public <T> T getValue(String key, AttriubtesGetValueTypes type)
-            throws RCSException {
-        Object obj = this.nativeGetValueN(key, type.ordinal());
-        T t = (T) obj;
-        return t;
-    }
-
-    /**
-     * Set Integer as Attribute value.
-     *
-     * @param key
-     *            Key of the element to be added.
-     *
-     * @param value
-     *            integer value to be set.
-     *
-     * @throws RCSException
-     *             In case of bad Request
-     */
-    public void setValueInt(String key, int value) throws RCSException {
-        try {
-            this.nativeSetValueInt(key, value);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * Set Vector of Integer as Attribute Value.
-     *
-     * @param key
-     *            Key of the element to be added.
-     *
-     * @param values
-     *            Vector of integer to be set.
-     *
-     * @throws RCSException
-     *             In case of bad Request
-     */
-    public void setValueVectorOfInt(String key, Vector<Integer> values) {
-        try {
-            this.nativeSetValueVectorOfInt(key, values);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * Set Vector of Vector of Integer as Attribute Value.
-     *
-     * @param key
-     *            Key of the element to be added.
-     *
-     * @param values
-     *            Vector of Vector of integer to be set.
-     *
-     * @throws RCSException
-     *             In case of bad Request
-     */
-    public void setValueVectorOfVectorInt(String key,
-            Vector<Vector<Integer>> values) {
-        try {
-            this.nativeSetValueVectorOfVectorOfInt(key, values);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * Set Vector Vector of Vector of Integer as Attribute Value.
-     *
-     * @param key
-     *            Key of the element to be added.
-     *
-     * @param values
-     *            Vector of Vector of Vector of integer to be set.
-     *
-     * @throws RCSException
-     *             In case of bad Request
-     */
-    public void setValueVectorOfVectorOfVectorInt(String key,
-            Vector<Vector<Vector<Integer>>> values) {
-        try {
-            this.nativeSetValueVectorOfVectorOfVectorOfInt(key, values);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * set a double attribute value.
-     *
-     * @param key
-     *            Key of the element to be added.
-     *
-     * @param value
-     *            double value of key to be set.
-     *
-     * @throws RCSException
-     *             In case of bad Request
-     */
-    public void setValueDouble(String key, double value) throws RCSException {
-        try {
-            this.nativeSetValueDouble(key, value);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * Set Vector of double as Attribute Value.
-     *
-     * @param key
-     *            Key of the element to be added.
-     *
-     * @param values
-     *            Vector of double value of key to be set.
-     *
-     * @throws RCSException
-     *             In case of bad Request
-     */
-    public void setValueVectorOfDouble(String key, Vector<Double> values) {
-        try {
-            this.nativeSetValueVectorOfDouble(key, values);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * Set Vector of Vector of double as Attribute Value.
-     *
-     * @param key
-     *            Key of the element to be added.
-     *
-     * @param values
-     *            Vector of vector of double value of key to be set.
-     *
-     * @throws RCSException
-     *             In case of bad Request
-     */
-    public void setValueVectorOfVectorOfDouble(String key,
-            Vector<Vector<Double>> values) {
-        try {
-            this.nativeSetValueVectorOfVectorOfDouble(key, values);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * Set Vector Vector of Vector of double as Attribute Value.
-     *
-     * @param key
-     *            Key of the element to be added.
-     *
-     * @param values
-     *            Vector of Vector of Vector of double value of key to be set.
-     *
-     * @throws RCSException
-     *             In case of bad Request
-     */
-    public void setValueVectorOfVectorOfVectorOfDouble(String key,
-            Vector<Vector<Vector<Double>>> values) {
-        try {
-            this.nativeSetValueVectorOfVectorOfVectorOfDouble(key, values);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * set a boolean attribute value.
-     *
-     * @param key
-     *            Key of the element to be added.
-     *
-     * @param values
-     *            boolean value of key to be set.
-     *
-     * @throws RCSException
-     *             In case of bad Request
-     *
-     */
-    public void setValueBool(String key, boolean value) throws RCSException {
-        try {
-            this.nativeSetValueBoolean(key, value);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * Set Vector of boolean as Attribute Value.
-     *
-     * @param key
-     *            Key of the element to be added.
-     *
-     * @param values
-     *            Vector of boolean value of key to be set.
-     *
-     * @throws RCSException
-     *             In case of bad Request
-     */
-    public void setValueVectorOfBool(String key, Vector<Boolean> values) {
-        try {
-            this.nativeSetValueVectorOfBoolean(key, values);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * Set Vector of Vector of boolean as Attribute Value.
-     *
-     * @param key
-     *            Key of the element to be added.
-     *
-     * @param values
-     *            Vector of vector of boolean value of key to be set.
-     *
-     * @throws RCSException
-     *             In case of bad Request
-     */
-    public void setValueVectorOfVectorOfBool(String key,
-            Vector<Vector<Boolean>> values) {
-        try {
-            this.nativeSetValueVectorOfVectorOfBoolean(key, values);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * Set Vector Vector of Vector of boolean as Attribute Value.
-     *
-     * @param key
-     *            Key of the element to be added.
-     *
-     * @param values
-     *            Vector of Vector of Vector of boolean value of key to be set.
-     *
-     * @throws RCSException
-     *             In case of bad Request
-     */
-    public void setValueVectorOfVectorOfVectorOfBool(String key,
-            Vector<Vector<Vector<Boolean>>> values) {
-        try {
-            this.nativeSetValueVectorOfVectorOfVectorOfBoolean(key, values);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * set a string attribute value.
-     *
-     * @param key
-     *            Key of the element to be added.
-     *
-     * @param value
-     *            String value of key to be set.
-     *
-     * @throws RCSException
-     *             In case of bad Request
-     */
-    public void setValueString(String key, String value) throws RCSException {
-        try {
-            this.nativeSetValueString(key, value);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * Set Vector of String as Attribute Value.
-     *
-     * @param key
-     *            Key of the element to be added.
-     *
-     * @param values
-     *            Vector of String value of key to be set.
-     *
-     * @throws RCSException
-     *             In case of bad Request
-     */
-    public void setValueVectorOfString(String key, Vector<String> values) {
-        try {
-            this.nativeSetValueVectorOfString(key, values);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * Set Vector of Vector of String as Attribute Value.
-     *
-     * @param key
-     *            Key of the element to be added.
-     *
-     * @param values
-     *            Vector of vector of String value of key to be set.
-     *
-     * @throws RCSException
-     *             In case of bad Request
-     */
-    public void setValueVectorOfVectorOfString(String key,
-            Vector<Vector<String>> values) {
-        try {
-            this.nativeSetValueVectorOfVectorOfString(key, values);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * Set Vector Vector of Vector of String as Attribute Value.
-     *
-     * @param key
-     *            Key of the element to be added.
-     *
-     * @param values
-     *            Vector of Vector of Vector of String value of key to be set.
-     *
-     * @throws RCSException
-     *             In case of bad Request
-     */
-    public void setValueVectorOfVectorOfVectorOfString(String key,
-            Vector<Vector<Vector<String>>> values) {
-        try {
-            this.nativeSetValueVectorOfVectorOfVectorOfString(key, values);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * set a Attribute as attribute value.
-     *
-     * @param key
-     *            Key of the element to be added.
-     *
-     * @param values
-     *            RCSResourceAttributes to be set.
-     *
-     * @throws RCSException
-     *             In case of bad Request
-     */
-    public void setValueAttributes(String key, RCSResourceAttributes value)
-            throws RCSException {
-        try {
-            this.nativeSetValueAttributes(key, value);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * Returns whether attribute is empty.
-     *
-     * @return boolean
-     */
-    public boolean isEmpty() {
-        return this.nativeIsEmpty();
-    }
-
-    /**
-     * Returns the number of elements.
-     *
-     * @return boolean
-     */
-    public int size() {
-        return this.nativeSize();
-    }
-
-    /**
-     * Removes a single attribute
-     *
-     * @param key
-     *            Key to be removed.
-     *
-     * @return true if an attribute is removed, false otherwise.
-     */
-    public boolean remove(String key) {
-        return this.nativeRemove(key);
-    }
-
-    /**
-     * Checks the container has an attribute with a Key equivalent to the
-     * provided key.
-     *
-     * @param key
-     *            Key to check.
-     *
-     * @return true if an attribute with requests key exists, false otherwise.
-     */
-    public boolean hasAttribute(String key) {
-        return this.nativeHasAttribute(key);
-    }
-
-    @Override
-    protected void finalize() throws Throwable {
-        super.finalize();
-        dispose(this.m_nativeNeedsDelete);
-    }
-}
diff --git a/service/resource-encapsulation/sdk/java/src/org/iotivity/ResourceEncapsulation/server/Builder.java b/service/resource-encapsulation/sdk/java/src/org/iotivity/ResourceEncapsulation/server/Builder.java
deleted file mode 100644 (file)
index a04d562..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-/******************************************************************
- *
- * 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.
- *
- ******************************************************************/
-/**
- * @file
- *  This file contains Builder class which provides the easy creation of Resource.
- */
-
-package org.iotivity.ResourceEncapsulation.server;
-
-import org.iotivity.ResourceEncapsulation.common.RCSException;
-import org.iotivity.ResourceEncapsulation.common.RCSResourceAttributes;
-
-/**
- * This class provides APIs for resource creation, setting properties and
- * attributes for the constructed resource. It provides the build() API which
- * builds a resource and returns RCSResourceObject.
- *
- * {@link RCSResourceObject}
- */
-public class Builder {
-    static {
-        System.loadLibrary("gnustl_shared");
-        System.loadLibrary("oc_logger");
-        System.loadLibrary("connectivity_abstraction");
-        System.loadLibrary("ca-interface");
-        System.loadLibrary("octbstack");
-        System.loadLibrary("oc");
-        System.loadLibrary("ocstack-jni");
-        System.loadLibrary("rcs_common");
-        System.loadLibrary("rcs_client");
-        System.loadLibrary("rcs_server");
-        System.loadLibrary("rcs_container");
-        System.loadLibrary("re-jni");
-    }
-
-    private String                m_resourceUri;
-    private String                m_resourceType;
-    private String                m_resourceInterface;
-    private boolean               m_observableFlag;
-    private boolean               m_discovervableFlag;
-    private RCSResourceAttributes m_attributes;
-
-    /**
-     * Native method for creation of Resource
-     */
-    private native RCSResourceObject nativeBuild(String resourceURI,
-            String resourceType, String resourceInterface,
-            boolean observableFlag, boolean discovervableFlag,
-            RCSResourceAttributes attributes);
-
-    /**
-     * Constructor
-     *
-     * @param resourceURI
-     *            Resource URI value to be set
-     * @param resourceType
-     *            Resource type value to be set
-     * @param resourceInterface
-     *            Interface value to be set
-     */
-    public Builder(String resourceURI, String resourceType,
-            String resourceInterface) {
-        m_resourceUri = resourceURI;
-        m_resourceType = resourceType;
-        m_resourceInterface = resourceInterface;
-    }
-
-    /**
-     * Sets the discoverable(OC_DISCOVERABLE) property for the resource.
-     *
-     * @param isDiscoverable
-     *            Whether to be discovered or not
-     */
-    public void setDiscoverable(boolean isDiscoverable) {
-        m_discovervableFlag = isDiscoverable;
-    }
-
-    /**
-     * Sets the observable(OC_OBSERVABLE) property of the resource.
-     *
-     * @param isObservable
-     *            Whether to be observed or not
-     */
-    public void setObservable(boolean isObservable) {
-        m_observableFlag = isObservable;
-    }
-
-    /**
-     * API for setting attributes of the resource.
-     *
-     * @param attributes
-     *            Resource Attributes to set
-     *
-     *            {@link RCSResourceAttributes}
-     */
-    public void setAttributes(RCSResourceAttributes attributes) {
-        m_attributes = attributes;
-    }
-
-    /**
-     * API for constructing a new RCSResourceObject.
-     *
-     * @return RCSResourceObject object (It is the resource that is created)
-     *
-     * @throws RCSException
-     *             It catches exception from registerResource API of OCPlatform
-     *             and throws it to developer.
-     *
-     *             <p>
-     *             Steps for creation of Resource : - Get the object of this
-     *             class by calling Constructor with resourceURI, resourceType,
-     *             resourceInterface - Using the object set the Discoverable and
-     *             Observable as needed. [optional] - Set the attributes for the
-     *             resource. [optional] - At last call the build() method to
-     *             create the resource.
-     */
-    public RCSResourceObject build() throws RCSException {
-        return this.nativeBuild(m_resourceUri, m_resourceType,
-                m_resourceInterface, m_observableFlag, m_discovervableFlag,
-                m_attributes);
-    }
-}
diff --git a/service/resource-encapsulation/sdk/java/src/org/iotivity/ResourceEncapsulation/server/RCSGetResponse.java b/service/resource-encapsulation/sdk/java/src/org/iotivity/ResourceEncapsulation/server/RCSGetResponse.java
deleted file mode 100644 (file)
index c1a3cb6..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-/******************************************************************
- *
- * 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.
- *
- ******************************************************************/
-/**
- * @file
- * This file contains the class for creating a Get response
- * for the received Get request.
- *
- */
-
-package org.iotivity.ResourceEncapsulation.server;
-
-import org.iotivity.ResourceEncapsulation.common.RCSResourceAttributes;
-import org.iotivity.ResourceEncapsulation.utils.EntityHandlerResult;
-
-/**
- * This class provides methods to create the response for a received get
- * request.
- *
- * {@link RCSResourceObject}
- */
-public class RCSGetResponse {
-
-    private int                   m_typeOfGetResponse;
-    private int                   m_handlerResult;
-    private int                   m_errorCode;
-    private RCSResourceAttributes m_attributes;
-
-    private final static int      DEFAULT_RESPONSE                 = 0;
-    private final static int      CREATE_WITH_RESULT               = 1;
-    private final static int      CREATE_WITH_ATTRIBUTE            = 2;
-    private final static int      CREATE_WITH_ATTRIBUTE_AND_RESULT = 3;
-
-    /**
-     * Creates a default RCSGetResponse. The response will have OC_EH_OK for the
-     * result and 200 for the errorCode. The attributes of RCSResourceObject
-     * will be set as the result attributes.
-     *
-     * @return RCSGetResponse
-     */
-    public static RCSGetResponse defaultAction() {
-        return new RCSGetResponse();
-    }
-
-    /**
-     * Creates a RCSGetResponse with a result and error code passed. The
-     * attributes of the RCSResourceObject will be set as the result attributes.
-     *
-     * @param result
-     *            The response result.
-     * @param errorCode
-     *            The error code to set in response.
-     *
-     * @return RCSGetResponse
-     *
-     *         {@link EntityHandlerResult}
-     */
-    public static RCSGetResponse create(EntityHandlerResult result,
-            int errorCode) {
-        return new RCSGetResponse(result.ordinal(), errorCode);
-
-    }
-
-    /**
-     * Creates a RCSGetResponse with custom attributes. This sends the passed
-     * attributes as the result attributes instead of the one the
-     * RCSResourceObject holds.
-     *
-     * @param attributes
-     *            The attributes to send in response.
-     *
-     * @return RCSGetResponse
-     *
-     *         {@link RCSResourceAttributes}
-     */
-    public static RCSGetResponse create(RCSResourceAttributes attributes) {
-        return new RCSGetResponse(attributes);
-    }
-
-    /**
-     * Creates a RCSGetResponse with a result and error code passed. This sends
-     * the passed attributes as the result attributes instead of one the
-     * RCSResourceObject holds.
-     *
-     * @param attributes
-     *            The attributes to send in response.
-     * @param result
-     *            The response result.
-     * @param errorCode
-     *            The error code for response.
-     *
-     *            {@link RCSResourceAttributes}
-     *
-     * @return RCSGetResponse
-     */
-    public static RCSGetResponse create(RCSResourceAttributes attributes,
-            EntityHandlerResult result, int errorCode) {
-        return new RCSGetResponse(attributes, result.ordinal(), errorCode);
-    }
-
-    // ******* JNI UTILTY FUNCTIONS ******* //
-
-    private RCSGetResponse() {
-        m_typeOfGetResponse = DEFAULT_RESPONSE;
-    }
-
-    private RCSGetResponse(int handlerResult, int errorCode) {
-        m_typeOfGetResponse = CREATE_WITH_RESULT;
-        this.m_handlerResult = handlerResult;
-        this.m_errorCode = errorCode;
-    }
-
-    private RCSGetResponse(RCSResourceAttributes attributes) {
-        m_typeOfGetResponse = CREATE_WITH_ATTRIBUTE;
-        this.m_attributes = attributes;
-    }
-
-    private RCSGetResponse(RCSResourceAttributes attributes, int handlerResult,
-            int errorCode) {
-        m_typeOfGetResponse = CREATE_WITH_ATTRIBUTE_AND_RESULT;
-        this.m_attributes = attributes;
-        this.m_handlerResult = handlerResult;
-        this.m_errorCode = errorCode;
-    }
-
-    private int getTypeOfGetResponse() {
-        return m_typeOfGetResponse;
-    }
-
-    private int getResult() {
-        return m_handlerResult;
-    }
-
-    private int getErrorCode() {
-        return m_errorCode;
-    }
-
-    private RCSResourceAttributes getAttributes() {
-        return m_attributes;
-    }
-}
diff --git a/service/resource-encapsulation/sdk/java/src/org/iotivity/ResourceEncapsulation/server/RCSResourceObject.java b/service/resource-encapsulation/sdk/java/src/org/iotivity/ResourceEncapsulation/server/RCSResourceObject.java
deleted file mode 100644 (file)
index ff086e7..0000000
+++ /dev/null
@@ -1,541 +0,0 @@
-/* *****************************************************************
- *
- * 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.
- *
- ******************************************************************/
-/**
- * @file
- * This file contains the resource object APIs provided to the developers.
- * RCSResourceObject is a part of the server builder module.
- */
-
-package org.iotivity.ResourceEncapsulation.server;
-
-import org.iotivity.ResourceEncapsulation.common.RCSResourceAttributes;
-
-import android.util.Log;
-
-/**
- * RCSResourceObject represents a resource. It handles any requests from clients
- * automatically with attributes.
- * <p>
- * It also provides an auto notification mechanism that notifies to the
- * observers. Requests are handled automatically by defaultAction of
- * RCSGetResponse and RCSSetResponse. Developer can override them and send your
- * own response.
- * <p>
- * For simple resources, developer may want to know whenever attributes are
- * changed by a set request. In this case, add an AttributeUpdatedListener with
- * a key interested in instead of overriding SetRequestHandler.
- *
- * <p>
- * Developer will get the object of this when they call the build() API of
- * Builder class
- *
- * {@link Builder}
- */
-public class RCSResourceObject {
-
-    private long                      m_nativeHandle;
-    private IGetRequestHandler        m_getRequestListener;
-    private ISetRequestHandler        m_setRequestListener;
-    private IAttributeUpdatedListener m_attributeUpdatedListener;
-    private final String              LOG_TAG = this.getClass().getSimpleName();
-
-    // native methods
-    private native void nativeSetAttributeInteger(String key, int value);
-
-    private native void nativeSetAttributeDouble(String key, double value);
-
-    private native void nativeSetAttributeBool(String key, boolean value);
-
-    private native void nativeSetAttributeString(String key, String value);
-
-    private native String nativeGetAttributeValue(String key);
-
-    private native boolean nativeRemoveAttribute(String key);
-
-    private native boolean nativeContainsAttribute(String key);
-
-    private native RCSResourceAttributes nativeGetAttributes();
-
-    private native boolean nativeIsObservable();
-
-    private native boolean nativeIsDiscoverable();
-
-    private native void nativeNotify();
-
-    private native void nativeSetAutoNotifyPolicy(int policy);
-
-    private native int nativeGetAutoNotifyPolicy();
-
-    private native void nativeSetSetRequestHandlerPolicy(int policy);
-
-    private native int nativeGetSetRequestHandlerPolicy();
-
-    private native void nativeSetGetRequestHandler(IGetRequestHandler handler);
-
-    private native void nativeSetSetRequestHandler(ISetRequestHandler handler);
-
-    private native void nativeAddAttributeUpdatedListener(String key,
-            IAttributeUpdatedListener listener);
-
-    private native boolean nativeRemoveAttributeUpdatedListener(String key);
-
-    private RCSResourceObject(long nativeHandle) {
-        m_nativeHandle = nativeHandle;
-    }
-
-    /**
-     * Represents the policy of AutoNotify function of RCSResourceObject class
-     * In accord with this policy, observers are notified of attributes that are
-     * changed or updated.
-     *
-     * <p>
-     * Attributes are changed or updated according to execution of some
-     * functions or receipt of 'set-request'.
-     *
-     * {@link RCSResourceObject}
-     */
-    public enum AutoNotifyPolicy {
-        NEVER, /* < Never notify. */
-        ALWAYS, /* < Always notify. */
-        UPDATED;
-        /* < When attributes are changed, notify. */
-
-        /*
-         * Utility API for integer to enum conversion.
-         */
-        public static AutoNotifyPolicy getAutoNotifyPolicy(int ordinal) {
-            if (ordinal == 0)
-                return AutoNotifyPolicy.values()[0];
-            else if (ordinal == 1)
-                return AutoNotifyPolicy.values()[1];
-            else if (ordinal == 2)
-                return AutoNotifyPolicy.values()[2];
-            return null;
-        }
-    }
-
-    public enum SetRequestHandlerPolicy {
-
-        NEVER, /*
-                * < Server ignore when server is received set-request of
-                * attributes of the new key.
-                */
-        ACCEPTANCE;
-        /*
-         * < Server creates attributes of the new key When server is received
-         * set-request of attributes of the new key.
-         */
-
-        /*
-         * Utility API for integer to enum conversion.
-         */
-        public static SetRequestHandlerPolicy getSetRequestHandlerPolicy(
-                int ordinal) {
-
-            if (ordinal == 0)
-                return SetRequestHandlerPolicy.values()[0];
-            else if (ordinal == 1)
-                return SetRequestHandlerPolicy.values()[1];
-            return null;
-        }
-    }
-
-    /**
-     * Provides interface for receiving the callback on receiving a Get request
-     * from the client
-     */
-    public interface IGetRequestHandler {
-
-        /**
-         * This callback method is called when received a get request from the
-         * client. Listener should be set to receive this callback.
-         *
-         * @param request
-         *            Request for the resource
-         * @param attributes
-         *            Resource Attributes
-         *
-         * @return RCSGetResponse Response to be sent.
-         *
-         *         {@link RCSResourceObject} {@link RCSGetResponse}
-         *         {@link RCSResourceAttributes}
-         */
-        RCSGetResponse onGetRequest(RCSRequest request,
-                RCSResourceAttributes attributes);
-
-    }
-
-    /**
-     * Provides interface for receiving the callback on receiving a Set request
-     * from the client
-     */
-    public interface ISetRequestHandler {
-
-        /**
-         * This callback method is called when received a set request from the
-         * client. Listener should be set to receive this callback.
-         *
-         * @param request
-         *            Request for the resource
-         * @param attributes
-         *            Resource Attributes to set
-         *
-         * @return RCSSetResponse Response to be sent.
-         *
-         *         {@link RCSResourceObject} {{@link RCSSetResponse}
-         *         {@link RCSResourceAttributes}
-         */
-        RCSSetResponse onSetRequest(RCSRequest request,
-                RCSResourceAttributes attributes);
-
-    }
-
-    /**
-     * Provides interface for receiving the callback on update of requested
-     * attribute.
-     */
-    public interface IAttributeUpdatedListener {
-
-        /**
-         * This callback method is called when a requested attribute value is
-         * updated. Listener should be set to receive this callback.
-         *
-         * @param oldValue
-         *            It is the attribute value before updation.
-         * @param newValue
-         *            It is the current resource attribute value.
-         *
-         *            {@link RCSResourceAttributes}
-         */
-        void onAttributeUpdate(String oldValue, String newValue);
-    }
-
-    /**
-     * Set listener for receiving get request from the client asynchronously.
-     *
-     * @param listener
-     *            IGetRequestHandler to receive asynchronous get request from
-     *            client.
-     *
-     *            {@link IGetRequestHandler}
-     */
-    public void setGetRequestListener(IGetRequestHandler listener) {
-        m_getRequestListener = listener;
-    }
-
-    /**
-     * Set listener for receiving set request from the client asynchronously.
-     *
-     * @param listener
-     *            ISetRequestHandler to receive asynchronous set request from
-     *            client.
-     *
-     *            {@link ISetRequestHandler}
-     */
-    public void setSetRequestListener(ISetRequestHandler listener) {
-        m_setRequestListener = listener;
-    }
-
-    /**
-     * Set listener for receiving the updated attribute value asynchronously.
-     *
-     * @param listener
-     *            IAttributeUpdatedListener to receive updated attribute value
-     *            asynchronously.
-     *
-     *            {@link IAttributeUpdatedListener}
-     */
-    public void setAttributeUpdatedListener(IAttributeUpdatedListener listener) {
-        m_attributeUpdatedListener = listener;
-    }
-
-    /**
-     * API for setting a particular attribute value as a integer
-     *
-     * @param key
-     *            name of attribute(used to map the attribute value).
-     * @param value
-     *            integer value to be mapped against the key.
-     *
-     *            The thread-safety for attributes is taken care internally.
-     */
-    public void setAttribute(String key, int value) {
-        Log.i(LOG_TAG, "setAttribute (integer) called");
-        this.nativeSetAttributeInteger(key, value);
-    }
-
-    /**
-     * API for setting a particular attribute value as a double
-     *
-     * @param key
-     *            name of attribute(used to map the attribute value).
-     * @param value
-     *            Double value to be mapped against the key.
-     *
-     *            The thread-safety for attributes is taken care internally.
-     */
-    public void setAttribute(String key, double value) {
-        Log.i(LOG_TAG, "setAttribute (float) called");
-        this.nativeSetAttributeDouble(key, value);
-    }
-
-    /**
-     * API for setting a particular attribute value as a boolean
-     *
-     * @param key
-     *            name of attribute(used to map the attribute value).
-     * @param value
-     *            boolean value to be mapped against the key.
-     *
-     *            The thread-safety for attributes is taken care internally.
-     */
-    public void setAttribute(String key, boolean value) {
-        Log.i(LOG_TAG, "setAttribute (double) called ");
-        this.nativeSetAttributeBool(key, value);
-    }
-
-    /**
-     * API for setting a particular attribute value as a String
-     *
-     * @param key
-     *            name of attribute(used to map the attribute value).
-     * @param value
-     *            String value to be mapped against the key.
-     *
-     *            The thread-safety for attributes is taken care internally.
-     */
-    public void setAttribute(String key, String value) {
-        Log.i(LOG_TAG, "setAttribute (String) called ");
-        this.nativeSetAttributeString(key, value);
-    }
-
-    /**
-     * API for retrieving the attribute value associated with the supplied key.
-     *
-     * @param key
-     *            Name of the attribute
-     *
-     * @return resource attributes value as a string
-     *
-     *         The thread-safety for attributes is taken care internally.
-     */
-    public String getAttributeValue(String key) {
-        Log.i(LOG_TAG, "getAttributeValue called");
-        return this.nativeGetAttributeValue(key);
-    }
-
-    /**
-     * API for removing a particular attribute of the resource.
-     *
-     * @param key
-     *            Name of the attribute.
-     *
-     * @return If the key exist and matched attribute is deleted, return true.
-     *
-     *         The thread-safety for attributes is taken care internally.
-     */
-    public boolean removeAttribute(String key) {
-        Log.i(LOG_TAG, "removeAttribute called");
-        return this.nativeRemoveAttribute(key);
-    }
-
-    /**
-     * API for checking whether a particular attribute is there for a resource
-     * or not.
-     *
-     * @param key
-     *            Name of the attribute.
-     *
-     * @return If the key exist, return true.
-     *
-     *         The thread-safety for attributes is taken care internally.
-     */
-    public boolean containsAttribute(String key) {
-        Log.i(LOG_TAG, "containsAttribute called");
-        return this.nativeContainsAttribute(key);
-    }
-
-    /**
-     * API for getting all the attributes of the RCSResourceObject.
-     *
-     * @return RCSResourceAttributes
-     *
-     *         {@link RCSResourceAttributes}
-     */
-    public RCSResourceAttributes getAttributes() {
-        Log.i(LOG_TAG, "getAttributes called");
-        return this.nativeGetAttributes();
-    }
-
-    /**
-     * API for checking whether the particular resource is observable or not
-     *
-     * @return true if observable otherwise false
-     */
-    public boolean isObservable() {
-        Log.i(LOG_TAG, "isObservable called");
-        return this.nativeIsObservable();
-    }
-
-    /**
-     * API for checking whether the particular resource is discoverable or not
-     *
-     * @return true if discoverable else false
-     */
-    public boolean isDiscoverable() {
-        Log.i(LOG_TAG, "isDiscoverable called");
-        return this.nativeIsDiscoverable();
-    }
-
-    /**
-     * API for setting the resource's get request handler by the
-     * developer/application. If developer set this handler then all get request
-     * will come to the application and developer can send the response to the
-     * client using APIs of RCSGetResponse class.
-     *
-     * <p>
-     * IGetRequestHandler should be set to call this API. For setting the
-     * listener call setGetRequestListener() API
-     *
-     * {@link RCSGetResponse} {@link #setGetRequestListener(IGetRequestHandler)}
-     */
-    public void setGetRequestHandler() {
-        if (null == m_getRequestListener) {
-            Log.i(LOG_TAG, "getRequestListener is not set");
-            return;
-        } else {
-            this.nativeSetGetRequestHandler(m_getRequestListener);
-        }
-    }
-
-    /**
-     * API for setting the resource's set request handler by the
-     * developer/application. If developer set this handler then all set request
-     * will come to the application and developer can send the response to the
-     * client using APIs of RCSSetResponse class.
-     *
-     * <p>
-     * ISetRequestHandler should be set to call this API. For setting the
-     * listener call setSetRequestListener() API
-     *
-     * {@link RCSSetResponse} {@link #setSetRequestListener(ISetRequestHandler)}
-     */
-    public void setSetRequestHandler() {
-        if (null == m_setRequestListener) {
-            Log.i(LOG_TAG, "setRequestListener is not set");
-            return;
-        } else {
-            this.nativeSetSetRequestHandler(m_setRequestListener);
-        }
-    }
-
-    /**
-     * API for setting the Listener for a particular attribute update.
-     *
-     * @param key
-     *            The interested attribute's key
-     *
-     *            <p>
-     *            IAttributeUpdatedListener should be set to call this API. For
-     *            setting the listener call setAttributeUpdatedListener() API
-     */
-    public void addAttributeUpdatedListener(String key) {
-        if (null == m_attributeUpdatedListener) {
-            Log.i(LOG_TAG, "addAttributeUpdatedListener is not set");
-            return;
-        } else {
-            this.nativeAddAttributeUpdatedListener(key,
-                    m_attributeUpdatedListener);
-        }
-    }
-
-    /**
-     * API for removing the handler for a particular attribute update.
-     *
-     * @param key
-     *            The interested attribute's key
-     *
-     * @return true if requested attribute is removed successfully else false
-     */
-    public boolean removeAttributeUpdatedListener(String key) {
-        return this.nativeRemoveAttributeUpdatedListener(key);
-    }
-
-    /**
-     * API for notifying all observers of the RCSResourceObject with the updated
-     * attributes value
-     */
-    public void notifyObservers() {
-        Log.i(LOG_TAG, "notifyObservers called");
-        this.nativeNotify();
-    }
-
-    /**
-     * API for setting Auto notify policy
-     *
-     * @param policy
-     *            policy to be set
-     *
-     *            {@link AutoNotifyPolicy}
-     */
-    public void setAutoNotifyPolicy(AutoNotifyPolicy policy) {
-        Log.i(LOG_TAG, "setAutoNotifyPolicy called");
-        this.nativeSetAutoNotifyPolicy(policy.ordinal());
-    }
-
-    /**
-     * API for getting auto notify policy
-     *
-     * @return AutoNotifyPolicy
-     *
-     *         {@link AutoNotifyPolicy}
-     */
-    public AutoNotifyPolicy getAutoNotifyPolicy() {
-        Log.i(LOG_TAG, "getAutoNotifyPolicy called");
-        return AutoNotifyPolicy.getAutoNotifyPolicy(this
-                .nativeGetAutoNotifyPolicy());
-    }
-
-    /**
-     * API for setting the policy for a setRequestHandler.
-     *
-     * @param policy
-     *            policy to be set
-     *
-     *            {@link SetRequestHandlerPolicy}
-     */
-    public void setSetRequestHandlerPolicy(SetRequestHandlerPolicy policy) {
-        Log.i(LOG_TAG, "setSetRequestHandlerPolicy called");
-        this.nativeSetSetRequestHandlerPolicy(policy.ordinal());
-    }
-
-    /**
-     * API for getting the SetRequestHandler Policy.
-     *
-     * @return SetRequestHandlerPolicy
-     *
-     *         {@link SetRequestHandlerPolicy}
-     */
-    public SetRequestHandlerPolicy getSetRequestHandlerPolicy() {
-        Log.i(LOG_TAG, "getSetRequestHandlerPolicy called");
-        return SetRequestHandlerPolicy.getSetRequestHandlerPolicy(this
-                .nativeGetSetRequestHandlerPolicy());
-    }
-}
diff --git a/service/resource-encapsulation/sdk/java/src/org/iotivity/ResourceEncapsulation/server/RCSSetResponse.java b/service/resource-encapsulation/sdk/java/src/org/iotivity/ResourceEncapsulation/server/RCSSetResponse.java
deleted file mode 100644 (file)
index 48fde74..0000000
+++ /dev/null
@@ -1,242 +0,0 @@
-/******************************************************************
- *
- * 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.
- *
- ******************************************************************/
-/**
- * @file
- * This file contains the class for creating a Set response
- * for the received Set request.
- */
-
-package org.iotivity.ResourceEncapsulation.server;
-
-import org.iotivity.ResourceEncapsulation.common.RCSResourceAttributes;
-import org.iotivity.ResourceEncapsulation.utils.EntityHandlerResult;
-import org.iotivity.ResourceEncapsulation.server.RCSResourceObject;
-
-/**
- * This class provides methods to create the response for a received set
- * request.
- *
- * {@link RCSResourceObject}
- */
-public class RCSSetResponse {
-
-    private int                   m_typeOfSetResponse;
-    private int                   m_handlerResult;
-    private int                   m_errorCode;
-    private RCSResourceAttributes m_attributes;
-
-    private final static int      DEFAULT_RESPONSE                 = 0;
-    private final static int      CREATE_WITH_RESULT               = 1;
-    private final static int      CREATE_WITH_ATTRIBUTE            = 2;
-    private final static int      CREATE_WITH_ATTRIBUTE_AND_RESULT = 3;
-    private final static int      ACCEPT                           = 4;
-    private final static int      ACCEPT_WITH_RESULT               = 5;
-    private final static int      IGNORE                           = 6;
-    private final static int      IGNORE_WIH_RESULT                = 7;
-
-    /**
-     * Creates a default RCSSetResponse with DEFAULT acceptance method. The
-     * response will have OC_EH_OK for the result and 200 for the errorCode. The
-     * attributes of RCSResourceObject will be set as the result attributes.
-     *
-     * <p>
-     * DEFAULT : Follow SetRequestHandlerPolicy of the RCSResourceObject.
-     */
-    public static RCSSetResponse defaultAction() {
-        return new RCSSetResponse(DEFAULT_RESPONSE);
-    }
-
-    /**
-     * Creates a default RCSSetResponse with ACCEPT acceptance method. The
-     * response will have OC_EH_OK for the result and 200 for the errorCode. The
-     * attributes of RCSResourceObject will be set as the result attributes.
-     *
-     * <p>
-     * ACCEPT : Accept the request attributes even if there is an unknown key or
-     * mismatched type.
-     *
-     * @return RCSSetResponse
-     */
-    public static RCSSetResponse accept() {
-        return new RCSSetResponse(ACCEPT);
-    }
-
-    /**
-     * Creates a RCSSetResponse with ACCEPT acceptance method. with a result and
-     * error code passed. The attributes of the RCSResourceObject will be set as
-     * the result attributes.
-     *
-     * @param result
-     *            The response result.
-     * @param errorCode
-     *            The error code to set in response.
-     *
-     *            <p>
-     *            ACCEPT : Accept the request attributes even if there is an
-     *            unknown key or mismatched type.
-     *
-     * @return RCSSetResponse
-     */
-    public static RCSSetResponse accept(EntityHandlerResult result,
-            int errorCode) {
-        return new RCSSetResponse(result.ordinal(), errorCode,
-                ACCEPT_WITH_RESULT);
-    }
-
-    /**
-     * Creates a default RCSSetResponse with IGNORE acceptance method. The
-     * response will have OC_EH_OK for the result and 200 for the errorCode. The
-     * attributes of RCSResourceObject will be set as the result attributes.
-     *
-     * <p>
-     * IGNORE : Ignore the request attributes.
-     *
-     * @return RCSSetResponse
-     */
-    public static RCSSetResponse ignore() {
-        return new RCSSetResponse(IGNORE);
-    }
-
-    /**
-     * Creates a RCSSetResponse with IGNORE acceptance method. with a result and
-     * error code passed. The attributes of the RCSResourceObject will be set as
-     * the result attributes.
-     *
-     * @param result
-     *            The response result.
-     * @param errorCode
-     *            The error code to set in response.
-     *
-     *            <p>
-     *            IGNORE : Ignore the request attributes.
-     *
-     * @return RCSSetResponse
-     */
-    public static RCSSetResponse ignore(EntityHandlerResult result,
-            int errorCode) {
-        return new RCSSetResponse(result.ordinal(), errorCode,
-                IGNORE_WIH_RESULT);
-    }
-
-    /**
-     * Creates a RCSSetResponse with a result and error code passed and has
-     * DEFAULT acceptance method. The attributes of the RCSResourceObject will
-     * be set as the result attributes.
-     *
-     * <p>
-     * DEFAULT : Follow SetRequestHandlerPolicy of the RCSResourceObject.
-     *
-     * @param result
-     *            The response result.
-     * @param errorCode
-     *            The error code to set in response.
-     *
-     *            {@link EntityHandlerResult}
-     *
-     * @return RCSSetResponse
-     */
-    public static RCSSetResponse create(EntityHandlerResult result,
-            int errorCode) {
-        return new RCSSetResponse(result.ordinal(), errorCode,
-                CREATE_WITH_RESULT);
-    }
-
-    /**
-     * Creates a RCSSetResponse with custom attributes and has DEFAULT
-     * acceptance method. This sends the passed attributes as the result
-     * attributes instead of one the RCSResourceObject holds.
-     *
-     * <p>
-     * DEFAULT : Follow SetRequestHandlerPolicy of the RCSResourceObject.
-     *
-     * @param attributes
-     *            The attributes to send in response.
-     *
-     *            {@link RCSResourceAttributes}
-     *
-     * @return RCSSetResponse
-     */
-    public static RCSSetResponse create(RCSResourceAttributes attributes) {
-        return new RCSSetResponse(attributes);
-    }
-
-    /**
-     * Creates a RCSSetResponse with a result and error code passed. This sends
-     * the passed attributes as the result attributes instead of one the
-     * RCSResourceObject holds.
-     *
-     * @param attributes
-     *            The attributes to send in response.
-     * @param result
-     *            The response result.
-     * @param errorCode
-     *            The error code for response.
-     *
-     *            <p>
-     *            RCSResourceAttributes
-     *
-     * @return RCSSetResponse
-     */
-    public static RCSSetResponse create(RCSResourceAttributes attributes,
-            EntityHandlerResult result, int errorCode) {
-        return new RCSSetResponse(attributes, result.ordinal(), errorCode);
-    }
-
-    // ******* JNI UTILTY FUNCTIONS ******* //
-
-    private RCSSetResponse(int typeOfSetResponse) {
-        this.m_typeOfSetResponse = typeOfSetResponse;
-    }
-
-    private RCSSetResponse(int handlerResult, int errorCode, int typeOfRequest) {
-        m_typeOfSetResponse = typeOfRequest;
-        m_handlerResult = handlerResult;
-        m_errorCode = errorCode;
-    }
-
-    private RCSSetResponse(RCSResourceAttributes attributes) {
-        m_typeOfSetResponse = CREATE_WITH_ATTRIBUTE;
-        this.m_attributes = attributes;
-    }
-
-    private RCSSetResponse(RCSResourceAttributes attributes, int handlerResult,
-            int errorCode) {
-        m_typeOfSetResponse = CREATE_WITH_ATTRIBUTE_AND_RESULT;
-        m_attributes = attributes;
-        m_handlerResult = handlerResult;
-        m_errorCode = errorCode;
-    }
-
-    private int getTypeOfGetResponse() {
-        return m_typeOfSetResponse;
-    }
-
-    private int getResult() {
-        return m_handlerResult;
-    }
-
-    private int getErrorCode() {
-        return m_errorCode;
-    }
-
-    private RCSResourceAttributes getAttributes() {
-        return m_attributes;
-    }
-}
diff --git a/service/resource-encapsulation/sdk/java/src/org/iotivity/ResourceEncapsulation/utils/DiscoveryType.java b/service/resource-encapsulation/sdk/java/src/org/iotivity/ResourceEncapsulation/utils/DiscoveryType.java
deleted file mode 100644 (file)
index 96463be..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/******************************************************************
- *
- * 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.
- *
- ******************************************************************/
-/**
- * @file
- * This file provides a Enum to handle unicast or multicast discovery.
- * @link RCSAddress
- */
-
-package org.iotivity.ResourceEncapsulation.utils;
-
-import org.iotivity.ResourceEncapsulation.client.RCSAddress;
-
-/**
- * This Enum discovery codes for different discovery types.
- *
- * <p>
- * Application will get this DiscoveryType as a result of getTypeOfDiscovery API
- * of RCSAddress class
- *
- * {@link RCSAddress}
- */
-public enum DiscoveryType {
-
-    UNICAST, /* < Unicast type discovery. */
-    MULTICAST;
-    /* < Multicast type discovery. */
-
-    /*
-     * Utility API for integer to enum conversion.
-     */
-    public static DiscoveryType getDiscoveryType(int ordinal) {
-
-        if (ordinal == 0)
-            return DiscoveryType.values()[0];
-        if (ordinal == 1)
-            return DiscoveryType.values()[1];
-
-        return null;
-    }
-}
index f8d4067..0d5af4d 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "ScopeLogger.h"
 
-#define TAG "RCSRemoteResourceObject"
+#define TAG PCF("RCSRemoteResourceObject")
 
 namespace
 {
@@ -99,20 +99,20 @@ namespace
         return OC_STACK_OK;
     }
 
-    void setCallback(const HeaderOptions&, const ResponseStatement& response, int,
+    void setCallback(const HeaderOptions&, const ResponseStatement& response, int eCode,
             RCSRemoteResourceObject::RemoteAttributesSetCallback onRemoteAttributesSet)
     {
         SCOPE_LOG_F(DEBUG, TAG);
 
-        onRemoteAttributesSet(response.getAttributes());
+        onRemoteAttributesSet(response.getAttributes(), eCode);
     }
 
-    void getCallback(const HeaderOptions&, const ResponseStatement& response, int,
+    void getCallback(const HeaderOptions&, const ResponseStatement& response, int eCode,
             RCSRemoteResourceObject::RemoteAttributesGetCallback onRemoteAttributesReceived)
     {
         SCOPE_LOG_F(DEBUG, TAG);
 
-        onRemoteAttributesReceived(response.getAttributes());
+        onRemoteAttributesReceived(response.getAttributes(), eCode);
     }
 }
 
@@ -287,16 +287,7 @@ namespace OIC
         {
             SCOPE_LOG_F(DEBUG, TAG);
 
-            //check whether key is available or not
-            RCSResourceAttributes cachedAttributes= getCachedAttributes();
-            if(cachedAttributes.contains(key))
-            {
-                return getCachedAttributes().at(key);
-            }
-            else
-            {
-                throw BadRequestException{ "Requested Attribute is not present" };
-            }
+            return getCachedAttributes().at(key);
         }
 
         std::string RCSRemoteResourceObject::getUri() const
index b50d2f2..a4ec4a3 100644 (file)
@@ -101,7 +101,7 @@ except KeyError:
        print ''
 
 
-resource_container_env.PrependUnique(LIBS = ['rcs_client', 'rcs_server', 'rcs_common', 'oc','octbstack', 'oc_logger', 'oc_logger_core', 'connectivity_abstraction'])
+resource_container_env.PrependUnique(LIBS = ['rcs_client', 'rcs_server', 'rcs_common', 'oc','octbstack', 'oc_logger', 'connectivity_abstraction'])
 resource_container_env.AppendUnique(LIBS = ['dl', 'boost_system', 'boost_date_time', 'boost_thread'])
 
 if int(containerJavaSupport):
index 0a03f4f..7ee45b6 100644 (file)
@@ -22,7 +22,7 @@
 #define SERVERBUILDER_REQUESTHANDLER_H
 
 #include <RCSResponse.h>
-#include <ResourceAttributesUtils.h>
+#include <RCSResourceAttributes.h>
 
 namespace OC
 {
@@ -75,6 +75,10 @@ namespace OIC
 
         class SetRequestHandler: public RequestHandler
         {
+        private:
+            typedef std::pair< std::string, RCSResourceAttributes::Value > AttrKeyValuePair;
+            typedef std::vector< AttrKeyValuePair > AttrKeyValuePairs;
+
         public:
             typedef std::shared_ptr< SetRequestHandler > Ptr;
 
index 5f5eb46..e0f2abb 100644 (file)
@@ -28,6 +28,7 @@
 #include <AssertUtils.h>
 #include <AtomicHelper.h>
 #include <ResourceAttributesConverter.h>
+#include <ResourceAttributesUtils.h>
 
 #include <logger.h>
 #include <OCPlatform.h>
@@ -419,6 +420,7 @@ namespace OIC
         OCEntityHandlerResult RCSResourceObject::entityHandler(
                 std::shared_ptr< OC::OCResourceRequest > request)
         {
+            OC_LOG(WARNING, LOG_TAG, "entityHandler");
             if (!request)
             {
                 return OC_EH_ERROR;
@@ -492,6 +494,7 @@ namespace OIC
             AttrKeyValuePairs replaced = requestHandler->applyAcceptanceMethod(
                     response.getAcceptanceMethod(), *this, attrs);
 
+            OC_LOG_V(WARNING, LOG_TAG, "replaced num %d", replaced.size());
             for (const auto& attrKeyValPair : replaced)
             {
                 std::lock_guard<std::mutex> lock(m_mutexKeyAttributeUpdate);
@@ -503,8 +506,14 @@ namespace OIC
                 }
             }
 
-            autoNotify(!replaced.empty(), m_autoNotifyPolicy);
-            return sendResponse(*this, request, response);
+            try
+            {
+                autoNotify(!replaced.empty(), m_autoNotifyPolicy);
+                return sendResponse(*this, request, response);
+            } catch (const PlatformException& e) {
+                OC_LOG(ERROR, LOG_TAG, e.what());
+                return OC_EH_ERROR;
+            }
         }
 
         OCEntityHandlerResult RCSResourceObject::handleObserve(
index b80985b..58e8594 100644 (file)
@@ -23,6 +23,7 @@
 #include <OCResourceResponse.h>
 #include <ResourceAttributesConverter.h>
 #include <RCSResourceObject.h>
+#include <ResourceAttributesUtils.h>
 
 namespace
 {
index cf0a443..732e0fe 100644 (file)
@@ -39,8 +39,8 @@ constexpr int ATTR_VALUE{ 0 };
 
 constexpr int DEFAULT_WAITING_TIME_IN_MILLIS = 3000;
 
-void getRemoteAttributesCallback(const RCSResourceAttributes&) {}
-void setRemoteAttributesCallback(const RCSResourceAttributes&) {}
+void getRemoteAttributesCallback(const RCSResourceAttributes&, int) {}
+void setRemoteAttributesCallback(const RCSResourceAttributes&, int) {}
 void resourceStateChanged(ResourceState) { }
 void cacheUpdatedCallback(const RCSResourceAttributes&) {}
 
@@ -150,12 +150,12 @@ TEST_F(RemoteResourceObjectTest, GetRemoteAttributesDoesNotAllowEmptyFunction)
 TEST_F(RemoteResourceObjectTest, GetRemoteAttributesGetsAttributesOfServer)
 {
     mocks.ExpectCallFunc(getRemoteAttributesCallback).Match(
-            [this](const RCSResourceAttributes& attrs)
+            [this](const RCSResourceAttributes& attrs, int)
             {
                 RCSResourceObject::LockGuard lock{ server };
                 return attrs == server->getAttributes();
             }
-    ).Do([this](const RCSResourceAttributes&){ Proceed(); });
+    ).Do([this](const RCSResourceAttributes&, int){ Proceed(); });
 
     object->getRemoteAttributes(getRemoteAttributesCallback);
 
@@ -174,7 +174,7 @@ TEST_F(RemoteResourceObjectTest, SetRemoteAttributesSetsAttributesOfServer)
     newAttrs[ATTR_KEY] = newValue;
 
     mocks.ExpectCallFunc(setRemoteAttributesCallback).
-            Do([this](const RCSResourceAttributes&){ Proceed(); });
+            Do([this](const RCSResourceAttributes&, int){ Proceed(); });
 
     object->setRemoteAttributes(newAttrs, setRemoteAttributesCallback);
     Wait();