KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > slide > store > DefaultIndexer


1 /*
2  * $Header:
3  * $Revision: 1.5 $
4  * $Date:
5  *
6  * ====================================================================
7  *
8  * Copyright 1999 The Apache Software Foundation
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */

23 package org.apache.slide.store;
24 import java.util.Hashtable JavaDoc;
25 import org.apache.slide.common.XAServiceBase;
26 import org.apache.slide.common.ServiceAccessException;
27 import org.apache.slide.common.ServiceConnectionFailedException;
28 import org.apache.slide.common.ServiceDisconnectionFailedException;
29 import org.apache.slide.common.ServiceParameterErrorException;
30 import org.apache.slide.common.ServiceParameterMissingException;
31 import org.apache.slide.common.ServiceResetFailedException;
32 import org.apache.slide.common.Uri;
33 import org.apache.slide.content.NodeRevisionContent;
34 import org.apache.slide.content.NodeRevisionDescriptor;
35 import org.apache.slide.content.NodeRevisionNumber;
36 import org.apache.slide.search.IndexException;
37 import org.apache.slide.search.basic.IBasicExpressionFactory;
38 import org.apache.slide.search.basic.IBasicExpressionFactoryProvider;
39 import org.apache.slide.store.IndexStore;
40
41
42 /**
43  * DefaultIndexer is loaded, when no Indexer was explicitly configured for a
44  * store (content or properties). Initilializes with the store specific
45  * indexer if store implements IBasicExpressionFactoryProvider, else with null,
46  * which means, no search possible on store (unless generic search).
47  * Fakes two phase commit.
48  *
49  * @version $Revision: 1.5 $
50  */

51 public class DefaultIndexer extends XAServiceBase implements IndexStore
52 {
53     private final IBasicExpressionFactoryProvider expressionProvider;
54     
55     /**
56      * Uses the ExpressionFactory of associated store (if applicable)
57      *
58      * @param associatedStore a properties- or content store
59      *
60      */

61     public DefaultIndexer (Object JavaDoc associatedStore) {
62         if (associatedStore instanceof IBasicExpressionFactoryProvider) {
63             expressionProvider = (IBasicExpressionFactoryProvider) associatedStore;
64         }
65         else {
66             expressionProvider = null;
67         }
68     }
69     
70     /**
71      * As defined in IBasicExpressionFactoryProvider
72      *
73      * @return an IBasicExpressionFactory
74      *
75      */

76     public IBasicExpressionFactory getBasicExpressionFactory()
77     {
78         if (expressionProvider != null) {
79             return expressionProvider.getBasicExpressionFactory();
80         }
81         return null;
82     }
83     
84     // used for two phase commit state
85
private boolean started = false;
86     
87     
88     /**
89      * Index an object content. Do nothing.
90      *
91      * @param uri Uri
92      * @exception IndexException Error accessing the Data Source
93      */

94     public void createIndex(Uri uri, NodeRevisionDescriptor revisionDescriptor,
95                             NodeRevisionContent revisionContent)
96         throws IndexException
97     {
98         // do nothing
99
}
100     
101     /**
102      * updates an index for a resource
103      *
104      * @param uri uri of the resource
105      * @param number nodeRevisionNumber of the resource
106      * @param revisionContent the content of the resource
107      *
108      * @throws IndexException
109      *
110      */

111     public void updateIndex(Uri uri, NodeRevisionDescriptor revisionDescriptor, NodeRevisionContent revisionContent) throws IndexException
112     {
113         // do nothing
114
}
115     
116     
117     /**
118      * Drop an object revision from the index. Do nothing
119      *
120      * @param uri Uri
121      * @exception IndexException Error accessing the Data Source
122      */

123     public void dropIndex(Uri uri, NodeRevisionNumber number)
124         throws IndexException
125     {
126         // do nothing
127
}
128     
129     /**
130      * Connects to the underlying data source (if any is needed).
131      *
132      * @exception ServiceConnectionFailedException Connection failed
133      */

134     public void connect() throws ServiceConnectionFailedException
135     {
136         started = true;
137     }
138     
139     /**
140      * This function tells whether or not the service is connected.
141      *
142      * @return boolean true if we are connected
143      * @exception ServiceAccessException Service access error
144      */

145     public boolean isConnected() throws ServiceAccessException
146     {
147         return started;
148     }
149     
150     /**
151      * Initializes the service with a set of parameters. Those could be :
152      * <li>User name, login info
153      * <li>Host name on which to connect
154      * <li>Remote port
155      * <li>JDBC driver whoich is to be used :-)
156      * <li>Anything else ...
157      *
158      * @param parameters Hashtable containing the parameters' names
159      * and associated values
160      * @exception ServiceParameterErrorException Incorrect service parameter
161      * @exception ServiceParameterMissingException Service parameter missing
162      */

163     public void setParameters(Hashtable JavaDoc parameters) throws ServiceParameterErrorException, ServiceParameterMissingException
164     {
165         // do nothing
166
}
167     
168     /**
169      * Disconnects from the underlying data source.
170      *
171      * @exception ServiceDisconnectionFailedException Disconnection failed
172      */

173     public void disconnect() throws ServiceDisconnectionFailedException
174     {
175         started = false;
176     }
177     
178     /**
179      * Deletes service underlying data source, if possible (and meaningful).
180      *
181      * @exception ServiceResetFailedException Reset failed
182      */

183     public void reset() throws ServiceResetFailedException
184     {
185         // do nothing
186
}
187     
188 }
189
190
Popular Tags