public class ActionCallbackProxy extends Object implements DpActionCallback
DpActionCallback
interface and delegates calls to the registered callback POJO with annotated
methodsM_ABORT, M_ACTION, M_COMMAND, M_COMPLETION, M_INIT
Constructor and Description |
---|
ActionCallbackProxy(Object backupObject,
String callPoint)
Constructor to Action Callback proxys.
|
Modifier and Type | Method and Description |
---|---|
void |
abort(DpActionTrans actx)
The abort() callback will be called for user initiated abort of an
action.
|
ConfXMLParam[] |
action(DpActionTrans actx,
ConfTag name,
ConfObject[] kp,
ConfXMLParam[] params)
The action() callback receives all the parameters pertaining to the
action: The name argument is a pointer to the action name as defined in
YANG model, the kp argument gives the path through the XML
tree, and finally the params argument is a representation of the
params element of the XML instance document provided with the invocation.
|
String |
actionpoint()
Return the name of the action point.
|
void |
addActionCapability(ActionCBType actionCBType)
Add action capability from annotated callType used to register
capabilities on the server
|
void |
addActionMethod(String name,
Method method)
Add callback action method to proxy
|
String[] |
command(DpActionTrans actx,
String cmdname,
String cmdpath,
String[] params)
The command() callback is invoked for CLI callback commands.
|
Completion |
completion(DpActionTrans actx,
char cliStyle,
String token,
char completionChar,
ConfObject[] kp,
String cmdPath,
String cmdParamId,
ConfQname simpleType,
String extra)
The completion() callback is invoked for CLI completion
and information.
|
static ActionCallbackProxy[] |
getActionCallbackProxys(Object obj)
Get array of proxy objects from registered POJO callback.
|
Object |
getBackupObject()
Retrieve the callback POJO
|
String |
getCallPoint()
Retrieve the callback callpoint
|
void |
init(DpActionTrans actx)
Similar to the init() callback for external data bases.
|
int |
mask()
Mask of flags for each method that is supported by this callback
|
public Object getBackupObject()
public String getCallPoint()
public void addActionMethod(String name, Method method)
name
- canonical action namemethod
- registered callback methodpublic void addActionCapability(ActionCBType actionCBType)
actionCBType
- action typepublic int mask()
DpActionCallback
mask
in interface DpActionCallback
public ConfXMLParam[] action(DpActionTrans actx, ConfTag name, ConfObject[] kp, ConfXMLParam[] params) throws DpCallbackException
DpActionCallback
action
in interface DpActionCallback
actx
- Action transaction contextname
- Action namekp
- Keypath array. kp[0] is the leaf.params
- Action parametersDpCallbackException
- Callback method failed.public String actionpoint()
DpActionCallback
actionpoint
in interface DpActionCallback
public String[] command(DpActionTrans actx, String cmdname, String cmdpath, String[] params) throws DpCallbackException
DpActionCallback
command
in interface DpActionCallback
actx
- Action transaction contextcmdname
- Command namecmdpath
- Command pathparams
- Command parametersDpCallbackException
- Callback method failedpublic void init(DpActionTrans actx) throws DpCallbackException
DpActionCallback
init
in interface DpActionCallback
actx
- Action transaction contextDpCallbackException
- Callback method failed.public void abort(DpActionTrans actx) throws DpCallbackException
DpActionCallback
DpActionTrans.getActionState()
. In this case the abort() can
have an empty implementation since the state will implicitly be set to
DpActionTrans.STATE_ABORTED
.
However the above scenario is often not sufficient because the action()
execution thread is busy and not able to check the state. In this case,
the abort() callback needs to get hold of the execution action() thread
and intervene to stop the execution.
To be able to do this there need to be some information carried in
DpActionTrans instance that makes this possible. Here using the
DpTrans.getTransactionUserOpaque()
is recommended.
For instance the action() callback can initially call
DpTrans.setTransactionUserOpaque(Object)
with the object
being the current thread using Thread.currentThread(). The abort()
can then retrieve that Thread using
DpTrans.getTransactionUserOpaque()
and make a Thread.interrupt()
call, under the assumption that
the action() implementation is sensitive to interrupts and handles
InterruptedException.abort
in interface DpActionCallback
actx
- The DpActionTrans instance, same as for the running action.DpCallbackException
public Completion completion(DpActionTrans actx, char cliStyle, String token, char completionChar, ConfObject[] kp, String cmdPath, String cmdParamId, ConfQname simpleType, String extra) throws DpCallbackException
DpActionCallback
Completion
class instance.
It is invoked for yang model elements with the directive
tailf:cli-completion-actionpoint as well as model list elements with
directives tailf:cli-custom-range-actionpoint or
tailf:cli-custom-range-enumerator. Also for the corresponding directives
in a clispec.completion
in interface DpActionCallback
actx
- Action transaction contextcliStyle
- One of J, C or I for juniper, cisco-xr or cisco-iostoken
- Parameter of the CLI command line that the callback
invocation pertains tocompletionChar
- The char the user typed on of '\t', '?' or ' 'kp
- Identifies model element path that the callback pertains
to or null if not applicablecmdPath
- String giving the full path of the commandcmdParamId
- The cli-completion-id if such is given in yang model
or clispec.simpleType
- If the invocation pertains to an element that has a
type definition, the simpleType identifies the typeextra
- The extra argument is currently unused (always null).DpCallbackException
public static ActionCallbackProxy[] getActionCallbackProxys(Object obj) throws DpCallbackException
obj
- registered callback POJODpCallbackException