summaryrefslogtreecommitdiffstats
path: root/sandbox/wjaniszewski/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/ErlangInvoker.java
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/wjaniszewski/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/ErlangInvoker.java')
-rw-r--r--sandbox/wjaniszewski/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/ErlangInvoker.java27
1 files changed, 17 insertions, 10 deletions
diff --git a/sandbox/wjaniszewski/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/ErlangInvoker.java b/sandbox/wjaniszewski/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/ErlangInvoker.java
index 9a540fd5bb..7cd23aa1b1 100644
--- a/sandbox/wjaniszewski/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/ErlangInvoker.java
+++ b/sandbox/wjaniszewski/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/ErlangInvoker.java
@@ -66,10 +66,6 @@ public class ErlangInvoker implements Invoker {
}
}
- private boolean isCookieProvided() throws Exception {
- return binding.getCookie() != null && binding.getCookie().length() > 0;
- }
-
private String getClientNodeName() {
return "_connector_to_" + binding.getNode()
+ System.currentTimeMillis();
@@ -80,7 +76,7 @@ public class ErlangInvoker implements Invoker {
OtpNode node = null;
try {
node = new OtpNode(getClientNodeName());
- if (isCookieProvided()) {
+ if (binding.hasCookie()) {
node.setCookie(binding.getCookie());
}
tmpMbox = node.createMbox();
@@ -89,7 +85,12 @@ public class ErlangInvoker implements Invoker {
tmpMbox.send(msg.getOperation().getName(), binding.getNode(),
msgPayload);
if (msg.getOperation().getOutputType() != null) {
- OtpMsg resultMsg = tmpMbox.receiveMsg(binding.getTimeout());
+ OtpMsg resultMsg = null;
+ if (binding.hasTimeout()) {
+ resultMsg = tmpMbox.receiveMsg(binding.getTimeout());
+ } else {
+ resultMsg = tmpMbox.receiveMsg();
+ }
OtpErlangObject result = resultMsg.getMsg();
msg.setBody(TypeHelpersProxy.toJava(result, msg.getOperation()
.getOutputType().getPhysical()));
@@ -120,7 +121,7 @@ public class ErlangInvoker implements Invoker {
OtpConnection connection = null;
try {
self = new OtpSelf(getClientNodeName());
- if (isCookieProvided()) {
+ if (binding.hasCookie()) {
self.setCookie(binding.getCookie());
}
other = new OtpPeer(binding.getNode());
@@ -131,8 +132,12 @@ public class ErlangInvoker implements Invoker {
.createRef(), binding.getModule(), msg.getOperation()
.getName(), params);
connection.send(MessageHelper.RPC_MBOX, message);
- OtpErlangObject rpcResponse = connection.receive(binding
- .getTimeout());
+ OtpErlangObject rpcResponse = null;
+ if (binding.hasTimeout()) {
+ rpcResponse = connection.receive(binding.getTimeout());
+ } else {
+ rpcResponse = connection.receive();
+ }
OtpErlangObject result = ((OtpErlangTuple) rpcResponse)
.elementAt(1);
if (MessageHelper.isfunctionUndefMessage(result)) {
@@ -153,7 +158,9 @@ public class ErlangInvoker implements Invoker {
}
} catch (OtpAuthException e) {
// TODO: externalize message?
- ErlangException ee = new ErlangException("Problem while authenticating client - check your cookie", e);
+ ErlangException ee = new ErlangException(
+ "Problem while authenticating client - check your cookie",
+ e);
msg.setBody(null);
reportProblem(msg, ee);
} catch (InterruptedException e) {