Package org.kohsuke.stapler
Class Facet
java.lang.Object
org.kohsuke.stapler.Facet
- Direct Known Subclasses:
StaticViewFacet
Aspect of stapler that brings in an optional language binding.
Put
MetaInfServices
on subtypes so that Stapler can discover them.- Author:
- Kohsuke Kawaguchi
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
buildFallbackDispatchers
(MetaClass owner, List<Dispatcher> dispatchers) AddsDispatcher
s that do catch-all behaviours like "doDispatch" does.void
buildIndexDispatchers
(MetaClass owner, List<Dispatcher> dispatchers) AddsDispatcher
s that serves the likes ofindex.EXT
The default implementation invokeshandleIndexRequest(RequestImpl, ResponseImpl, Object, MetaClass)
but facet implementations can improve runtime dispatch performance by testing the presence of index view page upfront.abstract void
buildViewDispatchers
(MetaClass owner, List<Dispatcher> dispatchers) AddsDispatcher
s that look at one token and binds that to the views associated with the 'it' object.protected <S> jakarta.servlet.RequestDispatcher
createRequestDispatcher
(AbstractTearOff<?, ? extends S, ?> scriptLoader, ScriptExecutor<? super S> scriptExecutor, Object it, String viewName) Creates a RequestDispatcher that integrates withDispatchValidator
andFilteredDispatchTriggerListener
.jakarta.servlet.RequestDispatcher
createRequestDispatcher
(RequestImpl request, Class type, Object it, String viewName) jakarta.servlet.RequestDispatcher
createRequestDispatcher
(RequestImpl request, Klass<?> type, Object it, String viewName) Creates aRequestDispatcher
that handles the given view, or return null if no such view was found.protected <S> Dispatcher
createValidatingDispatcher
(AbstractTearOff<?, ? extends S, ?> scriptLoader, ScriptExecutor<? super S> scriptExecutor) Creates a Dispatcher that integratesDispatchValidator
with the provided script loader and executor.discover
(ClassLoader cl) Discovers all the facets in the classloader.static <T> List<T>
discoverExtensions
(Class<T> type, ClassLoader... cls) protected String
For Facets that require a particular file extension to be put in any case.Klass<?>
Maps an instance to aKlass
.protected <S> boolean
handleIndexRequest
(AbstractTearOff<?, ? extends S, ?> scriptLoader, ScriptExecutor<? super S> scriptExecutor, RequestImpl req, ResponseImpl rsp, Object node) Handles an index request by dispatching a script.abstract boolean
handleIndexRequest
(RequestImpl req, ResponseImpl rsp, Object node, MetaClass nodeMetaClass) Attempts to route the HTTP request to the 'index' page of the 'it' object.protected boolean
isBasename
(String potentialPath) Ensure the path that is passed is only the name of the file and not a path
-
Field Details
-
LOGGER
-
ALLOW_VIEW_NAME_PATH_TRAVERSAL
public static boolean ALLOW_VIEW_NAME_PATH_TRAVERSAL
-
-
Constructor Details
-
Facet
public Facet()
-
-
Method Details
-
buildViewDispatchers
AddsDispatcher
s that look at one token and binds that to the views associated with the 'it' object. -
buildIndexDispatchers
AddsDispatcher
s that serves the likes ofindex.EXT
The default implementation invokeshandleIndexRequest(RequestImpl, ResponseImpl, Object, MetaClass)
but facet implementations can improve runtime dispatch performance by testing the presence of index view page upfront. -
buildFallbackDispatchers
AddsDispatcher
s that do catch-all behaviours like "doDispatch" does. -
discover
Discovers all the facets in the classloader. -
discoverExtensions
-
createRequestDispatcher
@CheckForNull public jakarta.servlet.RequestDispatcher createRequestDispatcher(RequestImpl request, Klass<?> type, Object it, String viewName) throws IOException Creates aRequestDispatcher
that handles the given view, or return null if no such view was found.- Parameters:
type
- If "it" is non-null,it.getClass()
. Otherwise the class from which the view is searched.- Throws:
IOException
- See Also:
-
createRequestDispatcher
@CheckForNull public jakarta.servlet.RequestDispatcher createRequestDispatcher(RequestImpl request, Class type, Object it, String viewName) throws IOException - Throws:
IOException
-
handleIndexRequest
public abstract boolean handleIndexRequest(RequestImpl req, ResponseImpl rsp, Object node, MetaClass nodeMetaClass) throws IOException, jakarta.servlet.ServletException Attempts to route the HTTP request to the 'index' page of the 'it' object.- Returns:
- true if the processing succeeds. Otherwise false.
- Throws:
IOException
jakarta.servlet.ServletException
- See Also:
-
getKlass
-
isBasename
Ensure the path that is passed is only the name of the file and not a path -
getExtensionSuffix
For Facets that require a particular file extension to be put in any case. Just return an empty String if the Facet does not want to have such behavior. If you do want to have an extension added, you must ensure you provide the dot at the first character position, see JellyFacet -
createValidatingDispatcher
@NonNull protected <S> Dispatcher createValidatingDispatcher(@NonNull AbstractTearOff<?, ? extends S, ?> scriptLoader, @NonNull ScriptExecutor<? super S> scriptExecutor) Creates a Dispatcher that integratesDispatchValidator
with the provided script loader and executor. If an exception or one of its causes is aCancelRequestHandlingException
, this will cause the Dispatcher to cancel and return false, thus allowing for further dispatchers to attempt to handle the request. This also requires validation to pass before any output can be written to the response. In any error case, the configuredFilteredDispatchTriggerListener
will be notified.- Type Parameters:
S
- type of script- Parameters:
scriptLoader
- tear-off script loader to find viewsscriptExecutor
- script executor for rendering views- Returns:
- dispatcher that handles scripts
- Since:
- TODO
- See Also:
-
handleIndexRequest
protected <S> boolean handleIndexRequest(@NonNull AbstractTearOff<?, ? extends S, throws jakarta.servlet.ServletException, IOException?> scriptLoader, @NonNull ScriptExecutor<? super S> scriptExecutor, @NonNull RequestImpl req, @NonNull ResponseImpl rsp, @CheckForNull Object node) Handles an index request by dispatching a script.- Throws:
jakarta.servlet.ServletException
IOException
- Since:
- TODO
-
createRequestDispatcher
@CheckForNull protected <S> jakarta.servlet.RequestDispatcher createRequestDispatcher(@NonNull AbstractTearOff<?, ? extends S, ?> scriptLoader, @NonNull ScriptExecutor<? super S> scriptExecutor, @CheckForNull Object it, @NonNull String viewName) Creates a RequestDispatcher that integrates withDispatchValidator
andFilteredDispatchTriggerListener
.- Type Parameters:
S
- view type- Parameters:
scriptLoader
- tear-off script loader for finding viewsscriptExecutor
- script executor for rendering viewsit
- the model node being dispatched againstviewName
- name of the view to load and execute- Returns:
- a RequestDispatcher that performs similar validation to
createValidatingDispatcher(AbstractTearOff, ScriptExecutor)
- Since:
- TODO
- See Also:
-