summaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioFiveTestCase.java51
-rw-r--r--java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioFourTestCase.java15
-rw-r--r--java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFive.java32
-rw-r--r--java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFiveComponent.java40
-rw-r--r--java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFiveImpl.java31
-rw-r--r--java/sca/itest/corba/src/test/resources/ScenarioFive.composite41
-rw-r--r--java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaServiceBindingProvider.java17
-rwxr-xr-xjava/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/util/SocketUtil.java (renamed from java/sca/modules/binding-sca-corba/src/main/java/org/apache/tuscany/sca/binding/sca/corba/impl/SocketUtil.java)2
-rw-r--r--java/sca/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/CorbaBinding.java4
-rw-r--r--java/sca/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingImpl.java11
-rw-r--r--java/sca/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingProcessor.java10
-rw-r--r--java/sca/modules/binding-sca-corba/src/main/java/org/apache/tuscany/sca/binding/sca/corba/impl/CorbaSCAServiceBindingProvider.java1
12 files changed, 245 insertions, 10 deletions
diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioFiveTestCase.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioFiveTestCase.java
new file mode 100644
index 0000000000..2704186386
--- /dev/null
+++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioFiveTestCase.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.test.corba;
+
+import static org.junit.Assert.fail;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+import org.apache.tuscany.sca.test.corba.types.ScenarioFive;
+import org.apache.tuscany.sca.test.corba.types.ScenarioFiveComponent;
+import org.junit.Test;
+
+/**
+ * Tests usage of "provideNameServer" attribute in <binding.corba>
+ */
+public class ScenarioFiveTestCase {
+
+ /**
+ * Tests binding with provided name server
+ */
+ @Test
+ public void test_providedNameServer() {
+ try {
+ // just make sure we can obtain and use the reference with success
+ SCADomain domain = SCADomain.newInstance("ScenarioFive.composite");
+ ScenarioFive scenarioFive =
+ domain.getService(ScenarioFiveComponent.class, "ScenarioFive").getScenarioFive();
+ scenarioFive.doNothing();
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+}
diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioFourTestCase.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioFourTestCase.java
index 2f3e421392..63bb05ca4c 100644
--- a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioFourTestCase.java
+++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioFourTestCase.java
@@ -34,7 +34,6 @@ import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-
/**
* Tests SCA default binding over CORBA binding
*/
@@ -85,7 +84,7 @@ public class ScenarioFourTestCase {
Assert.fail(e.getMessage());
}
}
-
+
/**
* Test for JAXB exceptions
*/
@@ -101,7 +100,7 @@ public class ScenarioFourTestCase {
fail();
}
}
-
+
/**
* General test for passing SDO objects
*/
@@ -112,20 +111,22 @@ public class ScenarioFourTestCase {
scenarioFourSdo.setMessage("Test1");
scenarioFourSdo.setSymbol("Test2");
ScenarioFourSdo result = scenarioFour.passScenarioFourStruct(scenarioFourSdo);
- assertTrue(scenarioFourSdo.getMessage().equals(result.getMessage()) && scenarioFourSdo.getSymbol().equals(result.getSymbol()));
+ assertTrue(scenarioFourSdo.getMessage().equals(result.getMessage()) && scenarioFourSdo.getSymbol()
+ .equals(result.getSymbol()));
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
-
+
/**
- * Tests reusing local name server with multiple bindings
+ * Tests reusing local name server with multiple bindings
*/
@Test
public void test_nameServerReuse() {
try {
- ScenarioFour scenarioFour = domain.getService(ScenarioFourComponent.class, "ScenarioFourReuse").getScenarioFour();
+ ScenarioFour scenarioFour =
+ domain.getService(ScenarioFourComponent.class, "ScenarioFourReuse").getScenarioFour();
ScenarioFourStruct struct = new ScenarioFourStruct();
scenarioFour.setStruct(struct);
} catch (Exception e) {
diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFive.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFive.java
new file mode 100644
index 0000000000..a254da205a
--- /dev/null
+++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFive.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.test.corba.types;
+
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * Operations for scenario five
+ */
+@Remotable
+public interface ScenarioFive {
+
+ void doNothing();
+
+}
diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFiveComponent.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFiveComponent.java
new file mode 100644
index 0000000000..577c40d963
--- /dev/null
+++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFiveComponent.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.test.corba.types;
+
+import org.osoa.sca.annotations.Reference;
+
+/**
+ * Component for obtaining ScenarioFive reference
+ */
+public class ScenarioFiveComponent {
+
+ private ScenarioFive scenarioFive;
+
+ @Reference
+ public void setScenarioFive(ScenarioFive scenarioFive) {
+ this.scenarioFive = scenarioFive;
+ }
+
+ public ScenarioFive getScenarioFive() {
+ return scenarioFive;
+ }
+
+}
diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFiveImpl.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFiveImpl.java
new file mode 100644
index 0000000000..faacdd564f
--- /dev/null
+++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFiveImpl.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.test.corba.types;
+
+/**
+ * Implementation of ScenarioFive service
+ */
+public class ScenarioFiveImpl implements ScenarioFive {
+
+ public void doNothing() {
+ // does nothing
+ }
+
+}
diff --git a/java/sca/itest/corba/src/test/resources/ScenarioFive.composite b/java/sca/itest/corba/src/test/resources/ScenarioFive.composite
new file mode 100644
index 0000000000..3c73e238a5
--- /dev/null
+++ b/java/sca/itest/corba/src/test/resources/ScenarioFive.composite
@@ -0,0 +1,41 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Corba">
+
+ <component name="ScenarioFiveService">
+ <implementation.java class="org.apache.tuscany.sca.test.corba.types.ScenarioFiveImpl" />
+ </component>
+ <service name="ScenarioFive" promote="ScenarioFiveService">
+ <interface.java interface="org.apache.tuscany.sca.test.corba.types.ScenarioFive"/>
+ <binding.sca uri="corbaname::localhost:5090#ScenarioFive"/>
+ </service>
+
+ <component name="ScenarioFive">
+ <implementation.java class="org.apache.tuscany.sca.test.corba.types.ScenarioFiveComponent" />
+ <reference name="scenarioFive">
+ <binding.sca uri="corbaname::localhost:5090#ScenarioFive"/>
+ </reference>
+ </component>
+
+</composite>
diff --git a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaServiceBindingProvider.java b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaServiceBindingProvider.java
index fe4fabc293..516605ec8f 100644
--- a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaServiceBindingProvider.java
+++ b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaServiceBindingProvider.java
@@ -24,7 +24,9 @@ import org.apache.tuscany.sca.binding.corba.impl.service.ComponentInvocationProx
import org.apache.tuscany.sca.binding.corba.impl.service.DynaCorbaServant;
import org.apache.tuscany.sca.binding.corba.impl.service.InvocationProxy;
import org.apache.tuscany.sca.binding.corba.impl.types.util.Utils;
+import org.apache.tuscany.sca.binding.corba.impl.util.SocketUtil;
import org.apache.tuscany.sca.host.corba.CorbaHost;
+import org.apache.tuscany.sca.host.corba.CorbanameURL;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
import org.apache.tuscany.sca.provider.ServiceBindingProvider;
@@ -40,11 +42,20 @@ public class CorbaServiceBindingProvider implements ServiceBindingProvider {
private CorbaHost host;
private RuntimeComponentService service;
private DynaCorbaServant servant;
+ private boolean isLocalhost;
+ private int port;
public CorbaServiceBindingProvider(CorbaBinding binding, CorbaHost host, RuntimeComponentService service) {
this.binding = binding;
this.host = host;
this.service = service;
+ if (binding.isProvideNameServer()) {
+ CorbanameURL details = new CorbanameURL(binding.getCorbaname());
+ isLocalhost = SocketUtil.isLocalhost(details.getHost());
+ if (isLocalhost) {
+ port = details.getPort();
+ }
+ }
}
/**
@@ -63,6 +74,9 @@ public class CorbaServiceBindingProvider implements ServiceBindingProvider {
InvocationProxy proxy = new ComponentInvocationProxy(service, service.getRuntimeWire(binding), javaClass);
servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass));
servant.setIds(new String[] {binding.getId()});
+ if (binding.isProvideNameServer() && isLocalhost) {
+ host.createLocalNameServer(port);
+ }
host.registerServant(binding.getCorbaname(), servant);
} catch (Exception e) {
throw new ServiceRuntimeException(e);
@@ -75,6 +89,9 @@ public class CorbaServiceBindingProvider implements ServiceBindingProvider {
*/
public void stop() {
try {
+ if (binding.isProvideNameServer() && isLocalhost) {
+ host.releaseLocalNameServer(port);
+ }
host.unregisterServant(binding.getCorbaname());
} catch (Exception e) {
throw new ServiceRuntimeException(e);
diff --git a/java/sca/modules/binding-sca-corba/src/main/java/org/apache/tuscany/sca/binding/sca/corba/impl/SocketUtil.java b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/util/SocketUtil.java
index 6f4b4b9a9b..3541fd92cf 100755
--- a/java/sca/modules/binding-sca-corba/src/main/java/org/apache/tuscany/sca/binding/sca/corba/impl/SocketUtil.java
+++ b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/util/SocketUtil.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.tuscany.sca.binding.sca.corba.impl;
+package org.apache.tuscany.sca.binding.corba.impl.util;
import java.net.InetAddress;
import java.net.NetworkInterface;
diff --git a/java/sca/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/CorbaBinding.java b/java/sca/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/CorbaBinding.java
index 0b79065cc3..bf3bc09461 100644
--- a/java/sca/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/CorbaBinding.java
+++ b/java/sca/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/CorbaBinding.java
@@ -43,4 +43,8 @@ public interface CorbaBinding extends Binding {
void setId(String id);
String getCorbaname();
+
+ boolean isProvideNameServer();
+
+ void setProvideNameServer(boolean provideNameServer);
}
diff --git a/java/sca/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingImpl.java b/java/sca/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingImpl.java
index 6afe49717f..167fe50d7b 100644
--- a/java/sca/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingImpl.java
+++ b/java/sca/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingImpl.java
@@ -38,7 +38,8 @@ public class CorbaBindingImpl implements CorbaBinding, PolicySetAttachPoint {
private String host;
private int port;
private String id;
-
+ private boolean provideNameServer;
+
private List<Intent> requiredIntents = new ArrayList<Intent>();
private List<PolicySet> policySets = new ArrayList<PolicySet>();
private IntentAttachPointType intentAttachPointType;
@@ -129,4 +130,12 @@ public class CorbaBindingImpl implements CorbaBinding, PolicySetAttachPoint {
return CorbaHostUtils.isValidCorbanameURI(getURI()) ? getURI(): CorbaHostUtils.createCorbanameURI(getHost(), getPort(), getName());
}
+ public boolean isProvideNameServer() {
+ return provideNameServer;
+ }
+
+ public void setProvideNameServer(boolean provideNameServer) {
+ this.provideNameServer = provideNameServer;
+ }
+
}
diff --git a/java/sca/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingProcessor.java b/java/sca/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingProcessor.java
index 53333bd7aa..a7be836437 100644
--- a/java/sca/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingProcessor.java
+++ b/java/sca/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingProcessor.java
@@ -80,11 +80,16 @@ public class CorbaBindingProcessor implements StAXArtifactProcessor<CorbaBinding
if (uri != null) {
binding.setURI(uri);
}
+
// Read CORBA id
String id = reader.getAttributeValue(null, "id");
if (id != null) {
binding.setId(id);
}
+
+ // Read name server request
+ String provideNameServer = reader.getAttributeValue(null, "provideNameServer");
+ binding.setProvideNameServer("true".equals(provideNameServer) ? true : false);
return binding;
}
@@ -114,7 +119,10 @@ public class CorbaBindingProcessor implements StAXArtifactProcessor<CorbaBinding
if (model.getId() != null) {
writer.writeAttribute("id", model.getId());
}
-
+
+ if (model.isProvideNameServer()) {
+ writer.writeAttribute("provideNameServer", "true");
+ }
writer.writeEndElement();
}
diff --git a/java/sca/modules/binding-sca-corba/src/main/java/org/apache/tuscany/sca/binding/sca/corba/impl/CorbaSCAServiceBindingProvider.java b/java/sca/modules/binding-sca-corba/src/main/java/org/apache/tuscany/sca/binding/sca/corba/impl/CorbaSCAServiceBindingProvider.java
index 1f96327bf6..dba88434be 100644
--- a/java/sca/modules/binding-sca-corba/src/main/java/org/apache/tuscany/sca/binding/sca/corba/impl/CorbaSCAServiceBindingProvider.java
+++ b/java/sca/modules/binding-sca-corba/src/main/java/org/apache/tuscany/sca/binding/sca/corba/impl/CorbaSCAServiceBindingProvider.java
@@ -23,6 +23,7 @@ import org.apache.axiom.om.OMElement;
import org.apache.tuscany.sca.assembly.SCABinding;
import org.apache.tuscany.sca.binding.corba.impl.service.DynaCorbaServant;
import org.apache.tuscany.sca.binding.corba.impl.service.InvocationProxy;
+import org.apache.tuscany.sca.binding.corba.impl.util.SocketUtil;
import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory;
import org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator;