1 //******************************************************************
3 // Copyright 2014 Intel Corporation All Rights Reserved.
4 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
9 * This represents a running open connection server.
11 * WARNING: This may change to an interface so that we may transition to a factory pattern
14 public class OCServer {
15 private native void jniRegisterResource(OCObject object, String url);
17 private native void jniUnregisterResource(OCObject object);
19 private native void jniStartOCServer();
21 private native void jniStopOCServer();
23 private native OCDiscovery jniGetDiscoverySingleton();
26 * Constructor for OCService.
31 * This registers a security model for access control to resources under this service.
33 * @param model - Security Model required for access to this service and control/view of it's
36 public void setSecurityModel(OCSecurityModel model) {
37 // Todo: Pat, What will we do here?
41 * Registers a resource with the service.
43 * @param object - The OCObject that handles the resource requests
44 * @param url - The URL under the resource.
45 * @param accessControl - The access control handler that determines whether the remote device is
46 * allowed to access this resource. If NULL, all access is granted.
48 public void registerResource(OCObject object, String url/* TODO: , AccessControl accessControl */) {
49 jniRegisterResource(object, url);
53 * Unregisters a resource with the service.
55 * @param object - The OCObject to be unregistered.
57 public void unregisterResource(OCObject object) {
58 jniUnregisterResource(object);
62 * Starts the open connectivity service.
64 * Thread-Safety: TODO Determine if it is going to be safe to call in a UI thread
71 * Stops the open connectivity service.
73 * Thread-Safety: TODO Determine if it is going to be safe to call in a UI thread
80 * Retrieves access to discovery APIs via the Discovery Singleton delegated by the SDK. Delegation
81 * is limited to just one singleton per OCServer object.
83 * @return Returns an object which permits access to the open connectivity discovery APIs to just
84 * one discovery singleton object.
86 * @throws //TODO throws an exception when the discovery singleton has already been checked out.
88 public OCDiscovery getDiscoverySingleton() {
89 return jniGetDiscoverySingleton();