From: Markus Jung Date: Wed, 8 Jul 2015 13:26:56 +0000 (+0900) Subject: Javadoc for Java Bundle-API, Modified public access API X-Git-Tag: 0.9.2-RC1^2~55 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=26fb5f36b667881811c1959af96d697b7b07cc46;p=contrib%2Fiotivity.git Javadoc for Java Bundle-API, Modified public access API Change-Id: Ie1e50a3f3edb5f59ee331fabfcf8aee160d692f8 Signed-off-by: Markus Jung Reviewed-on: https://gerrit.iotivity.org/gerrit/1589 Tested-by: jenkins-iotivity Reviewed-by: Uze Choi --- diff --git a/service/resource-manipulation/modules/resourceContainer/bundle-java-api/src/main/java/org/iotivity/resourcecontainer/bundle/api/BaseActivator.java b/service/resource-manipulation/modules/resourceContainer/bundle-java-api/src/main/java/org/iotivity/resourcecontainer/bundle/api/BaseActivator.java index a6890ab..361a963 100644 --- a/service/resource-manipulation/modules/resourceContainer/bundle-java-api/src/main/java/org/iotivity/resourcecontainer/bundle/api/BaseActivator.java +++ b/service/resource-manipulation/modules/resourceContainer/bundle-java-api/src/main/java/org/iotivity/resourcecontainer/bundle/api/BaseActivator.java @@ -1,12 +1,41 @@ +//****************************************************************** +// +// 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.resourcecontainer.bundle.api; import java.util.List; import java.util.Vector; +/** + * The BaseActivator implements the native interface to the resource container. + * It loads the resource container library and provies native methods + * that can be used to register and unregister resources. + */ public class BaseActivator implements BundleActivator { private String bundleId; private Vector bundleResources = new Vector(); + /** + * Creates an instance of the BaseActivator + * @param bundleId unique bundle identifier (e.g., oic.bundle.hue) + */ public BaseActivator(String bundleId) { this.bundleId = bundleId; @@ -20,10 +49,16 @@ public class BaseActivator implements BundleActivator { } } + /** + * Bundle activation needs to be provided by the subclass. + */ public void activateBundle() { } + /** + * Deactivates the bundle and unregisters its resources. + */ public void deactivateBundle() { System.out.println("Deactivating bundle (Base Activator)."); for(BundleResource bundleResource : bundleResources){ @@ -31,6 +66,10 @@ public class BaseActivator implements BundleActivator { } } + /** + * Registers a bundle resource at the resource container. + * @param resource bundle resource instance that should be made available as OIC resource + */ public void registerResource(BundleResource resource) { bundleResources.add(resource); registerJavaResource(resource, resource.getAttributeKeys(), bundleId, @@ -38,6 +77,10 @@ public class BaseActivator implements BundleActivator { resource.getName()); } + /** + * Wrapper to retrieve the resource configuration of the bundle resources. + * @return List of resource configurations. + */ public List getConfiguredBundleResources() { int configuredResources = getNumberOfConfiguredResources(bundleId); @@ -52,20 +95,42 @@ public class BaseActivator implements BundleActivator { return configs; } + /** + * Unregisters a resource from the resource container. + */ public void unregisterResource(BundleResource resource) { - System.out.println("Making native call."); unregisterJavaResource(resource, resource.getURI()); } - public native void registerJavaResource(BundleResource resource, + /** + * Native method that calls to the resource container. + * @param attributes String array of attribute names + * @param bundleId unique bundle identifier + * @param uri Uri that should be used to register the resource + */ + private native void registerJavaResource(BundleResource resource, String[] attributes, String bundleId, String uri, String resourceType, String name); - public native void unregisterJavaResource(BundleResource resource, String uri); - - public native int getNumberOfConfiguredResources(String bundleId); - - public native String[] getConfiguredResourceParams(String bundleId, + /** + * Native method that calls to the resource container. + * @param resource + * @param uri + */ + private native void unregisterJavaResource(BundleResource resource, String uri); + + /** + * Native method to retrieve the number of configured resources. + * @param bundleId unique bundle identifier + */ + private native int getNumberOfConfiguredResources(String bundleId); + + /** + * Native method to retrieve the configured resource parameters. + * @param bundleId unique bundle identifier + * @param resId get the resource params for a certain resource + */ + private native String[] getConfiguredResourceParams(String bundleId, int resId); } diff --git a/service/resource-manipulation/modules/resourceContainer/bundle-java-api/src/main/java/org/iotivity/resourcecontainer/bundle/api/BundleActivator.java b/service/resource-manipulation/modules/resourceContainer/bundle-java-api/src/main/java/org/iotivity/resourcecontainer/bundle/api/BundleActivator.java index 825c258..67d5692 100644 --- a/service/resource-manipulation/modules/resourceContainer/bundle-java-api/src/main/java/org/iotivity/resourcecontainer/bundle/api/BundleActivator.java +++ b/service/resource-manipulation/modules/resourceContainer/bundle-java-api/src/main/java/org/iotivity/resourcecontainer/bundle/api/BundleActivator.java @@ -1,15 +1,57 @@ +//****************************************************************** +// +// 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.resourcecontainer.bundle.api; import java.util.List; +/** + * The BundleActivator interface needs to be implemented. A bundle provider + * can directly extend fromt the BaseActivator. + */ public interface BundleActivator { + /** + * Activates the bundle and creates all resources. + */ public void activateBundle(); + /** + * Deactivates the bundle and destroys all resources. + */ public void deactivateBundle(); + /** + * Registers a single resource instance at the resource container + * @param resource Instance of a BundleResource + */ public void registerResource(BundleResource resource); + /** + * Unregisters a single resource instance at the resource container + * @param resource Instance of a BundleResource + */ public void unregisterResource(BundleResource resource); + /** + * List the configuration of the bundle resources. + * @return List of configuration for each resource + */ public List getConfiguredBundleResources(); } diff --git a/service/resource-manipulation/modules/resourceContainer/bundle-java-api/src/main/java/org/iotivity/resourcecontainer/bundle/api/BundleResource.java b/service/resource-manipulation/modules/resourceContainer/bundle-java-api/src/main/java/org/iotivity/resourcecontainer/bundle/api/BundleResource.java index 90a787e..5f66bfd 100644 --- a/service/resource-manipulation/modules/resourceContainer/bundle-java-api/src/main/java/org/iotivity/resourcecontainer/bundle/api/BundleResource.java +++ b/service/resource-manipulation/modules/resourceContainer/bundle-java-api/src/main/java/org/iotivity/resourcecontainer/bundle/api/BundleResource.java @@ -1,52 +1,128 @@ +//****************************************************************** +// +// 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.resourcecontainer.bundle.api; import java.util.HashMap; import java.util.Set; +/** + * Basic BundleResource that should be used as a base class + * by a bundle resources. A concrete technology has + * to override the setAttribute and getAttribute method + * and map the according reads and writes to the technology specific + * messages. + */ public abstract class BundleResource { - protected String m_name, m_uri, m_resourceType, m_address; + protected String m_name, m_uri, m_resourceType, m_address; protected HashMap m_attributes; + /** + * Initialize the internal attribute structure. + */ protected abstract void initAttributes(); + /** + * Set the attribute (map to a send command for the according protocol) + * @param key name of the attribute to be set + * @param value new value of the attribute + */ public abstract void setAttribute(String key, String value); + /** + * Retrieve the attribute (map to read command for the according protocol) + * @param key name of the attribute to be read + * @return Value of the attribute + */ public abstract String getAttribute(String key); + /** + * Attribute keys provided through by the bundle resource. + * @return Name of attribute keys as string array + */ public String[] getAttributeKeys() { Set keys = m_attributes.keySet(); return keys.toArray(new String[keys.size()]); } + /** + * Setter for the uri property + * @param uri URI of the resource + */ public void setURI(String uri) { this.m_uri = uri; } + /** + * Returns the URI of the resource + * @return + */ public String getURI() { return m_uri; } + /** + * Sets the resource type property + * @param resourceType OIC resource type + */ public void setResourceType(String resourceType) { this.m_resourceType = resourceType; } + /** + * Getter for the resource type + * @return OIC resource type + */ public String getResourceType() { return m_resourceType; } + /** + * Sets the technology specific address information (e.g., ZigBee short or long identifier) + * @param address + */ public void setAddress(String address) { this.m_address = address; } + /** + * Returns the technology specific address information + * @return + */ public String getAddress() { return m_address; } + /** + * Sets the name property of the resource + * @param name + */ public void setName(String name) { this.m_name = name; } + /** + * Returns the name property of the resource + * @return + */ public String getName() { return m_name; } diff --git a/service/resource-manipulation/modules/resourceContainer/bundle-java-api/src/main/java/org/iotivity/resourcecontainer/bundle/api/ProtocolBridgeConnector.java b/service/resource-manipulation/modules/resourceContainer/bundle-java-api/src/main/java/org/iotivity/resourcecontainer/bundle/api/ProtocolBridgeConnector.java index d442d3c..5302846 100644 --- a/service/resource-manipulation/modules/resourceContainer/bundle-java-api/src/main/java/org/iotivity/resourcecontainer/bundle/api/ProtocolBridgeConnector.java +++ b/service/resource-manipulation/modules/resourceContainer/bundle-java-api/src/main/java/org/iotivity/resourcecontainer/bundle/api/ProtocolBridgeConnector.java @@ -1,7 +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. +// +//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + package org.iotivity.resourcecontainer.bundle.api; +/** + * The ProtocolBridgeConnector interface should be implemented + * by a bundle provider and it should be called + * at bundle activation and deactivation. + */ public interface ProtocolBridgeConnector { + /** + * Connects to a specific protocol (e.g, establishes a communication session) + */ public void connect(); + /** + * Disconnects from a specific protocol + */ public void disconnect(); } diff --git a/service/resource-manipulation/modules/resourceContainer/bundle-java-api/src/main/java/org/iotivity/resourcecontainer/bundle/api/ResourceConfig.java b/service/resource-manipulation/modules/resourceContainer/bundle-java-api/src/main/java/org/iotivity/resourcecontainer/bundle/api/ResourceConfig.java index 683e308..cf35f4e 100644 --- a/service/resource-manipulation/modules/resourceContainer/bundle-java-api/src/main/java/org/iotivity/resourcecontainer/bundle/api/ResourceConfig.java +++ b/service/resource-manipulation/modules/resourceContainer/bundle-java-api/src/main/java/org/iotivity/resourcecontainer/bundle/api/ResourceConfig.java @@ -1,12 +1,43 @@ +//****************************************************************** +// +// 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.resourcecontainer.bundle.api; +/** + * This class holds the configuration parameters for a single resource instance provided + * by the resource bundle. + */ public class ResourceConfig { private String m_name, m_uri, m_resourceType, m_address; + /** + * Empty constructor for resoure config. + */ public ResourceConfig() { } + /** + * Creates a new resource config instance. + * @param params Resource parameters as array. 1. Name, 2. URI, 3. Resource Type, 4. Address + */ public ResourceConfig(String[] params) { m_name = params[0]; m_uri = params[1]; @@ -14,35 +45,67 @@ public class ResourceConfig { m_address = params[3]; } - public String getM_name() { + /** + * Returns the configured name + * @return name property + */ + public String getName() { return m_name; } - public void setM_name(String m_name) { + /** + * Sets the name + * @param m_name + */ + public void setName(String m_name) { this.m_name = m_name; } - public String getM_uri() { + /** + * Returns the configured URI + * @return Configured URI + */ + public String getURI() { return m_uri; } - public void setM_uri(String m_uri) { + /** + * Sets the configured URI + * @param m_uri Configuration URI + */ + public void setURI(String m_uri) { this.m_uri = m_uri; } - public String getM_resourceType() { + /** + * Returns the configured resource type + * @param m_uri configured resource type + */ + public String getResourceType() { return m_resourceType; } - public void setM_resourceType(String m_resourceType) { + /** + * Sets the configured resource type + * @param m_resourceType updates the configured resource type + */ + public void setResourceType(String m_resourceType) { this.m_resourceType = m_resourceType; } - public String getM_address() { + /** + * Returns the configured address + * @return Configured address + */ + public String getAddress() { return m_address; } - public void setM_address(String m_address) { + /** + * Sets the configured address + * @param m_address Configured address + */ + public void setAddress(String m_address) { this.m_address = m_address; }