public interface DpDataCallback
Dp.registerAnnotatedCallbacks(Object)
Modifier and Type | Method and Description |
---|---|
String |
callpoint()
The name of the callpoint
|
int |
create(DpTrans trans,
ConfObject[] kp)
This callback creates a new presence container, list entry or empty leaf.
|
boolean |
existsOptional(DpTrans trans,
ConfObject[] kp)
If we have presence containers or optional leafs (empty leafs) without a
type, we cannot use the getElem() callback to read such a leaf - since
the element is typeless.
|
int |
getAttrs(DpTrans trans,
ConfObject[] kp,
List<ConfAttributeValue> attrList)
This callback only needs to be implemented for callpoints specified for
configuration data, and only if attributes are enabled in the server
configuration (/confdConfig/enableAttributes set to true).
|
ConfObject |
getCase(DpTrans trans,
ConfObject[] kp,
ConfObject[] choice)
This callback method needs to return the currently chosen 'case' for a
'choice' construct.
|
ConfValue |
getElem(DpTrans trans,
ConfObject[] kp)
This callback method needs to return a specific leaf value.
|
ConfKey |
getIteratorKey(DpTrans trans,
ConfObject[] kp,
Object obj)
The following callback is used with the iterators above.
|
ConfObject[] |
getIteratorObject(DpTrans trans,
ConfObject[] kp,
Object obj)
The following callback is used with the iterators above.
|
List<ConfObject[]> |
getIteratorObjectList(DpTrans trans,
ConfObject[] kp,
Object obj,
Iterator<? extends Object> iterator)
This callback is used in place of getIteratorObject when a
List of objects is requested rather than a single instance. |
ConfObject[] |
getObject(DpTrans trans,
ConfObject[] kp)
The purpose of the callback is to return an array of values,
corresponding to a complete list entry in one swoop.
|
Iterator<? extends Object> |
iterator(DpTrans trans,
ConfObject[] kp)
This callback makes it possible for ConfD/NCS to traverse a set of list
entries.
|
DpDataFindNextIterator |
iterator(DpTrans trans,
ConfObject[] kp,
ConfFindNextType type,
ConfKey key)
This iterator method is a specialization of
DpDataCallback.iterator(DpTrans, ConfObject[])
in that it returns an extended iterator i.e. |
DpDataFindNextIterator |
iterator(DpTrans trans,
ConfObject[] kp,
ConfFindNextType type,
ConfKey key,
DpListFilter filter)
Variant of the DpDataFindNextIterator-returning iterator above that may
receive a DpListFilter instance which can be used to filter the list.
|
Iterator<? extends Object> |
iterator(DpTrans trans,
ConfObject[] kp,
DpListFilter filter)
Variant of iterator that may receive a DpListFilter which can be used to
filter the list.
|
int |
mask()
Mask of flags for each method that is supported by this callback:
DpDataCallback.M_EXISTS_OPTIONAL
DpDataCallback.M_GET_ELEM
DpDataCallback.M_GET_NEXT
DpDataCallback.M_SET_ELEM
DpDataCallback.M_CREATE
DpDataCallback.M_REMOVE
DpDataCallback.M_NUM_INSTANCES
DpDataCallback.M_GET_OBJECT
DpDataCallback.M_GET_NEXT_OBJECT
DpDataCallback.M_GET_CASE
DpDataCallback.M_SET_CASE
DpDataCallback.M_GET_ATTRS
DpDataCallback.M_SET_ATTR
DpDataCallback.M_MOVE_AFTER
DpDataCallback.M_WRITE_ALL
DpDataCallback.M_WANT_FILTER
|
int |
moveAfter(DpTrans trans,
ConfObject[] kp,
ConfKey prevkey)
This callback only needs to be implemented if we provide configuration
data that has YANG lists with a ordered-by user statement.
|
int |
numInstances(DpTrans trans,
ConfObject[] kp)
This callback can optionally be implemented.
|
int |
remove(DpTrans trans,
ConfObject[] kp)
This callback is used to remove a presence container, list entry or empty
leaf and all its sub elements.
|
int |
setAttr(DpTrans trans,
ConfObject[] kp,
ConfAttributeValue attr)
This callback also only needs to be implemented for callpoints specified
for configuration data, and only if attributes are enabled in the server
configuration (/confdConfig/enableAttributes set to true).
|
int |
setCase(DpTrans trans,
ConfObject[] kp,
ConfObject[] choice,
ConfTag caseval)
This callback method sets the currently chosen 'case' for a 'choice'
construct.
|
int |
setElem(DpTrans trans,
ConfObject[] kp,
ConfValue newval)
This callback writes a data leaf.
|
int |
writeAll(DpTrans trans,
ConfObject[] kp)
This callback method sets the currently chosen 'case' for a 'choice'
construct.
|
static final int M_EXISTS_OPTIONAL
DpDataCallback.existsOptional(DpTrans,ConfObject[])
method.static final int M_GET_ELEM
DpDataCallback.getElem(DpTrans,ConfObject[])
method.static final int M_GET_NEXT
DpDataCallback.iterator(DpTrans,ConfObject[])
method, and
converting the Java object into a key with the
DpDataCallback.getIteratorKey(DpTrans, ConfObject[], Object)
method.static final int M_SET_ELEM
DpDataCallback.setElem(DpTrans,ConfObject[],ConfValue)
method.static final int M_CREATE
DpDataCallback.create(DpTrans,ConfObject[])
method.static final int M_REMOVE
DpDataCallback.remove(DpTrans,ConfObject[])
method.static final int M_NUM_INSTANCES
DpDataCallback.numInstances(DpTrans,ConfObject[])
method.static final int M_GET_OBJECT
DpDataCallback.getObject(DpTrans,ConfObject[])
method.static final int M_GET_NEXT_OBJECT
DpDataCallback.iterator(DpTrans,ConfObject[])
method, and converting the Java
object into an array of ConfValues with the
DpDataCallback.getIteratorObject(DpTrans, ConfObject[], Object)
method.static final int M_GET_CASE
DpDataCallback.getCase(DpTrans, ConfObject[], ConfObject[])
method.static final int M_SET_CASE
DpDataCallback.setCase(DpTrans, ConfObject[], ConfObject[], ConfTag)
method.static final int M_GET_ATTRS
DpDataCallback.getAttrs(DpTrans, ConfObject[], List)
method.static final int M_SET_ATTR
DpDataCallback.setAttr(DpTrans, ConfObject[], ConfAttributeValue)
method.static final int M_MOVE_AFTER
DpDataCallback.moveAfter(DpTrans, ConfObject[], ConfKey)
method.static final int M_WRITE_ALL
DpDataCallback.writeAll(DpTrans, ConfObject[])
method.static final int M_WANT_FILTER
static final int M_ALL
String callpoint()
int mask()
DpDataCallback.M_EXISTS_OPTIONAL
DpDataCallback.M_GET_ELEM
DpDataCallback.M_GET_NEXT
DpDataCallback.M_SET_ELEM
DpDataCallback.M_CREATE
DpDataCallback.M_REMOVE
DpDataCallback.M_NUM_INSTANCES
DpDataCallback.M_GET_OBJECT
DpDataCallback.M_GET_NEXT_OBJECT
DpDataCallback.M_GET_CASE
DpDataCallback.M_SET_CASE
DpDataCallback.M_GET_ATTRS
DpDataCallback.M_SET_ATTR
DpDataCallback.M_MOVE_AFTER
DpDataCallback.M_WRITE_ALL
DpDataCallback.M_WANT_FILTER
ConfValue getElem(DpTrans trans, ConfObject[] kp) throws DpCallbackException
The callback must return a ConfValue
on
success. The implementation of getElem
must
be prepared to return all the leafs including the key(s).
When ConfD/NCS invokes getElem
on a key leaf it is
an existence test. The application should verify whether the
object exists or not. If an object doesn't exists this method
must return null.
trans
- Transactionkp
- The keypath structured as a reversed array of
ConfTag
and/or
ConfKey
objectsDpCallbackException
- Callback method failure.Iterator<? extends Object> iterator(DpTrans trans, ConfObject[] kp) throws DpCallbackException
This method is a specific java construct which is actually not
registered on the server side. Instead it is a mandatory tool for the
GET_NEXT/GET_NEXT_OBJECT functionality to work. If either the
DpDataCallback.getIteratorKey(DpTrans, ConfObject[], Object)
or the DpDataCallback.getIteratorObject(DpTrans, ConfObject[], Object)
is
registered this method must also be registered.
The Iterator is stored internally by Dp
and
when a GET_NEXT/GET_NEXT_OBJECT request is issued the iterator
is called to get the next element in the list.
Note that the iterator is free to return any POJO Object and it is instead the responsibility of the getIteratorKey or getIteratorObject to render the return values.
trans
- DpTrans object for current transactionkp
- Keypath for the list that is subject for traversalDpCallbackException
- if Callback method failed.Iterator<? extends Object> iterator(DpTrans trans, ConfObject[] kp, DpListFilter filter) throws DpCallbackException
trans
- DpTrans object for current transactionkp
- Keypath for the list that is subject for traversalfilter
- DpListFilter instance for filtering elements, or null
if no filtering is requestedDpCallbackException
- if Callback method failed.DpDataFindNextIterator iterator(DpTrans trans, ConfObject[] kp, ConfFindNextType type, ConfKey key) throws DpCallbackException
DpDataCallback.iterator(DpTrans, ConfObject[])
in that it returns an extended iterator i.e. DpFindNextIterator.
This iterator does the same job as the normal Java Iterator
but it also has a
DpDataFindNextIterator.findNext(DpTrans,
ConfObject[], ConfFindNextType, ConfKey)
method that is called if FIND_NEXT/FIND_NEXT_OBJECT is called.
Note that this iterator is expected to be able to traverse using
next()/hasNext() functions after a initial findNext(...) has been
called and it will take precedence over the standard iterator method.trans
- DpTrans object for current transactionkp
- Keypath for the list that is subject for traversaltype
- ConfFindNextType
describing the findNext behaviorkey
- ConfKey which constitutes the search criteriaDpCallbackException
- if Callback method failed.DpCallbackException
DpDataFindNextIterator iterator(DpTrans trans, ConfObject[] kp, ConfFindNextType type, ConfKey key, DpListFilter filter) throws DpCallbackException
trans
- DpTrans object for current transactionkp
- Keypath for the list that is subject for traversaltype
- ConfFindNextType
describing the findNext behaviorkey
- ConfKey which constitutes the search criteriafilter
- DpListFilter instance for filtering elements, or null
if no filtering is requestedDpCallbackException
- if Callback method failed.DpCallbackException
ConfKey getIteratorKey(DpTrans trans, ConfObject[] kp, Object obj) throws DpCallbackException
trans
- Transactionkp
- The keypathobj
- The object returned by the iteratorDpCallbackException
- Callback method failed.ConfObject[] getIteratorObject(DpTrans trans, ConfObject[] kp, Object obj) throws DpCallbackException
getIteratorObject
method will be invoked and it must
return either of the following:
ConfValue
s describing the object
ConfXMLParam
s describing the
object
ConfNoExists
element. Each list contained within
the object must also be represented by a single ConfNoExists, regardless
of whether it contains any elements or not. If a ConfXMLParam array is
used, lists and missing values should simply be omitted from the array.trans
- Transactionkp
- The keypathobj
- The object returned by the iteratorDpCallbackException
- Callback method failed.List<ConfObject[]> getIteratorObjectList(DpTrans trans, ConfObject[] kp, Object obj, Iterator<? extends Object> iterator) throws DpCallbackException
This callback is used in place of getIteratorObject when a
List
of objects is requested rather than a single instance.
This is of interest when lists are big and performance requires larger
chunks to be sent at once.
The first object from the iterator is already retrieved and delivered
in the obj
parameter. It is mandatory to put this object
first in the list. An arbitrary number of additional objects can then be
retrieved using the iterator.
The returned list should contain either ConfValue
arrays or
ConfXMLParam
arrays. See
DpDataCallback.getIteratorObject(com.tailf.dp.DpTrans, com.tailf.conf.ConfObject[], java.lang.Object)
for more information on how to format
the return values.
It is important to return all objects retrieved by the iterator. Any item that is retrieved but not returned will be lost.
To override the global object cache timeout for the response, return
an object of the type NextObjectList
<ConfObject[]>, for
example an instance of NextObjectArrayList
<ConfObject[]>
where you have set the desired timeout via the
NextObjectArrayList.setTimeout(int)
method.
For backwards compatibility reasons, you can return a List<ConfObject[]> instance of a class that doesn't implement the NextObjectList interface, in which case the default object cache timeout will be in effect for the response.
Also for backwards compatibility reasons, it is acceptable for this
method to return a List<ConfValue
[]> instead of a
List<ConfObject[]>.
trans
- Transactionkp
- The keypathobj
- The first object returned by the iteratoriterator
- The iterator to optionally retrieve more objects fromDpCallbackException
- Callback method failsint setElem(DpTrans trans, ConfObject[] kp, ConfValue newval) throws DpCallbackException
trans
- Transactionkp
- The keypathnewval
- The new value to be setConf.REPLY_OK
or Conf.REPLY_ACCUMULATE
DpCallbackException
- Callback method failed.int create(DpTrans trans, ConfObject[] kp) throws DpCallbackException
trans
- Transactionkp
- The keypathConf.REPLY_OK
or Conf.REPLY_ACCUMULATE
DpCallbackException
- Callback method failed.int remove(DpTrans trans, ConfObject[] kp) throws DpCallbackException
trans
- Transactionkp
- The keypathConf.REPLY_OK
or Conf.REPLY_ACCUMULATE
DpCallbackException
- Callback method failed.int numInstances(DpTrans trans, ConfObject[] kp) throws DpCallbackException
trans
- Transactionkp
- The keypathDpCallbackException
- Callback method failed.ConfObject[] getObject(DpTrans trans, ConfObject[] kp) throws DpCallbackException
trans
- Transactionkp
- The keypathDpCallbackException
- Callback method failed.boolean existsOptional(DpTrans trans, ConfObject[] kp) throws DpCallbackException
Additionally, the getElem() callback cannot be used as an existence test by requesting a key leaf for entries in operational data lists without keys, or for leaf-list entries (unless the deprecated leafListAsLeaf() flag is used), since there are no key leafs in those cases.
In all the above cases, we need to implement the existsOptional() callback method.
trans
- Transactionkp
- The keypathtrue
or false
DpCallbackException
- Callback method failed.ConfObject getCase(DpTrans trans, ConfObject[] kp, ConfObject[] choice) throws DpCallbackException
trans
- Transactionkp
- The keypathchoice
- The choice name(s) as an array of ConfTagDpCallbackException
- Callback method failed.int setCase(DpTrans trans, ConfObject[] kp, ConfObject[] choice, ConfTag caseval) throws DpCallbackException
trans
- Transactionkp
- The keypathchoice
- The choice name(s) as an array of ConfTagcaseval
- The name of the caseConf.REPLY_OK
DpCallbackException
- Callback method failed.int getAttrs(DpTrans trans, ConfObject[] kp, List<ConfAttributeValue> attrList) throws DpCallbackException, IllegalArgumentException
ConfAttributeType.TAGS
(values are ConfList of ConfBuf)
ConfAttributeType.ANNOTATION
(value is ConfBuf)
ConfAttributeType.INACTIVE
(not used)
ConfAttributeType.ORIGIN
(value is Confidentityref)
The attrs parameter is an list of ConfAttributeValue objects with
attributeType set to requested attribute and attributeValue set to null.
If the list is empty all attributes are requested.
If the node given by kp does not exist, the callback should throw an
IllegalArgumentException, otherwise it should set values to the elements
of the attrs list, or even add attributes if the list was empty.
Must return Conf.REPLY_OK
on success or
Conf.REPLY_DELAYED_RESPONSE
.
On error a DpCallbackException
should be throwntrans
- current transactionkp
- keypath for node to set attributes onattrList
- list of ConfAttributeValue to populate as resultConf.REPLY_OK
or
Conf.REPLY_DELAYED_RESPONSE
on successful callDpCallbackException
- on unsuccessful callIllegalArgumentException
int setAttr(DpTrans trans, ConfObject[] kp, ConfAttributeValue attr) throws DpCallbackException
trans
- current transactionkp
- keypath for node to set attributes onattr
- ConfAttributeValue to set valueDpCallbackException
int moveAfter(DpTrans trans, ConfObject[] kp, ConfKey prevkey) throws DpCallbackException
trans
- current transactionkp
- keypath for entry to moveprevkey
- position to entry which should be before the entry to moveConf.REPLY_OK
DpCallbackException
int writeAll(DpTrans trans, ConfObject[] kp) throws DpCallbackException
trans
- Transactionkp
- The keypathConf.REPLY_OK
DpCallbackException
- Callback method failed.