Class ConsoleAnnotatorFactory<T>
- java.lang.Object
-
- hudson.console.ConsoleAnnotatorFactory<T>
-
- All Implemented Interfaces:
ExtensionPoint
- Direct Known Subclasses:
UrlAnnotator
public abstract class ConsoleAnnotatorFactory<T> extends Object implements ExtensionPoint
Entry point to theConsoleAnnotatorextension point. This class creates a new instance ofConsoleAnnotatorthat starts a new console annotation session.ConsoleAnnotatorFactorys are used whenever a browser requests console output (as opposed to when the console output is being produced — for that seeConsoleNote.)ConsoleAnnotators returned byConsoleAnnotatorFactoryare asked to start from an arbitrary line of the output, because typically browsers do not request the entire console output. Because of this,ConsoleAnnotatorFactoryis generally suitable for peep-hole local annotation that only requires a small contextual information, such as keyword coloring, URL hyperlinking, and so on.To register, put @
Extensionon yourConsoleAnnotatorFactorysubtype.Behaviour, JavaScript, and CSS
ConsoleNotecan have associatedscript.jsandstyle.css(put them in the same resource directory that you normally put Jelly scripts), which will be loaded into the HTML page whenever the console notes are used. This allows you to use minimal markup in code generation, and do the styling in CSS and perform the rest of the interesting work as a CSS behaviour/JavaScript.- Since:
- 1.349
- Author:
- Kohsuke Kawaguchi
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Constructor Summary
Constructors Constructor Description ConsoleAnnotatorFactory()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static ExtensionList<ConsoleAnnotatorFactory>all()All the registered instances.voiddoScriptJs(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)Serves the JavaScript file associated with this console annotator factory.voiddoStyleCss(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)booleanhasScript()Returns true if this descriptor has a JavaScript to be inserted on applicable console page.booleanhasStylesheet()abstract ConsoleAnnotator<T>newInstance(T context)Called when a console output page is requested to create a statefulConsoleAnnotator.Class<?>type()For which context type does this annotator work?
-
-
-
Method Detail
-
newInstance
public abstract ConsoleAnnotator<T> newInstance(T context)
Called when a console output page is requested to create a statefulConsoleAnnotator.This method can be invoked concurrently by multiple threads.
- Parameters:
context- The model object that owns the console output, such asRun. This method is only called when the context object if assignable to the advertised type.- Returns:
- null if this factory is not going to participate in the annotation of this console.
-
type
public Class<?> type()
For which context type does this annotator work?
-
hasScript
public boolean hasScript()
Returns true if this descriptor has a JavaScript to be inserted on applicable console page.
-
hasStylesheet
public boolean hasStylesheet()
-
doScriptJs
@WebMethod(name="script.js") public void doScriptJs(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletExceptionServes the JavaScript file associated with this console annotator factory.- Throws:
IOExceptionjavax.servlet.ServletException
-
doStyleCss
@WebMethod(name="style.css") public void doStyleCss(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException- Throws:
IOExceptionjavax.servlet.ServletException
-
all
public static ExtensionList<ConsoleAnnotatorFactory> all()
All the registered instances.
-
-