|
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.ClientSyncManager
@ApplicationScoped public class ClientSyncManager
The main contact point for applications that want to initiate data sync operations from the client side of an Errai application.
Field Summary | |
---|---|
Caller<DataSyncService> |
dataSyncService
Temporarily public so we can override the caller from within the tests. |
protected static ErrorCallback<?> |
DEFAULT_ERROR_CALLBACK
|
Constructor Summary | |
---|---|
ClientSyncManager()
|
Method Summary | ||
---|---|---|
void |
clear()
Clears all expected state and actual state data (essentially wiping out all localStorage data that Errai cares about). |
|
|
coldSync(String queryName,
Class<E> queryResultType,
Map<String,Object> queryParams,
RemoteCallback<List<SyncResponse<E>>> onCompletion,
ErrorCallback<?> onError)
Performs a "cold" synchronization on the results of the given query with the given parameters. |
|
ErraiEntityManager |
getDesiredStateEm()
Returns the persistence context that holds the "desired state" of this Client-side Sync Manager (the state that the application has set up, which we will eventually sync to the server). |
|
ErraiEntityManager |
getExpectedStateEm()
Returns the persistence context that holds the "expected state" of this Client-side Sync Manager (the state that we believe the entities have on the server). |
|
static ClientSyncManager |
getInstance()
Returns the global instance of ClientSyncManager. |
|
boolean |
isSyncInProgress()
Returns true if a sync request has been sent to the server for which no response or error has yet been received; false if no sync operation is currently pending. |
|
static void |
resetInstance()
Resets the global instance of ClientSyncManager. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final ErrorCallback<?> DEFAULT_ERROR_CALLBACK
@Inject public Caller<DataSyncService> dataSyncService
Constructor Detail |
---|
public ClientSyncManager()
Method Detail |
---|
public static ClientSyncManager getInstance()
public static void resetInstance()
public <E> void coldSync(String queryName, Class<E> queryResultType, Map<String,Object> queryParams, RemoteCallback<List<SyncResponse<E>>> onCompletion, ErrorCallback<?> onError)
queryName
- The name of a JPA named query. This query must be defined in a NamedQuery
annotation that is visible to both the client and server applications. This usually
means it is defined on an entity in the shared
package.queryResultType
- The result type returned by the query. Must be a JPA entity type known to both the
client and server applications.queryParams
- The name-value pairs to use for filling in the named parameters in the query.onCompletion
- Called when the data sync response has been received from the server, and the sync
response operations have been applied to the expected state and desired state entity
managers. Must not be null. In case of conflicts, the original client values are
available in the list of SyncResponse objects, which gives you a chance to implement a
different conflict resolution policy.onError
- Called when the data sync fails: either because the remote service threw an exception,
or because of a communication error. Can be null, in which case the default error
handling for the Caller<DataSyncService>
will apply.public boolean isSyncInProgress()
coldSync(String, Class, Map, RemoteCallback, ErrorCallback)
will
fail immediately with an IllegalStateException.
public ErraiEntityManager getExpectedStateEm()
public ErraiEntityManager getDesiredStateEm()
public void clear()
|
Errai 3.0.1-SNAPSHOT | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |