Re: Logging configuration

2016-11-10 Thread Mike Kienenberger
+1 to using several appropriate functional names if we are picking
loggers by String rather than by Class.

On Thu, Nov 10, 2016 at 11:11 AM, Claude Brisson  wrote:
> On 10/11/2016 15:56, Greg Huber wrote:
>
>> Yes it does when I use name="Velocity"
>>
>> But as you are using the runtime instance logger its either on or off for
>> the whole package.  Using a per class I think enables more filtering as
>> you
>> can name="org.apache.velocity.app" level="DEBUG" purely for this package
>> and name="org.apache.velocity" level="WARN" for everything else.
>
>
> The reasons we only have one logger are mainly historical. It would
> certainly be more pertinent to have at least one logger per module, loading,
> introspection, etc...
>
>> But I you can filter the log file (in eclipse) so it makes no difference.
>>
>>
>> Thanks for the velocity upgrade!  Thought it was not being maintained any
>> more.
>
>
> Well, we're kinda resurrecting...
>
>
>   Claude
>
>
>
> -
> To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org
> For additional commands, e-mail: dev-h...@velocity.apache.org
>

-
To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org
For additional commands, e-mail: dev-h...@velocity.apache.org



Re: Logging configuration

2016-11-10 Thread Greg Huber
Yes it does when I use name="Velocity"

But as you are using the runtime instance logger its either on or off for
the whole package.  Using a per class I think enables more filtering as you
can name="org.apache.velocity.app" level="DEBUG" purely for this package
and name="org.apache.velocity" level="WARN" for everything else.

But I you can filter the log file (in eclipse) so it makes no difference.


Thanks for the velocity upgrade!  Thought it was not being maintained any
more.

Cheers Greg

On 10 November 2016 at 14:13, Claude Brisson  wrote:

> Any module anywhere can get a logger using one of the two static methods:
>
> Logger org.slf4j.LoggerFactory.getLogger(String loggerName)
>
> Logger org.slf4j.LoggerFactory.getLogger(Class targetClass)
>
> Calling one or the other is a matter of taste. It does not *have* to be
> the same logger anywhere in the application, each module can use its own
> logger. The parameter is generally used as a log line prefix, and can also
> be used to do a fine tuning of which modules can log at which log level,
> something we haven't taken advantage so far in Velocity (apart for the
> Tools themselves).
>
> I chose to use the first variant for sobriety (to avoid each log line
> contain the whole package name), but it s not necessarily a definitive
> choice. At least, it should be better documented.
>
> Does your logging work properly with this configuration?
>
>   Claude
>
>
> On 10/11/2016 11:12, Greg Huber wrote:
>
>> The name needs to be exactly Velocity which is not what I had expected,
>> usually its the package name format ie org.apache.velocity.
>>
>> 
>>  
>> 
>>
>> the docs suggest its org.apache.velocity.app.Velocity
>>
>> This seems to be set in RuntimeInstance:
>>
>> private Logger log = LoggerFactory.getLogger("Velocity");
>>
>>
>> Then I do not use slf4j so not sure how it should be configured ie per
>> package.
>>
>> Cheers Greg
>>
>>
>
> -
> To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org
> For additional commands, e-mail: dev-h...@velocity.apache.org
>
>


Re: svn commit: r1769055 - in /velocity/tools/trunk: velocity-tools-generic/ velocity-tools-generic/src/main/java/org/apache/velocity/tools/generic/ velocity-tools-generic/src/test/java/org/apache/vel

2016-11-10 Thread Sergiu Dumitriu
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 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=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=1769054=1769055=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



Re: svn commit: r1769055 - in /velocity/tools/trunk: velocity-tools-generic/ velocity-tools-generic/src/main/java/org/apache/velocity/tools/generic/ velocity-tools-generic/src/test/java/org/apache/vel

2016-11-10 Thread Nathan Bubna
On Thu, Nov 10, 2016 at 4:19 AM, Sergiu Dumitriu 
wrote:

> On 11/10/2016 03:01 AM, cbris...@apache.org wrote:
> > Author: cbrisson
> > Date: Thu Nov 10 08:01:41 2016
> > New Revision: 1769055
> >
> > URL: http://svn.apache.org/viewvc?rev=1769055=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=1769054=1769055=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?
>
>
Nothing prevents a user from manually inserting one into their session, but
this annotation bans them from configuring VelocityTools to automatically
insert fresh RenderTools into each session for them.


> >  public class RenderTool extends SafeConfig
> >  {
> >  /**
> >
>
> --
> 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
>
>


Re: Logging configuration

2016-11-10 Thread Claude Brisson

Any module anywhere can get a logger using one of the two static methods:

Logger org.slf4j.LoggerFactory.getLogger(String loggerName)

Logger org.slf4j.LoggerFactory.getLogger(Class targetClass)

Calling one or the other is a matter of taste. It does not *have* to be 
the same logger anywhere in the application, each module can use its own 
logger. The parameter is generally used as a log line prefix, and can 
also be used to do a fine tuning of which modules can log at which log 
level, something we haven't taken advantage so far in Velocity (apart 
for the Tools themselves).


I chose to use the first variant for sobriety (to avoid each log line 
contain the whole package name), but it s not necessarily a definitive 
choice. At least, it should be better documented.


Does your logging work properly with this configuration?

  Claude


On 10/11/2016 11:12, Greg Huber wrote:

The name needs to be exactly Velocity which is not what I had expected,
usually its the package name format ie org.apache.velocity.


 


the docs suggest its org.apache.velocity.app.Velocity

This seems to be set in RuntimeInstance:

private Logger log = LoggerFactory.getLogger("Velocity");


Then I do not use slf4j so not sure how it should be configured ie per
package.

Cheers Greg




-
To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org
For additional commands, e-mail: dev-h...@velocity.apache.org



Re: svn commit: r1769055 - in /velocity/tools/trunk: velocity-tools-generic/ velocity-tools-generic/src/main/java/org/apache/velocity/tools/generic/ velocity-tools-generic/src/test/java/org/apache/vel

2016-11-10 Thread Claude Brisson
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 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=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=1769054=1769055=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



Re: svn commit: r1769055 - in /velocity/tools/trunk: velocity-tools-generic/ velocity-tools-generic/src/main/java/org/apache/velocity/tools/generic/ velocity-tools-generic/src/test/java/org/apache/vel

2016-11-10 Thread Sergiu Dumitriu
On 11/10/2016 03:01 AM, cbris...@apache.org wrote:
> Author: cbrisson
> Date: Thu Nov 10 08:01:41 2016
> New Revision: 1769055
> 
> URL: http://svn.apache.org/viewvc?rev=1769055=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=1769054=1769055=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
>  {
>  /**
> 

-- 
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



Logging configuration

2016-11-10 Thread Greg Huber
The name needs to be exactly Velocity which is not what I had expected,
usually its the package name format ie org.apache.velocity.





the docs suggest its org.apache.velocity.app.Velocity

This seems to be set in RuntimeInstance:

private Logger log = LoggerFactory.getLogger("Velocity");


Then I do not use slf4j so not sure how it should be configured ie per
package.

Cheers Greg


Re: [ANNOUNCE] Velocity Engine 2.0 test build available

2016-11-10 Thread Greg Huber
Claude,

I have tested the fix and it now works, thanks.

##

One thing now is I cannot get the log into debug mode.  I use
commons-logging with log4j and the log4j-slf4j-impl as a bridge.


   



Other jars that use slf4j will log to debug ok.

The notes mention runtime.log.instance= maybe I need to set something here?







On 9 November 2016 at 22:40, Claude Brisson  wrote:

> Thanks Nathan!
>
> Greg, the bug is fixed. But I'll wait at least 48h for potential more
> feedback (thanks, by the way!) before submitting a new release candidate.
>
> If you want to test the corrected version before, you can grab the latest
> snapshot here:
>
> https://repository.apache.org/content/repositories/snapshots
> /org/apache/velocity/velocity-engine-core/2.0-SNAPSHOT/
> velocity-engine-core-2.0-20161109.221234-5.jar
>
> (with the usual signatures in .sha1 and .md5 files).
>
>   Claude
>
>
> On 09/11/2016 18:45, Nathan Bubna wrote:
>
>> Gah, really wish i had time to help. Keep up the great work, Claude!
>>
>> On Wed, Nov 9, 2016 at 9:06 AM, Claude Brisson 
>> wrote:
>>
>> Ok, I reproduced it. It happens when the method is overloaded with a
>>> variant that takes no argument.
>>>
>>> Guess there will be a third release candidate...
>>>
>>>
>>>
>>> On 09/11/2016 17:44, Greg Huber wrote:
>>>
>>> It seems to be returning the wrong class name in ClassUtils

method = node.getRuntimeServices().getUberspect().getMethod(o,
 methodName,
 params,
  new Info(node.getTemplateName(), node.getLine(),
 node.getColumn()));

 It is returning a method name of .thumbResource() rather than
 .thumbResource(String, String) and then further down the java reflection
 throws the java.lang.IllegalArgumentException exception.


 On 9 November 2016 at 16:09, Claude Brisson  wrote:

 I cannot reproduce it.

> Is the thumbResource() method overloaded?
>
> Do you have the full stacktrace?
>
>
> On 09/11/2016 16:50, Greg Huber wrote:
>
> Hello,
>
>> I am getting an error when a parameter on a method name is null, it
>> says
>> "wrong number of arguments at"
>>
>> eg :
>>
>> $entry.filePath == null
>>
>> $myPojo.thumbResource($entry.name, $entry.filePath)
>>
>> I get an exception :
>>
>> java.lang.IllegalArgumentException: wrong number of arguments at..
>>
>>
>>
>> public String thumbResource(String name, String filePath) {
>>...
>> }
>>
>> I have tried to debug it but it seems to originate in the ASTMethod
>> class.
>> If i change the variable to be blanks it works ok.
>>
>>
>>
>>
>>
>>
>>
>>
>> On 9 November 2016 at 14:50, Claude Brisson 
>> wrote:
>>
>> A new test build of Velocity Engine 2.0 is available.
>>
>> No determination as to the quality ('alpha,' 'beta,' or 'GA') of
>>> Velocity
>>> Engine 2.0 has been made, and at this time it is simply a "test
>>> build".
>>> We
>>> welcome any comments you may have, and will take all feedback into
>>> account
>>> if a quality vote is called for this build.
>>>
>>> Release notes:
>>>
>>> * https://dist.apache.org/repos/dist/dev/velocity/velocity-eng
>>> ine/2.0/release-notes.html
>>>
>>> Distribution:
>>>
>>> * https://dist.apache.org/repos/dist/dev/velocity/velocity-eng
>>> ine/2.0/
>>>
>>> Maven 2 staging repository:
>>>
>>> * https://repository.apache.org/content/repositories/orgapache
>>> velocity-1011/
>>>
>>> A vote regarding the quality of this test build will be initiated
>>> within
>>> the next couple of days.
>>>
>>>
>>> Regards,
>>>
>>>  Claude
>>>
>>>
>>> On 07/11/2016 11:06, Claude Brisson wrote:
>>>
>>> The test build of Velocity Engine 2.0 is available.
>>>
>>> No determination as to the quality ('alpha,' 'beta,' or 'GA') of
 Velocity
 Engine 2.0 has been made, and at this time it is simply a "test
 build".
 We
 welcome any comments you may have, and will take all feedback into
 account
 if a quality vote is called for this build.

 Release notes:

 * https://dist.apache.org/repos/dist/dev/velocity/velocity-eng
 ine/2.0/release-notes.html

 Distribution:

 * https://dist.apache.org/repos/dist/dev/velocity/velocity-eng
 ine/2.0/

 Maven 2 staging repository:

 * https://repository.apache.org/content/repositories/orgapache
 velocity-1010/

 A vote regarding the quality of this test build will be initiated
 within
 the next couple of days.