On Mon, Aug 23, 2010 at 11:00, Alex Busenius <[email protected]> wrote:
> Hello,
>
>
> I'd like to refactor AbstractScriptMacro in order to be able to change
> script behavior in the future without fanout violations. Here is the
> plan emerged after several discussions with ThomasM:
>
>
> Introduce a notion of cancelable events. Such events can be canceled by
> the receiver (providing an optional reason), the actual canceling is
> performed by the sender.
>
> http://dev.xwiki.org/xwiki/bin/view/Design/CancelableEvents
>
>
> Send a cancelable event ScriptEvaluationStartsEvent in
> AbstractScriptMacro just before evaluating the script and a
> ScriptEvaluationFinishedEvent right after evaluation has finished (in
> finally block).
>
>
> Add the following 3 listeners to those events (into
> rendering.internal.macro.script) and move the corresponding code from
> AbstractScriptMacro there:
>
> ScriptClassLoaderHandlerListener
> * does class loader manipulations currently performed by
>  AbstractScriptMacro#getClassLoader & Co

Lets say +0,5 because it makes more difficult to understand the
behavior of class loaders in script macros.

>
> PermissionCheckerListener
> * Aborts execution of scripts that need PR if the document is not saved
>  with PR

+1

> * To distinguish velocity and PR scripts, introduce a new interface
>  PrivilegedScriptMacro extends ScriptMacro and let
>  AbstractJSR223ScriptMacro implement it
>
> NestedScriptMacroValidatorListener
> * Replaces NestedScriptMacroValidator (ScriptMacroValidator component
>  is removed completely)

+1

>
>
> The refactoring will remove the following methods (breaks API):
>
> AbstractJSR223ScriptMacro:
> * protected boolean canExecuteScript()

> * public List execute(JSR223ScriptMacroParameters, String,
>  MacroTransformationContext)

Removing this method does not break anything since it's just an
override of AbstractScriptMacro#execute. Probably a clirr check bug or
something.

>
> AbstractScriptMacro:
> * protected boolean canHaveJarsParameters()
> * protected ClassLoader getClassLoader(String, ClassLoader)
>
>
> WDYT?

+1, cancelable events is a very useful feature that we will be  able
to use in many places: validate document before saving it, etc.

>
>
> Alex
> _______________________________________________
> devs mailing list
> [email protected]
> http://lists.xwiki.org/mailman/listinfo/devs
>



-- 
Thomas Mortagne
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to