Yep, thanks for clarifying. I was just puzzled because almost all of the others had @ValidScope(Scope.Application). I guess this one can be used both in Request and Application scopes, so it was easier to just exclude the third one than to include these two.
On 11/10/2016 08:58 AM, Claude Brisson wrote: > When you restart a J2EE container, it will try to serialize the sessions > on disk to restore them when reloading. This can only works if > everything in the session is serializable, including the session toolbox > itself. > > Since the RenderTool keeps references on a VelocityEngine, it cannot be > serialized. Even if we make the engine as being a transcient field, the > configure method won't be called upon reload. > > One possible workaround would be to mark it transcient, and have a > ServletContextListener call session tools configure method, but it could > induce other side effects. I prefer to mark the RenderTool as invalid in > the session, as it does not seems a very obvious use case to do so. > > That's also why ValueParser cannot be in the session: a > Map<String,Object> is not serializable, as Object is not. > > I marked NumberTool, DateTool, ConversionTool and ResourceTool as > serializable, since they relay on formats or locales which could > potentially be session-specific. > > Does it make more sense? > > Claude > > >>> Date: Thu Nov 10 08:01:41 2016 >>> New Revision: 1769055 >>> >>> URL: http://svn.apache.org/viewvc?rev=1769055&view=rev >>> Log: >>> [tools] a tool should either be Serializable or forbid Session scope >>> >>> Modified: >>> velocity/tools/trunk/velocity-tools-generic/src/main/java/org/apache/velocity/tools/generic/RenderTool.java >>> >>> URL: >>> http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-generic/src/main/java/org/apache/velocity/tools/generic/RenderTool.java?rev=1769055&r1=1769054&r2=1769055&view=diff >>> >>> ============================================================================== >>> >>> --- >>> velocity/tools/trunk/velocity-tools-generic/src/main/java/org/apache/velocity/tools/generic/RenderTool.java >>> (original) >>> +++ >>> velocity/tools/trunk/velocity-tools-generic/src/main/java/org/apache/velocity/tools/generic/RenderTool.java >>> Thu Nov 10 08:01:41 2016 >>> @@ -31,6 +31,7 @@ import org.apache.velocity.context.Conte >>> import org.apache.velocity.tools.Scope; >>> import org.apache.velocity.tools.ToolContext; >>> import org.apache.velocity.tools.config.DefaultKey; >>> +import org.apache.velocity.tools.config.InvalidScope; >>> /** >>> * This tool exposes methods to evaluate the given >>> @@ -103,7 +104,9 @@ import org.apache.velocity.tools.config. >>> * @author Nathan Bubna >>> * @version $Revision$ $Date$ >>> */ >>> + >>> @DefaultKey("render") >>> +@InvalidScope(Scope.SESSION) >> Is it intended to have an IN-valid scope? What prevents it to be used in >> a session? >> >>> public class RenderTool extends SafeConfig >>> { >>> /** >>> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org > For additional commands, e-mail: dev-h...@velocity.apache.org > -- Sergiu Dumitriu http://purl.org/net/sergiu --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org For additional commands, e-mail: dev-h...@velocity.apache.org