KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cayenne > query > Query


1 /*****************************************************************
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  ****************************************************************/

19
20 package org.apache.cayenne.query;
21
22 import java.io.Serializable JavaDoc;
23
24 import org.apache.cayenne.access.QueryEngine;
25 import org.apache.cayenne.map.EntityResolver;
26
27 /**
28  * Defines minimal API of a query descriptor that is executable via Cayenne.
29  *
30  * @author Andrus Adamchik
31  */

32 public interface Query extends Serializable JavaDoc {
33
34     /**
35      * Returns query runtime parameters. The method is called at various stages of the
36      * execution by Cayenne access stack to retrieve query parameters. EntityResolver
37      * instance is passed to this method, meaning that the query doesn't need to store
38      * direct references to Cayenne mapping objects and can resolve them at runtime.
39      *
40      * @since 1.2
41      */

42     QueryMetadata getMetaData(EntityResolver resolver);
43
44     /**
45      * A callback method invoked by Cayenne during the routing phase of the query
46      * execution. Mapping of DataNodes is provided by QueryRouter. Query should use a
47      * {@link QueryRouter#route(QueryEngine, Query, Query)} callback method to route
48      * itself. Query can create one or more substitute queries or even provide its own
49      * QueryEngine to execute itself.
50      *
51      * @since 1.2
52      */

53     void route(QueryRouter router, EntityResolver resolver, Query substitutedQuery);
54
55     /**
56      * A callback method invoked by Cayenne during the final execution phase of the query
57      * run. A concrete query implementation is given a chance to decide how it should be
58      * handled. Implementors can pick an appropriate method of the SQLActionVisitor to
59      * handle itself, create a custom SQLAction of its own, or substitute itself with
60      * another query that should be used for SQLAction construction.
61      *
62      * @since 1.2
63      */

64     SQLAction createSQLAction(SQLActionVisitor visitor);
65
66     /**
67      * Returns a symbolic name of the query. The name may be used as a key to find queries
68      * stored in the DataMap. Some query implementors reuse the name as a QueryMetadata
69      * cache key. Generally the name can be null.
70      *
71      * @since 1.1
72      */

73     String JavaDoc getName();
74 }
75
Popular Tags