01: /*
02: * Copyright 2004-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.compass.core.lucene.engine.store;
18:
19: import org.apache.lucene.store.Directory;
20: import org.compass.core.engine.SearchEngine;
21: import org.compass.core.engine.SearchEngineException;
22: import org.compass.core.engine.event.SearchEngineEventManager;
23:
24: /**
25: * An abstraction on top of Lucene {@link org.apache.lucene.store.Directory} handling.
26: *
27: * @author kimchy
28: */
29: public interface DirectoryStore {
30:
31: /**
32: * Opens a new {@link org.apache.lucene.store.Directory} for the given sub context and sub index.
33: */
34: Directory open(String subContext, String subIndex)
35: throws SearchEngineException;
36:
37: /**
38: * Returns <code>true</code> if the inex exists, <code>false</code> if it does not. Can return
39: * <code>null</code> which then will cause the default checking to apply.
40: */
41: Boolean indexExists(Directory dir) throws SearchEngineException;
42:
43: /**
44: * If applicable, deletes the given directory.
45: */
46: void deleteIndex(Directory dir, String subContext, String subIndex)
47: throws SearchEngineException;
48:
49: /**
50: * If applicable, cleans the given directory. Notes, this will be called right before the directory
51: * will be closed. And then a create index will be done.
52: */
53: void cleanIndex(Directory dir, String subContext, String subIndex)
54: throws SearchEngineException;
55:
56: /**
57: * Closes the given directory.
58: */
59: void closeDirectory(Directory dir, String subContext,
60: String subIndex) throws SearchEngineException;
61:
62: /**
63: * Perform any scheduled tasks that are needed on the given directory.
64: */
65: void performScheduledTasks(Directory dir, String subContext,
66: String subIndex) throws SearchEngineException;
67:
68: CopyFromHolder beforeCopyFrom(String subContext, String subIndex,
69: Directory dir) throws SearchEngineException;
70:
71: void afterSuccessfulCopyFrom(String subContext, String subIndex,
72: CopyFromHolder holder) throws SearchEngineException;
73:
74: void afterFailedCopyFrom(String subContext, String subIndex,
75: CopyFromHolder holder) throws SearchEngineException;
76:
77: void registerEventListeners(SearchEngine searchEngine,
78: SearchEngineEventManager eventManager);
79:
80: /**
81: * Closes the given directory.
82: */
83: void close();
84: }
|