if you use the ObjectLocator service do instantiate your validator you 
can inject the Logger interface through your constructor:

contributeFieldValidatorSource(map... ObjectLocator locator)
{
      map.add("forbiddenusername", 
locator.autobuild(ForbiddenUserName.class)
}

another option is to inject the LoggerSource service, create a Logger for 
the 
given class manually and pass it in to the validator via the constructor:

Logger logger = loggerSource.getLogger(ForbiddenUserName.class);

new ForbiddenUserName(... ,logger)

g,
kris




Borut Bolčina <[email protected]> 
06.05.2009 13:16
Bitte antworten an
"Tapestry users" <[email protected]>


An
List Tapestry User <[email protected]>
Kopie

Thema
Injecting logger into custom validator







Hi,

I have a class which extends AbstractValidator and is contributed in
my AppModule

    public static void
contributeFieldValidatorSource(MappedConfiguration<String, Validator>
configuration, ComponentClassResolver componentClassResolver) {
        configuration.add("forbiddenusername", new
ForbiddenUsername(componentClassResolver));
    }

Searching through mailing list I found that logger can not be injected
into contribute methods, only services. So what is the way to go?

Like this?

Logger logger = LoggerFactory.getLogger(ForbiddenUsername.class);

Or did I miss something? I am using 5.0.18.

Regards,
Borut

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


Reply via email to