Java API Project for Simulator.
authorG S Senthil Kumar <senthil.gs@samsung.com>
Fri, 7 Aug 2015 15:50:52 +0000 (21:20 +0530)
committerMadan Lanka <lanka.madan@samsung.com>
Tue, 11 Aug 2015 10:54:18 +0000 (10:54 +0000)
It includes the following changes:
    1. Updating existing service provider implementation that includes removal
       of unused SimulatorManagerCallback class, and inclusion of Javadoc
       comments.
    2. Implementation of client controller Java APIs.
    3. Changing the project's package structure to include both service
       provider and client controller related java files in the same project.
       Service provider and client controller files are segregated in
       different packages and there is a common package containing all common
       files.
    4. Updating the interface for log.

Change-Id: Ib8bf99d8f0de1e0c28e95a43c64447fe112f0eeb
Signed-off-by: G S Senthil Kumar <senthil.gs@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2138
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
27 files changed:
service/simulator/java/sdk/.classpath [new file with mode: 0644]
service/simulator/java/sdk/.project [new file with mode: 0644]
service/simulator/java/sdk/ServiceProvider/.classpath [deleted file]
service/simulator/java/sdk/ServiceProvider/.project [deleted file]
service/simulator/java/sdk/ServiceProvider/src/org/iotivity/simulator/OCSimulatorResult.java [deleted file]
service/simulator/java/sdk/ServiceProvider/src/org/iotivity/simulator/SimulatorManager.java [deleted file]
service/simulator/java/sdk/ServiceProvider/src/org/iotivity/simulator/SimulatorManagerCallback.java [deleted file]
service/simulator/java/sdk/ServiceProvider/src/org/iotivity/simulator/SimulatorManagerNativeInterface.java [deleted file]
service/simulator/java/sdk/ServiceProvider/src/org/iotivity/simulator/SimulatorResourceAttribute.java [deleted file]
service/simulator/java/sdk/ServiceProvider/src/org/iotivity/simulator/SimulatorResourceServer.java [deleted file]
service/simulator/java/sdk/src/org/oic/simulator/AutomationType.java [moved from service/simulator/java/sdk/ServiceProvider/src/org/iotivity/simulator/ILogMessageListener.java with 70% similarity]
service/simulator/java/sdk/src/org/oic/simulator/IAutomation.java [new file with mode: 0644]
service/simulator/java/sdk/src/org/oic/simulator/ILogger.java [new file with mode: 0644]
service/simulator/java/sdk/src/org/oic/simulator/OCSimulatorResult.java [new file with mode: 0644]
service/simulator/java/sdk/src/org/oic/simulator/SimulatorManager.java [new file with mode: 0644]
service/simulator/java/sdk/src/org/oic/simulator/SimulatorManagerNativeInterface.java [new file with mode: 0644]
service/simulator/java/sdk/src/org/oic/simulator/SimulatorResourceAttribute.java [new file with mode: 0644]
service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/IFindResourceListener.java [new file with mode: 0644]
service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/IGetListener.java [moved from service/simulator/java/sdk/ServiceProvider/src/org/iotivity/simulator/SimulatorResourceModel.java with 52% similarity]
service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/IObserveListener.java [new file with mode: 0644]
service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/IPostListener.java [new file with mode: 0644]
service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/IPutListener.java [new file with mode: 0644]
service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/SimulatorObserveType.java [moved from service/simulator/java/sdk/ServiceProvider/src/org/iotivity/simulator/IResourceModelChangedListener.java with 63% similarity]
service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/SimulatorRemoteResource.java [new file with mode: 0644]
service/simulator/java/sdk/src/org/oic/simulator/serviceprovider/IResourceModelChangedListener.java [new file with mode: 0644]
service/simulator/java/sdk/src/org/oic/simulator/serviceprovider/SimulatorResourceModel.java [new file with mode: 0644]
service/simulator/java/sdk/src/org/oic/simulator/serviceprovider/SimulatorResourceServer.java [new file with mode: 0644]

diff --git a/service/simulator/java/sdk/.classpath b/service/simulator/java/sdk/.classpath
new file mode 100644 (file)
index 0000000..11f3b6f
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+    <classpathentry kind="src" path="src" />
+    <classpathentry kind="con"
+        path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7" />
+    <classpathentry kind="output" path="bin" />
+</classpath>
diff --git a/service/simulator/java/sdk/.project b/service/simulator/java/sdk/.project
new file mode 100644 (file)
index 0000000..e32400a
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+    <name>Simulator</name>
+    <comment></comment>
+    <projects>
+    </projects>
+    <buildSpec>
+        <buildCommand>
+            <name>org.eclipse.jdt.core.javabuilder</name>
+            <arguments>
+            </arguments>
+        </buildCommand>
+    </buildSpec>
+    <natures>
+        <nature>org.eclipse.jdt.core.javanature</nature>
+    </natures>
+</projectDescription>
diff --git a/service/simulator/java/sdk/ServiceProvider/.classpath b/service/simulator/java/sdk/ServiceProvider/.classpath
deleted file mode 100644 (file)
index fb565a5..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-       <classpathentry kind="src" path="src"/>
-       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
-       <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/service/simulator/java/sdk/ServiceProvider/.project b/service/simulator/java/sdk/ServiceProvider/.project
deleted file mode 100644 (file)
index cfa4c11..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-       <name>ServiceProvider</name>
-       <comment></comment>
-       <projects>
-       </projects>
-       <buildSpec>
-               <buildCommand>
-                       <name>org.eclipse.jdt.core.javabuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-       </buildSpec>
-       <natures>
-               <nature>org.eclipse.jdt.core.javanature</nature>
-       </natures>
-</projectDescription>
diff --git a/service/simulator/java/sdk/ServiceProvider/src/org/iotivity/simulator/OCSimulatorResult.java b/service/simulator/java/sdk/ServiceProvider/src/org/iotivity/simulator/OCSimulatorResult.java
deleted file mode 100644 (file)
index 3bca79e..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.iotivity.simulator;
-
-/**
- * This Enum contains Status codes for Success and Errors
- */
-public enum OCSimulatorResult {
-    OC_STACK_OK,
-    OC_STACK_RESOURCE_CREATED,
-    OC_STACK_RESOURCE_DELETED,
-    OC_STACK_CONTINUE,
-    OC_STACK_INVALID_URI,
-    OC_STACK_INVALID_QUERY,
-    OC_STACK_INVALID_IP,
-    OC_STACK_INVALID_PORT,
-    OC_STACK_INVALID_CALLBACK,
-    OC_STACK_INVALID_METHOD,
-    OC_STACK_INVALID_PARAM,
-    OC_STACK_INVALID_OBSERVE_PARAM,
-    OC_STACK_NO_MEMORY,
-    OC_STACK_COMM_ERROR,
-    OC_STACK_NOTIMPL,
-    OC_STACK_NO_RESOURCE,
-    OC_STACK_RESOURCE_ERROR,
-    OC_STACK_SLOW_RESOURCE,
-    OC_STACK_REPEATED_REQUEST,
-    OC_STACK_NO_OBSERVERS,
-    OC_STACK_OBSERVER_NOT_FOUND,
-    OC_STACK_VIRTUAL_DO_NOT_HANDLE,
-    OC_STACK_INVALID_OPTION,
-    OC_STACK_MALFORMED_RESPONSE,
-    OC_STACK_PERSISTENT_BUFFER_REQUIRED,
-    OC_STACK_INVALID_REQUEST_HANDLE,
-    OC_STACK_INVALID_DEVICE_INFO,
-    OC_STACK_INVALID_JSON,
-    OC_STACK_PRESENCE_STOPPED,
-    OC_STACK_PRESENCE_TIMEOUT,
-    OC_STACK_PRESENCE_DO_NOT_HANDLE,
-    OC_STACK_ERROR,
-    OC_STACK_LISTENER_NOT_SET;
-}
\ No newline at end of file
diff --git a/service/simulator/java/sdk/ServiceProvider/src/org/iotivity/simulator/SimulatorManager.java b/service/simulator/java/sdk/ServiceProvider/src/org/iotivity/simulator/SimulatorManager.java
deleted file mode 100644 (file)
index 6f0201a..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.iotivity.simulator;
-
-import java.util.Vector;
-
-public class SimulatorManager {
-
-    static {
-        // TODO: Load all native libraries here
-    }
-
-    public static void setLogMessageHandler(ILogMessageListener listener) {
-        SimulatorManagerCallback.getInstance().registerLogMessageListener(
-                listener);
-    }
-
-    public static void setResourceModelChangeHandler(
-            IResourceModelChangedListener listener) {
-        SimulatorManagerCallback.getInstance()
-                .registerResourceModelChangeListener(listener);
-    }
-
-    public static void initialize() {
-        SimulatorManagerNativeInterface.initialize();
-    }
-
-    public static void terminate() {
-        SimulatorManagerNativeInterface.terminate();
-
-        // Unregister the listeners
-        SimulatorManagerCallback.getInstance().unregisterLogMessageListener();
-        SimulatorManagerCallback.getInstance()
-                .unregisterResourceModelChangeListener();
-    }
-
-    public static SimulatorResourceServer createResource(String configPath) {
-        SimulatorResourceServer simulatorResourceServerObj;
-        simulatorResourceServerObj = SimulatorManagerNativeInterface
-                .createResource(configPath);
-        return simulatorResourceServerObj;
-    }
-
-    public static Vector<SimulatorResourceServer> createResource(
-            String configPath, int count) {
-        Vector<SimulatorResourceServer> simulatorResourceServerVector;
-        simulatorResourceServerVector = SimulatorManagerNativeInterface
-                .createResources(configPath, count);
-        return simulatorResourceServerVector;
-    }
-
-    public static Vector<SimulatorResourceServer> getLocalResources() {
-        Vector<SimulatorResourceServer> simulatorResourceServerVector = null;
-        simulatorResourceServerVector = SimulatorManagerNativeInterface
-                .getResources();
-        return simulatorResourceServerVector;
-    }
-
-    public static void deleteResource(SimulatorResourceServer resource) {
-        SimulatorManagerNativeInterface.deleteResource(resource);
-    }
-
-    public static void deleteAllResources(String resourceType) {
-        SimulatorManagerNativeInterface.deleteAllResources(resourceType);
-    }
-
-    public static void deleteAllResources() {
-        SimulatorManagerNativeInterface.deleteAllResources();
-    }
-}
\ No newline at end of file
diff --git a/service/simulator/java/sdk/ServiceProvider/src/org/iotivity/simulator/SimulatorManagerCallback.java b/service/simulator/java/sdk/ServiceProvider/src/org/iotivity/simulator/SimulatorManagerCallback.java
deleted file mode 100644 (file)
index 8fcb410..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.iotivity.simulator;
-
-import java.util.Vector;
-
-class SimulatorManagerCallback {
-
-    private IResourceModelChangedListener   resourceModelChangeListener;
-    private ILogMessageListener             logMessageListener;
-    private static SimulatorManagerCallback simulatorManagerCallbackObj;
-
-    private SimulatorManagerCallback() {
-    }
-
-    public static synchronized SimulatorManagerCallback getInstance() {
-        if (null == simulatorManagerCallbackObj) {
-            simulatorManagerCallbackObj = new SimulatorManagerCallback();
-        }
-        return simulatorManagerCallbackObj;
-    }
-
-    public void registerResourceModelChangeListener(
-            IResourceModelChangedListener listener) {
-        resourceModelChangeListener = listener;
-    }
-
-    public void registerLogMessageListener(ILogMessageListener listener) {
-        logMessageListener = listener;
-    }
-
-    public void unregisterResourceModelChangeListener() {
-        resourceModelChangeListener = null;
-    }
-
-    public void unregisterLogMessageListener() {
-        logMessageListener = null;
-    }
-
-    public void onResourceModelChanged(String resourceURI,
-            Vector<SimulatorResourceAttribute> attributes) {
-        if (null != resourceModelChangeListener) {
-            resourceModelChangeListener.onResourceModelChanged(resourceURI,
-                    attributes);
-        }
-    }
-
-    public void onLogMessageHandler(int level, String tag, String location,
-            int lineNumber, String log) {
-        if (null != logMessageListener) {
-            logMessageListener.onLogMessageHandler(level, tag, location,
-                    lineNumber, log);
-        }
-    }
-}
\ No newline at end of file
diff --git a/service/simulator/java/sdk/ServiceProvider/src/org/iotivity/simulator/SimulatorManagerNativeInterface.java b/service/simulator/java/sdk/ServiceProvider/src/org/iotivity/simulator/SimulatorManagerNativeInterface.java
deleted file mode 100644 (file)
index 935845c..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.iotivity.simulator;
-
-import java.util.Vector;
-
-class SimulatorManagerNativeInterface {
-
-    public static native void initialize();
-
-    public static native void terminate();
-
-    public static native SimulatorResourceServer createResource(
-            String configPath);
-
-    public static native Vector<SimulatorResourceServer> createResources(
-            String configPath, int count);
-
-    public static native Vector<SimulatorResourceServer> getResources();
-
-    public static native void deleteResource(SimulatorResourceServer resource);
-
-    public static native void deleteAllResources(String resourceType);
-
-    public static native void deleteAllResources();
-
-}
\ No newline at end of file
diff --git a/service/simulator/java/sdk/ServiceProvider/src/org/iotivity/simulator/SimulatorResourceAttribute.java b/service/simulator/java/sdk/ServiceProvider/src/org/iotivity/simulator/SimulatorResourceAttribute.java
deleted file mode 100644 (file)
index 181596c..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.iotivity.simulator;
-
-public class SimulatorResourceAttribute {
-
-    private long nativeHandle;
-
-    public SimulatorResourceAttribute() {
-    }
-
-    public SimulatorResourceAttribute(String attrName) {
-        create(attrName);
-    }
-
-    private SimulatorResourceAttribute(long handle) {
-        nativeHandle = handle;
-    }
-
-    @Override
-    protected void finalize() throws Throwable {
-        dispose();
-    }
-
-    public <T> T getAttributeValue() {
-        Object obj = getValue();
-        @SuppressWarnings("unchecked")
-        T t = (T) obj;
-        return t;
-    }
-
-    private native void dispose();
-
-    public native void create(String attrName);
-
-    public native String getName();
-
-    public native Object getValue();
-
-    public native int allowedValuesSize();
-
-    public native String valueToString();
-
-    public native String allowedValuesToString();
-}
\ No newline at end of file
diff --git a/service/simulator/java/sdk/ServiceProvider/src/org/iotivity/simulator/SimulatorResourceServer.java b/service/simulator/java/sdk/ServiceProvider/src/org/iotivity/simulator/SimulatorResourceServer.java
deleted file mode 100644 (file)
index da3a639..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.iotivity.simulator;
-
-import java.util.Vector;
-
-public class SimulatorResourceServer {
-
-    private String resourceName;
-    private String resourceURI;
-    private String resourceType;
-    private String interfaceType;
-
-    private long   nativeHandle;
-
-    private SimulatorResourceServer(long nativeHandle) {
-        this.nativeHandle = nativeHandle;
-    }
-
-    public void setName(String resourceName) {
-        this.resourceName = resourceName;
-    }
-
-    private void setURI(String resourceURI) {
-        this.resourceURI = resourceURI;
-    }
-
-    private void setResourceType(String resourceType) {
-        this.resourceType = resourceType;
-    }
-
-    private void setInterfaceType(String interfaceType) {
-        this.interfaceType = interfaceType;
-    }
-
-    public String getName() {
-        return resourceName;
-    }
-
-    public String getURI() {
-        return resourceURI;
-    }
-
-    public String getResourceType() {
-        return resourceType;
-    }
-
-    public String getInterfaceType() {
-        return interfaceType;
-    }
-
-    @Override
-    protected void finalize() throws Throwable {
-        dispose();
-    }
-
-    public native SimulatorResourceModel getModel();
-
-    public native void updateAttributeFromAllowedValues(String attrName,
-            int index);
-
-    public native void setRange(String attrName, int min, int max);
-
-    public native void addAttributeInteger(String key, int value);
-
-    public native void addAttributeDouble(String key, double value);
-
-    public native void addAttributeBoolean(String key, Boolean value);
-
-    public native void addAttributeStringN(String key, String value);
-
-    public native void updateAttributeInteger(String key, int value);
-
-    public native void updateAttributeDouble(String key, double value);
-
-    public native void updateAttributeBoolean(String key, Boolean value);
-
-    public native void updateAttributeStringN(String key, String value);
-
-    public native void setAllowedValuesInteger(String key, int[] allowedValues);
-
-    public native void setAllowedValuesDouble(String key, double[] allowedValues);
-
-    public native void setAllowedValuesStringN(String key,
-            String[] allowedValues);
-
-    public native int startResourceAutomation();
-
-    public native int startAttributeAutomation(String attrName);
-
-    public native void startAutomation(int automationId);
-
-    public native void removeAttribute(String key);
-
-    private native void dispose();
-}
  * limitations under the License.
  */
 
-package org.iotivity.simulator;
+/**
+ * This file provides a enum which contains the automation types.
+ */
+package org.oic.simulator;
 
-public interface ILogMessageListener {
-    public void onLogMessageHandler(int level, String tag, String location,
-            int lineNumber, String log);
-}
\ No newline at end of file
+/**
+ * This Enum contains the different types of automation which are supported by
+ * the simulator.
+ */
+public enum AutomationType {
+    NORMAL, RECURRENT
+}
diff --git a/service/simulator/java/sdk/src/org/oic/simulator/IAutomation.java b/service/simulator/java/sdk/src/org/oic/simulator/IAutomation.java
new file mode 100644 (file)
index 0000000..4908b37
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * This file provides an interface for receiving notification when an automation completes.
+ */
+package org.oic.simulator;
+
+/**
+ * Interface for receiving automation complete notifications.
+ * 
+ * @param resourceURI
+ *            URI of the resource on which the automation has occurred.
+ * @param automationId
+ *            Unique Id of the automation.
+ */
+public interface IAutomation {
+    public void onAutomationComplete(String resourceURI, int automationId);
+}
diff --git a/service/simulator/java/sdk/src/org/oic/simulator/ILogger.java b/service/simulator/java/sdk/src/org/oic/simulator/ILogger.java
new file mode 100644 (file)
index 0000000..aeaaded
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * This file provides an interface for handling the log messages.
+ */
+package org.oic.simulator;
+
+/**
+ * Interface for receiving log messages.
+ */
+public interface ILogger {
+    public enum Level {
+        INFO, DEBUG, WARNING, ERROR
+    }
+
+    /**
+     * This callback method will be called to notify the application about the
+     * status or problems along with their severity.
+     *
+     * @param time
+     *            Local time information when action/event logged.
+     * @param level
+     *            Level or Severity of the log.
+     * @param message
+     *            The log message describing the issue.
+     */
+    public void write(String time, int level, String message);
+}
\ No newline at end of file
diff --git a/service/simulator/java/sdk/src/org/oic/simulator/OCSimulatorResult.java b/service/simulator/java/sdk/src/org/oic/simulator/OCSimulatorResult.java
new file mode 100644 (file)
index 0000000..296cd06
--- /dev/null
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * This file provides a Enum which contains Status codes for Success and Errors.
+ */
+package org.oic.simulator;
+
+/**
+ * This Enum contains Status codes for Success and Errors.
+ */
+public enum OCSimulatorResult {
+    OC_STACK_OK,
+    OC_STACK_RESOURCE_CREATED,
+    OC_STACK_RESOURCE_DELETED,
+    OC_STACK_CONTINUE,
+    OC_STACK_INVALID_URI,
+    OC_STACK_INVALID_QUERY,
+    OC_STACK_INVALID_IP,
+    OC_STACK_INVALID_PORT,
+    OC_STACK_INVALID_CALLBACK,
+    OC_STACK_INVALID_METHOD,
+    OC_STACK_INVALID_PARAM,
+    OC_STACK_INVALID_OBSERVE_PARAM,
+    OC_STACK_NO_MEMORY,
+    OC_STACK_COMM_ERROR,
+    OC_STACK_NOTIMPL,
+    OC_STACK_NO_RESOURCE,
+    OC_STACK_RESOURCE_ERROR,
+    OC_STACK_SLOW_RESOURCE,
+    OC_STACK_REPEATED_REQUEST,
+    OC_STACK_NO_OBSERVERS,
+    OC_STACK_OBSERVER_NOT_FOUND,
+    OC_STACK_VIRTUAL_DO_NOT_HANDLE,
+    OC_STACK_INVALID_OPTION,
+    OC_STACK_MALFORMED_RESPONSE,
+    OC_STACK_PERSISTENT_BUFFER_REQUIRED,
+    OC_STACK_INVALID_REQUEST_HANDLE,
+    OC_STACK_INVALID_DEVICE_INFO,
+    OC_STACK_INVALID_JSON,
+    OC_STACK_PRESENCE_STOPPED,
+    OC_STACK_PRESENCE_TIMEOUT,
+    OC_STACK_PRESENCE_DO_NOT_HANDLE,
+    OC_STACK_ERROR,
+    OC_STACK_LISTENER_NOT_SET;
+
+    public static OCSimulatorResult conversion(int ordinal) {
+
+        OCSimulatorResult result = OCSimulatorResult.values()[31];
+
+        if (ordinal == 0)
+            result = OCSimulatorResult.values()[0];
+        else if (ordinal == 1)
+            result = OCSimulatorResult.values()[1];
+        else if (ordinal == 2)
+            result = OCSimulatorResult.values()[2];
+        else if (ordinal == 3)
+            result = OCSimulatorResult.values()[3];
+
+        else if (ordinal == 20)
+            result = OCSimulatorResult.values()[4];
+        else if (ordinal == 21)
+            result = OCSimulatorResult.values()[5];
+        else if (ordinal == 22)
+            result = OCSimulatorResult.values()[6];
+        else if (ordinal == 23)
+            result = OCSimulatorResult.values()[7];
+        else if (ordinal == 24)
+            result = OCSimulatorResult.values()[8];
+        else if (ordinal == 25)
+            result = OCSimulatorResult.values()[9];
+        else if (ordinal == 26)
+            result = OCSimulatorResult.values()[10];
+        else if (ordinal == 27)
+            result = OCSimulatorResult.values()[11];
+        else if (ordinal == 28)
+            result = OCSimulatorResult.values()[12];
+        else if (ordinal == 29)
+            result = OCSimulatorResult.values()[13];
+        else if (ordinal == 30)
+            result = OCSimulatorResult.values()[14];
+        else if (ordinal == 31)
+            result = OCSimulatorResult.values()[15];
+        else if (ordinal == 32)
+            result = OCSimulatorResult.values()[16];
+        else if (ordinal == 33)
+            result = OCSimulatorResult.values()[17];
+        else if (ordinal == 34)
+            result = OCSimulatorResult.values()[18];
+        else if (ordinal == 35)
+            result = OCSimulatorResult.values()[19];
+        else if (ordinal == 36)
+            result = OCSimulatorResult.values()[20];
+        else if (ordinal == 37)
+            result = OCSimulatorResult.values()[21];
+        else if (ordinal == 38)
+            result = OCSimulatorResult.values()[22];
+        else if (ordinal == 39)
+            result = OCSimulatorResult.values()[23];
+        else if (ordinal == 40)
+            result = OCSimulatorResult.values()[24];
+        else if (ordinal == 41)
+            result = OCSimulatorResult.values()[25];
+        else if (ordinal == 42)
+            result = OCSimulatorResult.values()[26];
+        else if (ordinal == 43)
+            result = OCSimulatorResult.values()[27];
+
+        else if (ordinal == 128)
+            result = OCSimulatorResult.values()[28];
+        else if (ordinal == 129)
+            result = OCSimulatorResult.values()[29];
+        else if (ordinal == 130)
+            result = OCSimulatorResult.values()[30];
+
+        return result;
+    }
+}
\ No newline at end of file
diff --git a/service/simulator/java/sdk/src/org/oic/simulator/SimulatorManager.java b/service/simulator/java/sdk/src/org/oic/simulator/SimulatorManager.java
new file mode 100644 (file)
index 0000000..13797cf
--- /dev/null
@@ -0,0 +1,164 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * This file contains a class which has the methods
+ * for creation and deletion of resources.
+ */
+package org.oic.simulator;
+
+import java.util.ArrayList;
+import java.util.Vector;
+
+import org.oic.simulator.clientcontroller.IFindResourceListener;
+import org.oic.simulator.clientcontroller.SimulatorRemoteResource;
+import org.oic.simulator.serviceprovider.IResourceModelChangedListener;
+import org.oic.simulator.serviceprovider.SimulatorResourceServer;
+
+/**
+ * This class provides a set of methods for creation and deletion of resources.
+ */
+public class SimulatorManager {
+
+    /**
+     * Set listener for receiving log messages.
+     *
+     * @param logger
+     *            {@link ILogger} to receive the log messages.
+     */
+    public static void setLogger(ILogger logger) {
+        SimulatorManagerNativeInterface.setLogger(logger);
+    }
+
+    /**
+     * API for creating a resource from a RAML configuration file whose path is
+     * given as a parameter.
+     *
+     * @param configPath
+     *            Path to RAML configuration file.
+     * @param listener
+     *            Listener for receiving notifications whenever there is a
+     *            change in the resource model.
+     * 
+     * @return {@link SimulatorResourceServer} - Created resource on success,
+     *         otherwise null.
+     */
+    public static SimulatorResourceServer createResource(String configPath,
+            IResourceModelChangedListener listener) {
+        SimulatorResourceServer simulatorResourceServerObj;
+        simulatorResourceServerObj = SimulatorManagerNativeInterface
+                .createResource(configPath, listener);
+        return simulatorResourceServerObj;
+    }
+
+    /**
+     * API for creating a set of resources from a RAML configuration file whose
+     * path is given as a parameter.
+     *
+     * @param configPath
+     *            Path to RAML configuration file.
+     * @param count
+     *            Number of resources to be created.
+     * @param listener
+     *            Listener for receiving notifications whenever there is a
+     *            change in the resource model.
+     * 
+     * @return Returns an array of {@link SimulatorResourceServer} objects one
+     *         for each created resource on success, otherwise null.
+     */
+    public static SimulatorResourceServer[] createResource(String configPath,
+            int count, IResourceModelChangedListener listener) {
+        SimulatorResourceServer[] simulatorResourceServers;
+        simulatorResourceServers = SimulatorManagerNativeInterface
+                .createResources(configPath, count, listener);
+        return simulatorResourceServers;
+    }
+
+    /**
+     * API for getting all locally created resources.
+     *
+     * @return Returns a list of {@link SimulatorResourceServer} objects on
+     *         success, otherwise null.
+     */
+    public static Vector<SimulatorResourceServer> getLocalResources() {
+        Vector<SimulatorResourceServer> simulatorResourceServerVector = null;
+        simulatorResourceServerVector = SimulatorManagerNativeInterface
+                .getResources();
+        return simulatorResourceServerVector;
+    }
+
+    /**
+     * API for deleting a specific resource.
+     *
+     * @param resource
+     *            {@link SimulatorResourceServer} object of the resource to be
+     *            deleted.
+     */
+    public static void deleteResource(SimulatorResourceServer resource) {
+        SimulatorManagerNativeInterface.deleteResource(resource);
+    }
+
+    /**
+     * API for deleting either all the resources or resources of a specific
+     * type. Ex: If resourceType is oic.light, all resources of oic.light type
+     * will be deleted. If resourceType is null, then all of the resources will
+     * be deleted.
+     *
+     * @param resourceType
+     *            Type of resource to be deleted.
+     */
+    public static void deleteResources(String resourceType) {
+        SimulatorManagerNativeInterface.deleteResources(resourceType);
+    }
+
+    /**
+     * API for discovering resources in the network. Callback is called whenever
+     * a resource is discovered in the network.
+     *
+     * @param resourceType
+     *            Required resource type
+     *
+     * @return OCSimulatorResult - return value of this API. It returns
+     *         OC_STACK_OK if success.
+     *
+     */
+    public OCSimulatorResult findResource(String resourceType,
+            IFindResourceListener listener) {
+        OCSimulatorResult result;
+        int ordinal = SimulatorManagerNativeInterface.findResource(
+                resourceType, listener);
+        result = OCSimulatorResult.conversion(ordinal);
+        return result;
+    }
+
+    /**
+     * API for getting the list of previously discovered resources in the
+     * network.
+     *
+     * @param resourceType
+     *            Required resource type
+     *
+     * @return ArrayList<SimulatorRemoteResource> - returns list of
+     *         SimulatorRemoteResource
+     *
+     */
+    public ArrayList<SimulatorRemoteResource> getFoundResources(
+            String resourceType) {
+        ArrayList<SimulatorRemoteResource> resourceList = SimulatorManagerNativeInterface
+                .getFoundResources(resourceType);
+        return resourceList;
+    }
+}
\ No newline at end of file
diff --git a/service/simulator/java/sdk/src/org/oic/simulator/SimulatorManagerNativeInterface.java b/service/simulator/java/sdk/src/org/oic/simulator/SimulatorManagerNativeInterface.java
new file mode 100644 (file)
index 0000000..d8970f9
--- /dev/null
@@ -0,0 +1,155 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * This file contains a class which provides a set of native methods
+ * for creation and deletion of resources.
+ */
+package org.oic.simulator;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Vector;
+
+import org.oic.simulator.clientcontroller.IFindResourceListener;
+import org.oic.simulator.clientcontroller.SimulatorRemoteResource;
+import org.oic.simulator.ILogger;
+import org.oic.simulator.serviceprovider.IResourceModelChangedListener;
+import org.oic.simulator.serviceprovider.SimulatorResourceServer;
+
+/**
+ * This class provides a set of native functions for creation and deletion of
+ * resources.
+ */
+class SimulatorManagerNativeInterface {
+
+    /**
+     * Native function for creating a resource.
+     *
+     * @param configPath
+     *            Path to RAML configuration file.
+     * @param listener
+     *            Listener for receiving notifications whenever there is a
+     *            change in the resource model.
+     *
+     * @return {@link SimulatorResourceServer} object on success, otherwise
+     *         null.
+     */
+    public static native SimulatorResourceServer createResource(
+            String configPath, IResourceModelChangedListener listener);
+
+    /**
+     * Native function for creating several resources.
+     *
+     * @param configPath
+     *            Path to RAML configuration file.
+     * @param listener
+     *            Listener for receiving notifications whenever there is a
+     *            change in the resource model.
+     *
+     * @return An array of {@link SimulatorResourceServer} objects on success,
+     *         otherwise null.
+     */
+    public static native SimulatorResourceServer[] createResources(
+            String configPath, int count, IResourceModelChangedListener listener);
+
+    /**
+     * Native function to get the list of locally created resources.
+     *
+     * @return A list of {@link SimulatorResourceServer} objects on success,
+     *         otherwise null.
+     */
+    public static native Vector<SimulatorResourceServer> getResources();
+
+    /**
+     * Native function to delete a specific resource
+     *
+     * @param resource
+     *            {@link SimulatorResourceServer} object of the resource to be
+     *            deleted.
+     */
+    public static native void deleteResource(SimulatorResourceServer resource);
+
+    /**
+     * Native function to delete all resources or resources of a specific type.
+     *
+     * @param resourceType
+     *            Type of the resource.
+     */
+    public static native void deleteResources(String resourceType);
+
+    /**
+     * Native function to set the logger listener for receiving the log messages
+     * from native layer.
+     */
+    public static native void setLogger(ILogger logger);
+
+    /**
+     * Native function for discovering resources.
+     *
+     * @param resourceType
+     *            - required resource type
+     *
+     * @return OCSimulatorResult - return value of this API. It returns
+     *         OC_STACK_OK if success.
+     *
+     */
+    public static native int findResource(String resourceType,
+            IFindResourceListener listener);
+
+    /**
+     * Native function for getting the list of previously discovered resources
+     * in the network.
+     *
+     * @param resourceType
+     *            - required resource type
+     *
+     * @return ArrayList<SimulatorRemoteResource> - returns list of
+     *         SimulatorRemoteResource
+     *
+     */
+    public static native ArrayList<SimulatorRemoteResource> getFoundResources(
+            String resourceType);
+
+    /**
+     * Method to get the URI for this resource
+     *
+     * @return resource URI
+     */
+    public static native String getUri();
+
+    /**
+     * Method to get the list of resource types
+     *
+     * @return List of resource types
+     */
+    public static native List<String> getResourceTypes();
+
+    /**
+     * Method to get the list of resource interfaces
+     *
+     * @return List of resource interface
+     */
+    public static native List<String> getResourceInterfaces();
+
+    /**
+     * Method to get a string representation of the resource's server ID. This
+     * is unique per-server independent on how it was discovered.
+     *
+     * @return server ID
+     */
+    public static native String getServerId();
+}
\ No newline at end of file
diff --git a/service/simulator/java/sdk/src/org/oic/simulator/SimulatorResourceAttribute.java b/service/simulator/java/sdk/src/org/oic/simulator/SimulatorResourceAttribute.java
new file mode 100644 (file)
index 0000000..8682847
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * This file contains a class which has a set of native methods for
+ * getting the information associated with a particular attribute.
+ */
+package org.oic.simulator;
+
+/**
+ * This class represents an attribute of a resource. It has a set of native
+ * methods for getting the attribute's information.
+ */
+public class SimulatorResourceAttribute {
+
+    /**
+     * Handle to the native object of the simulator resource attribute.
+     */
+    private long nativeHandle;
+
+    public SimulatorResourceAttribute() {
+    }
+
+    /**
+     * Constructor for SimulatorResourceAttribute.
+     *
+     * @param nativeHandle
+     *            Handle to the native SimulatorResourceAttribute object.
+     */
+    private SimulatorResourceAttribute(long handle) {
+        nativeHandle = handle;
+    }
+
+    /**
+     * This constructor is used to create a new attribute.
+     *
+     * @param attrName
+     *            Name of the attribute
+     */
+    public SimulatorResourceAttribute(String attrName) {
+        create(attrName);
+    }
+
+    @Override
+    protected void finalize() throws Throwable {
+        dispose();
+    }
+
+    /**
+     * This generic API is used to get the value of an attribute whose type is
+     * given by the caller of the method.
+     *
+     * @param <T>
+     *            This specifies the type in which the value has to be returned.
+     *
+     * @return The attribute's value in a specified type.
+     */
+    public <T> T getAttributeValue() {
+        Object obj = getValue();
+        @SuppressWarnings("unchecked")
+        T t = (T) obj;
+        return t;
+    }
+
+    /**
+     * Native method to create a new attribute with the given name.
+     *
+     * @param attrName
+     *            Name of the attribute.
+     */
+    public native void create(String attrName);
+
+    /**
+     * Native method for getting the attribute's name.
+     *
+     * @return Attribute's name
+     */
+    public native String getName();
+
+    /**
+     * Native method for getting the attribute's value.
+     *
+     * @return Attribute's value represented as {@link Object}.
+     */
+    public native Object getValue();
+
+    /**
+     * Native method for getting the number of values in the allowed values
+     * list.
+     *
+     * @return Count of allowed values
+     */
+    public native int allowedValuesSize();
+
+    /**
+     * Native method for returning the string representation of the attribute's
+     * value.
+     *
+     * @return Attribute's value as {@link String}.
+     */
+    public native String valueToString();
+
+    /**
+     * Native method for returning the string representation of the attribute's
+     * allowed values.
+     *
+     * @return Attribute's allowed values as {@link String}.
+     */
+    public native String allowedValuesToString();
+
+    /**
+     * Native function to release the memory allocated to the native object for
+     * SimulatorResourceAttribute.
+     */
+    private native void dispose();
+
+}
\ No newline at end of file
diff --git a/service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/IFindResourceListener.java b/service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/IFindResourceListener.java
new file mode 100644 (file)
index 0000000..dc63e95
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * This file provides interface for getting notification when resources are
+ * discovered in network.
+ */
+package org.oic.simulator.clientcontroller;
+
+import org.oic.simulator.clientcontroller.SimulatorRemoteResource;
+
+/**
+ * Provides interface for getting notification when resources are discovered in
+ * network.
+ */
+public interface IFindResourceListener {
+    /**
+     * This callback method will be called whenever resource is discovered in
+     * the network.
+     *
+     * @param resource
+     *            resource discovered in the network
+     */
+    public void onResourceCallback(SimulatorRemoteResource resource);
+}
  * limitations under the License.
  */
 
-package org.iotivity.simulator;
-
-import java.util.Map;
-
-public class SimulatorResourceModel {
-
-    private long nativeHandle;
-
-    private SimulatorResourceModel(long nativeHandle) {
-        this.nativeHandle = nativeHandle;
-    }
-
-    @Override
-    protected void finalize() throws Throwable {
-        dispose();
-    }
-
-    public native int size();
-
-    public native Map<String, SimulatorResourceAttribute> getAttributes();
+/**
+ * This file provides interface for get callback information.
+ */
+package org.oic.simulator.clientcontroller;
 
-    public native SimulatorResourceAttribute getAttribute();
+import org.oic.simulator.serviceprovider.SimulatorResourceModel;
 
-    public native String[] getAllowedValues(String key);
+/**
+ * An OnGetListener can be registered via the resource get call. Event listeners
+ * are notified asynchronously
+ */
+public interface IGetListener {
+    public void onGetCompleted(SimulatorResourceModel representation);
 
-    public native void dispose();
-}
\ No newline at end of file
+    public void onGetFailed(Throwable ex);
+}
diff --git a/service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/IObserveListener.java b/service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/IObserveListener.java
new file mode 100644 (file)
index 0000000..a71384b
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * This file provides interface for getting notification on resource model change.
+ */
+package org.oic.simulator.clientcontroller;
+
+import org.oic.simulator.serviceprovider.SimulatorResourceModel;
+
+/**
+ * Provides interface for getting notification when resource model of an
+ * observed resource gets changed. An OnObserveListener can be registered via
+ * the SimulatorRemoteResource observe call. Event listeners are notified
+ * asynchronously.
+ */
+public interface IObserveListener {
+    /**
+     * This callback method will be called whenever the resource model of an
+     * observed resource gets changed.
+     *
+     * @param representation
+     *            Updated Simulator Resource Model
+     *
+     * @param sequenceNumber
+     *            Observe Sequence number
+     */
+    public void onObserveCompleted(SimulatorResourceModel representation,
+            int sequenceNumber);
+
+    /**
+     * This callback method will be called whenever the resource model of an
+     * observed resource gets changed and there is a failure in notifying the
+     * updated resource model.
+     *
+     * @param resource
+     *            resource discovered in the network
+     */
+    public void onObserveFailed(Throwable ex);
+}
diff --git a/service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/IPostListener.java b/service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/IPostListener.java
new file mode 100644 (file)
index 0000000..e88b98e
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * This file provides interface for post callback information.
+ */
+package org.oic.simulator.clientcontroller;
+
+import org.oic.simulator.serviceprovider.SimulatorResourceModel;
+
+/**
+ * An OnPostListener can be registered via the resource post call. Event
+ * listeners are notified asynchronously
+ */
+public interface IPostListener {
+    public void onPostCompleted(SimulatorResourceModel representation);
+
+    public void onPostFailed(Throwable ex);
+}
diff --git a/service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/IPutListener.java b/service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/IPutListener.java
new file mode 100644 (file)
index 0000000..a9c0738
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * This file provides interface for put callback information.
+ */
+package org.oic.simulator.clientcontroller;
+
+import org.oic.simulator.serviceprovider.SimulatorResourceModel;
+
+/**
+ * An OnPutListener can be registered via the resource put call. Event listeners
+ * are notified asynchronously
+ */
+public interface IPutListener {
+    public void onPutCompleted(SimulatorResourceModel representation);
+
+    public void onPutFailed(Throwable ex);
+}
  * limitations under the License.
  */
 
-package org.iotivity.simulator;
+/**
+ * This file provides a enum which contains the observable types.
+ */
+package org.oic.simulator.clientcontroller;
+
+public enum SimulatorObserveType {
+    OBSERVE(0), OBSERVE_ALL(1), ;
+
+    private int value;
 
-import java.util.Vector;
+    private SimulatorObserveType(int value) {
+        this.value = value;
+    }
 
-public interface IResourceModelChangedListener {
-    public void onResourceModelChanged(String resourceURI,
-            Vector<SimulatorResourceAttribute> attributes);
-}
\ No newline at end of file
+    public int getValue() {
+        return this.value;
+    }
+}
diff --git a/service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/SimulatorRemoteResource.java b/service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/SimulatorRemoteResource.java
new file mode 100644 (file)
index 0000000..583c273
--- /dev/null
@@ -0,0 +1,216 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * This file contains a class which has a set of native methods for 
+ * communicating with a remote resource.  
+ */
+package org.oic.simulator.clientcontroller;
+
+import java.util.List;
+import java.util.Map;
+
+import org.oic.simulator.serviceprovider.SimulatorResourceModel;
+
+/**
+ * SimulatorRemoteResource represents a Resource running in the remote Simulator
+ * Server. It comes with a well-defined contract or interface onto which you can
+ * perform different operations or subscribe for event notifications.
+ */
+public class SimulatorRemoteResource {
+
+    private SimulatorRemoteResource(long nativeHandle) {
+        this.mNativeHandle = nativeHandle;
+    }
+
+    /**
+     * Method to get the URI for this resource
+     *
+     * @return resource URI
+     */
+    public native String getUri();
+
+    /**
+     * Method to get the list of resource types
+     *
+     * @return List of resource types
+     */
+    public native List<String> getResourceTypes();
+
+    /**
+     * Method to get the list of resource interfaces
+     *
+     * @return List of resource interface
+     */
+    public native List<String> getResourceInterfaces();
+
+    /**
+     * Method to get a string representation of the resource's server ID. This
+     * is unique per-server independent on how it was discovered.
+     *
+     * @return server ID
+     */
+    public native String getServerId();
+
+    /**
+     * Method to set observation on the resource
+     *
+     * @param observeType
+     *            allows the client to specify how it wants to observe
+     * @param queryParamsMap
+     *            map which can have the query parameter name and value
+     * @param onObserveListener
+     *            event handler The handler method will be invoked with a map of
+     *            attribute name and values.
+     *
+     */
+    public native void observe(SimulatorObserveType observeType,
+            Map<String, String> queryParamsMap,
+            IObserveListener onObserveListener);
+
+    /**
+     * Method to cancel the observation on the resource
+     *
+     */
+    public native void cancelObserve();
+
+    /**
+     * Method to get the attributes of a resource.
+     *
+     * @param queryParamsMap
+     *            map which can have the query parameter name and value
+     * @param onGetListener
+     *            The event handler will be invoked with a map of attribute name
+     *            and values. The event handler will also have the result from
+     *            this Get operation This will have error codes
+     */
+    public native void get(Map<String, String> queryParamsMap,
+            IGetListener onGetListener);
+
+    /**
+     * Method to get the attributes of a resource.
+     *
+     * @param resourceType
+     *            resourceType of the resource to operate on
+     * @param resourceInterface
+     *            interface type of the resource to operate on
+     * @param queryParamsMap
+     *            map which can have the query parameter name and value
+     * @param onGetListener
+     *            The event handler will be invoked with a map of attribute name
+     *            and values. The event handler will also have the result from
+     *            this Get operation This will have error codes
+     */
+    public void get(String resourceType, String resourceInterface,
+            Map<String, String> queryParamsMap, IGetListener onGetListener) {
+        this.get2(resourceType, resourceInterface, queryParamsMap,
+                onGetListener);
+    }
+
+    private native void get2(String resourceType, String resourceInterface,
+            Map<String, String> queryParamsMap, IGetListener onGetListener);
+
+    /**
+     * Method to set the representation of a resource (via PUT)
+     *
+     * @param representation
+     *            representation of the resource
+     * @param queryParamsMap
+     *            Map which can have the query parameter name and value
+     * @param onPutListener
+     *            event handler The event handler will be invoked with a map of
+     *            attribute name and values.
+     */
+    public native void put(SimulatorResourceModel representation,
+            Map<String, String> queryParamsMap, IPutListener onPutListener);
+
+    /**
+     * Method to set the representation of a resource (via PUT)
+     *
+     * @param resourceType
+     *            resource type of the resource to operate on
+     * @param resourceInterface
+     *            interface type of the resource to operate on
+     * @param representation
+     *            representation of the resource
+     * @param queryParamsMap
+     *            Map which can have the query parameter name and value
+     * @param onPutListener
+     *            event handler The event handler will be invoked with a map of
+     *            attribute name and values.
+     */
+    public void put(String resourceType, String resourceInterface,
+            SimulatorResourceModel representation,
+            Map<String, String> queryParamsMap, IPutListener onPutListener) {
+        this.put2(resourceType, resourceInterface, representation,
+                queryParamsMap, onPutListener);
+    }
+
+    private native void put2(String resourceType, String resourceInterface,
+            SimulatorResourceModel representation,
+            Map<String, String> queryParamsMap, IPutListener onPutListener);
+
+    /**
+     * Method to POST on a resource
+     *
+     * @param representation
+     *            representation of the resource
+     * @param queryParamsMap
+     *            Map which can have the query parameter name and value
+     * @param onPostListener
+     *            event handler The event handler will be invoked with a map of
+     *            attribute name and values.
+     */
+    public native void post(SimulatorResourceModel representation,
+            Map<String, String> queryParamsMap, IPostListener onPostListener);
+
+    /**
+     * Method to POST on a resource
+     *
+     * @param resourceType
+     *            resource type of the resource to operate on
+     * @param resourceInterface
+     *            interface type of the resource to operate on
+     * @param representation
+     *            representation of the resource
+     * @param queryParamsMap
+     *            Map which can have the query parameter name and value
+     * @param onPostListener
+     *            event handler The event handler will be invoked with a map of
+     *            attribute name and values.
+     */
+    public void post(String resourceType, String resourceInterface,
+            SimulatorResourceModel representation,
+            Map<String, String> queryParamsMap, IPostListener onPostListener) {
+        this.post2(resourceType, resourceInterface, representation,
+                queryParamsMap, onPostListener);
+    }
+
+    private native void post2(String resourceType, String resourceInterface,
+            SimulatorResourceModel representation,
+            Map<String, String> queryParamsMap, IPostListener onPostListener);
+
+    @Override
+    protected void finalize() throws Throwable {
+        super.finalize();
+
+        dispose();
+    }
+
+    private native void dispose();
+
+    private long mNativeHandle;
+}
diff --git a/service/simulator/java/sdk/src/org/oic/simulator/serviceprovider/IResourceModelChangedListener.java b/service/simulator/java/sdk/src/org/oic/simulator/serviceprovider/IResourceModelChangedListener.java
new file mode 100644 (file)
index 0000000..c8b2174
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * This file provides an interface for handling the resource model
+ * related notifications.
+ */
+package org.oic.simulator.serviceprovider;
+
+/**
+ * Interface for receiving notifications whenever there is a change in the
+ * resource model.
+ */
+public interface IResourceModelChangedListener {
+    /**
+     * This callback method will be called to notify about the changes in the
+     * resource model.
+     *
+     * @param resourceURI
+     *            URI of resource.
+     * @param resourceModel
+     *            Resource model of the resource.
+     */
+    public void onResourceModelChanged(String resourceURI,
+            SimulatorResourceModel resourceModel);
+}
\ No newline at end of file
diff --git a/service/simulator/java/sdk/src/org/oic/simulator/serviceprovider/SimulatorResourceModel.java b/service/simulator/java/sdk/src/org/oic/simulator/serviceprovider/SimulatorResourceModel.java
new file mode 100644 (file)
index 0000000..fd69fba
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * This file contains a class which has a set of native methods for accessing
+ * the resource model.
+ */
+package org.oic.simulator.serviceprovider;
+
+import org.oic.simulator.SimulatorResourceAttribute;
+import java.util.Map;
+
+/**
+ * This class represents the resource model of a resource and it provides a set
+ * of native methods for accessing the resource model.
+ */
+public class SimulatorResourceModel {
+
+    /**
+     * Handle to the native object of the simulator resource model.
+     */
+    private long nativeHandle;
+
+    /**
+     * Constructor for SimulatorResourceModel.
+     *
+     * @param nativeHandle
+     *            Handle to the native SimulatorResourceModel object.
+     */
+    private SimulatorResourceModel(long nativeHandle) {
+        this.nativeHandle = nativeHandle;
+    }
+
+    @Override
+    protected void finalize() throws Throwable {
+        dispose();
+    }
+
+    /**
+     * Native function for getting the total count of attributes in the resource
+     * model.
+     *
+     * @return Total number of attributes.
+     */
+    public native int size();
+
+    /**
+     * Native function for getting all attributes of a resource.
+     *
+     * @return Map of attributes with attribute name as the key and its
+     *         corresponding {@link SimulatorResourceAttribute} object as the
+     *         value.
+     */
+    public native Map<String, SimulatorResourceAttribute> getAttributes();
+
+    /**
+     * Native function to get a specific attribute of a resource. It takes the
+     * attribute name and returns an object of
+     * {@link SimulatorResourceAttribute}.
+     *
+     * @param attrName
+     *            Name of the attribute
+     *
+     * @return An object of SimulatorResourceAttribute.
+     */
+    public native SimulatorResourceAttribute getAttribute(String attrName);
+
+    /**
+     * Native function to get all the allowed values of a particular attribute.
+     *
+     * @param key
+     *            Name of the attribute
+     *
+     * @return An array of all possible values as strings.
+     */
+    public native String[] getAllowedValues(String key);
+
+    /**
+     * Native function to release the memory allocated to the native object for
+     * SimulatorResourceModel.
+     */
+    public native void dispose();
+}
\ No newline at end of file
diff --git a/service/simulator/java/sdk/src/org/oic/simulator/serviceprovider/SimulatorResourceServer.java b/service/simulator/java/sdk/src/org/oic/simulator/serviceprovider/SimulatorResourceServer.java
new file mode 100644 (file)
index 0000000..0df65f5
--- /dev/null
@@ -0,0 +1,342 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * This file contains a class which has a set of native methods for manipulating
+ * the simulated resource by adding and removing attributes to its model,
+ * automating the attribute value updates, and changing the range of
+ * acceptable values of the attributes.
+ */
+package org.oic.simulator.serviceprovider;
+
+import java.util.Vector;
+
+import org.oic.simulator.IAutomation;
+
+/**
+ * This class represents a resource in the simulator. It provides a set of
+ * native methods for manipulating the attributes.
+ */
+public class SimulatorResourceServer {
+
+    private String resourceName;
+    private String resourceURI;
+    private String resourceType;
+    private String interfaceType;
+
+    private long   nativeHandle;
+
+    /**
+     * Constructor for SimulatorResourceServer.
+     *
+     * @param nativeHandle
+     *            Handle to the native {@link SimulatorResourceServer} object.
+     */
+    private SimulatorResourceServer(long nativeHandle) {
+        this.nativeHandle = nativeHandle;
+    }
+
+    /**
+     * API to set the name of the resource. Example: Light, Fan, etc.
+     *
+     * @param resourceName
+     *            Name of the resource.
+     */
+    public void setName(String resourceName) {
+        this.resourceName = resourceName;
+    }
+
+    /**
+     * API to set the URI of the resource. Example: /oic/light, /oic/fan, etc.
+     *
+     * @param resourceURI
+     *            URI of the resource.
+     */
+    private void setURI(String resourceURI) {
+        this.resourceURI = resourceURI;
+    }
+
+    /**
+     * API to set the type of the resource. Example: oic.light, oic.fan, etc.
+     *
+     * @param resourceType
+     *            Type of the resource.
+     */
+    private void setResourceType(String resourceType) {
+        this.resourceType = resourceType;
+    }
+
+    /**
+     * API to set the interface type of the resource. Example: oic.if.baseline,
+     * oic.if.b, etc.
+     *
+     * @param interfaceType
+     *            Interface type of the resource.
+     */
+    private void setInterfaceType(String interfaceType) {
+        this.interfaceType = interfaceType;
+    }
+
+    /**
+     * API to get the resource name. Example: Light, Fan, etc.
+     *
+     * @return Resource name.
+     */
+    public String getName() {
+        return resourceName;
+    }
+
+    /**
+     * API to get the resource URI. Example: /oic/light, /oic/fan, etc.
+     *
+     * @return Resource URI.
+     */
+    public String getURI() {
+        return resourceURI;
+    }
+
+    /**
+     * API to get the resource Type. Example: oic.light, oic.fan, etc.
+     *
+     * @return Resource type.
+     */
+    public String getResourceType() {
+        return resourceType;
+    }
+
+    /**
+     * API to get the interface type of the resource. Example: oic.if.baseline,
+     * oic.if.b, etc.
+     *
+     * @return Interface type of the resource.
+     */
+    public String getInterfaceType() {
+        return interfaceType;
+    }
+
+    @Override
+    protected void finalize() throws Throwable {
+        dispose();
+    }
+
+    /**
+     * Native function to get the {@link SimulatorResourceModel} of the
+     * corresponding resource.
+     *
+     * @return {@link SimulatorResourceModel} object on success, otherwise null.
+     */
+    public native SimulatorResourceModel getModel();
+
+    /**
+     * Native function to automatically update the value of an attribute from
+     * its allowed values.
+     *
+     * @param attrName
+     *            Name of the attribute
+     *
+     * @param index
+     *            Index of the value in the allowed values.
+     */
+    public native void updateAttributeFromAllowedValues(String attrName,
+            int index);
+
+    /**
+     * Native function to set the range of allowed values. This function is
+     * intended to be used for integral type attributes.
+     *
+     * @param attrName
+     *            Name of the attribute
+     * @param min
+     *            Minimum value in the range.
+     * @param max
+     *            Maximum value in the range.
+     */
+    public native void setRange(String attrName, int min, int max);
+
+    /**
+     * Native function to add an attribute whose value is of type int.
+     *
+     * @param key
+     *            Name of the attribute
+     * @param value
+     *            Initial value of the attribute
+     */
+    public native void addAttributeInteger(String key, int value);
+
+    /**
+     * Native function to add an attribute whose value is of type double.
+     *
+     * @param key
+     *            Name of the attribute
+     * @param value
+     *            Initial value of the attribute
+     */
+    public native void addAttributeDouble(String key, double value);
+
+    /**
+     * Native function to add an attribute whose value is of type Boolean.
+     *
+     * @param key
+     *            Name of the attribute
+     * @param value
+     *            Initial value of the attribute
+     */
+    public native void addAttributeBoolean(String key, Boolean value);
+
+    /**
+     * Native function to add an attribute whose value is of type String.
+     *
+     * @param key
+     *            Name of the attribute
+     * @param value
+     *            Initial value of the attribute
+     */
+    public native void addAttributeStringN(String key, String value);
+
+    /**
+     * Native function to update the value of an attribute whose value is of
+     * type int.
+     *
+     * @param key
+     *            Name of the attribute
+     * @param value
+     *            New value of the attribute
+     */
+    public native void updateAttributeInteger(String key, int value);
+
+    /**
+     * Native function to update the value of an attribute whose value is of
+     * type double.
+     *
+     * @param key
+     *            Name of the attribute
+     * @param value
+     *            New value of the attribute
+     */
+    public native void updateAttributeDouble(String key, double value);
+
+    /**
+     * Native function to update the value of an attribute whose value is of
+     * type boolean.
+     *
+     * @param key
+     *            Name of the attribute
+     * @param value
+     *            New value of the attribute
+     */
+    public native void updateAttributeBoolean(String key, Boolean value);
+
+    /**
+     * Native function to update the value of an attribute whose value is of
+     * type String.
+     *
+     * @param key
+     *            Name of the attribute
+     * @param value
+     *            New value of the attribute
+     */
+    public native void updateAttributeStringN(String key, String value);
+
+    /**
+     * Native function to set the allowed values of attribute whose value is of
+     * type int.
+     *
+     * @param key
+     *            Name of the attribute
+     * @param allowedValues
+     *            Allowed values of the attribute
+     */
+    public native void setAllowedValuesInteger(String key,
+            Vector<Integer> allowedValues);
+
+    /**
+     * Native function to set the allowed values of attribute whose value is of
+     * type double.
+     *
+     * @param key
+     *            Name of the attribute
+     * @param allowedValues
+     *            Allowed values of the attribute
+     */
+    public native void setAllowedValuesDouble(String key,
+            Vector<Double> allowedValues);
+
+    /**
+     * Native function to set the allowed values of attribute whose value is of
+     * type String.
+     *
+     * @param key
+     *            Name of the attribute
+     * @param allowedValues
+     *            Allowed values of the attribute
+     */
+    public native void setAllowedValuesStringN(String key,
+            Vector<String> allowedValues);
+
+    /**
+     * Native function to start the resource level automation. This automation
+     * involves automatically updating all the possible values for all the
+     * attributes sequentially.
+     *
+     * @param typeOfAutomation
+     *            Indicates whether the automation is one-time or recursive.
+     * @param listener
+     *            Listener to be notified when automation ends.
+     *
+     * @return Automation ID using which the automation can be stopped.
+     */
+    public native int startResourceAutomation(int typeOfAutomation,
+            IAutomation listener);
+
+    /**
+     * Native function to start the attribute level automation. This automation
+     * involves automatically updating all the possible values for a given
+     * attribute sequentially.
+     *
+     * @param attrName
+     *            Name of the attribute to be automated.
+     * @param typeOfAutomation
+     *            Indicates whether the automation is one-time or recursive.
+     * @param listener
+     *            Listener to be notified when automation ends.
+     *
+     * @return Automation ID using which the automation can be stopped.
+     */
+    public native int startAttributeAutomation(String attrName,
+            int typeOfAutomation, IAutomation listener);
+
+    /**
+     * Native function to stop the automation.
+     *
+     * @param automationId
+     *            Using which a specific automation can be stopped.
+     */
+    public native void stopAutomation(int automationId);
+
+    /**
+     * Native function to remove an attribute from the resource model.
+     *
+     * @param key
+     *            Name of the attribute to be deleted
+     */
+    public native void removeAttribute(String key);
+
+    /**
+     * Native function to release the memory allocated to the native object for
+     * SimulatorResourceServer.
+     */
+    private native void dispose();
+}