You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2008/06/28 08:22:04 UTC
svn commit: r672465 [2/2] - in /tuscany/java/sca/modules: ./ host-corba-jdk/
host-corba-jdk/src/ host-corba-jdk/src/main/ host-corba-jdk/src/main/java/
host-corba-jdk/src/main/java/org/ host-corba-jdk/src/main/java/org/apache/
host-corba-jdk/src/main/j...
Added: tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNamingContext.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNamingContext.java?rev=672465&view=auto
==============================================================================
--- tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNamingContext.java (added)
+++ tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNamingContext.java Fri Jun 27 23:22:02 2008
@@ -0,0 +1,440 @@
+/*
+ * 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.
+ */
+/**
+ * @version $Rev$ $Date$
+ */
+
+package org.apache.tuscany.sca.host.corba.naming;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import org.omg.CORBA.INTERNAL;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.SystemException;
+import org.omg.CosNaming.Binding;
+import org.omg.CosNaming.BindingHolder;
+import org.omg.CosNaming.BindingIteratorHelper;
+import org.omg.CosNaming.BindingIteratorPOA;
+import org.omg.CosNaming.BindingType;
+import org.omg.CosNaming.BindingTypeHolder;
+import org.omg.CosNaming.NameComponent;
+import org.omg.CosNaming.NamingContext;
+import org.omg.CosNaming.NamingContextHelper;
+import org.omg.CosNaming.NamingContextPackage.NotEmpty;
+import org.omg.PortableServer.POA;
+
+public class TransientNamingContext extends NamingContextBase {
+ // the bindings maintained by this context
+ protected HashMap bindings = new HashMap();
+ // the root context object
+ protected org.omg.CORBA.Object rootContext = null;
+
+ /**
+ * Create a top-level naming context.
+ *
+ * @param orb The orb hosting this context.
+ * @param poa The POA used to activate the object.
+ *
+ * @exception Exception
+ */
+ public TransientNamingContext(ORB orb, POA poa) throws Exception {
+ this(orb, poa, null);
+ // now get the initial root context as a corba object.
+
+ byte[] objectId = poa.activate_object(this);
+ rootContext = poa.id_to_reference(objectId);
+
+ }
+
+ /**
+ * Construct a TransientNamingContext subcontext.
+ *
+ * @param orb The orb this context is associated with.
+ * @param poa The POA the root context is activated under.
+ * @param root The root context.
+ *
+ * @exception Exception
+ */
+ public TransientNamingContext(ORB orb, POA poa, org.omg.CORBA.Object root) throws Exception {
+ super(orb, poa);
+ // save the root context link.
+ rootContext = root;
+ }
+
+ // abstract methods part of the interface contract that the implementation is required
+ // to supply.
+
+ /**
+ * Create a new context of the same type as the
+ * calling context.
+ *
+ * @return A new NamingContext item.
+ * @exception org.omg.CosNaming.NamingContextPackage.NotFound
+ * @exception SystemException
+ */
+ public NamingContext new_context() throws SystemException {
+ try {
+ // create a new context. Then we need to register this with the POA and activate it.
+ TransientNamingContext newContext = new TransientNamingContext(orb, poa, rootContext);
+
+ byte[] objectId = poa.activate_object(newContext);
+ org.omg.CORBA.Object obj = poa.id_to_reference(objectId);
+ return NamingContextHelper.narrow(obj);
+ } catch (SystemException e) {
+ // just propagate system exceptions
+ throw e;
+ } catch (Exception e) {
+ throw (INTERNAL)(new INTERNAL("Unable to create new naming context").initCause(e));
+ }
+ }
+
+ /**
+ * Destroy a context. This method should clean up
+ * any backing resources associated with the context.
+ *
+ * @exception org.omg.CosNaming.NamingContextPackage.NotEmpty
+ */
+ public synchronized void destroy() throws org.omg.CosNaming.NamingContextPackage.NotEmpty {
+ // still holding bound objects? Not allowed to destroy
+ if (!bindings.isEmpty()) {
+ throw new NotEmpty();
+ }
+
+ try {
+ // now detach ourselves from the POA
+ byte[] objectId = poa.servant_to_id(this);
+ if (objectId != null) {
+ poa.deactivate_object(objectId);
+ }
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
+ /**
+ * Create a list of bound objects an contexts contained
+ * within this context.
+ *
+ * @param how_many The count of elements to return as a BindingList.
+ * @param bl A holder element for returning the source binding list.
+ * @param bi A holder for returning a BindingIterator. Any extra
+ * elements not returned in the BindingList are returned
+ * in the BindingIterator.
+ *
+ * @exception SystemException
+ */
+ public synchronized void list(int how_many,
+ org.omg.CosNaming.BindingListHolder bl,
+ org.omg.CosNaming.BindingIteratorHolder bi) throws SystemException {
+ TransientBindingIterator iterator = new TransientBindingIterator(poa, (HashMap)bindings.clone());
+ // have the iterator fill in the entries here
+ iterator.next_n(how_many, bl);
+
+ // now it's necessary to activate this iterator with the poa. The value we pass
+ // back is the narrowed activated object
+ try {
+ byte[] objectId = poa.activate_object(iterator);
+ org.omg.CORBA.Object obj = poa.id_to_reference(objectId);
+
+ bi.value = BindingIteratorHelper.narrow(obj);
+ } catch (SystemException e) {
+ // just propagate system exceptions
+ throw e;
+ } catch (Exception e) {
+ throw (INTERNAL)(new INTERNAL("Unable to activate BindingIterator").initCause(e));
+ }
+ }
+
+ // lower level functions that are used by the base class
+
+ /**
+ * Resolve an object in this context (single level
+ * resolution).
+ *
+ * @param n The name of the target object.
+ * @param type A type holder for returning the bound object type
+ * information.
+ *
+ * @return The bound object. Returns null if the object does not
+ * exist in the context.
+ * @exception SystemException
+ */
+ protected org.omg.CORBA.Object resolveObject(NameComponent n, BindingTypeHolder type) throws SystemException {
+ // special call to resolve the root context. This is the only one that goes backwards.
+ if (n.id.length() == 0 && n.kind.length() == 0) {
+ // this is a name context item, so set it properly.
+ type.value = BindingType.ncontext;
+ return rootContext;
+ }
+
+ BindingKey key = new BindingKey(n);
+ BoundObject obj = (BoundObject)bindings.get(key);
+ // if not in the table, just return null
+ if (obj == null) {
+ return null;
+ }
+ // update the type information and return the bound object reference.
+ type.value = obj.type;
+ return obj.boundObject;
+ }
+
+ /**
+ * Bind an object into the current context. This can
+ * be either an object or a naming context.
+ *
+ * @param n The single-level name of the target object.
+ * @param obj The object or context to be bound.
+ * @param type
+ *
+ * @exception SystemException
+ */
+ protected void bindObject(NameComponent n, org.omg.CORBA.Object obj, BindingTypeHolder type) throws SystemException {
+ // fairly simple table put...
+ bindings.put(new BindingKey(n), new BoundObject(n, obj, type.value));
+ }
+
+ /**
+ * Unbind an object from the current context.
+ *
+ * @param n The name of the target object (single level).
+ *
+ * @return The object associated with the binding. Returns null
+ * if there was no binding currently associated with this
+ * name.
+ * @exception SystemException
+ */
+ protected org.omg.CORBA.Object unbindObject(NameComponent n) throws SystemException {
+ //remove the object from the hash table, returning the bound object if it exists.
+ BindingKey key = new BindingKey(n);
+ BoundObject obj = (BoundObject)bindings.remove(key);
+
+ if (obj != null) {
+ return obj.boundObject;
+ }
+ return null;
+ }
+
+ /**
+ * Retrieve the rootContext for this NamingContext.
+ *
+ * @return The rootContext CORBA object associated with this context.
+ */
+ public org.omg.CORBA.Object getRootContext() {
+ return rootContext;
+ }
+
+ /**
+ * Internal class used for HashMap lookup keys.
+ */
+ class BindingKey {
+ // the name component this is a HashMap key for.
+ public NameComponent name;
+ private int hashval = 0;
+
+ /**
+ * Create a new BindingKey for a NameComponent.
+ *
+ * @param n The lookup name.
+ */
+ public BindingKey(NameComponent n) {
+ name = n;
+ // create a hash value used for lookups
+ if (name.id != null) {
+ hashval += name.id.hashCode();
+ }
+ if (name.kind != null) {
+ hashval += name.kind.hashCode();
+ }
+ }
+
+ /**
+ * Return the hashcode associated with this binding key. The
+ * hashcode is created using the NameComponent id and
+ * kind fields.
+ *
+ * @return The lookup hashvalue associated with this key.
+ */
+ public int hashCode() {
+ return hashval;
+ }
+
+ /**
+ * Compare two BindingKeys for equality (used for HashMap
+ * lookups).
+ *
+ * @param other The comparison partner.
+ *
+ * @return True if the keys are equivalent, false otherwise.
+ */
+ public boolean equals(Object other) {
+ // if not given or the wrong type, this is false.
+ if (other == null || !(other instanceof BindingKey)) {
+ return false;
+ }
+
+ BindingKey otherKey = (BindingKey)other;
+
+ // verify first on the id name.
+ if (name.id != null) {
+ if (otherKey.name.id == null) {
+ return false;
+ }
+ if (!name.id.equals(otherKey.name.id)) {
+ return false;
+ }
+ } else {
+ if (otherKey.name.id != null) {
+ return false;
+ }
+ }
+ // this is a match so far...now compare the kinds
+ if (name.kind != null) {
+ if (otherKey.name.kind == null) {
+ return false;
+ }
+ if (!name.kind.equals(otherKey.name.kind)) {
+ return false;
+ }
+ } else {
+ if (otherKey.name.kind != null) {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+
+ /**
+ * Internal class used to store bound objects in the HashMap.
+ */
+ public class BoundObject {
+ // the name this object is bound under.
+ public NameComponent name;
+ // the type of binding (either nobject or ncontext).
+ public BindingType type;
+ // the actual bound object.
+ public org.omg.CORBA.Object boundObject;
+
+ /**
+ * Create a new object binding for our HashMap.
+ *
+ * @param name The bound object's name.
+ * @param boundObject
+ * The bound object (real object or NamingContext).
+ * @param type The type information associated with this binding.
+ */
+ public BoundObject(NameComponent name, org.omg.CORBA.Object boundObject, BindingType type) {
+ this.name = name;
+ this.boundObject = boundObject;
+ this.type = type;
+ }
+ }
+
+ /**
+ * Context implementation version of the BindingIterator
+ * object used to return list items.
+ */
+ public class TransientBindingIterator extends BindingIteratorPOA {
+ // the POA used to activate this object (required for destroy();
+ private POA poa;
+ // the binding set we're iterating over (this must be a snapshot copy)
+ private HashMap bindings;
+ // the iterator use to access the bindings
+ private Iterator iterator;
+
+ /**
+ * Create a new BindingIterator hosted by the given POA and
+ * iterating over the map of items.
+ *
+ * @param poa The hosting POA.
+ * @param bindings The HashMap of bound objects.
+ */
+ public TransientBindingIterator(POA poa, HashMap bindings) {
+ this.poa = poa;
+ this.bindings = bindings;
+ this.iterator = bindings.values().iterator();
+ }
+
+ /**
+ * Return the next object in the iteration sequence.
+ *
+ * @param b The BindingHolder used to return the next item. If
+ * we've reached the end of the sequence, an item
+ * with an empty name is returned.
+ *
+ * @return true if there is another item, false otherwise.
+ */
+ public boolean next_one(org.omg.CosNaming.BindingHolder b) {
+ if (iterator.hasNext()) {
+ // return this as a Binding value.
+ BoundObject obj = (BoundObject)iterator.next();
+ b.value = new Binding(new NameComponent[] {obj.name}, obj.type);
+ return true;
+ } else {
+ // return an empty element
+ b.value = new Binding(new NameComponent[0], BindingType.nobject);
+ return false;
+ }
+ }
+
+ /**
+ * Retrieve the next "n" items from the list, returned
+ * as a BindingList.
+ *
+ * @param how_many The count of items to retrieve.
+ * @param bl A holder for returning an array of Bindings for
+ * the returned items.
+ *
+ * @return true if any items were returned, false if there's
+ * nothing left to return.
+ */
+ public boolean next_n(int how_many, org.omg.CosNaming.BindingListHolder bl) {
+ List accum = new ArrayList();
+ BindingHolder holder = new BindingHolder();
+ int i = 0;
+ // Keep iterating as long as there are entries
+ while (i < how_many && next_one(holder)) {
+ accum.add(holder.value);
+ i++;
+ }
+
+ // convert to an array and return whether we found anything.
+ bl.value = (Binding[])accum.toArray(new Binding[accum.size()]);
+ return accum.isEmpty();
+ }
+
+ /**
+ * Destory this BindingIterator instance, which deativates
+ * it from the hosting POA.
+ */
+ public void destroy() {
+ try {
+ // we need to deactivate this from the POA.
+ byte[] objectId = poa.servant_to_id(this);
+ if (objectId != null) {
+ poa.deactivate_object(objectId);
+ }
+ } catch (Exception e) {
+ }
+ }
+ }
+}
Propchange: tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNamingContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNamingContext.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientServiceException.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientServiceException.java?rev=672465&view=auto
==============================================================================
--- tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientServiceException.java (added)
+++ tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientServiceException.java Fri Jun 27 23:22:02 2008
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+/**
+ * @version $Rev$ $Date$
+ */
+package org.apache.tuscany.sca.host.corba.naming;
+
+public class TransientServiceException extends Exception {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -2611596914331994827L;
+
+ public TransientServiceException() {
+ super();
+ }
+
+ public TransientServiceException(String reason) {
+ super(reason);
+ }
+
+ public TransientServiceException(String reason, Exception cause) {
+ super(reason, cause);
+ }
+
+}
Propchange: tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientServiceException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientServiceException.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: tuscany/java/sca/modules/host-corba-jdk/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-corba-jdk/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator?rev=672465&view=auto
==============================================================================
--- tuscany/java/sca/modules/host-corba-jdk/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator (added)
+++ tuscany/java/sca/modules/host-corba-jdk/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator Fri Jun 27 23:22:02 2008
@@ -0,0 +1,18 @@
+# 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.
+
+org.apache.tuscany.sca.host.corba.jdk.CorbaRuntimeModuleActivator
\ No newline at end of file
Added: tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/DefaultCorbaHostTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/DefaultCorbaHostTestCase.java?rev=672465&view=auto
==============================================================================
--- tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/DefaultCorbaHostTestCase.java (added)
+++ tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/DefaultCorbaHostTestCase.java Fri Jun 27 23:22:02 2008
@@ -0,0 +1,259 @@
+/*
+ * 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.host.corba.testing;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
+import static junit.framework.Assert.fail;
+
+import java.io.IOException;
+
+import org.apache.tuscany.sca.host.corba.CorbaHost;
+import org.apache.tuscany.sca.host.corba.CorbaHostException;
+import org.apache.tuscany.sca.host.corba.jdk.DefaultCorbaHost;
+import org.apache.tuscany.sca.host.corba.naming.TransientNameServer;
+import org.apache.tuscany.sca.host.corba.naming.TransientNameService;
+import org.apache.tuscany.sca.host.corba.testing.general.TestInterface;
+import org.apache.tuscany.sca.host.corba.testing.general.TestInterfaceHelper;
+import org.apache.tuscany.sca.host.corba.testing.servants.TestInterfaceServant;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.omg.CORBA.ORB;
+
+/**
+ * General tests
+ */
+public class DefaultCorbaHostTestCase {
+
+ private static final String LOCALHOST = "localhost";
+ private static final int DEFAULT_PORT = 11100; //1050;
+ private static final long INTERVAL = 500;
+
+ private static Process tn;
+ private static CorbaHost host;
+
+ /**
+ * Spawn tnameserv under given port
+ *
+ * @param port
+ * @return
+ * @throws IOException
+ */
+ private static Process spawnTnameserv(int port) throws IOException {
+ Process process = Runtime.getRuntime().exec("tnameserv -ORBInitialPort " + port);
+ for (int i = 0; i < 3; i++) {
+ try {
+ // Thread.sleep(SPAWN_TIME);
+ String[] args = {"-ORBInitialHost", LOCALHOST, "-ORBInitialPort", "" + port};
+ ORB orb = ORB.init(args, null);
+ orb.resolve_initial_references("NameService");
+ break;
+ } catch (Throwable e) {
+ try {
+ Thread.sleep(INTERVAL);
+ } catch (InterruptedException e1) {
+ // Ignore
+ }
+ }
+ }
+ return process;
+ }
+
+ /**
+ * Kill previously spawned tnameserv
+ *
+ * @param p
+ */
+ private static void killProcess(Process p) {
+ if (p != null) {
+ p.destroy();
+ }
+ }
+
+ /*
+ @BeforeClass
+ public static void start() {
+ try {
+ tn = spawnTnameserv(DEFAULT_PORT);
+ host = new DefaultCorbaHost();
+ } catch (Throwable e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ @AfterClass
+ public static void stop() {
+ killProcess(tn);
+ }
+ */
+
+ private static TransientNameServer server;
+
+ @BeforeClass
+ public static void start() {
+ try {
+ server = new TransientNameServer(LOCALHOST, DEFAULT_PORT, TransientNameService.DEFAULT_SERVICE_NAME);
+ Thread t = server.start();
+ if (t == null) {
+ fail("The naming server cannot be started");
+ }
+ host = new DefaultCorbaHost();
+ } catch (Throwable e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ @AfterClass
+ public static void stop() {
+ server.stop();
+ }
+
+ /**
+ * Tests registering, getting and unregistering CORBA object
+ */
+ @Test
+ public void test_registerServant() {
+ try {
+ ORB orb = host.createORB(LOCALHOST, DEFAULT_PORT, false);
+ TestInterface servant = new TestInterfaceServant();
+ host.registerServant(orb, "Test", servant);
+
+ TestInterface ref = TestInterfaceHelper.narrow(host.lookup(orb, "Test"));
+ assertEquals(2, ref.getInt(2));
+
+ host.unregisterServant(orb, "Test");
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * Tests situation when name is already registered
+ */
+ @Test
+ public void test_nameAlreadyRegistered() {
+ try {
+ ORB orb = host.createORB(LOCALHOST, DEFAULT_PORT, false);
+ TestInterface servant = new TestInterfaceServant();
+ host.registerServant(orb, "Test", servant);
+ host.registerServant(orb, "Test", servant);
+ fail();
+ } catch (CorbaHostException e) {
+ assertTrue(e.getMessage().equals(CorbaHostException.BINDING_IN_USE));
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * Tests getting non existing reference
+ */
+ @Test
+ public void test_getNonExistingObject() {
+ try {
+ ORB orb = host.createORB(LOCALHOST, DEFAULT_PORT, false);
+ host.lookup(orb, "NonExistingReference");
+ fail();
+ } catch (CorbaHostException e) {
+ assertTrue(e.getMessage().equals(CorbaHostException.NO_SUCH_OBJECT));
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * Tests unregistering non existing reference
+ */
+ @Test
+ public void test_unregisterNonExistentObject() {
+ try {
+ ORB orb = host.createORB(LOCALHOST, DEFAULT_PORT, false);
+ host.unregisterServant(orb, "NonExistingReference2");
+ fail();
+ } catch (CorbaHostException e) {
+ assertTrue(e.getMessage().equals(CorbaHostException.NO_SUCH_OBJECT));
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * Tests registering under invalid host
+ */
+ @Test
+ public void test_invalidHost() {
+ try {
+ ORB orb = host.createORB("not_" + LOCALHOST, DEFAULT_PORT, false);
+ TestInterface servant = new TestInterfaceServant();
+ host.registerServant(orb, "Test", servant);
+ fail();
+ } catch (CorbaHostException e) {
+ // Expected
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ /**
+ * Tests registering under invalid port
+ */
+ @Test
+ public void test_invalidPort() {
+ try {
+ ORB orb = host.createORB(LOCALHOST, DEFAULT_PORT + 1, false);
+ TestInterface servant = new TestInterfaceServant();
+ host.registerServant(orb, "Test", servant);
+ fail();
+ } catch (CorbaHostException e) {
+ // Expected
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ /**
+ * Tests registering under invalid name
+ */
+ @Test
+ @Ignore("SUN JDK 6 is happy with all kind of names")
+ public void test_invalidBindingName() {
+ try {
+ ORB orb = host.createORB(LOCALHOST, DEFAULT_PORT, false);
+ TestInterface servant = new TestInterfaceServant();
+ host.registerServant(orb, "---", servant);
+ fail();
+ } catch (CorbaHostException e) {
+ assertTrue(e.getMessage().equals(CorbaHostException.WRONG_NAME));
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+}
Propchange: tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/DefaultCorbaHostTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/DefaultCorbaHostTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterface.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterface.java?rev=672465&view=auto
==============================================================================
--- tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterface.java (added)
+++ tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterface.java Fri Jun 27 23:22:02 2008
@@ -0,0 +1,30 @@
+/*
+ * 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.host.corba.testing.general;
+
+/**
+* org/apache/tuscany/sca/host/corba/testing/general/TestInterface.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* ¶roda, 25 czerwiec 2008 16:19:44 CEST
+*/
+
+public interface TestInterface extends TestInterfaceOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity {
+} // interface TestInterface
Propchange: tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterface.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterface.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHelper.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHelper.java?rev=672465&view=auto
==============================================================================
--- tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHelper.java (added)
+++ tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHelper.java Fri Jun 27 23:22:02 2008
@@ -0,0 +1,98 @@
+/*
+ * 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.host.corba.testing.general;
+
+/**
+* org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* ¶roda, 25 czerwiec 2008 16:19:44 CEST
+*/
+
+abstract public class TestInterfaceHelper {
+ private static String _id = "IDL:org/apache/tuscany/sca/host/corba/testing/general/TestInterface:1.0";
+
+ public static void insert(org.omg.CORBA.Any a, org.apache.tuscany.sca.host.corba.testing.general.TestInterface that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static org.apache.tuscany.sca.host.corba.testing.general.TestInterface extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ __typeCode =
+ org.omg.CORBA.ORB.init()
+ .create_interface_tc(org.apache.tuscany.sca.host.corba.testing.general.TestInterfaceHelper.id(),
+ "TestInterface");
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static org.apache.tuscany.sca.host.corba.testing.general.TestInterface read(org.omg.CORBA.portable.InputStream istream) {
+ return narrow(istream.read_Object(_TestInterfaceStub.class));
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream,
+ org.apache.tuscany.sca.host.corba.testing.general.TestInterface value) {
+ ostream.write_Object((org.omg.CORBA.Object)value);
+ }
+
+ public static org.apache.tuscany.sca.host.corba.testing.general.TestInterface narrow(org.omg.CORBA.Object obj) {
+ if (obj == null)
+ return null;
+ else if (obj instanceof org.apache.tuscany.sca.host.corba.testing.general.TestInterface)
+ return (org.apache.tuscany.sca.host.corba.testing.general.TestInterface)obj;
+ else if (!obj._is_a(id()))
+ throw new org.omg.CORBA.BAD_PARAM();
+ else {
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate();
+ org.apache.tuscany.sca.host.corba.testing.general._TestInterfaceStub stub =
+ new org.apache.tuscany.sca.host.corba.testing.general._TestInterfaceStub();
+ stub._set_delegate(delegate);
+ return stub;
+ }
+ }
+
+ public static org.apache.tuscany.sca.host.corba.testing.general.TestInterface unchecked_narrow(org.omg.CORBA.Object obj) {
+ if (obj == null)
+ return null;
+ else if (obj instanceof org.apache.tuscany.sca.host.corba.testing.general.TestInterface)
+ return (org.apache.tuscany.sca.host.corba.testing.general.TestInterface)obj;
+ else {
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate();
+ org.apache.tuscany.sca.host.corba.testing.general._TestInterfaceStub stub =
+ new org.apache.tuscany.sca.host.corba.testing.general._TestInterfaceStub();
+ stub._set_delegate(delegate);
+ return stub;
+ }
+ }
+
+}
Propchange: tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHelper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHelper.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHolder.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHolder.java?rev=672465&view=auto
==============================================================================
--- tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHolder.java (added)
+++ tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHolder.java Fri Jun 27 23:22:02 2008
@@ -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.host.corba.testing.general;
+
+/**
+* org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* ¶roda, 25 czerwiec 2008 16:19:44 CEST
+*/
+
+public final class TestInterfaceHolder implements org.omg.CORBA.portable.Streamable {
+ public org.apache.tuscany.sca.host.corba.testing.general.TestInterface value = null;
+
+ public TestInterfaceHolder() {
+ }
+
+ public TestInterfaceHolder(org.apache.tuscany.sca.host.corba.testing.general.TestInterface initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.host.corba.testing.general.TestInterfaceHelper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.host.corba.testing.general.TestInterfaceHelper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.host.corba.testing.general.TestInterfaceHelper.type();
+ }
+
+}
Propchange: tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHolder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHolder.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceOperations.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceOperations.java?rev=672465&view=auto
==============================================================================
--- tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceOperations.java (added)
+++ tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceOperations.java Fri Jun 27 23:22:02 2008
@@ -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.host.corba.testing.general;
+
+/**
+* org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceOperations.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* ¶roda, 25 czerwiec 2008 16:19:44 CEST
+*/
+
+public interface TestInterfaceOperations {
+ int getInt(int arg);
+} // interface TestInterfaceOperations
Propchange: tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceOperations.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceOperations.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceImplBase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceImplBase.java?rev=672465&view=auto
==============================================================================
--- tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceImplBase.java (added)
+++ tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceImplBase.java Fri Jun 27 23:22:02 2008
@@ -0,0 +1,74 @@
+/*
+ * 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.host.corba.testing.general;
+
+/**
+* org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceImplBase.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* ¶roda, 25 czerwiec 2008 16:19:44 CEST
+*/
+
+public abstract class _TestInterfaceImplBase extends org.omg.CORBA.portable.ObjectImpl implements
+ org.apache.tuscany.sca.host.corba.testing.general.TestInterface, org.omg.CORBA.portable.InvokeHandler {
+
+ // Constructors
+ public _TestInterfaceImplBase() {
+ }
+
+ private static java.util.Hashtable _methods = new java.util.Hashtable();
+ static {
+ _methods.put("getInt", new java.lang.Integer(0));
+ }
+
+ public org.omg.CORBA.portable.OutputStream _invoke(String $method,
+ org.omg.CORBA.portable.InputStream in,
+ org.omg.CORBA.portable.ResponseHandler $rh) {
+ org.omg.CORBA.portable.OutputStream out = null;
+ java.lang.Integer __method = (java.lang.Integer)_methods.get($method);
+ if (__method == null)
+ throw new org.omg.CORBA.BAD_OPERATION(0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+
+ switch (__method.intValue()) {
+ case 0: // org/apache/tuscany/sca/host/corba/testing/general/TestInterface/getInt
+ {
+ int arg = in.read_long();
+ int $result = (int)0;
+ $result = this.getInt(arg);
+ out = $rh.createReply();
+ out.write_long($result);
+ break;
+ }
+
+ default:
+ throw new org.omg.CORBA.BAD_OPERATION(0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+ }
+
+ return out;
+ } // _invoke
+
+ // Type-specific CORBA::Object operations
+ private static String[] __ids = {"IDL:org/apache/tuscany/sca/host/corba/testing/general/TestInterface:1.0"};
+
+ public String[] _ids() {
+ return (String[])__ids.clone();
+ }
+
+} // class _TestInterfaceImplBase
Propchange: tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceImplBase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceImplBase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceStub.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceStub.java?rev=672465&view=auto
==============================================================================
--- tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceStub.java (added)
+++ tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceStub.java Fri Jun 27 23:22:02 2008
@@ -0,0 +1,73 @@
+/*
+ * 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.host.corba.testing.general;
+
+/**
+* org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceStub.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* ¶roda, 25 czerwiec 2008 16:19:44 CEST
+*/
+
+public class _TestInterfaceStub extends org.omg.CORBA.portable.ObjectImpl implements
+ org.apache.tuscany.sca.host.corba.testing.general.TestInterface {
+
+ public int getInt(int arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("getInt", true);
+ $out.write_long(arg);
+ $in = _invoke($out);
+ int $result = $in.read_long();
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return getInt(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // getInt
+
+ // Type-specific CORBA::Object operations
+ private static String[] __ids = {"IDL:org/apache/tuscany/sca/host/corba/testing/general/TestInterface:1.0"};
+
+ public String[] _ids() {
+ return (String[])__ids.clone();
+ }
+
+ private void readObject(java.io.ObjectInputStream s) throws java.io.IOException {
+ String str = s.readUTF();
+ String[] args = null;
+ java.util.Properties props = null;
+ org.omg.CORBA.Object obj = org.omg.CORBA.ORB.init(args, props).string_to_object(str);
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate();
+ _set_delegate(delegate);
+ }
+
+ private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
+ String[] args = null;
+ java.util.Properties props = null;
+ String str = org.omg.CORBA.ORB.init(args, props).object_to_string(this);
+ s.writeUTF(str);
+ }
+} // class _TestInterfaceStub
Propchange: tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceStub.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceStub.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/servants/TestInterfaceServant.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/servants/TestInterfaceServant.java?rev=672465&view=auto
==============================================================================
--- tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/servants/TestInterfaceServant.java (added)
+++ tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/servants/TestInterfaceServant.java Fri Jun 27 23:22:02 2008
@@ -0,0 +1,35 @@
+/*
+ * 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.host.corba.testing.servants;
+
+import org.apache.tuscany.sca.host.corba.testing.general._TestInterfaceImplBase;
+
+/**
+ * Testing servant
+ */
+public class TestInterfaceServant extends _TestInterfaceImplBase {
+
+ private static final long serialVersionUID = 1L;
+
+ public int getInt(int arg) {
+ return arg;
+ }
+
+}
Propchange: tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/servants/TestInterfaceServant.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/servants/TestInterfaceServant.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: tuscany/java/sca/modules/host-corba-jdk/src/test/resources/general.idl
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-corba-jdk/src/test/resources/general.idl?rev=672465&view=auto
==============================================================================
--- tuscany/java/sca/modules/host-corba-jdk/src/test/resources/general.idl (added)
+++ tuscany/java/sca/modules/host-corba-jdk/src/test/resources/general.idl Fri Jun 27 23:22:02 2008
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+
+/*
+ * compile by
+ * idlj -fall -oldImplBase genera.idl
+ */
+
+module org {
+ module apache {
+ module tuscany {
+ module sca {
+ module host {
+ module corba {
+ module testing {
+ module general {
+ interface TestInterface {
+ long getInt(in long arg);
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+};
Modified: tuscany/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHost.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHost.java?rev=672465&r1=672464&r2=672465&view=diff
==============================================================================
--- tuscany/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHost.java (original)
+++ tuscany/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHost.java Fri Jun 27 23:22:02 2008
@@ -19,43 +19,45 @@
package org.apache.tuscany.sca.host.corba;
+import org.omg.CORBA.ORB;
import org.omg.CORBA.Object;
/**
* CORBA Service hosting interface
*/
public interface CorbaHost {
-
+ /**
+ * Create an ORB instance
+ * @param host The host name
+ * @param port The port number
+ * @param server Is it for server side
+ * @return
+ */
+ ORB createORB(String host, int port, boolean server) throws CorbaHostException;
/**
* Registers servant in name server.
- *
+ * @param orb The ORB instance
* @param name binding name
- * @param host name server host
- * @param port name server port
* @param serviceObject
* @throws CorbaHostException
*/
- void registerServant(String name, String host, int port, Object serviceObject) throws CorbaHostException;
+ void registerServant(ORB orb, String name, Object serviceObject) throws CorbaHostException;
/**
* Removes servant from name server
- *
+ * @param orb The ORB instance
* @param name binding name
- * @param host name server host
- * @param port name server port
* @throws CorbaHostException
*/
- void unregisterServant(String name, String host, int port) throws CorbaHostException;
+ void unregisterServant(ORB orb, String name) throws CorbaHostException;
/**
* Gets reference to object
- *
+ * @param orb The ORB instance
* @param name binding name
- * @param host name server host
- * @param port name server port
* @return objects reference
* @throws CorbaHostException
*/
- Object getReference(String name, String host, int port) throws CorbaHostException;
+ Object lookup(ORB orb, String name) throws CorbaHostException;
}
Modified: tuscany/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/DefaultCorbaHostExtensionPoint.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/DefaultCorbaHostExtensionPoint.java?rev=672465&r1=672464&r2=672465&view=diff
==============================================================================
--- tuscany/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/DefaultCorbaHostExtensionPoint.java (original)
+++ tuscany/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/DefaultCorbaHostExtensionPoint.java Fri Jun 27 23:22:02 2008
@@ -30,8 +30,6 @@
private List<CorbaHost> corbaHosts = new ArrayList<CorbaHost>();
public DefaultCorbaHostExtensionPoint() {
- CorbaHost defaultHost = new DefaultCorbaHost();
- addCorbaHost(defaultHost);
}
public void addCorbaHost(CorbaHost host) {
Modified: tuscany/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/ExtensibleCorbaHost.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/ExtensibleCorbaHost.java?rev=672465&r1=672464&r2=672465&view=diff
==============================================================================
--- tuscany/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/ExtensibleCorbaHost.java (original)
+++ tuscany/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/ExtensibleCorbaHost.java Fri Jun 27 23:22:02 2008
@@ -19,6 +19,7 @@
package org.apache.tuscany.sca.host.corba;
+import org.omg.CORBA.ORB;
import org.omg.CORBA.Object;
/**
@@ -26,31 +27,33 @@
*/
public class ExtensibleCorbaHost implements CorbaHost {
- private CorbaHostExtensionPoint chep;
+ private CorbaHostExtensionPoint hosts;
public ExtensibleCorbaHost(CorbaHostExtensionPoint chep) {
- this.chep = chep;
+ this.hosts = chep;
}
- public Object getReference(String name, String host, int port) throws CorbaHostException {
- if (chep.getCorbaHosts().isEmpty()) {
- throw new CorbaHostException("No registered CORBA hosts");
- }
- return chep.getCorbaHosts().get(0).getReference(name, host, port);
+ public Object lookup(ORB orb, String name) throws CorbaHostException {
+ return getCorbaHost().lookup(orb, name);
}
- public void registerServant(String name, String host, int port, Object serviceObject) throws CorbaHostException {
- if (chep.getCorbaHosts().isEmpty()) {
- throw new CorbaHostException("No registered CORBA hosts");
- }
- chep.getCorbaHosts().get(0).registerServant(name, host, port, serviceObject);
+ public void registerServant(ORB orb, String name, Object serviceObject) throws CorbaHostException {
+ getCorbaHost().registerServant(orb, name, serviceObject);
}
- public void unregisterServant(String name, String host, int port) throws CorbaHostException {
- if (chep.getCorbaHosts().isEmpty()) {
+ public void unregisterServant(ORB orb, String name) throws CorbaHostException {
+ getCorbaHost().unregisterServant(orb, name);
+ }
+
+ protected CorbaHost getCorbaHost() throws CorbaHostException {
+ if (hosts.getCorbaHosts().isEmpty()) {
throw new CorbaHostException("No registered CORBA hosts");
}
- chep.getCorbaHosts().get(0).unregisterServant(name, host, port);
+ return hosts.getCorbaHosts().get(0);
+ }
+
+ public ORB createORB(String host, int port, boolean server) throws CorbaHostException {
+ return getCorbaHost().createORB(host, port, server);
}
}
Modified: tuscany/java/sca/modules/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/pom.xml?rev=672465&r1=672464&r2=672465&view=diff
==============================================================================
--- tuscany/java/sca/modules/pom.xml (original)
+++ tuscany/java/sca/modules/pom.xml Fri Jun 27 23:22:02 2008
@@ -105,6 +105,7 @@
<module>extensibility</module>
<module>extension-helper</module>
<module>host-corba</module>
+ <module>host-corba-jdk</module>
<module>host-ejb</module>
<module>host-embedded</module>
<module>host-http</module>