Class TemplateManager


  • public final class TemplateManager
    extends java.lang.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
      org.w3c.dom.Node doRequest​(org.onosproject.netconf.NetconfSession session, java.lang.String templateName)
      Execute the named NETCONF template against the specified session returning the /rpc-reply/data section of the response document as a Node.
      org.w3c.dom.Node doRequest​(org.onosproject.netconf.NetconfSession session, java.lang.String templateName, java.util.Map<java.lang.String,​java.lang.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.
      java.lang.Object doRequest​(org.onosproject.netconf.NetconfSession session, java.lang.String templateName, java.util.Map<java.lang.String,​java.lang.Object> templateContext, java.lang.String baseXPath, javax.xml.namespace.QName returnType)
      Executes the named NETCONF template against the specified session, returning the referenced XML node as the specified type.
      java.lang.String get​(java.lang.String templateName)
      Returns the named template.
      void load​(java.lang.Class<? extends java.lang.Object> reference, java.lang.String pattern, java.lang.String... templateNames)
      Loads the named templates into the template manager.
      void load​(java.lang.String... templateMNames)
      Loads the named templates into the template manager using the default reference class and resource path pattern.
      void load​(java.lang.String pattern, java.lang.String... templateMNames)
      Loads the named templates into the template manager using the default reference class.
      java.lang.String render​(java.lang.String template, java.util.Map<java.lang.String,​java.lang.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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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​(java.lang.Class<? extends java.lang.Object> reference,
                         java.lang.String pattern,
                         java.lang.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​(java.lang.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​(java.lang.String pattern,
                         java.lang.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 java.lang.String get​(java.lang.String templateName)
        Returns the named template.
        Parameters:
        templateName - name of template to return
        Returns:
        template
      • render

        public java.lang.String render​(java.lang.String template,
                                       java.util.Map<java.lang.String,​java.lang.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 java.lang.Object doRequest​(org.onosproject.netconf.NetconfSession session,
                                          java.lang.String templateName,
                                          java.util.Map<java.lang.String,​java.lang.Object> templateContext,
                                          java.lang.String baseXPath,
                                          javax.xml.namespace.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 org.w3c.dom.Node doRequest​(org.onosproject.netconf.NetconfSession session,
                                          java.lang.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 org.w3c.dom.Node doRequest​(org.onosproject.netconf.NetconfSession session,
                                          java.lang.String templateName,
                                          java.util.Map<java.lang.String,​java.lang.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