本文整理汇总了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);
}