Commit b7541a11 authored by David Feliot's avatar David Feliot
Browse files

JORAM-191: create messages with the message factory.

parent 1776e76c
......@@ -23,6 +23,9 @@ package fr.dyade.aaa.agent;
import java.io.IOException;
import fr.dyade.aaa.common.encoding.EncodableFactory;
import fr.dyade.aaa.common.encoding.EncodableFactoryRepository;
/**
* Context enabling an <code>AgentEngine</code> implemented in
* another package to invoke operations that cannot be accessed
......@@ -33,6 +36,9 @@ import java.io.IOException;
*/
class AgentEngineContextImpl implements AgentEngineContext {
private static EncodableFactory messageFactory = EncodableFactoryRepository
.getFactory(AgentServer.MESSAGE_CLASS_ID);
/**
* Package constructor not accessible from outside this package.
*/
......@@ -137,7 +143,15 @@ class AgentEngineContextImpl implements AgentEngineContext {
* @return
*/
public Message createMessage(AgentId from, AgentId to, Notification not) {
return Message.alloc(from, to, not);
Message msg = (Message) messageFactory.createEncodable();
msg.from = from;
msg.to = to;
if (not != null) {
msg.not = not;
msg.not.detached = not.detached;
msg.not.messageId = not.messageId;
}
return msg;
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment