use of org.neo4j.cluster.com.message.MessageType in project neo4j by neo4j.
the class StateMachineProxyFactory method invoke.
Object invoke(StateMachine stateMachine, Method method, Object arg) throws Throwable {
if (method.getName().equals("toString")) {
return me.toString();
}
if (method.getName().equals("equals")) {
return ((StateMachineProxyHandler) Proxy.getInvocationHandler(arg)).getStateMachineProxyFactory().me.equals(me);
}
String conversationId = conversations.getNextConversationId();
try {
Class<? extends MessageType> messageType = stateMachine.getMessageType();
MessageType typeAsEnum = (MessageType) Enum.valueOf((Class<? extends Enum>) messageType, method.getName());
Message<?> message = Message.internal(typeAsEnum, arg);
if (me != null) {
message.setHeader(Message.CONVERSATION_ID, conversationId).setHeader(Message.CREATED_BY, me.toString());
}
if (method.getReturnType().equals(Void.TYPE)) {
stateMachines.process(message);
return null;
} else {
ResponseFuture future = new ResponseFuture(conversationId, typeAsEnum, responseFutureMap);
responseFutureMap.put(conversationId, future);
log.debug("Added response future for conversation id %s", conversationId);
stateMachines.process(message);
return future;
}
} catch (IllegalArgumentException e) {
throw new IllegalStateException("No state machine can handle the method " + method.getName());
}
}
use of org.neo4j.cluster.com.message.MessageType in project neo4j by neo4j.
the class MessageDeliveryAction method messageCopy.
private Message<? extends MessageType> messageCopy() throws URISyntaxException {
URI to = new URI(message.getHeader(Message.TO));
Message<MessageType> copy = Message.to(message.getMessageType(), to, message.getPayload());
return message.copyHeadersTo(copy);
}
Aggregations