Class ActionCallbackProxy

Object
com.tailf.dp.annotations.ActionCallbackProxy
All Implemented Interfaces:
DpActionCallback

public class ActionCallbackProxy extends Object implements DpActionCallback
Callback proxy for Action Callbacks. Implements the DpActionCallback interface and delegates calls to the registered callback POJO with annotated methods
Since:
3.2.0
  • Constructor Details

    • ActionCallbackProxy

      public ActionCallbackProxy(Object backupObject, String callPoint)
      Constructor to Action Callback proxys. Used internally.
      Parameters:
      backupObject - registered callback POJO
      callPoint - string describing the callpoint for this callback
  • Method Details

    • getBackupObject

      public Object getBackupObject()
      Retrieve the callback POJO
      Returns:
      Object registered callback object
    • getCallPoint

      public String getCallPoint()
      Retrieve the callback callpoint
      Returns:
      callpoint string
    • addActionMethod

      public void addActionMethod(String name, Method method)
      Add callback action method to proxy
      Parameters:
      name - canonical action name
      method - registered callback method
    • addActionCapability

      public void addActionCapability(ActionCBType actionCBType)
      Add action capability from annotated callType used to register capabilities on the server
      Parameters:
      actionCBType - action type
    • mask

      public int mask()
      Description copied from interface: DpActionCallback
      Mask of flags for each method that is supported by this callback
      Specified by:
      mask in interface DpActionCallback
    • action

      public ConfXMLParam[] action(DpActionTrans actx, ConfTag name, ConfObject[] kp, ConfXMLParam[] params) throws DpCallbackException
      Description copied from interface: DpActionCallback
      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.
      Specified by:
      action in interface DpActionCallback
      Parameters:
      actx - Action transaction context
      name - Action name
      kp - Keypath array. kp[0] is the leaf.
      params - Action parameters
      Throws:
      DpCallbackException - Callback method failed.
    • actionpoint

      public String actionpoint()
      Description copied from interface: DpActionCallback
      Return the name of the action point.
      Specified by:
      actionpoint in interface DpActionCallback
    • command

      public String[] command(DpActionTrans actx, String cmdname, String cmdpath, String[] params) throws DpCallbackException
      Description copied from interface: DpActionCallback
      The command() callback is invoked for CLI callback commands. As the parameters in this case are all in string form, they are passed as an array of strings.
      Specified by:
      command in interface DpActionCallback
      Parameters:
      actx - Action transaction context
      cmdname - Command name
      cmdpath - Command path
      params - Command parameters
      Throws:
      DpCallbackException - Callback method failed
    • init

      public void init(DpActionTrans actx) throws DpCallbackException
      Description copied from interface: DpActionCallback
      Similar to the init() callback for external data bases. This socket will be used for the invocation of the action() callback, which implements the actual action. However note that unlike the callbacks for external data bases and validation, both callbacks are registered for each action point (i.e. different action points can have different init() callbacks), and there is no finish() callback - the action is completed when the action() callback returns.
      Specified by:
      init in interface DpActionCallback
      Parameters:
      actx - Action transaction context
      Throws:
      DpCallbackException - Callback method failed.
    • abort

      public void abort(DpActionTrans actx) throws DpCallbackException
      Description copied from interface: DpActionCallback
      The abort() callback will be called for user initiated abort of an action. The abort() callback will be called in a separate thread from the thread that is executing the action() callback. It is the responsibility of the abort() call to stop the action thread execution. There are two ways that the action() execution could be terminated. The simple solution is that the action() implementation itself checks the action transaction state by a call to 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.
      Specified by:
      abort in interface DpActionCallback
      Parameters:
      actx - The DpActionTrans instance, same as for the running action.
      Throws:
      DpCallbackException
    • completion

      public Completion completion(DpActionTrans actx, char cliStyle, String token, char completionChar, ConfObject[] kp, String cmdPath, String cmdParamId, ConfQname simpleType, String extra) throws DpCallbackException
      Description copied from interface: DpActionCallback
      The completion() callback is invoked for CLI completion and information. It must result in a 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.
      Specified by:
      completion in interface DpActionCallback
      Parameters:
      actx - Action transaction context
      cliStyle - One of J, C or I for juniper, cisco-xr or cisco-ios
      token - Parameter of the CLI command line that the callback invocation pertains to
      completionChar - The char the user typed on of '\t', '?' or ' '
      kp - Identifies model element path that the callback pertains to or null if not applicable
      cmdPath - String giving the full path of the command
      cmdParamId - 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 type
      extra - The extra argument is currently unused (always null).
      Returns:
      Completion object with the relevant completion structure.
      Throws:
      DpCallbackException
    • getActionCallbackProxys

      public static ActionCallbackProxy[] getActionCallbackProxys(Object obj) throws DpCallbackException
      Get array of proxy objects from registered POJO callback. Used internally at callback registration
      Parameters:
      obj - registered callback POJO
      Returns:
      array of ActionCallbackProxy
      Throws:
      DpCallbackException