@Managed public abstract class Query<T> extends java.lang.Object
KeyQuery
results calls.
A Query
notifier does not directly return results.
The notification provides an opportunity to change the contents of
shared memory (creating and or deleting Managed objects) before
a keyed query is done.
For example, it could be used for creating Managed objects from data
in a database.
Modifier | Constructor and Description |
---|---|
protected |
Query(java.lang.Class<T> klass,
java.lang.String keyName)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getKeyName()
Get the name of the key for this Query notifier.
|
static Query<?> |
getNotifier(java.lang.Class<?> klass,
java.lang.String key)
Return the currently installed Query notifier for
the Managed class and key.
|
abstract void |
query(java.lang.Class<? extends T> klass,
LockMode lockMode,
java.util.ArrayList<KeyField> queryData)
Notifier method for
KeyQuery results calls. |
abstract void |
queryMaximum(java.lang.Class<? extends T> klass,
LockMode lockMode,
java.util.ArrayList<KeyField> queryData)
Notifier method for
KeyQuery.getMaximumResult(com.kabira.platform.LockMode) calls. |
abstract void |
queryMinimum(java.lang.Class<? extends T> klass,
LockMode lockMode,
java.util.ArrayList<KeyField> queryData)
Notifier method for
KeyQuery.getMinimumResult(com.kabira.platform.LockMode) calls. |
protected Query(java.lang.Class<T> klass, java.lang.String keyName) throws ManagedClassError, KeyUnknownKeyNameError
Creating an instance automatically installs it as the query notifier for the associated Managed class and key.
A notifier may only be set on the class where the key is defined.
The notifier will apply to queries on the class where the key is defined, and queries on classes which inherit the key.
If a notifier is already installed for the key, the new instance replaces the previous instance.
Deleting a notifier automatically uninstalls it.
Notifiers are automatically deleted when the JVM shuts down. Notifiers created in other JVMs are not affected.
When a KeyQuery
results method is called, the Query notifier
for the key will be called before executing the query.
klass
- The Managed class where
keyName
is defined.keyName
- The key to receive query notifications for.ManagedClassError
- If klass
is not managed.KeyUnknownKeyNameError
- if keyName
is not
defined on klass
.public static Query<?> getNotifier(java.lang.Class<?> klass, java.lang.String key)
Inheritance is not examined by this method.
klass
- Class where key is defined.key
- Name of key.ManagedClassError
- If klass
is not managed.KeyUnknownKeyNameError
- If keyName
is not
defined on klass
.public final java.lang.String getKeyName()
public abstract void query(java.lang.Class<? extends T> klass, LockMode lockMode, java.util.ArrayList<KeyField> queryData)
KeyQuery
results calls.
Called by the system when following KeyQuery methods are called, but before they are executed:
KeyQuery.getOrCreateSingleResult(com.kabira.platform.LockMode, com.kabira.platform.KeyFieldValueList)
- for unique keys
KeyQuery.getSingleResult(com.kabira.platform.LockMode)
- for unique keys
KeyQuery.getResults(com.kabira.platform.LockMode)
- for non unique keys
KeyOrderedBy
does not need to be
considered by the notifier.
Result set ordering is handled by the runtime when the
query executes.
Will be called on each of the nodes in the
QueryScope
of the KeyQuery results call.
Work done within Query.query() will not generate calls to com.kabira.store notifiers on the local node.
Note: work done within the Query.query() method will generate calls to com.kabira.store notifiers on remote nodes.
klass
- The Managed class for the query results call.
This may be a subtype of the class
associated with the notifier.lockMode
- The lock mode for the query results. The notifier
implementation should attempt to honor this lock mode,
but there is no enforcement.queryData
- The query data, ordered as the caller added it
to the KeyFieldValueList
or KeyFieldValueRangeList
for the query.
See KeyField
.public abstract void queryMinimum(java.lang.Class<? extends T> klass, LockMode lockMode, java.util.ArrayList<KeyField> queryData)
KeyQuery.getMinimumResult(com.kabira.platform.LockMode)
calls.
Called by the system when KeyQuery.getMinimumResult is called, but before it is executed.
Will be called on each of the nodes in the
QueryScope
of getMinimumResult
call.
Work done within Query.queryMinimum() will not generate calls to com.kabira.store notifiers on the local node.
Note: work done within Query.queryMinimum() will generate calls to com.kabira.store notifiers on remote nodes.
klass
- The Managed class for the getMinimumResult call.
This may be a subtype of the class associated
with the notifier.lockMode
- The lock mode for the query result. The notifier
implementation should attempt to honor this lock mode,
but there is no enforcement.queryData
- The query data, ordered as the caller added it
to the KeyFieldValueList
or KeyFieldValueRangeList
for the query.
See KeyField
.public abstract void queryMaximum(java.lang.Class<? extends T> klass, LockMode lockMode, java.util.ArrayList<KeyField> queryData)
KeyQuery.getMaximumResult(com.kabira.platform.LockMode)
calls.
Called by the system when KeyQuery.getMaximumResult is called, but before it is executed.
Will be called on each of the nodes in the
QueryScope
of getMaximumResult
call.
Work done within Query.queryMaximum() will not generate calls to com.kabira.store notifiers on the local node.
Note: work done within Query.queryMaximum() will generate calls to com.kabira.store notifiers on remote nodes.
klass
- The Managed class for the getMaximumResult call.
This may be a subtype of the class associated with
the notifier.lockMode
- The lock mode for the query result. The notifier
implementation should attempt to honor this lock mode,
but there is no enforcement.queryData
- The query data, ordered as the caller added it
to the KeyFieldValueList
or KeyFieldValueRangeList
for the query.
See KeyField
.