1 /* Copyright (c) 2008 Sascha Kohlmann
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU Affero General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Affero General Public License for more details.
12 *
13 * You should have received a copy of the GNU Affero General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16 package net.sf.eos.lucene;
17
18 import static net.sf.eos.config.ConfigurationKey.Type.CLASSNAME;
19
20 import org.apache.commons.logging.Log;
21 import org.apache.commons.logging.LogFactory;
22
23 import net.sf.eos.EosException;
24 import net.sf.eos.config.Configuration;
25 import net.sf.eos.config.ConfigurationKey;
26 import net.sf.eos.config.Configured;
27 import net.sf.eos.config.FactoryMethod;
28 import net.sf.eos.search.EosLookup;
29
30 /**
31 * A simple <a href='http://lucene.apache.org/' title='Homepage'>Lucene</a>
32 * entity oriented search lookup implementation.
33 * @author Sascha Kohlmann
34 */
35 public abstract class LuceneEosLookup extends Configured implements EosLookup {
36
37 /** For logging. */
38 private static final Log LOG =
39 LogFactory.getLog(LuceneEosLookup.class.getName());
40
41 /** The configuration key name for the classname of the creator.
42 * @see #newInstance(Configuration) */
43 @SuppressWarnings("nls")
44 @ConfigurationKey(type=CLASSNAME,
45 description="Configuration key of the Lucene look up "
46 + " factory.")
47 public final static String LUCENE_EOS_LOOKUP_IMPL_CONFIG_NAME =
48 "net.sf.eos.lucene.LuceneEosLookup.impl";
49
50 // /**
51 // * Creates a new instance of a of the lookup. If the
52 // * {@code Configuration} contains a key
53 // * {@link #LUCENE_EOS_LOOKUP_IMPL_CONFIG_NAME} a new instance of the
54 // * classname in the value will instantiate. The
55 // * {@link DefaultLuceneEosLookup} will instantiate if there is no
56 // * value setted.
57 // * @param config the configuration
58 // * @return a new instance
59 // * @throws EosException if it is not possible to instantiate an instance
60 // */
61 // @FactoryMethod(key=LUCENE_EOS_LOOKUP_IMPL_CONFIG_NAME,
62 // implementation=DefaultLuceneEosLookup.class)
63 // public final static LuceneEosLookup
64 // newInstance(final Configuration config) throws EosException {
65 //
66 // final Thread t = Thread.currentThread();
67 // ClassLoader classLoader = t.getContextClassLoader();
68 // if (classLoader == null) {
69 // classLoader = LuceneEosLookup.class.getClassLoader();
70 // }
71 //
72 // final String clazzName =
73 // config.get(LUCENE_EOS_LOOKUP_IMPL_CONFIG_NAME,
74 // DefaultLuceneEosLookup.class.getName());
75 //
76 // try {
77 // final Class<? extends LuceneEosLookup> clazz =
78 // (Class<? extends LuceneEosLookup>) Class
79 // .forName(clazzName, true, classLoader);
80 // try {
81 //
82 // final LuceneEosLookup lookup = clazz.newInstance();
83 // lookup.configure(config);
84 // if (LOG.isDebugEnabled()) {
85 // LOG.debug("LuceneEosLookup instance: "
86 // + lookup.getClass().getName());
87 // }
88 // return lookup;
89 //
90 // } catch (final InstantiationException e) {
91 // throw new EosException(e);
92 // } catch (final IllegalAccessException e) {
93 // throw new EosException(e);
94 // }
95 // } catch (final ClassNotFoundException e) {
96 // throw new EosException(e);
97 // }
98 // }
99 }