|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectthinkmap.datasource.database.QueryDataSource
public class QueryDataSource
A query DataSource handles a query, working in concert with others to make a database DataSource work. You can write custom queries using XML and the query tag which this class represents. Or, you can extend this class and override whichever method you need to for your particular custom query (This is in effect a more convenient way that allows a Java Developer familiar with JDBC to write their own sql statements and create plugins that will be used in the server.tas file under the database datasource).
| Field Summary | |
|---|---|
protected String |
bindableEntityType
|
protected Binding[] |
bindings
|
protected DatabaseDataSource |
database
|
protected boolean |
debug
|
protected EntityResultMapping[] |
entityMappings
|
protected int |
maxResults
|
protected String |
query
|
protected Binding |
rejectionBinding
|
protected int |
requestType
|
| Constructor Summary | |
|---|---|
QueryDataSource()
Creates a new QueryDataSource object. |
|
| Method Summary | |
|---|---|
protected Object[] |
bindParameters(Message message,
SourceEntity entity,
EntityId id)
Get's the binding parameters which will be set on the prepared statement that is generated from the prepareQuery method. |
protected boolean |
canBind(Message message,
SourceEntity entity,
EntityId id)
Check if I can bind to this request and the indicated entity. |
protected void |
executeQuery(Message message,
SourceEntity entity,
EntityId id,
IEntityHandler callback,
Connection c)
The main method that is called to execute the entire query. |
Binding[] |
getArguments()
Get the ArgumentBinding array this QueryDataSource uses. |
String |
getBindableEntityType()
Get the entity type this QueryDataSource responds to. |
Binding |
getRejectionBinding()
Get a binding that will prevent this query from executing. |
int |
getRequestType()
Get the request type this QueryDataSource responds to. |
EntityResultMapping[] |
getResults()
Get the EntityResultMapping array this uses when sending back results. |
String |
getSQL()
Get the query string this QueryDataSource uses. |
protected void |
outputResults(ResultSet rs,
Message message,
SourceEntity entity,
EntityId id,
IEntityHandler callback)
Outputs the results using a resultset which represents the results from the prepared statement that was generated using the prepareQuery method. |
protected PreparedStatement |
prepareQuery(Connection c,
Message message,
SourceEntity entity,
EntityId id,
IEntityHandler callback)
Prepares the query that will be executed. |
void |
processRequest(Message message,
IEntityHandler callback,
Connection connection)
|
void |
setArguments(Binding[] bindings)
Set the array of argument bindings that this query DataSource uses. |
void |
setBindableEntityType(String bindableEntityType)
Set the entity type this query DataSource responds to. |
void |
setDebug(boolean b)
Set the true to enable debug output. |
void |
setMaxResults(int maxResults)
Set the maximum number of results to be returned by this query, or -1 for no limit. |
void |
setRejectionBinding(Binding rejectionBinding)
Set a binding that will prevent this query from executing. |
void |
setRequestType(int requestType)
Set the request type this query DataSource responds to. |
void |
setResults(EntityResultMapping[] entityMappings)
Set the EntityResultMapping array this uses when sending back results. |
void |
setSQL(String sql)
Set the query string used by this query DataSource. |
void |
setType(String type)
Set the type of this query. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected int requestType
protected Binding[] bindings
protected String bindableEntityType
protected String query
protected EntityResultMapping[] entityMappings
protected int maxResults
protected boolean debug
protected DatabaseDataSource database
protected Binding rejectionBinding
| Constructor Detail |
|---|
public QueryDataSource()
| Method Detail |
|---|
public void setSQL(String sql)
sql - new query stringpublic String getSQL()
public void setArguments(Binding[] bindings)
bindings - AgumentBinding arraypublic Binding[] getArguments()
public void setBindableEntityType(String bindableEntityType)
bindableEntityType - entity type namepublic String getBindableEntityType()
public void setType(String type)
type - public void setMaxResults(int maxResults)
maxResults - max resultspublic void setRequestType(int requestType)
requestType - request typepublic int getRequestType()
public void setResults(EntityResultMapping[] entityMappings)
entityMappings - EntityResultMapping arraypublic EntityResultMapping[] getResults()
public void setDebug(boolean b)
b - true to enable debug outputpublic void setRejectionBinding(Binding rejectionBinding)
rejectionBinding - public Binding getRejectionBinding()
public void processRequest(Message message,
IEntityHandler callback,
Connection connection)
protected void executeQuery(Message message,
SourceEntity entity,
EntityId id,
IEntityHandler callback,
Connection c)
message - the incoming message from the cliententity - the entity that was sent to the server from the client during this request (Related Request for instance). Can be null.id - id the id that was sent to the server from the client during this request. Can be null.callback - the EntityHandler that is used to transcribe messages back to the clientc - The JDBC Connection
protected PreparedStatement prepareQuery(Connection c,
Message message,
SourceEntity entity,
EntityId id,
IEntityHandler callback)
throws SQLException
c - The JDBC Connection which is used to generate the prepared statementmessage - the incoming message from the cliententity - the entity that was sent to the server from the client during this request (Related Request for instance). Can be null.id - id the id that was sent to the server from the client during this request. Can be null.callback - the EntityHandler that is used to transcribe messages back to the client
SQLException
protected Object[] bindParameters(Message message,
SourceEntity entity,
EntityId id)
throws BindingException
message - the incoming message from the cliententity - the entity that was sent to the server from the client during this request (Related Request for instance). Can be null.id - id the id that was sent to the server from the client during this request. Can be null.
BindingException
protected void outputResults(ResultSet rs,
Message message,
SourceEntity entity,
EntityId id,
IEntityHandler callback)
throws SQLException,
BindingException
rs - the SQL ResultSetmessage - the original message the came from the cliententity - the entity that was sent to the server from the client during this request (Related Request for instance). Can be null.id - the id that was sent to the server from the client during this request. Can be null.callback - the EntityHandler that is used to transcribe messages back to the client
SQLException
BindingException
protected boolean canBind(Message message,
SourceEntity entity,
EntityId id)
message - incoming messageentity - entity to check (can be null even if id is present)id - id of entity to check (can be null)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||