Updating JNI modules of service provider
authorG S Senthil Kumar <senthil.gs@samsung.com>
Fri, 7 Aug 2015 15:04:30 +0000 (20:34 +0530)
committerMadan Lanka <lanka.madan@samsung.com>
Tue, 11 Aug 2015 10:54:39 +0000 (10:54 +0000)
It has the following changes:
    1. Implementation of resource model change callback.
    2. Handled multi-resource creation.
    3. Updated the jni method names to comply with their corresponding
       java package.
    4. Renamed simulator_resource_jni.h/.cpp to
       simulator_resource_server_jni.h/.cpp

Change-Id: I3b25116b2506bb095d1248711e442c20f7791a07
Signed-off-by: G S Senthil Kumar <senthil.gs@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2137
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
12 files changed:
service/simulator/java/jni/simulator_common_jni.h
service/simulator/java/jni/simulator_manager_jni.cpp
service/simulator/java/jni/simulator_manager_jni.h
service/simulator/java/jni/simulator_resource_attributes_jni.cpp
service/simulator/java/jni/simulator_resource_attributes_jni.h
service/simulator/java/jni/simulator_resource_jni.cpp [deleted file]
service/simulator/java/jni/simulator_resource_jni.h [deleted file]
service/simulator/java/jni/simulator_resource_jni_util.cpp
service/simulator/java/jni/simulator_resource_model_jni.cpp
service/simulator/java/jni/simulator_resource_model_jni.h
service/simulator/java/jni/simulator_resource_server_jni.cpp [new file with mode: 0644]
service/simulator/java/jni/simulator_resource_server_jni.h [new file with mode: 0644]

index 10e7c9d4d3a67c3575e2e76b7830029d48e1f5c6..472748cbe000fa9ff8a787f20dbdb62b89fd2079 100644 (file)
@@ -35,6 +35,10 @@ typedef struct
     jclass classSimulatorResourceAttribute;
     jclass classSimulatorRemoteResource;
     jclass classSimulatorCallback;
+    jclass classMap;
+    jclass classMapEntry;
+    jclass classSet;
+    jclass classIterator;
 
     jmethodID classIntegerCtor;
     jmethodID classDoubleCtor;
@@ -49,6 +53,13 @@ typedef struct
     jmethodID classSimulatorResourceSetName;
     jmethodID classSimulatorResourceModelCtor;
     jmethodID classSimulatorResourceAttributeCtor;
+    jmethodID classSimulatorResourceModelId;
+    jmethodID classMapEntrySet;
+    jmethodID classMapGetKey;
+    jmethodID classMapGetValue;
+    jmethodID classIteratorId;
+    jmethodID classHasNextId;
+    jmethodID classNextId;
 } SimulatorClassRefs;
 
 static jfieldID GetHandleField(JNIEnv *env, jobject jobj)
index a7553cba3eff3272000106f4cd033bf723887126..3cb5573850547ff494687b9a9973c712588276d4 100644 (file)
  ******************************************************************/
 
 #include "simulator_manager_jni.h"
-#include "simulator_resource_jni.h"
+#include "simulator_resource_server_jni.h"
 #include "simulator_common_jni.h"
 #include "simulator_manager.h"
 #include "simulator_remote_resource_jni.h"
+#include "simulator_resource_model_jni.h"
 
 SimulatorClassRefs gSimulatorClassRefs;
 std::mutex gEnvMutex;
@@ -185,49 +186,142 @@ class JNIFoundResourceListener
         jweak m_listener;
 
 };
+
+void onResourceModelChange(jweak jlistenerRef, const std::string &uri,
+                           const SimulatorResourceModel &resModel)
+{
+    JNIEnv *env = getEnv();
+    if (nullptr == env)
+        return;
+
+    jobject modelChangeListener = env->NewLocalRef(jlistenerRef);
+    if (!modelChangeListener)
+    {
+        releaseEnv();
+        return;
+    }
+
+    jclass modelChangeCls = env->GetObjectClass(modelChangeListener);
+    if (!modelChangeCls)
+    {
+        releaseEnv();
+        return;
+    }
+
+    jmethodID foundModelChangeMId = env->GetMethodID(modelChangeCls, "onResourceModelChanged",
+                                    "(Ljava/lang/String;Lorg/oic/simulator/serviceprovider/SimulatorResourceModel;)V");
+    if (!foundModelChangeMId)
+    {
+        releaseEnv();
+        return;
+    }
+
+    JniSimulatorResourceModel *jniModel = new JniSimulatorResourceModel(resModel);
+    if (!jniModel)
+    {
+        releaseEnv();
+        return;
+    }
+
+    jobject jModel = JniSimulatorResourceModel::toJava(env, reinterpret_cast<jlong>(jniModel));
+
+    jstring jUri = env->NewStringUTF(uri.c_str());
+
+    env->CallVoidMethod(modelChangeListener, foundModelChangeMId, jUri, jModel);
+    if ((env)->ExceptionCheck())
+    {
+        releaseEnv();
+        return;
+    }
+
+    env->DeleteLocalRef(jUri);
+
+    releaseEnv();
+}
+
+
 JNIEXPORT jobject JNICALL
-Java_org_iotivity_simulator_SimulatorManagerNativeInterface_createResource
-(JNIEnv *env, jclass object, jstring jConfigPath)
+Java_org_oic_simulator_SimulatorManagerNativeInterface_createResource
+(JNIEnv *env, jclass object, jstring configPath, jobject listener)
 {
-    if (!jConfigPath)
+    if (!configPath)
         return NULL;
 
-    const char *configPath = env->GetStringUTFChars(jConfigPath, NULL);
-    if (!configPath)
+    if (!listener)
         return NULL;
 
-    std::string config(configPath);
-    std::shared_ptr<SimulatorResource> resource = SimulatorManager::getInstance()->createResource(
-                config, nullptr);
-    if (NULL == resource.get())
+    jweak jlistenerRef = env->NewWeakGlobalRef(listener);
+    SimulatorResourceServer::ResourceModelChangedCB callback =  [jlistenerRef](const std::string & uri,
+            const SimulatorResourceModel & resModel)
+    {
+        onResourceModelChange(jlistenerRef, uri, resModel);
+    };
+
+    const char *configPathCStr = env->GetStringUTFChars(configPath, NULL);
+    SimulatorResourceServerPtr resource = SimulatorManager::getInstance()->createResource(
+            configPathCStr, callback);
+    if (nullptr == resource)
+    {
+        if (configPathCStr)
+            env->ReleaseStringUTFChars(configPath, configPathCStr);
         return NULL;
+    }
 
     JniSimulatorResource *jniSimResource = new JniSimulatorResource(resource);
     jobject jSimulatorResource = JniSimulatorResource::toJava(env,
                                  reinterpret_cast<jlong>(jniSimResource));
 
-    // Setting the uri and resourceType
-    std::string uri = resource->getURI();
-    std::string resourceType = resource->getResourceType();
-    std::string name = resource->getName();
-
-    JniSimulatorResource::setUri(env, jSimulatorResource, uri);
-    JniSimulatorResource::setResourceType(env, jSimulatorResource, resourceType);
-    JniSimulatorResource::setResourceName(env, jSimulatorResource, name);
+    jniSimResource->setResourceInfo(env, jSimulatorResource);
 
+    if (configPathCStr)
+        env->ReleaseStringUTFChars(configPath, configPathCStr);
     return jSimulatorResource;
 }
 
 JNIEXPORT jobjectArray JNICALL
-Java_org_iotivity_simulator_SimulatorManagerNativeInterface_createResources
-(JNIEnv *env, jclass object, jstring jConfigPath, jint count)
+Java_org_oic_simulator_SimulatorManagerNativeInterface_createResources
+(JNIEnv *env, jclass object, jstring configPath, jint count, jobject listener)
 {
-    //TODO: Need to implement this method
-    return nullptr;
+    if (!configPath)
+        return NULL;
+
+    if (!listener)
+        return NULL;
+
+    jweak jlistenerRef = env->NewWeakGlobalRef(listener);
+    SimulatorResourceServer::ResourceModelChangedCB callback =  [jlistenerRef](const std::string & uri,
+            const SimulatorResourceModel & resModel)
+    {
+        onResourceModelChange(jlistenerRef, uri, resModel);
+    };
+
+
+    const char *configPathCStr = env->GetStringUTFChars(configPath, NULL);
+    std::vector<SimulatorResourceServerPtr> resources =
+        SimulatorManager::getInstance()->createResource(configPathCStr, count, callback);
+
+    // Construct the object array and send it java layer
+    jobjectArray resourceArray = env->NewObjectArray(resources.size(),
+                                 gSimulatorClassRefs.classSimulatorResource, NULL);
+    if (resourceArray)
+    {
+        for (size_t i = 0; i < resources.size(); i++)
+        {
+            JniSimulatorResource *jniSimResource = new JniSimulatorResource(resources[i]);
+            jobject jSimulatorResource = JniSimulatorResource::toJava(env,
+                                         reinterpret_cast<jlong>(jniSimResource));
+            jniSimResource->setResourceInfo(env, jSimulatorResource);
+            env->SetObjectArrayElement(resourceArray, i, jSimulatorResource);
+        }
+    }
+
+    if (configPathCStr)
+        env->ReleaseStringUTFChars(configPath, configPathCStr);
+    return resourceArray;
 }
 
 JNIEXPORT jobjectArray JNICALL
-Java_org_iotivity_simulator_SimulatorManagerNativeInterface_getResources
+Java_org_oic_simulator_SimulatorManagerNativeInterface_getResources
 (JNIEnv *env, jclass object)
 {
     //TODO: Need to implement this method
@@ -235,13 +329,13 @@ Java_org_iotivity_simulator_SimulatorManagerNativeInterface_getResources
 }
 
 JNIEXPORT void JNICALL
-Java_org_iotivity_simulator_SimulatorManagerNativeInterface_deleteResource
+Java_org_oic_simulator_SimulatorManagerNativeInterface_deleteResource
 (JNIEnv *env, jclass object, jobject jResource)
 {
     if (!jResource)
         return;
 
-    std::shared_ptr<SimulatorResource> resource =
+    SimulatorResourceServerPtr resource =
         JniSimulatorResource::getJniSimulatorResourcePtr(env, jResource);
     if (!resource)
         return;
@@ -249,19 +343,21 @@ Java_org_iotivity_simulator_SimulatorManagerNativeInterface_deleteResource
     SimulatorManager::getInstance()->deleteResource(resource);
 }
 
-
 JNIEXPORT void JNICALL
-Java_org_iotivity_simulator_SimulatorManagerNativeInterface_deleteResources
+Java_org_oic_simulator_SimulatorManagerNativeInterface_deleteResources
 (JNIEnv *env, jclass object, jstring resourceType)
 {
-    if (!resourceType)
-        return;
-
-    const char *type = env->GetStringUTFChars(resourceType, NULL);
-    if (!type)
-        return;
+    std::string type;
+    const char *typeCStr = NULL;
+    if (resourceType)
+    {
+        typeCStr = env->GetStringUTFChars(resourceType, NULL);
+        type = typeCStr;
+    }
 
     SimulatorManager::getInstance()->deleteResources(type);
+    if (typeCStr)
+        env->ReleaseStringUTFChars(resourceType, typeCStr);
 }
 
 JNIEXPORT jint JNICALL
@@ -336,7 +432,7 @@ Java_org_oic_simulator_SimulatorManagerNativeInterface_getFoundResources
 }
 
 JNIEXPORT void JNICALL
-Java_org_iotivity_simulator_SimulatorManagerNativeInterface_setLogger
+Java_org_oic_simulator_SimulatorManagerNativeInterface_setLogger
 (JNIEnv *env, jclass object, jobject logger)
 {
     static std::shared_ptr<ILogger> target(new JNILogger());
@@ -398,6 +494,26 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
         return JNI_ERR;
     }
 
+    if (false == getClassRef(env, "java/util/Map", gSimulatorClassRefs.classMap))
+    {
+        return JNI_ERR;
+    }
+
+    if (false == getClassRef(env, "java/util/Map$Entry", gSimulatorClassRefs.classMapEntry))
+    {
+        return JNI_ERR;
+    }
+
+    if (false == getClassRef(env, "java/util/Set", gSimulatorClassRefs.classSet))
+    {
+        return JNI_ERR;
+    }
+
+    if (false == getClassRef(env, "java/util/Iterator", gSimulatorClassRefs.classIterator))
+    {
+        return JNI_ERR;
+    }
+
     if (false == getClassRef(env, "org/oic/simulator/serviceprovider/SimulatorResourceServer",
                              gSimulatorClassRefs.classSimulatorResource))
     {
@@ -422,7 +538,6 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
         return JNI_ERR;
     }
 
-
     // Get the reference to methods
     gSimulatorClassRefs.classIntegerCtor = env->GetMethodID(gSimulatorClassRefs.classInteger, "<init>",
                                            "(I)V");
@@ -455,6 +570,36 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
     if (!gSimulatorClassRefs.classVectorAddElement)
         return JNI_ERR;
 
+    gSimulatorClassRefs.classMapEntrySet = env->GetMethodID(
+            gSimulatorClassRefs.classMap, "entrySet", "()Ljava/util/Set;");
+    if (!gSimulatorClassRefs.classMapEntrySet)
+        return JNI_ERR;
+
+    gSimulatorClassRefs.classMapGetKey = env->GetMethodID(
+            gSimulatorClassRefs.classMapEntry, "getKey", "()Ljava/lang/Object;");
+    if (!gSimulatorClassRefs.classMapGetKey)
+        return JNI_ERR;
+
+    gSimulatorClassRefs.classMapGetValue = env->GetMethodID(
+            gSimulatorClassRefs.classMapEntry, "getValue", "()Ljava/lang/Object;");
+    if (!gSimulatorClassRefs.classMapGetValue)
+        return JNI_ERR;
+
+    gSimulatorClassRefs.classIteratorId = env->GetMethodID(
+            gSimulatorClassRefs.classSet, "iterator", "()Ljava/util/Iterator;");
+    if (!gSimulatorClassRefs.classIteratorId)
+        return JNI_ERR;
+
+    gSimulatorClassRefs.classHasNextId = env->GetMethodID(
+            gSimulatorClassRefs.classIterator, "hasNext", "()Z");
+    if (!gSimulatorClassRefs.classHasNextId)
+        return JNI_ERR;
+
+    gSimulatorClassRefs.classNextId = env->GetMethodID(
+                                          gSimulatorClassRefs.classIterator, "next", "()Ljava/lang/Object;");
+    if (!gSimulatorClassRefs.classNextId)
+        return JNI_ERR;
+
     gSimulatorClassRefs.classSimulatorResourceCtor = env->GetMethodID(
                 gSimulatorClassRefs.classSimulatorResource, "<init>", "(J)V");
     if (!gSimulatorClassRefs.classSimulatorResourceCtor)
@@ -490,6 +635,11 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
     if (!gSimulatorClassRefs.classSimulatorResourceAttributeCtor)
         return JNI_ERR;
 
+    gSimulatorClassRefs.classSimulatorResourceModelId = env->GetMethodID(
+                gSimulatorClassRefs.classSimulatorResourceModel, "<init>", "(J)V");
+    if (!gSimulatorClassRefs.classSimulatorResourceModelId)
+        return JNI_ERR;
+
     gvm = vm;
     return JNI_VERSION_1_6;
 }
index 2089536238a20e7929a4c021c0ecb907d640a45e..410aa7158d38b0082bb740f3e4b5b5596ef92454 100644 (file)
@@ -28,27 +28,27 @@ extern "C" {
 #endif
 
 JNIEXPORT jobject JNICALL
-Java_org_iotivity_simulator_SimulatorManagerNativeInterface_createResource
-(JNIEnv *env, jclass object, jstring jConfigPath);
+Java_org_oic_simulator_SimulatorManagerNativeInterface_createResource
+(JNIEnv *env, jclass object, jstring jConfigPath, jobject jListener);
 
 JNIEXPORT jobjectArray JNICALL
-Java_org_iotivity_simulator_SimulatorManagerNativeInterface_createResources
-(JNIEnv *env, jclass object, jstring jConfigPath, jint count);
+Java_org_oic_simulator_SimulatorManagerNativeInterface_createResources
+(JNIEnv *env, jclass object, jstring jConfigPath, jint count, jobject jListener);
 
 JNIEXPORT jobjectArray JNICALL
-Java_org_iotivity_simulator_SimulatorManageNativeInterfacer_getResources
+Java_org_oic_simulator_SimulatorManageNativeInterface_getResources
 (JNIEnv *env, jclass object);
 
 JNIEXPORT void JNICALL
-Java_org_iotivity_simulator_SimulatorManagerNativeInterface_deleteResource
+Java_org_oic_simulator_SimulatorManagerNativeInterface_deleteResource
 (JNIEnv *env, jclass object, jobject jResource);
 
 JNIEXPORT void JNICALL
-Java_org_iotivity_simulator_SimulatorManagerNativeInterface_deleteResources
+Java_org_oic_simulator_SimulatorManagerNativeInterface_deleteResources
 (JNIEnv *env, jclass object, jstring resourceType);
 
 JNIEXPORT void JNICALL
-Java_org_iotivity_simulator_SimulatorManagerNativeInterface_setLogger
+Java_org_oic_simulator_SimulatorManagerNativeInterface_setLogger
 (JNIEnv *env, jclass object, jobject logger);
 
 JNIEXPORT jint JNICALL
index c2aafbdfa082db8cd1a1f1a8aad1410dbbc8b446..62241de27b84bac26fef08fd28e90d77e777d9db 100644 (file)
@@ -67,7 +67,7 @@ class attribute_value_visitor : public boost::static_visitor<jobject>
 };
 
 JNIEXPORT void JNICALL
-Java_org_iotivity_simulator_SimulatorResourceAttribute_create
+Java_org_oic_simulator_SimulatorResourceAttribute_create
 (JNIEnv *env, jobject object, jstring attrName)
 {
     if (!attrName)
@@ -92,7 +92,7 @@ Java_org_iotivity_simulator_SimulatorResourceAttribute_create
 }
 
 JNIEXPORT void JNICALL
-Java_org_iotivity_simulator_SimulatorResourceAttribute_dispose
+Java_org_oic_simulator_SimulatorResourceAttribute_dispose
 (JNIEnv *env, jobject object)
 {
     SimulatorResourceModel::Attribute *attribute = GetHandle<SimulatorResourceModel::Attribute>(env,
@@ -101,7 +101,7 @@ Java_org_iotivity_simulator_SimulatorResourceAttribute_dispose
 }
 
 JNIEXPORT int JNICALL
-Java_org_iotivity_simulator_SimulatorResourceAttribute_allowedValuesSize
+Java_org_oic_simulator_SimulatorResourceAttribute_allowedValuesSize
 (JNIEnv *env, jobject object)
 {
     SimulatorResourceModel::Attribute *attribute = GetHandle<SimulatorResourceModel::Attribute>(env,
@@ -115,7 +115,7 @@ Java_org_iotivity_simulator_SimulatorResourceAttribute_allowedValuesSize
 }
 
 JNIEXPORT jstring JNICALL
-Java_org_iotivity_simulator_SimulatorResourceAttribute_valueToString
+Java_org_oic_simulator_SimulatorResourceAttribute_valueToString
 (JNIEnv *env, jobject object)
 {
     SimulatorResourceModel::Attribute *attribute = GetHandle<SimulatorResourceModel::Attribute>(env,
@@ -130,7 +130,7 @@ Java_org_iotivity_simulator_SimulatorResourceAttribute_valueToString
 }
 
 JNIEXPORT jstring JNICALL
-Java_org_iotivity_simulator_SimulatorResourceAttribute_allowedValuesToString
+Java_org_oic_simulator_SimulatorResourceAttribute_allowedValuesToString
 (JNIEnv *env, jobject object)
 {
     SimulatorResourceModel::Attribute *attribute = GetHandle<SimulatorResourceModel::Attribute>(env,
@@ -145,7 +145,7 @@ Java_org_iotivity_simulator_SimulatorResourceAttribute_allowedValuesToString
 }
 
 JNIEXPORT jstring JNICALL
-Java_org_iotivity_simulator_SimulatorResourceAttribute_getName
+Java_org_oic_simulator_SimulatorResourceAttribute_getName
 (JNIEnv *env, jobject object)
 {
     SimulatorResourceModel::Attribute *attribute = GetHandle<SimulatorResourceModel::Attribute>(env,
@@ -160,7 +160,7 @@ Java_org_iotivity_simulator_SimulatorResourceAttribute_getName
 }
 
 JNIEXPORT jobject JNICALL
-Java_org_iotivity_simulator_SimulatorResourceAttribute_getValue
+Java_org_oic_simulator_SimulatorResourceAttribute_getValue
 (JNIEnv *env, jobject object)
 {
     SimulatorResourceModel::Attribute *attribute = GetHandle<SimulatorResourceModel::Attribute>(env,
index a6afc919b19961546739b430e7df1fbe51417202..df7d2d587aaaddc0ddb5c8cbf6919fddc1c94797 100644 (file)
@@ -35,31 +35,31 @@ extern "C" {
 #endif
 
 JNIEXPORT void JNICALL
-Java_org_iotivity_simulator_SimulatorResourceAttribute_create
+Java_org_oic_simulator_SimulatorResourceAttribute_create
 (JNIEnv *, jobject, jstring);
 
 JNIEXPORT void JNICALL
-Java_org_iotivity_simulator_SimulatorResourceAttribute_dispose
+Java_org_oic_simulator_SimulatorResourceAttribute_dispose
 (JNIEnv *, jobject);
 
 JNIEXPORT int JNICALL
-Java_org_iotivity_simulator_SimulatorResourceAttribute_allowedValuesSize
+Java_org_oic_simulator_SimulatorResourceAttribute_allowedValuesSize
 (JNIEnv *, jobject);
 
 JNIEXPORT jstring JNICALL
-Java_org_iotivity_simulator_SimulatorResourceAttribute_valueToString
+Java_org_oic_simulator_SimulatorResourceAttribute_valueToString
 (JNIEnv *, jobject);
 
 JNIEXPORT jstring JNICALL
-Java_org_iotivity_simulator_SimulatorResourceAttribute_allowedValuesToString
+Java_org_oic_simulator_SimulatorResourceAttribute_allowedValuesToString
 (JNIEnv *, jobject);
 
 JNIEXPORT jstring JNICALL
-Java_org_iotivity_simulator_SimulatorResourceAttribute_getName
+Java_org_oic_simulator_SimulatorResourceAttribute_getName
 (JNIEnv *, jobject);
 
 JNIEXPORT jobject JNICALL
-Java_org_iotivity_simulator_SimulatorResourceAttribute_getValue
+Java_org_oic_simulator_SimulatorResourceAttribute_getValue
 (JNIEnv *, jobject);
 
 #ifdef __cplusplus
diff --git a/service/simulator/java/jni/simulator_resource_jni.cpp b/service/simulator/java/jni/simulator_resource_jni.cpp
deleted file mode 100644 (file)
index 2143ee6..0000000
+++ /dev/null
@@ -1,468 +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 "simulator_resource_jni.h"
-#include "simulator_resource_jni_util.h"
-#include "simulator_common_jni.h"
-#include "simulator_resource_model_jni.h"
-
-extern SimulatorClassRefs gSimulatorClassRefs;
-
-JniSimulatorResource::JniSimulatorResource(SimulatorResourcePtr &resource)
-    : m_sharedResource(resource) {}
-
-SimulatorResourcePtr JniSimulatorResource::getJniSimulatorResourcePtr(JNIEnv *env, jobject thiz)
-{
-    JniSimulatorResource *resource = GetHandle<JniSimulatorResource>(env, thiz);
-    if (env->ExceptionCheck())
-    {
-        return NULL;
-    }
-    return resource->m_sharedResource;
-}
-
-jobject JniSimulatorResource::toJava(JNIEnv *env, jlong resource)
-{
-    jobject resourceObj = (jobject) env->NewObject(gSimulatorClassRefs.classSimulatorResource,
-                          gSimulatorClassRefs.classSimulatorResourceCtor, resource);
-    if (NULL == resourceObj)
-    {
-        return NULL;
-    }
-    return resourceObj;
-}
-
-void JniSimulatorResource::setUri(JNIEnv *env, jobject jobj, const std::string &uri)
-{
-    if (!env || !jobj)
-        return;
-
-    jstring jURI = env->NewStringUTF(uri.c_str());
-    if (!jURI)
-        return;
-
-    env->CallVoidMethod(jobj, gSimulatorClassRefs.classSimulatorResourceSetURI, jURI);
-    env->DeleteLocalRef(jURI);
-}
-
-void JniSimulatorResource::setResourceType(JNIEnv *env, jobject jobj,
-        const std::string &resourceType)
-{
-    if (!env || !jobj)
-        return;
-
-    jstring jResourceType = env->NewStringUTF(resourceType.c_str());
-    if (!jResourceType)
-        return;
-
-    env->CallVoidMethod(jobj, gSimulatorClassRefs.classSimulatorResourceSetResourceType, jResourceType);
-    env->DeleteLocalRef(jResourceType);
-}
-
-void JniSimulatorResource::setResourceName(JNIEnv *env, jobject jobj, const std::string &name)
-{
-    if (!env || !jobj)
-        return;
-
-    jstring jName = env->NewStringUTF(name.c_str());
-    if (!jName)
-        return;
-
-    env->CallVoidMethod(jobj, gSimulatorClassRefs.classSimulatorResourceSetName, jName);
-    env->DeleteLocalRef(jName);
-}
-
-JNIEXPORT jobject JNICALL
-Java_org_iotivity_simulator_SimulatorResourceServer_getModel
-(JNIEnv *env, jobject object)
-{
-    SimulatorResourcePtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env, object);
-    if (nullptr == resource.get())
-    {
-        std::cout << "getModel: Resource is NULL";
-        return nullptr;
-    }
-
-    SimulatorResourceModel resModel = resource->getModel();
-    JniSimulatorResourceModel *model = new JniSimulatorResourceModel(resModel);
-    jobject jModel = JniSimulatorResourceModel::toJava(env, reinterpret_cast<jlong>(model));
-    return jModel;
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_simulator_SimulatorResourceServer_updateAttributeFromAllowedValues
-(JNIEnv *env, jobject object, jstring attrName, jint index)
-{
-    SimulatorResourcePtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env, object);
-    if (nullptr == resource.get())
-    {
-        std::cout << "updateAttributeFromAllowedValues: Resource is NULL";
-        return;
-    }
-
-    const char *attrNamePtr = env->GetStringUTFChars(attrName, NULL);
-    if (!attrNamePtr)
-    {
-        std::cout << "updateAttributeFromAllowedValues: Failed to convert jstring to char string!";
-        return;
-    }
-
-    resource->updateAttributeFromAllowedValues(attrNamePtr, static_cast<int>(index));
-    env->ReleaseStringUTFChars(attrName, attrNamePtr);
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_simulator_SimulatorResourceServer_setRange
-(JNIEnv *env, jobject object, jstring attrName, jint min, jint max)
-{
-    SimulatorResourcePtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env, object);
-    if (nullptr == resource.get())
-    {
-        std::cout << "setRange: Resource is NULL";
-        return;
-    }
-
-    const char *attrNamePtr = env->GetStringUTFChars(attrName, NULL);
-    if (!attrNamePtr)
-    {
-        std::cout << "setRange: Failed to convert jstring to char string!";
-        return;
-    }
-
-    resource->setRange(attrNamePtr, static_cast<int>(min), static_cast<int>(max));
-    env->ReleaseStringUTFChars(attrName, attrNamePtr);
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_simulator_SimulatorResourceServer_setInterfaceType
-(JNIEnv *env, jobject jobject, const std::string &interfaceType)
-{
-    jstring jInterfaceType = env->NewStringUTF(interfaceType.c_str());
-    if (!jInterfaceType)
-    {
-        std::cout << "setInterfaceType: InterfaceType is NULL";
-        return;
-    }
-
-    env->CallVoidMethod(jobject, gSimulatorClassRefs.classSimulatorResourceSetInterfaceType,
-                        jInterfaceType);
-    env->DeleteLocalRef(jInterfaceType);
-}
-
-JNIEXPORT void JNICALL Java_org_iotivity_simulator_SimulatorResourceServer_addAttributeInteger
-(JNIEnv *env, jobject jobject, jstring jKey, jint jValue)
-{
-    if (!jKey)
-    {
-        std::cout << "addAttributeInteger: AttributeName is Empty";
-        return;
-    }
-
-    SimulatorResourcePtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env, jobject);
-    if (nullptr == resource.get())
-    {
-        std::cout << "addAttributeInteger: Resource is NULL";
-        return;
-    }
-
-    std::string str = env->GetStringUTFChars(jKey, NULL);
-    resource->addAttribute(str, static_cast<int>(jValue));
-}
-
-JNIEXPORT void JNICALL Java_org_iotivity_simulator_SimulatorResourceServer_addAttributeDouble
-(JNIEnv *env, jobject jobject, jstring jKey, jdouble jValue)
-{
-    if (!jKey)
-    {
-        std::cout << "addAttributeDouble: AttributeName is Empty";
-        return;
-    }
-
-    SimulatorResourcePtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env, jobject);
-    if (nullptr == resource.get())
-    {
-        std::cout << "addAttributeDouble: Resource is NULL";
-        return;
-    }
-
-    std::string str = env->GetStringUTFChars(jKey, NULL);
-    resource->addAttribute(str, static_cast<double>(jValue));
-}
-
-JNIEXPORT void JNICALL Java_org_iotivity_simulator_SimulatorResourceServer_addAttributeBoolean
-(JNIEnv *env, jobject jobject, jstring jKey, jboolean jValue)
-{
-    if (!jKey)
-    {
-        std::cout << "addAttributeBoolean: AttributeName is Empty";
-        return;
-    }
-
-    SimulatorResourcePtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env, jobject);
-    if (nullptr == resource.get())
-    {
-        std::cout << "addAttributeBoolean: Resource is NULL";
-        return;
-    }
-
-    std::string str = env->GetStringUTFChars(jKey, NULL);
-    resource->addAttribute(str, static_cast<bool>(jValue));
-}
-
-JNIEXPORT void JNICALL Java_org_iotivity_simulator_SimulatorResourceServer_addAttributeStringN
-(JNIEnv *env, jobject jobject, jstring jKey, jstring jValue)
-{
-    if (!jKey)
-    {
-        std::cout << "addAttributeStringN: AttributeName is Empty";
-        return;
-    }
-
-    SimulatorResourcePtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env, jobject);
-    if (nullptr == resource.get())
-    {
-        std::cout << "addAttributeStringN: Resource is NULL";
-        return;
-    }
-
-    std::string key = env->GetStringUTFChars(jKey, NULL);
-    std::string value = env->GetStringUTFChars(jValue, NULL);
-
-    resource->addAttribute(key, value);
-}
-
-JNIEXPORT void JNICALL Java_org_iotivity_simulator_SimulatorResourceServer_updateAttributeInteger
-(JNIEnv *env, jobject jobject, jstring jKey, jint jValue)
-{
-    if (!jKey)
-    {
-        std::cout << "updateAttributeInteger: AttributeName is Empty";
-        return;
-    }
-
-    SimulatorResourcePtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env, jobject);
-    if (nullptr == resource.get())
-    {
-        std::cout << "updateAttributeInteger: Resource is NULL";
-        return;
-    }
-
-    std::string str = env->GetStringUTFChars(jKey, NULL);
-    resource->updateAttribute(str, static_cast<int>(jValue));
-}
-
-JNIEXPORT void JNICALL Java_org_iotivity_simulator_SimulatorResourceServer_updateAttributeDouble
-(JNIEnv *env, jobject jobject, jstring jKey, jdouble jValue)
-{
-    if (!jKey)
-    {
-        std::cout << "updateAttributeDouble: AttributeName is Empty";
-        return;
-    }
-
-    SimulatorResourcePtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env, jobject);
-    if (nullptr == resource.get())
-    {
-        std::cout << "updateAttributeDouble: Resource is NULL";
-        return;
-    }
-
-    std::string str = env->GetStringUTFChars(jKey, NULL);
-    resource->updateAttribute(str, static_cast<double>(jValue));
-}
-
-JNIEXPORT void JNICALL Java_org_iotivity_simulator_SimulatorResourceServer_updateAttributeBoolean
-(JNIEnv *env, jobject jobject, jstring jKey, jboolean jValue)
-{
-    if (!jKey)
-    {
-        std::cout << "updateAttributeBoolean: AttributeName is Empty";
-        return;
-    }
-
-    SimulatorResourcePtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env, jobject);
-    if (nullptr == resource.get())
-    {
-        std::cout << "updateAttributeBoolean: Resource is NULL";
-        return;
-    }
-
-    std::string str = env->GetStringUTFChars(jKey, NULL);
-    resource->updateAttribute(str, static_cast<bool>(jValue));
-}
-
-JNIEXPORT void JNICALL Java_org_iotivity_simulator_SimulatorResourceServer_updateAttributeStringN
-(JNIEnv *env, jobject jobject, jstring jKey, jstring jValue)
-{
-    if (!jKey)
-    {
-        std::cout << "updateAttributeStringN: AttributeName is Empty";
-        return;
-    }
-
-    SimulatorResourcePtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env, jobject);
-    if (nullptr == resource.get())
-    {
-        std::cout << "updateAttributeStringN: Resource is NULL";
-        return;
-    }
-
-    std::string key = env->GetStringUTFChars(jKey, NULL);
-    std::string value = env->GetStringUTFChars(jValue, NULL);
-
-    resource->updateAttribute(key, value);
-}
-
-JNIEXPORT void JNICALL Java_org_iotivity_simulator_SimulatorResourceServer_setAllowedValuesInteger
-(JNIEnv *env, jobject object, jstring jKey, jobject jAllowedValues)
-{
-    if (!jKey)
-    {
-        std::cout << "setAllowedValuesInteger: AttributeName is Empty";
-        return;
-    }
-
-    SimulatorResourcePtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env, object);
-    if (nullptr == resource.get())
-    {
-        std::cout << "setAllowedValuesInteger: Resource is NULL";
-        return;
-    }
-
-    std::string str = env->GetStringUTFChars(jKey, NULL);
-    resource->setAllowedValues(str, convertIntegerVector(env, jAllowedValues));
-}
-
-JNIEXPORT void JNICALL Java_org_iotivity_simulator_SimulatorResourceServer_setAllowedValuesDouble
-(JNIEnv *env, jobject object, jstring jKey, jobject jAllowedValues)
-{
-    if (!jKey)
-    {
-        std::cout << "setAllowedValuesDouble: AttributeName is Empty";
-        return;
-    }
-
-    SimulatorResourcePtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env, object);
-    if (nullptr == resource.get())
-    {
-        std::cout << "setAllowedValuesDouble: Resource is NULL";
-        return;
-    }
-
-    std::string str = env->GetStringUTFChars(jKey, NULL);
-    resource->setAllowedValues(str, convertDoubleVector(env, jAllowedValues));
-}
-
-JNIEXPORT void JNICALL Java_org_iotivity_simulator_SimulatorResourceServer_setAllowedValuesStringN
-(JNIEnv *env, jobject object, jstring jKey, jobject jAllowedValues)
-{
-    if (!jKey)
-    {
-        std::cout << "setAllowedValuesStringN: AttributeName is Empty";
-        return;
-    }
-
-    SimulatorResourcePtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env, object);
-    if (nullptr == resource.get())
-    {
-        std::cout << "setAllowedValuesStringN: Resource is NULL";
-        return;
-    }
-
-    std::string str = env->GetStringUTFChars(jKey, NULL);
-    resource->setAllowedValues(str, convertStringVector(env, jAllowedValues));
-}
-
-JNIEXPORT jint JNICALL
-Java_org_iotivity_simulator_SimulatorResourceServer_startResourceAutomation
-(JNIEnv *env, jobject object)
-{
-    SimulatorResourcePtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env, object);
-    if (nullptr == resource.get())
-    {
-        return -1;
-    }
-
-    int automationId;
-    if (SIMULATOR_SUCCESS != resource->startUpdateAutomation(AutomationType::NORMAL, automationId))
-        return -1;
-
-    return automationId;
-}
-
-JNIEXPORT jint JNICALL
-Java_org_iotivity_simulator_SimulatorResourceServer_startAttributeAutomation
-(JNIEnv *env, jobject object, jstring attrName)
-{
-    SimulatorResourcePtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env, object);
-    if (nullptr == resource.get())
-    {
-        return -1;
-    }
-
-    const char *attrNamePtr = env->GetStringUTFChars(attrName, NULL);
-
-    int automationId = -1;
-    resource->startUpdateAutomation(AutomationType::NORMAL, automationId);
-
-    env->ReleaseStringUTFChars(attrName, attrNamePtr);
-    return automationId;
-}
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_simulator_SimulatorResourceServer_startAutomation
-(JNIEnv *env, jobject object, jint automationId)
-{
-    SimulatorResourcePtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env, object);
-    if (nullptr == resource.get())
-    {
-        return;
-    }
-
-    resource->stopUpdateAutomation(automationId);
-}
-
-JNIEXPORT void JNICALL Java_org_iotivity_simulator_SimulatorResourceServer_removeAttribute
-(JNIEnv *env, jobject jobject, jstring jKey)
-{
-    if (!jKey)
-    {
-        std::cout << "removeAttribute: AttributeName is Empty";
-        return;
-    }
-
-    SimulatorResourcePtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env, jobject);
-    if (nullptr == resource.get())
-    {
-        std::cout << "removeAttribute: Resource is NULL";
-        return;
-    }
-
-    std::string str = env->GetStringUTFChars(jKey, NULL);
-    resource->removeAttribute(str);
-}
-
-JNIEXPORT void JNICALL Java_org_iotivity_simulator_SimulatorResourceServer_dispose
-(JNIEnv *env, jobject thiz)
-{
-    JniSimulatorResource *resource = GetHandle<JniSimulatorResource>(env, thiz);
-    delete resource;
-}
-
diff --git a/service/simulator/java/jni/simulator_resource_jni.h b/service/simulator/java/jni/simulator_resource_jni.h
deleted file mode 100644 (file)
index aaf6a75..0000000
+++ /dev/null
@@ -1,124 +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.
- *
- ******************************************************************/
-
-#ifndef SIMULATOR_RESOURCE_JNI_H_
-#define SIMULATOR_RESOURCE_JNI_H_
-
-#include <jni.h>
-#include "simulator_resource.h"
-
-class JniSimulatorResource
-{
-    public:
-        JniSimulatorResource(SimulatorResourcePtr &resource);
-
-        static jobject toJava(JNIEnv *env, jlong resource);
-        static void setUri(JNIEnv *env, jobject jobj, const std::string &uri);
-        static void setResourceType(JNIEnv *env, jobject jobj, const std::string &resourceType);
-        static void setResourceName(JNIEnv *env, jobject jobj, const std::string &name);
-        static void setInterfaceType(JNIEnv *env, jobject jobject, const std::string &interfaceType);
-        static SimulatorResourcePtr getJniSimulatorResourcePtr(JNIEnv *env, jobject thiz);
-    private:
-        SimulatorResourcePtr m_sharedResource;
-};
-
-
-#ifdef __cplusplus
-extern "C" {
-
-JNIEXPORT jobject JNICALL
-Java_org_iotivity_simulator_SimulatorResourceServer_getModel
-(JNIEnv *, jobject);
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_simulator_SimulatorResourceServer_updateAttributeFromAllowedValues
-(JNIEnv *, jobject, jstring, jint);
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_simulator_SimulatorResourceServer_setRange
-(JNIEnv *, jobject, jstring, jint, jint);
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_simulator_SimulatorResourceServer_addAttributeInteger
-(JNIEnv *, jobject, jstring, jint);
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_simulator_SimulatorResourceServer_addAttributeDouble
-(JNIEnv *, jobject, jstring, jdouble);
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_simulator_SimulatorResourceServer_addAttributeBoolean
-(JNIEnv *, jobject, jstring, jboolean);
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_simulator_SimulatorResourceServer_addAttributeStringN
-(JNIEnv *, jobject, jstring, jstring);
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_simulator_SimulatorResourceServer_updateAttributeInteger
-(JNIEnv *, jobject, jstring, jint);
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_simulator_SimulatorResourceServer_updateAttributeDouble
-(JNIEnv *, jobject, jstring, jdouble);
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_simulator_SimulatorResourceServer_updateAttributeBoolean
-(JNIEnv *, jobject, jstring, jboolean);
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_simulator_SimulatorResourceServer_updateAttributeStringN
-(JNIEnv *, jobject, jstring, jstring);
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_simulator_SimulatorResourceServer_setAllowedValuesInteger
-(JNIEnv *, jobject, jstring, jobject);
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_simulator_SimulatorResourceServer_setAllowedValuesDouble
-(JNIEnv *, jobject, jstring, jobject);
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_simulator_SimulatorResourceServer_setAllowedValuesStringN
-(JNIEnv *, jobject, jstring, jobject);
-
-JNIEXPORT jint JNICALL
-Java_org_iotivity_simulator_SimulatorResourceServer_startResourceAutomation
-(JNIEnv *, jobject);
-
-JNIEXPORT jint JNICALL
-Java_org_iotivity_simulator_SimulatorResourceServer_startAttributeAutomation
-(JNIEnv *, jobject, jstring);
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_simulator_SimulatorResourceServer_startAutomation
-(JNIEnv *, jobject, jint);
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_simulator_SimulatorResourceServer_removeAttribute
-(JNIEnv *, jobject, jstring);
-
-JNIEXPORT void JNICALL
-Java_org_iotivity_simulator_SimulatorResourceServer_dispose
-(JNIEnv *, jobject);
-
-}
-#endif
-#endif //SIMULATOR_RESOURCE_JNI_H_
index f53e5a0a78486712921f783dc778be2cd04dcacd..a93998ceb0fe36d6b7397d8183f430840baac2c5 100644 (file)
@@ -35,7 +35,7 @@ std::vector<int> convertIntegerVector(JNIEnv *env, jobject jVectorInt)
         return vectorInt;
     }
 
-    jmethodID get = env->GetMethodID(vectorClass, "get", "(I)I");
+    jmethodID get = env->GetMethodID(vectorClass, "get", "(I)""Ljava/lang/Object;");
     if (NULL == get)
     {
         return vectorInt;
@@ -70,7 +70,7 @@ std::vector<double> convertDoubleVector(JNIEnv *env, jobject jVectorDouble)
         return vectorDouble;
     }
 
-    jmethodID get = env->GetMethodID(vectorClass, "get", "(I)D");
+    jmethodID get = env->GetMethodID(vectorClass, "get", "(I)""Ljava/lang/Object;");
     if (NULL == get)
     {
         return vectorDouble;
index 4280f32437891b8aaf1cd3cb45e37654b6fb9f99..b886d39550e19aa388b80a9c56910fa09604cdc2 100644 (file)
@@ -73,7 +73,7 @@ static void addEntryToHashMap(JNIEnv *env, jobject mapobj, jobject key, jobject
 }
 
 JNIEXPORT jint JNICALL
-Java_org_iotivity_simulator_SimulatorResourceModel_size
+Java_org_oic_simulator_serviceprovider_SimulatorResourceModel_size
 (JNIEnv *env, jobject thiz)
 {
     SimulatorResourceModel resourceModel;
@@ -87,7 +87,7 @@ Java_org_iotivity_simulator_SimulatorResourceModel_size
 }
 
 JNIEXPORT jobject JNICALL
-Java_org_iotivity_simulator_SimulatorResourceModel_getAttributes
+Java_org_oic_simulator_serviceprovider_SimulatorResourceModel_getAttributes
 (JNIEnv *env, jobject thiz)
 {
     SimulatorResourceModel resourceModel;
@@ -126,7 +126,7 @@ Java_org_iotivity_simulator_SimulatorResourceModel_getAttributes
 }
 
 JNIEXPORT jobject JNICALL
-Java_org_iotivity_simulator_SimulatorResourceModel_getAttribute
+Java_org_oic_simulator_serviceprovider_SimulatorResourceModel_getAttribute
 (JNIEnv *env, jobject thiz, jstring jAttrName)
 {
     if (!jAttrName)
@@ -170,7 +170,7 @@ Java_org_iotivity_simulator_SimulatorResourceModel_getAttribute
 }
 
 JNIEXPORT jobjectArray JNICALL
-Java_org_iotivity_simulator_SimulatorResourceModel_getAllowedValues
+Java_org_oic_simulator_serviceprovider_SimulatorResourceModel_getAllowedValues
 (JNIEnv *env, jobject thiz, jstring jAttrName)
 {
     if (!jAttrName)
@@ -225,7 +225,7 @@ Java_org_iotivity_simulator_SimulatorResourceModel_getAllowedValues
 }
 
 JNIEXPORT void JNICALL
-Java_org_iotivity_simulator_SimulatorResourceModel_dispose
+Java_org_oic_simulator_serviceprovider_SimulatorResourceModel_dispose
 (JNIEnv *env, jobject thiz)
 {
     JniSimulatorResourceModel *resourceModel = GetHandle<JniSimulatorResourceModel>(env, thiz);
index 43202a3975522bdf5d1cf4eca2f5109710af741a..010007658d4f1d2ac72d0228526a7812f052e39c 100644 (file)
@@ -42,23 +42,23 @@ extern "C" {
 #endif
 
 JNIEXPORT jint JNICALL
-Java_org_iotivity_simulator_SimulatorResourceModel_size
+Java_org_oic_simulator_serviceprovider_SimulatorResourceModel_size
 (JNIEnv *, jobject);
 
 JNIEXPORT jobject JNICALL
-Java_org_iotivity_simulator_SimulatorResourceModel_getAttributes
+Java_org_oic_simulator_serviceprovider_SimulatorResourceModel_getAttributes
 (JNIEnv *, jobject);
 
 JNIEXPORT jobject JNICALL
-Java_org_iotivity_simulator_SimulatorResourceModel_getAttribute
+Java_org_oic_simulator_serviceprovider_SimulatorResourceModel_getAttribute
 (JNIEnv *, jobject, jstring);
 
 JNIEXPORT jobjectArray JNICALL
-Java_org_iotivity_simulator_SimulatorResourceModel_getAllowedValues
+Java_org_oic_simulator_serviceprovider_SimulatorResourceModel_getAllowedValues
 (JNIEnv *, jobject, jstring);
 
 JNIEXPORT void JNICALL
-Java_org_iotivity_simulator_SimulatorResourceModel_dispose
+Java_org_oic_simulator_serviceprovider_SimulatorResourceModel_dispose
 (JNIEnv *, jobject);
 
 
diff --git a/service/simulator/java/jni/simulator_resource_server_jni.cpp b/service/simulator/java/jni/simulator_resource_server_jni.cpp
new file mode 100644 (file)
index 0000000..bde0c52
--- /dev/null
@@ -0,0 +1,575 @@
+/******************************************************************
+ *
+ * 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 "simulator_resource_server_jni.h"
+#include "simulator_resource_jni_util.h"
+#include "simulator_common_jni.h"
+#include "simulator_resource_model_jni.h"
+
+extern SimulatorClassRefs gSimulatorClassRefs;
+
+JniSimulatorResource::JniSimulatorResource(SimulatorResourceServerPtr &resource)
+    : m_sharedResource(resource) {}
+
+SimulatorResourceServerPtr JniSimulatorResource::getJniSimulatorResourcePtr(JNIEnv *env,
+        jobject thiz)
+{
+    JniSimulatorResource *resource = GetHandle<JniSimulatorResource>(env, thiz);
+    if (env->ExceptionCheck())
+    {
+        return NULL;
+    }
+    return resource->m_sharedResource;
+}
+
+jobject JniSimulatorResource::toJava(JNIEnv *env, jlong resource)
+{
+    jobject resourceObj = (jobject) env->NewObject(gSimulatorClassRefs.classSimulatorResource,
+                          gSimulatorClassRefs.classSimulatorResourceCtor, resource);
+    if (NULL == resourceObj)
+    {
+        return NULL;
+    }
+    return resourceObj;
+}
+
+void JniSimulatorResource::setResourceInfo(JNIEnv *env, jobject jobj)
+{
+    if (!env || !jobj)
+        return;
+
+    std::string uri = m_sharedResource->getURI();
+    std::string resourceType = m_sharedResource->getResourceType();
+    std::string name = m_sharedResource->getName();
+    std::string interfaceType = m_sharedResource->getInterfaceType();
+
+    jstring jURI = env->NewStringUTF(uri.c_str());
+    if (jURI)
+    {
+        env->CallVoidMethod(jobj, gSimulatorClassRefs.classSimulatorResourceSetURI, jURI);
+        env->DeleteLocalRef(jURI);
+    }
+
+    jstring jResourceType = env->NewStringUTF(resourceType.c_str());
+    if (jResourceType)
+    {
+        env->CallVoidMethod(jobj, gSimulatorClassRefs.classSimulatorResourceSetResourceType, jResourceType);
+        env->DeleteLocalRef(jResourceType);
+    }
+
+    jstring jName = env->NewStringUTF(name.c_str());
+    if (jName)
+    {
+        env->CallVoidMethod(jobj, gSimulatorClassRefs.classSimulatorResourceSetName, jName);
+        env->DeleteLocalRef(jName);
+    }
+
+    jstring jInterfaceType = env->NewStringUTF(interfaceType.c_str());
+    if (jInterfaceType)
+    {
+        env->CallVoidMethod(jobj, gSimulatorClassRefs.classSimulatorResourceSetInterfaceType,
+                            jInterfaceType);
+        env->DeleteLocalRef(jInterfaceType);
+    }
+}
+
+void onAutomationComplete(jweak jlistenerRef, const std::string &uri,
+                          const int automationID)
+{
+    std::cout << "onAutomationComplete JNI entry" << std::endl;
+    JNIEnv *env = getEnv();
+    if (nullptr == env)
+        return;
+
+    jobject autoCompleteListener = env->NewLocalRef(jlistenerRef);
+    if (!autoCompleteListener)
+    {
+        releaseEnv();
+        return;
+    }
+
+    jclass autoCompleteCls = env->GetObjectClass(autoCompleteListener);
+    if (!autoCompleteCls)
+    {
+        releaseEnv();
+        return;
+    }
+
+    jmethodID autoCompleteMId = env->GetMethodID(autoCompleteCls, "onAutomationComplete",
+                                "(Ljava/lang/String;I)V");
+    if (!autoCompleteMId)
+    {
+        releaseEnv();
+        return;
+    }
+
+    jstring jUri = env->NewStringUTF(uri.c_str());
+
+    env->CallVoidMethod(autoCompleteListener, autoCompleteMId, jUri, automationID);
+    if ((env)->ExceptionCheck())
+    {
+        releaseEnv();
+        return;
+    }
+
+    env->DeleteLocalRef(jUri);
+
+    releaseEnv();
+}
+
+JNIEXPORT jobject JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_getModel
+(JNIEnv *env, jobject object)
+{
+    SimulatorResourceServerPtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env, object);
+    if (nullptr == resource.get())
+    {
+        std::cout << "getModel: Resource is NULL";
+        return nullptr;
+    }
+
+    SimulatorResourceModel resModel = resource->getModel();
+    JniSimulatorResourceModel *model = new JniSimulatorResourceModel(resModel);
+    jobject jModel = JniSimulatorResourceModel::toJava(env, reinterpret_cast<jlong>(model));
+    return jModel;
+}
+
+JNIEXPORT void JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_updateAttributeFromAllowedValues
+(JNIEnv *env, jobject object, jstring attrName, jint index)
+{
+    SimulatorResourceServerPtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env, object);
+    if (nullptr == resource.get())
+    {
+        std::cout << "updateAttributeFromAllowedValues: Resource is NULL";
+        return;
+    }
+
+    const char *attrNamePtr = env->GetStringUTFChars(attrName, NULL);
+    if (!attrNamePtr)
+    {
+        std::cout << "updateAttributeFromAllowedValues: Failed to convert jstring to char string!";
+        return;
+    }
+
+    resource->updateAttributeFromAllowedValues(attrNamePtr, static_cast<int>(index));
+    env->ReleaseStringUTFChars(attrName, attrNamePtr);
+}
+
+JNIEXPORT void JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_setRange
+(JNIEnv *env, jobject object, jstring attrName, jint min, jint max)
+{
+    SimulatorResourceServerPtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env, object);
+    if (nullptr == resource.get())
+    {
+        std::cout << "setRange: Resource is NULL";
+        return;
+    }
+
+    const char *attrNamePtr = env->GetStringUTFChars(attrName, NULL);
+    if (!attrNamePtr)
+    {
+        std::cout << "setRange: Failed to convert jstring to char string!";
+        return;
+    }
+
+    resource->setRange(attrNamePtr, static_cast<int>(min), static_cast<int>(max));
+    env->ReleaseStringUTFChars(attrName, attrNamePtr);
+}
+
+JNIEXPORT void JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_setInterfaceType
+(JNIEnv *env, jobject jobject, const std::string &interfaceType)
+{
+    jstring jInterfaceType = env->NewStringUTF(interfaceType.c_str());
+    if (!jInterfaceType)
+    {
+        std::cout << "setInterfaceType: InterfaceType is NULL";
+        return;
+    }
+
+    env->CallVoidMethod(jobject, gSimulatorClassRefs.classSimulatorResourceSetInterfaceType,
+                        jInterfaceType);
+    env->DeleteLocalRef(jInterfaceType);
+}
+
+JNIEXPORT void JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_addAttributeInteger
+(JNIEnv *env, jobject jobject, jstring jKey, jint jValue)
+{
+    if (!jKey)
+    {
+        std::cout << "addAttributeInteger: AttributeName is Empty";
+        return;
+    }
+
+    SimulatorResourceServerPtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env,
+                                          jobject);
+    if (nullptr == resource.get())
+    {
+        std::cout << "addAttributeInteger: Resource is NULL";
+        return;
+    }
+
+    std::string str = env->GetStringUTFChars(jKey, NULL);
+    resource->addAttribute(str, static_cast<int>(jValue));
+}
+
+JNIEXPORT void JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_addAttributeDouble
+(JNIEnv *env, jobject jobject, jstring jKey, jdouble jValue)
+{
+    if (!jKey)
+    {
+        std::cout << "addAttributeDouble: AttributeName is Empty";
+        return;
+    }
+
+    SimulatorResourceServerPtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env,
+                                          jobject);
+    if (nullptr == resource.get())
+    {
+        std::cout << "addAttributeDouble: Resource is NULL";
+        return;
+    }
+
+    std::string str = env->GetStringUTFChars(jKey, NULL);
+    resource->addAttribute(str, static_cast<double>(jValue));
+}
+
+JNIEXPORT void JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_addAttributeBoolean
+(JNIEnv *env, jobject jobject, jstring jKey, jboolean jValue)
+{
+    if (!jKey)
+    {
+        std::cout << "addAttributeBoolean: AttributeName is Empty";
+        return;
+    }
+
+    SimulatorResourceServerPtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env,
+                                          jobject);
+    if (nullptr == resource.get())
+    {
+        std::cout << "addAttributeBoolean: Resource is NULL";
+        return;
+    }
+
+    std::string str = env->GetStringUTFChars(jKey, NULL);
+    resource->addAttribute(str, static_cast<bool>(jValue));
+}
+
+JNIEXPORT void JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_addAttributeStringN
+(JNIEnv *env, jobject jobject, jstring jKey, jstring jValue)
+{
+    if (!jKey)
+    {
+        std::cout << "addAttributeStringN: AttributeName is Empty";
+        return;
+    }
+
+    SimulatorResourceServerPtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env,
+                                          jobject);
+    if (nullptr == resource.get())
+    {
+        std::cout << "addAttributeStringN: Resource is NULL";
+        return;
+    }
+
+    std::string key = env->GetStringUTFChars(jKey, NULL);
+    std::string value = env->GetStringUTFChars(jValue, NULL);
+
+    resource->addAttribute(key, value);
+}
+
+JNIEXPORT void JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_updateAttributeInteger
+(JNIEnv *env, jobject jobject, jstring jKey, jint jValue)
+{
+    if (!jKey)
+    {
+        std::cout << "updateAttributeInteger: AttributeName is Empty";
+        return;
+    }
+
+    SimulatorResourceServerPtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env,
+                                          jobject);
+    if (nullptr == resource.get())
+    {
+        std::cout << "updateAttributeInteger: Resource is NULL";
+        return;
+    }
+
+    std::string str = env->GetStringUTFChars(jKey, NULL);
+    resource->updateAttribute(str, static_cast<int>(jValue));
+}
+
+JNIEXPORT void JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_updateAttributeDouble
+(JNIEnv *env, jobject jobject, jstring jKey, jdouble jValue)
+{
+    if (!jKey)
+    {
+        std::cout << "updateAttributeDouble: AttributeName is Empty";
+        return;
+    }
+
+    SimulatorResourceServerPtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env,
+                                          jobject);
+    if (nullptr == resource.get())
+    {
+        std::cout << "updateAttributeDouble: Resource is NULL";
+        return;
+    }
+
+    std::string str = env->GetStringUTFChars(jKey, NULL);
+    resource->updateAttribute(str, static_cast<double>(jValue));
+}
+
+JNIEXPORT void JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_updateAttributeBoolean
+(JNIEnv *env, jobject jobject, jstring jKey, jboolean jValue)
+{
+    if (!jKey)
+    {
+        std::cout << "updateAttributeBoolean: AttributeName is Empty";
+        return;
+    }
+
+    SimulatorResourceServerPtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env,
+                                          jobject);
+    if (nullptr == resource.get())
+    {
+        std::cout << "updateAttributeBoolean: Resource is NULL";
+        return;
+    }
+
+    std::string str = env->GetStringUTFChars(jKey, NULL);
+    resource->updateAttribute(str, static_cast<bool>(jValue));
+}
+
+JNIEXPORT void JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_updateAttributeStringN
+(JNIEnv *env, jobject jobject, jstring jKey, jstring jValue)
+{
+    if (!jKey)
+    {
+        std::cout << "updateAttributeStringN: AttributeName is Empty";
+        return;
+    }
+
+    SimulatorResourceServerPtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env,
+                                          jobject);
+    if (nullptr == resource.get())
+    {
+        std::cout << "updateAttributeStringN: Resource is NULL";
+        return;
+    }
+
+    std::string key = env->GetStringUTFChars(jKey, NULL);
+    std::string value = env->GetStringUTFChars(jValue, NULL);
+
+    resource->updateAttribute(key, value);
+}
+
+JNIEXPORT void JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_setAllowedValuesInteger
+(JNIEnv *env, jobject object, jstring jKey, jobject jAllowedValues)
+{
+    if (!jKey)
+    {
+        std::cout << "setAllowedValuesInteger: AttributeName is Empty";
+        return;
+    }
+
+    SimulatorResourceServerPtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env, object);
+    if (nullptr == resource.get())
+    {
+        std::cout << "setAllowedValuesInteger: Resource is NULL";
+        return;
+    }
+
+    std::string str = env->GetStringUTFChars(jKey, NULL);
+    resource->setAllowedValues(str, convertIntegerVector(env, jAllowedValues));
+}
+
+JNIEXPORT void JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_setAllowedValuesDouble
+(JNIEnv *env, jobject object, jstring jKey, jobject jAllowedValues)
+{
+    if (!jKey)
+    {
+        std::cout << "setAllowedValuesDouble: AttributeName is Empty";
+        return;
+    }
+
+    SimulatorResourceServerPtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env, object);
+    if (nullptr == resource.get())
+    {
+        std::cout << "setAllowedValuesDouble: Resource is NULL";
+        return;
+    }
+
+    std::string str = env->GetStringUTFChars(jKey, NULL);
+    resource->setAllowedValues(str, convertDoubleVector(env, jAllowedValues));
+}
+
+JNIEXPORT void JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_setAllowedValuesStringN
+(JNIEnv *env, jobject object, jstring jKey, jobject jAllowedValues)
+{
+    if (!jKey)
+    {
+        std::cout << "setAllowedValuesStringN: AttributeName is Empty";
+        return;
+    }
+
+    SimulatorResourceServerPtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env, object);
+    if (nullptr == resource.get())
+    {
+        std::cout << "setAllowedValuesStringN: Resource is NULL";
+        return;
+    }
+
+    std::string str = env->GetStringUTFChars(jKey, NULL);
+    resource->setAllowedValues(str, convertStringVector(env, jAllowedValues));
+}
+
+JNIEXPORT jint JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_startResourceAutomation
+(JNIEnv *env, jobject object, jint automationType, jobject listener)
+{
+    SimulatorResourceServerPtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env, object);
+    if (nullptr == resource.get())
+    {
+        return -1;
+    }
+
+    if (!listener)
+    {
+        return -1;
+    }
+
+    jweak jlistenerRef = env->NewWeakGlobalRef(listener);
+    updateCompleteCallback callback =  [jlistenerRef](const std::string & uri, const int automationID)
+    {
+        onAutomationComplete(jlistenerRef, uri, automationID);
+    };
+
+    AutomationType type = AutomationType::NORMAL;
+    if (1 == automationType)
+    {
+        type = AutomationType::RECURRENT;
+    }
+
+    int automationId;
+    if (SIMULATOR_SUCCESS != resource->startUpdateAutomation(type, callback,
+            automationId))
+        return -1;
+
+    return automationId;
+}
+
+JNIEXPORT jint JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_startAttributeAutomation
+(JNIEnv *env, jobject object, jstring attrName, jint automationType, jobject listener)
+{
+    std::cout << "starAttributeAutomation JNI" << std::endl;
+    SimulatorResourceServerPtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env, object);
+    if (nullptr == resource.get())
+    {
+        return -1;
+    }
+
+    if (!attrName)
+    {
+        return -1;
+    }
+
+    if (!listener)
+    {
+        return -1;
+    }
+
+    jweak jlistenerRef = env->NewWeakGlobalRef(listener);
+    updateCompleteCallback callback =  [jlistenerRef](const std::string & uri, const int automationID)
+    {
+        onAutomationComplete(jlistenerRef, uri, automationID);
+    };
+
+    const char *attrNamePtr = env->GetStringUTFChars(attrName, NULL);
+
+    AutomationType type = AutomationType::NORMAL;
+    if (1 == automationType)
+    {
+        type = AutomationType::RECURRENT;
+    }
+
+    int automationId = -1;
+    resource->startUpdateAutomation(attrNamePtr, type, callback, automationId);
+
+    env->ReleaseStringUTFChars(attrName, attrNamePtr);
+    return automationId;
+}
+
+JNIEXPORT void JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_stopAutomation
+(JNIEnv *env, jobject object, jint automationId)
+{
+    SimulatorResourceServerPtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env, object);
+    if (nullptr == resource.get())
+    {
+        return;
+    }
+
+    resource->stopUpdateAutomation(automationId);
+}
+
+JNIEXPORT void JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_removeAttribute
+(JNIEnv *env, jobject jobject, jstring jKey)
+{
+    if (!jKey)
+    {
+        std::cout << "removeAttribute: AttributeName is Empty";
+        return;
+    }
+
+    SimulatorResourceServerPtr resource = JniSimulatorResource::getJniSimulatorResourcePtr(env,
+                                          jobject);
+    if (nullptr == resource.get())
+    {
+        std::cout << "removeAttribute: Resource is NULL";
+        return;
+    }
+
+    std::string str = env->GetStringUTFChars(jKey, NULL);
+    resource->removeAttribute(str);
+}
+
+JNIEXPORT void JNICALL Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_dispose
+(JNIEnv *env, jobject thiz)
+{
+    JniSimulatorResource *resource = GetHandle<JniSimulatorResource>(env, thiz);
+    delete resource;
+}
+
diff --git a/service/simulator/java/jni/simulator_resource_server_jni.h b/service/simulator/java/jni/simulator_resource_server_jni.h
new file mode 100644 (file)
index 0000000..f41479d
--- /dev/null
@@ -0,0 +1,121 @@
+/******************************************************************
+ *
+ * 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 SIMULATOR_RESOURCE_JNI_H_
+#define SIMULATOR_RESOURCE_JNI_H_
+
+#include <jni.h>
+#include "simulator_resource_server.h"
+
+class JniSimulatorResource
+{
+    public:
+        JniSimulatorResource(SimulatorResourceServerPtr &resource);
+
+        static jobject toJava(JNIEnv *env, jlong resource);
+        void setResourceInfo(JNIEnv *env, jobject jobj);
+        static SimulatorResourceServerPtr getJniSimulatorResourcePtr(JNIEnv *env, jobject thiz);
+    private:
+        SimulatorResourceServerPtr m_sharedResource;
+};
+
+
+#ifdef __cplusplus
+extern "C" {
+
+JNIEXPORT jobject JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_getModel
+(JNIEnv *, jobject);
+
+JNIEXPORT void JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_updateAttributeFromAllowedValues
+(JNIEnv *, jobject, jstring, jint);
+
+JNIEXPORT void JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_setRange
+(JNIEnv *, jobject, jstring, jint, jint);
+
+JNIEXPORT void JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_addAttributeInteger
+(JNIEnv *, jobject, jstring, jint);
+
+JNIEXPORT void JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_addAttributeDouble
+(JNIEnv *, jobject, jstring, jdouble);
+
+JNIEXPORT void JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_addAttributeBoolean
+(JNIEnv *, jobject, jstring, jboolean);
+
+JNIEXPORT void JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_addAttributeStringN
+(JNIEnv *, jobject, jstring, jstring);
+
+JNIEXPORT void JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_updateAttributeInteger
+(JNIEnv *, jobject, jstring, jint);
+
+JNIEXPORT void JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_updateAttributeDouble
+(JNIEnv *, jobject, jstring, jdouble);
+
+JNIEXPORT void JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_updateAttributeBoolean
+(JNIEnv *, jobject, jstring, jboolean);
+
+JNIEXPORT void JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_updateAttributeStringN
+(JNIEnv *, jobject, jstring, jstring);
+
+JNIEXPORT void JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_setAllowedValuesInteger
+(JNIEnv *, jobject, jstring, jobject);
+
+JNIEXPORT void JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_setAllowedValuesDouble
+(JNIEnv *, jobject, jstring, jobject);
+
+JNIEXPORT void JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_setAllowedValuesStringN
+(JNIEnv *, jobject, jstring, jobject);
+
+JNIEXPORT jint JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_startResourceAutomation
+(JNIEnv *, jobject, jint, jobject);
+
+JNIEXPORT jint JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_startAttributeAutomation
+(JNIEnv *, jobject, jstring, jint, jobject);
+
+JNIEXPORT void JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_stopAutomation
+(JNIEnv *, jobject, jint);
+
+JNIEXPORT void JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_removeAttribute
+(JNIEnv *, jobject, jstring);
+
+JNIEXPORT void JNICALL
+Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_dispose
+(JNIEnv *, jobject);
+
+}
+#endif
+#endif //SIMULATOR_RESOURCE_JNI_H_