Skip to content

HSEARCH-1268 Make it possible to plug in a custom MassIndexer implementation #380

Closed
wants to merge 4 commits into from

2 participants

@DavideD
Hibernate member
DavideD commented Feb 1, 2013

https://hibernate.onjira.com/browse/HSEARCH-1268

I have a couple of question. I will ask as inline comments

@DavideD
Hibernate member
DavideD commented Feb 1, 2013

I don't think I can leave on inline comment on this one because it's about file I didn't change, anyway:

ClassLoaderHelper#classForName is using the contextClassloader before using the one passed as a parameter. Shouldn't be the opposite?

@Sanne
Hibernate member
Sanne commented Feb 2, 2013

ClassLoaderHelper#classForName is using the contextClassloader before using the one passed as a parameter. Shouldn't be the opposite?

Order is not important, it only has a performance impact as it might try the correct one first, avoiding one reource access.
We expect most things to be found on the contextClassLoader as that's where the user resources are (like lists of stopwords, custom analyzers, any other extension)

@Sanne Sanne and 1 other commented on an outdated diff Feb 2, 2013
...e/search/hcore/impl/MassIndexerFactoryIntegrator.java
+
+ public static final String MASS_INDEXER_FACTORY_CLASS_PROP = "hibernate.search.indexer.factory";
+
+ @Override
+ public Class<MassIndexerFactory> getServiceInitiated() {
+ return MassIndexerFactory.class;
+ }
+
+ @Override
+ public MassIndexerFactory initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
+ String factoryClassName = (String) configurationValues.get( MASS_INDEXER_FACTORY_CLASS_PROP );
+ return factoryClassName == null ? DEFAULT_FACTORY : createFactory( factoryClassName );
+ }
+
+ private MassIndexerFactory createFactory(String factoryClassName) {
+ return ClassLoaderHelper.instanceFromName( MassIndexerFactory.class, factoryClassName, getClass()
@Sanne
Hibernate member
Sanne added a note Feb 2, 2013

did you check if ORM isn't providing you the classloader as a Service?

 getClass().getClassLoader()

If we still use this code, then the fix in the previous commit isn't as useful as I thought it would be.

@DavideD
Hibernate member
DavideD added a note Feb 2, 2013

I didn't check.

I will take a look at it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@DavideD
Hibernate member
DavideD commented Feb 2, 2013

ClassLoaderHelper#classForName is using the contextClassloader before using the one passed as a parameter. Shouldn't be the opposite?

Order is not important, it only has a performance impact as it might try the correct one first, avoiding one reource access.
We expect most things to be found on the contextClassLoader as that's where the user resources are (like lists of stopwords, custom analyzers, any other extension)

I'm asking because It's seems a bit awkward that I pass the classloader that I want to use and then another one is used. By the way, I've noticed this writing some unit tests.

@DavideD
Hibernate member
DavideD commented Feb 4, 2013

Added some documentation and javadoc

@DavideD
Hibernate member
DavideD commented Feb 5, 2013

Rebased. All the changes should be applied now.

@DavideD
Hibernate member
DavideD commented Feb 5, 2013

Changed a comment

@Sanne
Hibernate member
Sanne commented Feb 5, 2013

merged!

@Sanne Sanne closed this Feb 5, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.