Hi,
I am working in a flex application using spring,hibernate and axon. In
the logon process I want to return some data: the aggregate id, a
authenticate string code and some other data like user state, passwrod
expiring days, etc.
I've decide to use a command handler cause this process changes the
state of the server, but i have problems receiving the response in
flex. I'm receiving a void ProxyObject.
Where am i wrong? Anyone can help me? Can i found any example
returning data to flex client?
Thanks!!
Code:
public class UsuariCommandHandler {
private Repository<Usuari> repository;
private UsuariRepository usuariRepository;
@CommandHandler
public UsuariAuthenticatedResult
handleAuthenticateUser(UsuariAuthenticateCommand command) throws
DeskException {
Assert.notNull(command.getIdent(),
"usuari.authenticate.ident.null");
Assert.notNull(command.getPassword(),
"usuari.authenticate.password.null");
try {
Usuari usuari;
String usuariId = command.getUsuariId();
if (usuariId == null) {
usuariId = UUID.randomUUID().toString();
UsuariEntry account =
usuariRepository.getByIdent(command.getIdent());
usuari = new Usuari(new
StringAggregateIdentifier(usuariId),account);
usuari.authenticate(command.getPassword());
repository.add(usuari);
} else {
usuari = repository.load(new
StringAggregateIdentifier(usuariId));
}
String code = usuari.authorize(command.getToken());
UsuariAuthenticatedResult result = new
UsuariAuthenticatedResult(usuariId,code,usuari.getUsuariState(),usuari.daysToExpirePassword());
return result;
} catch (NoResultException e) {
throw new UsuariException(e);
}
}
@Autowired
public void setRepository(Repository<Usuari> repository) {
this.repository = repository;
}
@Autowired
public void setUsuariRepository(UsuariRepository userRepository) {
this.usuariRepository = userRepository;
}
}
Flex:
package commands.system
{
import commands.BaseController;
import model.system.UserAuthenticateEvent;
import mx.messaging.messages.AcknowledgeMessage;
import mx.rpc.AsyncToken;
import mx.rpc.events.FaultEvent;
public class LoginUserController extends BaseController {
public function LoginUserController() {
super();
}
public function execute(event:UserAuthenticateEvent):AsyncToken {
var command:UsuariAuthenticateCommand = new
UsuariAuthenticateCommand();
command.ident = event.user.ident;
command.password = event.user.password;
return commandReceiver.sendCommand(command);
}
public function result(result:*):void {
return;
}
}
}