1 /*
2 * ModeShape (http://www.modeshape.org)
3 * See the COPYRIGHT.txt file distributed with this work for information
4 * regarding copyright ownership. Some portions may be licensed
5 * to Red Hat, Inc. under one or more contributor license agreements.
6 * See the AUTHORS.txt file in the distribution for a full listing of
7 * individual contributors.
8 *
9 * ModeShape is free software. Unless otherwise indicated, all code in ModeShape
10 * is licensed to you under the terms of the GNU Lesser General Public License as
11 * published by the Free Software Foundation; either version 2.1 of
12 * the License, or (at your option) any later version.
13 *
14 * ModeShape is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this software; if not, write to the Free
21 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
23 */
24 package org.modeshape.graph.search;
25
26 import net.jcip.annotations.ThreadSafe;
27 import org.modeshape.graph.ExecutionContext;
28 import org.modeshape.graph.connector.RepositorySource;
29 import org.modeshape.graph.connector.RepositorySourceException;
30 import org.modeshape.graph.observe.Observer;
31 import org.modeshape.graph.request.ChangeRequest;
32
33 /**
34 * A component that acts as a search engine for the content within a single {@link RepositorySource}. This engine manages a set of
35 * indexes and provides search functionality for each of the workspaces within the source, and provides various methods to
36 * (re)index the content contained with source's workspaces and keep the indexes up-to-date via changes.
37 */
38 @ThreadSafe
39 public interface SearchEngine {
40
41 /**
42 * Get the name of the source that can be searched with an engine that uses this provider.
43 *
44 * @return the name of the source that is to be searchable; never null
45 */
46 String getSourceName();
47
48 /**
49 * Create the {@link SearchEngineProcessor} implementation that can be used to operate against the
50 * {@link SearchEngineWorkspace} instances.
51 * <p>
52 * Note that the resulting processor must be {@link SearchEngineProcessor#close() closed} by the caller when completed.
53 * </p>
54 *
55 * @param context the context in which the processor is to be used; never null
56 * @param observer the observer of any events created by the processor; may be null
57 * @param readOnly true if the processor will only be reading or searching, or false if the processor will be used to update
58 * the workspaces
59 * @return the processor; may not be null
60 */
61 SearchEngineProcessor createProcessor( ExecutionContext context,
62 Observer observer,
63 boolean readOnly );
64
65 /**
66 * Update the indexes with the supplied set of changes to the content.
67 *
68 * @param context the execution context for which this session is to be established; may not be null
69 * @param changes the set of changes to the content
70 * @throws IllegalArgumentException if the path is null
71 * @throws RepositorySourceException if there is a problem accessing the content
72 * @throws SearchEngineException if there is a problem updating the indexes
73 */
74 void index( ExecutionContext context,
75 final Iterable<ChangeRequest> changes ) throws SearchEngineException;
76 }