----- Forwarded Message -----
From: "Mike Brock" <cbrock(a)redhat.com>
To: "Heiko Braun" <hbraun(a)redhat.com>
Cc: "Lillian Angel" <langel(a)redhat.com>, "Rodney Russ"
<rruss(a)redhat.com>
Sent: Wednesday, October 21, 2009 7:39:40 PM GMT -07:00 US/Canada Mountain
Subject: Serialization working across the bus!
I have managed to get serialization working across the bus with a one-step annotated
process. Now you can expose entities to the bus, which will auto-generate demarshalling
stubs in the client which allow full Java classes to be used within the bus API.
For example:
@Entity
@ExposeEntity
public class User implements Serializable {
@Id private String userId;
private String name;
private String fullname;
private String password;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getFullname() {
return fullname;
}
public void setFullname(String fullname) {
this.fullname = fullname;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Override
public String toString() {
return "userId=" + userId + ";name=" + name + ";fullname=" +
fullname;
}
}
The @ExposeEntity annotation tells Errai it should generate stubs to support it across the
bus. You can then send it across the wire using the standard bus API like magic:
@Service
public class UserManagement implements MessageCallback {
private MessageBus bus;
@Inject
public UserManagement(MessageBus bus) {
this.bus = bus;
}
public void callback(CommandMessage message) {
User user = new User();
user.setName("jdoe");
user.setFullname("John Doe");
user.setUserId("0aE0101");
ConversationMessage.create(message)
.set("UserObj", user)
.sendNowWith(bus);
}
}
... and pull it out on the client side ...
bus.conversationWith(CommandMessage.create()
.toSubject("UserManagement"), new MessageCallback() {
public void callback(CommandMessage message) {
User user = message.get(User.class, "UserObj");
System.out.println("::" + user.toString());
}
});
This is one giant leap towards supporting things like WebBeans and JPA on the client side
over ErraiBus.
Thoughts?
Mike.
Show replies by date