本文整理匯總了Java中org.jboss.errai.bus.client.ErraiBus類的典型用法代碼示例。如果您正苦於以下問題:Java ErraiBus類的具體用法?Java ErraiBus怎麽用?Java ErraiBus使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ErraiBus類屬於org.jboss.errai.bus.client包,在下文中一共展示了ErraiBus類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initBtns
import org.jboss.errai.bus.client.ErraiBus; //導入依賴的package包/類
private void initBtns() {
Button btnMessageCallback = new Button("MessageCallback");
btnMessageCallback.addClickHandler(event -> {
MessageBuilder.createMessage().toSubject("ErraiMessageCallbackService").signalling().noErrorHandling()
.sendNowWith(ErraiBus.getDispatcher());
Window.alert("See log statements for printed message from MessageCallback implementation");
});
RootPanel.get().add(btnMessageCallback);
Button btnCommand1 = new Button("CommandService: command1");
btnCommand1.addClickHandler(event -> {
MessageBuilder.createMessage().toSubject("ErraiCommandService").command("command1").noErrorHandling()
.sendNowWith(ErraiBus.getDispatcher());
Window.alert(
"See log statements for printed message from Service with @Command annotated methods: command name equals method name");
});
RootPanel.get().add(btnCommand1);
Button btnCommand2 = new Button("CommandService: command2");
btnCommand2.addClickHandler(event -> {
MessageBuilder.createMessage().toSubject("ErraiCommandService").command("CMD2").noErrorHandling()
.sendNowWith(ErraiBus.getDispatcher());
Window.alert(
"See log statements for printed message from Service with @Command annotated methods: command name specified in annotation");
});
RootPanel.get().add(btnCommand2);
Button btnRPCPing = new Button("RPC: ping");
btnRPCPing.addClickHandler(event -> {
messageServiceCaller.call(new RemoteCallback<RPCResult>() {
@Override
public void callback(RPCResult result) {
Window.alert("Ping result: " + result.getResult());
}
}).callPing();
});
RootPanel.get().add(btnRPCPing);
Button btnRPCTrigger = new Button("ADMIN ONLY RPC: trigger");
btnRPCTrigger.addClickHandler(event -> {
messageServiceCaller.call(new RemoteCallback<Void>() {
@Override
public void callback(Void response) {
logger.info("done calling trigger");
// this would have trigger bus subscription
// MessageFromServer if user had admin role
}
}, new ErrorCallback<Message>() {
@Override
public boolean error(Message message, Throwable t) {
logger.log(Level.SEVERE, "after calling trigger", t);
if (t instanceof UnauthenticatedException) {
return true;
} else if (t instanceof UnauthorizedException) {
Window.alert("Did not pass admin authorization for RPC call: trigger");
return true;
} else {
return true;
}
}
}).triggerMessage();
});
RootPanel.get().add(btnRPCTrigger);
// logout is probably best handled with SpringSecurity logout url
// but using auth service for example
Button btnLogout = new Button("Logout");
btnLogout.addClickHandler(event -> {
authenticationServiceCaller.call().logout();
});
RootPanel.get().add(btnLogout);
}