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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbuildFallbackDispatchers(MetaClass owner, List<Dispatcher> dispatchers) AddsDispatchers that do catch-all behaviours like "doDispatch" does.voidbuildIndexDispatchers(MetaClass owner, List<Dispatcher> dispatchers) AddsDispatchers that serves the likes ofindex.EXTThe 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 voidbuildViewDispatchers(MetaClass owner, List<Dispatcher> dispatchers) AddsDispatchers that look at one token and binds that to the views associated with the 'it' object.protected <S> jakarta.servlet.RequestDispatchercreateRequestDispatcher(AbstractTearOff<?, ? extends S, ?> scriptLoader, ScriptExecutor<? super S> scriptExecutor, Object it, String viewName) Creates a RequestDispatcher that integrates withDispatchValidatorandFilteredDispatchTriggerListener.jakarta.servlet.RequestDispatchercreateRequestDispatcher(RequestImpl request, Class type, Object it, String viewName) jakarta.servlet.RequestDispatchercreateRequestDispatcher(RequestImpl request, Klass<?> type, Object it, String viewName) Creates aRequestDispatcherthat handles the given view, or return null if no such view was found.protected <S> DispatchercreateValidatingDispatcher(AbstractTearOff<?, ? extends S, ?> scriptLoader, ScriptExecutor<? super S> scriptExecutor) Creates a Dispatcher that integratesDispatchValidatorwith 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 StringFor Facets that require a particular file extension to be put in any case.Klass<?>Maps an instance to aKlass.protected <S> booleanhandleIndexRequest(AbstractTearOff<?, ? extends S, ?> scriptLoader, ScriptExecutor<? super S> scriptExecutor, RequestImpl req, ResponseImpl rsp, Object node) Handles an index request by dispatching a script.abstract booleanhandleIndexRequest(RequestImpl req, ResponseImpl rsp, Object node, MetaClass nodeMetaClass) Attempts to route the HTTP request to the 'index' page of the 'it' object.protected booleanisBasename(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
AddsDispatchers that look at one token and binds that to the views associated with the 'it' object. -
buildIndexDispatchers
AddsDispatchers that serves the likes ofindex.EXTThe 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
AddsDispatchers 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 aRequestDispatcherthat 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:
IOExceptionjakarta.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 integratesDispatchValidatorwith 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 configuredFilteredDispatchTriggerListenerwill 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.ServletExceptionIOException- 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 withDispatchValidatorandFilteredDispatchTriggerListener.- 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:
-