From 2d396d6ea3aa15c0a98cbded7c11d5eee7776346 Mon Sep 17 00:00:00 2001 From: coderhyme Date: Thu, 24 Sep 2015 21:16:26 -0700 Subject: [PATCH] In resource-encapsulation android api, ResourceContainer related files are removed. It is not part of service api any more. And manifest is modified to eliminate lint issues. Change-Id: I80adb6784bd3a1667aa1b71f6f6b978c1148988c Signed-off-by: coderhyme Reviewed-on: https://gerrit.iotivity.org/gerrit/3073 Tested-by: jenkins-iotivity Reviewed-by: Madan Lanka --- .../android/service/src/main/AndroidManifest.xml | 10 +- .../org/iotivity/service/server/RcsBundleInfo.java | 96 ------- .../service/server/RcsResourceContainer.java | 214 ---------------- .../android/service/src/main/jni/Android.mk | 6 - .../android/service/src/main/jni/JniMain.cpp | 3 - .../service/src/main/jni/JniRcsBundleInfo.cpp | 100 -------- .../service/src/main/jni/JniRcsBundleInfo.h | 60 ----- .../src/main/jni/JniRcsResourceContainer.cpp | 281 --------------------- .../service/src/main/jni/JniRcsResourceContainer.h | 85 ------- 9 files changed, 1 insertion(+), 854 deletions(-) delete mode 100644 service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsBundleInfo.java delete mode 100644 service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsResourceContainer.java delete mode 100644 service/resource-encapsulation/android/service/src/main/jni/JniRcsBundleInfo.cpp delete mode 100644 service/resource-encapsulation/android/service/src/main/jni/JniRcsBundleInfo.h delete mode 100644 service/resource-encapsulation/android/service/src/main/jni/JniRcsResourceContainer.cpp delete mode 100644 service/resource-encapsulation/android/service/src/main/jni/JniRcsResourceContainer.h diff --git a/service/resource-encapsulation/android/service/src/main/AndroidManifest.xml b/service/resource-encapsulation/android/service/src/main/AndroidManifest.xml index 0496cd0..dad19f2 100644 --- a/service/resource-encapsulation/android/service/src/main/AndroidManifest.xml +++ b/service/resource-encapsulation/android/service/src/main/AndroidManifest.xml @@ -1,10 +1,2 @@ - - - - + package="org.iotivity.service" /> \ No newline at end of file diff --git a/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsBundleInfo.java b/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsBundleInfo.java deleted file mode 100644 index 0707456..0000000 --- a/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsBundleInfo.java +++ /dev/null @@ -1,96 +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 RCSBundleInfo class, which provides APIs related to Bundle information. - */ -package org.iotivity.service.server; - -import org.iotivity.service.RcsObject; - -/** - * This class provides APIs for getting and setting the Bundle Information - */ -public class RcsBundleInfo extends RcsObject { - private native String nativeGetID(); - - private native String nativeGetPath(); - - private native String nativeGetActivatorName(); - - private native String nativeGetLibraryPath(); - - private native String nativeGetVersion(); - - private RcsBundleInfo() { - } - - /** - * API for getting the Id of the bundle - * - * @return string - Id of the bundle - * - */ - public String getID() { - return nativeGetID(); - } - - /** - * API for getting the path of the bundle - * - * @return path - path of the bundle - * - */ - public String getPath() { - return nativeGetPath(); - } - - /** - * API for setting the Activator name for the bundle - * - * @return string - Name of the activator - * - */ - public String getActivatorName() { - return nativeGetActivatorName(); - } - - /** - * API for getting the library path for the bundle - * - * @return string - Library path in string form - * - */ - public String getLibraryPath() { - return nativeGetLibraryPath(); - } - - /** - * API for getting the version of the bundle - * - * @return string - version of the bundle - * - */ - public String getVersion() { - return nativeGetVersion(); - } - -} diff --git a/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsResourceContainer.java b/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsResourceContainer.java deleted file mode 100644 index 082d425..0000000 --- a/service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsResourceContainer.java +++ /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. - * - ******************************************************************/ - -/** - * @file - * This file contains the Resource Container APIs - */ -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 { - - 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 static RcsResourceContainer sInstance = new RcsResourceContainer(); - - private native void nativeStartContainer(String configFile); - - private native void nativeStopContainer(); - - private native void nativeAddBundle(String bundleId, String bundleUri, - String bundlePath, String activator, Map params); - - private native void nativeRemoveBundle(String bundleId); - - private native List nativeListBundles(); - - private native void nativeStartBundle(String bundleId); - - private native void nativeStopBundle(String bundleId); - - private native void nativeAddResourceConfig(String bundleId, - String resourceUri, Map params); - - private native void nativeRemoveResourceConfig(String bundleId, - String resourceUri); - - private native List nativeListBundleResources(String bundleId); - - /** - * API for getting the Instance of ResourceContainer class - * - */ - public static RcsResourceContainer getInstance() { - return sInstance; - } - - /** - * API for starting the Container - * - *

- * This API start the container with the provided Configuration file. - * - * @param configFile - * configuration File that contains the Bundle/Bundles - * information. - * - */ - public void startContainer(String configFile) { - nativeStartContainer(configFile); - } - - /** - * API for stopping the Container - */ - public void stopContainer() { - nativeStopContainer(); - } - - /** - * API for getting the list of all bundles in the container - * - * @return list -List of BundleInfo objects each associated - * with a bundle - * - * {@link RcsBundleInfo} - */ - public List listBundles() { - return nativeListBundles(); - } - - /** - * 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 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 - * - *

- * It is dynamic configuration - */ - public void addBundle(String bundleId, String bundleUri, String bundlePath, - String activator, Map params) { - nativeAddBundle(bundleId, bundleUri, bundlePath, activator, params); - } - - /** - * API for removing the bundle from the container - * - * @param bundleId - * Id of the Bundle - * - */ - public void removeBundle(String bundleId) { - nativeRemoveBundle(bundleId); - } - - /** - * API for starting the bundle. - * - * @param bundleId - * Id of the Bundle - * - */ - public void startBundle(String bundleId) { - nativeStartBundle(bundleId); - } - - /** - * API for Stopping the bundle - * - * @param bundleId - * Id of the Bundle - * - */ - public void stopBundle(String bundleId) { - nativeStopBundle(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 - * - */ - public void addResourceConfig(String bundleId, String resourceUri, - Map params) { - nativeAddResourceConfig(bundleId, resourceUri, params); - } - - /** - * API for removing the Resource configuration information from the bundle - * - * @param bundleId - * Id of the Bundle - * @param resourceUri - * URI of the resource - * - */ - public void removeResourceConfig(String bundleId, String resourceUri) { - nativeRemoveResourceConfig(bundleId, resourceUri); - } - - /** - * API for getting the list of Bundle Resources - * - * @param bundleId - * Id of the Bundle - * - * @return List All the bundle resources - */ - public List listBundleResources(String bundleId) { - return nativeListBundleResources(bundleId); - } -} diff --git a/service/resource-encapsulation/android/service/src/main/jni/Android.mk b/service/resource-encapsulation/android/service/src/main/jni/Android.mk index 65c7204..01d8daf 100644 --- a/service/resource-encapsulation/android/service/src/main/jni/Android.mk +++ b/service/resource-encapsulation/android/service/src/main/jni/Android.mk @@ -19,11 +19,6 @@ 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 @@ -44,6 +39,5 @@ 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 index dcc4184..55ec492 100644 --- a/service/resource-encapsulation/android/service/src/main/jni/JniMain.cpp +++ b/service/resource-encapsulation/android/service/src/main/jni/JniMain.cpp @@ -23,7 +23,6 @@ #include "JniRcsRemoteResourceObject.h" #include "JniRcsResourceAttributes.h" #include "JniRcsResourceObject.h" -#include "JniRcsResourceContainer.h" #include "JniRcsValue.h" #include "JavaClasses.h" #include "JavaExceptions.h" @@ -60,7 +59,6 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) initRCSRemoteResourceObject(&envWrapper); initRCSObject(&envWrapper); initRCSResourceObject(&envWrapper); - initRCSResourceContainer(&envWrapper); } catch (const JavaException&) { @@ -86,7 +84,6 @@ JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved) try { - clearRCSResourceContainer(&envWrapper); clearRCSResourceObject(&envWrapper); clearRCSObject(&envWrapper); clearRCSRemoteResourceObject(&envWrapper); diff --git a/service/resource-encapsulation/android/service/src/main/jni/JniRcsBundleInfo.cpp b/service/resource-encapsulation/android/service/src/main/jni/JniRcsBundleInfo.cpp deleted file mode 100644 index ace4db6..0000000 --- a/service/resource-encapsulation/android/service/src/main/jni/JniRcsBundleInfo.cpp +++ /dev/null @@ -1,100 +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 "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 deleted file mode 100644 index 4f8d71e..0000000 --- a/service/resource-encapsulation/android/service/src/main/jni/JniRcsBundleInfo.h +++ /dev/null @@ -1,60 +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_RCS_BUNDLE_INFO_H_ -#define JNI_RCS_BUNDLE_INFO_H_ - -#include - -#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/JniRcsResourceContainer.cpp b/service/resource-encapsulation/android/service/src/main/jni/JniRcsResourceContainer.cpp deleted file mode 100644 index 5f2b5cc..0000000 --- a/service/resource-encapsulation/android/service/src/main/jni/JniRcsResourceContainer.cpp +++ /dev/null @@ -1,281 +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 "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 deleted file mode 100644 index 82ce507..0000000 --- a/service/resource-encapsulation/android/service/src/main/jni/JniRcsResourceContainer.h +++ /dev/null @@ -1,85 +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_RCS_RESOURCE_CONTAINER_H_ -#define JNI_RCS_RESOURCE_CONTAINER_H_ - -#include - -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_ -- 2.7.4