On 8/3/12 4:10 PM, Davide Simoncelli wrote:
Hello,
I would like to use a custom hasher. In S4 0.3 it was pretty easy to use a
custom one by changing a XML config file. How to do that in the new version?
I see that now the reference to the hasher is owned by the Sender and the App
class has a reference to the Sender. I could overload the getSender method in
my application class and return my custom sender that basically will pass a
custom hasher instance to the parent class. But how to instance a Sender
instance? Is it the right way?
Hi,
Hasher implementations are set by dependency injection. The default
Hasher is set in the DefaultCoreModule class.
--> bind(Hasher.class).to(DefaultHasher.class);
If you want to use a different Hasher implementation, you can:
1. specify a different implementation for the core module
(-coreModuleClass option)
2. override the default hasher (-emc option)
I recommend option 2, implementation of the extra module is as simple as:
protected void configure() {
bind(Hasher.class).to(CustomHasher.class)
}
See the wiki
https://cwiki.apache.org/confluence/display/S4/Configuration for more
information on how to customize the platform.
Hope this helps,
Matthieu