01: package net.bagaluten.jca.lucene.connector.impl;
02:
03: import java.util.Set;
04: import java.util.logging.Logger;
05:
06: import javax.resource.ResourceException;
07:
08: import net.bagaluten.jca.lucene.connector.Entries;
09: import net.bagaluten.jca.lucene.connector.Entry;
10: import net.bagaluten.jca.lucene.connector.LuceneConnection;
11: import net.bagaluten.jca.lucene.connector.QueryField;
12:
13: public class LuceneConnectionImpl implements LuceneConnection {
14:
15: private static final Logger log = Logger
16: .getLogger(LuceneConnectionImpl.class.getName());
17:
18: /** Underlying physical connection instance */
19: private LuceneManagedConnection mc;
20:
21: /**
22: * The constructor
23: *
24: * @param mc
25: * underlying physical connection instance
26: */
27: public LuceneConnectionImpl(LuceneManagedConnection mc) {
28: this .mc = mc;
29: }
30:
31: /**
32: * Associates this handle with given underlying physical connection instance
33: *
34: * @param newMc
35: * underlying physical connection instance
36: */
37: public void associateConnection(LuceneManagedConnection newMc) {
38: log.fine("associating connection");
39: this .mc.removeConnection(this );
40: newMc.addConnection(this );
41: this .mc = newMc;
42: }
43:
44: /**
45: * Invalidates the connection
46: */
47: public void invalidate() {
48: mc = null;
49: }
50:
51: public boolean add(Entry entry) {
52: return mc.add(entry);
53: }
54:
55: public int bulkAdd(Entries entries) throws ResourceException {
56: return mc.bulkAdd(entries);
57: }
58:
59: public void optimize() throws ResourceException {
60: mc.optimize();
61: }
62:
63: public Entries search(String query, Set<QueryField> fields,
64: int offset, int count) throws ResourceException {
65: return mc.search(query, fields, offset, count);
66: }
67:
68: public Set<String> suggest(String words, QueryField field,
69: int suggestNumber) throws ResourceException {
70: return mc.suggest(words, field, suggestNumber);
71: }
72:
73: public void close() {
74: mc.close(this);
75: }
76:
77: }
|