|
Errai 3.0.1-SNAPSHOT | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jboss.errai.jpa.sync.client.local.ClientSyncWorker<E>
E
- The entity type this worker's named query returns.public class ClientSyncWorker<E>
Handles the job of keeping one JPA NamedQuery
in sync between the client and server. A
ClientSyncWorker has three states:
#start()
,
and stop them with a call to stop()
. Once started, a sync worker instance can be stopped
but not restarted. Once stopped, a sync worker cannot be restarted.
Nested Class Summary | |
---|---|
static interface |
ClientSyncWorker.QueryParamInitCallback
A callback that provides parameters for the query used by a ClientSyncWorker . |
Constructor Summary | |
---|---|
ClientSyncWorker(ClientSyncManager manager,
String queryName,
Class<E> queryResultType,
ErrorCallback<?> onError)
Creates a new ClientSyncWorker which takes responsibility for syncing the results of the named JPA query. |
Method Summary | ||
---|---|---|
void |
addSyncCallback(DataSyncCallback<E> onCompletion)
Registers the given callback to receive notifications each time a sync operation has been performed. |
|
static
|
create(String queryName,
Class<E> queryResultType,
ErrorCallback<?> onError)
Creates a new ClientSyncWorker which takes responsibility for syncing the results of the named JPA query. |
|
void |
start(Map<String,Object> queryParams)
Starts this sync worker if it has not already been started or stopped. |
|
void |
start(Object beanInstance,
ClientSyncWorker.QueryParamInitCallback queryParamCallback)
Starts this sync worker if it has not already been started or stopped. |
|
void |
stop()
Stops this sync worker if it is running. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ClientSyncWorker(ClientSyncManager manager, String queryName, Class<E> queryResultType, ErrorCallback<?> onError)
This constructor is primarily intended for testing. Consider using
#create(String, Class, Map, ErrorCallback)
instead, which obtains an instance of
ClientSyncManager from the IOC Bean Manager.
manager
- The instance of ClientSyncManager that should be used for all data sync operations.queryName
- The name of a JPA named query. Must be visible to client-side code, and if it has
parameters, they must be named (not positional) parameters.queryResultType
- The result type returned by the named query.onError
- Error callback that should be invoked if any sync request encounters a data
transmission error on the bus. If null, transmission errors are logged to the slf4j
logger for the ClientSyncWorker
class.Method Detail |
---|
public static <E> ClientSyncWorker<E> create(String queryName, Class<E> queryResultType, ErrorCallback<?> onError)
E
- The entity type the named query returns.queryName
- The name of a JPA named query. Must be visible to client-side code, and if it has
parameters, they must be named (not positional) parameters.queryResultType
- The result type returned by the named query.onError
- Error callback that should be invoked if any sync request encounters a data
transmission error on the bus. If null, transmission errors are logged to the slf4j
logger for the ClientSyncWorker
class.
public void addSyncCallback(DataSyncCallback<E> onCompletion)
onCompletion
- the callback to notify of completed sync operations. Must not be null.public void start(Map<String,Object> queryParams)
queryParams
- Name-value pairs for all named parameters in the named query. Never null.
IllegalStateException
- if this sync worker has been stopped.public void start(Object beanInstance, ClientSyncWorker.QueryParamInitCallback queryParamCallback)
beanInstance
- The managed bean instance the observes the sync results and defines the query
parameters.queryParamCallback
- A ClientSyncWorker.QueryParamInitCallback
that provides the query parameters for this
ClientSyncWorker
's query.
IllegalStateException
- if this sync worker has been stopped.public void stop()
IllegalStateException
- if this sync worker has not yet been started.
|
Errai 3.0.1-SNAPSHOT | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |