Interface IfaceAwareNodeService<T extends BinaryMsgIface,N>
- All Superinterfaces:
BinaryMsgIfaceFactory
Instead of a service creating a IfaceClient for the adapter connection, it
defines a node object, where one node object can be created for each node in the device.
The IfaceCilent is then placed in the node object and accessed by the nodeId
of the node to operate on.
Management of the node cache is as simple as creating a class to represent a node
and then adding a ManifestNodeCache in the service that will hold the nodes.
This must be accessible via getNodeCache() to work with this interface.
Once in place, any requests for a node via a nodeId will pass through this cache.
The cache will perform validation on the nodeId, ensuring invalid nodeId's are
ignored and creating a new node instance for the cache when needed.
The getIfaceName() method should return the name of the iface to bind to.
As adapters connect, this name will be used to automatically discover matching
ifaces and route them to this service where they will automatically create a
matching node in the cache and call createIface(). This method simply
creates an instance of the iface, passing the IfaceClient from the node
to the iface to bind them together.
- Since:
- 9
- Version:
- 9
-
Method Summary
Modifier and TypeMethodDescriptioncreateIface(BinaryMsgSession session, N node) Return an instance of the custom iface for the specified node.default TcreateIface(String name, BinaryMsgSession session) Implementation ofBinaryMsgIfaceFactorythat will forward the create request to the specific node object.Return the name of the iface for this service.default NReturn a node instance for the specifiednodeIdbut only if the instance already exists.Return an instance ofManifestNodeCacheto hold the node data.default NgetOrCreateNode(NodeId nodeId) Given a nodeId, return a node instance for the id, creating a new node if needed.
-
Method Details
-
getNodeCache
ManifestNodeCache<N> getNodeCache()Return an instance ofManifestNodeCacheto hold the node data.- Since:
- 9
-
getIfaceName
String getIfaceName()Return the name of the iface for this service.- Since:
- 9
-
getOrCreateNode
Given a nodeId, return a node instance for the id, creating a new node if needed. Given that node creation is backed byManifestNodeCachewhich valiates nodeId's against the list of possible nodes defined in the device manifest, this may still return null if an invalid nodeId is specified.- Parameters:
nodeId- id of the node to bind an iface to- Since:
- 9
-
getNode
Return a node instance for the specifiednodeIdbut only if the instance already exists. This can be used in normal use cases where checking the existence of an instance shouldn't cause the instance to be created.- Parameters:
nodeId- the nodeId to return an instance for- Since:
- 9
-
createIface
Implementation ofBinaryMsgIfaceFactorythat will forward the create request to the specific node object.- Specified by:
createIfacein interfaceBinaryMsgIfaceFactory- Parameters:
name- the name of the interfacesession- the session to back the interface- Returns:
- the iface or null
- Since:
- 9
-
createIface
Return an instance of the custom iface for the specified node. This is called when the adapter for the service connects to java. This will be called every time the adapter connects to the service to bind a new iface.- Since:
- 9
-