The BlazeDS documentation shows how to explicitly map between ActionScript and Java objects. For example, this works fine for RPC services, e.g.
import flash.utils.IExternalizable;
import flash.utils.IDataInput;
import flash.utils.IDataOutput;
[Bindable]
[RemoteClass(alias="javaclass.User")]
public class User implements IExternalizable {
public var id : String;
public var secret : String;
public function User() {
}
public function readExternal(input : IDataInput) : void {
id = input.readObject() as String;
}
public function writeExternal(output : IDataOutput) : void {
output.writeObject(id);
}
}
and
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
public class User implements Externalizable {
protected String id;
protected String secret;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getSecret() {
return secret;
}
public void setSecret(String secret) {
this.secret = secret;
}
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
id = (String) in.readObject();
}
public void writeExternal(ObjectOutput out) throws IOException {
out.writeObject(id);
}
}
If I called an RPC service that returns a User
, the secret
is not sent over the wire.
Is it also possible to do this for the messaging service? That is, if I create a custom messaging adapter and use the function below, can I also prevent secret
from being sent?
MessageBroker messageBroker = MessageBroker.getMessageBroker(null);
AsyncMessage message = new AsyncMessage();
message.setDestination("MyMessagingService");
message.setClientId(UUIDUtils.createUUID());
message.setMessageId(UUIDUtils.createUUID());
User user = new User();
user.setId("id");
user.setSecret("secret");
message.setBody(user);
messageBroker.routeMessageToService(message, null);