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();
50 public interface OnSubscriptionListener
52 public void onConsumerSubscribed(Consumer consumer);
54 public interface OnSyncInfoListener
56 public void onMessageSynchronized(SyncInfo syncInfo);
59 public static ProviderService getInstance()
63 public int Start(boolean policy,
64 OnSubscriptionListener subscriptionListener,
65 OnSyncInfoListener syncInfoListener) throws NSException
68 return nativeStart(policy, subscriptionListener, syncInfoListener);
71 public int Stop() throws NSException
76 public int SendMessage(Message message) throws NSException
78 return nativeSendMessage(message);
81 public void SendSyncInfo ( long messageId , SyncInfo.SyncType syncType) throws NSException
83 nativeSendSyncInfo(messageId, syncType.ordinal());
87 public Message CreateMessage () throws NSException
89 return nativeCreateMessage();
92 public int EnableRemoteService(String servAdd) throws NSException
94 return nativeEnableRemoteService(servAdd);
97 public int DisableRemoteService(String servAdd) throws NSException
99 return nativeDisableRemoteService(servAdd);
102 public int AddTopic(String topicName) throws NSException
104 return nativeAddTopic(topicName);
106 public int DeleteTopic(String topicName) throws NSException
108 return nativeDeleteTopic(topicName);
110 public TopicsList GetTopics() throws NSException
112 return nativeGetTopics();
115 public native int nativeStart(boolean policy,
116 OnSubscriptionListener subscriptionListener,
117 OnSyncInfoListener syncInfoListener);
118 public native int nativeStop();
119 public native int nativeSendMessage(Message message);
120 public native void nativeSendSyncInfo( long messageId , int type);
121 public native Message nativeCreateMessage();
122 public native int nativeEnableRemoteService(String servAdd);
123 public native int nativeDisableRemoteService(String servAdd);
124 public native int nativeAddTopic(String topicName);
125 public native int nativeDeleteTopic(String topicName);
126 public native TopicsList nativeGetTopics();