summaryrefslogtreecommitdiffstats
path: root/sandbox/wjaniszewski/binding-erlang
diff options
context:
space:
mode:
authorwjaniszewski <wjaniszewski@13f79535-47bb-0310-9956-ffa450edef68>2009-03-20 14:23:51 +0000
committerwjaniszewski <wjaniszewski@13f79535-47bb-0310-9956-ffa450edef68>2009-03-20 14:23:51 +0000
commitfce6ad4c30b15b4284a94e7a00e084bf18748cf2 (patch)
treea49756814cc819ecb6ca2ccecfedb3f9969b274e /sandbox/wjaniszewski/binding-erlang
parente962b3bbdff3995b6871393755ccd070b78aa329 (diff)
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
Diffstat (limited to 'sandbox/wjaniszewski/binding-erlang')
-rw-r--r--sandbox/wjaniszewski/binding-erlang/src/main/java/org/apache/tuscany/sca/binding/erlang/ErlangBinding.java6
-rw-r--r--sandbox/wjaniszewski/binding-erlang/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/ErlangBindingImpl.java20
-rw-r--r--sandbox/wjaniszewski/binding-erlang/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ErlangBindingProcessorTestCase.java30
3 files changed, 22 insertions, 34 deletions
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<PolicySet> policySets = new ArrayList<PolicySet>();
private IntentAttachPointType intentAttachPointType;
private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
- 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 {
+ " </service>"
+ " </component>"
+ "</composite>";
-
- private static final String COMPOSITE_ZERO_TIMEOUT =
- "<?xml version=\"1.0\" encoding=\"ASCII\"?>" + "<composite xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.0\" targetNamespace=\"http://binding-erlang\" name=\"binding-erlang\">"
- + " <component name=\"HelloWorldComponent\">"
- + " <implementation.java class=\"services.HelloWorld\"/>"
- + " <service name=\"HelloWorldService\">"
- + " <tuscany:binding.erlang node=\"SomeNode\" timeout=\"0\"/>"
- + " </service>"
- + " </component>"
- + "</composite>";
private static XMLInputFactory inputFactory;
private static StAXArtifactProcessor<Object> 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());
}
}