1 //******************************************************************
3 // Copyright 2016 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20 package org.iotivity.service.ns.provider;
21 import org.iotivity.service.ns.common.*;
22 import java.util.Vector;
24 * @class ProviderService
25 * @brief This class provides a set of Java APIs for Notification ProviderService.
27 public class ProviderService
32 System.loadLibrary("gnustl_shared");
33 System.loadLibrary("oc_logger");
34 System.loadLibrary("connectivity_abstraction");
35 System.loadLibrary("ca-interface");
36 System.loadLibrary("octbstack");
37 System.loadLibrary("oc");
38 System.loadLibrary("ocstack-jni");
39 System.loadLibrary("notification_provider");
40 System.loadLibrary("notification_provider_wrapper");
41 System.loadLibrary("notification_provider_jni");
44 private static ProviderService instance;
48 instance = new ProviderService();
51 public static ProviderService getInstance()
56 public int start(OnConsumerSubscribedListener subscribedListener,
57 OnMessageSynchronizedListener messageSynchronized,
58 boolean subControllability, String userInfo) throws NSException
60 return nativeStart(subscribedListener, messageSynchronized,subControllability,userInfo);
63 public int stop() throws NSException
68 public int sendMessage(Message message) throws NSException
70 return nativeSendMessage(message);
73 public void sendSyncInfo ( long messageId , SyncInfo.SyncType syncType) throws NSException
75 nativeSendSyncInfo(messageId, syncType.ordinal());
78 public Message createMessage () throws NSException
80 return nativeCreateMessage();
83 public int enableRemoteService(String servAdd) throws NSException
85 return nativeEnableRemoteService(servAdd);
88 public int disableRemoteService(String servAdd) throws NSException
90 return nativeDisableRemoteService(servAdd);
93 public int registerTopic(String topicName) throws NSException
95 return nativeRegisterTopic(topicName);
98 public int unregisterTopic(String topicName) throws NSException
100 return nativeUnregisterTopic(topicName);
103 public TopicsList getRegisteredTopicList() throws NSException
105 return nativeGetRegisteredTopicList();
108 public interface OnConsumerSubscribedListener
110 public void onConsumerSubscribed(Consumer consumer);
113 public interface OnMessageSynchronizedListener
115 public void onMessageSynchronized(SyncInfo syncInfo);
118 public native int nativeStart(OnConsumerSubscribedListener subscribedListener,
119 OnMessageSynchronizedListener messageSynchronized,
120 boolean subControllability, String userInfo) throws NSException;
121 public native int nativeStop() throws NSException;
122 public native int nativeSendMessage(Message message) throws NSException;
123 public native void nativeSendSyncInfo( long messageId , int type) throws NSException;
124 public native Message nativeCreateMessage() throws NSException;
125 public native int nativeEnableRemoteService(String servAdd) throws NSException;
126 public native int nativeDisableRemoteService(String servAdd) throws NSException;
127 public native int nativeRegisterTopic(String topicName) throws NSException;
128 public native int nativeUnregisterTopic(String topicName) throws NSException;
129 public native TopicsList nativeGetRegisteredTopicList() throws NSException;