1 /******************************************************************
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 ******************************************************************/
23 * This file contains the Resource Container APIs
25 package org.iotivity.service.resourcecontainer;
27 import java.util.List;
30 // TODO null check for parameters
32 * This class provides APIs for managing the container and bundles in the
35 public class RcsResourceContainer {
38 System.loadLibrary("gnustl_shared");
39 System.loadLibrary("oc_logger");
40 System.loadLibrary("connectivity_abstraction");
41 System.loadLibrary("ca-interface");
42 System.loadLibrary("octbstack");
43 System.loadLibrary("oc");
44 System.loadLibrary("rcs_client");
45 System.loadLibrary("rcs_server");
46 System.loadLibrary("rcs_common");
47 System.loadLibrary("rcs_container");
48 System.loadLibrary("resource_container_jni");
51 private static RcsResourceContainer sInstance = new RcsResourceContainer();
53 private native void nativeStartContainer(String configFile);
55 private native void nativeStopContainer();
57 private native void nativeAddBundle(String bundleId, String bundleUri,
58 String bundlePath, String activator, Map<String, String> params);
60 private native void nativeRemoveBundle(String bundleId);
62 private native List<RcsBundleInfo> nativeListBundles();
64 private native void nativeStartBundle(String bundleId);
66 private native void nativeStopBundle(String bundleId);
68 private native void nativeAddResourceConfig(String bundleId,
69 String resourceUri, Map<String, String> params);
71 private native void nativeRemoveResourceConfig(String bundleId,
74 private native List<String> nativeListBundleResources(String bundleId);
77 * API for getting the Instance of ResourceContainer class
80 public static RcsResourceContainer getInstance() {
85 * API for starting the Container
88 * This API start the container with the provided Configuration file.
91 * configuration File that contains the Bundle/Bundles
95 public void startContainer(String configFile) {
96 nativeStartContainer(configFile);
100 * API for stopping the Container
102 public void stopContainer() {
103 nativeStopContainer();
107 * API for getting the list of all bundles in the container
109 * @return list<RCSBundleInfo> -List of BundleInfo objects each associated
112 * {@link RcsBundleInfo}
114 public List<RcsBundleInfo> listBundles() {
115 return nativeListBundles();
119 * API for adding the bundle to the Container
128 * Activation prefix for .so bundles, or activator class name for
131 * key-value pairs in string form for other Bundle parameters
134 * It is dynamic configuration
136 public void addBundle(String bundleId, String bundleUri, String bundlePath,
137 String activator, Map<String, String> params) {
138 nativeAddBundle(bundleId, bundleUri, bundlePath, activator, params);
142 * API for removing the bundle from the container
148 public void removeBundle(String bundleId) {
149 nativeRemoveBundle(bundleId);
153 * API for starting the bundle.
159 public void startBundle(String bundleId) {
160 nativeStartBundle(bundleId);
164 * API for Stopping the bundle
170 public void stopBundle(String bundleId) {
171 nativeStopBundle(bundleId);
175 * API for adding the Resource configuration information to the bundle
180 * URI of the resource
182 * key-value pairs in string form for other Bundle parameters
185 public void addResourceConfig(String bundleId, String resourceUri,
186 Map<String, String> params) {
187 nativeAddResourceConfig(bundleId, resourceUri, params);
191 * API for removing the Resource configuration information from the bundle
196 * URI of the resource
199 public void removeResourceConfig(String bundleId, String resourceUri) {
200 nativeRemoveResourceConfig(bundleId, resourceUri);
204 * API for getting the list of Bundle Resources
209 * @return List<String> All the bundle resources
211 public List<String> listBundleResources(String bundleId) {
212 return nativeListBundleResources(bundleId);