Author: epbernard
Date: 2007-02-24 18:42:41 -0500 (Sat, 24 Feb 2007)
New Revision: 11237
Modified:
branches/Branch_3_2/HibernateExt/search/src/java/org/hibernate/search/SearchFactory.java
Log:
HSEARCH-21
Modified:
branches/Branch_3_2/HibernateExt/search/src/java/org/hibernate/search/SearchFactory.java
===================================================================
---
branches/Branch_3_2/HibernateExt/search/src/java/org/hibernate/search/SearchFactory.java 2007-02-23
22:53:24 UTC (rev 11236)
+++
branches/Branch_3_2/HibernateExt/search/src/java/org/hibernate/search/SearchFactory.java 2007-02-24
23:42:41 UTC (rev 11237)
@@ -32,7 +32,6 @@
new ThreadLocal<WeakHashMap<Configuration, SearchFactory>>();
static {
Version.touch();
- contexts.set( new WeakHashMap<Configuration, SearchFactory>(2) );
}
private Map<Class, DocumentBuilder<Object>> documentBuilders = new
HashMap<Class, DocumentBuilder<Object>>();
//keep track of the index modifiers per DirectoryProvider since multiple entity can use
the same directory provider
@@ -115,8 +114,13 @@
}
//code doesn't have to be multithreaded because SF creation is not.
+ //this is not a public API, should really only be used during the SessionFActory
building
public static SearchFactory getSearchFactory(Configuration cfg) {
WeakHashMap<Configuration, SearchFactory> contextMap = contexts.get();
+ if (contextMap == null) {
+ contextMap = new WeakHashMap<Configuration, SearchFactory>( 2 );
+ contexts.set( contextMap );
+ }
SearchFactory searchFactory = contextMap.get( cfg );
if ( searchFactory == null) {
searchFactory = new SearchFactory(cfg);