1 //******************************************************************
3 // Copyright 2014 Intel Mobile Communications GmbH 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 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
24 * This represents a running open connection server.
26 * WARNING: This may change to an interface so that we may transition to a factory pattern
29 public class OCServer {
30 private native void jniRegisterResource(OCObject object, String url);
32 private native void jniUnregisterResource(OCObject object);
34 private native void jniStartOCServer();
36 private native void jniStopOCServer();
38 private native OCDiscovery jniGetDiscoverySingleton();
41 * Constructor for OCService.
46 * This registers a security model for access control to resources under this service.
48 * @param model - Security Model required for access to this service and control/view of it's
51 public void setSecurityModel(OCSecurityModel model) {
52 // Todo: Pat, What will we do here?
56 * Registers a resource with the service.
58 * @param object - The OCObject that handles the resource requests
59 * @param url - The URL under the resource.
60 * @param accessControl - The access control handler that determines whether the remote device is
61 * allowed to access this resource. If NULL, all access is granted.
63 public void registerResource(OCObject object, String url/* TODO: , AccessControl accessControl */) {
64 jniRegisterResource(object, url);
68 * Unregisters a resource with the service.
70 * @param object - The OCObject to be unregistered.
72 public void unregisterResource(OCObject object) {
73 jniUnregisterResource(object);
77 * Starts the open connectivity service.
79 * Thread-Safety: TODO Determine if it is going to be safe to call in a UI thread
86 * Stops the open connectivity service.
88 * Thread-Safety: TODO Determine if it is going to be safe to call in a UI thread
95 * Retrieves access to discovery APIs via the Discovery Singleton delegated by the SDK. Delegation
96 * is limited to just one singleton per OCServer object.
98 * @return Returns an object which permits access to the open connectivity discovery APIs to just
99 * one discovery singleton object.
101 * @throws //TODO throws an exception when the discovery singleton has already been checked out.
103 public OCDiscovery getDiscoverySingleton() {
104 return jniGetDiscoverySingleton();