From fce6ad4c30b15b4284a94e7a00e084bf18748cf2 Mon Sep 17 00:00:00 2001 From: wjaniszewski Date: Fri, 20 Mar 2009 14:23:51 +0000 Subject: Added configurable timeout and cookies for service bindings. Consequence is that one SCA-Erlang node is created excusively for one service binding, so service bindings cannot share the same value in 'node' attribute like it was before. Made some other fixes. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@756480 13f79535-47bb-0310-9956-ffa450edef68 --- .../tuscany/sca/binding/erlang/ErlangBinding.java | 6 +++++ .../sca/binding/erlang/impl/ErlangBindingImpl.java | 20 ++++++++------- .../testing/ErlangBindingProcessorTestCase.java | 30 ++++------------------ 3 files changed, 22 insertions(+), 34 deletions(-) (limited to 'sandbox/wjaniszewski/binding-erlang') diff --git a/sandbox/wjaniszewski/binding-erlang/src/main/java/org/apache/tuscany/sca/binding/erlang/ErlangBinding.java b/sandbox/wjaniszewski/binding-erlang/src/main/java/org/apache/tuscany/sca/binding/erlang/ErlangBinding.java index a6bb801005..4014dbc11f 100644 --- a/sandbox/wjaniszewski/binding-erlang/src/main/java/org/apache/tuscany/sca/binding/erlang/ErlangBinding.java +++ b/sandbox/wjaniszewski/binding-erlang/src/main/java/org/apache/tuscany/sca/binding/erlang/ErlangBinding.java @@ -29,6 +29,8 @@ import org.apache.tuscany.sca.assembly.xml.Constants; */ public interface ErlangBinding extends Binding { + final long NO_TIMEOUT = 0; + QName BINDING_ERLANG_QNAME = new QName(Constants.SCA10_TUSCANY_NS, "binding.erlang"); String getNode(); @@ -50,5 +52,9 @@ public interface ErlangBinding extends Binding { String getCookie(); void setCookie(String cookie); + + boolean hasTimeout(); + + boolean hasCookie(); } diff --git a/sandbox/wjaniszewski/binding-erlang/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/ErlangBindingImpl.java b/sandbox/wjaniszewski/binding-erlang/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/ErlangBindingImpl.java index ad1bec06d3..9c0e9c82e7 100644 --- a/sandbox/wjaniszewski/binding-erlang/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/ErlangBindingImpl.java +++ b/sandbox/wjaniszewski/binding-erlang/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/ErlangBindingImpl.java @@ -33,8 +33,6 @@ import org.apache.tuscany.sca.policy.PolicySetAttachPoint; */ public class ErlangBindingImpl implements ErlangBinding, PolicySetAttachPoint { - public static final long DEFAULT_TIMEOUT = 10000; - private String node; private String module; private boolean mbox; @@ -44,7 +42,7 @@ public class ErlangBindingImpl implements ErlangBinding, PolicySetAttachPoint { private List policySets = new ArrayList(); private IntentAttachPointType intentAttachPointType; private List applicablePolicySets = new ArrayList(); - private long timeout = DEFAULT_TIMEOUT; + private long timeout = NO_TIMEOUT; public String getNode() { return node; @@ -121,12 +119,8 @@ public class ErlangBindingImpl implements ErlangBinding, PolicySetAttachPoint { } public void setTimeout(long timeout) { - // NOTE: 0 timeout will cause setting to default - if (timeout == 0) { - this.timeout = DEFAULT_TIMEOUT; - } else { - this.timeout = timeout; - } + // NOTE: not setting timeout or setting it to 0 will cause no timeout + this.timeout = timeout; } public String getCookie() { @@ -137,4 +131,12 @@ public class ErlangBindingImpl implements ErlangBinding, PolicySetAttachPoint { this.cookie = cookie; } + public boolean hasTimeout() { + return timeout != ErlangBinding.NO_TIMEOUT; + } + + public boolean hasCookie() { + return cookie != null && cookie.length() > 0; + } + } diff --git a/sandbox/wjaniszewski/binding-erlang/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ErlangBindingProcessorTestCase.java b/sandbox/wjaniszewski/binding-erlang/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ErlangBindingProcessorTestCase.java index 6a229d1ea2..3d954d7b5c 100644 --- a/sandbox/wjaniszewski/binding-erlang/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ErlangBindingProcessorTestCase.java +++ b/sandbox/wjaniszewski/binding-erlang/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ErlangBindingProcessorTestCase.java @@ -65,16 +65,6 @@ public class ErlangBindingProcessorTestCase { + " " + " " + ""; - - private static final String COMPOSITE_ZERO_TIMEOUT = - "" + "" - + " " - + " " - + " " - + " " - + " " - + " " - + ""; private static XMLInputFactory inputFactory; private static StAXArtifactProcessor staxProcessor; @@ -110,6 +100,8 @@ public class ErlangBindingProcessorTestCase { assertEquals("SomeNode", binding.getNode()); assertEquals(1000, binding.getTimeout()); assertEquals("cookie", binding.getCookie()); + assertEquals(true, binding.hasTimeout()); + assertEquals(true, binding.hasCookie()); } /** @@ -123,22 +115,10 @@ public class ErlangBindingProcessorTestCase { Composite composite = (Composite)staxProcessor.read(reader); ErlangBinding binding = (ErlangBinding)composite.getComponents().get(0).getServices().get(0).getBindings().get(0); - assertEquals(ErlangBindingImpl.DEFAULT_TIMEOUT, binding.getTimeout()); + assertEquals(ErlangBindingImpl.NO_TIMEOUT, binding.getTimeout()); assertEquals(null, binding.getCookie()); - } - - /** - * Tests "resultTimeout" attribute set to 0 - * - * @throws Exception - */ - @Test - public void testLoadZeroTimeout() throws Exception { - XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(COMPOSITE_ZERO_TIMEOUT)); - Composite composite = (Composite)staxProcessor.read(reader); - ErlangBinding binding = - (ErlangBinding)composite.getComponents().get(0).getServices().get(0).getBindings().get(0); - assertEquals(ErlangBindingImpl.DEFAULT_TIMEOUT, binding.getTimeout()); + assertEquals(false, binding.hasTimeout()); + assertEquals(false, binding.hasCookie()); } } -- cgit v1.2.3