E
- The entity type this worker's named query returns.public class ClientSyncWorker<E> extends Object
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.Modifier and Type | Class and Description |
---|---|
static interface |
ClientSyncWorker.QueryParamInitCallback
A callback that provides parameters for the query used by a
ClientSyncWorker . |
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
void |
addSyncCallback(DataSyncCallback<E> onCompletion)
Registers the given callback to receive notifications each time a sync operation has been
performed.
|
static <E> ClientSyncWorker<E> |
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.
|
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.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.Copyright © 2013-2015 JBoss, a division of Red Hat. All Rights Reserved.