summaryrefslogtreecommitdiffstats
path: root/java/sca/modules
diff options
context:
space:
mode:
Diffstat (limited to 'java/sca/modules')
-rw-r--r--java/sca/modules/assembly-xsd/src/main/resources/tuscany-sca-binding-rmi.xsd2
-rw-r--r--java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingImpl.java48
-rw-r--r--java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIServiceBindingProvider.java3
-rw-r--r--java/sca/modules/binding-rmi/src/test/resources/RMIBindingTest.composite2
4 files changed, 53 insertions, 2 deletions
diff --git a/java/sca/modules/assembly-xsd/src/main/resources/tuscany-sca-binding-rmi.xsd b/java/sca/modules/assembly-xsd/src/main/resources/tuscany-sca-binding-rmi.xsd
index 2697a1ea98..dbef8fbed6 100644
--- a/java/sca/modules/assembly-xsd/src/main/resources/tuscany-sca-binding-rmi.xsd
+++ b/java/sca/modules/assembly-xsd/src/main/resources/tuscany-sca-binding-rmi.xsd
@@ -36,7 +36,7 @@
</sequence>
<attribute name="host" type="anyURI" use="optional"/>
<attribute name="port" type="int" use="optional"/>
- <attribute name="serviceName" type="anyURI" use="required"/>
+ <attribute name="serviceName" type="anyURI" use="optional"/>
</extension>
</complexContent>
</complexType>
diff --git a/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingImpl.java b/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingImpl.java
index daf6ea6291..4acb9783f5 100644
--- a/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingImpl.java
+++ b/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingImpl.java
@@ -18,6 +18,9 @@
*/
package org.apache.tuscany.sca.binding.rmi.impl;
+import java.net.URI;
+import java.net.URISyntaxException;
+
import org.apache.tuscany.sca.binding.rmi.RMIBinding;
/**
@@ -81,6 +84,7 @@ public class RMIBindingImpl implements RMIBinding {
}
public String getURI() {
+ compose();
return uri;
}
@@ -90,6 +94,7 @@ public class RMIBindingImpl implements RMIBinding {
public void setURI(String uri) {
this.uri = uri;
+ parse(uri);
}
@@ -105,5 +110,48 @@ public class RMIBindingImpl implements RMIBinding {
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
+
+ /*
+ rmi://[host][:port][/[object]]
+ rmi:[/][object]
+ */
+ private void parse(String uriStr) {
+ if (uriStr == null) {
+ return;
+ }
+ URI uri = URI.create(uriStr);
+ if (host == null) {
+ this.host = uri.getHost();
+ }
+ if (port == null) {
+ this.port = String.valueOf(uri.getPort());
+ }
+ if (serviceName == null) {
+ String path = uri.getPath();
+ if (path != null && path.charAt(0) == '/') {
+ path = path.substring(1);
+ }
+ this.serviceName = path;
+ }
+ }
+
+ private void compose() {
+ if (uri == null) {
+ int p = -1;
+ if (port != null && port.length() > 0) {
+ p = Integer.decode(port);
+ }
+ String path = serviceName;
+ if (path != null) {
+ path = "/" + path;
+ }
+ try {
+ uri = new URI("rmi", null, host, p, path, null, null).toString();
+ } catch (URISyntaxException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+ }
+
}
diff --git a/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIServiceBindingProvider.java b/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIServiceBindingProvider.java
index 2215d7fa35..5d829162d9 100644
--- a/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIServiceBindingProvider.java
+++ b/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIServiceBindingProvider.java
@@ -94,6 +94,9 @@ public class RMIServiceBindingProvider implements ServiceBindingProvider {
int portNumber = RMIHost.RMI_DEFAULT_PORT;
if (port != null && port.length() > 0) {
portNumber = Integer.decode(port);
+ if (portNumber == -1) {
+ portNumber = RMIHost.RMI_DEFAULT_PORT;
+ }
}
return portNumber;
}
diff --git a/java/sca/modules/binding-rmi/src/test/resources/RMIBindingTest.composite b/java/sca/modules/binding-rmi/src/test/resources/RMIBindingTest.composite
index d29fe85586..65aec1681d 100644
--- a/java/sca/modules/binding-rmi/src/test/resources/RMIBindingTest.composite
+++ b/java/sca/modules/binding-rmi/src/test/resources/RMIBindingTest.composite
@@ -23,7 +23,7 @@
<service name="HelloWorldRmiService" promote="HelloWorldServiceComponent">
<interface.java interface="helloworld.HelloWorldService"/>
- <tuscany:binding.rmi host="localhost" port="8099" serviceName="HelloWorldRemoteService" />
+ <tuscany:binding.rmi uri="rmi://localhost:8099/HelloWorldRemoteService" />
</service>
<component name="HelloWorldServiceComponent">