Errai 3.0.1-SNAPSHOT

org.jboss.errai.jpa.sync.client.local
Annotation Type Sync


@Documented
@Target(value=METHOD)
@Retention(value=RUNTIME)
public @interface Sync

Specifies that a ClientSyncWorker should be created with the given query and query parameters, and that s sync worker will be started when this bean is first created and stopped when this bean is destroyed.

The annotated method needs to have exactly one parameter of type SyncResponses and will be called each time a data synch operation has completed. All sync operations passed to the method will have already been applied to the local EntityManager, with conflicts resolved in favour of the server's version of the data. The original client values are available in the SyncResponses object, which gives you a chance to implement a different conflict resolution policy.

Example usage:

 public class ExampleBean {
 
   private long id;
   private String name;
   private SyncResponses responses;
   
   @Sync(query = "simpleEntitiesByIdAndString",
       params = { @SyncParam(name = "id", val = "{id}"),
                  @SyncParam(name = "string", val = "{name}"),
                  @SyncParam(name = "literal", val = "literalValue") })
   private void onSyncResponse(SyncResponses<SimpleEntity> responses) {
     // enjoy
   }
 }
 

Author:
Jonathan Fuerth , Christian Sadilek

Required Element Summary
 String query
          The name of the named query that will be used for the sync operation.
 
Optional Element Summary
 SyncParam[] params
          The optional parameters of the query.
 

Element Detail

query

public abstract String query
The name of the named query that will be used for the sync operation.

params

public abstract SyncParam[] params
The optional parameters of the query.

Default:
{}

Errai 3.0.1-SNAPSHOT

Copyright © 2013-2014 JBoss, a division of Red Hat. All Rights Reserved.