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 [1/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...

Author: rfeng
Date: Fri Jun 27 23:22:02 2008
New Revision: 672465

URL: http://svn.apache.org/viewvc?rev=672465&view=rev
Log:
Add host-corba-jdk

Added:
    tuscany/java/sca/modules/host-corba-jdk/   (with props)
    tuscany/java/sca/modules/host-corba-jdk/LICENSE
    tuscany/java/sca/modules/host-corba-jdk/NOTICE
    tuscany/java/sca/modules/host-corba-jdk/pom.xml   (with props)
    tuscany/java/sca/modules/host-corba-jdk/src/
    tuscany/java/sca/modules/host-corba-jdk/src/main/
    tuscany/java/sca/modules/host-corba-jdk/src/main/java/
    tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/
    tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/
    tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/
    tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/
    tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/
    tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/
    tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/jdk/
    tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/jdk/CorbaRuntimeModuleActivator.java   (with props)
    tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/jdk/DefaultCorbaHost.java   (with props)
    tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/
    tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/NamingContextBase.java   (with props)
    tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNameServer.java   (with props)
    tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNameService.java   (with props)
    tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNamingContext.java   (with props)
    tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientServiceException.java   (with props)
    tuscany/java/sca/modules/host-corba-jdk/src/main/resources/
    tuscany/java/sca/modules/host-corba-jdk/src/main/resources/META-INF/
    tuscany/java/sca/modules/host-corba-jdk/src/main/resources/META-INF/services/
    tuscany/java/sca/modules/host-corba-jdk/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator
    tuscany/java/sca/modules/host-corba-jdk/src/test/
    tuscany/java/sca/modules/host-corba-jdk/src/test/java/
    tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/
    tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/
    tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/
    tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/
    tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/
    tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/
    tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/
    tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/DefaultCorbaHostTestCase.java   (with props)
    tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/
    tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterface.java   (with props)
    tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHelper.java   (with props)
    tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHolder.java   (with props)
    tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceOperations.java   (with props)
    tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceImplBase.java   (with props)
    tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceStub.java   (with props)
    tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/servants/
    tuscany/java/sca/modules/host-corba-jdk/src/test/java/org/apache/tuscany/sca/host/corba/testing/servants/TestInterfaceServant.java   (with props)
    tuscany/java/sca/modules/host-corba-jdk/src/test/resources/
    tuscany/java/sca/modules/host-corba-jdk/src/test/resources/general.idl
Removed:
    tuscany/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/DefaultCorbaHost.java
    tuscany/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/naming/
    tuscany/java/sca/modules/host-corba/src/test/java/
    tuscany/java/sca/modules/host-corba/src/test/resources/
Modified:
    tuscany/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHost.java
    tuscany/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/DefaultCorbaHostExtensionPoint.java
    tuscany/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/ExtensibleCorbaHost.java
    tuscany/java/sca/modules/pom.xml

Propchange: tuscany/java/sca/modules/host-corba-jdk/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Jun 27 23:22:02 2008
@@ -0,0 +1,19 @@
+target
+work
+dojo
+*.iws
+*.ipr
+*.iml
+derby.log
+maven.log
+build.xml
+build-dependency.xml
+velocity.log*
+junit*.properties
+surefire*.properties
+.project
+.classpath
+.settings
+.deployables
+.wtpmodules
+.externalToolBuilders

Added: tuscany/java/sca/modules/host-corba-jdk/LICENSE
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-corba-jdk/LICENSE?rev=672465&view=auto
==============================================================================
--- tuscany/java/sca/modules/host-corba-jdk/LICENSE (added)
+++ tuscany/java/sca/modules/host-corba-jdk/LICENSE Fri Jun 27 23:22:02 2008
@@ -0,0 +1,205 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed 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.
+
+
+

Added: tuscany/java/sca/modules/host-corba-jdk/NOTICE
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-corba-jdk/NOTICE?rev=672465&view=auto
==============================================================================
--- tuscany/java/sca/modules/host-corba-jdk/NOTICE (added)
+++ tuscany/java/sca/modules/host-corba-jdk/NOTICE Fri Jun 27 23:22:02 2008
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+

Added: tuscany/java/sca/modules/host-corba-jdk/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-corba-jdk/pom.xml?rev=672465&view=auto
==============================================================================
--- tuscany/java/sca/modules/host-corba-jdk/pom.xml (added)
+++ tuscany/java/sca/modules/host-corba-jdk/pom.xml Fri Jun 27 23:22:02 2008
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.    
+-->
+<project>
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.tuscany.sca</groupId>
+        <artifactId>tuscany-modules</artifactId>
+        <version>1.4-SNAPSHOT</version>
+    </parent>
+    <artifactId>tuscany-host-corba-jdk</artifactId>
+    <name>Apache Tuscany SCA JDK built-in CORBA Host</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-host-corba</artifactId>
+            <version>1.4-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
+
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+
+                <configuration>
+                    <instructions>
+                        <Bundle-Version>${tuscany.version}</Bundle-Version>
+                        <Bundle-SymbolicName>org.apache.tuscany.sca.host.corba.jdk</Bundle-SymbolicName>
+                        <Bundle-Description>${pom.name}</Bundle-Description>
+                        <Export-Package>org.apache.tuscany.sca.host.corba.jdk*</Export-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

Propchange: tuscany/java/sca/modules/host-corba-jdk/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/java/sca/modules/host-corba-jdk/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/jdk/CorbaRuntimeModuleActivator.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/jdk/CorbaRuntimeModuleActivator.java?rev=672465&view=auto
==============================================================================
--- tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/jdk/CorbaRuntimeModuleActivator.java (added)
+++ tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/jdk/CorbaRuntimeModuleActivator.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.jdk;
+
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ModuleActivator;
+import org.apache.tuscany.sca.host.corba.CorbaHostExtensionPoint;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CorbaRuntimeModuleActivator implements ModuleActivator {
+    private static final Logger logger = Logger.getLogger(CorbaRuntimeModuleActivator.class.getName());
+
+    private DefaultCorbaHost server;
+
+    public void start(ExtensionPointRegistry extensionPointRegistry) {
+
+        // Register our Corba host
+        CorbaHostExtensionPoint corbaHosts =
+            extensionPointRegistry.getExtensionPoint(CorbaHostExtensionPoint.class);
+        
+        server = new DefaultCorbaHost();
+        corbaHosts.addCorbaHost(server);
+    }
+
+    public void stop(ExtensionPointRegistry registry) {
+        if (server != null) {
+            server.stop();
+        }
+    }
+
+}

Propchange: tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/jdk/CorbaRuntimeModuleActivator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/jdk/CorbaRuntimeModuleActivator.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/jdk/DefaultCorbaHost.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/jdk/DefaultCorbaHost.java?rev=672465&view=auto
==============================================================================
--- tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/jdk/DefaultCorbaHost.java (added)
+++ tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/jdk/DefaultCorbaHost.java Fri Jun 27 23:22:02 2008
@@ -0,0 +1,166 @@
+/*
+ * 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.jdk;
+
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.host.corba.CorbaHost;
+import org.apache.tuscany.sca.host.corba.CorbaHostException;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Object;
+import org.omg.CosNaming.NameComponent;
+import org.omg.CosNaming.NamingContextExt;
+import org.omg.CosNaming.NamingContextExtHelper;
+import org.omg.CosNaming.NamingContextPackage.InvalidName;
+import org.omg.CosNaming.NamingContextPackage.NotFound;
+
+/**
+ * Default implementation of CORBA host
+ */
+public class DefaultCorbaHost implements CorbaHost {
+    private static final Logger logger = Logger.getLogger(DefaultCorbaHost.class.getName());
+
+    private Map<String, ORB> orbs = new ConcurrentHashMap<String, ORB>();
+
+    private void validatePort(int port) throws IllegalArgumentException {
+        if (port < 1) {
+            throw new IllegalArgumentException("Port value should be > 0");
+        }
+    }
+
+    private void validateName(String name) throws IllegalArgumentException {
+        if (name == null || name.length() == 0) {
+            throw new IllegalArgumentException("Object name shouldn't be null");
+        }
+    }
+
+    private NamingContextExt getNamingContext(ORB orb) throws Exception {
+        org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
+        return NamingContextExtHelper.narrow(objRef);
+    }
+
+    private void handleException(Exception e) throws CorbaHostException {
+        // The cause of the Exception is JDK specific
+        if (e instanceof NotFound) {
+            throw new CorbaHostException(CorbaHostException.NO_SUCH_OBJECT, e);
+        } else if (e instanceof InvalidName) {
+            throw new CorbaHostException(e);
+        } else {
+            throw new CorbaHostException(e);
+        }
+    }
+
+    public void registerServant(ORB orb, String name, Object servantObject) throws CorbaHostException {
+        validateName(name);
+        try {
+            NamingContextExt ncRef = getNamingContext(orb);
+            NameComponent[] path = ncRef.to_name(name);
+            try {
+                ncRef.resolve(path);
+                // no exception means that some object is already registered
+                // under this name, we need to crash here
+                throw new CorbaHostException(CorbaHostException.BINDING_IN_USE);
+            } catch (NotFound e) {
+                ncRef.bind(path, servantObject);
+            }
+        } catch (CorbaHostException e) {
+            throw e;
+        } catch (Exception e) {
+            handleException(e);
+        }
+    }
+
+    public void unregisterServant(ORB orb, String name) throws CorbaHostException {
+        validateName(name);
+        try {
+            NamingContextExt ncRef = getNamingContext(orb);
+            NameComponent[] path = ncRef.to_name(name);
+            ncRef.unbind(path);
+        } catch (Exception e) {
+            handleException(e);
+        }
+    }
+
+    public Object lookup(ORB orb, String name) throws CorbaHostException {
+        validateName(name);
+        Object result = null;
+        try {
+            NamingContextExt ncRef = getNamingContext(orb);
+            NameComponent[] path = ncRef.to_name(name);
+            result = ncRef.resolve(path);
+        } catch (Exception e) {
+            handleException(e);
+        }
+        return result;
+    }
+
+    public ORB createORB(String host, int port, boolean server) throws CorbaHostException {
+        validatePort(port);
+
+        String key = host + ":" + port;
+        ORB orb = orbs.get(key);
+        if (orb != null) {
+            return orb;
+        }
+        // Create an ORB object
+        Properties props = new Properties();
+        props.putAll(System.getProperties());
+
+        String portStr = String.valueOf(port);
+        props.put("org.omg.CORBA.ORBServerId", "1000000");
+        props.put("org.omg.CORBA.ORBInitialHost", host);
+        props.put("org.omg.CORBA.ORBInitialPort", portStr);
+
+        // STEP 1: Set ORBPeristentServerPort property
+        // Set the proprietary property to open up a port to listen to
+        // INS requests. 
+
+        if (server) {
+            props.put("com.sun.CORBA.POA.ORBPersistentServerPort", portStr);
+            props.put("com.ibm.CORBA.ListenerPort", portStr);
+            props.put("gnu.CORBA.ListenerPort", portStr);
+            //        props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
+            //        props.put("org.omg.CORBA.ORBSingletonClass", "org.apache.yoko.orb.CORBA.ORBSingleton");
+            props.put("yoko.orb.oa.endpoint", "iiop --host " + host + " --port " + port);
+            props.put("yoko.orb.poamanager.TNameService.endpoint", "iiop --host " + host);
+        }
+
+        String[] args = {"-ORBInitialHost", host, "-ORBInitialPort", "" + port};
+        orb = ORB.init(args, props);
+        orbs.put(key, orb);
+        return orb;
+    }
+
+    public void stop() {
+        for (ORB orb : orbs.values()) {
+            try {
+                orb.shutdown(true);
+                orb.destroy();
+            } catch (Throwable e) {
+                logger.log(Level.SEVERE, e.getMessage(), e);
+            }
+        }
+    }
+
+}

Propchange: tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/jdk/DefaultCorbaHost.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/jdk/DefaultCorbaHost.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/NamingContextBase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/NamingContextBase.java?rev=672465&view=auto
==============================================================================
--- tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/NamingContextBase.java (added)
+++ tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/NamingContextBase.java Fri Jun 27 23:22:02 2008
@@ -0,0 +1,863 @@
+/*
+ * 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.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.SystemException;
+import org.omg.CosNaming.BindingType;
+import org.omg.CosNaming.BindingTypeHolder;
+import org.omg.CosNaming.NameComponent;
+import org.omg.CosNaming.NamingContext;
+import org.omg.CosNaming.NamingContextExtPOA;
+import org.omg.CosNaming.NamingContextHelper;
+import org.omg.CosNaming.NamingContextExtPackage.InvalidAddress;
+import org.omg.CosNaming.NamingContextPackage.AlreadyBound;
+import org.omg.CosNaming.NamingContextPackage.InvalidName;
+import org.omg.CosNaming.NamingContextPackage.NotFound;
+import org.omg.CosNaming.NamingContextPackage.NotFoundReason;
+import org.omg.PortableServer.POA;
+
+public abstract class NamingContextBase extends NamingContextExtPOA {
+    // the real logger backing instance.  We use the interface class as the locator
+    protected static final Logger logger = Logger.getLogger(NamingContext.class.getName());
+
+    // set of URL characters that don't require escaping when encoded.
+    protected final String nonEscaped = ";/?:@&=+$;-_.!~* ()";
+    // the orb we're attached to
+    protected ORB orb;
+    // the poa we're associated with
+    protected POA poa;
+
+    /**
+     * Create a new base NamingContext (super class constructor
+     * for the derived classes).
+     *
+     * @param orb    The ORB this is hosted on.
+     *
+     * @exception java.lang.Exception
+     */
+    public NamingContextBase(ORB orb, POA poa) throws java.lang.Exception {
+        super();
+        this.orb = orb;
+        this.poa = poa;
+    }
+
+    /**
+     * Bind an object to a given name.
+     *
+     * @param n      An array of NameComponents that are the target name.
+     *               The last element in the array is binding name for the
+     *               object.  The remainder of the array is the path
+     *               for resolving the naming context, relative to the
+     *               current context.  All path contexts must already be
+     *               bound in the context tree.
+     * @param obj    The object to be bound.
+     *
+     * @exception org.omg.CosNaming.NamingContextPackage.NotFound
+     * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed
+     * @exception org.omg.CosNaming.NamingContextPackage.InvalidName
+     * @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound
+     */
+    public void bind(org.omg.CosNaming.NameComponent[] n, org.omg.CORBA.Object obj)
+        throws org.omg.CosNaming.NamingContextPackage.NotFound, org.omg.CosNaming.NamingContextPackage.CannotProceed,
+        org.omg.CosNaming.NamingContextPackage.InvalidName, org.omg.CosNaming.NamingContextPackage.AlreadyBound {
+        // perform various name validations
+        validateName(n);
+
+        logNameComponent("bind() name", n);
+
+        // do we need to push through to a deeper naming context first?
+        if (n.length > 1) {
+            // resolve the top level name to a context, and have that context
+            // resolve the rest.
+            NamingContext context = resolveContext(n[0]);
+            NameComponent[] subName = extractSubName(n);
+
+            // now pass this along to the next context for the real bind operation.
+            context.bind(subName, obj);
+        } else {
+            NameComponent name = n[0];
+            // we need the resolveObject() and bindObject() calls to be consistent, so
+            // synchronize on this
+            synchronized (this) {
+                // see if we have this bound already...can't replace these.
+                BindingTypeHolder type = new BindingTypeHolder();
+                if (resolveObject(name, type) != null) {
+                    throw new AlreadyBound();
+                }
+                type.value = BindingType.nobject;
+                // ok, this is a new binding, go do it.
+                bindObject(name, obj, type);
+            }
+        }
+    }
+
+    /**
+     * Rebind an object to a given name.  If an object is
+     * already bound with this name, the new object replaces
+     * the bound object's value.  If no object has been
+     * bound already, this is the same as a bind operation.
+     *
+     * @param n      An array of NameComponents that are the target name.
+     *               The last element in the array is binding name for the
+     *               object.  The remainder of the array is the path
+     *               for resolving the naming context, relative to the
+     *               current context.  All path contexts must already be
+     *               bound in the context tree.
+     * @param obj    The new value for this binding.
+     *
+     * @exception org.omg.CosNaming.NamingContextPackage.NotFound
+     * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed
+     * @exception org.omg.CosNaming.NamingContextPackage.InvalidName
+     * @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound
+     */
+    public void rebind(org.omg.CosNaming.NameComponent[] n, org.omg.CORBA.Object obj)
+        throws org.omg.CosNaming.NamingContextPackage.NotFound, org.omg.CosNaming.NamingContextPackage.CannotProceed,
+        org.omg.CosNaming.NamingContextPackage.InvalidName {
+        // perform various name validations
+        validateName(n);
+
+        logNameComponent("rebind() name", n);
+
+        // do we need to push through to a deeper naming context first?
+        if (n.length > 1) {
+            // resolve the top level name to a context, and have that context
+            // resolve the rest.
+            NamingContext context = resolveContext(n[0]);
+            NameComponent[] subName = extractSubName(n);
+
+            // now pass this along to the next context for the real bind operation.
+            context.rebind(subName, obj);
+        } else {
+            NameComponent name = n[0];
+            // we need the resolveObject() and bindObject() calls to be consistent, so
+            // synchronize on this
+            synchronized (this) {
+                // see if we have this bound already...can't replace these.
+                BindingTypeHolder type = new BindingTypeHolder();
+                // for a rebind, we must have an object, and it must be a real object
+                if (resolveObject(name, type) != null) {
+                    // it has to resolve to a real object.  If it is a naming context,
+                    // then this is the wrong binding operation.
+                    if (type.value.value() == BindingType._ncontext) {
+                        throw new NotFound(NotFoundReason.not_object, n);
+                    }
+                    // safe to unbind
+                    unbindObject(name);
+                }
+                type.value = BindingType.nobject;
+                // now bind this object
+                bindObject(name, obj, type);
+            }
+        }
+    }
+
+    /**
+     * Bind a new context to a given name.
+     *
+     * @param n      An array of NameComponents that are the target name.
+     *               The last element in the array is binding name for the
+     *               object.  The remainder of the array is the path
+     *               for resolving the naming context, relative to the
+     *               current context.  All path contexts must already be
+     *               bound in the context tree.
+     * @param nc     The new naming context added to the tree.
+     *
+     * @exception org.omg.CosNaming.NamingContextPackage.NotFound
+     * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed
+     * @exception org.omg.CosNaming.NamingContextPackage.InvalidName
+     * @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound
+     */
+    public void bind_context(org.omg.CosNaming.NameComponent[] n, org.omg.CosNaming.NamingContext nc)
+        throws org.omg.CosNaming.NamingContextPackage.NotFound, org.omg.CosNaming.NamingContextPackage.CannotProceed,
+        org.omg.CosNaming.NamingContextPackage.InvalidName, org.omg.CosNaming.NamingContextPackage.AlreadyBound {
+        // perform various name validations
+        validateName(n);
+
+        logNameComponent("bind_context() name", n);
+
+        // do we need to push through to a deeper naming context first?
+        if (n.length > 1) {
+            // resolve the top level name to a context, and have that context
+            // resolve the rest.
+            NamingContext context = resolveContext(n[0]);
+            NameComponent[] subName = extractSubName(n);
+
+            // now pass this along to the next context for the real bind operation.
+            context.bind_context(subName, nc);
+        } else {
+            NameComponent name = n[0];
+            // we need the resolveObject() and bindObject() calls to be consistent, so
+            // synchronize on this
+            synchronized (this) {
+                // see if we have this bound already...can't replace these.
+                BindingTypeHolder type = new BindingTypeHolder();
+                if (resolveObject(name, type) != null) {
+                    throw new AlreadyBound();
+                }
+                type.value = BindingType.ncontext;
+                // ok, this is a new binding, go do it.
+                bindObject(name, nc, type);
+            }
+        }
+    }
+
+    /**
+     * Rebind a context to a given name.  If a context is
+     * already bound with this name, the new context replaces
+     * the existing context.  If no context has been
+     * bound already, this is the same as a bind operation.
+     *
+     * @param n      An array of NameComponents that are the target name.
+     *               The last element in the array is binding name for the
+     *               object.  The remainder of the array is the path
+     *               for resolving the naming context, relative to the
+     *               current context.  All path contexts must already be
+     *               bound in the context tree.
+     * @param nc     The new context to be bound with the name.
+     *
+     * @exception org.omg.CosNaming.NamingContextPackage.NotFound
+     * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed
+     * @exception org.omg.CosNaming.NamingContextPackage.InvalidName
+     * @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound
+     */
+    public void rebind_context(org.omg.CosNaming.NameComponent[] n, org.omg.CosNaming.NamingContext nc)
+        throws org.omg.CosNaming.NamingContextPackage.NotFound, org.omg.CosNaming.NamingContextPackage.CannotProceed,
+        org.omg.CosNaming.NamingContextPackage.InvalidName {
+        // perform various name validations
+        validateName(n);
+
+        logNameComponent("rebind_context() name", n);
+
+        // do we need to push through to a deeper naming context first?
+        if (n.length > 1) {
+            // resolve the top level name to a context, and have that context
+            // resolve the rest.
+            NamingContext context = resolveContext(n[0]);
+            NameComponent[] subName = extractSubName(n);
+
+            // now pass this along to the next context for the real bind operation.
+            context.rebind_context(subName, nc);
+        } else {
+            NameComponent name = n[0];
+            // we need the resolveObject() and bindObject() calls to be consistent, so
+            // synchronize on this
+            synchronized (this) {
+                // see if we have this bound already...can't replace these.
+                BindingTypeHolder type = new BindingTypeHolder();
+                // for a rebind, we must have an object, and it must be a real object
+                if (resolveObject(name, type) != null) {
+                    // it has to resolve to a real object.  If it is a naming context,
+                    // then this is the wrong binding operation.
+                    if (type.value.value() != BindingType._ncontext) {
+                        throw new NotFound(NotFoundReason.not_context, n);
+                    }
+                    // safe to unbind
+                    unbindObject(name);
+                }
+                type.value = BindingType.ncontext;
+                // now bind this object
+                bindObject(name, nc, type);
+            }
+        }
+    }
+
+    /**
+     * Resolve an an entry in the context tree.  The
+     * resolved object may be a bound object or another
+     * NamingContext.  If the named entry is not found,
+     * a NotFound exception is thrown.
+     *
+     * @param n      An array of NameComponents that are the target name.
+     *               The last element in the array is binding name for the
+     *               object.  The remainder of the array is the path
+     *               for resolving the naming context, relative to the
+     *               current context.  All path contexts must already be
+     *               bound in the context tree.
+     *
+     * @return The object bound at the indicated location.
+     * @exception org.omg.CosNaming.NamingContextPackage.NotFound
+     * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed
+     * @exception org.omg.CosNaming.NamingContextPackage.InvalidName
+     * @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound
+     */
+    public org.omg.CORBA.Object resolve(org.omg.CosNaming.NameComponent[] n)
+        throws org.omg.CosNaming.NamingContextPackage.NotFound, org.omg.CosNaming.NamingContextPackage.CannotProceed,
+        org.omg.CosNaming.NamingContextPackage.InvalidName {
+        // perform various name validations
+        validateName(n);
+
+        logNameComponent("resolve() name", n);
+
+        // do we need to push through to a deeper naming context first?
+        if (n.length > 1) {
+            // resolve the top level name to a context, and have that context
+            // resolve the rest.
+            NamingContext context = resolveContext(n[0]);
+            NameComponent[] subName = extractSubName(n);
+
+            // now pass this along to the next context for the real bind operation.
+            return context.resolve(subName);
+        } else {
+            NameComponent name = n[0];
+            // see if we have this bound already...can't replace these.
+            BindingTypeHolder type = new BindingTypeHolder();
+            org.omg.CORBA.Object obj = resolveObject(name, type);
+            if (obj == null) {
+                // Object was not found
+                throw new NotFound(NotFoundReason.missing_node, n);
+            }
+            return obj;
+        }
+    }
+
+    /**
+     * Remove an entry from the context tree.  The
+     * target object may be a bound object or another
+     * NamingContext.  If the named entry is not found,
+     * a NotFound exception is thrown.
+     *
+     * @param n      An array of NameComponents that are the target name.
+     *               The last element in the array is binding name for the
+     *               object.  The remainder of the array is the path
+     *               for resolving the naming context, relative to the
+     *               current context.  All path contexts must already be
+     *               bound in the context tree.
+     *
+     * @exception org.omg.CosNaming.NamingContextPackage.NotFound
+     * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed
+     * @exception org.omg.CosNaming.NamingContextPackage.InvalidName
+     * @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound
+     */
+    public void unbind(org.omg.CosNaming.NameComponent[] n) throws org.omg.CosNaming.NamingContextPackage.NotFound,
+        org.omg.CosNaming.NamingContextPackage.CannotProceed, org.omg.CosNaming.NamingContextPackage.InvalidName {
+        // perform various name validations
+        validateName(n);
+
+        logNameComponent("unbind() name", n);
+
+        // do we need to push through to a deeper naming context first?
+        if (n.length > 1) {
+            // resolve the top level name to a context, and have that context
+            // resolve the rest.
+            NamingContext context = resolveContext(n[0]);
+            NameComponent[] subName = extractSubName(n);
+
+            // now pass this along to the next context for the real bind operation.
+            context.unbind(subName);
+        } else {
+            NameComponent name = n[0];
+            synchronized (this) {
+                // see if we have this bound already...can't replace these.
+                BindingTypeHolder type = new BindingTypeHolder();
+                org.omg.CORBA.Object obj = unbindObject(name);
+                if (obj == null) {
+                    // Object was not found
+                    throw new NotFound(NotFoundReason.missing_node, n);
+                }
+            }
+        }
+    }
+
+    /**
+     * Create a new context and bind it in at the target
+     * location.
+     *
+     * @param n      An array of NameComponents that are the target name.
+     *               The last element in the array is binding name for the
+     *               object.  The remainder of the array is the path
+     *               for resolving the naming context, relative to the
+     *               current context.  All path contexts must already be
+     *               bound in the context tree.
+     *
+     * @return The newly created context.
+     * @exception org.omg.CosNaming.NamingContextPackage.NotFound
+     * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed
+     * @exception org.omg.CosNaming.NamingContextPackage.InvalidName
+     * @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound
+     */
+    public synchronized org.omg.CosNaming.NamingContext bind_new_context(org.omg.CosNaming.NameComponent[] n)
+        throws org.omg.CosNaming.NamingContextPackage.NotFound, org.omg.CosNaming.NamingContextPackage.AlreadyBound,
+        org.omg.CosNaming.NamingContextPackage.CannotProceed, org.omg.CosNaming.NamingContextPackage.InvalidName {
+        logNameComponent("bind_new_context() name", n);
+
+        NamingContext context = new_context();
+        try {
+            bind_context(n, context);
+            NamingContext returnContext = context;
+            // transfer this to another variable so the finally block doesn't try to destroy this.
+            context = null;
+            return returnContext;
+        } finally {
+            // if there is a bind failure on this, we need to ensure the context has
+            // an opportunity to clean up any of its resources.
+            if (context != null) {
+                try {
+                    context.destroy();
+                } catch (org.omg.CosNaming.NamingContextPackage.NotEmpty e) {
+                    // new contexts should be empty.
+                }
+            }
+        }
+    }
+
+    /**
+     * Convert an array of NameComponents into the string
+     * form of a context name.
+     *
+     * @param n      The array of NameComponents to convert.
+     *
+     * @return The context name, in string form.
+     * @exception org.omg.CosNaming.NamingContextPackage.InvalidName
+     */
+    public String to_string(org.omg.CosNaming.NameComponent[] n)
+        throws org.omg.CosNaming.NamingContextPackage.InvalidName {
+        validateName(n);
+
+        logNameComponent("to_string() name", n);
+
+        // convert the first part of the name
+        StringBuffer value = new StringBuffer();
+        ;
+        // convert the first component, then build up from there.
+        nameToString(n[0], value);
+
+        // the remainder need to get a separator
+        for (int i = 1; i < n.length; i++) {
+            value.append('/');
+            nameToString(n[i], value);
+        }
+        return value.toString();
+    }
+
+    /**
+     * Perform the reverse operation of the to_string() method,
+     * parsing a String context name into an array of
+     * NameComponents.
+     *
+     * @param sn     The string form of the name.
+     *
+     * @return An array of NameComponents parsed from the String name.
+     * @exception org.omg.CosNaming.NamingContextPackage.InvalidName
+     */
+    public org.omg.CosNaming.NameComponent[] to_name(String sn)
+        throws org.omg.CosNaming.NamingContextPackage.InvalidName {
+        // must have a argument to parse
+        if (sn == null || sn.length() == 0) {
+            throw new InvalidName();
+        }
+
+        List components = new ArrayList();
+
+        StringBuffer component = new StringBuffer();
+
+        int index = 0;
+        String id = null;
+        String kind = null;
+        while (index < sn.length()) {
+            char ch = sn.charAt(index++);
+
+            // found an escape character or a delimiter?
+            if (ch == '\\') {
+                // nothing after the escape?  Trouble
+                if (index >= sn.length()) {
+                    throw new InvalidName();
+                }
+                // get the next character
+                ch = sn.charAt(index++);
+                component.append(ch);
+            }
+            // we need to process the periods here, to avoid getting
+            // mixed up with unescaped periods.
+            else if (ch == '.') {
+                // already seen a period while scanning?  That's not allowed
+                if (id != null) {
+                    throw new InvalidName();
+                }
+                // pull off the id piece and reset the buffer
+                id = component.toString();
+                component.setLength(0);
+            }
+            // found a component delimiter?
+            else if (ch == '/') {
+                // not seen a id/kind separator yet?  This is an id with no kind
+                if (id == null) {
+                    id = component.toString();
+                    kind = "";
+                } else {
+                    // we have an id already, pull off the kind
+                    kind = component.toString();
+                }
+                // add the parsed name component
+                components.add(new NameComponent(id, kind));
+                // make sure these are all reset after pulling off a component
+                component.setLength(0);
+                id = null;
+                kind = null;
+            } else {
+                component.append(ch);
+            }
+        }
+
+        // parse the last section
+        // not seen a id/kind separator yet?  This is an id with no kind
+        if (id == null) {
+            id = component.toString();
+            kind = "";
+        } else {
+            // we have an id already, pull off the kind
+            kind = component.toString();
+        }
+        // add the parsed name component
+        components.add(new NameComponent(id, kind));
+
+        // and turn this into a component array
+        return (NameComponent[])components.toArray(new NameComponent[components.size()]);
+    }
+
+    /**
+     * Create a URL name for accessing a component by name.  The
+     * URL will have a corbaname: protocol.
+     *
+     * @param addr   The address location for the naming service used
+     *               to resolve the object.  This is in "host:port" form,
+     *               just line a corbaloc: URL.
+     * @param sn     The string mae of the target object.
+     *
+     * @return A URL for accessing this object, in String form.
+     * @exception org.omg.CosNaming.NamingContextExtPackage.InvalidAddress
+     * @exception org.omg.CosNaming.NamingContextPackage.InvalidName
+     */
+    public String to_url(String addr, String sn) throws org.omg.CosNaming.NamingContextExtPackage.InvalidAddress,
+        org.omg.CosNaming.NamingContextPackage.InvalidName {
+        // basic validation
+        if (addr == null || addr.length() == 0) {
+            throw new InvalidAddress();
+        }
+
+        if (sn == null || sn.length() == 0) {
+            throw new InvalidName();
+        }
+
+        // TODO:  What validation, if any, needs to be done here?
+        return "corbaname:" + addr + "#" + encodeRFC2396Name(sn);
+    }
+
+    /**
+     * Resolve a bound object or context using a name
+     * in String form.
+     *
+     * @param n      The string name of the object context.  This must
+     *               be a form parseable by to_name().
+     *
+     * @return The bound object or context.
+     * @exception org.omg.CosNaming.NamingContextPackage.NotFound
+     * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed
+     * @exception org.omg.CosNaming.NamingContextPackage.InvalidName
+     */
+    public org.omg.CORBA.Object resolve_str(String n) throws org.omg.CosNaming.NamingContextPackage.NotFound,
+        org.omg.CosNaming.NamingContextPackage.CannotProceed, org.omg.CosNaming.NamingContextPackage.InvalidName {
+        // this is just a simple convenience method
+        return resolve(to_name(n));
+    }
+
+    // abstract methods that are part of the NamingContext interface that need to be
+    // implemented by the subclasses.
+
+    /**
+     * 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 abstract org.omg.CosNaming.NamingContext new_context() throws SystemException;
+
+    /**
+     * Destroy a context.  This method should clean up
+     * any backing resources associated with the context.
+     *
+     * @exception org.omg.CosNaming.NamingContextPackage.NotEmpty
+     */
+    public abstract void destroy() throws org.omg.CosNaming.NamingContextPackage.NotEmpty;
+
+    /**
+     * 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 abstract void list(int how_many,
+                              org.omg.CosNaming.BindingListHolder bl,
+                              org.omg.CosNaming.BindingIteratorHolder bi) throws SystemException;
+
+    // abstract methods for the sub class to implement
+
+    /**
+     * 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 abstract org.omg.CORBA.Object resolveObject(NameComponent n, BindingTypeHolder type)
+        throws SystemException;
+
+    /**
+     * 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 abstract void bindObject(NameComponent n, org.omg.CORBA.Object obj, BindingTypeHolder type)
+        throws SystemException;
+
+    /**
+     * 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 abstract org.omg.CORBA.Object unbindObject(NameComponent n) throws SystemException;
+
+    // implementation specific routines
+
+    /**
+     * Resolve a name to a context object stored that has
+     * already been stored in this context.  Throws an exception
+     * if the name cannot be resolved or if the resolved
+     * object is not a naming context.
+     *
+     * @param name   The target name.
+     *
+     * @return The resolved NamingContext object.
+     * @exception org.omg.CosNaming.NamingContextPackage.NotFound
+     */
+    protected synchronized NamingContext resolveContext(NameComponent name)
+        throws org.omg.CosNaming.NamingContextPackage.NotFound {
+        BindingTypeHolder type = new BindingTypeHolder();
+        // Resolve this to an object.  We must be able to resolve this.
+        org.omg.CORBA.Object resolvedReference = resolveObject(name, type);
+        if (resolvedReference == null) {
+            throw new NotFound(NotFoundReason.missing_node, new NameComponent[] {name});
+        }
+
+        // it has to resolve to a naming context
+        if (type.value.value() != BindingType._ncontext) {
+            throw new NotFound(NotFoundReason.not_context, new NameComponent[] {name});
+        }
+
+        // in theory, this is a naming context.  Narrow it an return.  Any
+        // errors just become a NotFound exception
+        try {
+            return NamingContextHelper.narrow(resolvedReference);
+        } catch (org.omg.CORBA.BAD_PARAM ex) {
+            throw new NotFound(NotFoundReason.not_context, new NameComponent[] {name});
+        }
+    }
+
+    /**
+     * Extract the tail portion of a name.  This is used
+     * to strip off the first name element so we can recurse
+     * on the name resolutions with a resolved context.
+     *
+     * @param name   The current name array (this MUST have 2 or more
+     *               elements).
+     *
+     * @return An array of NameComponent items that is one element
+     *         smaller than the argument array, with the elements
+     *         shifted over.
+     */
+    protected NameComponent[] extractSubName(NameComponent[] name) {
+        NameComponent[] subName = new NameComponent[name.length - 1];
+        System.arraycopy(name, 1, subName, 0, name.length - 1);
+        return subName;
+    }
+
+    /**
+     * Perform common name validity checking.
+     *
+     * @param n      The NameComponent array to check.
+     *
+     * @exception InvalidName
+     */
+    protected void validateName(NameComponent[] n) throws InvalidName {
+        // perform various name validations
+        if (n == null) {
+            throw new BAD_PARAM(27 | org.omg.CORBA.OMGVMCID.value, CompletionStatus.COMPLETED_NO);
+        }
+
+        // Valid name?
+        if (n.length < 1) {
+            throw new InvalidName();
+        }
+
+        // we have at least one name, so validate the toplevel item
+        NameComponent name = n[0];
+
+        // more name validation
+        if (name.id.length() == 0 && name.kind.length() == 0) {
+            throw new InvalidName();
+        }
+    }
+
+    /**
+     * Convert a NameComponent item into a string form,
+     * appending it to a StringBuffer.
+     *
+     * @param name   The source NameComponent.
+     * @param out    The StringBuffer location used to store the name
+     *               value (appended to the end).
+     */
+    protected void nameToString(NameComponent name, StringBuffer out) {
+        // if the id is null, then we base off of the kind.
+        if (name.id == null || name.id.length() == 0) {
+            out.append(".");
+            // true null name element?  That displays as a "."
+            if (name.kind != null && name.kind.length() != 0) {
+                escapeName(name.kind, out);
+            }
+        } else {
+            // escape the name
+            escapeName(name.id, out);
+            // have a kind qualifier to add on?
+            if (name.kind != null && name.kind.length() != 0) {
+                out.append(".");
+                escapeName(name.kind, out);
+            }
+        }
+    }
+
+    /**
+     * Process a name or kind element of a NameComponent,
+     * adding escape characters for '.' or '/' characters
+     * that might appear in the name.
+     *
+     * @param name   The name element to process.
+     * @param out    The StringBuffer to copy the escaped name into.
+     */
+    protected void escapeName(String name, StringBuffer out) {
+        // no characters requiring escapes (common)?
+        // use this directly
+        if (name.indexOf('.') == -1 && name.indexOf('/') == -1) {
+            out.append(name);
+        } else {
+            // scan the string adding the escapes
+            for (int i = 0; i < name.length(); i++) {
+                char ch = name.charAt(i);
+                if (ch == '.' || ch == '/') {
+                    out.append('/');
+                }
+                out.append(ch);
+            }
+        }
+    }
+
+    /**
+     * Perform RFC 2396 escape encoding of a name value.
+     *
+     * @param name   The input name value.
+     *
+     * @return An encoded name, with special characters converted
+     *         into a hex encoded value.
+     */
+    protected String encodeRFC2396Name(String name) {
+        StringBuffer value = new StringBuffer();
+
+        for (int i = 0; i < name.length(); i++) {
+            char ch = name.charAt(i);
+
+            // Alphanumerics and the "acceptable" set of special characters just get copied
+            // without encoding.
+            if (Character.isLetterOrDigit(ch) || nonEscaped.indexOf(ch) != -1) {
+                value.append(ch);
+            } else {
+                // this gets converted into a hex value, marked by "%".
+                value.append('%');
+                value.append(Integer.toHexString((int)ch));
+            }
+        }
+        return value.toString();
+    }
+
+    /**
+     * Test if debug logging is currently available.
+     *
+     * @return True if debug level (FINE) logging is currently turned on.
+     */
+    protected boolean isDebugEnabled() {
+        return logger.isLoggable(Level.FINE);
+    }
+
+    /**
+     * Log a line of debug output
+     *
+     * @param message The message to log
+     */
+    protected void debug(String message) {
+        logger.fine(message);
+    }
+
+    /**
+     * Log the name components passed in for a request.
+     *
+     * @param message A message describing the request context.
+     * @param n       The array of name components.
+     */
+    protected void logNameComponent(String message, NameComponent[] n) {
+        if (isDebugEnabled()) {
+            debug(message);
+            for (int i = 0; i < n.length; i++) {
+                debug("   NameComponent " + i + " id=" + n[i].id + " kind=" + n[i].kind);
+            }
+        }
+    }
+
+}

Propchange: tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/NamingContextBase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/NamingContextBase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNameServer.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNameServer.java?rev=672465&view=auto
==============================================================================
--- tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNameServer.java (added)
+++ tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNameServer.java Fri Jun 27 23:22:02 2008
@@ -0,0 +1,133 @@
+/*
+ * 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 org.omg.CORBA.ORB;
+
+/**
+ * A stand-alone naming service launchable from a command line.
+ */
+public class TransientNameServer {
+    private final TransientNameService service;
+    private final Object flag = new Object();
+    private Boolean started;
+
+    public TransientNameServer(String host, int port, String serviceName) {
+        this.service = new TransientNameService(host, port, serviceName);
+    }
+
+    public ORB getORB() {
+        return service.getORB();
+    }
+
+    public Thread start() {
+        Thread t = new Thread() {
+            public void run() {
+                ORB orb = null;
+                synchronized (flag) {
+                    try {
+                        service.run();
+                        orb = service.getORB();
+                        started = Boolean.TRUE;
+                    } catch (Throwable e) {
+                        started = Boolean.FALSE;
+                        throw new IllegalStateException(e);
+                    } finally {
+                        flag.notifyAll();
+                    }
+                }
+                // Wait for requests
+                orb.run();
+            }
+        };
+        // t.setDaemon(true);
+        t.start();
+        checkState();
+        return t.isAlive() ? t : null;
+    }
+
+    private Boolean checkState() {
+        synchronized (flag) {
+            while (started == null) {
+                try {
+                    flag.wait();
+                } catch (InterruptedException e) {
+                    return null;
+                }
+            }
+            return started;
+        }
+    }
+
+    public void stop() {
+        if (started == Boolean.TRUE) {
+            service.destroy();
+        }
+    }
+
+    /**
+     * Launch a name service as a stand alone process.  The
+     * Host, port, and service name are controlled using
+     * program arguments.
+     *
+     * @param args   The array of arguments for tailoring the service.
+     *
+     * @exception Exception
+     */
+    public static void main(String args[]) throws Exception {
+        int port = TransientNameService.DEFAULT_SERVICE_PORT;
+        String host = TransientNameService.DEFAULT_SERVICE_HOST;
+        String serviceName = TransientNameService.DEFAULT_SERVICE_NAME;
+
+        // see if we have
+        for (int i = 0; i < args.length; i++) {
+            if (args[i].equals("-ORBInitialPort")) {
+                i++;
+                if (i < args.length) {
+                    port = java.lang.Integer.parseInt(args[i]);
+                } else {
+                    throw new IllegalArgumentException("Invalid -ORBInitialPort option");
+                }
+            } else if (args[i].equals("-ORBInitialHost")) {
+                i++;
+                if (i < args.length) {
+                    host = args[i];
+                } else {
+                    throw new IllegalArgumentException("Invalid -ORBInitialHost option");
+                }
+            } else if (args[i].equals("-ORBServiceName")) {
+                i++;
+                if (i < args.length) {
+                    serviceName = args[i];
+                } else {
+                    throw new IllegalArgumentException("Invalid -ORBServiceName option");
+                }
+            }
+
+        }
+        // create a services, and just spin it off.  We wait forever after that.
+        TransientNameServer server = new TransientNameServer(host, port, serviceName);
+        server.start().join();
+    }
+
+}

Propchange: tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNameServer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNameServer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNameService.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNameService.java?rev=672465&view=auto
==============================================================================
--- tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNameService.java (added)
+++ tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNameService.java Fri Jun 27 23:22:02 2008
@@ -0,0 +1,183 @@
+/*
+ * 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.lang.reflect.Method;
+import java.util.Properties;
+
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Policy;
+import org.omg.PortableServer.IdAssignmentPolicyValue;
+import org.omg.PortableServer.LifespanPolicyValue;
+import org.omg.PortableServer.POA;
+import org.omg.PortableServer.ServantRetentionPolicyValue;
+
+/**
+ * A transient name service attached to an ORB.  This
+ * class manages all of the housekeeping for creating a
+ * TransientNamingContext and a exposing it using an
+ * ORB.
+ */
+public class TransientNameService {
+    // the default registered name service
+    static public final String DEFAULT_SERVICE_NAME = "TNameService";
+    // the default listening port
+    static public final int DEFAULT_SERVICE_PORT = 900;
+    // the default host name
+    static public final String DEFAULT_SERVICE_HOST = "localhost";
+
+    // the service root context
+    protected TransientNamingContext initialContext;
+    // initial listening port
+    protected int port;
+    // initial listening host
+    protected String host;
+    // the service name (used for registing for the corbaloc:: URL name
+    protected String serviceName;
+    // the orb instance we're running on
+    protected ORB createdOrb;
+
+    /**
+     * Create a new TransientNameService, using all default
+     * attributes.
+     */
+    public TransientNameService() {
+        this(DEFAULT_SERVICE_HOST, DEFAULT_SERVICE_PORT, DEFAULT_SERVICE_NAME);
+    }
+
+    /**
+     * Create a default-named name service using the specified
+     * host and port parameters.
+     *
+     * @param host   The host to expose this under.
+     * @param port   The initial listening port.
+     */
+    public TransientNameService(String host, int port) {
+        this(host, port, DEFAULT_SERVICE_NAME);
+    }
+
+    /**
+     * Create a specifically-named name service using the specified
+     * host and port parameters.
+     *
+     * @param host   The host to expose this under.
+     * @param port   The initial listening port.
+     * @param name   The name to register this service under using the
+     *               BootManager.
+     */
+    public TransientNameService(String host, int port, String name) {
+        this.port = port;
+        this.host = host;
+        this.serviceName = name;
+    }
+
+    /**
+     * Start up the name service, including creating an
+     * ORB instance to expose it under.
+     *
+     * @exception TransientServiceException
+     */
+    public void run() throws TransientServiceException {
+        // Create an ORB object
+        Properties props = new Properties();
+        props.putAll(System.getProperties());
+
+        String portStr = String.valueOf(port);
+        props.put("org.omg.CORBA.ORBServerId", "1000000");
+        props.put("org.omg.CORBA.ORBInitialHost", host);
+        props.put("org.omg.CORBA.ORBInitialPort", portStr);
+
+        // STEP 1: Set ORBPeristentServerPort property
+        // Set the proprietary property to open up a port to listen to
+        // INS requests. 
+
+        props.put("com.sun.CORBA.POA.ORBPersistentServerPort", portStr);
+        props.put("com.ibm.CORBA.ListenerPort", portStr);
+        props.put("gnu.CORBA.ListenerPort", portStr);
+        //        props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
+        //        props.put("org.omg.CORBA.ORBSingletonClass", "org.apache.yoko.orb.CORBA.ORBSingleton");
+        props.put("yoko.orb.oa.endpoint", "iiop --host " + host + " --port " + port);
+        props.put("yoko.orb.poamanager.TNameService.endpoint", "iiop --host " + host);
+
+        String[] args = {"-ORBInitialHost", host, "-ORBInitialPort", "" + port};
+        createdOrb = ORB.init(args, props);
+
+        // now initialize the service
+        initialize(createdOrb);
+
+    }
+
+    /**
+     * Initialize a transient name service on a specific
+     * ORB.
+     *
+     * @param orb    The ORB hosting the service.
+     *
+     * @exception TransientServiceException
+     */
+    public void initialize(ORB orb) throws TransientServiceException {
+        try {
+            // get the root POA.  We're going to re
+            POA rootPOA = (POA)orb.resolve_initial_references("RootPOA");
+            rootPOA.the_POAManager().activate();
+
+            // we need to create a POA to manage this named instance, and then activate
+            // a context on it.
+            Policy[] policy = new Policy[3];
+            policy[0] = rootPOA.create_lifespan_policy(LifespanPolicyValue.TRANSIENT);
+            policy[1] = rootPOA.create_id_assignment_policy(IdAssignmentPolicyValue.SYSTEM_ID);
+            policy[2] = rootPOA.create_servant_retention_policy(ServantRetentionPolicyValue.RETAIN);
+
+            POA nameServicePOA = rootPOA.create_POA("TNameService", null, policy);
+            nameServicePOA.the_POAManager().activate();
+
+            // create our initial context, and register that with the ORB as the name service
+            initialContext = new TransientNamingContext(orb, nameServicePOA);
+            org.omg.CORBA.Object context = initialContext.getRootContext();
+            Method method =
+                orb.getClass().getMethod("register_initial_reference", String.class, org.omg.CORBA.Object.class);
+            method.invoke(orb, serviceName, context);
+            method.invoke(orb, "NamingService", context);
+            method.invoke(orb, "NameService", context);
+        } catch (Exception e) {
+            throw new TransientServiceException("Unable to initialize name service", e);
+        }
+    }
+
+    /**
+     * Destroy the created service.
+     */
+    public void destroy() {
+        // only destroy this if we created the orb instance.
+        if (createdOrb != null) {
+            createdOrb.shutdown(true);
+            createdOrb.destroy();
+            createdOrb = null;
+        }
+    }
+
+    public ORB getORB() {
+        return createdOrb;
+    }
+
+}

Propchange: tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNameService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/java/sca/modules/host-corba-jdk/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNameService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date