Updating Simulator Java API project with the following changes.
authorG S Senthil Kumar <senthil.gs@samsung.com>
Wed, 2 Sep 2015 14:35:51 +0000 (20:05 +0530)
committerMadan Lanka <lanka.madan@samsung.com>
Thu, 3 Sep 2015 06:37:42 +0000 (06:37 +0000)
1. Moved SimulatorResourceModel to the common package and renamed resource attribute class.
2. Added APIs for client controller
3. Added APIs for Observer information.
4. Updated Javadoc comments.

Change-Id: I6290d80557e309686b2fedb00332c209e53156fb
Signed-off-by: G S Senthil Kumar <senthil.gs@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2353
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
19 files changed:
service/simulator/java/sdk/.gitignore [new file with mode: 0644]
service/simulator/java/sdk/src/org/oic/simulator/IAutomation.java
service/simulator/java/sdk/src/org/oic/simulator/ILogger.java
service/simulator/java/sdk/src/org/oic/simulator/ResourceAttribute.java [new file with mode: 0644]
service/simulator/java/sdk/src/org/oic/simulator/SimulatorManager.java
service/simulator/java/sdk/src/org/oic/simulator/SimulatorManagerNativeInterface.java
service/simulator/java/sdk/src/org/oic/simulator/SimulatorResourceAttribute.java [deleted file]
service/simulator/java/sdk/src/org/oic/simulator/SimulatorResourceModel.java [new file with mode: 0644]
service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/IGetListener.java
service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/IObserveListener.java
service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/IPostListener.java
service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/IPutListener.java
service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/IVerificationListener.java [new file with mode: 0644]
service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/SimulatorRemoteResource.java
service/simulator/java/sdk/src/org/oic/simulator/serviceprovider/IObserver.java [new file with mode: 0644]
service/simulator/java/sdk/src/org/oic/simulator/serviceprovider/IResourceModelChangedListener.java
service/simulator/java/sdk/src/org/oic/simulator/serviceprovider/ObserverInfo.java [new file with mode: 0644]
service/simulator/java/sdk/src/org/oic/simulator/serviceprovider/SimulatorResourceModel.java [deleted file]
service/simulator/java/sdk/src/org/oic/simulator/serviceprovider/SimulatorResourceServer.java

diff --git a/service/simulator/java/sdk/.gitignore b/service/simulator/java/sdk/.gitignore
new file mode 100644 (file)
index 0000000..ae3c172
--- /dev/null
@@ -0,0 +1 @@
+/bin/
index 4908b37..4dbe18e 100644 (file)
 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.
+ * Interface for receiving notifications on completion of automation.
  */
 public interface IAutomation {
+    /**
+     * Callback method 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 void onAutomationComplete(String resourceURI, int automationId);
 }
index aeaaded..629899f 100644 (file)
@@ -23,6 +23,9 @@ package org.oic.simulator;
  * Interface for receiving log messages.
  */
 public interface ILogger {
+    /**
+     * This enumeration contains different levels of log.
+     */
     public enum Level {
         INFO, DEBUG, WARNING, ERROR
     }
diff --git a/service/simulator/java/sdk/src/org/oic/simulator/ResourceAttribute.java b/service/simulator/java/sdk/src/org/oic/simulator/ResourceAttribute.java
new file mode 100644 (file)
index 0000000..ffda865
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+ * 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 ResourceAttribute {
+    /**
+     * Type of attribute value.
+     */
+    public enum Type {
+        INT, DOUBLE, BOOL, STRING;
+
+        private static Type[] m_cvalues = Type.values();
+
+        @SuppressWarnings("unused")
+        private static Type getType(int x) {
+            return m_cvalues[x];
+        }
+    };
+
+    /**
+     * Class contains range property in min and max value.
+     */
+    public class Range {
+        public int getMin() {
+            return m_min;
+        }
+
+        public int getMax() {
+            return m_max;
+        }
+
+        private Range(int min, int max) {
+            m_min = min;
+            m_max = max;
+        }
+
+        private int m_min;
+        private int m_max;
+    }
+
+    @SuppressWarnings("unused")
+    private void setRange(int min, int max) {
+        m_range = new Range(min, max);
+    }
+
+    /**
+     * 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 getValue() {
+        @SuppressWarnings("unchecked")
+        T t = (T) m_value;
+        return t;
+    }
+
+    /**
+     * Method for getting the attribute's name.
+     *
+     * @return Attribute's name
+     */
+    public String getName() {
+        return m_name;
+    }
+
+    /**
+     * Method for getting the attribute's value type.
+     *
+     * @return Attribute's value type as {@link Type}
+     */
+    public Type getType() {
+        return m_type;
+    }
+
+    /**
+     * Method for getting the attribute's value base type. For example If the
+     * attribute value object is of type Vector of {@link Integer} then its type
+     * is Vector and base type is INT.
+     *
+     * @return Attribute's value type as {@link Type}
+     */
+    public Type getBaseType() {
+        return m_type;
+    }
+
+    /**
+     * Method for getting the attribute's range property. Range will be valid
+     * only for Integer type.
+     *
+     * @return Attribute's value range as {@link Range}.
+     */
+    public Range getRange() {
+        return m_range;
+    }
+
+    /**
+     * Method for getting the attribute's allowed values property. Allowed
+     * values property will be valid only for Integer, Double, String types.
+     *
+     * @param <T>
+     *            Attribute's allowed values whose type is given by the caller
+     *            of the method.
+     *
+     * @return Attribute's value range as {@link Range}.
+     */
+    public <T> T getAllowedValues() {
+        @SuppressWarnings("unchecked")
+        T t = (T) m_AllowedValues;
+        return t;
+    }
+
+    private String m_name          = null;
+    private Object m_value         = null;
+    private Type   m_type          = Type.STRING;
+    private Range  m_range         = null;
+    private Object m_AllowedValues = null;
+}
\ No newline at end of file
index 13797cf..ee4691f 100644 (file)
@@ -130,12 +130,13 @@ public class SimulatorManager {
      *
      * @param resourceType
      *            Required resource type
-     *
+     * @param listener
+     *            Interface to receive the discovered remote resources.
+     * 
      * @return OCSimulatorResult - return value of this API. It returns
      *         OC_STACK_OK if success.
-     *
      */
-    public OCSimulatorResult findResource(String resourceType,
+    public static OCSimulatorResult findResource(String resourceType,
             IFindResourceListener listener) {
         OCSimulatorResult result;
         int ordinal = SimulatorManagerNativeInterface.findResource(
@@ -151,11 +152,11 @@ public class SimulatorManager {
      * @param resourceType
      *            Required resource type
      *
-     * @return ArrayList<SimulatorRemoteResource> - returns list of
+     * @return A list of {@link SimulatorRemoteResource} - returns list of
      *         SimulatorRemoteResource
      *
      */
-    public ArrayList<SimulatorRemoteResource> getFoundResources(
+    public static ArrayList<SimulatorRemoteResource> getFoundResources(
             String resourceType) {
         ArrayList<SimulatorRemoteResource> resourceList = SimulatorManagerNativeInterface
                 .getFoundResources(resourceType);
index d8970f9..dc33156 100644 (file)
@@ -56,6 +56,8 @@ class SimulatorManagerNativeInterface {
      *
      * @param configPath
      *            Path to RAML configuration file.
+     * @param count
+     *            Number of instances.
      * @param listener
      *            Listener for receiving notifications whenever there is a
      *            change in the resource model.
@@ -94,6 +96,9 @@ class SimulatorManagerNativeInterface {
     /**
      * Native function to set the logger listener for receiving the log messages
      * from native layer.
+     * 
+     * @param logger
+     *            Interface to receive log.
      */
     public static native void setLogger(ILogger logger);
 
@@ -101,11 +106,12 @@ class SimulatorManagerNativeInterface {
      * Native function for discovering resources.
      *
      * @param resourceType
-     *            - required resource type
+     *            required resource type
+     * @param listener
+     *            Interface to receive the discovered remote resources.
      *
      * @return OCSimulatorResult - return value of this API. It returns
      *         OC_STACK_OK if success.
-     *
      */
     public static native int findResource(String resourceType,
             IFindResourceListener listener);
@@ -115,7 +121,7 @@ class SimulatorManagerNativeInterface {
      * in the network.
      *
      * @param resourceType
-     *            required resource type
+     *            required resource type
      *
      * @return ArrayList<SimulatorRemoteResource> - returns list of
      *         SimulatorRemoteResource
@@ -127,7 +133,7 @@ class SimulatorManagerNativeInterface {
     /**
      * Method to get the URI for this resource
      *
-     * @return resource URI
+     * @return Resource URI
      */
     public static native String getUri();
 
@@ -141,7 +147,7 @@ class SimulatorManagerNativeInterface {
     /**
      * Method to get the list of resource interfaces
      *
-     * @return List of resource interface
+     * @return List of resource interfaces
      */
     public static native List<String> getResourceInterfaces();
 
@@ -149,7 +155,7 @@ class SimulatorManagerNativeInterface {
      * 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
+     * @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
deleted file mode 100644 (file)
index 8682847..0000000
+++ /dev/null
@@ -1,130 +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.
- */
-
-/**
- * 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/SimulatorResourceModel.java b/service/simulator/java/sdk/src/org/oic/simulator/SimulatorResourceModel.java
new file mode 100644 (file)
index 0000000..199f819
--- /dev/null
@@ -0,0 +1,134 @@
+/*
+ * 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;
+
+import org.oic.simulator.ResourceAttribute;
+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 {
+
+    /**
+     * Constructor.
+     */
+    public SimulatorResourceModel() {
+        create();
+    }
+
+    /**
+     * Method for adding an attribute whose value is of type int.
+     * 
+     * @param name
+     *            Name of the attribute
+     * @param value
+     *            Value of the attribute
+     */
+    public void addAttribute(String name, int value) {
+        addAttributeInt(name, value);
+    }
+
+    /**
+     * Method for adding an attribute whose value is of type double.
+     * 
+     * @param name
+     *            Name of the attribute
+     * @param value
+     *            Value of the attribute
+     */
+    public void addAttribute(String name, double value) {
+        addAttributeDouble(name, value);
+    }
+
+    /**
+     * Method for adding an attribute whose value is of type boolean.
+     * 
+     * @param name
+     *            Name of the attribute
+     * @param value
+     *            Value of the attribute
+     */
+    public void addAttribute(String name, boolean value) {
+        addAttributeBoolean(name, value);
+    }
+
+    /**
+     * Method for adding an attribute whose value is of type string.
+     * 
+     * @param name
+     *            Name of the attribute
+     * @param value
+     *            Value of the attribute
+     */
+    public void addAttribute(String name, String value) {
+        addAttributeString(name, value);
+    }
+
+    /**
+     * Method for getting the number of attributes this model comprised of.
+     *
+     * @return Number of attributes.
+     */
+    public native int size();
+
+    /**
+     * Method for getting all attributes.
+     *
+     * @return Map of attributes with attribute name as the key and its
+     *         corresponding {@link ResourceAttribute} object as the value.
+     */
+    public native Map<String, ResourceAttribute> getAttributes();
+
+    /**
+     * Method for getting a specific attribute by its name.
+     *
+     * @param attrName
+     *            Name of the attribute
+     *
+     * @return An object of {@link ResourceAttribute}.
+     */
+    public native ResourceAttribute getAttribute(String attrName);
+
+    private native void addAttributeInt(String name, int value);
+
+    private native void addAttributeDouble(String name, double value);
+
+    private native void addAttributeBoolean(String name, boolean value);
+
+    private native void addAttributeString(String name, String value);
+
+    private SimulatorResourceModel(long nativeHandle) {
+        this.nativeHandle = nativeHandle;
+    }
+
+    @Override
+    protected void finalize() throws Throwable {
+        dispose();
+    }
+
+    private native void create();
+
+    private native void dispose();
+
+    private long nativeHandle;
+}
\ No newline at end of file
index 32abac6..24f89a4 100644 (file)
  */
 package org.oic.simulator.clientcontroller;
 
-import org.oic.simulator.serviceprovider.SimulatorResourceModel;
+import org.oic.simulator.SimulatorResourceModel;
 
 /**
  * An OnGetListener can be registered via the resource get call. Event listeners
  * are notified asynchronously
  */
 public interface IGetListener {
-    public void onGetCompleted(SimulatorResourceModel representation);
+    public void onGetCompleted(String uId, SimulatorResourceModel representation);
 
     public void onGetFailed(Throwable ex);
 }
index a71384b..cdf297c 100644 (file)
@@ -19,7 +19,7 @@
  */
 package org.oic.simulator.clientcontroller;
 
-import org.oic.simulator.serviceprovider.SimulatorResourceModel;
+import org.oic.simulator.SimulatorResourceModel;
 
 /**
  * Provides interface for getting notification when resource model of an
@@ -28,26 +28,8 @@ import org.oic.simulator.serviceprovider.SimulatorResourceModel;
  * 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);
+    public void onObserveCompleted(String uId,
+            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);
 }
index e88b98e..1b4ddcb 100644 (file)
  */
 package org.oic.simulator.clientcontroller;
 
-import org.oic.simulator.serviceprovider.SimulatorResourceModel;
+import org.oic.simulator.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 onPostCompleted(String uId,
+            SimulatorResourceModel representation);
 
     public void onPostFailed(Throwable ex);
 }
index a9c0738..dced792 100644 (file)
  */
 package org.oic.simulator.clientcontroller;
 
-import org.oic.simulator.serviceprovider.SimulatorResourceModel;
+import org.oic.simulator.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 onPutCompleted(String uId, SimulatorResourceModel representation);
 
     public void onPutFailed(Throwable ex);
 }
diff --git a/service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/IVerificationListener.java b/service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/IVerificationListener.java
new file mode 100644 (file)
index 0000000..3b582c6
--- /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 verification callback information.
+ */
+package org.oic.simulator.clientcontroller;
+
+/**
+ * An OnVerificationListener can be registered via the resource
+ * startVerification call. Event listeners are notified asynchronously.
+ */
+public interface IVerificationListener {
+    public void onVerificationStarted(String uId, int id);
+
+    public void onVerificationAborted(String uId, int id);
+
+    public void onVerificationCompleted(String uId, int id);
+}
index 583c273..078e999 100644 (file)
  */
 
 /**
- * This file contains a class which has a set of native methods for 
- * communicating with a remote resource.  
+ * 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.LinkedList;
 import java.util.Map;
 
-import org.oic.simulator.serviceprovider.SimulatorResourceModel;
+import org.oic.simulator.SimulatorResourceModel;
 
 /**
  * SimulatorRemoteResource represents a Resource running in the remote Simulator
@@ -33,41 +33,76 @@ import org.oic.simulator.serviceprovider.SimulatorResourceModel;
 public class SimulatorRemoteResource {
 
     private SimulatorRemoteResource(long nativeHandle) {
-        this.mNativeHandle = nativeHandle;
+        this.nativeHandle = nativeHandle;
     }
 
     /**
      * Method to get the URI for this resource
-     *
+     * 
      * @return resource URI
      */
-    public native String getUri();
+    public String getUri() {
+        return mUri;
+    }
+
+    /**
+     * Method to get the observe capability of this resource
+     * 
+     * @return true if the resource is observable, otherwise false.
+     */
+    public boolean getIsObservable() {
+        return mIsObservable;
+    }
+
+    /**
+     * Method to get the connectivity type for this resource
+     * 
+     * @return Connectivity type.
+     */
+    public String getConnectivityType() {
+        return mConnType;
+    }
 
     /**
      * Method to get the list of resource types
-     *
+     * 
      * @return List of resource types
      */
-    public native List<String> getResourceTypes();
+    public LinkedList<String> getResourceTypes() {
+        return mResTypes;
+    }
 
     /**
      * Method to get the list of resource interfaces
-     *
+     * 
      * @return List of resource interface
      */
-    public native List<String> getResourceInterfaces();
+    public LinkedList<String> getResourceInterfaces() {
+        return mResInterfaces;
+    }
 
     /**
      * 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();
+    public String getServerId() {
+        return mSid;
+    }
+
+    /**
+     * Method to get a unique Id of the resource.
+     * 
+     * @return Unique ID.
+     */
+    public String getUid() {
+        return mUid;
+    }
 
     /**
      * Method to set observation on the resource
-     *
+     * 
      * @param observeType
      *            allows the client to specify how it wants to observe
      * @param queryParamsMap
@@ -75,7 +110,7 @@ public class SimulatorRemoteResource {
      * @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,
@@ -83,13 +118,12 @@ public class SimulatorRemoteResource {
 
     /**
      * 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
@@ -97,14 +131,14 @@ public class SimulatorRemoteResource {
      *            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);
+    public void get(Map<String, String> queryParamsMap,
+            IGetListener onGetListener) {
+        this.get(null, queryParamsMap, 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
@@ -114,18 +148,12 @@ public class SimulatorRemoteResource {
      *            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,
+    public native void get(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
@@ -134,14 +162,14 @@ public class SimulatorRemoteResource {
      *            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);
+    public void put(SimulatorResourceModel representation,
+            Map<String, String> queryParamsMap, IPutListener onPutListener) {
+        this.put(null, representation, queryParamsMap, 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
@@ -152,20 +180,13 @@ public class SimulatorRemoteResource {
      *            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,
+    private native int put(String resourceInterface,
             SimulatorResourceModel representation,
             Map<String, String> queryParamsMap, IPutListener onPutListener);
 
     /**
      * Method to POST on a resource
-     *
+     * 
      * @param representation
      *            representation of the resource
      * @param queryParamsMap
@@ -174,14 +195,14 @@ public class SimulatorRemoteResource {
      *            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);
+    public void post(SimulatorResourceModel representation,
+            Map<String, String> queryParamsMap, IPostListener onPostListener) {
+        this.post(null, representation, queryParamsMap, 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
@@ -192,17 +213,43 @@ public class SimulatorRemoteResource {
      *            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,
+    private native int post(String resourceInterface,
             SimulatorResourceModel representation,
             Map<String, String> queryParamsMap, IPostListener onPostListener);
 
+    /**
+     * Method to set the RAML file path from application
+     * 
+     * @param ramlPath
+     *            RAML configuration file path
+     */
+    public native void configureRAMLPath(String ramlPath);
+
+    /**
+     * Method to start verification of a resource using automation
+     * 
+     * @param requestType
+     *            request type to verify
+     * 
+     * @param onVerifyListener
+     *            event handler The event handler will be invoked with the
+     *            automation ID.
+     * 
+     * @return Automation ID.
+     * 
+     */
+    public native int startVerification(int requestType,
+            IVerificationListener onVerifyListener);
+
+    /**
+     * Method to stop verification of a resource previously started.
+     * 
+     * @param id
+     *            Automation ID.
+     * 
+     */
+    public native void stopVerification(int id);
+
     @Override
     protected void finalize() throws Throwable {
         super.finalize();
@@ -212,5 +259,12 @@ public class SimulatorRemoteResource {
 
     private native void dispose();
 
-    private long mNativeHandle;
+    private long               nativeHandle;
+    private String             mUri;
+    private String             mConnType;
+    private String             mSid;
+    private String             mUid;
+    private boolean            mIsObservable;
+    private LinkedList<String> mResTypes;
+    private LinkedList<String> mResInterfaces;
 }
diff --git a/service/simulator/java/sdk/src/org/oic/simulator/serviceprovider/IObserver.java b/service/simulator/java/sdk/src/org/oic/simulator/serviceprovider/IObserver.java
new file mode 100644 (file)
index 0000000..7e48fe5
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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 the notifications on observers.
+ */
+package org.oic.simulator.serviceprovider;
+
+/**
+ * Interface for receiving the observe notifications.
+ */
+public interface IObserver {
+    /**
+     * This callback method will be called when a new observer is added or an
+     * existing observer is removed.
+     * 
+     * @param resourceURI
+     *            URI of the resource.
+     * @param state
+     *            Indicates whether an observer is added or removed.
+     * @param observer
+     *            {@link ObserverInfo} object containing the details of
+     *            observer.
+     */
+    public void onObserverChanged(String resourceURI, int state,
+            ObserverInfo observer);
+}
index c8b2174..bb5c3ac 100644 (file)
@@ -20,6 +20,8 @@
  */
 package org.oic.simulator.serviceprovider;
 
+import org.oic.simulator.SimulatorResourceModel;
+
 /**
  * Interface for receiving notifications whenever there is a change in the
  * resource model.
diff --git a/service/simulator/java/sdk/src/org/oic/simulator/serviceprovider/ObserverInfo.java b/service/simulator/java/sdk/src/org/oic/simulator/serviceprovider/ObserverInfo.java
new file mode 100644 (file)
index 0000000..7f9b166
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * 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 for storing observer related information.
+ */
+package org.oic.simulator.serviceprovider;
+
+/**
+ * Class which represents the details of an observer.
+ */
+public class ObserverInfo {
+
+    private int    id;
+    private String address;
+    private int    port;
+
+    private ObserverInfo(int id, String address, int port) {
+        this.id = id;
+        this.address = address;
+        this.port = port;
+    }
+
+    /**
+     * This method is used to return the observer's id.
+     * 
+     * @return Observer's Id.
+     */
+    public int getId() {
+        return id;
+    }
+
+    /**
+     * This method is used to return the observer's address.
+     * 
+     * @return Observer's device address.
+     */
+    public String getAddress() {
+        return address;
+    }
+
+    /**
+     * This method is used to return the observer's port number.
+     * 
+     * @return Observer's port number.
+     */
+    public int getPort() {
+        return port;
+    }
+}
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
deleted file mode 100644 (file)
index fd69fba..0000000
+++ /dev/null
@@ -1,96 +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.
- */
-
-/**
- * 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
index 0df65f5..8112a0b 100644 (file)
@@ -25,6 +25,7 @@ package org.oic.simulator.serviceprovider;
 import java.util.Vector;
 
 import org.oic.simulator.IAutomation;
+import org.oic.simulator.SimulatorResourceModel;
 
 /**
  * This class represents a resource in the simulator. It provides a set of
@@ -39,12 +40,6 @@ public class SimulatorResourceServer {
 
     private long   nativeHandle;
 
-    /**
-     * Constructor for SimulatorResourceServer.
-     *
-     * @param nativeHandle
-     *            Handle to the native {@link SimulatorResourceServer} object.
-     */
     private SimulatorResourceServer(long nativeHandle) {
         this.nativeHandle = nativeHandle;
     }
@@ -335,6 +330,34 @@ public class SimulatorResourceServer {
     public native void removeAttribute(String key);
 
     /**
+     * Native function to set the observation callback.
+     * 
+     * @param observer
+     *            Listener to be notified when clients start/stop observing.
+     */
+    public native void setObserverCallback(IObserver observer);
+
+    /**
+     * Native function to get the details of a list of observers.
+     * 
+     * @return An array of {@link ObserverInfo} objects.
+     */
+    public native ObserverInfo[] getObserversList();
+
+    /**
+     * Native function which sends notification to a specific observer.
+     * 
+     * @param id
+     *            Observer's Id.
+     */
+    public native void notifyObserver(int id);
+
+    /**
+     * Native function which sends notification to all observers.
+     */
+    public native void notifyAllObservers();
+
+    /**
      * Native function to release the memory allocated to the native object for
      * SimulatorResourceServer.
      */