New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ISPN-1458 Allow to explicitly register a key transformer in KeyTransformationHandler #571
Conversation
… you can't annotate a key type with @transformable)
@@ -48,6 +53,8 @@ import org.infinispan.util.logging.LogFactory; | |||
public class KeyTransformationHandler { | |||
private static final Log log = LogFactory.getLog(KeyTransformationHandler.class, Log.class); | |||
|
|||
private static Map<Class<?>, Class<? extends Transformer>> transformers = new HashMap<Class<?>, Class<? extends Transformer>>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can't be static or we will leak classes
Hi @luksa, |
Also make sure to open an issue on JIRA regarding these changes |
Yeah, I had a feeling the static Map would be a problem, but thought I'd just commit and you'd tell me after reviewing. Hmm, if I make KeyTransformationHandler's methods non static, I will have to change QueryExtractorUtil, LazyIterator and a few other classes, since they all call the handler's stringToKey() method. I could keep stringToKey() static, and instead of supplying a ClassLoader as the second parameter, clients would simply need to pass in the cache. Right now, clients are calling stringToKey like this: KeyTransformationHandler.stringToKey(key,cache.getAdvancedCache().getClassLoader()); So all those calls would be simplified into: KeyTransformationHandler.stringToKey(key,cache); This would reduce duplication a little and prevent people from passing in a completely different ClassLoader. The stringToKey() could now obtain the cache's QueryInterceptor and through it also the correct instance of the KeyTransformationHandler. The other way to do it, would be to add a registerKeyTransformer method to SearchManager, which would delegate to QueryInterceptor, which would then delegate to KeyTransformationHandler (so I don't need to expose either QueryInterceptor or KeyTransformationHandler). Of course all the clients that are currently calling the static stringToKey() method, would now have to first obtain a SearchManager (or the QueryInterceptor directly), get the keyTransformationHandler from it and call the non-static stringToKey() method. What do you think? |
Hi, Don't worry for the internal APIs, you can change them to do some spring cleaning if you have good ideas. |
@luksa sorry for the delay, I didn't get any notification of you adding the last changes. Will review soon. |
@luksa did you already sign the contributor agreement for Infinispan at https://cla.jboss.org ? |
I have just signed it. |
thanks a lot, merged with some minor changes. The lookup service is very useful for some cases like the clustered query, in which we need it as otherwise we're without context, but generally I've moved the lookup out of the hot loops. |
Sanne said this could be useful.
Allow to register a Transformer in KeyTransformationHandler (for when you can't annotate a key type with @transformable).