Class TemplateManager


  • public final class TemplateManager
    extends Object
    Manages templates and provides utilities to execute these templates against a NETCONF session.
    • Constructor Summary

      Constructors 
      Constructor Description
      TemplateManager()
      Constructs a new template manager and loads the default templates.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Node doRequest​(org.onosproject.netconf.NetconfSession session, String templateName)
      Execute the named NETCONF template against the specified session returning the /rpc-reply/data section of the response document as a Node.
      Node doRequest​(org.onosproject.netconf.NetconfSession session, String templateName, Map<String,​Object> templateContext)
      Execute the named NETCONF template with the given template context against the specified session returning the /rpc-reply/data section of the response document as a Node.
      Object doRequest​(org.onosproject.netconf.NetconfSession session, String templateName, Map<String,​Object> templateContext, String baseXPath, QName returnType)
      Executes the named NETCONF template against the specified session, returning the referenced XML node as the specified type.
      String get​(String templateName)
      Returns the named template.
      void load​(Class<? extends Object> reference, String pattern, String... templateNames)
      Loads the named templates into the template manager.
      void load​(String... templateMNames)
      Loads the named templates into the template manager using the default reference class and resource path pattern.
      void load​(String pattern, String... templateMNames)
      Loads the named templates into the template manager using the default reference class.
      String render​(String template, Map<String,​Object> context)
      Performs simple variable substitution into a string in likely the most inefficient way possible.
      void setRequestDriver​(TemplateRequestDriver driver)
      Sets the request driver for the template manager.
    • Constructor Detail

      • TemplateManager

        public TemplateManager()
        Constructs a new template manager and loads the default templates.
    • Method Detail

      • setRequestDriver

        public void setRequestDriver​(TemplateRequestDriver driver)
        Sets the request driver for the template manager.
        Parameters:
        driver - the driver to use
      • load

        public void load​(Class<? extends Object> reference,
                         String pattern,
                         String... templateNames)
        Loads the named templates into the template manager.
        Parameters:
        reference - the class reference from which to load resources
        pattern - pattern to convert template name to resource path
        templateNames - list of template to load
      • load

        public void load​(String... templateMNames)
        Loads the named templates into the template manager using the default reference class and resource path pattern.
        Parameters:
        templateMNames - list of template to load
      • load

        public void load​(String pattern,
                         String... templateMNames)
        Loads the named templates into the template manager using the default reference class.
        Parameters:
        pattern - pattern to convert template name to resource path
        templateMNames - list of template to load
      • get

        public String get​(String templateName)
        Returns the named template.
        Parameters:
        templateName - name of template to return
        Returns:
        template
      • render

        public String render​(String template,
                             Map<String,​Object> context)
        Performs simple variable substitution into a string in likely the most inefficient way possible.
        Parameters:
        template - template into which to substitute variables
        context - variable substitution map
        Returns:
        template rendered with variable substitution
      • doRequest

        public Object doRequest​(org.onosproject.netconf.NetconfSession session,
                                String templateName,
                                Map<String,​Object> templateContext,
                                String baseXPath,
                                QName returnType)
                         throws org.onosproject.netconf.NetconfException
        Executes the named NETCONF template against the specified session, returning the referenced XML node as the specified type.
        Parameters:
        session - NETCONF serssion
        templateName - name of NETCONF request template to execute
        templateContext - variable to values substitutions to be used against templates
        baseXPath - XPath expression to specify the returned document node
        returnType - expected return type of the referenced node
        Returns:
        XML document node referenced by the baseXPath
        Throws:
        org.onosproject.netconf.NetconfException - if any IO, XPath, or NETCONF exception occurs
      • doRequest

        public Node doRequest​(org.onosproject.netconf.NetconfSession session,
                              String templateName)
                       throws org.onosproject.netconf.NetconfException
        Execute the named NETCONF template against the specified session returning the /rpc-reply/data section of the response document as a Node.
        Parameters:
        session - NETCONF session
        templateName - name of NETCONF request template to execute
        Returns:
        XML document node that represents the NETCONF response data
        Throws:
        org.onosproject.netconf.NetconfException - if any IO, XPath, or NETCONF exception occurs
      • doRequest

        public Node doRequest​(org.onosproject.netconf.NetconfSession session,
                              String templateName,
                              Map<String,​Object> templateContext)
                       throws org.onosproject.netconf.NetconfException
        Execute the named NETCONF template with the given template context against the specified session returning the /rpc-reply/data section of the response document as a Node.
        Parameters:
        session - NETCONF session
        templateName - name of NETCONF request template to execute
        templateContext - variables to substitute into the template
        Returns:
        XML document node that represents the NETCONF response data
        Throws:
        org.onosproject.netconf.NetconfException - if any IO, XPath, or NETCONF exception occurs