01: /**
02: * Sequoia: Database clustering technology.
03: * Copyright (C) 2002-2004 French National Institute For Research In Computer
04: * Science And Control (INRIA).
05: * Contact: sequoia@continuent.org
06: *
07: * Licensed under the Apache License, Version 2.0 (the "License");
08: * you may not use this file except in compliance with the License.
09: * You may obtain a copy of the License at
10: *
11: * http://www.apache.org/licenses/LICENSE-2.0
12: *
13: * Unless required by applicable law or agreed to in writing, software
14: * distributed under the License is distributed on an "AS IS" BASIS,
15: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16: * See the License for the specific language governing permissions and
17: * limitations under the License.
18: *
19: * Initial developer(s): Emmanuel Cecchet.
20: * Contributor(s): ______________________________________.
21: */package org.continuent.sequoia.controller.requestmanager;
22:
23: import java.sql.SQLException;
24:
25: import org.continuent.sequoia.common.sql.schema.DatabaseSchema;
26: import org.continuent.sequoia.controller.requests.AbstractRequest;
27:
28: /**
29: * This thread is used to process request parsing in background.
30: *
31: * @author <a href="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet</a>
32: * @version 1.0
33: */
34: public class ParserThread extends Thread {
35: private boolean isCaseSensitive;
36: private AbstractRequest request;
37: private DatabaseSchema dbs;
38: private int granularity;
39:
40: /**
41: * Creates a new ParserThread
42: *
43: * @param request the request to parse
44: * @param dbs the database schema
45: * @param granularity the parsing granularity to use
46: * @param isCaseSensitive true if parsing is case sensitive
47: */
48: public ParserThread(AbstractRequest request, DatabaseSchema dbs,
49: int granularity, boolean isCaseSensitive) {
50: this .request = request;
51: this .dbs = dbs;
52: this .granularity = granularity;
53: this .isCaseSensitive = isCaseSensitive;
54: start();
55: }
56:
57: /**
58: * @see java.lang.Runnable#run()
59: */
60: public void run() {
61: try {
62: if (!request.isParsed())
63: request.parse(dbs, granularity, isCaseSensitive);
64: } catch (SQLException e) {
65: System.err.println("Error while parsing request (" + e
66: + ")");
67: }
68: }
69:
70: }
|