Package org.onosproject.drivers.netconf
Class TemplateManager
- java.lang.Object
-
- org.onosproject.drivers.netconf.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 NodedoRequest(org.onosproject.netconf.NetconfSession session, String templateName)Execute the named NETCONF template against the specified session returning the/rpc-reply/datasection of the response document as aNode.NodedoRequest(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/datasection of the response document as aNode.ObjectdoRequest(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.Stringget(String templateName)Returns the named template.voidload(Class<? extends Object> reference, String pattern, String... templateNames)Loads the named templates into the template manager.voidload(String... templateMNames)Loads the named templates into the template manager using the default reference class and resource path pattern.voidload(String pattern, String... templateMNames)Loads the named templates into the template manager using the default reference class.Stringrender(String template, Map<String,Object> context)Performs simple variable substitution into a string in likely the most inefficient way possible.voidsetRequestDriver(TemplateRequestDriver driver)Sets the request driver for the template manager.
-
-
-
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 resourcespattern- pattern to convert template name to resource pathtemplateNames- 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 pathtemplateMNames- 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 variablescontext- 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 serssiontemplateName- name of NETCONF request template to executetemplateContext- variable to values substitutions to be used against templatesbaseXPath- XPath expression to specify the returned document nodereturnType- 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/datasection of the response document as aNode.- Parameters:
session- NETCONF sessiontemplateName- 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/datasection of the response document as aNode.- Parameters:
session- NETCONF sessiontemplateName- name of NETCONF request template to executetemplateContext- 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
-
-