Skip to content

Instantly share code, notes, and snippets.

View csadilek's full-sized avatar

Christian Sadilek csadilek

  • Mozilla
  • Toronto
View GitHub Profile
package org.jboss.errai.jpa.client.local;
import com.google.gwt.json.client.JSONObject;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import javax.persistence.CascadeType;
import javax.persistence.TypedQuery;
import javax.persistence.metamodel.Attribute.PersistentAttributeType;
import javax.persistence.metamodel.Bindable.BindableType;
.E17l0oxA {
background : greenyellow;
margin-top : 3px;
}
.E17l0oxB , .E17l0oxC {
background : greenyellow;
}
div.E17l0oxD {
text-decoration : #000;
}
.E17l0oxA {
background : greenyellow;
margin-top : 3px;
}
.E17l0oxB , .E17l0oxC {
background : greenyellow;
}
div.E17l0oxD {
text-decoration : #000;
}
@Templated
@Page
public class GroceryListView extends Composite {
@PageState
private long activeUserId;
@Sync(query = "groceryListsForUser",
params = { @SyncParam(name = "userId", val = "{activeUserId}") })
private void onDataSyncComplete(SyncResponses<GroceryList> responses) {
@UncaughtException
private void onUncaughtException(Throwable caught) {
try {
throw caught;
}
catch (UserNotAuthenticatedException e) {
// navigate to login dialog
}
catch (Throwable t) {
logger.error("An unexpected error has occurred", t);
@Remote
public interface LongRunningService {
public CallableFuture<String> someLongRunningTask();
}
@Service
public class LongRunningServiceImpl implements LongRunningService {
@Override
public CallableFuture<String> someLongRunningTask() {
final CallableFuture<String> future =
CallableFutureFactory.get().createFuture(String.class);
// Start some asynchronous, potentially slow computation
SomeSlowStringComputation slow = new SomeSlowStringComputation();
@Dependent
@InterceptsRemoteCall({ MyRemoteInterface.class, MyOtherRemoteInterface.class })
public class MyCacheInterceptor implements RpcInterceptor {
@Inject
private MyAppCache cache;
@Override
public void aroundInvoke(final RemoteCallContext context) {
// e.g check if the result is cached and carry out
java.sql.Date sqldate = new java.sql.Date(70, 0, 2);
DateFormat df = DateFormat.getDateTimeInstance();
df.setTimeZone( TimeZone.getTimeZone( "GMT" ) );
System.out.println("Created with YMD: " + df.format(sqldate));
public class BasicAuthInterceptor implements RestClientInterceptor {
@Override
public void aroundInvoke(final RestCallContext context) {
RequestBuilder builder = context.getRequestBuilder();
builder.setUser(MyApp.getCurrentUser().getName());
builder.setPassword(MyApp.getCurrentUser().getPassword());
context.proceed();
}