You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ad...@apache.org on 2005/01/24 08:33:11 UTC

svn commit: r126264 - in geronimo/trunk/modules/interop: . src src/idl src/java src/java/org src/java/org/apache src/java/org/apache/geronimo src/java/org/apache/geronimo/interop src/java/org/apache/geronimo/interop/CosNaming src/java/org/apache/geronimo/interop/CosNaming/iiop_stubs src/java/org/apache/geronimo/interop/adapter src/java/org/apache/geronimo/interop/client src/java/org/apache/geronimo/interop/generator src/java/org/apache/geronimo/interop/generator/class src/java/org/apache/geronimo/interop/generator/java src/java/org/apache/geronimo/interop/naming src/java/org/apache/geronimo/interop/properties src/java/org/apache/geronimo/interop/repository src/java/org/apache/geronimo/interop/rmi src/java/org/apache/geronimo/interop/rmi/iiop src/java/org/apache/geronimo/interop/rmi/iiop/client src/java/org/apache/geronimo/interop/rmi/iiop/compiler src/java/org/apache/geronimo/interop/rmi/iiop/server src/java/org/apache/geronimo/interop/security src/java/org/apache/geronimo/interop/server src/java/org/apache/geronimo/interop/util src/test src/test-resources src/test-resources/META-INF src/test/org src/test/org/apache src/test/org/apache/geronimo src/test/org/apache/geronimo/interop

Author: adc
Date: Sun Jan 23 23:33:10 2005
New Revision: 126264

URL: http://svn.apache.org/viewcvs?view=rev&rev=126264
Log:
Maven build of RMI-IIOP and Interop
http://issues.apache.org/jira/browse/GERONIMO-548
Added:
   geronimo/trunk/modules/interop/
   geronimo/trunk/modules/interop/LICENSE.txt
   geronimo/trunk/modules/interop/NOTICE.txt
   geronimo/trunk/modules/interop/maven.xml
   geronimo/trunk/modules/interop/project.properties
   geronimo/trunk/modules/interop/project.xml
   geronimo/trunk/modules/interop/src/
   geronimo/trunk/modules/interop/src/idl/
   geronimo/trunk/modules/interop/src/idl/CosNaming.idl
   geronimo/trunk/modules/interop/src/idl/GIOP.idl
   geronimo/trunk/modules/interop/src/idl/IIOP.idl
   geronimo/trunk/modules/interop/src/idl/IOP.idl
   geronimo/trunk/modules/interop/src/idl/Readme.txt
   geronimo/trunk/modules/interop/src/idl/org-apache-geronimo-interop-rmi-iiop.idl
   geronimo/trunk/modules/interop/src/java/
   geronimo/trunk/modules/interop/src/java/org/
   geronimo/trunk/modules/interop/src/java/org/apache/
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/CheckedException.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/CosNaming/
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/CosNaming/iiop_stubs/
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/CosNaming/iiop_stubs/NamingContext_Stub.1.txt
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/CosNaming/iiop_stubs/NamingContext_Stub.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/InteropGBean.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/SystemException.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/adapter/
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/adapter/Adapter.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/adapter/AdapterManager.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/client/
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/client/InitialContextFactory.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/client/InitialContextFactoryBuilder.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/CodeWriter.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/GenException.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/GenOptions.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/Generator.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JBlockStatement.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JCaseStatement.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JCatchStatement.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JClass.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JCodeStatement.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JConstructor.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JDeclareStatement.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JElseIfStatement.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JElseStatement.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JEntity.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JExpression.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JField.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JFinallyStatement.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JForStatement.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JIfElseIfElseStatement.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JIfStatement.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JLocalVariable.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JMethod.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JPackage.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JParameter.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JReturnType.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JStatement.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JSwitchStatement.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JTryCatchFinallyStatement.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JTryStatement.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JVariable.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JavaGenerator.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JavaWriter.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/class/
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/java/
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/readme.txt
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/naming/
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/naming/InitialContext.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/naming/InitialContextFactory.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/naming/NameService.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/naming/NameServiceLog.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/naming/NamingContext.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/BooleanProperty.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/ByteProperty.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/DoubleProperty.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/FloatProperty.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/IntProperty.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/LongProperty.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/MissingRequiredPropertyException.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/PropertyLog.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/PropertyMap.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/PropertyType.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/ShortProperty.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/StringProperty.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/SystemProperties.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/SystemPropertyLog.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/repository/
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/repository/Repository.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/RmiTrace.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/Any.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ArrayHelper.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/BadMagicException.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/CdrInputStream.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/CdrOutputStream.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/FieldByNameComparator.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/FieldComparator.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/GiopMessage.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/GiopVersion.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/IDLEntityHelper.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/IiopVersion.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ListenerInfo.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/NameServiceOperations_Skeleton.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectHelper.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectInputStream.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectKey.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectOutputStream.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectRef.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectRefHelper.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/PrimitiveType.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/Protocol.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/RemoteExceptionFactory.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/RemoteInterface.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/RemoteObject.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/SecurityInfo.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/SimpleObjectInputStream.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/SimpleObjectOutputStream.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/StringHelper.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/StringValueHelper.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/SystemExceptionFactory.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/TypeCode.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/UnsupportedProtocolVersionException.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ValueType.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ValueTypeField.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/client/
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/client/ClientNamingContext.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/client/Connection.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/client/ConnectionPool.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/client/HostList.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/client/NameBinding.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/client/RetryInvokeException.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/client/UrlInfo.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/client/ValueInfo.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/Compiler.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/SkelCompiler.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/SkelFactory.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/StubClass.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/StubCompiler.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/StubCompiler.txt
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/StubFactory.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/ValueTypeContext.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/MessageHandler.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/RequestHandler.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/ServerNamingContext.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/SocketListener.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/security/
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/security/Role.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/security/SimpleSubject.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/security/User.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/server/
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/server/IIOPDaemon.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/server/IIOPSDaemon.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/ArrayUtil.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/Base16Binary.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/Base64Binary.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/BigEndian.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/ExceptionList.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/ExceptionUtil.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/FileUtil.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/FutureObject.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/InstancePool.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/IntegerCache.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/JavaClass.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/JavaMethod.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/JavaObject.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/JavaType.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/ListUtil.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/LittleEndian.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/MemoryBarrier.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/MethodParameter.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/NamedValue.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/NamedValueList.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/ParameterList.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/ProcessUtil.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/SimpleIdentityHashMap.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/StringUtil.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/SystemUtil.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/ThreadContext.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/UTF8.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/UnsignedByte.java
   geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/UnsignedShort.java
   geronimo/trunk/modules/interop/src/test/
   geronimo/trunk/modules/interop/src/test-resources/
   geronimo/trunk/modules/interop/src/test-resources/META-INF/
   geronimo/trunk/modules/interop/src/test/org/
   geronimo/trunk/modules/interop/src/test/org/apache/
   geronimo/trunk/modules/interop/src/test/org/apache/geronimo/
   geronimo/trunk/modules/interop/src/test/org/apache/geronimo/interop/
   geronimo/trunk/modules/interop/src/test/org/apache/geronimo/interop/InteropGBeanTest.java

Added: geronimo/trunk/modules/interop/LICENSE.txt
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/LICENSE.txt?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/LICENSE.txt	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,203 @@
+
+                                 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: geronimo/trunk/modules/interop/NOTICE.txt
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/NOTICE.txt?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/NOTICE.txt	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,3 @@
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+

Added: geronimo/trunk/modules/interop/maven.xml
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/maven.xml?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/maven.xml	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,214 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+    Copyright 2004-2005 The Apache Software Foundation
+
+    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.
+-->
+  
+
+<!-- $Rev: 46019 $ $Date: 2004-09-14 05:56:06 -0400 (Tue, 14 Sep 2004) $ -->
+
+<project default="default"
+    xmlns:j="jelly:core"
+    xmlns:ant="jelly:ant"
+    >
+
+    <!--
+      #
+      # Be carefull about changing the package prefix.  When generating the java
+      # files for the .IDL files, they will normally go into a package that
+      # corresponds with the module.  I originally had o.a.g.i.org.omg as the
+      # prefix, but the idlj tool would generate the GIOP in a wrong package:
+      # o.a.g.i.org.omg.o.a.g.i for some strange reason.
+    -->
+
+    <!--
+      # Todo:
+      #
+      # 1. It would be nice to improve the iop, giop, iiop, cosnaming targets as their
+      #    build goals are almost the same.  Maybe we could figure out how to use a for
+      #    script statement....
+      #
+      # 2. Run the idlj targets only if the idl files were changed.  Figure out how
+      #    to add a dependency check....
+      #
+      # 3. ....
+      #
+    -->
+
+    <goal name="interop:idlj:iop">
+        <j:set var="pkg.prefix" value="org.apache.geronimo.interop"/>
+        <ant:echo message="Interop :: idlj :: IOP"/>
+        <ant:exec dir="${basedir}" executable="idlj">
+            <ant:arg line="-td"/>
+            <ant:arg line="${maven.build.src}"/>
+            <ant:arg line="-i"/>
+            <ant:arg line="${java.home}/lib"/>
+            <ant:arg line="-i"/>
+            <ant:arg line="${maven.src.dir}/idl"/>
+            <ant:arg line="-verbose"/>
+            <ant:arg line="-pkgPrefix"/>
+            <ant:arg line="IOP"/>
+            <ant:arg line="${pkg.prefix}"/>
+            <ant:arg line="-pkgPrefix"/>
+            <ant:arg line="IIOP"/>
+            <ant:arg line="${pkg.prefix}"/>
+            <ant:arg line="-pkgPrefix"/>
+            <ant:arg line="GIOP"/>
+            <ant:arg line="${pkg.prefix}"/>
+            <ant:arg line="-pkgPrefix"/>
+            <ant:arg line="CosNaming"/>
+            <ant:arg line="${pkg.prefix}"/>
+            <ant:arg line="${maven.src.dir}/idl/IOP.idl"/>
+        </ant:exec>
+    </goal>
+
+    <goal name="interop:idlj:giop">
+        <j:set var="pkg.prefix" value="org.apache.geronimo.interop"/>
+        <ant:echo message="Interop :: idlj :: GIOP"/>
+        <ant:exec dir="${basedir}" executable="idlj">
+            <ant:arg line="-td"/>
+            <ant:arg line="${maven.build.src}"/>
+            <ant:arg line="-i"/>
+            <ant:arg line="${java.home}/lib"/>
+            <ant:arg line="-i"/>
+            <ant:arg line="${maven.src.dir}/idl"/>
+            <ant:arg line="-verbose"/>
+            <ant:arg line="-pkgPrefix"/>
+            <ant:arg line="IOP"/>
+            <ant:arg line="${pkg.prefix}"/>
+            <ant:arg line="-pkgPrefix"/>
+            <ant:arg line="IIOP"/>
+            <ant:arg line="${pkg.prefix}"/>
+            <ant:arg line="-pkgPrefix"/>
+            <ant:arg line="GIOP"/>
+            <ant:arg line="${pkg.prefix}"/>
+            <ant:arg line="-pkgPrefix"/>
+            <ant:arg line="CosNaming"/>
+            <ant:arg line="${pkg.prefix}"/>
+            <ant:arg line="${maven.src.dir}/idl/GIOP.idl"/>
+        </ant:exec>
+    </goal>
+
+    <goal name="interop:idlj:iiop">
+        <j:set var="pkg.prefix" value="org.apache.geronimo.interop"/>
+        <ant:echo message="Interop :: idlj :: IIOP"/>
+        <ant:exec dir="${basedir}" executable="idlj">
+            <ant:arg line="-td"/>
+            <ant:arg line="${maven.build.src}"/>
+            <ant:arg line="-i"/>
+            <ant:arg line="${java.home}/lib"/>
+            <ant:arg line="-i"/>
+            <ant:arg line="${maven.src.dir}/idl"/>
+            <ant:arg line="-verbose"/>
+            <ant:arg line="-pkgPrefix"/>
+            <ant:arg line="IOP"/>
+            <ant:arg line="${pkg.prefix}"/>
+            <ant:arg line="-pkgPrefix"/>
+            <ant:arg line="IIOP"/>
+            <ant:arg line="${pkg.prefix}"/>
+            <ant:arg line="-pkgPrefix"/>
+            <ant:arg line="GIOP"/>
+            <ant:arg line="${pkg.prefix}"/>
+            <ant:arg line="-pkgPrefix"/>
+            <ant:arg line="CosNaming"/>
+            <ant:arg line="${pkg.prefix}"/>
+            <ant:arg line="${maven.src.dir}/idl/IIOP.idl"/>
+        </ant:exec>
+    </goal>
+
+    <goal name="interop:idlj:cosnaming">
+        <j:set var="pkg.prefix" value="org.apache.geronimo.interop"/>
+        <ant:echo message="Interop :: idlj :: CosNaming"/>
+        <ant:exec dir="${basedir}" executable="idlj">
+            <ant:arg line="-td"/>
+            <ant:arg line="${maven.build.src}"/>
+            <ant:arg line="-i"/>
+            <ant:arg line="${java.home}/lib"/>
+            <ant:arg line="-i"/>
+            <ant:arg line="${maven.src.dir}/idl"/>
+            <ant:arg line="-verbose"/>
+            <ant:arg line="-pkgPrefix"/>
+            <ant:arg line="IOP"/>
+            <ant:arg line="${pkg.prefix}"/>
+            <ant:arg line="-pkgPrefix"/>
+            <ant:arg line="IIOP"/>
+            <ant:arg line="${pkg.prefix}"/>
+            <ant:arg line="-pkgPrefix"/>
+            <ant:arg line="GIOP"/>
+            <ant:arg line="${pkg.prefix}"/>
+            <ant:arg line="-pkgPrefix"/>
+            <ant:arg line="CosNaming"/>
+            <ant:arg line="${pkg.prefix}"/>
+            <ant:arg line="${maven.src.dir}/idl/CosNaming.idl"/>
+        </ant:exec>
+    </goal>
+
+    <goal name="interop:idlj:interop-rmi-iiop">
+        <j:set var="pkg.prefix" value="org.apache.geronimo.interop"/>
+        <ant:echo message="Interop :: idlj :: interop-rmi-iiop"/>
+        <ant:exec dir="${basedir}" executable="idlj">
+            <ant:arg line="-td"/>
+            <ant:arg line="${maven.build.src}"/>
+            <ant:arg line="-i"/>
+            <ant:arg line="${java.home}/lib"/>
+            <ant:arg line="-i"/>
+            <ant:arg line="${maven.src.dir}/idl"/>
+            <ant:arg line="-verbose"/>
+            <ant:arg line="-pkgPrefix"/>
+            <ant:arg line="IOP"/>
+            <ant:arg line="${pkg.prefix}"/>
+            <ant:arg line="-pkgPrefix"/>
+            <ant:arg line="IIOP"/>
+            <ant:arg line="${pkg.prefix}"/>
+            <ant:arg line="-pkgPrefix"/>
+            <ant:arg line="GIOP"/>
+            <ant:arg line="${pkg.prefix}"/>
+            <ant:arg line="-pkgPrefix"/>
+            <ant:arg line="CosNaming"/>
+            <ant:arg line="${pkg.prefix}"/>
+            <ant:arg line="${maven.src.dir}/idl/org-apache-geronimo-interop-rmi-iiop.idl"/>
+        </ant:exec>
+    </goal>
+
+    <goal name="interop:idlj:csiv2">
+        <!-- Are there any CSIv2 IDL files that require generation? -->
+        <ant:echo message="Interop :: idlj :: CSIv2"/>
+    </goal>
+
+    <goal name="interop:idlj:costxn">
+        <!-- Are there any CosTransaction IDL files that require generation? -->
+        <ant:echo message="Interop :: idlj :: CosTransactions"/>
+    </goal>
+
+    <goal name="interop:java:compile">
+        <ant:echo message="Interop :: Compile"/>
+        <ant:javac srcdir="${maven.build.src}" destdir="${maven.build.dest}"
+            classpath="${maven.build.dest};${maven.build.src}"/>
+    </goal>
+
+    <goal name="interop:idlj">
+        <attainGoal name="interop:idlj:iop"/>
+        <attainGoal name="interop:idlj:giop"/>
+        <attainGoal name="interop:idlj:iiop"/>
+        <attainGoal name="interop:idlj:cosnaming"/>
+        <attainGoal name="interop:idlj:interop-rmi-iiop"/>
+    </goal>
+
+    <preGoal name="java:compile">
+        <attainGoal name="interop:idlj"/>
+        <attainGoal name="interop:java:compile"/>
+    </preGoal>
+
+</project>

Added: geronimo/trunk/modules/interop/project.properties
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/project.properties?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/project.properties	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,3 @@
+##
+## $Rev: 47137 $ $Date: 2004-09-24 00:04:29 -0700 (Fri, 24 Sep 2004) $
+##

Added: geronimo/trunk/modules/interop/project.xml
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/project.xml?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/project.xml	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+    Copyright 2004-2005 The Apache Software Foundation
+
+    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.
+-->
+
+
+<!-- $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $ -->
+
+<project>
+    <pomVersion>3</pomVersion>
+    <extend>../../etc/project.xml</extend>
+
+    <!-- ===================== -->
+    <!-- Module Identification -->
+    <!-- ===================== -->
+
+    <name>Geronimo :: Interop</name>
+    <id>geronimo-interop</id>
+    <shortDescription>Geronimo Interop</shortDescription>
+    <description>Geronimo Interop</description>
+    <url>http://geronimo.apache.org/modules/interop/</url>
+    <siteDirectory>/www/geronimo.apache.org/modules/interop</siteDirectory>
+    <distributionDirectory>/www/incubator.apache.org/projects/geronimo/builds/interop</distributionDirectory>
+
+    <package>org.apache.geronimo.interop</package>
+
+    <!-- ============ -->
+    <!-- Dependencies -->
+    <!-- ============ -->
+
+    <dependencies>
+        <dependency>
+            <groupId>geronimo</groupId>
+            <artifactId>geronimo-kernel</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>geronimo-spec</groupId>
+            <artifactId>geronimo-spec-ejb</artifactId>
+            <version>${geronimo_spec_ejb_version}</version>
+        </dependency>
+
+        <!-- Thirdparty -->
+
+        <dependency>
+            <groupId>cglib</groupId>
+            <artifactId>cglib-full</artifactId>
+            <version>${cglib_version}</version>
+            <url>http://cglib.sf.net/</url>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+            <version>${commons_logging_version}</version>
+            <url>http://jakarta.apache.org/commons/logging/</url>
+        </dependency>
+
+        <dependency>
+            <groupId>mx4j</groupId>
+            <artifactId>mx4j</artifactId>
+            <version>${mx4j_version}</version>
+        </dependency>
+    </dependencies>
+
+
+    <!-- =================== -->
+    <!-- Build Specification -->
+    <!-- =================== -->
+
+    <build>
+        <unitTest>
+            <includes>
+                <include>**/*Test.java</include>
+            </includes>
+            <excludes>
+                <exclude>**/Abstract*.java</exclude>
+            </excludes>
+            <resources>
+                <resource>
+                    <directory>${basedir}/src/test-resources</directory>
+                </resource>
+            </resources>
+        </unitTest>
+    </build>
+</project>

Added: geronimo/trunk/modules/interop/src/idl/CosNaming.idl
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/idl/CosNaming.idl?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/idl/CosNaming.idl	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,456 @@
+//
+// CosNaming.idl - Naming service interface
+//
+#pragma prefix "omg.org"
+
+/**
+ * The CORBA COS Naming Service provides the ability to bind a name
+ * to an object relative to a naming context. A naming context is an
+ * object that contains a set of name bindings in which each name is unique. 
+ * To resolve a name is to determine the object associated with the name in
+ * a given context. <p>
+ *
+ * See http://www.omg.org/corba/sectrans.htm#nam for the complete CORBA
+ * COS Naming Specification. <p>
+ */
+module CosNaming 
+{
+  typedef string Istring;
+
+  /** 
+   * Many of the operations defined on a naming context take names as
+   * parameters. Names have structure. A name is an ordered sequence of 
+   * components. <p>
+   * 
+   * A name with a single component is called a simple name; a name with
+   * multiple components is called a compound name. Each component except 
+   * the last is used to name a context; the last component denotes the 
+   * bound object. <p>
+   * 
+   * A name component consists of two attributes: the identifier
+   * attribute and the kind attribute. Both the identifier attribute and the 
+   * kind attribute are represented as IDL strings. The kind attribute adds 
+   * descriptive power to names in a syntax-independent way. Examples of the 
+   * value of the kind attribute include c_source, object_code, executable, 
+   * postscript, or " ". 
+   */
+  struct NameComponent 
+  {
+    Istring id;
+    Istring kind;
+  };
+    
+  // A name is a sequence of name components.
+  typedef sequence <NameComponent> Name;
+    
+  /**
+   * Specifies whether the given binding is for a object (that is not a
+   * naming context) or for a naming context.
+   */
+  enum BindingType 
+  {
+    nobject, 	// name is bound to an object
+    ncontext	// name is bound to a naming context
+  };
+    
+  /**
+   * A name-to-object association is called a Binding.
+   */
+  struct Binding 
+  {
+    Name binding_name; 		// name
+    BindingType binding_type;	// whether name is bound to an object
+                                //  or a naming context
+  };
+    
+  typedef sequence <Binding> BindingList;    
+    
+  /**
+   * The BindingIterator interface allows a client to iterate through
+   * the bindings using the next_one or next_n operations.
+   * 
+   * The bindings iterator is obtained by using the <tt>list</tt>
+   * method on the <tt>NamingContext</tt>. 
+   * @see org.omg.CosNaming.NamingContext#list
+   */
+  interface BindingIterator 
+  {
+    /**
+     * This operation returns the next binding. If there are no more
+     * bindings, false is returned.
+     * 
+     * @param b the returned binding
+     */ 
+    boolean next_one(out Binding b);
+    
+    /**
+     * This operation returns at most the requested number of bindings.
+     * 
+     * @param how_many the maximum number of bindings tro return <p>
+     * 
+     * @param bl the returned bindings
+     */ 
+    boolean next_n(in unsigned long how_many, 
+		   out BindingList bl);
+        
+    // Destroy binding iterator
+    /**
+     * This operation destroys the iterator.
+     */ 
+    void destroy();
+  };
+    
+
+  /** 
+   * A naming context is an object that contains a set of name bindings in 
+   * which each name is unique. Different names can be bound to an object 
+   * in the same or different contexts at the same time. <p>
+   * 
+   * See <a href=" http://www.omg.org/corba/sectrans.htm#nam">CORBA COS 
+   * Naming Specification.</a>
+   */
+
+  interface NamingContext 
+  {
+    // Declare exceptions
+    /**
+     * 
+     */
+    enum NotFoundReason 
+    { 
+      missing_node, 
+      not_context, 
+      not_object 
+    };
+        
+    /** 
+     * Indicates the name does not identify a binding.
+     */
+    exception NotFound 
+    { 
+      NotFoundReason why;
+      Name rest_of_name;
+    };
+    
+    /**
+     * Indicates that the implementation has given up for some reason.
+     * The client, however, may be able to continue the operation at the
+     * returned naming context.
+     */
+    exception CannotProceed 
+    {
+      NamingContext cxt;
+      Name rest_of_name;
+    };
+                                         
+    /** 
+     * Indicates the name is invalid. 
+     */
+    exception InvalidName 
+    {};                        
+    
+    /**
+     * Indicates an object is already bound to the specified name. Only
+     * one object can be bound to a particular name in a context. 
+     */
+    exception AlreadyBound 
+    {};
+    
+    /**
+     * Indicates that the Naming Context contains bindings.
+     */
+    exception NotEmpty 
+    {};
+    
+    /**
+     * Creates a binding of a name and an object in the naming context.
+     * Naming contexts that are bound using bind do not participate in name
+     * resolution when compound names are passed to be resolved. 
+     * 
+     * @param n Name of the object <p>
+     * 
+     * @param obj The Object to bind with the given name<p>
+     * 
+     * @exception org.omg.CosNaming.NamingContextPackage.NotFound Indicates the name does not identify a binding.<p>
+     * 
+     * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Indicates that the implementation has
+     * given up for some reason. The client, however, may be able to 
+     * continue the operation at the returned naming context.<p>
+     * 
+     * @exception org.omg.CosNaming.NamingContextPackage.InvalidName Indicates that the name is invalid. <p>
+     *
+     * @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound Indicates an object is already 
+     * bound to the specified name.<p>
+     */ 
+    void bind(in Name n, 
+	      in Object obj)
+      raises(NotFound, 
+	     CannotProceed, 
+	     InvalidName, 
+	     AlreadyBound);
+    
+    /**
+     * Names an object that is a naming context. Naming contexts that
+     * are bound using bind_context() participate in name resolution 
+     * when compound names are passed to be resolved.
+     * 
+     * @param n Name of the object <p>
+     * 
+     * @param nc NamingContect object to bind with the given name <p>
+     * 
+     * @exception org.omg.CosNaming.NamingContextPackage.NotFound Indicates the name does not identify a binding.<p>
+     * 
+     * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Indicates that the implementation has
+     * given up for some reason. The client, however, may be able to 
+     * continue the operation at the returned naming context.<p>
+     * 
+     * @exception org.omg.CosNaming.NamingContextPackage.InvalidName Indicates that the name is invalid. <p>
+     *
+     * @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound Indicates an object is already 
+     * bound to the specified name.<p>
+     */ 
+    void bind_context(in Name n, 
+		      in NamingContext nc)
+      raises(NotFound, 
+	     CannotProceed, 
+	     InvalidName, 
+	     AlreadyBound);
+    
+    /**
+     * Creates a binding of a name and an object in the naming context
+     * even if the name is already bound in the context. Naming contexts 
+     * that are bound using rebind do not participate in name resolution 
+     * when compound names are passed to be resolved.
+     * 
+     * @param  n Name of the object <p>
+     * 
+     * @parm obj The Object to rebind with the given name <p>
+     * 
+     * @exception org.omg.CosNaming.NamingContextPackage.NotFound Indicates the name does not identify a binding.<p>
+     * 
+     * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Indicates that the implementation has
+     * given up for some reason. The client, however, may be able to 
+     * continue the operation at the returned naming context.<p>
+     * 
+     * @exception org.omg.CosNaming.NamingContextPackage.InvalidName Indicates that the name is invalid. <p>
+     */ 
+    void rebind(in Name n, 
+		in Object obj)
+      raises(NotFound, 
+	     CannotProceed, 
+	     InvalidName);
+    
+    /** 
+     * Creates a binding of a name and a naming context in the naming
+     * context even if the name is already bound in the context. Naming 
+     * contexts that are bound using rebind_context() participate in name 
+     * resolution when compound names are passed to be resolved.
+     * 
+     * @param n Name of the object <p>
+     * 
+     * @param nc NamingContect object to rebind with the given name <p>
+     * 
+     * @exception org.omg.CosNaming.NamingContextPackage.NotFound Indicates the name does not identify a binding.<p>
+     * 
+     * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Indicates that the implementation has
+     * given up for some reason. The client, however, may be able to 
+     * continue the operation at the returned naming context.<p>
+     * 
+     * @exception org.omg.CosNaming.NamingContextPackage.InvalidName Indicates that the name is invalid. <p>
+     */ 
+    void rebind_context(in Name n, 
+			in NamingContext nc)
+      raises(NotFound, 
+	     CannotProceed, 
+	     InvalidName);
+
+    /** 
+     * The resolve operation is the process of retrieving an object
+     * bound to a name in a given context. The given name must exactly 
+     * match the bound name. The naming service does not return the type 
+     * of the object. Clients are responsible for "narrowing" the object 
+     * to the appropriate type. That is, clients typically cast the returned 
+     * object from Object to a more specialized interface.
+     * 
+     * @param n Name of the object <p>
+     * 
+     * @exception org.omg.CosNaming.NamingContextPackage.NotFound Indicates the name does not identify a binding.<p>
+     * 
+     * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Indicates that the implementation has
+     * given up for some reason. The client, however, may be able to 
+     * continue the operation at the returned naming context.<p>
+     * 
+     * @exception org.omg.CosNaming.NamingContextPackage.InvalidName Indicates that the name is invalid. <p>
+     */ 
+    Object resolve(in Name n)
+      raises(NotFound, 
+	     CannotProceed, 
+	     InvalidName);
+    
+    /** 
+     * The unbind operation removes a name binding from a context.
+     * 
+     * @param n Name of the object <p>
+     * 
+     * @exception org.omg.CosNaming.NamingContextPackage.NotFound Indicates the name does not identify a binding.<p>
+     * 
+     * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Indicates that the implementation has
+     * given up for some reason. The client, however, may be able to 
+     * continue the operation at the returned naming context.<p>
+     * 
+     * @exception org.omg.CosNaming.NamingContextPackage.InvalidName Indicates that the name is invalid. <p>
+     */ 
+    void unbind(in Name n)
+      raises(NotFound, 
+	     CannotProceed, 
+	     InvalidName);
+    
+    /**
+     * The list operation allows a client to iterate through a set of
+     * bindings in a naming context. <p>
+     * 
+     * The list operation returns at most the requested number of
+     * bindings in BindingList bl. 
+     * <ul>
+     * <li>If the naming context contains additional 
+     * bindings, the list operation returns a BindingIterator with the 
+     * additional bindings. 
+     * <li>If the naming context does not contain additional 
+     * bindings, the binding iterator is a nil object reference.
+     * </ul>
+     * 
+     * @param how_many the maximum number of bindings to return <p>
+     * 
+     * @param bl the returned list of bindings <p>
+     * 
+     * @param bi the returned binding iterator <p>
+     */ 
+    void list(in unsigned long how_many, 
+	      out BindingList bl, 
+	      out BindingIterator bi);
+
+    /**
+     * This operation returns a naming context implemented by the same
+     * naming server as the context on which the operation was invoked. 
+     * The new context is not bound to any name.
+     */ 
+    NamingContext new_context();
+    
+    /**
+     * This operation creates a new context and binds it to the name
+     * supplied as an argument. The newly-created context is implemented 
+     * by the same naming server as the context in which it was bound (that 
+     * is, the naming server that implements the context denoted by the 
+     * name argument excluding the last component).
+     * 
+     * @param n Name of the object <p>
+     * 
+     * @exception org.omg.CosNaming.NamingContextPackage.NotFound Indicates the name does not identify a binding.<p>
+     * 
+     * @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound Indicates an object is already 
+     * bound to the specified name.<p>
+     * 
+     * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Indicates that the implementation has
+     * given up for some reason. The client, however, may be able to 
+     * continue the operation at the returned naming context.<p>
+     * 
+     * @exception org.omg.CosNaming.NamingContextPackage.InvalidName Indicates that the name is invalid. <p>
+     */ 
+    NamingContext bind_new_context(in Name n)
+      raises(NotFound, 
+	     AlreadyBound, 
+	     CannotProceed, 
+	     InvalidName);
+    
+    /**  Not implemented yet!
+    void destroy()
+      raises(NotEmpty);
+     * The destroy operation deletes a naming context. If the naming 
+     * context contains bindings, the NotEmpty exception is raised.
+     * 
+     * @exception org.omg.CosNaming.NamingContextPackage.NotEmpty Indicates that the Naming Context contains bindings.
+     */
+   }; 
+  /**
+   * A naming context extension is an extenrion to naming context that contains a set of name bindings in 
+   * which each name is unique. Different names can be bound to an object 
+   * in the same or different contexts at the same time. <p>
+   * 
+   * See <a href=" http://www.omg.org/corba/sectrans.htm#nam">CORBA COS 
+   * Naming Specification.</a>
+   */
+
+  interface NamingContextExt : CosNaming::NamingContext {
+
+    typedef string StringName;
+    typedef string Address;
+    typedef string URLString;
+
+  /** 
+     * The to_string operation is the process of retrieving a stringified name 
+     * from a name object. 
+     * 
+     * @param n String Name of the object <p>
+     * 
+     * @exception org.omg.CosNaming.NamingContextPackage.InvalidName Indicates that the name is invalid. <p>
+     */ 
+    StringName to_string(in Name n) 
+      raises(
+	NamingContext::InvalidName);
+
+  /** 
+     * The to_name operation is the process of retrieving a name object
+     * to a stringified name. 
+     * 
+     * @param n String Name of the object <p>
+     * 
+     * @exception org.omg.CosNaming.NamingContextPackage.InvalidName Indicates that the name is invalid. <p>
+     */ 
+    Name to_name(in StringName sn)
+      raises(NamingContext::InvalidName);
+
+
+    exception InvalidAddress {};
+
+  /** 
+     * The to_url operation is the process of retrieving a url representation from a stringified name and
+     * address.
+     * 
+     * @param addr Address of the object <p>
+     * 
+     * @param sn String Name of the object <p>
+     * 
+     * @exception org.omg.CosNaming.NamingContextPackage.InvalidName Indicates that the name is invalid. <p>
+     * 
+     * @exception org.omg.CosNaming.NamingContextPackage.InvalidAddress Indicates that the Address is invalid. <p>
+     */
+     URLString to_url(in Address addr, in StringName sn)
+       raises(
+        InvalidAddress, 
+        NamingContext::InvalidName);
+    /** 
+     * The resolve_str operation is the process of retrieving an object
+     * bound to a stringified name in a given context. The given name must exactly 
+     * match the bound name. The naming service does not return the type 
+     * of the object. Clients are responsible for "narrowing" the object 
+     * to the appropriate type. That is, clients typically cast the returned 
+     * object from Object to a more specialized interface.
+     * 
+     * @param n String Name of the object <p>
+     * 
+     * @exception org.omg.CosNaming.NamingContextPackage.NotFound Indicates the name does not identify a binding.<p>
+     * 
+     * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Indicates that the implementation has
+     * given up for some reason. The client, however, may be able to 
+     * continue the operation at the returned naming context.<p>
+     * 
+     * @exception org.omg.CosNaming.NamingContextPackage.InvalidName Indicates that the name is invalid. <p>
+     */ 
+    
+    Object resolve_str(in StringName n)
+      raises(
+         NamingContext::NotFound, 
+         NamingContext::CannotProceed,
+         NamingContext::InvalidName);
+   };
+};

Added: geronimo/trunk/modules/interop/src/idl/GIOP.idl
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/idl/GIOP.idl?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/idl/GIOP.idl	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,239 @@
+// File: GIOP.idl
+// From CORBA 3.0: Chapter 15, General Inter-ORB Protocol
+
+#define _PRE_3_0_COMPILER_ 
+#define GIOP_1_1
+#define GIOP_1_2
+
+#ifndef _GIOP_IDL_
+#define _GIOP_IDL_
+
+#ifdef _PRE_3_0_COMPILER_ 
+#pragma prefix "omg.org"
+#include <IOP.idl>
+#else
+import ::IOP;
+#endif // _PRE_3_0_COMPILER_
+
+module GIOP {                   // IDL extended for version 1.1 and 1.2
+
+#ifndef _PRE_3_0_COMPILER_ 
+    typeprefix GIOP "omg.org";
+#endif // _PRE_3_0_COMPILER_
+
+    struct Version {                            
+        octet           major;
+        octet           minor;
+    };
+
+    // Note: Principal is not used in V1.2 and beyond. However, it must
+    //       be available for V1.0 and V1.1
+    typedef sequence<octet> Principal;
+
+#ifndef GIOP_1_1
+    // GIOP 1.0
+    enum MsgType_1_0{                       // rename from MsgType
+        Request,            Reply,          CancelRequest,
+        LocateRequest,      LocateReply,
+        CloseConnection,    MessageError
+        };
+#else
+    // GIOP 1.1
+    enum MsgType_1_1{
+        Request,            Reply,          CancelRequest,
+        LocateRequest,      LocateReply,
+        CloseConnection,    MessageError,                  
+        Fragment            // GIOP 1.1 addition
+    };
+#endif // GIOP_1_1
+    typedef MsgType_1_1 MsgType_1_2;
+    typedef MsgType_1_1 MsgType_1_3;
+
+    
+    // GIOP 1.0 
+    struct MessageHeader_1_0 {// Renamed from MessageHeader
+        char                        magic [4];
+        Version                     GIOP_version;
+        boolean                     byte_order;         
+        octet                       message_type;
+        unsigned long               message_size;
+    };
+
+    // GIOP 1.1
+    struct MessageHeader_1_1 {
+        char                        magic [4];
+        Version                     GIOP_version;
+        octet                       flags;      // GIOP 1.1 change
+        octet                       message_type;
+        unsigned long               message_size;
+    };
+
+    // GIOP 1.2
+    typedef MessageHeader_1_1 MessageHeader_1_2;
+
+    // GIOP 1.3
+    typedef MessageHeader_1_1 MessageHeader_1_3;                
+
+    // GIOP 1.0
+    struct RequestHeader_1_0 {
+        IOP::ServiceContextList     service_context;
+        unsigned long               request_id;
+        boolean                     response_expected;
+        sequence <octet>            object_key;
+        string                      operation;
+        Principal                   requesting_principal;
+    };
+
+    // GIOP 1.1
+    struct RequestHeader_1_1 {
+        IOP::ServiceContextList     service_context;
+        unsigned long               request_id;
+        boolean                     response_expected;
+        octet                       reserved[3]; // Added in GIOP 1.1
+        sequence <octet>            object_key;
+        string                      operation;
+        Principal                   requesting_principal;
+    };
+
+    // GIOP 1.2
+    typedef short                   AddressingDisposition;
+    const short                     KeyAddr         = 0;
+    const short                     ProfileAddr     = 1;
+    const short                     ReferenceAddr   = 2;
+    struct IORAddressingInfo {
+        unsigned long               selected_profile_index;
+        IOP::IOR                    ior;
+    };
+    union TargetAddress switch (AddressingDisposition) {
+        case KeyAddr:               sequence <octet>    object_key;
+        case ProfileAddr:           IOP::TaggedProfile  profile;
+        case ReferenceAddr:         IORAddressingInfo   ior;
+    };
+    struct RequestHeader_1_2 {
+        unsigned long               request_id;
+        octet                       response_flags;             
+        octet                       reserved[3];
+        TargetAddress               target;
+        string                      operation;
+        // Principal not in GIOP 1.2
+        IOP::ServiceContextList     service_context;    // 1.2 change
+    };
+
+    // GIOP 1.3
+    typedef RequestHeader_1_2 RequestHeader_1_3;
+
+#ifndef GIOP_1_2
+    // GIOP 1.0 and 1.1
+    enum ReplyStatusType_1_0 {// Renamed from ReplyStatusType
+        NO_EXCEPTION,
+        USER_EXCEPTION,
+        SYSTEM_EXCEPTION,
+        LOCATION_FORWARD
+    };
+#endif
+
+    // GIOP 1.2
+    enum ReplyStatusType_1_2 {
+        NO_EXCEPTION,
+        USER_EXCEPTION,
+        SYSTEM_EXCEPTION,
+        LOCATION_FORWARD,
+        LOCATION_FORWARD_PERM,              // new value for 1.2
+        NEEDS_ADDRESSING_MODE               // new value for 1.2
+    };                  
+
+    struct ReplyHeader_1_2 {
+        unsigned long               request_id;
+        ReplyStatusType_1_2         reply_status;
+        IOP::ServiceContextList     service_context;    // 1.2 change
+    };
+
+    // GIOP 1.3
+    typedef ReplyHeader_1_2 ReplyHeader_1_3;
+
+    // GIOP 1.0
+    struct ReplyHeader_1_0 {// Renamed from ReplyHeader
+        IOP::ServiceContextList     service_context;
+        unsigned long               request_id;
+        ReplyStatusType_1_2         reply_status;
+    };
+
+    // GIOP 1.1
+    typedef ReplyHeader_1_0 ReplyHeader_1_1;
+    // Same Header contents for 1.0 and 1.1
+
+    struct SystemExceptionReplyBody {
+        string                      exception_id;
+        unsigned long               minor_code_value;
+        unsigned long               completion_status;
+    };
+
+    struct CancelRequestHeader {
+        unsigned long               request_id;
+    };
+
+    // GIOP 1.0
+    struct LocateRequestHeader_1_0 {// Renamed LocationRequestHeader
+        unsigned long               request_id;
+        sequence <octet>            object_key;
+    };
+
+    // GIOP 1.1
+    typedef LocateRequestHeader_1_0 LocateRequestHeader_1_1;
+    // Same Header contents for 1.0 and 1.1
+
+    // GIOP 1.2
+    struct LocateRequestHeader_1_2 {
+            unsigned long           request_id;
+            TargetAddress           target;
+    };
+
+    // GIOP 1.3
+    typedef LocateRequestHeader_1_2 LocateRequestHeader_1_3;
+
+#ifndef GIOP_1_2
+    // GIOP 1.0 and 1.1
+    enum LocateStatusType_1_0 {// Renamed from LocateStatusType
+            UNKNOWN_OBJECT,
+            OBJECT_HERE,
+            OBJECT_FORWARD
+    };
+#endif
+
+    // GIOP 1.2
+    enum LocateStatusType_1_2 {
+            UNKNOWN_OBJECT,
+            OBJECT_HERE,
+            OBJECT_FORWARD,
+            OBJECT_FORWARD_PERM,        // new value for GIOP 1.2
+            LOC_SYSTEM_EXCEPTION,       // new value for GIOP 1.2
+            LOC_NEEDS_ADDRESSING_MODE   // new value for GIOP 1.2
+    };
+    struct LocateReplyHeader_1_2 {
+        unsigned long               request_id;
+        LocateStatusType_1_2        locate_status;
+    };
+
+    // GIOP 1.3
+    typedef LocateReplyHeader_1_2 LocateReplyHeader_1_3;
+
+    // GIOP 1.0
+    struct LocateReplyHeader_1_0 {// Renamed from LocateReplyHeader
+            unsigned long           request_id;
+            LocateStatusType_1_2    locate_status;
+    };
+
+    // GIOP 1.1
+    typedef LocateReplyHeader_1_0 LocateReplyHeader_1_1;
+    // same Header contents for 1.0 and 1.1
+
+    // GIOP 1.2
+    struct FragmentHeader_1_2 {
+        unsigned long               request_id;
+    };
+
+    // GIOP 1.3
+    typedef FragmentHeader_1_2 FragmentHeader_1_3;
+
+};
+#endif // _GIOP_IDL_

Added: geronimo/trunk/modules/interop/src/idl/IIOP.idl
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/idl/IIOP.idl?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/idl/IIOP.idl	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,53 @@
+// File: IIOP.idl
+// From CORBA 3.0: Chapter 15, General Inter-ORB Protocol
+
+#define _PRE_3_0_COMPILER_ 
+
+#ifndef _IIOP_IDL_
+#define _IIOP_IDL_
+
+#ifdef _PRE_3_0_COMPILER_ 
+#pragma prefix "omg.org"
+#include <IOP.idl>
+#else
+import ::IOP;
+#endif // _PRE_3_0_COMPILER_
+
+module IIOP {       // IDL extended for version 1.1 and 1.2
+
+#ifndef _PRE_3_0_COMPILER_ 
+    typeprefix IIOP "omg.org";
+#endif // _PRE_3_0_COMPILER_
+
+    struct Version {
+        octet               major;
+        octet               minor;
+    };
+    struct ProfileBody_1_0 {// renamed from ProfileBody
+        Version             iiop_version;
+        string              host;
+        unsigned short      port;
+        sequence <octet>    object_key;
+    };
+    struct ProfileBody_1_1 {// also used for 1.2
+        Version             iiop_version;
+        string              host;
+        unsigned short      port;
+        sequence <octet>    object_key;
+        // Added in 1.1 unchanged for 1.2
+        sequence <IOP::TaggedComponent> components; 
+    };              
+
+    // BiDirectional IIOP
+
+    struct ListenPoint {
+        string              host;
+        unsigned short      port;
+    };
+    typedef sequence<ListenPoint> ListenPointList;
+    struct BiDirIIOPServiceContext {// BI_DIR_IIOP Service Context
+        ListenPointList listen_points;
+    };
+};
+#endif // _IIOP_IDL_
+

Added: geronimo/trunk/modules/interop/src/idl/IOP.idl
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/idl/IOP.idl?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/idl/IOP.idl	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,175 @@
+// File: IOP.idl
+// From CORBA 3.0: Chapter 13, ORB Interoperability Achitecture
+
+#define _PRE_3_0_COMPILER_ 
+
+#ifndef _IOP_IDL_
+#define _IOP_IDL_
+
+#ifdef _PRE_3_0_COMPILER_ 
+#pragma prefix "omg.org"
+
+// #include <orb.idl>
+#else
+import ::CORBA;
+#endif // _PRE_3_0_COMPILER_
+
+module IOP {
+
+#ifndef _PRE_3_0_COMPILER_ 
+    typeprefix IOP "omg.org";
+#endif // _PRE_3_0_COMPILER_
+
+    // IOR Profiles
+
+    // Standard Protocol Profile tag values 
+    typedef unsigned long           ProfileId;
+    const ProfileId                 TAG_INTERNET_IOP = 0;
+    const ProfileId                 TAG_MULTIPLE_COMPONENTS = 1;
+    const ProfileId                 TAG_SCCP_IOP = 2;
+
+    struct TaggedProfile {
+        ProfileId                   tag;
+        sequence <octet>            profile_data;
+    };
+    
+   
+    // The IOR
+
+    // an Interoperable Object Reference is a sequence of
+    // object-specific protocol profiles, plus a type ID.
+    struct IOR {
+        string                      type_id;
+        sequence <TaggedProfile>    profiles;
+    };
+    
+
+    // IOR Components
+
+
+    // Standard way of representing multicomponent profiles.
+    // This would be encapsulated in a TaggedProfile.
+
+    typedef unsigned long ComponentId;
+
+    struct TaggedComponent {
+        ComponentId                 tag;
+        sequence <octet>            component_data;
+    };
+
+    typedef sequence <TaggedComponent> MultipleComponentProfile;
+
+    const ComponentId           TAG_ORB_TYPE                = 0;
+    const ComponentId           TAG_CODE_SETS               = 1;
+    const ComponentId           TAG_POLICIES                = 2;   
+    const ComponentId           TAG_ALTERNATE_IIOP_ADDRESS  = 3;
+    const ComponentId           TAG_ASSOCIATION_OPTIONS     = 13;
+    const ComponentId           TAG_SEC_NAME                = 14;
+    const ComponentId           TAG_SPKM_1_SEC_MECH         = 15;
+    const ComponentId           TAG_SPKM_2_SEC_MECH         = 16;
+    const ComponentId           TAG_KerberosV5_SEC_MECH     = 17;
+    const ComponentId           TAG_CSI_ECMA_Secret_SEC_MECH= 18;
+    const ComponentId           TAG_CSI_ECMA_Hybrid_SEC_MECH= 19;
+    const ComponentId           TAG_SSL_SEC_TRANS           = 20;
+    const ComponentId           TAG_CSI_ECMA_Public_SEC_MECH= 21;
+    const ComponentId           TAG_GENERIC_SEC_MECH        = 22;
+    const ComponentId           TAG_FIREWALL_TRANS          = 23; 
+    const ComponentId           TAG_SCCP_CONTACT_INFO       = 24; 
+    const ComponentId           TAG_JAVA_CODEBASE           = 25;
+
+    const ComponentId           TAG_TRANSACTION_POLICY      = 26;
+    const ComponentId           TAG_MESSAGE_ROUTER          = 30;
+    const ComponentId           TAG_OTS_POLICY              = 31;
+    const ComponentId           TAG_INV_POLICY              = 32;
+
+    const ComponentId           TAG_CSI_SEC_MECH_LIST       = 33;
+    const ComponentId           TAG_NULL_TAG                = 34;
+    const ComponentId           TAG_SECIOP_SEC_TRANS        = 35;
+
+    const ComponentId           TAG_TLS_SEC_TRANS           = 36;
+
+    const ComponentId           TAG_ACTIVITY_POLICY         = 37;
+ 
+
+    const ComponentId           TAG_COMPLETE_OBJECT_KEY     = 5;
+    const ComponentId           TAG_ENDPOINT_ID_POSITION    = 6;
+    const ComponentId           TAG_LOCATION_POLICY         = 12;
+    const ComponentId           TAG_DCE_STRING_BINDING      = 100;
+    const ComponentId           TAG_DCE_BINDING_NAME        = 101;
+    const ComponentId           TAG_DCE_NO_PIPES            = 102;
+
+    const ComponentId           TAG_DCE_SEC_MECH            = 103;
+
+    const ComponentId           TAG_INET_SEC_TRANS          = 123;
+
+    // Service Contexts
+
+    typedef unsigned long       ServiceId;
+    struct ServiceContext {
+        ServiceId               context_id;
+        sequence <octet>        context_data;
+    };
+    typedef sequence <ServiceContext> ServiceContextList;
+    const ServiceId             TransactionService          = 0;
+    const ServiceId             CodeSets                    = 1;
+    const ServiceId             ChainBypassCheck            = 2;
+    const ServiceId             ChainBypassInfo             = 3;
+    const ServiceId             LogicalThreadId             = 4;
+    const ServiceId             BI_DIR_IIOP                 = 5;
+    const ServiceId             SendingContextRunTime       = 6;
+    const ServiceId             INVOCATION_POLICIES         = 7;
+    const ServiceId             FORWARDED_IDENTITY          = 8;
+    const ServiceId             UnknownExceptionInfo        = 9;
+    const ServiceId             RTCorbaPriority             = 10;
+    const ServiceId             RTCorbaPriorityRange        = 11;
+    const ServiceId             FT_GROUP_VERSION            = 12;
+    const ServiceId             FT_REQUEST                  = 13;
+    const ServiceId             ExceptionDetailMessage      = 14;
+    const ServiceId             SecurityAttributeService    = 15;
+    const ServiceId             ActivityService             = 16;
+
+    /*
+    
+    // Coder Decoder from Portable Interceptor
+
+    local interface Codec {
+        exception InvalidTypeForEncoding {};
+        exception FormatMismatch {};
+        exception TypeMismatch {};
+
+        CORBA::OctetSeq encode (in any data)
+            raises (InvalidTypeForEncoding);
+        any decode (in CORBA::OctetSeq data)
+            raises (FormatMismatch);
+        CORBA::OctetSeq encode_value (in any data)
+            raises (InvalidTypeForEncoding);
+        any decode_value (
+            in CORBA::OctetSeq data,
+            in CORBA::TypeCode tc)
+            raises (FormatMismatch, TypeMismatch);
+    };
+
+    // Codec Factory
+
+    typedef short EncodingFormat;
+    const EncodingFormat ENCODING_CDR_ENCAPS = 0;
+
+    struct Encoding {
+        EncodingFormat format;
+        octet major_version;
+        octet minor_version;
+    };
+
+    local interface CodecFactory {
+        exception UnknownEncoding {};
+        Codec create_codec (in Encoding enc)
+            raises (UnknownEncoding);
+    };
+    
+    */
+};
+
+// #include <IOP_DCE.idl>
+
+#endif  // _IOP_IDL_
+

Added: geronimo/trunk/modules/interop/src/idl/Readme.txt
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/idl/Readme.txt?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/idl/Readme.txt	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,45 @@
+These files have been adapted from the Corba 3.0 specs.  New CORBA 3.0
+interfaces and types have been commented out to provide the same functionality
+as in 2.3.1.
+
+Note, these files are being used for protocol marshalling (helpers and holders)
+
+echo on
+
+rem
+rem To use this in intellij:
+rem
+rem 1. Add an external tool called idlj
+rem    program: $JDKPath$/bin/idlj.exe
+rem    parameters: -i $JDKPath$/lib -verbose -pkgPrefix IOP org.apache.geronimo.gcc.org.omg -pkgPrefix GIOP org.apache.geronimo.gcc.org.omg -pkgPrefix IIOP org.apache.geronimo.gcc.org.omg -pkgPrefix CosNaming org.apache.geronimo.gcc.org.omg -td $ProjectFileDir$/genfiles/src $FileName$
+rem    working directory: $ProjectFileDir$\idl
+rem
+rem 2. You can right click on the .idl file and choose idlj to build it.
+rem
+
+rem
+rem This is the good version of the CORBA stubs/skels
+rem these files get copied into the d:\org.apache.geronimo.gcc\work\geronimo\corba_container\src
+rem
+
+setlocal
+
+set pkgprefix=org.apache.geronimo.gcc.org.omg
+
+set opts=
+set opts=-i %java_home%\lib
+set opts=%opts% -verbose
+set opts=%opts% -pkgPrefix IOP %pkgprefix%
+set opts=%opts% -pkgPrefix GIOP %pkgprefix%
+set opts=%opts% -pkgPrefix IIOP %pkgprefix%
+set opts=%opts% -pkgPrefix CosNaming %pkgprefix%
+
+
+idlj -td gen %opts% IOP.idl
+idlj -td gen %opts% GIOP.idl
+idlj -td gen %opts% IIOP.idl
+idlj -td gen %opts% CosNaming.idl
+
+idlj -td gen %opts% org.apache.geronimo.gcc-rmi-iiop.idl
+
+endlocal

Added: geronimo/trunk/modules/interop/src/idl/org-apache-geronimo-interop-rmi-iiop.idl
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/idl/org-apache-geronimo-interop-rmi-iiop.idl?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/idl/org-apache-geronimo-interop-rmi-iiop.idl	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,30 @@
+
+#include "CosNaming.idl"
+
+/* 
+ * resolve_host is a custom API that lets the name service send back a logical hostname for
+ * a component, which then can be resolved by the server for clustering and loadbalancing
+ */
+
+module org
+{
+    module apache
+    {
+        module geronimo
+        {
+            module interop
+            {
+                module rmi
+                {
+                    module iiop
+                    {
+                        interface NameService : ::CosNaming::NamingContextExt
+                        {
+                            string resolve_host(in string host);
+                        };
+                    };
+                };
+            };
+        };
+    };
+};

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/CheckedException.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/CheckedException.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/CheckedException.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,30 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop;
+
+
+
+
+/**
+ * * A wrapper that allows checked exceptions to be thrown as unchecked.
+ */
+public class CheckedException extends RuntimeException {
+    public CheckedException(Throwable cause) {
+        super(cause);
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/CosNaming/iiop_stubs/NamingContext_Stub.1.txt
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/CosNaming/iiop_stubs/NamingContext_Stub.1.txt?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/CosNaming/iiop_stubs/NamingContext_Stub.1.txt	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,465 @@
+
+package org.apache.geronimo.interop.CosNaming.iiop_stubs;
+
+import org.apache.geronimo.interop.rmi.iiop.ObjectRef;
+
+public class NamingContext_Stub
+    extends ObjectRef
+    implements org.apache.geronimo.interop.CosNaming.NamingContext
+{
+    // 
+    // Fields
+    // 
+    public java.lang.String[] _ids = { "org.apache.geronimo.interop.CosNaming.NamingContext", "RMI:org.apache.geronimo.interop.CosNaming.NamingContext:0000000000000000"};
+    private static final org.apache.geronimo.interop.rmi.iiop.ValueType vt$0 = org.apache.geronimo.interop.rmi.iiop.ValueType.getInstance(java.lang.String.class);
+    private static final org.apache.geronimo.interop.rmi.iiop.ValueType vt$1 = org.apache.geronimo.interop.rmi.iiop.ValueType.getInstance(org.apache.geronimo.interop.CosNaming.NameComponent[].class);
+    private static final org.apache.geronimo.interop.rmi.iiop.ValueType vt$2 = org.apache.geronimo.interop.rmi.iiop.ValueType.getInstance(org.omg.CORBA.Object.class);
+    private static final org.apache.geronimo.interop.rmi.iiop.ValueType vt$3 = org.apache.geronimo.interop.rmi.iiop.ValueType.getInstance(org.apache.geronimo.interop.CosNaming.NamingContextPackage.NotFound.class);
+    private static final org.apache.geronimo.interop.rmi.iiop.ValueType vt$4 = org.apache.geronimo.interop.rmi.iiop.ValueType.getInstance(org.apache.geronimo.interop.CosNaming.NamingContextPackage.CannotProceed.class);
+    private static final org.apache.geronimo.interop.rmi.iiop.ValueType vt$5 = org.apache.geronimo.interop.rmi.iiop.ValueType.getInstance(org.apache.geronimo.interop.CosNaming.NamingContextPackage.InvalidName.class);
+    private static final org.apache.geronimo.interop.rmi.iiop.ValueType vt$6 = org.apache.geronimo.interop.rmi.iiop.ValueType.getInstance(org.apache.geronimo.interop.CosNaming.NamingContextPackage.AlreadyBound.class);
+    private static final org.apache.geronimo.interop.rmi.iiop.ValueType vt$7 = org.apache.geronimo.interop.rmi.iiop.ValueType.getInstance(org.apache.geronimo.interop.CosNaming.NamingContext.class);
+    private static final org.apache.geronimo.interop.rmi.iiop.ValueType vt$8 = org.apache.geronimo.interop.rmi.iiop.ValueType.getInstance(org.apache.geronimo.interop.CosNaming.Binding[].class);
+    private static final org.apache.geronimo.interop.rmi.iiop.ValueType vt$9 = org.apache.geronimo.interop.rmi.iiop.ValueType.getInstance(org.apache.geronimo.interop.CosNaming.BindingIterator.class);
+
+    // 
+    // Constructors
+    // 
+    public NamingContext_Stub( )
+    {
+        super();
+    }
+    
+    // 
+    // Methods
+    // 
+    
+    public boolean _is_a( java.lang.String id )
+    {
+        java.lang.Object $key = $getRequestKey();
+        int $retry;
+        
+        for ($retry = 0
+        ; ; $retry++
+        )
+        {
+            
+            try
+            {
+                org.apache.geronimo.interop.rmi.iiop.client.Connection $conn;
+                org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream $out;
+                java.lang.String $et;
+                boolean $rc;
+                org.apache.geronimo.interop.rmi.iiop.ObjectInputStream $in;
+                $conn = this.$connect();
+                $out = $conn.getSimpleOutputStream();
+                $out.writeObject( vt$0, id);
+                $conn.invoke(this, "_is_a", $key, $retry);
+                $in = $conn.getSimpleInputStream();
+                $conn.forget($key);
+                $conn.close();
+                $et = $conn.getExceptionType();
+
+                if ($et != null)
+                {
+                    throw org.apache.geronimo.interop.rmi.iiop.SystemExceptionFactory.getException($conn.getException());
+                }
+                $rc = $in.readBoolean();
+                return $rc;
+            }
+            catch( org.apache.geronimo.interop.rmi.iiop.client.RetryInvokeException $ex )
+            {
+                if ($retry == 3)
+                {
+                    throw $ex.getRuntimeException();
+                }
+            }
+        }
+    }
+    
+    public void list( int p1, org.apache.geronimo.interop.CosNaming.BindingListHolder p2, org.apache.geronimo.interop.CosNaming.BindingIteratorHolder p3 )
+    {
+        java.lang.Object $key = $getRequestKey();
+        for (int $retry = 0; ; $retry++)
+        {
+            try
+            {
+                org.apache.geronimo.interop.rmi.iiop.client.Connection $connection_2 = this.$connect();
+                org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream $output_3 = $connection_2.getSimpleOutputStream();
+                $output_3.writeInt(p1);
+                $output_3.writeObject(vt$9, p2.value);
+                $output_3.writeObject(vt$10, p3.value);
+                $connection_2.invoke(this, "list", $key, $retry);
+                org.apache.geronimo.interop.rmi.iiop.ObjectInputStream $input_4 = $connection_2.getSimpleInputStream();
+                $connection_2.forget($key);
+                $connection_2.close();
+                java.lang.String $et_5 = $connection_2.getExceptionType();
+                if ($et_5 != null)
+                {
+                    throw org.apache.geronimo.interop.rmi.iiop.SystemExceptionFactory.getException($connection_2.getException());
+                }
+                return;
+            }
+            catch (org.apache.geronimo.interop.rmi.iiop.client.RetryInvokeException $ex_6)
+            {
+                if ($retry == 3)
+                {
+                    throw $ex_6.getRuntimeException();
+                }
+            }
+        }
+    }
+
+    public void bind(org.apache.geronimo.interop.CosNaming.NameComponent[] p1, org.omg.CORBA.Object p2) throws org.apache.geronimo.interop.CosNaming.NamingContextPackage.NotFound, org.apache.geronimo.interop.CosNaming.NamingContextPackage.CannotProceed, org.apache.geronimo.interop.CosNaming.NamingContextPackage.InvalidName, org.apache.geronimo.interop.CosNaming.NamingContextPackage.AlreadyBound
+    {
+        java.lang.Object $key = $getRequestKey();
+        for (int $retry = 0; ; $retry++)
+        {
+            try
+            {
+                org.apache.geronimo.interop.rmi.iiop.client.Connection $connection_2 = this.$connect();
+                org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream $output_3 = $connection_2.getSimpleOutputStream();
+                $output_3.writeObject(vt$2, p1);
+                $output_3.writeObject(vt$3, p2);
+                $connection_2.invoke(this, "bind", $key, $retry);
+                org.apache.geronimo.interop.rmi.iiop.ObjectInputStream $input_4 = $connection_2.getSimpleInputStream();
+                $connection_2.forget($key);
+                $connection_2.close();
+                java.lang.String $et_5 = $connection_2.getExceptionType();
+                if ($et_5 != null)
+                {
+                    if ($et_5.equals("org.apache.geronimo.interop.CosNaming.NamingContextPackage.NotFound"))
+                    {
+                        throw (org.apache.geronimo.interop.CosNaming.NamingContextPackage.NotFound)$input_4.readException(vt$4);
+                    }
+                    if ($et_5.equals("org.apache.geronimo.interop.CosNaming.NamingContextPackage.CannotProceed"))
+                    {
+                        throw (org.apache.geronimo.interop.CosNaming.NamingContextPackage.CannotProceed)$input_4.readException(vt$5);
+                    }
+                    if ($et_5.equals("org.apache.geronimo.interop.CosNaming.NamingContextPackage.InvalidName"))
+                    {
+                        throw (org.apache.geronimo.interop.CosNaming.NamingContextPackage.InvalidName)$input_4.readException(vt$6);
+                    }
+                    if ($et_5.equals("org.apache.geronimo.interop.CosNaming.NamingContextPackage.AlreadyBound"))
+                    {
+                        throw (org.apache.geronimo.interop.CosNaming.NamingContextPackage.AlreadyBound)$input_4.readException(vt$7);
+                    }
+                    throw org.apache.geronimo.interop.rmi.iiop.SystemExceptionFactory.getException($connection_2.getException());
+                }
+                return;
+            }
+            catch (org.apache.geronimo.interop.rmi.iiop.client.RetryInvokeException $ex_6)
+            {
+                if ($retry == 3)
+                {
+                    throw $ex_6.getRuntimeException();
+                }
+            }
+        }
+    }
+
+    public void bind_context(org.apache.geronimo.interop.CosNaming.NameComponent[] p1, org.apache.geronimo.interop.CosNaming.NamingContext p2) throws org.apache.geronimo.interop.CosNaming.NamingContextPackage.NotFound, org.apache.geronimo.interop.CosNaming.NamingContextPackage.CannotProceed, org.apache.geronimo.interop.CosNaming.NamingContextPackage.InvalidName, org.apache.geronimo.interop.CosNaming.NamingContextPackage.AlreadyBound
+    {
+        java.lang.Object $key = $getRequestKey();
+        for (int $retry = 0; ; $retry++)
+        {
+            try
+            {
+                org.apache.geronimo.interop.rmi.iiop.client.Connection $connection_2 = this.$connect();
+                org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream $output_3 = $connection_2.getSimpleOutputStream();
+                $output_3.writeObject(vt$2, p1);
+                $output_3.writeObject(vt$8, p2);
+                $connection_2.invoke(this, "bind_context", $key, $retry);
+                org.apache.geronimo.interop.rmi.iiop.ObjectInputStream $input_4 = $connection_2.getSimpleInputStream();
+                $connection_2.forget($key);
+                $connection_2.close();
+                java.lang.String $et_5 = $connection_2.getExceptionType();
+                if ($et_5 != null)
+                {
+                    if ($et_5.equals("org.apache.geronimo.interop.CosNaming.NamingContextPackage.NotFound"))
+                    {
+                        throw (org.apache.geronimo.interop.CosNaming.NamingContextPackage.NotFound)$input_4.readException(vt$4);
+                    }
+                    if ($et_5.equals("org.apache.geronimo.interop.CosNaming.NamingContextPackage.CannotProceed"))
+                    {
+                        throw (org.apache.geronimo.interop.CosNaming.NamingContextPackage.CannotProceed)$input_4.readException(vt$5);
+                    }
+                    if ($et_5.equals("org.apache.geronimo.interop.CosNaming.NamingContextPackage.InvalidName"))
+                    {
+                        throw (org.apache.geronimo.interop.CosNaming.NamingContextPackage.InvalidName)$input_4.readException(vt$6);
+                    }
+                    if ($et_5.equals("org.apache.geronimo.interop.CosNaming.NamingContextPackage.AlreadyBound"))
+                    {
+                        throw (org.apache.geronimo.interop.CosNaming.NamingContextPackage.AlreadyBound)$input_4.readException(vt$7);
+                    }
+                    throw org.apache.geronimo.interop.rmi.iiop.SystemExceptionFactory.getException($connection_2.getException());
+                }
+                return;
+            }
+            catch (org.apache.geronimo.interop.rmi.iiop.client.RetryInvokeException $ex_6)
+            {
+                if ($retry == 3)
+                {
+                    throw $ex_6.getRuntimeException();
+                }
+            }
+        }
+    }
+
+    public org.apache.geronimo.interop.CosNaming.NamingContext bind_new_context(org.apache.geronimo.interop.CosNaming.NameComponent[] p1) throws org.apache.geronimo.interop.CosNaming.NamingContextPackage.NotFound, org.apache.geronimo.interop.CosNaming.NamingContextPackage.AlreadyBound, org.apache.geronimo.interop.CosNaming.NamingContextPackage.CannotProceed, org.apache.geronimo.interop.CosNaming.NamingContextPackage.InvalidName
+    {
+        java.lang.Object $key = $getRequestKey();
+        for (int $retry = 0; ; $retry++)
+        {
+            try
+            {
+                org.apache.geronimo.interop.rmi.iiop.client.Connection $connection_2 = this.$connect();
+                org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream $output_3 = $connection_2.getSimpleOutputStream();
+                $output_3.writeObject(vt$2, p1);
+                $connection_2.invoke(this, "bind_new_context", $key, $retry);
+                org.apache.geronimo.interop.rmi.iiop.ObjectInputStream $input_4 = $connection_2.getSimpleInputStream();
+                $connection_2.forget($key);
+                $connection_2.close();
+                java.lang.String $et_5 = $connection_2.getExceptionType();
+                if ($et_5 != null)
+                {
+                    if ($et_5.equals("org.apache.geronimo.interop.CosNaming.NamingContextPackage.NotFound"))
+                    {
+                        throw (org.apache.geronimo.interop.CosNaming.NamingContextPackage.NotFound)$input_4.readException(vt$4);
+                    }
+                    if ($et_5.equals("org.apache.geronimo.interop.CosNaming.NamingContextPackage.AlreadyBound"))
+                    {
+                        throw (org.apache.geronimo.interop.CosNaming.NamingContextPackage.AlreadyBound)$input_4.readException(vt$7);
+                    }
+                    if ($et_5.equals("org.apache.geronimo.interop.CosNaming.NamingContextPackage.CannotProceed"))
+                    {
+                        throw (org.apache.geronimo.interop.CosNaming.NamingContextPackage.CannotProceed)$input_4.readException(vt$5);
+                    }
+                    if ($et_5.equals("org.apache.geronimo.interop.CosNaming.NamingContextPackage.InvalidName"))
+                    {
+                        throw (org.apache.geronimo.interop.CosNaming.NamingContextPackage.InvalidName)$input_4.readException(vt$6);
+                    }
+                    throw org.apache.geronimo.interop.rmi.iiop.SystemExceptionFactory.getException($connection_2.getException());
+                }
+                org.apache.geronimo.interop.CosNaming.NamingContext $djc_result;
+                $djc_result = (org.apache.geronimo.interop.CosNaming.NamingContext)$input_4.readObject(vt$8);
+                return $djc_result;
+            }
+            catch (org.apache.geronimo.interop.rmi.iiop.client.RetryInvokeException $ex_6)
+            {
+                if ($retry == 3)
+                {
+                    throw $ex_6.getRuntimeException();
+                }
+            }
+        }
+    }
+
+
+    public org.apache.geronimo.interop.CosNaming.NamingContext new_context()
+    {
+        java.lang.Object $key = $getRequestKey();
+        for (int $retry = 0; ; $retry++)
+        {
+            try
+            {
+                org.apache.geronimo.interop.rmi.iiop.client.Connection $connection_2 = this.$connect();
+                $connection_2.invoke(this, "new_context", $key, $retry);
+                org.apache.geronimo.interop.rmi.iiop.ObjectInputStream $input_3 = $connection_2.getSimpleInputStream();
+                $connection_2.forget($key);
+                $connection_2.close();
+                java.lang.String $et_4 = $connection_2.getExceptionType();
+                if ($et_4 != null)
+                {
+                    throw org.apache.geronimo.interop.rmi.iiop.SystemExceptionFactory.getException($connection_2.getException());
+                }
+                org.apache.geronimo.interop.CosNaming.NamingContext $djc_result;
+                $djc_result = (org.apache.geronimo.interop.CosNaming.NamingContext)$input_3.readObject(vt$8);
+                return $djc_result;
+            }
+            catch (org.apache.geronimo.interop.rmi.iiop.client.RetryInvokeException $ex_5)
+            {
+                if ($retry == 3)
+                {
+                    throw $ex_5.getRuntimeException();
+                }
+            }
+        }
+    }
+
+    public void rebind(org.apache.geronimo.interop.CosNaming.NameComponent[] p1, org.omg.CORBA.Object p2) throws org.apache.geronimo.interop.CosNaming.NamingContextPackage.NotFound, org.apache.geronimo.interop.CosNaming.NamingContextPackage.CannotProceed, org.apache.geronimo.interop.CosNaming.NamingContextPackage.InvalidName
+    {
+        java.lang.Object $key = $getRequestKey();
+        for (int $retry = 0; ; $retry++)
+        {
+            try
+            {
+                org.apache.geronimo.interop.rmi.iiop.client.Connection $connection_2 = this.$connect();
+                org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream $output_3 = $connection_2.getSimpleOutputStream();
+                $output_3.writeObject(vt$2, p1);
+                $output_3.writeObject(vt$3, p2);
+                $connection_2.invoke(this, "rebind", $key, $retry);
+                org.apache.geronimo.interop.rmi.iiop.ObjectInputStream $input_4 = $connection_2.getSimpleInputStream();
+                $connection_2.forget($key);
+                $connection_2.close();
+                java.lang.String $et_5 = $connection_2.getExceptionType();
+                if ($et_5 != null)
+                {
+                    if ($et_5.equals("org.apache.geronimo.interop.CosNaming.NamingContextPackage.NotFound"))
+                    {
+                        throw (org.apache.geronimo.interop.CosNaming.NamingContextPackage.NotFound)$input_4.readException(vt$4);
+                    }
+                    if ($et_5.equals("org.apache.geronimo.interop.CosNaming.NamingContextPackage.CannotProceed"))
+                    {
+                        throw (org.apache.geronimo.interop.CosNaming.NamingContextPackage.CannotProceed)$input_4.readException(vt$5);
+                    }
+                    if ($et_5.equals("org.apache.geronimo.interop.CosNaming.NamingContextPackage.InvalidName"))
+                    {
+                        throw (org.apache.geronimo.interop.CosNaming.NamingContextPackage.InvalidName)$input_4.readException(vt$6);
+                    }
+                    throw org.apache.geronimo.interop.rmi.iiop.SystemExceptionFactory.getException($connection_2.getException());
+                }
+                return;
+            }
+            catch (org.apache.geronimo.interop.rmi.iiop.client.RetryInvokeException $ex_6)
+            {
+                if ($retry == 3)
+                {
+                    throw $ex_6.getRuntimeException();
+                }
+            }
+        }
+    }
+
+    public void rebind_context(org.apache.geronimo.interop.CosNaming.NameComponent[] p1, org.apache.geronimo.interop.CosNaming.NamingContext p2) throws org.apache.geronimo.interop.CosNaming.NamingContextPackage.NotFound, org.apache.geronimo.interop.CosNaming.NamingContextPackage.CannotProceed, org.apache.geronimo.interop.CosNaming.NamingContextPackage.InvalidName
+    {
+        java.lang.Object $key = $getRequestKey();
+        for (int $retry = 0; ; $retry++)
+        {
+            try
+            {
+                org.apache.geronimo.interop.rmi.iiop.client.Connection $connection_2 = this.$connect();
+                org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream $output_3 = $connection_2.getSimpleOutputStream();
+                $output_3.writeObject(vt$2, p1);
+                $output_3.writeObject(vt$8, p2);
+                $connection_2.invoke(this, "rebind_context", $key, $retry);
+                org.apache.geronimo.interop.rmi.iiop.ObjectInputStream $input_4 = $connection_2.getSimpleInputStream();
+                $connection_2.forget($key);
+                $connection_2.close();
+                java.lang.String $et_5 = $connection_2.getExceptionType();
+                if ($et_5 != null)
+                {
+                    if ($et_5.equals("org.apache.geronimo.interop.CosNaming.NamingContextPackage.NotFound"))
+                    {
+                        throw (org.apache.geronimo.interop.CosNaming.NamingContextPackage.NotFound)$input_4.readException(vt$4);
+                    }
+                    if ($et_5.equals("org.apache.geronimo.interop.CosNaming.NamingContextPackage.CannotProceed"))
+                    {
+                        throw (org.apache.geronimo.interop.CosNaming.NamingContextPackage.CannotProceed)$input_4.readException(vt$5);
+                    }
+                    if ($et_5.equals("org.apache.geronimo.interop.CosNaming.NamingContextPackage.InvalidName"))
+                    {
+                        throw (org.apache.geronimo.interop.CosNaming.NamingContextPackage.InvalidName)$input_4.readException(vt$6);
+                    }
+                    throw org.apache.geronimo.interop.rmi.iiop.SystemExceptionFactory.getException($connection_2.getException());
+                }
+                return;
+            }
+            catch (org.apache.geronimo.interop.rmi.iiop.client.RetryInvokeException $ex_6)
+            {
+                if ($retry == 3)
+                {
+                    throw $ex_6.getRuntimeException();
+                }
+            }
+        }
+    }
+
+    public org.omg.CORBA.Object resolve(org.apache.geronimo.interop.CosNaming.NameComponent[] p1) throws org.apache.geronimo.interop.CosNaming.NamingContextPackage.NotFound, org.apache.geronimo.interop.CosNaming.NamingContextPackage.CannotProceed, org.apache.geronimo.interop.CosNaming.NamingContextPackage.InvalidName
+    {
+        java.lang.Object $key = $getRequestKey();
+        for (int $retry = 0; ; $retry++)
+        {
+            try
+            {
+                org.apache.geronimo.interop.rmi.iiop.client.Connection $connection_2 = this.$connect();
+                org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream $output_3 = $connection_2.getSimpleOutputStream();
+                $output_3.writeObject(vt$2, p1);
+                $connection_2.invoke(this, "resolve", $key, $retry);
+                org.apache.geronimo.interop.rmi.iiop.ObjectInputStream $input_4 = $connection_2.getSimpleInputStream();
+                $connection_2.forget($key);
+                $connection_2.close();
+                java.lang.String $et_5 = $connection_2.getExceptionType();
+                if ($et_5 != null)
+                {
+                    if ($et_5.equals("org.apache.geronimo.interop.CosNaming.NamingContextPackage.NotFound"))
+                    {
+                        throw (org.apache.geronimo.interop.CosNaming.NamingContextPackage.NotFound)$input_4.readException(vt$4);
+                    }
+                    if ($et_5.equals("org.apache.geronimo.interop.CosNaming.NamingContextPackage.CannotProceed"))
+                    {
+                        throw (org.apache.geronimo.interop.CosNaming.NamingContextPackage.CannotProceed)$input_4.readException(vt$5);
+                    }
+                    if ($et_5.equals("org.apache.geronimo.interop.CosNaming.NamingContextPackage.InvalidName"))
+                    {
+                        throw (org.apache.geronimo.interop.CosNaming.NamingContextPackage.InvalidName)$input_4.readException(vt$6);
+                    }
+                    throw org.apache.geronimo.interop.rmi.iiop.SystemExceptionFactory.getException($connection_2.getException());
+                }
+                org.omg.CORBA.Object $djc_result;
+                $djc_result = (org.omg.CORBA.Object)$input_4.readObject(vt$3);
+                return $djc_result;
+            }
+            catch (org.apache.geronimo.interop.rmi.iiop.client.RetryInvokeException $ex_6)
+            {
+                if ($retry == 3)
+                {
+                    throw $ex_6.getRuntimeException();
+                }
+            }
+        }
+    }
+
+    public void unbind(org.apache.geronimo.interop.CosNaming.NameComponent[] p1) throws org.apache.geronimo.interop.CosNaming.NamingContextPackage.NotFound, org.apache.geronimo.interop.CosNaming.NamingContextPackage.CannotProceed, org.apache.geronimo.interop.CosNaming.NamingContextPackage.InvalidName
+    {
+        java.lang.Object $key = $getRequestKey();
+        for (int $retry = 0; ; $retry++)
+        {
+            try
+            {
+                org.apache.geronimo.interop.rmi.iiop.client.Connection $connection_2 = this.$connect();
+                org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream $output_3 = $connection_2.getSimpleOutputStream();
+                $output_3.writeObject(vt$2, p1);
+                $connection_2.invoke(this, "unbind", $key, $retry);
+                org.apache.geronimo.interop.rmi.iiop.ObjectInputStream $input_4 = $connection_2.getSimpleInputStream();
+                $connection_2.forget($key);
+                $connection_2.close();
+                java.lang.String $et_5 = $connection_2.getExceptionType();
+                if ($et_5 != null)
+                {
+                    if ($et_5.equals("org.apache.geronimo.interop.CosNaming.NamingContextPackage.NotFound"))
+                    {
+                        throw (org.apache.geronimo.interop.CosNaming.NamingContextPackage.NotFound)$input_4.readException(vt$4);
+                    }
+                    if ($et_5.equals("org.apache.geronimo.interop.CosNaming.NamingContextPackage.CannotProceed"))
+                    {
+                        throw (org.apache.geronimo.interop.CosNaming.NamingContextPackage.CannotProceed)$input_4.readException(vt$5);
+                    }
+                    if ($et_5.equals("org.apache.geronimo.interop.CosNaming.NamingContextPackage.InvalidName"))
+                    {
+                        throw (org.apache.geronimo.interop.CosNaming.NamingContextPackage.InvalidName)$input_4.readException(vt$6);
+                    }
+                    throw org.apache.geronimo.interop.rmi.iiop.SystemExceptionFactory.getException($connection_2.getException());
+                }
+                return;
+            }
+            catch (org.apache.geronimo.interop.rmi.iiop.client.RetryInvokeException $ex_6)
+            {
+                if ($retry == 3)
+                {
+                    throw $ex_6.getRuntimeException();
+                }
+            }
+        }
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/CosNaming/iiop_stubs/NamingContext_Stub.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/CosNaming/iiop_stubs/NamingContext_Stub.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/CosNaming/iiop_stubs/NamingContext_Stub.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,392 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.CosNaming.iiop_stubs;
+
+import org.apache.geronimo.interop.rmi.iiop.ObjectRef;
+
+
+public class NamingContext_Stub
+        extends ObjectRef
+        implements org.apache.geronimo.interop.CosNaming.NamingContext {
+    // 
+    // Fields
+    // 
+    public java.lang.String[] _ids = {"org.apache.geronimo.interop.CosNaming.NamingContext", "RMI:org.apache.geronimo.interop.CosNaming.NamingContext:0000000000000000"};
+    private static final org.apache.geronimo.interop.rmi.iiop.ValueType vt$0 = org.apache.geronimo.interop.rmi.iiop.ValueType.getInstance(java.lang.String.class);
+    private static final org.apache.geronimo.interop.rmi.iiop.ValueType vt$1 = org.apache.geronimo.interop.rmi.iiop.ValueType.getInstance(org.apache.geronimo.interop.CosNaming.BindingListHolder.class);
+    private static final org.apache.geronimo.interop.rmi.iiop.ValueType vt$2 = org.apache.geronimo.interop.rmi.iiop.ValueType.getInstance(org.apache.geronimo.interop.CosNaming.BindingIteratorHolder.class);
+    private static final org.apache.geronimo.interop.rmi.iiop.ValueType vt$3 = org.apache.geronimo.interop.rmi.iiop.ValueType.getInstance(org.apache.geronimo.interop.CosNaming.NameComponent[].class);
+    private static final org.apache.geronimo.interop.rmi.iiop.ValueType vt$4 = org.apache.geronimo.interop.rmi.iiop.ValueType.getInstance(org.omg.CORBA.Object.class);
+    private static final org.apache.geronimo.interop.rmi.iiop.ValueType vt$5 = org.apache.geronimo.interop.rmi.iiop.ValueType.getInstance(org.apache.geronimo.interop.CosNaming.NamingContext.class);
+
+    //
+    // Constructors
+    // 
+    public NamingContext_Stub() {
+        super();
+    }
+    
+    // 
+    // Methods
+    // 
+    
+    public boolean _is_a(java.lang.String id) {
+        java.lang.Object $key = $getRequestKey();
+        int $retry;
+
+        for ($retry = 0
+                ; ; $retry++
+                ) {
+
+            try {
+                org.apache.geronimo.interop.rmi.iiop.client.Connection $conn;
+                org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream $out;
+                java.lang.String $et;
+                boolean $rc;
+                org.apache.geronimo.interop.rmi.iiop.ObjectInputStream $in;
+                $conn = this.$connect();
+                $out = $conn.getSimpleOutputStream();
+                $out.writeObject(vt$0, id);
+                $conn.invoke(this, "_is_a", $key, $retry);
+                $in = $conn.getSimpleInputStream();
+                $conn.forget($key);
+                $conn.close();
+                $et = $conn.getExceptionType();
+
+                if ($et != null) {
+                    throw org.apache.geronimo.interop.rmi.iiop.SystemExceptionFactory.getException($conn.getException());
+                }
+                $rc = $in.readBoolean();
+                return $rc;
+            } catch (org.apache.geronimo.interop.rmi.iiop.client.RetryInvokeException $ex) {
+
+                if ($retry == 3) {
+                    throw $ex.getRuntimeException();
+                }
+            }
+        }
+    }
+
+    public void list(int p0, org.apache.geronimo.interop.CosNaming.BindingListHolder p1, org.apache.geronimo.interop.CosNaming.BindingIteratorHolder p2) {
+        java.lang.Object $key = $getRequestKey();
+        int $retry;
+
+        for ($retry = 0
+                ; ; $retry++
+                ) {
+
+            try {
+                org.apache.geronimo.interop.rmi.iiop.client.Connection $conn;
+                org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream $out;
+                java.lang.String $et;
+                $conn = this.$connect();
+                $out = $conn.getSimpleOutputStream();
+                $out.writeInt(p0);
+                $out.writeObject(vt$1, p1);
+                $out.writeObject(vt$2, p2);
+                $conn.invoke(this, "list", $key, $retry);
+                $conn.forget($key);
+                $conn.close();
+                $et = $conn.getExceptionType();
+
+                if ($et != null) {
+                    throw org.apache.geronimo.interop.rmi.iiop.SystemExceptionFactory.getException($conn.getException());
+                }
+            } catch (org.apache.geronimo.interop.rmi.iiop.client.RetryInvokeException $ex) {
+
+                if ($retry == 3) {
+                    throw $ex.getRuntimeException();
+                }
+            }
+        }
+    }
+
+    public org.omg.CORBA.Object resolve(org.apache.geronimo.interop.CosNaming.NameComponent[] p0) throws org.apache.geronimo.interop.CosNaming.NamingContextPackage.NotFound, org.apache.geronimo.interop.CosNaming.NamingContextPackage.CannotProceed, org.apache.geronimo.interop.CosNaming.NamingContextPackage.InvalidName {
+        java.lang.Object $key = $getRequestKey();
+        int $retry;
+
+        for ($retry = 0
+                ; ; $retry++
+                ) {
+
+            try {
+                org.apache.geronimo.interop.rmi.iiop.client.Connection $conn;
+                org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream $out;
+                java.lang.String $et;
+                org.omg.CORBA.Object $rc;
+                org.apache.geronimo.interop.rmi.iiop.ObjectInputStream $in;
+                $conn = this.$connect();
+                $out = $conn.getSimpleOutputStream();
+                $out.writeObject(vt$3, p0);
+                $conn.invoke(this, "resolve", $key, $retry);
+                $in = $conn.getSimpleInputStream();
+                $conn.forget($key);
+                $conn.close();
+                $et = $conn.getExceptionType();
+
+                if ($et != null) {
+                    throw org.apache.geronimo.interop.rmi.iiop.SystemExceptionFactory.getException($conn.getException());
+                }
+                $rc = (org.omg.CORBA.Object) $in.readObject(vt$4);
+                return $rc;
+            } catch (org.apache.geronimo.interop.rmi.iiop.client.RetryInvokeException $ex) {
+
+                if ($retry == 3) {
+                    throw $ex.getRuntimeException();
+                }
+            }
+        }
+    }
+
+    public void bind(org.apache.geronimo.interop.CosNaming.NameComponent[] p0, org.omg.CORBA.Object p1) throws org.apache.geronimo.interop.CosNaming.NamingContextPackage.NotFound, org.apache.geronimo.interop.CosNaming.NamingContextPackage.CannotProceed, org.apache.geronimo.interop.CosNaming.NamingContextPackage.InvalidName, org.apache.geronimo.interop.CosNaming.NamingContextPackage.AlreadyBound {
+        java.lang.Object $key = $getRequestKey();
+        int $retry;
+
+        for ($retry = 0
+                ; ; $retry++
+                ) {
+
+            try {
+                org.apache.geronimo.interop.rmi.iiop.client.Connection $conn;
+                org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream $out;
+                java.lang.String $et;
+                $conn = this.$connect();
+                $out = $conn.getSimpleOutputStream();
+                $out.writeObject(vt$3, p0);
+                $out.writeObject(vt$4, p1);
+                $conn.invoke(this, "bind", $key, $retry);
+                $conn.forget($key);
+                $conn.close();
+                $et = $conn.getExceptionType();
+
+                if ($et != null) {
+                    throw org.apache.geronimo.interop.rmi.iiop.SystemExceptionFactory.getException($conn.getException());
+                }
+            } catch (org.apache.geronimo.interop.rmi.iiop.client.RetryInvokeException $ex) {
+
+                if ($retry == 3) {
+                    throw $ex.getRuntimeException();
+                }
+            }
+        }
+    }
+
+    public void bind_context(org.apache.geronimo.interop.CosNaming.NameComponent[] p0, org.apache.geronimo.interop.CosNaming.NamingContext p1) throws org.apache.geronimo.interop.CosNaming.NamingContextPackage.NotFound, org.apache.geronimo.interop.CosNaming.NamingContextPackage.CannotProceed, org.apache.geronimo.interop.CosNaming.NamingContextPackage.InvalidName, org.apache.geronimo.interop.CosNaming.NamingContextPackage.AlreadyBound {
+        java.lang.Object $key = $getRequestKey();
+        int $retry;
+
+        for ($retry = 0
+                ; ; $retry++
+                ) {
+
+            try {
+                org.apache.geronimo.interop.rmi.iiop.client.Connection $conn;
+                org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream $out;
+                java.lang.String $et;
+                $conn = this.$connect();
+                $out = $conn.getSimpleOutputStream();
+                $out.writeObject(vt$3, p0);
+                $out.writeObject(vt$5, p1);
+                $conn.invoke(this, "bind_context", $key, $retry);
+                $conn.forget($key);
+                $conn.close();
+                $et = $conn.getExceptionType();
+
+                if ($et != null) {
+                    throw org.apache.geronimo.interop.rmi.iiop.SystemExceptionFactory.getException($conn.getException());
+                }
+            } catch (org.apache.geronimo.interop.rmi.iiop.client.RetryInvokeException $ex) {
+
+                if ($retry == 3) {
+                    throw $ex.getRuntimeException();
+                }
+            }
+        }
+    }
+
+    public void rebind(org.apache.geronimo.interop.CosNaming.NameComponent[] p0, org.omg.CORBA.Object p1) throws org.apache.geronimo.interop.CosNaming.NamingContextPackage.NotFound, org.apache.geronimo.interop.CosNaming.NamingContextPackage.CannotProceed, org.apache.geronimo.interop.CosNaming.NamingContextPackage.InvalidName {
+        java.lang.Object $key = $getRequestKey();
+        int $retry;
+
+        for ($retry = 0
+                ; ; $retry++
+                ) {
+
+            try {
+                org.apache.geronimo.interop.rmi.iiop.client.Connection $conn;
+                org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream $out;
+                java.lang.String $et;
+                $conn = this.$connect();
+                $out = $conn.getSimpleOutputStream();
+                $out.writeObject(vt$3, p0);
+                $out.writeObject(vt$4, p1);
+                $conn.invoke(this, "rebind", $key, $retry);
+                $conn.forget($key);
+                $conn.close();
+                $et = $conn.getExceptionType();
+
+                if ($et != null) {
+                    throw org.apache.geronimo.interop.rmi.iiop.SystemExceptionFactory.getException($conn.getException());
+                }
+            } catch (org.apache.geronimo.interop.rmi.iiop.client.RetryInvokeException $ex) {
+
+                if ($retry == 3) {
+                    throw $ex.getRuntimeException();
+                }
+            }
+        }
+    }
+
+    public void rebind_context(org.apache.geronimo.interop.CosNaming.NameComponent[] p0, org.apache.geronimo.interop.CosNaming.NamingContext p1) throws org.apache.geronimo.interop.CosNaming.NamingContextPackage.NotFound, org.apache.geronimo.interop.CosNaming.NamingContextPackage.CannotProceed, org.apache.geronimo.interop.CosNaming.NamingContextPackage.InvalidName {
+        java.lang.Object $key = $getRequestKey();
+        int $retry;
+
+        for ($retry = 0
+                ; ; $retry++
+                ) {
+
+            try {
+                org.apache.geronimo.interop.rmi.iiop.client.Connection $conn;
+                org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream $out;
+                java.lang.String $et;
+                $conn = this.$connect();
+                $out = $conn.getSimpleOutputStream();
+                $out.writeObject(vt$3, p0);
+                $out.writeObject(vt$5, p1);
+                $conn.invoke(this, "rebind_context", $key, $retry);
+                $conn.forget($key);
+                $conn.close();
+                $et = $conn.getExceptionType();
+
+                if ($et != null) {
+                    throw org.apache.geronimo.interop.rmi.iiop.SystemExceptionFactory.getException($conn.getException());
+                }
+            } catch (org.apache.geronimo.interop.rmi.iiop.client.RetryInvokeException $ex) {
+
+                if ($retry == 3) {
+                    throw $ex.getRuntimeException();
+                }
+            }
+        }
+    }
+
+    public void unbind(org.apache.geronimo.interop.CosNaming.NameComponent[] p0) throws org.apache.geronimo.interop.CosNaming.NamingContextPackage.NotFound, org.apache.geronimo.interop.CosNaming.NamingContextPackage.CannotProceed, org.apache.geronimo.interop.CosNaming.NamingContextPackage.InvalidName {
+        java.lang.Object $key = $getRequestKey();
+        int $retry;
+
+        for ($retry = 0
+                ; ; $retry++
+                ) {
+
+            try {
+                org.apache.geronimo.interop.rmi.iiop.client.Connection $conn;
+                org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream $out;
+                java.lang.String $et;
+                $conn = this.$connect();
+                $out = $conn.getSimpleOutputStream();
+                $out.writeObject(vt$3, p0);
+                $conn.invoke(this, "unbind", $key, $retry);
+                $conn.forget($key);
+                $conn.close();
+                $et = $conn.getExceptionType();
+
+                if ($et != null) {
+                    throw org.apache.geronimo.interop.rmi.iiop.SystemExceptionFactory.getException($conn.getException());
+                }
+            } catch (org.apache.geronimo.interop.rmi.iiop.client.RetryInvokeException $ex) {
+
+                if ($retry == 3) {
+                    throw $ex.getRuntimeException();
+                }
+            }
+        }
+    }
+
+    public org.apache.geronimo.interop.CosNaming.NamingContext new_context() {
+        java.lang.Object $key = $getRequestKey();
+        int $retry;
+
+        for ($retry = 0
+                ; ; $retry++
+                ) {
+
+            try {
+                org.apache.geronimo.interop.rmi.iiop.client.Connection $conn;
+                org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream $out;
+                java.lang.String $et;
+                org.apache.geronimo.interop.CosNaming.NamingContext $rc;
+                org.apache.geronimo.interop.rmi.iiop.ObjectInputStream $in;
+                $conn = this.$connect();
+                $out = $conn.getSimpleOutputStream();
+                $conn.invoke(this, "new_context", $key, $retry);
+                $in = $conn.getSimpleInputStream();
+                $conn.forget($key);
+                $conn.close();
+                $et = $conn.getExceptionType();
+
+                if ($et != null) {
+                    throw org.apache.geronimo.interop.rmi.iiop.SystemExceptionFactory.getException($conn.getException());
+                }
+                $rc = (org.apache.geronimo.interop.CosNaming.NamingContext) $in.readObject(vt$5);
+                return $rc;
+            } catch (org.apache.geronimo.interop.rmi.iiop.client.RetryInvokeException $ex) {
+
+                if ($retry == 3) {
+                    throw $ex.getRuntimeException();
+                }
+            }
+        }
+    }
+
+    public org.apache.geronimo.interop.CosNaming.NamingContext bind_new_context(org.apache.geronimo.interop.CosNaming.NameComponent[] p0) throws org.apache.geronimo.interop.CosNaming.NamingContextPackage.NotFound, org.apache.geronimo.interop.CosNaming.NamingContextPackage.AlreadyBound, org.apache.geronimo.interop.CosNaming.NamingContextPackage.CannotProceed, org.apache.geronimo.interop.CosNaming.NamingContextPackage.InvalidName {
+        java.lang.Object $key = $getRequestKey();
+        int $retry;
+
+        for ($retry = 0
+                ; ; $retry++
+                ) {
+
+            try {
+                org.apache.geronimo.interop.rmi.iiop.client.Connection $conn;
+                org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream $out;
+                java.lang.String $et;
+                org.apache.geronimo.interop.CosNaming.NamingContext $rc;
+                org.apache.geronimo.interop.rmi.iiop.ObjectInputStream $in;
+                $conn = this.$connect();
+                $out = $conn.getSimpleOutputStream();
+                $out.writeObject(vt$3, p0);
+                $conn.invoke(this, "bind_new_context", $key, $retry);
+                $in = $conn.getSimpleInputStream();
+                $conn.forget($key);
+                $conn.close();
+                $et = $conn.getExceptionType();
+
+                if ($et != null) {
+                    throw org.apache.geronimo.interop.rmi.iiop.SystemExceptionFactory.getException($conn.getException());
+                }
+                $rc = (org.apache.geronimo.interop.CosNaming.NamingContext) $in.readObject(vt$5);
+                return $rc;
+            } catch (org.apache.geronimo.interop.rmi.iiop.client.RetryInvokeException $ex) {
+
+                if ($retry == 3) {
+                    throw $ex.getRuntimeException();
+                }
+            }
+        }
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/InteropGBean.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/InteropGBean.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/InteropGBean.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,143 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop;
+
+import java.util.Properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.gbean.WaitingException;
+import org.apache.geronimo.interop.IOP.IOR;
+
+
+/**
+ * A GBean that provides an example interop
+ *
+ * @version $Rev: $ $Date: $
+ */
+public class InteropGBean implements GBeanLifecycle {
+
+    private final Log log = LogFactory.getLog(InteropGBean.class);
+
+    private IOR ior;
+
+    private Properties properties;
+    private String strprop;
+    private String objectName;
+
+    /**
+     * Construct an instance of InteropGBean
+     *
+     * @param strprop some strprop
+     */
+    public InteropGBean(String objectName, String strprop, Properties properties) {
+        this.objectName = objectName;
+        this.strprop = strprop;
+        this.properties = (properties == null ? new Properties() : properties);
+    }
+
+    /**
+     * Returns the strprop.
+     */
+    public String getAStrProp() {
+        return strprop;
+    }
+
+    /**
+     * Sets the strprop
+     *
+     * @param strprop the strprop
+     */
+    public void setAStrProp(String strprop) {
+        this.strprop = strprop;
+    }
+
+    /**
+     * Returns the Properties
+     */
+    public Properties getProperties() {
+        return properties;
+    }
+
+    /**
+     * Sets the properties
+     *
+     * @param properties the props.
+     */
+    public void setProperties(Properties properties) {
+        this.properties = properties;
+    }
+
+    /**
+     * Returns the object name of this protocol GBean
+     */
+    public String getObjectName() {
+        return objectName;
+    }
+
+    /**
+     * Add the overrides from the member variables to the properties file.
+     */
+    public void echo(String msg) {
+        log.info(getObjectName() + ": Echo " + msg);
+    }    
+
+    /* 
+     * Interface :: GBeanLifecycle
+     */
+
+    public void doStart() throws WaitingException, Exception {
+        log.info("Started " + getObjectName());
+    }
+
+    public void doStop() throws WaitingException, Exception {
+        log.info("Stopped " + getObjectName());
+    }
+
+    public void doFail() {
+        log.info("Failed " + getObjectName());
+    }
+
+    /* 
+     * GBeanInfo
+     */
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoFactory = new GBeanInfoBuilder(InteropGBean.class);
+
+        infoFactory.addAttribute("objectName", String.class, false);
+        infoFactory.addAttribute("strprop", String.class, true);
+        infoFactory.addAttribute("properties", Properties.class, true);
+
+        infoFactory.addOperation("echo", new Class[]{String.class});
+
+        infoFactory.setConstructor(new String[]{"objectName", "strprop", "properties"});
+
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/SystemException.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/SystemException.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/SystemException.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,50 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop;
+
+
+public class SystemException extends RuntimeException {
+    public SystemException(String message) {
+        super(message);
+    }
+
+    public SystemException(Throwable cause) {
+        super(cause != null && cause instanceof SystemException
+              && cause.getMessage() == null
+              ? cause.getCause() : cause);
+    }
+
+    public SystemException(String message, Throwable cause) {
+        super(message, cause != null && cause instanceof SystemException
+                       && cause.getMessage() == null
+                       ? cause.getCause() : cause);
+    }
+
+    /*
+Constructor Summary 
+RuntimeException() 
+          Constructs a new runtime exception with null as its detail message. 
+RuntimeException(String message) 
+          Constructs a new runtime exception with the specified detail message. 
+RuntimeException(String message, Throwable cause) 
+          Constructs a new runtime exception with the specified detail message and cause. 
+RuntimeException(Throwable cause) 
+          Constructs a new runtime exception with the specified cause and a detail message of (cause==null ? null : cause.toString()) (which typically contains the class and detail message of cause). 
+          */
+
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/adapter/Adapter.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/adapter/Adapter.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/adapter/Adapter.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,252 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.adapter;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Vector;
+
+import org.apache.geronimo.interop.rmi.iiop.RemoteInterface;
+
+
+public class Adapter {
+    //
+    // Public Accessible Properties
+    //
+    protected String _bindName;
+    protected String _remoteClassName;
+    protected String _remoteInterfaceName;
+    protected Vector _idVector;
+    protected boolean _shared;
+    protected ClassLoader _cl;
+    protected RemoteInterface _ri;
+
+    //
+    // Internal Properrties
+    //
+
+    protected Object _sharedObject;
+    protected HashMap _objects;
+    protected Class _remoteClassClass;
+    protected Class _remoteInterfaceClass;
+
+    public Adapter() {
+        _objects = new HashMap();
+        _idVector = new Vector();
+    }
+
+    /*
+     * BindName is the name that will be registered with the INS (Inter-operable Name Service)
+     */
+    public String getBindName() {
+        return _bindName;
+    }
+
+    public void setBindName(String bindName) {
+        _bindName = bindName;
+    }
+
+    /*
+     * Is this a shared component?  If so this will invoke the getInstance method on
+     * the component ...
+     */
+    public boolean isShared() {
+        return _shared;
+    }
+
+    public void setShared(boolean shared) {
+        _shared = shared;
+    }
+
+    /*
+     * The classloader that will load any dependancies of the adapter or corba skel interfaces.
+     * Its should be set by the ejb container
+     */
+    public ClassLoader getClassLoader() {
+        return _cl;
+    }
+
+    public void setClassLoader(ClassLoader cl) {
+        _cl = cl;
+    }
+
+    /*
+     * This is the name of the remote class that implements the remote interface.
+     *
+     * This is only used if this adapter is going to directly invoke an object.  For the
+     * EJB Container, the adapter will pass through the method invocations.
+     */
+    public String getRemoteClassName() {
+        return _remoteClassName;
+    }
+
+    public void setRemoteClassName(String rcName) {
+        _remoteClassName = rcName;
+    }
+
+    /*
+     * The remote interface name for the remote object.  This will most likely be the name
+     * of the EJB's RemoteInterface and RemoteHomeInterface
+     *
+     * The stub/skel generator will use this interface name.
+     */
+    public String getRemoteInterfaceName() {
+        return _remoteInterfaceName;
+    }
+
+    public void setRemoteInterfaceName(String riName) {
+        _remoteInterfaceName = riName;
+    }
+
+    /*
+     * A list of public IDs that the remote object implements:
+     *
+     * IDL:....:1.0
+     * RMI:....:X:Y
+     */
+    public Vector getIds() {
+        return _idVector;
+    }
+
+    public void addId(String id) {
+        _idVector.add(id);
+    }
+
+    public void removeId(String id) {
+        _idVector.remove(id);
+    }
+
+    /*
+     * Return the skeleton implemention for the remote interface.  This interface has the
+     * invoke method to handle the rmi/iiop messages.
+     */
+    public RemoteInterface getRemoteInterface() {
+        if (_ri == null) {
+            synchronized (this) {
+                String riName = _remoteInterfaceName + "_Skeleton";
+                _remoteInterfaceClass = loadClass(riName);
+
+                try {
+                    _ri = (RemoteInterface) _remoteInterfaceClass.newInstance();
+                } catch (InstantiationException e) {
+                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+                } catch (IllegalAccessException e) {
+                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+                }
+            }
+        }
+
+        return _ri;
+    }
+
+    /*
+     * Get an object instance to invoke based on the object key.
+     *
+     * The objectKey could probably be passed to the EJB container so that the
+     * container can directly invoke the ejb object as required.
+     */
+    public Object getInstance(byte[] objectKey) {
+        String key = new String(objectKey);
+        return getInstance(key);
+    }
+
+    public Object getInstance(String key) {
+        Object o = _objects.get(key);
+
+        if (o == null) {
+            o = newInstance(key);
+        }
+
+        return o;
+    }
+
+    public Object newInstance(byte[] objectKey) {
+        String key = new String(objectKey);
+        return newInstance(key);
+    }
+
+    public Object newInstance(String key) {
+        Object o = null;
+
+        if (_remoteClassClass == null) {
+            synchronized (this) {
+                _remoteClassClass = loadClass(_remoteClassName);
+            }
+
+            try {
+                if (_shared) {
+                    synchronized (this) {
+                        Method m = _remoteClassClass.getMethod("getInstance", (Class[]) null);
+                        o = m.invoke(_remoteClassClass, (Object[]) null);
+
+                        if (o != null) {
+                            _objects.put(key, o);
+                        }
+                    }
+                } else {
+                    o = _remoteClassClass.newInstance();
+                    _objects.put(key, o);
+                }
+            } catch (InstantiationException e) {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            } catch (IllegalAccessException e) {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            } catch (NoSuchMethodException e) {
+                e.printStackTrace();
+            } catch (InvocationTargetException e) {
+                e.printStackTrace();
+            }
+        }
+
+        return o;
+    }
+
+    /*
+     * Invoke method from the IIOP Message Handler.  The adapter is bound to the INS name service.
+     * When an RMI/IIOP message is processed by the server, the message handler will perform a lookup
+     * on the name service to get the Adapter, then the invocation will be passed to the adapter
+     * The adapter will obtain the object key and then determine which object instance to pass the
+     * invocation to.
+     */
+    public void invoke(java.lang.String methodName, byte[] objectKey, org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input, org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) {
+        RemoteInterface skeleton = getRemoteInterface();
+        Object instance = getInstance(objectKey);
+
+        if (instance != null) {
+            skeleton.$invoke(methodName, objectKey, instance, input, output);
+        } else {
+            throw new org.omg.CORBA.OBJECT_NOT_EXIST(new String(objectKey));
+        }
+    }
+
+    /*
+     * Helper function to load a class.  This uses classloader for the adapter.
+     */
+    protected Class loadClass(String name) {
+        Class c = null;
+
+        try {
+            c = _cl.loadClass(name);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return c;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/adapter/AdapterManager.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/adapter/AdapterManager.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/adapter/AdapterManager.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,43 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.adapter;
+
+import java.util.Hashtable;
+
+
+public class AdapterManager {
+    protected Hashtable _adapters;
+    protected static AdapterManager _me = new AdapterManager();
+
+    protected AdapterManager() {
+        _adapters = new Hashtable();
+    }
+
+    public static AdapterManager getInstance() {
+        return _me;
+    }
+
+    public void registerAdapter(Adapter a) {
+
+        _adapters.put(a.getBindName(), a);
+    }
+
+    public Adapter getAdapter(String objectName) {
+        return (Adapter) _adapters.get(objectName);
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/client/InitialContextFactory.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/client/InitialContextFactory.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/client/InitialContextFactory.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,32 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.client;
+
+import java.util.HashMap;
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+
+public class InitialContextFactory
+        implements javax.naming.spi.InitialContextFactory {
+    private HashMap _startMap = new HashMap();
+
+    public Context getInitialContext(java.util.Hashtable env) throws NamingException {
+        return org.apache.geronimo.interop.rmi.iiop.client.ClientNamingContext.getInstance(env);
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/client/InitialContextFactoryBuilder.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/client/InitialContextFactoryBuilder.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/client/InitialContextFactoryBuilder.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,28 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.client;
+
+import java.util.Hashtable;
+
+
+public class InitialContextFactoryBuilder
+        implements javax.naming.spi.InitialContextFactoryBuilder {
+    public javax.naming.spi.InitialContextFactory createInitialContextFactory(Hashtable env) {
+        return new InitialContextFactory();
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/CodeWriter.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/CodeWriter.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/CodeWriter.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,65 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.generator;
+
+import java.io.File;
+
+
+public abstract class CodeWriter {
+    protected GenOptions _genOptions;
+
+    protected File _file;
+
+    protected String _fileName;
+    protected String _fileExt = ".java";
+
+    public CodeWriter(GenOptions genOptions, String fileName, String ext) {
+        _genOptions = genOptions;
+        _fileName = fileName;
+        _fileExt = ext;
+    }
+
+    public GenOptions getGenOptions() {
+        return _genOptions;
+    }
+
+    public void setGenOptions(GenOptions genOptions) {
+        _genOptions = genOptions;
+    }
+
+    public void setFileName(String val) {
+        _fileName = val;
+    }
+
+    public String getFileName() {
+        return _fileName;
+    }
+
+    public void setFileExt(String val) {
+        _fileExt = val;
+    }
+
+    public String getFileExt() {
+        return _fileExt;
+    }
+
+    public abstract void openFile() throws GenException;
+
+    public abstract void closeFile() throws GenException;
+}
+

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/GenException.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/GenException.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/GenException.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,43 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.generator;
+
+/**
+ * User: Mark
+ * Date: Dec 21, 2004
+ * Time: 3:49:45 PM
+ */
+
+public class GenException
+        extends Exception {
+    public GenException() {
+        super();
+    }
+
+    public GenException(String message) {
+        super(message);
+    }
+
+    public GenException(Throwable cause) {
+        super(cause);
+    }
+
+    public GenException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/GenOptions.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/GenOptions.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/GenOptions.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,58 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.generator;
+
+public class GenOptions {
+    protected String _genDir = "./";
+    protected boolean _overwrite = false;
+    protected boolean _verbose = false;
+
+    public GenOptions() {
+    }
+
+    public GenOptions(String genDir, boolean overwrite, boolean verbose) {
+        _genDir = genDir;
+        _overwrite = overwrite;
+        _verbose = verbose;
+    }
+
+    public String getGenDir() {
+        return _genDir;
+    }
+
+    public void setGenDir(String genDir) {
+        _genDir = genDir;
+    }
+
+    public boolean isOverwrite() {
+        return _overwrite;
+    }
+
+    public void setOverwrite(boolean overwrite) {
+        _overwrite = overwrite;
+    }
+
+    public boolean isVerbose() {
+        return _verbose;
+    }
+
+    public void setVerbose(boolean verbose) {
+        _verbose = verbose;
+    }
+
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/Generator.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/Generator.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/Generator.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,22 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.generator;
+
+public interface Generator {
+    public void generate(JEntity e);
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JBlockStatement.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JBlockStatement.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JBlockStatement.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,71 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.generator;
+
+import java.util.Vector;
+
+
+public class JBlockStatement extends JStatement {
+    protected Vector _localVars;
+    protected Vector _statements;
+
+    public JBlockStatement() {
+        _localVars = new Vector();
+        _statements = new Vector();
+    }
+
+    public boolean hasVariables() {
+        return _localVars.size() > 0;
+    }
+
+    public boolean hasStatements() {
+        return _statements.size() > 0;
+    }
+
+    public JLocalVariable newLocalVariable(Class type, String name) {
+        return newLocalVariable(type, name, null);
+    }
+
+    public JLocalVariable newLocalVariable(Class type, String name, JExpression initExpr) {
+        JLocalVariable v = new JLocalVariable(type, name);
+
+        v.setInitExpression(initExpr);
+
+        _localVars.add(v);
+
+        return v;
+    }
+
+    public void deleteLocalVariable(JLocalVariable f) {
+        _localVars.remove(f);
+    }
+
+    public Vector getLocalVariables() {
+        return _localVars;
+    }
+
+    public void addStatement(JStatement s) {
+        if (s != this) {
+            _statements.add(s);
+        }
+    }
+
+    public Vector getStatements() {
+        return _statements;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JCaseStatement.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JCaseStatement.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JCaseStatement.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,49 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.generator;
+
+
+
+
+public class JCaseStatement extends JStatement {
+    protected JExpression _expr;
+    protected JBlockStatement _statements;
+
+    public JCaseStatement(JExpression e) {
+        super();
+
+        _expr = e;
+        _statements = new JBlockStatement();
+    }
+
+    public void setExpression(JExpression e) {
+        _expr = e;
+    }
+
+    public JExpression getExpression() {
+        return _expr;
+    }
+
+    public void addStatement(JStatement s) {
+        _statements.addStatement(s);
+    }
+
+    public JBlockStatement getStatement() {
+        return _statements;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JCatchStatement.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JCatchStatement.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JCatchStatement.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,124 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.generator;
+
+public class JCatchStatement extends JBlockStatement {
+    protected JVariable _var;
+
+    public JCatchStatement(JVariable v) {
+        super();
+        _var = v;
+    }
+
+    public JVariable getVariable() {
+        return _var;
+    }
+
+    public int hashCode() {
+        return _var.hashCode();
+    }
+
+    public boolean equals(Object other) {
+        boolean rc = false;
+
+        if (this == other) {
+            rc = true;
+        } else if (other instanceof JCatchStatement) {
+            JCatchStatement cs = (JCatchStatement) other;
+
+            if (cs._var.getType().equals(_var.getType())) {
+                rc = true;
+            }
+        } else if (other instanceof JVariable) {
+            JVariable v = (JVariable) other;
+
+            if (v.getType().equals(_var.getType())) {
+                rc = true;
+            }
+        }
+
+
+        return rc;
+    }
+}
+
+/*
+public class JCatchStatement extends JStatement
+{
+    protected JVariable          _var;
+    protected JBlockStatement    _statements;
+
+    public JCatchStatement( JVariable v )
+    {
+        _var = v;
+        _statements = new JBlockStatement();
+    }
+
+    public void addStatement( JStatement s )
+    {
+        _statements.addStatement( s );
+    }
+
+    public JBlockStatement getStatement()
+    {
+        return _statements;
+    }
+
+    public JVariable getVariable()
+    {
+        return _var;
+    }
+
+    public int hashCode()
+    {
+        return _var.hashCode();
+    }
+
+    public boolean equals( Object other )
+    {
+        boolean rc = false;
+
+        if (this == other)
+        {
+            rc = true;
+        }
+        else if (other instanceof JCatchStatement)
+        {
+            JCatchStatement cs = (JCatchStatement)other;
+
+            if (cs._var.getType().equals(_var.getType()))
+            {
+                rc = true;
+            }
+        }
+        else if (other instanceof JVariable)
+        {
+            JVariable v = (JVariable)other;
+
+            if (v.getType().equals( _var.getType() ))
+            {
+                rc = true;
+            }
+        }
+
+
+        return rc;
+    }
+}
+
+*/
\ No newline at end of file

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JClass.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JClass.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JClass.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,255 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.generator;
+
+import java.lang.reflect.Modifier;
+import java.util.Vector;
+
+
+public class JClass extends JEntity {
+    protected JPackage _pkg;
+
+    protected Vector _imports;
+    protected Vector _implements;
+    protected String _baseClassName;
+
+    protected Vector _constructors;
+    protected Vector _methods;
+    protected Vector _fields;
+
+    protected Vector _classes = new Vector();
+    protected JClass _parent;
+
+    protected JClass(String name) {
+        super(name, Modifier.PUBLIC);
+
+        _imports = new Vector();
+        _implements = new Vector();
+        _baseClassName = "";
+
+        _constructors = new Vector();
+        _methods = new Vector();
+        _fields = new Vector();
+    }
+
+    protected JClass(String name, JPackage pkg) {
+        this(name);
+
+        if (pkg == null) {
+            pkg = new JPackage("");
+        }
+
+        _pkg = pkg;
+    }
+
+    protected JClass(String name, JClass parent) {
+        this(name);
+
+        _parent = parent;
+    }
+
+    public JConstructor newConstructor(JParameter parms[], Class thrown[]) {
+        JConstructor c = new JConstructor(parms, thrown);
+        c.setParent(this);
+        _constructors.add(c);
+        return c;
+    }
+
+    /*
+    public JConstructor newConstructor( JParameter parms[], String thrown[] )
+    {
+        JConstructor c = new JConstructor( parms, thrown );
+        c.setParent( this );
+        _constructors.add( c );
+        return c;
+    }
+    */
+
+    public void deleteConstructor(JConstructor m) {
+        _constructors.removeElement(m);
+    }
+
+    public Vector getConstructors() {
+        return _constructors;
+    }
+
+    public JMethod newMethod(JReturnType rt, String name, JParameter parms[], Class thrown[]) {
+        JMethod m = new JMethod(rt, name, parms, thrown);
+        m.setParent(this);
+        _methods.add(m);
+        return m;
+    }
+
+    /*
+    public JMethod newMethod( JReturnType rt, String name, JParameter parms[], String thrown[] )
+    {
+        JMethod m = new JMethod( rt, name, parms, thrown );
+        m.setParent( this );
+        _methods.add( m );
+        return m;
+    }
+    */
+
+    public void deleteMethod(JMethod m) {
+        _methods.removeElement(m);
+    }
+
+    public Vector getMethods() {
+        return _methods;
+    }
+
+    protected void setFieldParentAndModifier(JField f) {
+        f.setParent(this);
+
+        if (Modifier.isPublic(this.getModifiers())) {
+            f.setModifiers(f.getModifiers() | Modifier.PUBLIC);
+        }
+
+        if (Modifier.isProtected(this.getModifiers())) {
+            f.setModifiers(f.getModifiers() | Modifier.PROTECTED);
+        }
+
+        if (Modifier.isPrivate(this.getModifiers())) {
+            f.setModifiers(f.getModifiers() | Modifier.PRIVATE);
+        }
+    }
+
+    public JField newField(Class type, String name) {
+        return newField(type, name, null);
+    }
+
+    public JField newField(Class type, String name, JExpression initExpr) {
+        return newField(type, name, initExpr, false);
+    }
+
+    public JField newField(Class type, String name, JExpression initExpr, boolean isArray) {
+        JField f = new JField(type, name);
+
+        setFieldParentAndModifier(f);
+        f.setInitExpression(initExpr);
+
+        _fields.add(f);
+
+        return f;
+    }
+
+    public void deleteField(JField f) {
+        _fields.remove(f);
+    }
+
+    public Vector getFields() {
+        return _fields;
+    }
+
+    public JClass newClass(String name) {
+        JClass c = new JClass(name, this);
+        _classes.add(c);
+        return c;
+    }
+
+    public JPackage getPackage() {
+        if (_parent != null) {
+            return _parent.getPackage();
+        } else {
+            return _pkg;
+        }
+    }
+
+    public String getName() {
+        if (_parent != null) {
+            return _parent.getName() + "$" + super.getName();
+        } else {
+            return super.getName();
+        }
+    }
+
+    public void setExtends(String bcl) {
+        setBaseClassName(bcl);
+    }
+
+    public String getExtends() {
+        return getBaseClassName();
+    }
+
+    public void setBaseClassName(String bcl) {
+        _baseClassName = bcl;
+    }
+
+    public String getBaseClassName() {
+        return _baseClassName;
+    }
+
+    public void addImplements(String className) {
+        _implements.add(className);
+    }
+
+    public void removeImplements(String className) {
+        _implements.remove(className);
+    }
+
+    public Vector getImplements() {
+        return _implements;
+    }
+
+    /*
+     * Adding Imports
+     */
+    public void addImport(Package pkg, String itemName) {
+        if (pkg != null) {
+            addImport(pkg.getName(), itemName);
+        }
+    }
+
+    public void addImport(Package pkg) {
+        if (pkg != null) {
+            addImport(pkg.getName(), "*");
+        }
+    }
+
+    public void addImport(String name, String itemName) {
+        addImport(name + "." + itemName);
+    }
+
+    public void addImport(String fqName) {
+        _imports.add(fqName);
+    }
+
+    public void removeImport(Package pkg, String itemName) {
+        if (pkg != null) {
+            removeImport(pkg.getName(), itemName);
+        }
+    }
+
+    public void removeImport(Package pkg) {
+        if (pkg != null) {
+            removeImport(pkg.getName());
+        }
+    }
+
+    public void removeImport(String name, String itemName) {
+        removeImport(name + "." + itemName);
+    }
+
+    public void removeImport(String name) {
+        _imports.remove(name);
+    }
+
+    public Vector getImports() {
+        return _imports;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JCodeStatement.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JCodeStatement.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JCodeStatement.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,33 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.generator;
+
+
+
+
+public class JCodeStatement extends JStatement {
+    protected String _code;
+
+    public JCodeStatement(String code) {
+        _code = code;
+    }
+
+    public String getCode() {
+        return _code;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JConstructor.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JConstructor.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JConstructor.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,38 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.generator;
+
+
+
+
+public class JConstructor extends JMethod {
+    protected JConstructor(String name) {
+        super(name);
+    }
+
+    protected JConstructor(JParameter parms[], Class thrown[]) {
+        super((JReturnType) null, (String) null, parms, thrown);
+    }
+
+    /*
+    protected JConstructor( JParameter parms[], String thrownType[] )
+    {
+        super( (JReturnType)null, (String)null, parms, thrownType );
+    }
+    */
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JDeclareStatement.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JDeclareStatement.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JDeclareStatement.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,48 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.generator;
+
+public class JDeclareStatement extends JStatement {
+    protected JVariable _v;
+    protected JExpression _initExpr;
+
+    public JDeclareStatement(JVariable v) {
+        this(v, null);
+    }
+
+    public JDeclareStatement(JVariable v, JExpression initExpr) {
+        _v = v;
+        _initExpr = initExpr;
+    }
+
+    public void setVariable(JVariable s) {
+        _v = s;
+    }
+
+    public JVariable getVariable() {
+        return _v;
+    }
+
+    public void setInitExpression(JExpression initExpr) {
+        _initExpr = initExpr;
+    }
+
+    public JExpression getInitExpression() {
+        return _initExpr;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JElseIfStatement.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JElseIfStatement.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JElseIfStatement.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,24 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.generator;
+
+public class JElseIfStatement extends JIfStatement {
+    public JElseIfStatement(JExpression e) {
+        super(e);
+    }
+}
\ No newline at end of file

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JElseStatement.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JElseStatement.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JElseStatement.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,24 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.generator;
+
+public class JElseStatement extends JBlockStatement {
+    public JElseStatement() {
+        super();
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JEntity.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JEntity.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JEntity.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,71 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.generator;
+
+public class JEntity {
+    protected String _name;
+    protected int _modifiers;
+    protected JEntity _parent;
+
+    public JEntity(String name) {
+        this(name, 0);
+    }
+
+    public JEntity(String name, int modifiers) {
+        _name = name;
+        _modifiers = modifiers;
+    }
+
+    public JEntity getParent() {
+        return _parent;
+    }
+
+    public void setParent(JEntity parent) {
+        _parent = parent;
+    }
+
+    public String getName() {
+        return _name;
+    }
+
+    public void setName(String val) {
+        _name = val;
+    }
+
+    /*
+     * if value is true, then the modifier will be set,
+     * if value is false, then the modifier will be unset.
+     */
+    public void setModifier(int modifier, boolean value) {
+        if (value) {
+            _modifiers = (_modifiers | modifier);
+        } else {
+            if ((_modifiers & modifier) == modifier) {
+                _modifiers = (_modifiers ^ modifier);
+            }
+        }
+    }
+
+    public void setModifiers(int modifiers) {
+        _modifiers = modifiers;
+    }
+
+    public int getModifiers() {
+        return _modifiers;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JExpression.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JExpression.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JExpression.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,34 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.generator;
+
+public class JExpression extends JStatement {
+    protected JStatement _statement;
+
+    public JExpression(JStatement s) {
+        _statement = s;
+    }
+
+    public void setStatement(JStatement s) {
+        _statement = s;
+    }
+
+    public JStatement getStatement() {
+        return _statement;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JField.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JField.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JField.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,24 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.generator;
+
+public class JField extends JVariable {
+    protected JField(Class type, String name) {
+        super(type, name);
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JFinallyStatement.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JFinallyStatement.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JFinallyStatement.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,43 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.generator;
+
+
+
+
+public class JFinallyStatement extends JStatement {
+    protected JBlockStatement _finallyStatements;
+    protected boolean _hasStatements = false;
+
+    public JFinallyStatement() {
+        _finallyStatements = new JBlockStatement();
+    }
+
+    public void addStatement(JStatement s) {
+        _finallyStatements.addStatement(s);
+        _hasStatements = true;
+    }
+
+    public JBlockStatement getStatement() {
+        return _finallyStatements;
+    }
+
+    public boolean hasStatements() {
+        return _hasStatements;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JForStatement.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JForStatement.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JForStatement.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,46 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.generator;
+
+
+
+
+public class JForStatement extends JBlockStatement {
+    protected JStatement _initStmt;
+    protected JExpression _loopExpr;
+    protected JStatement _iterStmt;
+
+    public JForStatement(JStatement init, JExpression loop, JStatement iter) {
+        super();
+        _initStmt = init;
+        _loopExpr = loop;
+        _iterStmt = iter;
+    }
+
+    public JStatement getInitStatement() {
+        return _initStmt;
+    }
+
+    public JExpression getLoopExpression() {
+        return _loopExpr;
+    }
+
+    public JStatement getIterStatement() {
+        return _iterStmt;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JIfElseIfElseStatement.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JIfElseIfElseStatement.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JIfElseIfElseStatement.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,93 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.generator;
+
+import java.util.Vector;
+
+
+public class JIfElseIfElseStatement extends JStatement {
+    protected JIfStatement _ifStatement;
+    protected Vector _elseifStatements;
+    protected JElseStatement _elseStatement;
+
+    public JIfElseIfElseStatement(JExpression if_expr) {
+        _ifStatement = new JIfStatement(if_expr);
+        _elseifStatements = new Vector();
+        _elseStatement = new JElseStatement();
+    }
+
+    public void addIfStatement(JStatement s) {
+        _ifStatement.addStatement(s);
+    }
+
+    public JIfStatement getIfStatement() {
+        return _ifStatement;
+    }
+
+    public Vector getIfStatements() {
+        return _ifStatement.getStatements();
+    }
+
+    public void addElseStatement(JStatement s) {
+        _elseStatement.addStatement(s);
+    }
+
+    public JElseStatement getElseStatement() {
+        return _elseStatement;
+    }
+
+    public Vector getElseStatements() {
+        return _elseStatement.getStatements();
+    }
+
+    public JElseIfStatement getElseIf(JExpression e) {
+        JElseIfStatement rc = null;
+        int index = _elseifStatements.indexOf(e);
+
+        if (index >= 0) {
+            rc = (JElseIfStatement) _elseifStatements.get(index);
+        }
+
+        return rc;
+    }
+
+    public JElseIfStatement newElseIf(JExpression e) {
+        JElseIfStatement rc = getElseIf(e);
+
+        if (rc == null) {
+            rc = new JElseIfStatement(e);
+            _elseifStatements.add(rc);
+        }
+
+        return rc;
+    }
+
+    public void addCatchStatement(JExpression e, JStatement s) {
+        JElseIfStatement eis = getElseIf(e);
+
+        if (eis == null) {
+            eis = newElseIf(e);
+        }
+
+        eis.addStatement(s);
+    }
+
+    public Vector getElseIfs() {
+        return _elseifStatements;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JIfStatement.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JIfStatement.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JIfStatement.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,52 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.generator;
+
+public class JIfStatement extends JBlockStatement {
+    protected JExpression _expr;
+
+    public JIfStatement(JExpression e) {
+        super();
+        _expr = e;
+    }
+
+    public JExpression getExpression() {
+        return _expr;
+    }
+
+    public int hashCode() {
+        return _expr.hashCode();
+    }
+
+    public boolean equals(Object other) {
+        boolean rc = false;
+
+        if (this == other) {
+            rc = true;
+        } else if (other instanceof JIfStatement) {
+            JIfStatement is = (JIfStatement) other;
+
+            if (is._expr == _expr) {
+                // Todo: Need equals()
+                rc = true;
+            }
+        }
+
+        return rc;
+    }
+}
\ No newline at end of file

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JLocalVariable.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JLocalVariable.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JLocalVariable.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,24 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.generator;
+
+public class JLocalVariable extends JVariable {
+    protected JLocalVariable(Class type, String name) {
+        super(type, name);
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JMethod.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JMethod.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JMethod.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,133 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.generator;
+
+import java.lang.reflect.Modifier;
+import java.util.Vector;
+
+
+public class JMethod extends JEntity {
+    protected JReturnType _rt;
+    protected JParameter _parms[];
+    protected Class _thrown[];
+
+    protected Vector _statements;
+    protected JBlockStatement _bodyBlockStatement;
+
+    protected String _body;  // Yuck
+
+    protected JMethod(String name) {
+        super(name, Modifier.PUBLIC);
+
+        _statements = new Vector();
+        _bodyBlockStatement = new JBlockStatement();
+    }
+
+    protected JMethod(JReturnType rt, String name, JParameter parms[], Class thrown[]) {
+        this(name);
+
+        setRT(rt);
+        setParms(parms);
+        setThrown(thrown);
+    }
+
+    public void setRT(JReturnType jt) {
+        _rt = jt;
+    }
+
+    public JReturnType getRT() {
+        return _rt;
+    }
+
+    public void setParms(JParameter parms[]) {
+        _parms = parms;
+    }
+
+    public JParameter[] getParms() {
+        return _parms;
+    }
+
+    public void setThrown(Class thrown[]) {
+        _thrown = thrown;
+
+        /*
+        if (_thrown != null)
+        {
+            _thrownType = new String[_thrown.length];
+            int i;
+            for( i=0; i<_thrown.length; i++ )
+            {
+                _thrownType[i] = _thrown[i].getName();
+            }
+        }
+        else
+        {
+            _thrownType = null;
+        }
+        */
+    }
+
+    public Class[] getThrown() {
+        return _thrown;
+    }
+
+    /*
+    public void setThrownType( String thrownType[] )
+    {
+        _thrownType = thrownType;
+        _thrown = null;
+    }
+
+    public String[] getThrownType()
+    {
+        return _thrownType;
+    }
+    */
+
+    public void setBody(String body) {
+        _body = body;
+    }
+
+    public String getBody() {
+        return _body;
+    }
+
+    public JLocalVariable newLocalVariable(Class type, String name) {
+        return _bodyBlockStatement.newLocalVariable(type, name);
+    }
+
+    public JLocalVariable newLocalVariable(Class type, String name, JExpression initExpr) {
+        return _bodyBlockStatement.newLocalVariable(type, name, initExpr);
+    }
+
+    public void deleteLocalVariable(JLocalVariable f) {
+        _bodyBlockStatement.deleteLocalVariable(f);
+    }
+
+    public Vector getLocalVariables() {
+        return _bodyBlockStatement.getLocalVariables();
+    }
+
+    public void addStatement(JStatement s) {
+        _statements.add(s);
+    }
+
+    public Vector getStatements() {
+        return _statements;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JPackage.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JPackage.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JPackage.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,43 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.generator;
+
+import java.util.Vector;
+
+
+public class JPackage extends JEntity {
+    protected Vector _classes = new Vector();
+
+    public JPackage(String name) {
+        super(name);
+    }
+
+    public JClass newClass(String name) {
+        JClass c = new JClass(name, this);
+        _classes.add(c);
+        return c;
+    }
+
+    public void deleteClass(JClass c) {
+        _classes.removeElement(c);
+    }
+
+    public Vector getClasses() {
+        return _classes;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JParameter.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JParameter.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JParameter.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,24 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.generator;
+
+public class JParameter extends JVariable {
+    public JParameter(Class type, String name) {
+        super(type, name);
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JReturnType.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JReturnType.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JReturnType.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,89 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.generator;
+
+public class JReturnType {
+    protected Class _type;
+    protected String _typeName;
+    protected boolean _isArray;
+
+    public JReturnType(Class type) {
+        this(type, false);
+    }
+
+    public JReturnType(Class type, boolean isArray) {
+        _type = type;
+        _typeName = type.getName();
+        _isArray = isArray;
+    }
+
+    public JReturnType(String typeName) {
+        this(typeName, false);
+    }
+
+    public JReturnType(String typeName, boolean isArray) {
+        _typeName = typeName;
+        _isArray = isArray;
+
+        try {
+            _type = Class.forName(_typeName);
+        } catch (Exception e) {
+            // Ignore;
+        }
+    }
+
+    public void setType(Class type) {
+        _type = type;
+        _typeName = type.getName();
+    }
+
+    public Class getType() {
+        return _type;
+    }
+
+    public void setTypeName(String typeName) {
+        _type = null;
+        _typeName = typeName;
+    }
+
+    public String getTypeName() {
+        return _typeName;
+    }
+
+    public boolean isArray() {
+        return _isArray;
+    }
+
+    public int hashCode() {
+        return _type.hashCode();
+    }
+
+    public boolean equals(Object other) {
+        boolean rc = false;
+
+        if (other == this) {
+            rc = true;
+        } else if (other instanceof org.apache.geronimo.interop.generator.JReturnType) {
+            org.apache.geronimo.interop.generator.JReturnType jr = (org.apache.geronimo.interop.generator.JReturnType) other;
+
+            rc = jr._typeName.equals(_typeName);
+        }
+
+        return rc;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JStatement.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JStatement.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JStatement.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,23 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.generator;
+
+public class JStatement {
+    public JStatement() {
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JSwitchStatement.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JSwitchStatement.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JSwitchStatement.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,75 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.generator;
+
+import java.util.Vector;
+
+
+public class JSwitchStatement extends JStatement {
+    protected JExpression _switchExpr;
+    protected Vector _caseStatements;
+
+    public JSwitchStatement(JExpression e) {
+        _switchExpr = e;
+        _caseStatements = new Vector();
+    }
+
+    public void setVariable(JExpression e) {
+        _switchExpr = e;
+    }
+
+    public JExpression getExpression() {
+        return _switchExpr;
+    }
+
+    public JCaseStatement getCase(JExpression e) {
+        JCaseStatement rc = null;
+        int index = _caseStatements.indexOf(e);
+
+        if (index >= 0) {
+            rc = (JCaseStatement) _caseStatements.get(index);
+        }
+
+        return rc;
+    }
+
+    public JCaseStatement newCase(JExpression e) {
+        JCaseStatement rc = getCase(e);
+
+        if (rc == null) {
+            rc = new JCaseStatement(e);
+            _caseStatements.add(rc);
+        }
+
+        return rc;
+    }
+
+    public void addCaseStatement(JExpression e, JStatement s) {
+        JCaseStatement cs = getCase(e);
+
+        if (cs == null) {
+            cs = newCase(e);
+        }
+
+        cs.addStatement(s);
+    }
+
+    public Vector getCases() {
+        return _caseStatements;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JTryCatchFinallyStatement.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JTryCatchFinallyStatement.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JTryCatchFinallyStatement.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,85 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.generator;
+
+import java.util.Vector;
+
+
+public class JTryCatchFinallyStatement extends JStatement {
+    protected JTryStatement _TryStatement;
+    protected Vector _catchStatements;
+    protected JFinallyStatement _FinallyStatement;
+
+    public JTryCatchFinallyStatement() {
+        _TryStatement = new JTryStatement();
+        _catchStatements = new Vector();
+        _FinallyStatement = new JFinallyStatement();
+    }
+
+    public void addTryStatement(JStatement s) {
+        _TryStatement.addStatement(s);
+    }
+
+    public JTryStatement getTryStatement() {
+        return _TryStatement;
+    }
+
+    public JCatchStatement getCatch(JVariable v) {
+        JCatchStatement rc = null;
+        int index = _catchStatements.indexOf(v);
+
+        if (index >= 0) {
+            rc = (JCatchStatement) _catchStatements.get(index);
+        }
+
+        return rc;
+    }
+
+    public JCatchStatement newCatch(JVariable v) {
+        JCatchStatement rc = getCatch(v);
+
+        if (rc == null) {
+            rc = new JCatchStatement(v);
+            _catchStatements.add(rc);
+        }
+
+        return rc;
+    }
+
+    public void addCatchStatement(JVariable v, JStatement s) {
+        JCatchStatement cs = getCatch(v);
+
+        if (cs == null) {
+            cs = newCatch(v);
+        }
+
+        cs.addStatement(s);
+    }
+
+    public Vector getCatches() {
+        return _catchStatements;
+    }
+
+    public void addFinallyStatement(JStatement s) {
+        _FinallyStatement.addStatement(s);
+    }
+
+    public JFinallyStatement getFinallyStatement() {
+        return _FinallyStatement;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JTryStatement.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JTryStatement.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JTryStatement.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,54 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.generator;
+
+public class JTryStatement extends JBlockStatement {
+    public JTryStatement() {
+        super();
+    }
+}
+
+/*
+public class JTryStatement extends JStatement
+{
+    protected JBlockStatement    _tryStatements;
+
+    public JTryStatement( )
+    {
+        _tryStatements = new JBlockStatement();
+    }
+
+    public void addStatement( JStatement s )
+    {
+        if (s == _tryStatements ||
+            s.equals( _tryStatements ))
+        {
+            // Don't add it.
+            // Todo: Throw an exception?
+            return;
+        }
+
+        _tryStatements.addStatement( s );
+    }
+
+    public JBlockStatement getStatement()
+    {
+        return _tryStatements;
+    }
+}
+*/
\ No newline at end of file

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JVariable.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JVariable.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JVariable.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,169 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.generator;
+
+import java.util.HashMap;
+
+
+public class JVariable extends JEntity {
+    protected static HashMap _typeMap = new HashMap(60);
+
+    protected Class _type;
+    protected String _typeDecl;
+    protected JExpression _initExpr;
+    protected boolean _isArray;
+
+    public JVariable(Class type, String name) {
+        super(name);
+        setType(type);
+    }
+
+    public void setType(Class type) {
+        _type = type;
+        calculateTypeDecl();
+    }
+
+    public Class getType() {
+        return _type;
+    }
+
+    public String getTypeDecl() {
+        return _typeDecl;
+    }
+
+    public void setInitExpression(JExpression initExpr) {
+        _initExpr = initExpr;
+    }
+
+    public JExpression getInitExpression() {
+        return _initExpr;
+    }
+
+    public int hashCode() {
+        return _type.hashCode() + _name.hashCode();
+    }
+
+    public boolean equals(Object other) {
+        boolean rc = false;
+
+        if (other == this) {
+            rc = true;
+        } else if (other instanceof JVariable) {
+            JVariable v = (JVariable) other;
+
+            rc = v._type.equals(_type);
+        }
+
+        return rc;
+    }
+
+    protected void calculateTypeDecl() {
+        if (_type == null) {
+            return;
+        }
+
+        _typeDecl = (String) _typeMap.get(_type);
+
+        if (_typeDecl == null) {
+            synchronized (_typeMap) {
+                _typeDecl = _type.getName();
+
+                if (_type.isArray()) {
+                    _typeDecl = convertToTypeDecl(_typeDecl);
+                }
+
+                _typeMap.put(_type, _typeDecl);
+            }
+        }
+    }
+
+    protected String convertToTypeDecl(String typeName) {
+        String rc = "";
+        char charAt = 0;
+        int i;
+
+        if (typeName != null && typeName.length() > 0) {
+            for (i = 0; i < typeName.length(); i++) {
+                charAt = typeName.charAt(i);
+
+                if (charAt == '[') {
+                    rc = rc + "[]";
+                } else if (charAt == 'Z') {
+                    rc = "boolean" + rc;
+                } else if (charAt == 'B') {
+                    rc = "byte" + rc;
+                } else if (charAt == 'C') {
+                    rc = "char" + rc;
+                } else if (charAt == 'L') {
+                    int semiIndex = typeName.indexOf(";");
+                    rc = typeName.substring(i + 1, semiIndex) + rc;
+                    i = semiIndex;
+                } else if (charAt == 'D') {
+                    rc = "double" + rc;
+                } else if (charAt == 'F') {
+                    rc = "float" + rc;
+                } else if (charAt == 'I') {
+                    rc = "int" + rc;
+                } else if (charAt == 'J') {
+                    rc = "long" + rc;
+                } else if (charAt == 'S') {
+                    rc = "short" + rc;
+                } else {
+                    System.out.println("Error: Invalid signature. typeName = " + typeName + ", charAt = " + charAt + ", i = " + i);
+                }
+            }
+        }
+
+        return rc;
+    }
+
+    protected void showTypeInfo() {
+        System.out.println("getName() = " + _type.getName());
+        System.out.println("\tisArray()     = " + _type.isArray());
+        System.out.println("\tisPrimitive() = " + _type.isPrimitive());
+        System.out.println("\ttoString()    = " + _type.toString());
+        System.out.println("\ttypeDecl      = " + getTypeDecl());
+        System.out.println("");
+    }
+
+    protected void validateDeclType(String t) {
+        String ct = getTypeDecl();
+        if (!t.equals(ct)) {
+            System.out.println("Class Decl Type: '" + ct + "' does not match expected type: '" + t + "'");
+        }
+    }
+
+    public static void main(String args[])
+            throws Exception {
+        (new JVariable(java.lang.String.class, "v")).showTypeInfo();
+        (new JVariable(java.lang.String[].class, "v")).showTypeInfo();
+        (new JVariable(java.lang.String[][].class, "v")).showTypeInfo();
+
+        (new JVariable(int.class, "v")).showTypeInfo();
+        (new JVariable(int[].class, "v")).showTypeInfo();
+        (new JVariable(int[][].class, "v")).showTypeInfo();
+
+        (new JVariable(java.lang.String.class, "v")).validateDeclType("java.lang.String");
+        (new JVariable(java.lang.String[].class, "v")).validateDeclType("java.lang.String[]");
+        (new JVariable(java.lang.String[][].class, "v")).validateDeclType("java.lang.String[][]");
+
+        (new JVariable(int.class, "v")).validateDeclType("int");
+        (new JVariable(int[].class, "v")).validateDeclType("int[]");
+        (new JVariable(int[][].class, "v")).validateDeclType("int[][]");
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JavaGenerator.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JavaGenerator.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JavaGenerator.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,467 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.generator;
+
+import java.io.File;
+import java.lang.reflect.Modifier;
+import java.util.Vector;
+
+
+public class JavaGenerator implements Generator {
+    protected GenOptions _genOptions;
+
+    public JavaGenerator(GenOptions genOptions) {
+        _genOptions = genOptions;
+    }
+
+    public GenOptions getGenOptions() {
+        return _genOptions;
+    }
+
+    public void setGenOptions(GenOptions genOptions) {
+        _genOptions = genOptions;
+    }
+
+    public void generate(JEntity e) {
+        // Meaningless
+    }
+
+    public void generate(JPackage p)
+            throws GenException {
+        if (p == null) {
+            return;
+        }
+
+        Vector v = p.getClasses();
+
+        if (v != null && v.size() > 0) {
+            int i;
+            for (i = 0; i < v.size(); i++) {
+                generate((JClass) v.elementAt(i));
+            }
+        }
+    }
+
+    public void generate(JClass c)
+            throws GenException {
+        if (c == null) {
+            return;
+        }
+
+        String className = c.getName();
+        String pkgName = c.getPackage().getName();
+
+        pkgName = pkgName.replace('.', File.separatorChar);
+
+        String fullName = pkgName + "/" + className;
+
+        JavaWriter jw = new JavaWriter(_genOptions, fullName, ".java");
+
+        jw.openFile();
+        writeClass(jw, c);
+        jw.closeFile();
+    }
+
+    protected void writeClass(JavaWriter jw, JClass c) {
+        writeClassPackage(jw, c);
+        writeClassImports(jw, c);
+
+        writeClassClassDefn(jw, c);
+        jw.begin();
+        writeClassFields(jw, c);
+        writeClassConstructors(jw, c);
+        writeClassMethods(jw, c);
+        jw.end();
+    }
+
+    protected void writeClassPackage(JavaWriter jw, JClass c) {
+        if (c.getPackage().getName().length() > 0) {
+            jw.newln();
+            jw.println("package " + c.getPackage().getName() + ";");
+        }
+    }
+
+    protected void writeClassImports(JavaWriter jw, JClass c) {
+        Vector v = c.getImports();
+        if (v != null && v.size() > 0) {
+            int i;
+
+            jw.newln();
+
+            for (i = 0; i < v.size(); i++) {
+                jw.println("import " + v.elementAt(i) + ";");
+            }
+        }
+    }
+
+    protected void writeClassClassDefn(JavaWriter jw, JClass c) {
+        jw.newln();
+
+        writeModifiers(jw, c.getModifiers());
+        jw.println("class " + c.getName());
+
+        if (c.getExtends() != null && c.getExtends().length() > 0) {
+            jw.indent();
+            jw.println("extends " + c.getBaseClassName());
+            jw.outdent();
+        }
+
+        Vector v = c.getImplements();
+        if (v != null && v.size() > 0) {
+            int i;
+
+            jw.indent();
+            jw.print("implements ");
+            jw.outdent();
+
+            for (i = 0; i < v.size(); i++) {
+                jw.print("" + v.elementAt(i));
+
+                if (i + 1 != v.size()) {
+                    jw.print(", ");
+                }
+            }
+            jw.println("");
+        }
+    }
+
+    protected void writeClassFields(JavaWriter jw, JClass c) {
+        Vector v = c.getFields();
+        if (v != null && v.size() > 0) {
+            jw.comment("");
+            jw.comment("Fields");
+            jw.comment("");
+
+            int i;
+            JField f;
+            for (i = 0; i < v.size(); i++) {
+                f = (JField) v.elementAt(i);
+                writeClassField(jw, c, f);
+            }
+        }
+    }
+
+    protected void writeClassField(JavaWriter jw, JClass c, JField f) {
+        writeModifiers(jw, f.getModifiers());
+        jw.print(f.getTypeDecl() + " " + f.getName());
+
+        if (f.getInitExpression() != null) {
+            jw.print(" = ");
+            writeExpression(jw, f.getInitExpression());
+        }
+
+        jw.println(";");
+    }
+
+    protected void writeClassConstructors(JavaWriter jw, JClass c) {
+        Vector v = c.getConstructors();
+        if (v != null && v.size() > 0) {
+            int i;
+            JMethod m;
+
+            jw.newln();
+
+            jw.comment("");
+            jw.comment("Constructors");
+            jw.comment("");
+
+            for (i = 0; i < v.size(); i++) {
+                m = (JMethod) v.elementAt(i);
+                writeClassMethod(jw, c, m);
+            }
+        }
+    }
+
+    protected void writeClassMethods(JavaWriter jw, JClass c) {
+        Vector v = c.getMethods();
+        if (v != null && v.size() > 0) {
+            int i;
+            JMethod m;
+
+            jw.newln();
+
+            jw.comment("");
+            jw.comment("Methods");
+            jw.comment("");
+
+            for (i = 0; i < v.size(); i++) {
+                jw.newln();
+                m = (JMethod) v.elementAt(i);
+                writeClassMethod(jw, c, m);
+            }
+        }
+    }
+
+    protected void writeClassMethod(JavaWriter jw, JClass c, JMethod m) {
+        writeModifiers(jw, m.getModifiers());
+
+        if (m instanceof JConstructor) {
+            jw.print(c.getName());
+        } else {
+            //jw.print( m.getRCType() + " " + m.getName() );
+            jw.print(m.getRT().getTypeName());
+
+            if (m.getRT().isArray()) {
+                jw.print("[]");
+            }
+
+            jw.print(" " + m.getName());
+        }
+        jw.print("(");
+
+        JParameter p[] = m.getParms();
+        if (p != null && p.length > 0) {
+            int i;
+            for (i = 0; i < p.length; i++) {
+                jw.print(" " + p[i].getTypeDecl() + " " + p[i].getName());
+
+                if (i + 1 != p.length) {
+                    jw.print(",");
+                }
+            }
+        }
+
+        jw.print(" )");
+
+        //String s[] = m.getThrownType();
+        Class s[] = m.getThrown();
+        if (s != null && s.length > 0) {
+            int i;
+
+            jw.print(" throws ");
+
+            for (i = 0; i < s.length; i++) {
+                jw.print(s[i].getName());
+
+                if (i + 1 != s.length) {
+                    jw.print(", ");
+                }
+            }
+        }
+        jw.println("");
+
+        jw.begin();
+        writeLocalVariables(jw, m.getLocalVariables());
+        writeStatements(jw, m.getStatements());
+
+        if (m.getBody() != null && m.getBody().length() > 0) {
+            jw.println(m.getBody());
+        }
+        jw.end();
+    }
+
+    protected void writeLocalVariables(JavaWriter jw, Vector lv) {
+        if (lv != null && lv.size() > 0) {
+            int i;
+            for (i = 0; i < lv.size(); i++) {
+                writeLocalVariable(jw, (JLocalVariable) lv.elementAt(i));
+            }
+        }
+    }
+
+    protected void writeLocalVariable(JavaWriter jw, JLocalVariable lv) {
+        jw.print(lv.getTypeDecl() + " " + lv.getName());
+
+        if (lv.getInitExpression() != null) {
+            jw.print(" = ");
+            writeExpression(jw, lv.getInitExpression());
+        }
+
+        jw.println(";");
+    }
+
+    protected void writeStatements(JavaWriter jw, Vector sv) {
+        if (sv != null && sv.size() > 0) {
+            int i;
+            for (i = 0; i < sv.size(); i++) {
+                writeStatement(jw, (JStatement) sv.elementAt(i));
+            }
+        }
+    }
+
+    protected void writeModifiers(JavaWriter jw, int m) {
+        String s = Modifier.toString(m);
+
+        if (s != null && s.length() > 0) {
+            jw.print(s + " ");
+        }
+    }
+
+    protected void writeStatement(JavaWriter jw, JStatement s) {
+        if (s instanceof JCaseStatement) {
+            writeCaseStatement(jw, (JCaseStatement) s);
+        } else if (s instanceof JCatchStatement) {
+            writeCatchStatement(jw, (JCatchStatement) s);
+        } else if (s instanceof JCodeStatement) {
+            writeCodeStatement(jw, (JCodeStatement) s, true);
+        } else if (s instanceof JDeclareStatement) {
+            writeDeclareStatement(jw, (JDeclareStatement) s);
+        } else if (s instanceof JElseStatement) {
+            writeElseStatement(jw, (JElseStatement) s);
+        } else if (s instanceof JElseIfStatement) {
+            writeElseIfStatement(jw, (JElseIfStatement) s);
+        } else if (s instanceof JIfElseIfElseStatement) {
+            writeIfElseIfElseStatement(jw, (JIfElseIfElseStatement) s);
+        } else if (s instanceof JFinallyStatement) {
+            writeFinallyStatement(jw, (JFinallyStatement) s);
+        } else if (s instanceof JForStatement) {
+            writeForStatement(jw, (JForStatement) s);
+        } else if (s instanceof JIfStatement) {
+            writeIfStatement(jw, (JIfStatement) s);
+        } else if (s instanceof JTryCatchFinallyStatement) {
+            writeTryCatchFinallyStatement(jw, (JTryCatchFinallyStatement) s);
+        } else if (s instanceof JSwitchStatement) {
+            writeSwitchStatement(jw, (JSwitchStatement) s);
+        } else if (s instanceof JTryStatement) {
+            writeTryStatement(jw, (JTryStatement) s);
+        } else if (s instanceof JBlockStatement) {
+            // BlockStatemnet should be last since there are other subclasses of it.
+            writeBlockStatement(jw, (JBlockStatement) s);
+        } else {
+            jw.comment("");
+            jw.comment("Error: Unknown statement: " + s);
+            jw.comment("");
+        }
+    }
+
+    protected void writeBlockStatement(JavaWriter jw, JBlockStatement bs) {
+        jw.begin();
+        writeLocalVariables(jw, bs.getLocalVariables());
+        writeStatements(jw, bs.getStatements());
+        jw.end();
+    }
+
+    protected void writeCaseStatement(JavaWriter jw, JCaseStatement cs) {
+        jw.print("case ");
+        writeExpression(jw, cs.getExpression());
+        jw.println(":");
+        writeStatement(jw, cs.getStatement());
+        jw.println("break;");
+    }
+
+    protected void writeCatchStatement(JavaWriter jw, JCatchStatement cs) {
+        jw.println("catch( " + cs.getVariable().getTypeDecl() + " " + cs.getVariable().getName() + " )");
+        writeBlockStatement(jw, cs);
+        //writeStatement( jw, cs.getStatement() );
+    }
+
+    protected void writeCodeStatement(JavaWriter jw, JCodeStatement cs, boolean newLine) {
+        jw.print(cs.getCode());
+
+        if (newLine) {
+            jw.newln();
+        }
+
+        //jw.print( cs.getCode() );
+        //jw.println( ";" );
+    }
+
+    protected void writeDeclareStatement(JavaWriter jw, JDeclareStatement ds) {
+        JVariable v = ds.getVariable();
+        jw.print(v.getTypeDecl() + " " + v.getName());
+
+        JExpression e = ds.getInitExpression();
+        if (e != null) {
+            jw.print(" = ");
+            writeExpression(jw, e);
+        }
+
+        jw.println(";");
+    }
+
+    protected void writeElseStatement(JavaWriter jw, JElseStatement es) {
+        if (es.hasStatements()) {
+            jw.println("else");
+            writeBlockStatement(jw, es);
+        }
+    }
+
+    protected void writeElseIfStatement(JavaWriter jw, JElseIfStatement eis) {
+        if (eis.hasStatements()) {
+            jw.print("else ");
+            writeIfStatement(jw, eis);
+        }
+    }
+
+    protected void writeIfElseIfElseStatement(JavaWriter jw, JIfElseIfElseStatement ies) {
+        writeIfStatement(jw, ies.getIfStatement());
+    }
+
+    protected void writeExpression(JavaWriter jw, JExpression e) {
+        // TODO: not sure how I am going to do this but...
+
+        if (e.getStatement() instanceof JCodeStatement) {
+            JCodeStatement cs = (JCodeStatement) e.getStatement();
+            writeCodeStatement(jw, cs, false);
+            //jw.print( cs.getCode() );
+        } else {
+            writeStatement(jw, e.getStatement());
+        }
+    }
+
+    protected void writeFinallyStatement(JavaWriter jw, JFinallyStatement fs) {
+        if (fs.hasStatements()) {
+            jw.println("finally");
+            writeStatement(jw, fs.getStatement());
+        }
+    }
+
+    protected void writeForStatement(JavaWriter jw, JForStatement fs) {
+        jw.newln();
+        jw.print("for (");
+        writeStatement(jw, fs.getInitStatement());
+        jw.print(";");
+        writeExpression(jw, fs.getLoopExpression());
+        writeStatement(jw, fs.getIterStatement());
+        jw.println(")");
+        writeBlockStatement(jw, fs);
+        //writeBlockStatement( jw, fs.getStatement() );
+    }
+
+    protected void writeIfStatement(JavaWriter jw, JIfStatement is) {
+        jw.newln();
+        jw.print("if (");
+        writeExpression(jw, is.getExpression());
+        jw.println(")");
+        writeBlockStatement(jw, is);
+    }
+
+    protected void writeSwitchStatement(JavaWriter jw, JSwitchStatement ss) {
+        jw.newln();
+        jw.print("switch (");
+        writeExpression(jw, ss.getExpression());
+        jw.println(")");
+        jw.begin();
+        writeStatements(jw, ss.getCases());
+        jw.end();
+    }
+
+    protected void writeTryCatchFinallyStatement(JavaWriter jw, JTryCatchFinallyStatement tcfs) {
+        writeStatement(jw, tcfs.getTryStatement());
+        writeStatements(jw, tcfs.getCatches());
+        writeStatement(jw, tcfs.getFinallyStatement());
+    }
+
+    protected void writeTryStatement(JavaWriter jw, JTryStatement ts) {
+        jw.println("");
+        jw.println("try");
+        writeBlockStatement(jw, ts);
+        //writeStatement( jw, ts.getStatement() );
+    }
+
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JavaWriter.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JavaWriter.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/JavaWriter.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,180 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.generator;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+
+
+public class JavaWriter extends CodeWriter {
+    protected GenOptions _genOptions;
+
+    protected PrintWriter _pw;
+
+    protected boolean _needIndent = true;
+    protected int _indentPos = 0;
+    protected String _indentStr = "";
+    protected String _spaces = "                                                        ";
+
+    public JavaWriter(GenOptions genOptions, String fileName, String ext) {
+        super(genOptions, fileName, ext);
+    }
+
+    protected File getFile()
+            throws GenException {
+        File file = null;
+        GenOptions go = getGenOptions();
+        String fileName = getFileName() + getFileExt();
+
+        try {
+            file = new File(go.getGenDir(), fileName);
+
+            if (file.exists() && !go.isOverwrite()) {
+                fileName = fileName + ".new";
+
+                file = new File(go.getGenDir(), fileName);
+            }
+        } catch (Exception ex) {
+            throw new GenException("Error: Unable to open output dir: " + go.getGenDir() + ", file: " + fileName, ex);
+        }
+
+        return file;
+    }
+
+    public void openFile()
+            throws GenException {
+        OutputStream os = null;
+
+        if (_file != null) {
+            //System.out.println( "Output file already opened" );
+            return;
+        }
+
+        _file = getFile();
+
+        if (_file == null) {
+            throw new GenException("Error: Unable to obtain output file.");
+        }
+
+        if (getGenOptions().isVerbose()) {
+            System.out.println("Generating: " + _file);
+        }
+
+        os = null;
+
+        //if (_file.isFile())
+        //{
+        _file.getParentFile().mkdirs();
+        //}
+
+        if (_file.exists() && !_file.canWrite()) {
+            throw new GenException("Error: Unable to write to file: " + _file);
+        }
+
+        if (!_file.exists() && !_file.getParentFile().canWrite()) {
+            throw new GenException("Error: Unable to write to directory: " + _file.getParentFile());
+        }
+
+        try {
+            os = new FileOutputStream(_file);
+        } catch (Exception ex) {
+            throw new GenException("Error: Unable to init output file: " + _file, ex);
+        }
+
+        try {
+            _pw = new PrintWriter(new OutputStreamWriter(os));
+        } catch (Exception ex) {
+            throw new GenException("Error: Unable to init output file: " + _file, ex);
+        }
+    }
+
+    public void closeFile()
+            throws GenException {
+        if (_pw != null) {
+            try {
+                _pw.flush();
+                _pw.close();
+            } catch (Exception e) {
+                throw new GenException("Error: Unable to close output file: " + _file, e);
+            }
+
+            _pw = null;
+        }
+
+        _file = null;
+    }
+
+    public void indent() {
+        _indentPos += 4;
+        if (_indentPos > _spaces.length()) {
+            _indentPos -= 4;
+        }
+        _indentStr = _spaces.substring(0, _indentPos);
+    }
+
+    public void outdent() {
+        _indentPos -= 4;
+        if (_indentPos < 0) {
+            _indentPos = 0;
+        }
+        _indentStr = _spaces.substring(0, _indentPos);
+    }
+
+    public void begin() {
+        _needIndent = true;
+        println("{");
+        indent();
+    }
+
+    public void end() {
+        outdent();
+        _needIndent = true;
+        println("}");
+    }
+
+    public void newln() {
+        println("");
+        _needIndent = true;
+    }
+
+    public void comment(String msg) {
+        println("// " + msg);
+    }
+
+    public void println(String line) {
+        if (_needIndent) {
+            _needIndent = false;
+            _pw.print(_indentStr);
+        }
+
+        _pw.println(line);
+        _needIndent = true;
+    }
+
+    public void print(String line) {
+        if (_needIndent) {
+            _needIndent = false;
+            _pw.print(_indentStr);
+        }
+
+        _pw.print(line);
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/readme.txt
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/readme.txt?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/generator/readme.txt	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,9 @@
+The generator directory is a basic code generator that will be able to generate java source code or byte
+code from the same input (instructions).  The idea behind this was that code could be generated via
+statements which could then be written as java source or byte code.
+
+Todo:
+
+    - create two subpackages:
+        - java      - Impl of the code writer for .java
+        - class     - Impl of the code writer for .class
\ No newline at end of file

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/naming/InitialContext.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/naming/InitialContext.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/naming/InitialContext.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,175 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.naming;
+
+import java.util.HashMap;
+import java.util.Hashtable;
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NameParser;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.OperationNotSupportedException;
+
+
+public class InitialContext implements Context, java.io.Serializable {
+    private static HashMap EMPTY_MAP = new HashMap();
+    private String _prefix;
+
+    InitialContext(String prefix) {
+        _prefix = prefix;
+    }
+
+    public HashMap getMap() {
+        NamingContext namingContext = NamingContext.getCurrent();
+        if (namingContext == null) {
+            return EMPTY_MAP;
+        } else {
+            return namingContext.getMap();
+        }
+    }
+
+    public Object lookup(Name name) throws NamingException {
+        return lookup(name.toString());
+    }
+
+    public Object lookup(String name) throws NamingException {
+        NamingContext namingContext = NamingContext.getCurrent();
+        if (namingContext == null) {
+            namingContext = NamingContext.getInstance(NameService.class);
+        }
+        return namingContext.lookup(name, _prefix);
+    }
+
+    public Object lookupReturnNullIfNotFound(String name) {
+        NamingContext namingContext = NamingContext.getCurrent();
+        if (namingContext == null) {
+            return null;
+        } else {
+            return namingContext.lookupReturnNullIfNotFound(name, _prefix);
+        }
+    }
+
+    public void bind(Name name, Object obj) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public void bind(String name, Object obj) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public void rebind(Name name, Object obj) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public void rebind(String name, Object obj) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public void unbind(Name name) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public void unbind(String name) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public void rename(Name oldName, Name newName) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public void rename(String oldName, String newName) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public NamingEnumeration list(Name name) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public NamingEnumeration list(String name) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public NamingEnumeration listBindings(Name name) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public NamingEnumeration listBindings(String name) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public void destroySubcontext(Name name) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public void destroySubcontext(String name) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public Context createSubcontext(Name name) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public Context createSubcontext(String name) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public Object lookupLink(Name name) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public Object lookupLink(String name) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public NameParser getNameParser(Name name) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public NameParser getNameParser(String name) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public Name composeName(Name name, Name prefix) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public String composeName(String name, String prefix) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public Object addToEnvironment(String propName, Object propVal) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public Object removeFromEnvironment(String propName) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public Hashtable getEnvironment() throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public String getNameInNamespace() throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public void close() throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/naming/InitialContextFactory.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/naming/InitialContextFactory.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/naming/InitialContextFactory.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,28 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.naming;
+
+import java.util.Hashtable;
+
+
+public class InitialContextFactory
+        implements javax.naming.spi.InitialContextFactory {
+    public javax.naming.Context getInitialContext(Hashtable env) {
+        return new org.apache.geronimo.interop.naming.InitialContext(null);
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/naming/NameService.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/naming/NameService.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/naming/NameService.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,66 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.naming;
+
+import java.util.HashMap;
+import javax.naming.NamingException;
+
+import org.apache.geronimo.interop.adapter.Adapter;
+
+
+public class NameService {
+    protected static NameService _ns = null;
+
+    public static NameService getInstance() {
+        if (_ns == null) {
+            synchronized (NameService.class) {
+                if (_ns == null) {
+                    _ns = new NameService();
+                    _ns.init();
+                }
+            }
+        }
+
+        return _ns;
+    }
+
+    private org.apache.geronimo.interop.naming.InitialContext _context;
+
+    /*
+     * TODO: Do we need this method?
+     */
+    public void bindAdapter(Adapter adp) {
+        NamingContext.getInstance(NameService.class).bindAdapter(adp);
+    }
+
+    public static org.apache.geronimo.interop.naming.InitialContext getInitialContext() {
+        return getInstance()._context;
+    }
+
+    public HashMap getMap() {
+        return _context.getMap();
+    }
+
+    public Object lookup(String name) throws NamingException {
+        return _context.lookup(name);
+    }
+
+    protected void init() {
+        _context = new org.apache.geronimo.interop.naming.InitialContext(null);
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/naming/NameServiceLog.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/naming/NameServiceLog.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/naming/NameServiceLog.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,84 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.naming;
+
+public class NameServiceLog {
+    public static NameServiceLog getInstance() {
+        return new NameServiceLog();
+    }
+
+    public String infoBind(String context, String name, String value) {
+        String msg;
+        msg = "NSL.infoBind: context: " + context + ", name: + " + name + ", value: " + value;
+        return msg;
+    }
+
+    public String warnAmbiguousBinding(String context, String name, String interfaceName) {
+        String msg;
+        msg = "NSL.warnAmbiguousBinding: context: " + context + ", name: + " + name + ", interfaceName: " + interfaceName;
+        return msg;
+    }
+
+    public String warnAmbiguousPattern(String context, String name, String pattern) {
+        String msg;
+        msg = "NSL.warnAmbiguousPattern: context: " + context + ", name: + " + name + ", pattern: " + pattern;
+        return msg;
+    }
+
+    public String warnBindFailed(String context, String name, String value, Exception ex) {
+        String msg;
+        msg = "NSL.warnBindFailed: context: " + context + ", name: + " + name + ", ex: " + ex;
+        return msg;
+    }
+
+    public String warnIllegalBindValue(String context, Class type, String name, String value) {
+        String msg;
+        msg = "NSL.warnBindValue: context: " + context + ", type: + " + type + ", name: " + name + ", value: " + value;
+        return msg;
+    }
+
+    public String warnNameNotFound(String context, Exception notFound) {
+        String msg;
+        msg = "NSL.warnNameNotFound: context: " + context + ", notFound: " + notFound;
+        return msg;
+    }
+
+    public String warnNoComponentsForInterface(String context, String name, String interfaceName) {
+        String msg;
+        msg = "NSL.warnNoComponentForInterface: context: " + context + ", name: + " + name + ", interfaceName: " + interfaceName;
+        return msg;
+    }
+
+    public String warnNoComponentsMatchPattern(String context, String name, String pattern) {
+        String msg;
+        msg = "NSL.warnNoComponentsMatchPattern: context: " + context + ", name: + " + name + ", pattern: " + pattern;
+        return msg;
+    }
+
+    public String warnNoCurrentContext(String exception) {
+        String msg;
+        msg = "NSL.infoNoCurrentContext: exception: " + exception;
+        return msg;
+    }
+
+    public String warnObjectHasNoRemoteInterface(String lookupName, String className) {
+        String msg;
+        msg = "NSL.warnObjectHasNoRemoteInterface: lookupName: " + lookupName + ", className: + " + className;
+        return msg;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/naming/NamingContext.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/naming/NamingContext.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/naming/NamingContext.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,150 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.naming;
+
+import java.util.HashMap;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+
+import org.apache.geronimo.interop.adapter.Adapter;
+
+
+public class NamingContext {
+    public static final NamingContext getInstance(Class baseClass) {
+        NamingContext context;
+        synchronized (_contextMap) {
+            context = (NamingContext) _contextMap.get(baseClass);
+            if (context == null) {
+                context = new NamingContext();
+                _contextMap.put(baseClass, context);
+                context.init(baseClass);
+            }
+        }
+        return context;
+    }
+
+    private static ThreadLocal _current = new ThreadLocal();
+    private static HashMap _contextMap = new HashMap();
+    private static boolean _quiet = false; // TODO: Configure
+    private static boolean _verbose = true; // TODO: Configure
+    private String _logContext;
+    private HashMap _map = new HashMap();
+
+    public static final NamingContext getCurrent() {
+        return (NamingContext) _current.get();
+    }
+
+    public static final NamingContext push(NamingContext that) {
+        NamingContext restore = getCurrent();
+        _current.set(that);
+        return restore;
+    }
+
+    public static void pop(NamingContext restore) {
+        _current.set(restore);
+    }
+
+    public HashMap getMap() {
+        return _map;
+    }
+
+    public Object lookup(String name, String prefix) throws NamingException {
+        if (prefix != null) {
+            name += prefix + "/" + name;
+        }
+
+        // Note: this part of the method is performance critical. Please
+        // refrain from using string concatenation, synchronization and
+        // other slow calls here. All possible initialization should
+        // be performed in 'init' so as to permit this method to be as
+        // fast as possible (i.e. a simple unsynchronized HashMap lookup).
+
+        Object value = _map.get(name);
+
+        if (value == null) {
+            value = dynamicLookup(name);
+            if (value != null) {
+                _map.put(name, value); // TODO: allow refresh.
+            }
+        }
+
+        if (value == null) {
+            NameNotFoundException notFound = new NameNotFoundException(name.length() == 0 ? formatEmptyName() : name);
+            if (!_quiet) {
+                NameServiceLog.getInstance().warnNameNotFound(_logContext, notFound);
+            }
+            throw notFound;
+        } else {
+            return value;
+        }
+    }
+
+    public Object lookupReturnNullIfNotFound(String name, String prefix) {
+        if (prefix != null) {
+            name += prefix + "/" + name;
+        }
+        return _map.get(name);
+    }
+
+    protected void init(Class baseClass) {
+        // TODO: Nothing really to do as this would init all the env-prop res-ref ... from a component
+        //       this logic isn't required for the CORBA container.
+    }
+
+    protected void bindAdapter(Adapter adp) {
+        _map.put(adp.getBindName(), adp);
+    }
+
+    protected boolean adapterExists(String name) {
+        System.out.println("TODO: NamingComponent.componentExists(): name = " + name);
+
+        //String propsFileName = SystemProperties.getRepository() + "/Component/" + name.replace('.', '/') + ".properties";
+        //return new java.io.File(propsFileName).exists();
+
+        return false;
+    }
+
+    protected Object dynamicLookup(String name) {
+        return null;
+    }
+
+    /*
+    protected List getComponentsForInterface(String interfaceName)
+    {
+        return null;
+    }
+    */
+
+    /*
+    protected String resolveComponent(String name, String pattern)
+    {
+        return "";
+    }
+    */
+
+    /*
+    protected void copyObjectsWithRemoteInterface(final HashMap intoMap)
+    {
+    }
+    */
+
+    protected String formatEmptyName() {
+        return "formatEmptyName:";
+    }
+
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/BooleanProperty.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/BooleanProperty.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/BooleanProperty.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,88 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.properties;
+
+public class BooleanProperty extends PropertyType {
+    private boolean _defaultValue = false;
+
+    public BooleanProperty(Class componentClass, String propertyName) {
+        super(componentClass, propertyName);
+    }
+
+    public BooleanProperty displayName(String displayName) {
+        setDisplayName(displayName);
+        return this;
+    }
+
+    public BooleanProperty displayOnlyIf(PropertyType other, String value) {
+        setDisplayOnlyIf(other, value);
+        return this;
+    }
+
+    public BooleanProperty description(String description) {
+        setDescription(description);
+        return this;
+    }
+
+    public BooleanProperty consoleHelp(String consoleHelp) {
+        setConsoleHelp(consoleHelp);
+        return this;
+    }
+
+    public BooleanProperty sortOrder(int sortOrder) {
+        setSortOrder(sortOrder);
+        return this;
+    }
+
+    public BooleanProperty defaultValue(boolean defaultValue) {
+        _defaultValue = defaultValue;
+        return this;
+    }
+
+    public boolean getDefaultValue() {
+        return _defaultValue;
+    }
+
+    public String getDefaultValueAsString() {
+        return String.valueOf(_defaultValue);
+    }
+
+    public boolean getBoolean() {
+        return getBoolean(null, getComponentProperties());
+    }
+
+    public boolean getBoolean(String instanceName, PropertyMap props) {
+        boolean b;
+        boolean ok = true;
+        String value = props.getProperty(_propertyName, String.valueOf(_defaultValue));
+        value = value.toLowerCase();
+        if (value.equals("true")) {
+            b = true;
+        } else if (value.equals("false")) {
+            b = false;
+        } else {
+            ok = false;
+            b = false;
+        }
+        if (!ok) {
+            badPropertyValue(instanceName, value, expectedTrueOrFalse());
+        }
+        logPropertyValue(instanceName, value, b == _defaultValue);
+        return b;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/ByteProperty.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/ByteProperty.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/ByteProperty.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,110 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.properties;
+
+public class ByteProperty extends PropertyType {
+    private byte _defaultValue = 0;
+
+    private byte _minimumValue = 0;
+
+    private byte _maximumValue = Byte.MAX_VALUE;
+
+    public ByteProperty(Class componentClass, String propertyName) {
+        super(componentClass, propertyName);
+    }
+
+    public ByteProperty displayName(String displayName) {
+        setDisplayName(displayName);
+        return this;
+    }
+
+    public ByteProperty displayOnlyIf(PropertyType other, String value) {
+        setDisplayOnlyIf(other, value);
+        return this;
+    }
+
+    public ByteProperty description(String description) {
+        setDescription(description);
+        return this;
+    }
+
+    public ByteProperty consoleHelp(String consoleHelp) {
+        setConsoleHelp(consoleHelp);
+        return this;
+    }
+
+    public ByteProperty sortOrder(int sortOrder) {
+        setSortOrder(sortOrder);
+        return this;
+    }
+
+    public ByteProperty defaultValue(byte defaultValue) {
+        _defaultValue = defaultValue;
+        return this;
+    }
+
+    public ByteProperty minimumValue(byte minimumValue) {
+        _minimumValue = minimumValue;
+        return this;
+    }
+
+    public ByteProperty maximumValue(byte maximumValue) {
+        _maximumValue = maximumValue;
+        return this;
+    }
+
+    public byte getDefaultValue() {
+        return _defaultValue;
+    }
+
+    public String getDefaultValueAsString() {
+        return String.valueOf(_defaultValue);
+    }
+
+    public byte getMinimumValue() {
+        return _minimumValue;
+    }
+
+    public byte getMaximumValue() {
+        return _maximumValue;
+    }
+
+    public byte getByte() {
+        return getByte(null, getComponentProperties());
+    }
+
+    public byte getByte(String instanceName, PropertyMap props) {
+        byte n;
+        boolean ok = true;
+        String value = props.getProperty(_propertyName, String.valueOf(_defaultValue));
+        try {
+            n = Byte.parseByte(value);
+        } catch (NumberFormatException ex) {
+            ok = false;
+            n = 0;
+        }
+        if (n < _minimumValue || n > _maximumValue) {
+            ok = false;
+        }
+        if (!ok) {
+            badPropertyValue(instanceName, value, expectedNumberInRange(_minimumValue, _maximumValue));
+        }
+        logPropertyValue(instanceName, value, n == _defaultValue);
+        return n;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/DoubleProperty.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/DoubleProperty.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/DoubleProperty.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,113 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.properties;
+
+
+
+
+public class DoubleProperty extends PropertyType {
+    private double _defaultValue = 0;
+
+    private double _minimumValue = 0;
+
+    private double _maximumValue = Double.MAX_VALUE;
+
+    public DoubleProperty(Class componentClass, String propertyName) {
+        super(componentClass, propertyName);
+    }
+
+    public DoubleProperty displayName(String displayName) {
+        setDisplayName(displayName);
+        return this;
+    }
+
+    public DoubleProperty displayOnlyIf(PropertyType other, String value) {
+        setDisplayOnlyIf(other, value);
+        return this;
+    }
+
+    public DoubleProperty description(String description) {
+        setDescription(description);
+        return this;
+    }
+
+    public DoubleProperty consoleHelp(String consoleHelp) {
+        setConsoleHelp(consoleHelp);
+        return this;
+    }
+
+    public DoubleProperty sortOrder(int sortOrder) {
+        setSortOrder(sortOrder);
+        return this;
+    }
+
+    public DoubleProperty defaultValue(double defaultValue) {
+        _defaultValue = defaultValue;
+        return this;
+    }
+
+    public DoubleProperty minimumValue(double minimumValue) {
+        _minimumValue = minimumValue;
+        return this;
+    }
+
+    public DoubleProperty maximumValue(double maximumValue) {
+        _maximumValue = maximumValue;
+        return this;
+    }
+
+    public double getDefaultValue() {
+        return _defaultValue;
+    }
+
+    public String getDefaultValueAsString() {
+        return String.valueOf(_defaultValue);
+    }
+
+    public double getMinimumValue() {
+        return _minimumValue;
+    }
+
+    public double getMaximumValue() {
+        return _maximumValue;
+    }
+
+    public double getDouble() {
+        return getDouble(null, getComponentProperties());
+    }
+
+    public double getDouble(String instanceName, PropertyMap props) {
+        double n;
+        boolean ok = true;
+        String value = props.getProperty(_propertyName, String.valueOf(_defaultValue));
+        try {
+            n = Double.parseDouble(value);
+        } catch (NumberFormatException ex) {
+            ok = false;
+            n = 0;
+        }
+        if (n < _minimumValue || n > _maximumValue) {
+            ok = false;
+        }
+        if (!ok) {
+            badPropertyValue(instanceName, value, expectedNumberInRange(_minimumValue, _maximumValue));
+        }
+        logPropertyValue(instanceName, value, n == _defaultValue);
+        return n;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/FloatProperty.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/FloatProperty.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/FloatProperty.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,110 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.properties;
+
+public class FloatProperty extends PropertyType {
+    private float _defaultValue = 0;
+
+    private float _minimumValue = 0;
+
+    private float _maximumValue = Float.MAX_VALUE;
+
+    public FloatProperty(Class componentClass, String propertyName) {
+        super(componentClass, propertyName);
+    }
+
+    public FloatProperty displayName(String displayName) {
+        setDisplayName(displayName);
+        return this;
+    }
+
+    public FloatProperty displayOnlyIf(PropertyType other, String value) {
+        setDisplayOnlyIf(other, value);
+        return this;
+    }
+
+    public FloatProperty description(String description) {
+        setDescription(description);
+        return this;
+    }
+
+    public FloatProperty consoleHelp(String consoleHelp) {
+        setConsoleHelp(consoleHelp);
+        return this;
+    }
+
+    public FloatProperty sortOrder(int sortOrder) {
+        setSortOrder(sortOrder);
+        return this;
+    }
+
+    public FloatProperty defaultValue(float defaultValue) {
+        _defaultValue = defaultValue;
+        return this;
+    }
+
+    public FloatProperty minimumValue(float minimumValue) {
+        _minimumValue = minimumValue;
+        return this;
+    }
+
+    public FloatProperty maximumValue(float maximumValue) {
+        _maximumValue = maximumValue;
+        return this;
+    }
+
+    public float getDefaultValue() {
+        return _defaultValue;
+    }
+
+    public String getDefaultValueAsString() {
+        return String.valueOf(_defaultValue);
+    }
+
+    public float getMinimumValue() {
+        return _minimumValue;
+    }
+
+    public float getMaximumValue() {
+        return _maximumValue;
+    }
+
+    public float getFloat() {
+        return getFloat(null, getComponentProperties());
+    }
+
+    public float getFloat(String instanceName, PropertyMap props) {
+        float n;
+        boolean ok = true;
+        String value = props.getProperty(_propertyName, String.valueOf(_defaultValue));
+        try {
+            n = Float.parseFloat(value);
+        } catch (NumberFormatException ex) {
+            ok = false;
+            n = 0;
+        }
+        if (n < _minimumValue || n > _maximumValue) {
+            ok = false;
+        }
+        if (!ok) {
+            badPropertyValue(instanceName, value, expectedNumberInRange(_minimumValue, _maximumValue));
+        }
+        logPropertyValue(instanceName, value, n == _defaultValue);
+        return n;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/IntProperty.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/IntProperty.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/IntProperty.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,110 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.properties;
+
+public class IntProperty extends PropertyType {
+    private int _defaultValue = 0;
+
+    private int _minimumValue = 0;
+
+    private int _maximumValue = Integer.MAX_VALUE;
+
+    public IntProperty(Class componentClass, String propertyName) {
+        super(componentClass, propertyName);
+    }
+
+    public IntProperty displayName(String displayName) {
+        setDisplayName(displayName);
+        return this;
+    }
+
+    public IntProperty displayOnlyIf(PropertyType other, String value) {
+        setDisplayOnlyIf(other, value);
+        return this;
+    }
+
+    public IntProperty description(String description) {
+        setDescription(description);
+        return this;
+    }
+
+    public IntProperty consoleHelp(String consoleHelp) {
+        setConsoleHelp(consoleHelp);
+        return this;
+    }
+
+    public IntProperty sortOrder(int sortOrder) {
+        setSortOrder(sortOrder);
+        return this;
+    }
+
+    public IntProperty defaultValue(int defaultValue) {
+        _defaultValue = defaultValue;
+        return this;
+    }
+
+    public IntProperty minimumValue(int minimumValue) {
+        _minimumValue = minimumValue;
+        return this;
+    }
+
+    public IntProperty maximumValue(int maximumValue) {
+        _maximumValue = maximumValue;
+        return this;
+    }
+
+    public int getDefaultValue() {
+        return _defaultValue;
+    }
+
+    public String getDefaultValueAsString() {
+        return String.valueOf(_defaultValue);
+    }
+
+    public int getMinimumValue() {
+        return _minimumValue;
+    }
+
+    public int getMaximumValue() {
+        return _maximumValue;
+    }
+
+    public int getInt() {
+        return getInt(null, getComponentProperties());
+    }
+
+    public int getInt(String instanceName, PropertyMap props) {
+        int n;
+        boolean ok = true;
+        String value = props.getProperty(_propertyName, String.valueOf(_defaultValue));
+        try {
+            n = Integer.parseInt(value);
+        } catch (NumberFormatException ex) {
+            ok = false;
+            n = 0;
+        }
+        if (n < _minimumValue || n > _maximumValue) {
+            ok = false;
+        }
+        if (!ok) {
+            badPropertyValue(instanceName, value, expectedNumberInRange(_minimumValue, _maximumValue));
+        }
+        logPropertyValue(instanceName, value, n == _defaultValue);
+        return n;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/LongProperty.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/LongProperty.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/LongProperty.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,121 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.properties;
+
+
+
+
+public class LongProperty extends PropertyType {
+    private long _defaultValue = 0;
+
+    private long _minimumValue = 0;
+
+    private long _maximumValue = Integer.MAX_VALUE;
+
+    public LongProperty(Class componentClass, String propertyName) {
+        super(componentClass, propertyName);
+    }
+
+    public LongProperty displayName(String displayName) {
+        setDisplayName(displayName);
+        return this;
+    }
+
+    public LongProperty displayOnlyIf(PropertyType other, String value) {
+        setDisplayOnlyIf(other, value);
+        return this;
+    }
+
+    public LongProperty description(String description) {
+        setDescription(description);
+        return this;
+    }
+
+    public LongProperty consoleHelp(String consoleHelp) {
+        setConsoleHelp(consoleHelp);
+        return this;
+    }
+
+    public LongProperty sortOrder(int sortOrder) {
+        setSortOrder(sortOrder);
+        return this;
+    }
+
+    public LongProperty defaultValue(long defaultValue) {
+        _defaultValue = defaultValue;
+        return this;
+    }
+
+    public LongProperty minimumValue(long minimumValue) {
+        _minimumValue = minimumValue;
+        return this;
+    }
+
+    public LongProperty maximumValue(long maximumValue) {
+        _maximumValue = maximumValue;
+        return this;
+    }
+
+    public long getDefaultValue() {
+        return _defaultValue;
+    }
+
+    public String getDefaultValueAsString() {
+        return String.valueOf(_defaultValue);
+    }
+
+    public long getMinimumValue() {
+        return _minimumValue;
+    }
+
+    public long getMaximumValue() {
+        return _maximumValue;
+    }
+
+    public long getLong() {
+        return getLong(null, getComponentProperties());
+    }
+
+    /*
+    public long getLong(Object instance)
+    {
+        return getLong(((Component.InstanceName)instance).getInstanceName(),
+            ((Component.InstanceProperties)instance).getInstanceProperties());
+    }
+    */
+
+    public long getLong(String instanceName, PropertyMap props) {
+        long n;
+        boolean ok = true;
+        String value = props.getProperty(_propertyName, String.valueOf(_defaultValue));
+        try {
+            n = Long.parseLong(value);
+        } catch (NumberFormatException ex) {
+            ok = false;
+            n = 0;
+        }
+        if (n < _minimumValue || n > _maximumValue) {
+            ok = false;
+        }
+        if (!ok) {
+            badPropertyValue(instanceName, value, expectedNumberInRange(_minimumValue, _maximumValue));
+        }
+        logPropertyValue(instanceName, value, n == _defaultValue);
+        return n;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/MissingRequiredPropertyException.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/MissingRequiredPropertyException.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/MissingRequiredPropertyException.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,24 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.properties;
+
+public class MissingRequiredPropertyException extends RuntimeException {
+    public MissingRequiredPropertyException(String message) {
+        super(message);
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/PropertyLog.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/PropertyLog.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/PropertyLog.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,56 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.properties;
+
+public class PropertyLog {
+    public static PropertyLog getInstance(String instanceName) {
+        PropertyLog log = new PropertyLog();
+        log.init(instanceName);
+        return log;
+    }
+
+    private String _instanceName;
+
+    public String getInstanceName() {
+        return _instanceName;
+    }
+
+    protected void init(String instanceName) {
+        _instanceName = instanceName;
+    }
+
+    public void debugUsingValue(String value) {
+        System.out.println("PropertyLog.debugUsingValue(): NEEDS IMPLEMENTATION??");
+    }
+
+    public void debugUsingDefaultValue(String defaultValue) {
+        System.out.println("PropertyLog.debugUsingValue(): NEEDS IMPLEMENTATION??");
+    }
+
+    public String errorMissingValueForRequiredProperty(String property, String context) {
+        String msg = "PropertyLog.errorMissingValueForRequiredProperty(): property: " + property + ", context: " + context;
+        System.out.println(msg);
+        return msg;
+    }
+
+    public String errorMissingValueForRequiredSystemProperty(String property, String refProperty, String context) {
+        String msg = "PropertyLog.errorMissingValueForRequiredSystemProperty(): property: " + property + ", refProperty: " + refProperty + ", context: " + context;
+        System.out.println(msg);
+        return msg;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/PropertyMap.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/PropertyMap.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/PropertyMap.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,91 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.properties;
+
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.geronimo.interop.SystemException;
+
+
+public class PropertyMap extends HashMap {
+    public PropertyMap() {
+        super();
+    }
+
+    public PropertyMap(Map map) {
+        super(map);
+    }
+
+    public Object put(Object key, Object value) {
+        if (key == null) {
+            throw new NullPointerException("key");
+        }
+        if (value == null) {
+            // Avoid exception in getProperties (Properties can't take null value)
+            throw new NullPointerException("value");
+        }
+        return super.put(key, value);
+    }
+
+    public String getProperty(String name) {
+        return (String) super.get(name);
+    }
+
+    public String getProperty(String name, String defaultValue) {
+        String value = getProperty(name);
+        if (value == null || value.length() == 0) {
+            value = defaultValue;
+        }
+        return value;
+    }
+
+    public Properties getProperties() {
+        Properties props = new Properties();
+        for (Iterator i = entrySet().iterator(); i.hasNext();) {
+            Map.Entry entry = (Map.Entry) i.next();
+            String key = (String) entry.getKey();
+            String value = (String) entry.getValue();
+            props.put(key, value);
+        }
+        return props;
+    }
+
+    public static PropertyMap readFile(String fileName) {
+        try {
+            Properties props = new Properties();
+            BufferedInputStream input = new BufferedInputStream(new FileInputStream(fileName));
+            props.load(input);
+            input.close();
+            PropertyMap map = new PropertyMap();
+            for (Iterator i = props.entrySet().iterator(); i.hasNext();) {
+                Map.Entry entry = (Map.Entry) i.next();
+                String key = entry.getKey().toString().trim();
+                String value = entry.getValue().toString().trim();
+                map.put(key, value);
+            }
+            return map;
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/PropertyType.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/PropertyType.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/PropertyType.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,205 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.properties;
+
+import java.util.List;
+
+import org.apache.geronimo.interop.util.ExceptionUtil;
+
+
+public abstract class PropertyType {
+    protected static boolean _debug;
+
+    static {
+        try {
+            _debug = Boolean.getBoolean("org.apache.geronimo.interop.debug:properties");
+        } catch (Exception ignore) // e.g. SecurityException for Applet
+        {
+            _debug = false;
+        }
+    }
+
+    protected Class _componentClass;
+
+    protected String _propertyName;
+
+    protected String _displayName;
+
+    protected String _displayOnlyIfOther;
+
+    protected String _displayOnlyIfValue;
+
+    protected String _description;
+
+    protected String _consoleHelp;
+
+    protected int _sortOrder;
+
+    public PropertyType(Class componentClass, String propertyName) {
+        _componentClass = componentClass;
+        _propertyName = propertyName;
+    }
+
+    public Class getComponentClass() {
+        return _componentClass;
+    }
+
+    public PropertyMap getComponentProperties() {
+        if (_componentClass == SystemProperties.class) {
+            return SystemProperties.getInstance();
+        } else {
+            return null; // Component.forClass(_componentClass).getProperties();
+        }
+    }
+
+    public String getPropertyName() {
+        return _propertyName;
+    }
+
+    public String getDisplayName() {
+        return _displayName;
+    }
+
+    public String getDisplayOnlyIfOther() {
+        return _displayOnlyIfOther;
+    }
+
+    public String getDisplayOnlyIfValue() {
+        return _displayOnlyIfValue;
+    }
+
+    public String getDescription() {
+        return _description;
+    }
+
+    public String getConsoleHelp() {
+        return _consoleHelp;
+    }
+
+    public int getSortOrder() {
+        return _sortOrder;
+    }
+
+    public String getDefaultValueAsString() {
+        return "";
+    }
+
+    public boolean isList() {
+        return false;
+    }
+
+    public boolean isReadOnly() {
+        return false;
+    }
+
+    public void setDisplayName(String displayName) {
+        _displayName = displayName;
+    }
+
+    public void setDisplayOnlyIf(PropertyType other, String value) {
+        _displayOnlyIfOther = other.getPropertyName();
+        _displayOnlyIfValue = value;
+    }
+
+    public void setDescription(String description) {
+        _description = description;
+    }
+
+    public void setConsoleHelp(String consoleHelp) {
+        _consoleHelp = consoleHelp;
+    }
+
+    public void setSortOrder(int sortOrder) {
+        _sortOrder = sortOrder;
+    }
+
+    public void badPropertyValue(String instanceName, String value) {
+        badPropertyValue(instanceName, value, (String) null);
+    }
+
+    public void badPropertyValue(String instanceName, String value, Exception ex) {
+        badPropertyValue(instanceName, value, "exception: " + ExceptionUtil.getStackTrace(ex));
+    }
+
+    public void badPropertyValue(String instanceName, String value, String reason) {
+        // TODO: I18N
+        /* 
+        throw new SystemException("Bad value '" + value
+            + "' for property '" + _propertyName
+            + "' of component " + _componentClass.getName()
+            + (instanceName == null ? "" : (", instance " + instanceName))
+            + (reason != null ? (", " + reason) : ""));
+            */
+        Thread.dumpStack();
+    }
+
+    public String expectedNumberInRange(long minimumValue, long maximumValue) {
+        // TODO: I18N
+        return "expected number in range [" + minimumValue + " .. " + maximumValue + "]";
+    }
+
+    public String expectedNumberInRange(double minimumValue, double maximumValue) {
+        // TODO: I18N
+        return "expected number in range [" + minimumValue + " .. " + maximumValue + "]";
+    }
+
+    public String expectedTrueOrFalse() {
+        // TODO: I18N
+        return "expected true or false";
+    }
+
+    public String expectedValueInList(List legalValues) {
+        // TODO: I18N
+        return "expected value in list " + legalValues;
+    }
+
+    public void logPropertyValue(String instanceName, String value, boolean usingDefaultValue) {
+        if (_propertyName.toLowerCase().endsWith("password")) {
+            value = "******";
+        }
+        if (_debug) // TODO: allow for bootstrap
+        {
+            if (usingDefaultValue) {
+                if (_componentClass == SystemProperties.class) {
+                    SystemPropertyLog.getInstance(_propertyName).debugUsingDefaultValue(value);
+                } else {
+                    getLog(instanceName).debugUsingDefaultValue(value);
+                }
+            } else {
+                if (_componentClass == SystemProperties.class) {
+                    SystemPropertyLog.getInstance(_propertyName).debugUsingValue(value);
+                } else {
+                    getLog(instanceName).debugUsingValue(value);
+                }
+            }
+        }
+    }
+
+    public String getContext(String instanceName) {
+        /*
+        String showName = JavaClass.getNameSuffix(_componentClass.getName());
+        // TODO: optional full component name
+        return showName + (instanceName != null ? (":" + instanceName) : "");
+        */
+        return "TODO: PropertyType.getContext()";
+    }
+
+    public PropertyLog getLog(String instanceName) {
+        return PropertyLog.getInstance(_propertyName + ", " + getContext(instanceName));
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/ShortProperty.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/ShortProperty.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/ShortProperty.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,110 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.properties;
+
+public class ShortProperty extends PropertyType {
+    private short _defaultValue = 0;
+
+    private short _minimumValue = 0;
+
+    private short _maximumValue = Short.MAX_VALUE;
+
+    public ShortProperty(Class componentClass, String propertyName) {
+        super(componentClass, propertyName);
+    }
+
+    public ShortProperty displayName(String displayName) {
+        setDisplayName(displayName);
+        return this;
+    }
+
+    public ShortProperty displayOnlyIf(PropertyType other, String value) {
+        setDisplayOnlyIf(other, value);
+        return this;
+    }
+
+    public ShortProperty description(String description) {
+        setDescription(description);
+        return this;
+    }
+
+    public ShortProperty consoleHelp(String consoleHelp) {
+        setConsoleHelp(consoleHelp);
+        return this;
+    }
+
+    public ShortProperty sortOrder(int sortOrder) {
+        setSortOrder(sortOrder);
+        return this;
+    }
+
+    public ShortProperty defaultValue(short defaultValue) {
+        _defaultValue = defaultValue;
+        return this;
+    }
+
+    public ShortProperty minimumValue(short minimumValue) {
+        _minimumValue = minimumValue;
+        return this;
+    }
+
+    public ShortProperty maximumValue(short maximumValue) {
+        _maximumValue = maximumValue;
+        return this;
+    }
+
+    public short getDefaultValue() {
+        return _defaultValue;
+    }
+
+    public String getDefaultValueAsString() {
+        return String.valueOf(_defaultValue);
+    }
+
+    public short getMinimumValue() {
+        return _minimumValue;
+    }
+
+    public short getMaximumValue() {
+        return _maximumValue;
+    }
+
+    public short getShort() {
+        return getShort(null, getComponentProperties());
+    }
+
+    public short getShort(String instanceName, PropertyMap props) {
+        short n;
+        boolean ok = true;
+        String value = props.getProperty(_propertyName, String.valueOf(_defaultValue));
+        try {
+            n = Short.parseShort(value);
+        } catch (NumberFormatException ex) {
+            ok = false;
+            n = 0;
+        }
+        if (n < _minimumValue || n > _maximumValue) {
+            ok = false;
+        }
+        if (!ok) {
+            badPropertyValue(instanceName, value, expectedNumberInRange(_minimumValue, _maximumValue));
+        }
+        logPropertyValue(instanceName, value, n == _defaultValue);
+        return n;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/StringProperty.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/StringProperty.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/StringProperty.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,232 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.properties;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.geronimo.interop.util.FileUtil;
+import org.apache.geronimo.interop.util.ListUtil;
+import org.apache.geronimo.interop.util.StringUtil;
+
+
+public class StringProperty extends PropertyType {
+    private String _defaultValue = "";
+
+    private List _valueIsInList = null;
+
+    private Map _displayValues = null;
+
+    private Class _valueIsNameOf = null;
+
+    private boolean _isDirName = false;
+
+    private boolean _isFileName = false;
+
+    private boolean _isList = false;
+
+    private boolean _isReadOnly = false;
+
+    private boolean _isRequired = false;
+
+    public StringProperty(Class componentClass, String propertyName) {
+        super(componentClass, propertyName);
+    }
+
+    public StringProperty displayName(String displayName) {
+        setDisplayName(displayName);
+        return this;
+    }
+
+    public StringProperty displayOnlyIf(PropertyType other, String value) {
+        setDisplayOnlyIf(other, value);
+        return this;
+    }
+
+    public StringProperty description(String description) {
+        setDescription(description);
+        return this;
+    }
+
+    public StringProperty consoleHelp(String consoleHelp) {
+        setConsoleHelp(consoleHelp);
+        return this;
+    }
+
+    public StringProperty sortOrder(int sortOrder) {
+        setSortOrder(sortOrder);
+        return this;
+    }
+
+    public StringProperty defaultValue(String defaultValue) {
+        _defaultValue = defaultValue;
+        return this;
+    }
+
+    public StringProperty legalValues(Class valueIsNameOf) {
+        _valueIsNameOf = valueIsNameOf;
+        return this;
+    }
+
+    public StringProperty legalValues(List valueIsInList) {
+        _valueIsInList = Collections.unmodifiableList(valueIsInList);
+        return this;
+    }
+
+    public StringProperty legalValues(String valueIsInList) {
+        List list = ListUtil.getCommaSeparatedList(valueIsInList);
+        _valueIsInList = new ArrayList(list.size());
+        for (Iterator i = list.iterator(); i.hasNext();) {
+            String value = (String) i.next();
+            if (value.indexOf('=') != -1) {
+                String displayValue = StringUtil.afterFirst("=", value).trim();
+                value = StringUtil.beforeFirst("=", value).trim();
+                if (_displayValues == null) {
+                    _displayValues = new HashMap();
+                }
+                _displayValues.put(value, displayValue);
+            }
+            _valueIsInList.add(value);
+        }
+        return this;
+    }
+
+    public String getDisplayValue(String value) {
+        if (_displayValues != null) {
+            String displayValue = (String) _displayValues.get(value);
+            if (displayValue != null) {
+                return displayValue;
+            }
+        }
+        return value;
+    }
+
+    public StringProperty isDirName() {
+        _isDirName = true;
+        return this;
+    }
+
+    public StringProperty isFileName() {
+        _isFileName = true;
+        return this;
+    }
+
+    public StringProperty list() {
+        _isList = true;
+        return this;
+    }
+
+    public StringProperty readOnly() {
+        _isReadOnly = true;
+        return this;
+    }
+
+    public StringProperty required() {
+        _isRequired = true;
+        return this;
+    }
+
+    public boolean isList() {
+        return _isList;
+    }
+
+    public boolean isReadOnly() {
+        return _isReadOnly;
+    }
+
+    public boolean isRequired() {
+        return _isRequired;
+    }
+
+    public String getDefaultValue() {
+        return _defaultValue;
+    }
+
+    public String getDefaultValueAsString() {
+        return _defaultValue;
+    }
+
+    public List getLegalValues() {
+        if (_valueIsInList != null) {
+            return _valueIsInList;
+        } else if (_valueIsNameOf != null) {
+            //return Repository.getInstance().getInstanceNames(_valueIsNameOf);
+            return null;
+        } else {
+            return null;
+        }
+    }
+
+    public String getString() {
+        return getString(null, getComponentProperties());
+    }
+
+    public String getString(String instanceName, PropertyMap props) {
+        boolean ok = true, usingDefaultValue = false;
+        String s = props.getProperty(_propertyName, _defaultValue);
+        if (s != null && s.startsWith("${")) {
+            // Value is contained in system property.
+            s = StringUtil.removePrefix(s, "${");
+            s = StringUtil.removeSuffix(s, "}");
+            StringProperty sp = new StringProperty(SystemProperties.class, s);
+            s = sp.getString();
+            if (s == null || s.length() == 0) {
+                if (isRequired()) {
+                    String message = getLog(instanceName).errorMissingValueForRequiredSystemProperty(sp.getPropertyName(), _propertyName, getContext(instanceName));
+                    throw new MissingRequiredPropertyException(message);
+                }
+            }
+        }
+        if (s == null && !isRequired()) {
+            s = "";
+        }
+        List legalValues = getLegalValues();
+        if (legalValues != null) {
+            ok = false;
+            for (Iterator i = legalValues.iterator(); i.hasNext();) {
+                String legalValue = (String) i.next();
+                if (s != null && s.equals(legalValue)) {
+                    ok = true;
+                    break;
+                }
+            }
+            if (!isRequired() && s.equals("")) {
+                ok = true;
+            }
+        }
+        if (!ok) {
+            badPropertyValue(instanceName, s, expectedValueInList(legalValues));
+        }
+        if (_isDirName || _isFileName) {
+            s = FileUtil.expandHomeRelativePath(s);
+            s = FileUtil.pretty(s);
+        }
+        if (s == null || s.length() == 0) {
+            if (isRequired()) {
+                String message = getLog(instanceName).errorMissingValueForRequiredProperty(_propertyName, getContext(instanceName));
+                throw new MissingRequiredPropertyException(message);
+            }
+        }
+        logPropertyValue(instanceName, s, s != null && s.equals(_defaultValue));
+        return s;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/SystemProperties.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/SystemProperties.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/SystemProperties.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,169 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.properties;
+
+import org.apache.geronimo.interop.util.FileUtil;
+
+
+public class SystemProperties extends PropertyMap {
+    // Not a component as it is required for bootstrapping
+    // and we want to avoid circular build dependencies.
+
+    // properties
+
+    public static final BooleanProperty debugProperty =
+            new BooleanProperty(SystemProperties.class, "org.apache.geronimo.interop.debug");
+
+    public static final BooleanProperty quietProperty =
+            new BooleanProperty(SystemProperties.class, "org.apache.geronimo.interop.quiet");
+
+    public static final BooleanProperty verboseProperty =
+            new BooleanProperty(SystemProperties.class, "org.apache.geronimo.interop.verbose");
+
+    public static final StringProperty homeProperty =
+            new StringProperty(SystemProperties.class, "org.apache.geronimo.interop.home")
+            .isDirName();
+
+    public static final StringProperty repositoryProperty =
+            new StringProperty(SystemProperties.class, "org.apache.geronimo.interop.repository")
+            .isDirName();
+
+    public static final StringProperty logFileProperty =
+            new StringProperty(SystemProperties.class, "org.apache.geronimo.interop.logFile")
+            .defaultValue("~/logs/default.log")
+            .isFileName();
+
+    public static final StringProperty tempDirProperty =
+            new StringProperty(SystemProperties.class, "org.apache.geronimo.interop.tempDir")
+            .isFileName();
+
+    public static final IntProperty rmiNamingContextCacheTimeoutProperty =
+            new IntProperty(SystemProperties.class, "org.apache.geronimo.interop.rmi.namingContextCacheTimeout")
+            .defaultValue(600); // 10 minutes
+
+    public static final IntProperty rmiSocketTimeoutProperty =
+            new IntProperty(SystemProperties.class, "org.apache.geronimo.interop.rmi.socketTimeout")
+            .defaultValue(600); // 10 minutes
+
+    public static final BooleanProperty rmiTraceProperty =
+            new BooleanProperty(SystemProperties.class, "org.apache.geronimo.interop.rmiTrace");
+
+    public static final BooleanProperty useThreadLocalRmiConnectionPoolsProperty =
+            new BooleanProperty(SystemProperties.class, "org.apache.geronimo.interop.rmi.useThreadLocalConnectionPools");
+
+    // privata data
+
+    private static SystemProperties _instance;
+    private boolean _canAccessFileSystem = true;
+    private boolean _rmiTrace;
+    private boolean _debug;
+    private boolean _quiet;
+    private boolean _verbose;
+    private String _home;
+    private String _repository;
+    private String _tempDir;
+
+    static {
+        _instance = new SystemProperties();
+        _instance.init();
+    }
+
+    public static SystemProperties getInstance() {
+        return _instance;
+    }
+
+    // private methods
+
+    private SystemProperties() {
+        try {
+            putAll(System.getProperties());
+        } catch (Exception ignore) // e.g. due to Applet Security Manager
+        {
+            _canAccessFileSystem = false;
+        }
+    }
+
+    private void init() {
+        _debug = debugProperty.getBoolean();
+        _quiet = quietProperty.getBoolean();
+        _verbose = verboseProperty.getBoolean();
+
+        if (_verbose) {
+            System.out.println("System Property org.apache.geronimo.interop.debug = " + _debug);
+            System.out.println("System Property org.apache.geronimo.interop.verbose = true");
+        }
+
+        _rmiTrace = rmiTraceProperty.getBoolean();
+
+        homeProperty.defaultValue("/org.apache.geronimo.interop");
+        _home = homeProperty.getString();
+
+        repositoryProperty.defaultValue(_home + "/Repository");
+        _repository = repositoryProperty.getString();
+
+        tempDirProperty.defaultValue(_home + "/temp");
+        _tempDir = tempDirProperty.getString();
+    }
+
+    // public methods
+
+    public static boolean rmiTrace() {
+        return getInstance()._rmiTrace;
+    }
+
+    public static boolean debug() {
+        return getInstance()._debug;
+    }
+
+    public static boolean quiet() {
+        return getInstance()._quiet;
+    }
+
+    public static boolean verbose() {
+        return getInstance()._verbose;
+    }
+
+    public static boolean canAccessFileSystem() {
+        return getInstance()._canAccessFileSystem;
+    }
+
+    public static String logFile() {
+        // Note: this is not necessarily a constant.
+        // Application might call System.setProperty to change "org.apache.geronimo.interop.logFile".
+        try {
+            String file = System.getProperty(logFileProperty.getPropertyName(), logFileProperty.getDefaultValue());
+            file = FileUtil.expandHomeRelativePath(file);
+            return file;
+        } catch (Exception ex) // e.g. SecurityException in Applet
+        {
+            return logFileProperty.getString();
+        }
+    }
+
+    public static String getHome() {
+        return getInstance()._home;
+    }
+
+    public static String getRepository() {
+        return getInstance()._repository;
+    }
+
+    public static String getTempDir() {
+        return getInstance()._tempDir;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/SystemPropertyLog.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/SystemPropertyLog.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/properties/SystemPropertyLog.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,63 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.properties;
+
+
+
+
+public class SystemPropertyLog {
+    public static SystemPropertyLog getInstance(String instanceName) {
+        SystemPropertyLog log = new SystemPropertyLog();
+        log.init(instanceName);
+        return log;
+    }
+
+    // -----------------------------------------------------------------------
+    // private data
+    // -----------------------------------------------------------------------
+
+    private String _instanceName;
+
+    // -----------------------------------------------------------------------
+    // public methods
+    // -----------------------------------------------------------------------
+
+    public String getInstanceName() {
+        return _instanceName;
+    }
+
+    // -----------------------------------------------------------------------
+    // protected methods
+    // -----------------------------------------------------------------------
+
+    protected void init(String instanceName) {
+        _instanceName = instanceName;
+    }
+
+    // -----------------------------------------------------------------------
+    // log methods
+    // -----------------------------------------------------------------------
+
+    public void debugUsingValue(String value) {
+        System.out.println("SystemPropertyLog.debugUsingValue(): value: " + value);
+    }
+
+    public void debugUsingDefaultValue(String defaultValue) {
+        System.out.println("SystemPropertyLog.debugUsingValue(): defaultValue: " + defaultValue);
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/repository/Repository.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/repository/Repository.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/repository/Repository.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,23 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.repository;
+
+
+public class Repository {
+    // ??
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/RmiTrace.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/RmiTrace.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/RmiTrace.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,98 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi;
+
+import org.apache.geronimo.interop.util.StringUtil;
+
+
+public class RmiTrace {
+    public static final boolean ENABLED = true;
+    public static final boolean CONNECT = true;
+
+    public RmiTrace() {
+    }
+
+    public static void receive(String host, byte[] data) {
+        dump(formatReceiveHeader(host), data);
+    }
+
+    public static void send(String host, byte[] data) {
+        dump(formatSendHeader(host), data);
+    }
+
+    public static void dump(String header, byte[] data) {
+        traceRmiHeader(header);
+        StringBuffer dataBuffer = new StringBuffer(44);
+        StringBuffer textBuffer = new StringBuffer(20);
+        for (int i = 0; i < data.length; i++) {
+            int d = (data[i] + 0x100) & 0xff;
+            String h = StringUtil.padLeft(Integer.toHexString(d).toUpperCase(), '0', 2);
+            dataBuffer.append(h);
+            if (i % 4 == 3 && i % 20 != 19) {
+                dataBuffer.append(' ');
+            }
+            char c = (char) d;
+            if (c < 32 || c > 127) {
+                c = '.';
+            }
+            textBuffer.append(c);
+            if (i % 20 == 19) {
+                traceRmi(StringUtil.padRight(dataBuffer.toString(), ' ', 44), textBuffer.toString());
+                dataBuffer.setLength(0);
+                textBuffer.setLength(0);
+            }
+        }
+        if (dataBuffer.length() != 0) {
+            traceRmi(StringUtil.padRight(dataBuffer.toString(), ' ', 44), textBuffer.toString());
+        }
+    }
+
+    // format methods
+
+    protected static String formatReceiveHeader(String host) {
+        String msg;
+        msg = "RmiTrace.formatReceiveHeader(): host: " + host;
+        return msg;
+    }
+
+    protected static String formatSendHeader(String host) {
+        String msg;
+        msg = "RmiTrace.formatSendHeader(): host: " + host;
+        return msg;
+    }
+
+
+    // log methods
+
+    public static void traceConnect(String endpoint) {
+        System.out.println("RmiTrace.traceConnect(): endpoint: " + endpoint);
+    }
+
+    public static void traceDisconnect(String endpoint) {
+        System.out.println("RmiTrace.traceDisconnect(): endpoint: " + endpoint);
+    }
+
+    protected static void traceRmiHeader(String header) {
+        System.out.println("RmiTrace.traceRmiHeader(): header: " + header);
+    }
+
+    protected static void traceRmi(String data, String text) {
+        System.out.println("RmiTrace.traceRmi(): data: " + data + ", text: " + text);
+    }
+
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/Any.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/Any.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/Any.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,453 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop;
+
+import org.omg.CORBA.TCKind;
+
+
+/**
+ * * An implementation of CORBA 'any' for the Sybase ORB.
+ */
+public class Any extends org.omg.CORBA.Any {
+    private org.omg.CORBA.TypeCode _type;
+
+    private byte[] _data;
+
+    private void extract_type(TCKind tk, String what) {
+        if (_type.kind().value() != tk.value()) {
+            throw new org.omg.CORBA.BAD_TYPECODE("com.sybase.CORBA.Any.extract_"
+                                                 + what + ": type = " + _type);
+        }
+    }
+
+    public Any() {
+        _type = TypeCode.NULL;
+    }
+
+    public boolean equal(org.omg.CORBA.Any a) {
+        if (!_type.equal(a.type())) {
+            return false;
+        }
+        if (a instanceof org.apache.geronimo.interop.rmi.iiop.Any) {
+            org.apache.geronimo.interop.rmi.iiop.Any _that = (org.apache.geronimo.interop.rmi.iiop.Any) a;
+            String x = org.apache.geronimo.interop.util.Base16Binary.toString(this._data);
+            String y = org.apache.geronimo.interop.util.Base16Binary.toString(_that._data);
+            return x.equals(y);
+        } else {
+            // TODO: implement equality testing with other ORB's 'any' values
+            throw new org.omg.CORBA.NO_IMPLEMENT("org.apache.geronimo.interop.rmi.iiop.Any.equal("
+                                                 + a.getClass().getName() + ")");
+        }
+    }
+
+    public org.omg.CORBA.TypeCode type() {
+        return _type;
+    }
+
+    public void type(org.omg.CORBA.TypeCode type) {
+        _type = type;
+    }
+
+    public void read_value(org.omg.CORBA.portable.InputStream input, org.omg.CORBA.TypeCode type) {
+        byte[] buffer = ((CdrInputStream) input)._buffer;
+        int length = ((CdrInputStream) input)._length;
+        _type = type;
+        _data = new byte[length];
+        System.arraycopy(buffer, 0, _data, 0, length);
+    }
+
+    public void write_value(org.omg.CORBA.portable.OutputStream output) {
+        // A no-op in this implementation.
+    }
+
+    public org.omg.CORBA.portable.OutputStream create_output_stream() {
+        _data = null;
+        return CdrOutputStream.getInstance();
+    }
+
+    public org.omg.CORBA.portable.InputStream create_input_stream() {
+        if (_data == null) {
+            throw new org.omg.CORBA.BAD_OPERATION("com.sybase.CORBA.Any.create_input_stream");
+        }
+        return CdrInputStream.getInstance();
+    }
+
+    public short extract_short() {
+        extract_type(TCKind.tk_short, "short");
+        return create_input_stream().read_short();
+    }
+
+    public void insert_short(short value) {
+        org.omg.CORBA.portable.OutputStream output = create_output_stream();
+        output.write_short(value);
+        read_value(null, TypeCode.SHORT);
+    }
+
+    public int extract_long() {
+        extract_type(TCKind.tk_long, "long");
+        return create_input_stream().read_long();
+    }
+
+    public void insert_long(int value) {
+        org.omg.CORBA.portable.OutputStream output = create_output_stream();
+        output.write_long(value);
+        read_value(null, TypeCode.LONG);
+    }
+
+    public long extract_longlong() {
+        extract_type(TCKind.tk_longlong, "longlong");
+        return create_input_stream().read_longlong();
+    }
+
+    public void insert_longlong(long value) {
+        org.omg.CORBA.portable.OutputStream output = create_output_stream();
+        output.write_longlong(value);
+        read_value(null, TypeCode.LONGLONG);
+    }
+
+    public short extract_ushort() {
+        extract_type(TCKind.tk_ushort, "ushort");
+        return create_input_stream().read_ushort();
+    }
+
+    public void insert_ushort(short value) {
+        org.omg.CORBA.portable.OutputStream output = create_output_stream();
+        output.write_ushort(value);
+        read_value(null, TypeCode.USHORT);
+    }
+
+    public int extract_ulong() {
+        extract_type(TCKind.tk_ulong, "ulong");
+        return create_input_stream().read_ulong();
+    }
+
+    public void insert_ulong(int value) {
+        org.omg.CORBA.portable.OutputStream output = create_output_stream();
+        output.write_ulong(value);
+        read_value(null, TypeCode.ULONG);
+    }
+
+    public long extract_ulonglong() {
+        extract_type(TCKind.tk_ulonglong, "ulonglong");
+        return create_input_stream().read_ulonglong();
+    }
+
+    public void insert_ulonglong(long value) {
+        org.omg.CORBA.portable.OutputStream output = create_output_stream();
+        output.write_ulonglong(value);
+        read_value(null, TypeCode.ULONGLONG);
+    }
+
+    public float extract_float() {
+        extract_type(TCKind.tk_float, "float");
+        return create_input_stream().read_float();
+    }
+
+    public void insert_float(float value) {
+        org.omg.CORBA.portable.OutputStream output = create_output_stream();
+        output.write_float(value);
+        read_value(null, TypeCode.FLOAT);
+    }
+
+    public double extract_double() {
+        extract_type(TCKind.tk_double, "double");
+        return create_input_stream().read_double();
+    }
+
+    public void insert_double(double value) {
+        org.omg.CORBA.portable.OutputStream output = create_output_stream();
+        output.write_double(value);
+        read_value(null, TypeCode.DOUBLE);
+    }
+
+    public boolean extract_boolean() {
+        extract_type(TCKind.tk_boolean, "boolean");
+        return create_input_stream().read_boolean();
+    }
+
+    public void insert_boolean(boolean value) {
+        org.omg.CORBA.portable.OutputStream output = create_output_stream();
+        output.write_boolean(value);
+        read_value(null, TypeCode.BOOLEAN);
+    }
+
+    public char extract_char() {
+        extract_type(TCKind.tk_char, "char");
+        return create_input_stream().read_char();
+    }
+
+    public void insert_char(char value) {
+        org.omg.CORBA.portable.OutputStream output = create_output_stream();
+        output.write_char(value);
+        read_value(null, TypeCode.CHAR);
+    }
+
+    public char extract_wchar() {
+        extract_type(TCKind.tk_wchar, "wchar");
+        return create_input_stream().read_wchar();
+    }
+
+    public void insert_wchar(char value) {
+        org.omg.CORBA.portable.OutputStream output = create_output_stream();
+        output.write_wchar(value);
+        read_value(null, TypeCode.WCHAR);
+    }
+
+    public byte extract_octet() {
+        extract_type(TCKind.tk_octet, "octet");
+        return create_input_stream().read_octet();
+    }
+
+    public void insert_octet(byte value) {
+        org.omg.CORBA.portable.OutputStream output = create_output_stream();
+        output.write_octet(value);
+        read_value(null, TypeCode.OCTET);
+    }
+
+    public org.omg.CORBA.Any extract_any() {
+        extract_type(TCKind.tk_any, "any");
+        return create_input_stream().read_any();
+    }
+
+    public void insert_any(org.omg.CORBA.Any value) {
+        org.omg.CORBA.portable.OutputStream output = create_output_stream();
+        output.write_any(value);
+        read_value(null, TypeCode.ANY);
+    }
+
+    public org.omg.CORBA.Object extract_Object() {
+        extract_type(TCKind.tk_objref, "Object");
+        org.omg.CORBA.Object obj = create_input_stream().read_Object();
+        return obj;
+    }
+
+    public void insert_Object(org.omg.CORBA.Object value) {
+        org.omg.CORBA.portable.OutputStream output = create_output_stream();
+        output.write_Object(value);
+        read_value(null, TypeCode.OBJREF);
+    }
+
+    public void insert_Object(org.omg.CORBA.Object value, org.omg.CORBA.TypeCode type) {
+        org.omg.CORBA.portable.OutputStream output = create_output_stream();
+        output.write_Object(value);
+        read_value(null, type);
+    }
+
+    public java.io.Serializable extract_Value() {
+        throw new org.omg.CORBA.NO_IMPLEMENT();
+    }
+
+    public void insert_Value(java.io.Serializable v) {
+        throw new org.omg.CORBA.NO_IMPLEMENT();
+    }
+
+    public void insert_Value(java.io.Serializable v, org.omg.CORBA.TypeCode t) {
+        throw new org.omg.CORBA.NO_IMPLEMENT();
+    }
+
+    public String extract_string() {
+        extract_type(TCKind.tk_string, "string");
+        return create_input_stream().read_string();
+    }
+
+    public void insert_string(String value) {
+        org.omg.CORBA.portable.OutputStream output = create_output_stream();
+        output.write_string(value);
+        read_value(null, TypeCode.STRING);
+    }
+
+    public String extract_wstring() {
+        extract_type(TCKind.tk_wstring, "wstring");
+        return create_input_stream().read_wstring();
+    }
+
+    public void insert_wstring(String value) {
+        org.omg.CORBA.portable.OutputStream output = create_output_stream();
+        output.write_wstring(value);
+        read_value(null, TypeCode.WSTRING);
+    }
+
+    public org.omg.CORBA.TypeCode extract_TypeCode() {
+        extract_type(TCKind.tk_TypeCode, "TypeCode");
+        return create_input_stream().read_TypeCode();
+    }
+
+    public void insert_TypeCode(org.omg.CORBA.TypeCode value) {
+        org.omg.CORBA.portable.OutputStream output = create_output_stream();
+        output.write_TypeCode(value);
+        read_value(null, TypeCode.TYPECODE);
+    }
+
+    public org.omg.CORBA.Principal extract_Principal() {
+        throw new org.omg.CORBA.NO_IMPLEMENT("org.apache.geronimo.interop.rmi.iiop.Any.extract_Principal");
+    }
+
+    public void insert_Principal(org.omg.CORBA.Principal value) {
+        throw new org.omg.CORBA.NO_IMPLEMENT("org.apache.geronimo.interop.rmi.iiop.Any.insert_Principal");
+    }
+
+    // Don't implement insert_Streamable and extract_Streamable since from
+    // a TypeCode it appears to be impossible to determine the holder class
+    // name (in the general case) in order to construct a Streamable object
+    // for return from extract_Streamable.
+
+    public org.omg.CORBA.portable.Streamable extract_Streamable()
+            throws org.omg.CORBA.BAD_INV_ORDER {
+        throw new org.omg.CORBA.NO_IMPLEMENT();
+    }
+
+    public void insert_Streamable(org.omg.CORBA.portable.Streamable s) {
+        throw new org.omg.CORBA.NO_IMPLEMENT();
+    }
+
+    // -----------------------------------------------------------------------
+    // Sybase-internal constructors and methods
+    // -----------------------------------------------------------------------
+
+    /**
+     * * Construct an Any from a TypeCode and a String value
+     * * (supported for boolean and numeric primitive IDL types only).
+     */
+    public Any(org.omg.CORBA.TypeCode type, String value) {
+        try {
+            _type = type;
+            switch (_type.kind().value()) {
+                case TCKind._tk_boolean:
+                    if (value.equals("0")) {
+                        insert_boolean(false);
+                    } else if (value.equals("1")) {
+                        insert_boolean(true);
+                    } else {
+                        insert_boolean(Boolean.valueOf(value).booleanValue());
+                    }
+                    break;
+                case TCKind._tk_octet:
+                    // Don't use class Byte as it isn't present in JDK 1.0.2
+                    insert_octet((byte) parse(value, 0, 255));
+                    break;
+                case TCKind._tk_short:
+                    // Don't use class Short as it isn't present in JDK 1.0.2
+                    insert_short((short) parse(value, -32768, 32767));
+                    break;
+                case TCKind._tk_ushort:
+                    // Don't use class Short as it isn't present in JDK 1.0.2
+                    insert_ushort((short) parse(value, 0, 65535));
+                    break;
+                case TCKind._tk_long:
+                    insert_long((int) parse(value, -2147483648, 2147483647));
+                    break;
+                case TCKind._tk_ulong:
+                    insert_ulong((int) parse(value, 0, 4294967295L));
+                    break;
+                case TCKind._tk_longlong:
+                    insert_longlong(Long.parseLong(value));
+                    break;
+                case TCKind._tk_ulonglong:
+                    // Note: doesn't handle "unsigned long" values >= 2^63. Fix
+                    // this if reported by customers.
+                    insert_ulonglong(Long.parseLong(value));
+                    break;
+                case TCKind._tk_float:
+                    insert_float(Float.valueOf(value).floatValue());
+                    break;
+                case TCKind._tk_double:
+                    insert_double(Double.valueOf(value).doubleValue());
+                    break;
+                default:
+                    throw new org.omg.CORBA.BAD_PARAM(value);
+            }
+        } catch (NumberFormatException nfe) {
+            throw new org.omg.CORBA.BAD_PARAM(value + " - " + nfe.toString());
+        }
+    }
+
+    private long parse(String value, long min, long max) throws NumberFormatException {
+        long n = Long.parseLong(value);
+        if (n < min || n > max) {
+            throw new NumberFormatException(value + " is not in range ["
+                                            + min + ".." + max + "]");
+        }
+        return n;
+    }
+
+    public String toString() {
+        switch (_type.kind().value()) {
+            case TCKind._tk_any:
+            case TCKind._tk_boolean:
+            case TCKind._tk_char:
+            case TCKind._tk_wchar:
+            case TCKind._tk_octet:
+            case TCKind._tk_short:
+            case TCKind._tk_ushort:
+            case TCKind._tk_long:
+            case TCKind._tk_ulong:
+            case TCKind._tk_longlong:
+            case TCKind._tk_ulonglong:
+            case TCKind._tk_float:
+            case TCKind._tk_double:
+            case TCKind._tk_string:
+            case TCKind._tk_wstring:
+            case TCKind._tk_objref:
+                return value();
+            default:
+                // TODO: traverse structure to produce printable output
+                return _type.toString();
+        }
+    }
+
+    private String value() {
+        switch (_type.kind().value()) {
+            case TCKind._tk_any:
+                return "" + extract_any();
+            case TCKind._tk_boolean:
+                return extract_boolean() ? "TRUE" : "FALSE";
+            case TCKind._tk_char:
+                return "'" + extract_char() + "'";
+            case TCKind._tk_wchar:
+                return "'" + extract_wchar() + "'";
+            case TCKind._tk_octet:
+                return "" + extract_octet();
+            case TCKind._tk_short:
+                return "" + extract_short();
+            case TCKind._tk_ushort:
+                return "" + extract_ushort();
+            case TCKind._tk_long:
+                return "" + extract_long();
+            case TCKind._tk_ulong:
+                return "" + extract_ulong();
+            case TCKind._tk_longlong:
+                return "" + extract_longlong();
+            case TCKind._tk_ulonglong:
+                return "" + extract_ulonglong();
+            case TCKind._tk_float:
+                return "" + extract_float();
+            case TCKind._tk_double:
+                return "" + extract_double();
+            case TCKind._tk_string:
+                return "\"" + extract_string() + "\"";
+            case TCKind._tk_wstring:
+                return "\"" + extract_wstring() + "\"";
+            case TCKind._tk_objref:
+                return extract_Object().toString();
+            case TCKind._tk_TypeCode:
+                return "" + extract_TypeCode();
+            default:
+                return "?";
+        }
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ArrayHelper.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ArrayHelper.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ArrayHelper.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,59 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop;
+
+import java.lang.reflect.Array;
+
+import org.apache.geronimo.interop.SystemException;
+import org.apache.geronimo.interop.util.ArrayUtil;
+
+
+public class ArrayHelper implements ObjectHelper {
+    private ValueType _element;
+
+    public ArrayHelper(Class elementClass) {
+        if (elementClass.isPrimitive()) {
+            throw new SystemException("TODO");
+        } else {
+            _element = ValueType.getInstance(elementClass);
+        }
+    }
+
+    public Object read(ObjectInputStream input) {
+        CdrInputStream cdrInput = input._cdrInput;
+        int n = cdrInput.read_long();
+        Object[] array = (Object[]) Array.newInstance(_element._class, n);
+        for (int i = 0; i < n; i++) {
+            array[i] = input.readObject(_element);
+        }
+        return array;
+    }
+
+    public void write(ObjectOutputStream output, Object value) {
+        CdrOutputStream cdrOutput = output._cdrOutput;
+        Object[] array = (Object[]) value;
+        if (array == null) {
+            array = ArrayUtil.EMPTY_OBJECT_ARRAY;
+        }
+        int n = array.length;
+        cdrOutput.write_long(n);
+        for (int i = 0; i < n; i++) {
+            output.writeObject(_element, array[i]);
+        }
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/BadMagicException.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/BadMagicException.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/BadMagicException.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,24 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop;
+
+public class BadMagicException extends RuntimeException {
+    public BadMagicException(String magic) {
+        super(magic);
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/CdrInputStream.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/CdrInputStream.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/CdrInputStream.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,1043 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop;
+
+import org.omg.CORBA.TCKind;
+
+import org.apache.geronimo.interop.GIOP.*;
+import org.apache.geronimo.interop.IOP.*;
+import org.apache.geronimo.interop.rmi.RmiTrace;
+import org.apache.geronimo.interop.rmi.iiop.client.ClientNamingContext;
+import org.apache.geronimo.interop.util.ArrayUtil;
+import org.apache.geronimo.interop.util.BigEndian;
+import org.apache.geronimo.interop.util.LittleEndian;
+import org.apache.geronimo.interop.util.UTF8;
+import org.apache.geronimo.interop.util.UnsignedShort;
+
+
+/**
+ * * CORBA 2.3 / GIOP 1.2 CDR InputStream.
+ */
+public class CdrInputStream extends org.omg.CORBA_2_3.portable.InputStream {
+    public static CdrInputStream getInstance() {
+        CdrInputStream input = new CdrInputStream();
+        input.init(new byte[64], 0, DEFAULT_BUFFER_LENGTH, false);
+        return input;
+    }
+
+    public static CdrInputStream getInstance(byte[] buffer) {
+        CdrInputStream input = new CdrInputStream();
+        input.init(buffer, 0, buffer.length, false);
+        return input;
+    }
+
+    public static CdrInputStream getInstance(byte[] buffer, int offset, int length, boolean little) {
+        CdrInputStream input = new CdrInputStream();
+        input.init(buffer, offset, length, little);
+        return input;
+    }
+
+    public static CdrInputStream getInstanceForEncapsulation() {
+        return getInstance();
+    }
+
+    public static CdrInputStream getPooledInstance() {
+        CdrInputStream input = null; //(CdrInputStream)_pool.get();
+        if (input == null) {
+            input = getInstance();
+        }
+        return input;
+    }
+
+    // -----------------------------------------------------------------------
+    // private data
+    // -----------------------------------------------------------------------
+
+    private static final int DEFAULT_BUFFER_LENGTH = 64;
+
+    private static final int MAXIMUM_POOLED_BUFFER_LENGTH = 1024;
+
+    private static boolean RMI_TRACE = true; //SystemProperties.rmiTrace();
+
+    private static final byte[] EMPTY_BYTE_ARRAY = {};
+
+    //private static ThreadLocalInstancePool _pool = new ThreadLocalInstancePool(CdrInputStream.class.getName());
+
+    private GiopMessage _giopMessage;
+
+    private ClientNamingContext _namingContext;
+
+    private boolean _unaligned;
+
+    private byte[] _pooledBuffer;
+
+    // -----------------------------------------------------------------------
+    // package-private data
+    // -----------------------------------------------------------------------
+
+    byte[] _buffer;
+
+    int _offset;
+
+    int _length;
+
+    boolean _little;
+
+    // -----------------------------------------------------------------------
+    // public methods
+    // -----------------------------------------------------------------------
+
+    public void init(byte[] buffer, int offset, int length, boolean little) {
+        _buffer = buffer;
+        _offset = offset;
+        _length = length;
+        _little = little;
+    }
+
+    public void recycle() {
+        reset();
+        //_pool.put(this);
+    }
+
+    public void reset() {
+        _offset = 0;
+        if (_buffer.length > MAXIMUM_POOLED_BUFFER_LENGTH) {
+            _buffer = _pooledBuffer;
+            _pooledBuffer = null;
+            if (_buffer == null) {
+                _buffer = new byte[DEFAULT_BUFFER_LENGTH];
+            }
+        }
+        _length = _buffer.length;
+        _little = false;
+        _namingContext = null;
+    }
+
+    public void setUnaligned() {
+        _unaligned = true;
+    }
+
+    public byte[] getBytes() {
+        return ArrayUtil.getBytes(_buffer, 0, _length);
+    }
+
+    public byte[] getBuffer() {
+        return _buffer;
+    }
+
+    public int getOffset() {
+        return _offset;
+    }
+
+    public int getGiopVersion() {
+        GiopMessage message = _giopMessage;
+        if (message == null) {
+            throw new IllegalStateException();
+        }
+        return message.giopVersion;
+    }
+
+    public void setLength(int length) {
+        if (_buffer.length < length) {
+            byte[] newBuffer = new byte[length];
+            System.arraycopy(_buffer, 0, newBuffer, 0, 12);
+            pool(_buffer);
+            _buffer = newBuffer;
+        }
+        _length = length;
+    }
+
+    public void setNamingContext(ClientNamingContext namingContext) {
+        _namingContext = namingContext;
+    }
+
+    public void setEncapsulation(byte[] data) {
+        _buffer = data;
+        _offset = 0;
+        _length = data.length;
+        _little = read_boolean();
+    }
+
+    public boolean hasMoreData() {
+        return _offset < _length;
+    }
+
+    /**
+     * * Align the buffer offset so the next item is read from at an offset
+     * * aligned according to <code>alignment</code>, which must be a
+     * * power of 2 (and at least = 1).
+     * * <p>Then we check if there is enough space left in the buffer for
+     * * an item of <code>size</code> bytes; if not, we throw an
+     * * exception.
+     */
+    public final void read_align(int alignment, int size) {
+        if (_unaligned) {
+            alignment = 1;
+        }
+        int mask = alignment - 1;
+        _offset += (alignment - (_offset & mask)) & mask;
+        if (_offset + size <= _length) {
+            return;
+        } else {
+            throw new org.omg.CORBA.MARSHAL("offset (" + _offset + ") + size ("
+                                            + size + ") > buffer length (" + _length + ")");
+        }
+    }
+
+    /**
+     * * Convenience method needed in many places.
+     */
+    public byte[] read_octet_sequence() {
+        int n = read_long();
+        if (n == 0) {
+            return EMPTY_BYTE_ARRAY;
+        }
+        byte[] bytes = new byte[n];
+        read_octet_array(bytes, 0, n);
+        return bytes;
+    }
+
+    public GiopMessage read_message() {
+        return receive_message(null, null);
+    }
+
+    public GiopMessage receive_message(java.io.InputStream input, String host) {
+        GiopMessage message = _giopMessage;
+        if (message == null) {
+            message = _giopMessage = new GiopMessage();
+        }
+        if (input != null) {
+            read(input, _buffer, 0, 12);
+        }
+        int m1 = read_octet();
+        int m2 = read_octet();
+        int m3 = read_octet();
+        int m4 = read_octet();
+        if (m1 != 'G' || m2 != 'I' || m3 != 'O' || m4 != 'P') {
+            throw new BadMagicException(m1 + "," + m2 + "," + m3 + "," + m4);
+        }
+        int v1 = read_octet();
+        int v2 = read_octet();
+        if (v1 != 1 || (v2 < 0 || v2 > 2)) // support GIOP 1.0, 1.1, 1.2
+        {
+            throw new UnsupportedProtocolVersionException(v1 + "." + v2);
+        }
+        int giopVersion;
+        message.giopVersion = giopVersion = v2;
+        int flags = read_octet();
+        _little = (flags & 1) != 0;
+        boolean fragmented = (flags & 2) != 0;
+        int messageType = message.type = read_octet();
+        int messageSize = message.size = read_ulong();
+        if (fragmented && messageSize % 8 != 0) {
+            throw new org.omg.CORBA.MARSHAL("GIOP Fragment: bad message size (not divisible by 8) = " + messageSize);
+        }
+        _length = 12 + messageSize;
+        if (messageSize > 0 && input != null) {
+            if (_buffer.length < _length) {
+                byte[] newBuffer = new byte[_length];
+                System.arraycopy(_buffer, 0, newBuffer, 0, 12);
+                pool(_buffer);
+                _buffer = newBuffer;
+            }
+            read(input, _buffer, 12, _length);
+        }
+        if (RMI_TRACE && host != null) {
+            byte[] data = new byte[_length];
+            System.arraycopy(_buffer, 0, data, 0, _length);
+            RmiTrace.receive(host, data);
+        }
+        switch (messageType) {
+            case MsgType_1_1._Request:
+                switch (giopVersion) {
+                    case GiopVersion.VERSION_1_0:
+                        {
+                            RequestHeader_1_0 req10 = RequestHeader_1_0Helper.read(this);
+                            RequestHeader_1_2 req12 = new RequestHeader_1_2();
+                            req12.service_context = req10.service_context;
+                            req12.request_id = req10.request_id;
+                            req12.response_flags = (byte) (req10.response_expected ? 3 : 0);
+                            req12.operation = req10.operation;
+                            (req12.target = new TargetAddress()).object_key(req10.object_key);
+                            message.request = req12;
+                        }
+                        break;
+                    case GiopVersion.VERSION_1_1:
+                        {
+                            RequestHeader_1_1 req11 = RequestHeader_1_1Helper.read(this);
+                            RequestHeader_1_2 req12 = new RequestHeader_1_2();
+                            req12.service_context = req11.service_context;
+                            req12.request_id = req11.request_id;
+                            req12.response_flags = (byte) (req11.response_expected ? 3 : 0);
+                            req12.operation = req11.operation;
+                            (req12.target = new TargetAddress()).object_key(req11.object_key);
+                            message.request = req12;
+                        }
+                        break;
+                    case GiopVersion.VERSION_1_2:
+                        message.request = RequestHeader_1_2Helper.read(this);
+                        if (_length > _offset) {
+                            read_align(8, 0); // parameters are 8-byte aligned (if present)
+                        }
+                        break;
+                }
+                break;
+            case MsgType_1_1._Reply:
+                message.reply = ReplyHeader_1_2Helper.read(this);
+                if (giopVersion >= GiopVersion.VERSION_1_2) {
+                    if (_length > _offset) {
+                        read_align(8, 0); // results are 8-byte aligned (if present)
+                    }
+                }
+                break;
+            case MsgType_1_1._LocateRequest:
+                switch (giopVersion) {
+                    case GiopVersion.VERSION_1_0:
+                    case GiopVersion.VERSION_1_1:
+                        {
+                            LocateRequestHeader_1_0 req10 = LocateRequestHeader_1_0Helper.read(this);
+                            LocateRequestHeader_1_2 req12 = new LocateRequestHeader_1_2();
+                            req12.request_id = req10.request_id;
+                            (req12.target = new TargetAddress()).object_key(req10.object_key);
+                            message.locateRequest = req12;
+                        }
+                        break;
+                    default:
+                        message.locateRequest = LocateRequestHeader_1_2Helper.read(this);
+                }
+                break;
+            case MsgType_1_1._LocateReply:
+                // We never send LocateRequest, so this is unexpected.
+                throw new org.omg.CORBA.MARSHAL("GIOP LocateReply: unexpected");
+                // TODO: CloseConnection messages etc...
+            default:
+                throw new org.omg.CORBA.NO_IMPLEMENT("TODO: message type = " + messageType);
+        }
+        return message;
+    }
+
+    // -----------------------------------------------------------------------
+    // public methods from org.omg.CORBA.portable.InputStream
+    // -----------------------------------------------------------------------
+
+    public boolean read_boolean() {
+        read_align(1, 1);
+        int b = _buffer[_offset++];
+        if (b == 0) {
+            return false;
+        } else if (b == 1) {
+            return true;
+        } else {
+            throw new org.omg.CORBA.MARSHAL("read_boolean: value = " + b);
+        }
+    }
+
+    public char read_char() {
+        read_align(1, 1);
+        return (char) _buffer[_offset++];
+    }
+
+    public char read_wchar() {
+        read_align(1, 3);
+        int size = (int) read_wchar_size();
+        int value = (char) read_ushort_no_align_big_endian();
+        boolean littleEndian = ((value & 0xffff) == 0xFFFE);
+        boolean bigEndian = ((value & 0xffff) == 0xFEFF);
+        boolean bomPresent = (littleEndian || bigEndian);
+        if ((bomPresent && size != 4) || (!bomPresent && size != 2)) {
+            throw new org.omg.CORBA.MARSHAL("wchar size = " + size
+                                            + (bomPresent ? " (BOM present)" : " (BOM absent)"));
+        }
+        if (littleEndian) {
+            read_align(1, 2);
+            return (char) read_ushort_no_align_little_endian();
+        } else if (bigEndian) {
+            read_align(1, 2);
+            return (char) read_ushort_no_align_big_endian();
+        } else {
+            // no BOM, big endian
+            return (char) value;
+        }
+    }
+
+    public byte read_octet() {
+        read_align(1, 1);
+        return _buffer[_offset++];
+    }
+
+    public short read_short() {
+        read_align(2, 2);
+        int oldOffset = _offset;
+        _offset += 2;
+        if (_little) {
+            return LittleEndian.getShort(_buffer, oldOffset);
+        } else {
+            return BigEndian.getShort(_buffer, oldOffset);
+        }
+    }
+
+    public short read_ushort() {
+        return read_short();
+    }
+
+    public int read_long() {
+        read_align(4, 4);
+        int oldOffset = _offset;
+        _offset += 4;
+        if (_little) {
+            return LittleEndian.getInt(_buffer, oldOffset);
+        } else {
+            return BigEndian.getInt(_buffer, oldOffset);
+        }
+    }
+
+    public int read_ulong() {
+        return read_long();
+    }
+
+    public long read_longlong() {
+        read_align(8, 8);
+        int oldOffset = _offset;
+        _offset += 8;
+        if (_little) {
+            return LittleEndian.getLong(_buffer, oldOffset);
+        } else {
+            return BigEndian.getLong(_buffer, oldOffset);
+        }
+    }
+
+    public long read_ulonglong() {
+        return read_longlong();
+    }
+
+    public float read_float() {
+        return Float.intBitsToFloat(read_ulong());
+    }
+
+    public double read_double() {
+        return Double.longBitsToDouble(read_ulonglong());
+    }
+
+    public java.lang.String read_string() {
+        int size = read_ulong();
+        if (size < 1) // Zero or negative due to unsigned value > 2Gb
+        {
+            throw new org.omg.CORBA.MARSHAL("read_string: size = " + size);
+        }
+        read_align(1, size);
+        size--;
+        if (_buffer[_offset + size] != 0) {
+            throw new org.omg.CORBA.MARSHAL("read_string: missing NUL");
+        }
+        // Assume transmission code set is UTF-8
+        String value = UTF8.toString(_buffer, _offset, size);
+        _offset += size + 1; // 1 for NUL
+        return value;
+    }
+
+    public java.lang.String read_wstring() {
+        int size = read_long();
+        if (size == 0) {
+            return "";
+        }
+        read_align(2, size);
+        int numChars = size / 2;
+        boolean littleEndian = false;
+        read_align(1, 2);
+        int firstChar = (char) read_ushort_no_align_big_endian();
+        _offset += 2;
+        char[] result;
+        int index = 0;
+        if (firstChar == 0xFEFF) {
+            // big endian
+            result = new char[--numChars];
+        } else if (firstChar == 0xFFFE) {
+            // little endian
+            result = new char[--numChars];
+            littleEndian = true;
+        } else {
+            // no BOM, big endian
+            result = new char[numChars--];
+            result[index++] = (char) firstChar;
+        }
+        read_align(1, 2 * numChars);
+        if (littleEndian) {
+            for (int i = 0; i < numChars; i++) {
+                result[index++] = (char) read_ushort_no_align_little_endian();
+                _offset += 2;
+            }
+        } else {
+            for (int i = 0; i < numChars; i++) {
+                result[index++] = (char) read_ushort_no_align_big_endian();
+                _offset += 2;
+            }
+        }
+        return new String(result);
+    }
+
+    public void read_boolean_array(boolean[] value, int offset, int length) {
+        for (int i = 0; i < length; i++) {
+            value[offset + i] = read_boolean();
+        }
+    }
+
+    public void read_char_array(char[] value, int offset, int length) {
+        for (int i = 0; i < length; i++) {
+            value[i] = read_char();
+        }
+    }
+
+    public void read_wchar_array(char[] value, int offset, int length) {
+        for (int i = 0; i < length; i++) {
+            value[offset + i] = read_wchar();
+        }
+    }
+
+    public void read_octet_array(byte[] value, int offset, int length) {
+        read_align(1, length);
+        System.arraycopy(_buffer, _offset, value, offset, length);
+        _offset += length;
+    }
+
+    public void read_short_array(short[] value, int offset, int length) {
+        for (int i = 0; i < length; i++) {
+            value[offset + i] = read_short();
+        }
+    }
+
+    public void read_ushort_array(short[] value, int offset, int length) {
+        for (int i = 0; i < length; i++) {
+            value[offset + i] = read_ushort();
+        }
+    }
+
+    public void read_long_array(int[] value, int offset, int length) {
+        for (int i = 0; i < length; i++) {
+            value[offset + i] = read_long();
+        }
+    }
+
+    public void read_ulong_array(int[] value, int offset, int length) {
+        for (int i = 0; i < length; i++) {
+            value[offset + i] = read_ulong();
+        }
+    }
+
+    public void read_longlong_array(long[] value, int offset, int length) {
+        for (int i = 0; i < length; i++) {
+            value[offset + i] = read_longlong();
+        }
+    }
+
+    public void read_ulonglong_array(long[] value, int offset, int length) {
+        for (int i = 0; i < length; i++) {
+            value[offset + i] = read_ulonglong();
+        }
+    }
+
+    public void read_float_array(float[] value, int offset, int length) {
+        for (int i = 0; i < length; i++) {
+            value[offset + i] = read_float();
+        }
+    }
+
+    public void read_double_array(double[] value, int offset, int length) {
+        for (int i = 0; i < length; i++) {
+            value[offset + i] = read_double();
+        }
+    }
+
+    public org.omg.CORBA.Object read_Object() {
+        IOR ior = IORHelper.read(this);
+        if (ior.profiles.length == 0) {
+            return null;
+        }
+        ObjectRef stub = null;
+        if (ior.type_id.length() != 0) {
+            // Return instance of appropriate stub class
+            if (ior.type_id.startsWith("RMI:") && ior.type_id.endsWith(":0000000000000000")) {
+                String interfaceName = ior.type_id.substring(4, ior.type_id.length() - 17);
+
+                System.out.println("TODO: CdrInputStream.read_Object(): NYI: interfaceName = " + interfaceName + ", ior = " + ior.type_id);
+                stub = null;
+
+                //Class remoteInterface = ThreadContext.loadClass(interfaceName);
+                //stub = StubFactory.getInstance().getStub(remoteInterface);
+            }
+            if (ior.type_id.startsWith("IDL:") && ior.type_id.endsWith(":1.0")) {
+                String interfaceName = ior.type_id.substring(4, ior.type_id.length() - 4).replace('/', '.');
+
+                System.out.println("TODO: CdrInputStream.read_Object(): NYI: interfaceName = " + interfaceName + ", ior = " + ior.type_id);
+                stub = null;
+
+                //Class remoteInterface = ThreadContext.loadClass(interfaceName);
+                //stub = StubFactory.getInstance().getStub(remoteInterface);
+            }
+        }
+        if (stub == null) {
+            stub = new ObjectRef();
+        }
+        stub.$setIOR(ior);
+        stub.$setNamingContext(_namingContext);
+        return stub;
+    }
+
+    public org.omg.CORBA.TypeCode read_TypeCode() {
+        return read_TypeCode(new java.util.HashMap());
+    }
+
+    private org.omg.CORBA.TypeCode read_TypeCode(java.util.HashMap table) {
+        int beforeKindOffset = _offset;
+        int tk = read_ulong();
+        int afterKindOffset = _offset;
+        org.apache.geronimo.interop.rmi.iiop.TypeCode tc;
+        if (tk == 0xffffffff) {
+            // an indirection to another TypeCode we have seen.
+            int offset = read_long();
+            Integer key = new Integer(afterKindOffset + offset);
+            org.omg.CORBA.TypeCode ref = (org.omg.CORBA.TypeCode) table.get(key);
+            if (ref == null) {
+                throw new org.omg.CORBA.MARSHAL("read_TypeCode: bad indirection: offset = " + offset);
+            }
+            tc = new org.apache.geronimo.interop.rmi.iiop.TypeCode(TCKind.tk_null);
+            tc.indirection(ref);
+            return tc;
+        }
+        tc = new org.apache.geronimo.interop.rmi.iiop.TypeCode(TCKind.from_int(tk));
+        table.put(new Integer(beforeKindOffset), tc);
+        switch (tk) {
+            case TCKind._tk_null:
+            case TCKind._tk_void:
+            case TCKind._tk_TypeCode:
+            case TCKind._tk_any:
+            case TCKind._tk_boolean:
+            case TCKind._tk_char:
+            case TCKind._tk_wchar:
+            case TCKind._tk_octet:
+            case TCKind._tk_short:
+            case TCKind._tk_ushort:
+            case TCKind._tk_long:
+            case TCKind._tk_ulong:
+            case TCKind._tk_longlong:
+            case TCKind._tk_ulonglong:
+            case TCKind._tk_float:
+            case TCKind._tk_double:
+            case TCKind._tk_longdouble:
+                // All these require only a TCKind.
+                break;
+            case TCKind._tk_fixed:
+                tc.fixed_digits(read_ushort());
+                tc.fixed_scale(read_short());
+                break;
+            case TCKind._tk_string:
+            case TCKind._tk_wstring:
+                tc.length(read_ulong());
+                break;
+            case TCKind._tk_objref:
+            case TCKind._tk_native:
+            case TCKind._tk_abstract_interface:
+                {
+                    boolean saveLittle = begin();
+                    tc.id(read_string());
+                    tc.name(read_string());
+                    end(saveLittle);
+                }
+                break;
+            case TCKind._tk_alias:
+                // Change Here
+            case TCKind._tk_value_box:
+                // End Change Here
+                {
+                    boolean saveLittle = begin();
+                    tc.id(read_string());
+                    tc.name(read_string());
+                    tc.content_type(read_TypeCode(table));
+                    end(saveLittle);
+                }
+                break;
+            case TCKind._tk_sequence:
+            case TCKind._tk_array:
+                {
+                    boolean saveLittle = begin();
+                    tc.content_type(read_TypeCode(table));
+                    tc.length(read_ulong());
+                    end(saveLittle);
+                }
+                break;
+            case TCKind._tk_enum:
+                {
+                    boolean saveLittle = begin();
+                    tc.id(read_string());
+                    tc.name(read_string());
+                    int count = read_ulong();
+                    tc.member_count(count);
+                    for (int i = 0; i < count; i++) {
+                        tc.member_name(i, read_string());
+                    }
+                    end(saveLittle);
+                }
+                break;
+            case TCKind._tk_struct:
+            case TCKind._tk_except:
+                {
+                    boolean saveLittle = begin();
+                    tc.id(read_string());
+                    tc.name(read_string());
+                    int count = read_ulong();
+                    tc.member_count(count);
+                    for (int i = 0; i < count; i++) {
+                        tc.member_name(i, read_string());
+                        tc.member_type(i, read_TypeCode(table));
+                    }
+                    end(saveLittle);
+                }
+                break;
+            case TCKind._tk_union:
+                {
+                    boolean saveLittle = begin();
+                    tc.id(read_string());
+                    tc.name(read_string());
+                    org.omg.CORBA.TypeCode dt = read_TypeCode(table);
+                    tc.discriminator_type(dt);
+                    int di = read_ulong();
+                    int count = read_ulong();
+                    tc.member_count(count);
+                    for (int i = 0; i < count; i++) {
+                        org.omg.CORBA.Any label = new org.apache.geronimo.interop.rmi.iiop.Any();
+                        read_Any(label.create_output_stream(), dt);
+                        label.read_value(null, dt);
+                        tc.member_label(i, label);
+                        tc.member_name(i, read_string());
+                        tc.member_type(i, read_TypeCode(table));
+                    }
+                    tc.default_index(di); // must call after setting members
+                    end(saveLittle);
+                }
+                break;
+            case TCKind._tk_value:
+                {
+                    boolean saveLittle = begin();
+                    tc.id(read_string());
+                    tc.name(read_string());
+                    tc.type_modifier(read_short());
+                    tc.concrete_base_type(read_TypeCode(table));
+                    int count = read_ulong();
+                    tc.member_count(count);
+                    for (int i = 0; i < count; i++) {
+                        tc.member_name(i, read_string());
+                        tc.member_type(i, read_TypeCode(table));
+                        tc.member_visibility(i, read_short());
+                    }
+                    end(saveLittle);
+                }
+                break;
+            default:
+                throw new org.omg.CORBA.MARSHAL("read_TypeCode: kind = " + tk);
+        }
+        return tc;
+    }
+
+    public org.omg.CORBA.Any read_Any() {
+        org.omg.CORBA.TypeCode tc = read_TypeCode();
+        org.omg.CORBA.Any value = new org.apache.geronimo.interop.rmi.iiop.Any();
+        org.omg.CORBA.portable.OutputStream os = value.create_output_stream();
+        read_Any(os, tc);
+        value.read_value(os.create_input_stream(), tc);
+        return value;
+    }
+
+    // Sybase-internal
+    public void read_Any(org.omg.CORBA.portable.OutputStream os, org.omg.CORBA.TypeCode tc) {
+        try {
+            int tk = tc.kind().value();
+            switch (tk) {
+                case TCKind._tk_null:
+                case TCKind._tk_void:
+                    break;
+                case TCKind._tk_TypeCode:
+                    os.write_TypeCode(read_TypeCode());
+                    break;
+                case TCKind._tk_any:
+                    os.write_any(read_Any());
+                    break;
+                case TCKind._tk_boolean:
+                    os.write_boolean(read_boolean());
+                    break;
+                case TCKind._tk_char:
+                    os.write_char(read_char());
+                    break;
+                case TCKind._tk_wchar:
+                    os.write_wchar(read_wchar());
+                    break;
+                case TCKind._tk_octet:
+                    os.write_octet(read_octet());
+                    break;
+                case TCKind._tk_short:
+                    os.write_short(read_short());
+                    break;
+                case TCKind._tk_ushort:
+                    os.write_ushort(read_ushort());
+                    break;
+                case TCKind._tk_long:
+                    os.write_long(read_long());
+                    break;
+                case TCKind._tk_ulong:
+                case TCKind._tk_enum:
+                    os.write_ulong(read_ulong());
+                    break;
+                case TCKind._tk_longlong:
+                    os.write_longlong(read_longlong());
+                    break;
+                case TCKind._tk_ulonglong:
+                    os.write_ulonglong(read_ulonglong());
+                    break;
+                case TCKind._tk_float:
+                    os.write_float(read_float());
+                    break;
+                case TCKind._tk_double:
+                    os.write_double(read_double());
+                    break;
+                case TCKind._tk_string:
+                    os.write_string(read_string());
+                    break;
+                case TCKind._tk_wstring:
+                    os.write_wstring(read_wstring());
+                    break;
+                case TCKind._tk_objref:
+                    os.write_Object(read_Object());
+                    break;
+                case TCKind._tk_alias:
+                    read_Any(os, tc.content_type());
+                    break;
+                case TCKind._tk_array:
+                    {
+                        int n = tc.length();
+                        org.omg.CORBA.TypeCode c = tc.content_type();
+                        for (int i = 0; i < n; i++) {
+                            read_Any(os, c);
+                        }
+                    }
+                    break;
+                case TCKind._tk_sequence:
+                    {
+                        int n = read_ulong();
+                        os.write_ulong(n);
+                        org.omg.CORBA.TypeCode c = tc.content_type();
+                        for (int i = 0; i < n; i++) {
+                            read_Any(os, c);
+                        }
+                    }
+                    break;
+                case TCKind._tk_struct:
+                case TCKind._tk_except:
+                    {
+                        int n = tc.member_count();
+                        for (int i = 0; i < n; i++) {
+                            read_Any(os, tc.member_type(i));
+                        }
+                    }
+                    break;
+                case TCKind._tk_union:
+                    {
+                        org.omg.CORBA.TypeCode dt = tc.discriminator_type();
+                        org.omg.CORBA.Any disc = new org.apache.geronimo.interop.rmi.iiop.Any();
+                        read_Any(disc.create_output_stream(), dt);
+                        disc.read_value(null, dt);
+                        write_disc(disc, os, dt);
+                        int di = tc.default_index();
+                        int i, n = tc.member_count();
+                        for (i = 0; i < n; i++) {
+                            org.omg.CORBA.Any label = tc.member_label(i);
+                            if (label.equal(disc)) {
+                                read_Any(os, tc.member_type(i));
+                                break;
+                            }
+                        }
+                        if (i == n && di >= 0) {
+                            read_Any(os, tc.member_type(di));
+                        }
+                    }
+                    break;
+                case TCKind._tk_fixed: // TODO
+                case TCKind._tk_value: // TODO
+                default:
+                    throw new org.omg.CORBA.MARSHAL("read_Any: type = " + tc);
+            }
+        } catch (org.omg.CORBA.TypeCodePackage.BadKind ex) {
+            throw new org.omg.CORBA.MARSHAL("read_Any: " + ex.toString());
+        } catch (org.omg.CORBA.TypeCodePackage.Bounds ex) {
+            throw new org.omg.CORBA.MARSHAL("read_Any: " + ex.toString());
+        }
+    }
+
+    public org.omg.CORBA.Any read_any() {
+        throw new org.omg.CORBA.NO_IMPLEMENT("read_any: NOT YET IMPLMENTED");
+    }
+
+    public org.omg.CORBA.Principal read_Principal() {
+        throw new org.omg.CORBA.NO_IMPLEMENT("read_Principal: NOT YET IMPLMENTED");
+    }
+
+    public int read() throws java.io.IOException {
+        throw new org.omg.CORBA.NO_IMPLEMENT("read: NOT YET IMPLMENTED");
+    }
+
+    public java.math.BigDecimal read_fixed() {
+        throw new org.omg.CORBA.NO_IMPLEMENT("read_fixed: NOT YET IMPLMENTED");
+    }
+
+    public org.omg.CORBA.Context read_Context() {
+        throw new org.omg.CORBA.NO_IMPLEMENT("read_Context: NOT YET IMPLMENTED");
+    }
+
+    public org.omg.CORBA.Object read_Object(Class _class) {
+        throw new org.omg.CORBA.NO_IMPLEMENT("read_Object: NOT YET IMPLMENTED");
+    }
+
+    public org.omg.CORBA.ORB orb() {
+        throw new org.omg.CORBA.NO_IMPLEMENT("orb: NOT YET IMPLMENTED");
+    }
+
+
+    // -----------------------------------------------------------------------
+    // public methods from org.omg.CORBA_2_3.portable.InputStream
+    // -----------------------------------------------------------------------
+
+    public java.io.Serializable read_value() {
+        throw new org.omg.CORBA.NO_IMPLEMENT("read_value: NOT YET IMPLMENTED");
+    }
+
+    public java.io.Serializable read_value(Class _class) {
+        throw new org.omg.CORBA.NO_IMPLEMENT("read_value: NOT YET IMPLMENTED");
+    }
+
+    public java.io.Serializable read_value(org.omg.CORBA.portable.BoxedValueHelper helper) {
+        throw new org.omg.CORBA.NO_IMPLEMENT("read_value: NOT YET IMPLMENTED");
+    }
+
+    public java.io.Serializable read_value(java.lang.String id) {
+        throw new org.omg.CORBA.NO_IMPLEMENT("read_value: NOT YET IMPLMENTED");
+    }
+
+    public java.io.Serializable read_value(java.io.Serializable todo) {
+        throw new org.omg.CORBA.NO_IMPLEMENT("read_value: NOT YET IMPLMENTED");
+    }
+
+    public java.lang.Object read_abstract_interface() {
+        throw new org.omg.CORBA.NO_IMPLEMENT("read_abstract_interface: NOT YET IMPLMENTED");
+    }
+
+    public java.lang.Object read_abstract_interface(Class _class) {
+        throw new org.omg.CORBA.NO_IMPLEMENT("read_abstract_interface: NOT YET IMPLMENTED");
+    }
+
+
+    // -----------------------------------------------------------------------
+    // protected methods
+    // -----------------------------------------------------------------------
+
+    protected void pool(byte[] oldBuffer) {
+        if (oldBuffer.length <= MAXIMUM_POOLED_BUFFER_LENGTH) {
+            _pooledBuffer = oldBuffer;
+        }
+    }
+
+    protected int read_ushort_no_align_big_endian() {
+        return UnsignedShort.intValue(BigEndian.getShort(_buffer, _offset));
+    }
+
+    protected int read_ushort_no_align_little_endian() {
+        return UnsignedShort.intValue(LittleEndian.getShort(_buffer, _offset));
+    }
+
+    protected int read_wchar_size() {
+        read_align(1, 1);
+        int size = _buffer[_offset++];
+        if (size < 2) {
+            throw new org.omg.CORBA.MARSHAL("wchar size = " + size);
+        }
+        return size;
+    }
+
+    protected void read(java.io.InputStream input, byte[] buffer, int offset, int length) {
+        try {
+            while (offset < length) {
+                int needLength = length - offset;
+                int readLength = input.read(buffer, offset, needLength);
+                if (readLength == -1) {
+                    throw new org.omg.CORBA.MARSHAL("read: EOF");
+                }
+                offset += readLength;
+            }
+        } catch (java.io.IOException ex) {
+            throw new org.omg.CORBA.COMM_FAILURE(ex.toString());
+        }
+    }
+
+    public boolean begin() {
+        int length = read_ulong(); // encapsulation length
+        boolean saveLittle = _little;
+        _little = read_boolean();
+        return saveLittle;
+    }
+
+    public void end(boolean saveLittle) {
+        _little = saveLittle;
+    }
+
+    private void write_disc(org.omg.CORBA.Any disc, org.omg.CORBA.portable.OutputStream os, org.omg.CORBA.TypeCode dt) {
+        int tk = dt.kind().value();
+        if (tk == TCKind._tk_alias) {
+            try {
+                write_disc(disc, os, dt.content_type());
+            } catch (org.omg.CORBA.TypeCodePackage.BadKind ex) {
+                throw new org.omg.CORBA.MARSHAL("write_disc: " + ex.toString());
+            }
+        }
+        switch (tk) {
+            case TCKind._tk_boolean:
+                os.write_boolean(disc.extract_boolean());
+                break;
+            case TCKind._tk_octet:
+                os.write_octet(disc.extract_octet());
+                break;
+            case TCKind._tk_short:
+                os.write_short(disc.extract_short());
+                break;
+            case TCKind._tk_ushort:
+                os.write_ushort(disc.extract_ushort());
+                break;
+            case TCKind._tk_long:
+                os.write_long(disc.extract_long());
+                break;
+            case TCKind._tk_ulong:
+            case TCKind._tk_enum:
+                os.write_ulong(disc.extract_ulong());
+                break;
+            case TCKind._tk_longlong:
+                os.write_longlong(disc.extract_longlong());
+                break;
+            case TCKind._tk_ulonglong:
+                os.write_ulonglong(disc.extract_ulonglong());
+                break;
+            default:
+                throw new org.omg.CORBA.MARSHAL("write_disc: type = " + dt);
+        }
+    }
+
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/CdrOutputStream.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/CdrOutputStream.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/CdrOutputStream.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,980 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop;
+
+import org.omg.CORBA.TCKind;
+
+import org.apache.geronimo.interop.GIOP.*;
+import org.apache.geronimo.interop.IOP.*;
+import org.apache.geronimo.interop.rmi.RmiTrace;
+import org.apache.geronimo.interop.util.ArrayUtil;
+import org.apache.geronimo.interop.util.BigEndian;
+import org.apache.geronimo.interop.util.ExceptionUtil;
+import org.apache.geronimo.interop.util.JavaClass;
+import org.apache.geronimo.interop.util.UTF8;
+
+
+/**
+ * * CORBA 2.3 / GIOP 1.2 CDR OutputStream.
+ */
+public class CdrOutputStream extends org.omg.CORBA_2_3.portable.OutputStream {
+    public static CdrOutputStream getInstance() {
+        CdrOutputStream output = new CdrOutputStream();
+        output.init(new byte[DEFAULT_BUFFER_LENGTH], 0);
+        return output;
+    }
+
+    public static CdrOutputStream getInstance(byte[] buffer) {
+        CdrOutputStream output = new CdrOutputStream();
+        output.init(buffer, 0);
+        return output;
+    }
+
+    public static CdrOutputStream getInstance(byte[] buffer, int offset) {
+        CdrOutputStream output = new CdrOutputStream();
+        output.init(buffer, offset);
+        return output;
+    }
+
+    public static CdrOutputStream getInstanceForEncapsulation() {
+        CdrOutputStream output = getInstance();
+        output.write_boolean(false); // byte order: big endian
+        return output;
+    }
+
+    public static CdrOutputStream getPooledInstance() {
+        CdrOutputStream output = null; //(CdrOutputStream)_pool.get();
+        if (output == null) {
+            output = getInstance();
+        }
+        return output;
+    }
+
+    // -----------------------------------------------------------------------
+    // private data
+    // -----------------------------------------------------------------------
+
+    private static final int DEFAULT_BUFFER_LENGTH = 64;
+
+    private static final int MAXIMUM_POOLED_BUFFER_LENGTH = 1024;
+
+    private static final boolean RMI_TRACE = true; //SystemProperties.rmiTrace();
+
+    private static IOR NULL_IOR = new IOR("", new TaggedProfile[0]);
+
+    private static char[] GIOP_MAGIC = {'G', 'I', 'O', 'P'};
+
+    private static ServiceContext[] EMPTY_SERVICE_CONTEXT_LIST = {};
+
+    private static Version GIOP_VERSION_1_0 = new Version((byte) 1, (byte) 0);
+    private static Version GIOP_VERSION_1_1 = new Version((byte) 1, (byte) 1);
+    private static Version GIOP_VERSION_1_2 = new Version((byte) 1, (byte) 2);
+
+    //private static ThreadLocalInstancePool _pool = new ThreadLocalInstancePool(CdrOutputStream.class.getName());
+
+    private int _giopVersion = GiopVersion.VERSION_1_2;
+
+    private boolean _unaligned;
+
+    private byte[] _pooledBuffer;
+
+    // -----------------------------------------------------------------------
+    // package-private data
+    // -----------------------------------------------------------------------
+
+    byte[] _buffer;
+
+    int _offset;
+
+    int _length;
+
+    // -----------------------------------------------------------------------
+    // public methods
+    // -----------------------------------------------------------------------
+
+    public void init(byte[] buffer, int offset) {
+        _buffer = buffer;
+        _offset = offset;
+        _length = _buffer.length;
+    }
+
+    public void recycle() {
+        reset();
+        //_pool.put(this);
+    }
+
+    public void reset() {
+        _offset = 0;
+        if (_buffer.length > MAXIMUM_POOLED_BUFFER_LENGTH) {
+            _buffer = _pooledBuffer;
+            _pooledBuffer = null;
+            if (_buffer == null) {
+                _buffer = new byte[DEFAULT_BUFFER_LENGTH];
+            }
+        }
+        _length = _buffer.length;
+    }
+
+    public void setUnaligned() {
+        _unaligned = true;
+    }
+
+    public byte[] getBytes() {
+        int n = _offset;
+        byte[] bytes = new byte[n];
+        System.arraycopy(_buffer, 0, bytes, 0, n);
+        return bytes;
+    }
+
+    public byte[] getBuffer() {
+        return _buffer;
+    }
+
+    public int getOffset() {
+        return _offset;
+    }
+
+    public int getLength() {
+        return _length;
+    }
+
+    public byte[] getEncapsulation() {
+        byte[] data = new byte[_offset];
+        System.arraycopy(_buffer, 0, data, 0, _offset);
+        return data;
+    }
+
+    public void setGiopVersion(int version) {
+        _giopVersion = version;
+    }
+
+    /**
+     * * Align the buffer offset so the next item is written at an offset
+     * * aligned according to <code>alignment</code>, which must be a
+     * * power of 2 (and at least = 1).
+     * * <p>The padding bytes are set to zero, to prevent the
+     * * security problems inherent in uninitialised padding bytes.
+     * * <p>Then we check if there is enough space left in the buffer for
+     * * an item of <code>size</code> bytes; if not, we expand the buffer
+     * * to make space.
+     */
+    public final void write_align(int alignment, int size) {
+        if (_unaligned) {
+            alignment = 1;
+        }
+        int needLength = _offset + alignment + size;
+        if (needLength > _length) {
+            // We need to increase the buffer size. We allow for a bit
+            // of future expansion (if possible).
+            int factor8 = 32;
+            for (int pass = 1; pass <= 7; pass++, factor8 /= 2) {
+                // We try factors 5, 3, 2, 1.5, 1.25, 1.125, 1.
+                try {
+                    byte[] newBuffer = new byte[needLength + factor8 * needLength / 8];
+                    // Copy old buffer contents into new buffer.
+                    System.arraycopy(_buffer, 0, newBuffer, 0, _offset);
+                    pool(_buffer);
+                    _buffer = newBuffer;
+                    _length = newBuffer.length;
+                    break;
+                } catch (OutOfMemoryError ignore) {
+                    if (pass == 7) {
+                        throw new org.omg.CORBA.NO_MEMORY(needLength + " bytes");
+                    }
+                }
+            }
+        }
+        int mask = alignment - 1;
+        for (int i = (alignment - (_offset & mask)) & mask; i > 0; i--) {
+            _buffer[_offset++] = 0;
+        }
+    }
+
+    /**
+     * * Convenience method needed in many places.
+     */
+    public void write_octet_sequence(byte[] bytes) {
+        if (bytes == null) {
+            bytes = ArrayUtil.EMPTY_BYTE_ARRAY;
+        }
+        int n = bytes.length;
+        write_long(n);
+        write_octet_array(bytes, 0, n);
+    }
+
+    public void write_message(int messageType) {
+        MessageHeader_1_1 header = new MessageHeader_1_1();
+        header.magic = GIOP_MAGIC;
+        switch (_giopVersion) {
+            case GiopVersion.VERSION_1_0:
+                header.GIOP_version = GIOP_VERSION_1_2;
+                break;
+            case GiopVersion.VERSION_1_1:
+                header.GIOP_version = GIOP_VERSION_1_1;
+                break;
+            case GiopVersion.VERSION_1_2:
+                header.GIOP_version = GIOP_VERSION_1_2;
+                break;
+            default:
+                throw new IllegalStateException();
+        }
+        header.flags = 0;
+        header.message_type = (byte) messageType;
+        header.message_size = 0;
+        // header.message_size is rewritten later
+        MessageHeader_1_1Helper.write(this, header);
+    }
+
+    public void write_message_size() {
+        int messageSize = _offset - 12;
+        int saveOffset = _offset;
+        _offset = 8;
+        write_long(messageSize);
+        _offset = saveOffset;
+    }
+
+    public void write_request(RequestHeader_1_2 request, CdrOutputStream parameters) {
+        if (request.service_context == null) {
+            // Avoid allocation of empty array by Helper.
+            request.service_context = EMPTY_SERVICE_CONTEXT_LIST;
+        }
+        write_message(MsgType_1_1._Request);
+        switch (_giopVersion) {
+            case GiopVersion.VERSION_1_0:
+                RequestHeader_1_0 req10 = new RequestHeader_1_0();
+                req10.service_context = request.service_context;
+                req10.request_id = request.request_id;
+                req10.response_expected = (request.response_flags & 1) != 0;
+                req10.operation = request.operation;
+                req10.object_key = request.target.object_key();
+                RequestHeader_1_0Helper.write(this, req10);
+                break;
+            case GiopVersion.VERSION_1_1:
+                RequestHeader_1_1 req11 = new RequestHeader_1_1();
+                req11.service_context = request.service_context;
+                req11.request_id = request.request_id;
+                req11.response_expected = (request.response_flags & 1) != 0;
+                req11.operation = request.operation;
+                req11.object_key = request.target.object_key();
+                RequestHeader_1_1Helper.write(this, req11);
+                break;
+            case GiopVersion.VERSION_1_2:
+                RequestHeader_1_2Helper.write(this, request);
+                break;
+            default:
+                throw new IllegalStateException();
+        }
+        byte[] parametersBuffer = parameters.getBuffer();
+        int parametersLength = parameters.getOffset();
+        if (parametersLength > 0) {
+            if (_giopVersion >= GiopVersion.VERSION_1_2) {
+                write_align(8, 0); // parameters are 8-byte aligned
+            } else {
+                // TODO: should have padded service context earlier
+            }
+            write_octet_array(parametersBuffer, 0, parametersLength);
+        }
+        write_message_size();
+    }
+
+    public void write_reply(ReplyHeader_1_2 reply, CdrOutputStream results) {
+        if (reply.service_context == null) {
+            // Avoid allocation of empty array by Helper.
+            reply.service_context = EMPTY_SERVICE_CONTEXT_LIST;
+        }
+        write_message(MsgType_1_1._Reply);
+        switch (_giopVersion) {
+            case GiopVersion.VERSION_1_0:
+            case GiopVersion.VERSION_1_1:
+                ReplyHeader_1_0 rep10 = new ReplyHeader_1_0();
+                rep10.service_context = reply.service_context;
+                rep10.request_id = reply.request_id;
+                rep10.reply_status = reply.reply_status;
+                ReplyHeader_1_0Helper.write(this, rep10);
+                break;
+            case GiopVersion.VERSION_1_2:
+                ReplyHeader_1_2Helper.write(this, reply);
+                break;
+            default:
+                throw new IllegalStateException();
+        }
+        byte[] resultsBuffer = results.getBuffer();
+        int resultsLength = results.getOffset();
+        if (resultsLength > 0) {
+            if (_giopVersion >= GiopVersion.VERSION_1_2) {
+                write_align(8, 0); // results are 8-byte aligned
+            } else {
+                // TODO: should have padded service context earlier
+            }
+            write_octet_array(resultsBuffer, 0, resultsLength);
+        }
+        write_message_size();
+    }
+
+    public void write_reply(LocateReplyHeader_1_2 reply) {
+        write_message(MsgType_1_1._LocateReply);
+        LocateReplyHeader_1_2Helper.write(this, reply);
+        write_message_size();
+    }
+
+    public void write_SystemException(Exception ex, boolean withStackTrace) {
+        String type = "UNKNOWN";
+        if (ex instanceof org.omg.CORBA.SystemException) {
+            type = JavaClass.getNameSuffix(ex.getClass().getName());
+        } else if (ex instanceof SecurityException) {
+            type = "NO_PERMISSION";
+        } else if (ex instanceof UnsupportedOperationException) {
+            type = "BAD_OPERATION";
+        }
+        String id = "IDL:omg.org/CORBA/" + type + ":1.0";
+        write_string(id);
+        write_long(0); // minor (TODO: other values?)
+        write_long(0); // completed (TODO: other values?)
+        if (withStackTrace) {
+            write_string(ExceptionUtil.getStackTrace(ex));
+        }
+    }
+
+    public void send_message(java.io.OutputStream output, String host) {
+        if (RMI_TRACE) {
+            byte[] data = new byte[_offset];
+            System.arraycopy(_buffer, 0, data, 0, _offset);
+            RmiTrace.send(host, data);
+        }
+        try {
+            output.write(_buffer, 0, _offset);
+            output.flush();
+        } catch (java.io.IOException ex) {
+            throw new org.omg.CORBA.COMM_FAILURE(ex.toString());
+        }
+    }
+
+    // -----------------------------------------------------------------------
+    // public methods from org.omg.CORBA.portable.OutputStream
+    // -----------------------------------------------------------------------
+
+    public void write_boolean(boolean value) {
+        write_align(1, 1);
+        if (value) {
+            _buffer[_offset++] = 1;
+        } else {
+            _buffer[_offset++] = 0;
+        }
+    }
+
+    public void write_char(char value) {
+        write_align(1, 1);
+        if ((int) value > 255) {
+            throw new org.omg.CORBA.MARSHAL("write_char: value = " + value);
+        }
+        _buffer[_offset++] = (byte) value;
+    }
+
+    public void write_wchar(char value) {
+        write_octet((byte) 2); // size of wchar is 2 bytes
+        write_align(1, 2);
+        write_ushort_no_align_big_endian((int) value);
+    }
+
+    public void write_octet(byte value) {
+        write_align(1, 1);
+        _buffer[_offset++] = value;
+    }
+
+    public void write_short(short value) {
+        write_align(2, 2);
+        int oldOffset = _offset;
+        _offset += 2;
+        BigEndian.setShort(_buffer, oldOffset, value);
+    }
+
+    public void write_ushort(short value) {
+        write_short(value);
+    }
+
+    public void write_long(int value) {
+        write_align(4, 4);
+        int oldOffset = _offset;
+        _offset += 4;
+        BigEndian.setInt(_buffer, oldOffset, value);
+    }
+
+    public void write_ulong(int value) {
+        write_long(value);
+    }
+
+    public void write_longlong(long value) {
+        write_align(8, 8);
+        int oldOffset = _offset;
+        _offset += 8;
+        BigEndian.setLong(_buffer, oldOffset, value);
+    }
+
+    public void write_ulonglong(long value) {
+        write_longlong(value);
+    }
+
+    public void write_float(float value) {
+        write_long(Float.floatToIntBits(value));
+    }
+
+    public void write_double(double value) {
+        write_longlong(Double.doubleToLongBits(value));
+    }
+
+    public void write_string(String value) {
+        if (value == null) {
+            value = "";
+        }
+        write_align(4, 4);
+        int size = UTF8.fromString(value, _buffer, _offset + 4, _length - 1);
+        if (size == -1) {
+            // No room to convert in-place, ok to allocate new byte array.
+            byte[] bytes = UTF8.fromString(value);
+            size = bytes.length;
+            write_ulong(size + 1);
+            write_octet_array(bytes, 0, size);
+        } else {
+            // Already converted already into _buffer.
+            write_ulong(size + 1);
+            _offset += size;
+        }
+        write_octet((byte) 0);
+    }
+
+    public void write_wstring(String value) {
+        if (value == null) {
+            value = "";
+        }
+        int size = value.length();
+        int numBytes = 2 * size;
+        write_ulong(numBytes); // No terminating NUL
+        write_align(1, numBytes);
+        for (int i = 0; i < size; i++) {
+            char c = value.charAt(i);
+            BigEndian.setShort(_buffer, _offset, (short) c);
+            _offset += 2;
+        }
+    }
+
+    public void write_boolean_array(boolean[] value, int offset, int length) {
+        for (int i = 0; i < length; i++) {
+            write_boolean(value[offset + i]);
+        }
+    }
+
+    public void write_char_array(char[] value, int offset, int length) {
+        for (int i = 0; i < length; i++) {
+            write_char(value[offset + i]);
+        }
+    }
+
+    public void write_wchar_array(char[] value, int offset, int length) {
+        for (int i = 0; i < length; i++) {
+            write_wchar(value[offset + i]);
+        }
+    }
+
+    public void write_octet_array(byte[] value, int offset, int length) {
+        write_align(1, length);
+        System.arraycopy(value, offset, _buffer, _offset, length);
+        _offset += length;
+    }
+
+    public void write_short_array(short[] value, int offset, int length) {
+        for (int i = 0; i < length; i++) {
+            write_short(value[offset + i]);
+        }
+    }
+
+    public void write_ushort_array(short[] value, int offset, int length) {
+        for (int i = 0; i < length; i++) {
+            write_ushort(value[offset + i]);
+        }
+    }
+
+    public void write_long_array(int[] value, int offset, int length) {
+        for (int i = 0; i < length; i++) {
+            write_long(value[offset + i]);
+        }
+    }
+
+    public void write_ulong_array(int[] value, int offset, int length) {
+        for (int i = 0; i < length; i++) {
+            write_ulong(value[offset + i]);
+        }
+    }
+
+    public void write_longlong_array(long[] value, int offset, int length) {
+        for (int i = 0; i < length; i++) {
+            write_longlong(value[offset + i]);
+        }
+    }
+
+    public void write_ulonglong_array(long[] value, int offset, int length) {
+        for (int i = 0; i < length; i++) {
+            write_ulonglong(value[offset + i]);
+        }
+    }
+
+    public void write_float_array(float[] value, int offset, int length) {
+        for (int i = 0; i < length; i++) {
+            write_float(value[offset + i]);
+        }
+    }
+
+    public void write_double_array(double[] value, int offset, int length) {
+        for (int i = 0; i < length; i++) {
+            write_double(value[offset + i]);
+        }
+    }
+
+    public void write_Object(org.omg.CORBA.Object value) {
+        if (value == null) {
+            write_IOR(null);
+        } else if (value instanceof ObjectRef) {
+            ObjectRef ref = (ObjectRef) value;
+            IOR ior = ref.$getIOR();
+            write_IOR(ior);
+        } else {
+            throw new org.omg.CORBA.MARSHAL(value.getClass().getName());
+        }
+    }
+
+    public void write_TypeCode(org.omg.CORBA.TypeCode tc) {
+        write_TypeCode(tc, new java.util.HashMap());
+    }
+
+    public void write_Any(org.omg.CORBA.Any value) {
+        org.omg.CORBA.TypeCode tc = value.type();
+        write_TypeCode(tc);
+        write_Any(value.create_input_stream(), tc);
+    }
+
+    // Sybase-internal
+    public void write_Any(org.omg.CORBA.portable.InputStream is, org.omg.CORBA.TypeCode tc) {
+        try {
+            int tk = tc.kind().value();
+            switch (tk) {
+                case TCKind._tk_null:
+                case TCKind._tk_void:
+                    break;
+                case TCKind._tk_TypeCode:
+                    write_TypeCode(is.read_TypeCode());
+                    break;
+                case TCKind._tk_any:
+                    write_Any(is.read_any());
+                    break;
+                case TCKind._tk_boolean:
+                    write_boolean(is.read_boolean());
+                    break;
+                case TCKind._tk_char:
+                    write_char(is.read_char());
+                    break;
+                case TCKind._tk_wchar:
+                    write_wchar(is.read_wchar());
+                    break;
+                case TCKind._tk_octet:
+                    write_octet(is.read_octet());
+                    break;
+                case TCKind._tk_short:
+                    write_short(is.read_short());
+                    break;
+                case TCKind._tk_ushort:
+                    write_ushort(is.read_ushort());
+                    break;
+                case TCKind._tk_long:
+                    write_long(is.read_long());
+                    break;
+                case TCKind._tk_ulong:
+                case TCKind._tk_enum:
+                    write_ulong(is.read_ulong());
+                    break;
+                case TCKind._tk_longlong:
+                    write_longlong(is.read_longlong());
+                    break;
+                case TCKind._tk_ulonglong:
+                    write_ulonglong(is.read_ulonglong());
+                    break;
+                case TCKind._tk_float:
+                    write_float(is.read_float());
+                    break;
+                case TCKind._tk_double:
+                    write_double(is.read_double());
+                    break;
+                case TCKind._tk_string:
+                    write_string(is.read_string());
+                    break;
+                case TCKind._tk_wstring:
+                    write_wstring(is.read_wstring());
+                    break;
+                case TCKind._tk_objref:
+                    write_Object(is.read_Object());
+                    break;
+                case TCKind._tk_alias:
+                    write_Any(is, tc.content_type());
+                    break;
+                case TCKind._tk_array:
+                    {
+                        int n = tc.length();
+                        org.omg.CORBA.TypeCode c = tc.content_type();
+                        for (int i = 0; i < n; i++) {
+                            write_Any(is, c);
+                        }
+                    }
+                    break;
+                case TCKind._tk_sequence:
+                    {
+                        int n = is.read_ulong();
+                        write_ulong(n);
+                        org.omg.CORBA.TypeCode c = tc.content_type();
+                        for (int i = 0; i < n; i++) {
+                            write_Any(is, c);
+                        }
+                    }
+                    break;
+                case TCKind._tk_struct:
+                case TCKind._tk_except:
+                    {
+                        int n = tc.member_count();
+                        for (int i = 0; i < n; i++) {
+                            write_Any(is, tc.member_type(i));
+                        }
+                    }
+                    break;
+                case TCKind._tk_union:
+                    {
+                        org.omg.CORBA.TypeCode dt = tc.discriminator_type();
+                        org.omg.CORBA.Any disc = read_disc(is, dt);
+                        write_Any(disc.create_input_stream(), dt);
+                        int di = tc.default_index();
+                        int i, n = tc.member_count();
+                        for (i = 0; i < n; i++) {
+                            org.omg.CORBA.Any label = tc.member_label(i);
+                            if (label.equal(disc)) {
+                                write_Any(is, tc.member_type(i));
+                            }
+                        }
+                        if (i == n && di >= 0) {
+                            write_Any(is, tc.member_type(di));
+                        }
+                    }
+                    break;
+                case TCKind._tk_fixed: // TODO
+                case TCKind._tk_value: // TODO
+                default:
+                    throw new org.omg.CORBA.MARSHAL("write_Any: type = " + tc);
+            }
+        } catch (org.omg.CORBA.TypeCodePackage.BadKind ex) {
+            throw new org.omg.CORBA.MARSHAL("write_Any: " + ex.toString());
+        } catch (org.omg.CORBA.TypeCodePackage.Bounds ex) {
+            throw new org.omg.CORBA.MARSHAL("write_Any: " + ex.toString());
+        }
+    }
+
+    public void write_any(org.omg.CORBA.Any value) {
+        throw new org.omg.CORBA.NO_IMPLEMENT("write_any: NOT IMPLMENTED YET");
+    }
+
+    public void write_Principal(org.omg.CORBA.Principal value) {
+        throw new org.omg.CORBA.NO_IMPLEMENT("write_Principal: NOT IMPLMENTED YET");
+    }
+
+    public void write(int value) throws java.io.IOException {
+        throw new org.omg.CORBA.NO_IMPLEMENT("write: NOT IMPLMENTED YET");
+    }
+
+    public void write_fixed(java.math.BigDecimal value) {
+        throw new org.omg.CORBA.NO_IMPLEMENT("write_fixed: NOT IMPLMENTED YET");
+    }
+
+    public void write_Context(org.omg.CORBA.Context context, org.omg.CORBA.ContextList list) {
+        throw new org.omg.CORBA.NO_IMPLEMENT("write_Context: NOT IMPLMENTED YET");
+    }
+
+    public org.omg.CORBA.ORB orb() {
+        throw new org.omg.CORBA.NO_IMPLEMENT("orb: NOT IMPLMENTED YET");
+    }
+
+
+    // -----------------------------------------------------------------------
+    // public methods from org.omg.CORBA_2_3.portable.OutputStream
+    // -----------------------------------------------------------------------
+
+    public void write_value(java.io.Serializable value) {
+        throw new org.omg.CORBA.NO_IMPLEMENT("write_value: NOT IMPLMENTED YET");
+    }
+
+    public void write_value(java.io.Serializable value, Class _class) {
+        throw new org.omg.CORBA.NO_IMPLEMENT("write_value: NOT IMPLMENTED YET");
+    }
+
+    public void write_value(java.io.Serializable value, String id) {
+        throw new org.omg.CORBA.NO_IMPLEMENT("write_value: NOT IMPLMENTED YET");
+    }
+
+    public void write_value(java.io.Serializable value, org.omg.CORBA.portable.BoxedValueHelper helper) {
+        throw new org.omg.CORBA.NO_IMPLEMENT("write_value: NOT IMPLMENTED YET");
+    }
+
+    public void write_abstract_interface(java.lang.Object value) {
+        throw new org.omg.CORBA.NO_IMPLEMENT("write_abstract_interface: NOT IMPLMENTED YET");
+    }
+
+
+    // doing this specifically to handle Any. This implementation 
+    // could be worng but will work for us
+    public org.omg.CORBA.portable.InputStream create_input_stream() {
+        CdrInputStream is = CdrInputStream.getInstance();
+        is._buffer = new byte[_buffer.length];
+        System.arraycopy(_buffer, 0, is._buffer, 0, _buffer.length);
+        is._length = _buffer.length;
+        is._offset = 0;
+        return is;
+    }
+
+    // -----------------------------------------------------------------------
+    // protected methods
+    // -----------------------------------------------------------------------
+
+    protected void pool(byte[] oldBuffer) {
+        if (oldBuffer.length <= MAXIMUM_POOLED_BUFFER_LENGTH) {
+            _pooledBuffer = oldBuffer;
+        }
+    }
+
+    protected final void write_ushort_no_align_big_endian(int value) {
+        int oldOffset = _offset;
+        _offset += 2;
+        BigEndian.setShort(_buffer, oldOffset, (short) value);
+    }
+
+    protected void write_IOR(IOR ior) {
+        if (ior == null) {
+            ior = NULL_IOR;
+        }
+        IORHelper.write(this, ior);
+    }
+
+    public int begin() {
+        write_ulong(0);
+        int saveOffset = _offset;
+        write_boolean(false);
+        return saveOffset;
+    }
+
+    public void end(int saveOffset) {
+        int endOffset = _offset;
+        _offset = saveOffset - 4;
+        write_ulong(endOffset - saveOffset);
+        _offset = endOffset;
+    }
+
+    private void write_TypeCode(org.omg.CORBA.TypeCode tc, java.util.HashMap table) {
+        try {
+            int tk = tc.kind().value();
+            // Check if we need to write an indirection
+            switch (tk) {
+                case TCKind._tk_struct:
+                case TCKind._tk_union:
+                case TCKind._tk_value:
+                    String id = tc.id();
+                    if (!id.equals("")) {
+                        Integer key = (Integer) table.get(id);
+                        if (key != null) {
+                            write_ulong(0xffffffff);
+                            write_long(key.intValue() - _offset);
+                            return;
+                        }
+                        table.put(id, new Integer(_offset));
+                    }
+            }
+            write_ulong(tk);
+            switch (tk) {
+                case TCKind._tk_null:
+                case TCKind._tk_void:
+                case TCKind._tk_TypeCode:
+                case TCKind._tk_any:
+                case TCKind._tk_boolean:
+                case TCKind._tk_char:
+                case TCKind._tk_wchar:
+                case TCKind._tk_octet:
+                case TCKind._tk_short:
+                case TCKind._tk_ushort:
+                case TCKind._tk_long:
+                case TCKind._tk_ulong:
+                case TCKind._tk_longlong:
+                case TCKind._tk_ulonglong:
+                case TCKind._tk_float:
+                case TCKind._tk_double:
+                case TCKind._tk_longdouble:
+                    // All these require only a TCKind.
+                    break;
+                case TCKind._tk_fixed:
+                    write_ushort(tc.fixed_digits());
+                    write_short(tc.fixed_scale());
+                    break;
+                case TCKind._tk_string:
+                case TCKind._tk_wstring:
+                    write_ulong(tc.length());
+                    break;
+                case TCKind._tk_objref:
+                case TCKind._tk_native:
+                case TCKind._tk_abstract_interface:
+                    {
+                        int saveOffset = begin();
+                        write_string(tc.id());
+                        write_string(tc.name());
+                        end(saveOffset);
+                    }
+                    break;
+                case TCKind._tk_alias:
+                case TCKind._tk_value_box:
+                    {
+                        int saveOffset = begin();
+                        write_string(tc.id());
+                        write_string(tc.name());
+                        write_TypeCode(tc.content_type(), table);
+                        end(saveOffset);
+                    }
+                    break;
+                case TCKind._tk_sequence:
+                case TCKind._tk_array:
+                    {
+                        int saveOffset = begin();
+                        write_TypeCode(tc.content_type(), table);
+                        write_ulong(tc.length());
+                        end(saveOffset);
+                    }
+                    break;
+                case TCKind._tk_enum:
+                    {
+                        int saveOffset = begin();
+                        write_string(tc.id());
+                        write_string(tc.name());
+                        int count = tc.member_count();
+                        write_ulong(count);
+                        for (int i = 0; i < count; i++) {
+                            write_string(tc.member_name(i));
+                        }
+                        end(saveOffset);
+                    }
+                    break;
+                case TCKind._tk_struct:
+                case TCKind._tk_except:
+                    {
+                        int saveOffset = begin();
+                        write_string(tc.id());
+                        write_string(tc.name());
+                        int count = tc.member_count();
+                        write_ulong(count);
+                        for (int i = 0; i < count; i++) {
+                            write_string(tc.member_name(i));
+                            write_TypeCode(tc.member_type(i), table);
+                        }
+                        end(saveOffset);
+                    }
+                    break;
+                case TCKind._tk_union:
+                    {
+                        int saveOffset = begin();
+                        write_string(tc.id());
+                        write_string(tc.name());
+                        org.omg.CORBA.TypeCode dt = tc.discriminator_type();
+                        write_TypeCode(dt, table);
+                        int di = tc.default_index();
+                        write_ulong(di);
+                        int count = tc.member_count();
+                        write_ulong(count);
+                        for (int i = 0; i < count; i++) {
+                            write_Any(tc.member_label(i).create_input_stream(), dt);
+                            write_string(tc.member_name(i));
+                            write_TypeCode(tc.member_type(i), table);
+                        }
+                        end(saveOffset);
+                    }
+                    break;
+                case TCKind._tk_value:
+                    {
+                        int saveOffset = begin();
+                        write_string(tc.id());
+                        write_string(tc.name());
+                        write_short(tc.type_modifier());
+                        write_TypeCode(tc.concrete_base_type(), table);
+                        int count = tc.member_count();
+                        write_ulong(count);
+                        for (int i = 0; i < count; i++) {
+                            write_string(tc.member_name(i));
+                            write_TypeCode(tc.member_type(i), table);
+                            write_short(tc.member_visibility(i));
+                        }
+                        end(saveOffset);
+                    }
+                    break;
+                default:
+                    throw new org.omg.CORBA.MARSHAL("write_TypeCode: kind = " + tk);
+            }
+        } catch (org.omg.CORBA.TypeCodePackage.BadKind ex) {
+            throw new org.omg.CORBA.MARSHAL(ex.toString());
+        } catch (org.omg.CORBA.TypeCodePackage.Bounds ex) {
+            throw new org.omg.CORBA.MARSHAL(ex.toString());
+        }
+    }
+
+    private org.omg.CORBA.Any read_disc(org.omg.CORBA.portable.InputStream is, org.omg.CORBA.TypeCode dt) {
+        int tk = dt.kind().value();
+        if (tk == TCKind._tk_alias) {
+            try {
+                return read_disc(is, dt.content_type());
+            } catch (org.omg.CORBA.TypeCodePackage.BadKind ex) {
+                throw new org.omg.CORBA.MARSHAL("read_disc: " + ex.toString());
+            }
+        }
+        org.omg.CORBA.Any disc = new org.apache.geronimo.interop.rmi.iiop.Any();
+        switch (tk) {
+            case TCKind._tk_boolean:
+                disc.insert_boolean(is.read_boolean());
+                break;
+            case TCKind._tk_octet:
+                disc.insert_octet(is.read_octet());
+                break;
+            case TCKind._tk_short:
+                disc.insert_short(is.read_short());
+                break;
+            case TCKind._tk_ushort:
+                disc.insert_ushort(is.read_ushort());
+                break;
+            case TCKind._tk_long:
+                disc.insert_long(is.read_long());
+                break;
+            case TCKind._tk_ulong:
+            case TCKind._tk_enum:
+                disc.insert_ulong(is.read_ulong());
+                break;
+            case TCKind._tk_longlong:
+                disc.insert_longlong(is.read_longlong());
+                break;
+            case TCKind._tk_ulonglong:
+                disc.insert_ulonglong(is.read_ulonglong());
+                break;
+            default:
+                throw new org.omg.CORBA.MARSHAL("read_disc: type = " + dt);
+        }
+        return disc;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/FieldByNameComparator.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/FieldByNameComparator.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/FieldByNameComparator.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,41 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop;
+
+import java.lang.reflect.Field;
+import java.util.Comparator;
+
+
+/**
+ * * Sort fields by name only.
+ */
+public class FieldByNameComparator implements Comparator {
+    public static final FieldByNameComparator SINGLETON = new FieldByNameComparator();
+
+    public int compare(Object x, Object y) {
+        Field a = (Field) x;
+        Field b = (Field) y;
+        return a.getName().compareTo(b.getName());
+    }
+
+    public boolean equals(Object x) {
+        // shouldn't be used
+        return false;
+    }
+}
+

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/FieldComparator.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/FieldComparator.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/FieldComparator.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,53 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop;
+
+import java.lang.reflect.Field;
+import java.util.Comparator;
+
+
+/**
+ * * Sort fields in the order they must be marshalled for RMI-IIOP.
+ */
+public class FieldComparator implements Comparator {
+    public static final FieldComparator SINGLETON = new FieldComparator();
+
+    public int compare(Object x, Object y) {
+        Field a = (Field) x;
+        Field b = (Field) y;
+        if (a.getType().isPrimitive()) {
+            if (b.getType().isPrimitive()) {
+                return a.getName().compareTo(b.getName());
+            } else {
+                return -1;
+            }
+        } else {
+            if (b.getType().isPrimitive()) {
+                return 1;
+            } else {
+                return a.getName().compareTo(b.getName());
+            }
+        }
+    }
+
+    public boolean equals(Object x) {
+        // shouldn't be used
+        return false;
+    }
+}
+

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/GiopMessage.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/GiopMessage.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/GiopMessage.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,74 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop;
+
+import org.apache.geronimo.interop.GIOP.*;
+
+
+public class GiopMessage {
+    public int size;
+    public int type;
+    public int giopVersion;
+    public RequestHeader_1_2 request;
+    public LocateRequestHeader_1_2 locateRequest;
+    public ReplyHeader_1_2 reply;
+
+    public String toString() {
+        StringBuffer sb = new StringBuffer("GiopMessage(");
+        /* TODO
+        if (header != null)
+        {
+            if (header.GIOP_version != null)
+            {
+                sb.append("version = ");
+                sb.append(header.GIOP_version.major);
+                sb.append('.');
+                sb.append(header.GIOP_version.minor);
+            }
+            if ((header.flags & 1) != 0)
+            {
+                sb.append(", little endian");
+            }
+            else
+            {
+                sb.append(", big endian");
+            }
+            if ((header.flags & 2) != 0)
+            {
+                sb.append(", fragmented");
+            }
+            sb.append(", message type = ");
+            switch (header.message_type)
+            {
+              case MsgType_1_1._Request:
+                sb.append("Request");
+                break;
+              case MsgType_1_1._Reply:
+                sb.append("Reply");
+                break;
+              default:
+                sb.append(header.message_type);
+            }
+            sb.append(", message size = ");
+            sb.append(header.message_size);
+        }
+        */
+        sb.append(")");
+        return sb.toString();
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/GiopVersion.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/GiopVersion.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/GiopVersion.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,24 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop;
+
+public class GiopVersion {
+    public static final int VERSION_1_0 = 0;
+    public static final int VERSION_1_1 = 1;
+    public static final int VERSION_1_2 = 2;
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/IDLEntityHelper.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/IDLEntityHelper.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/IDLEntityHelper.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,109 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+
+import org.apache.geronimo.interop.SystemException;
+import org.apache.geronimo.interop.util.ThreadContext;
+
+
+public class IDLEntityHelper implements ObjectHelper {
+    private static Class[] EMPTY_CLASS_ARRAY = {};
+
+    private static Object[] EMPTY_OBJECT_ARRAY = {};
+
+    private static HashMap _helperMap = new HashMap();
+
+    private Method _id;
+
+    private Method _type;
+
+    private Method _read;
+
+    private Method _write;
+
+    static IDLEntityHelper getInstance(Class theClass) {
+        IDLEntityHelper helper = (IDLEntityHelper) _helperMap.get(theClass);
+        if (helper == null) {
+            synchronized (_helperMap) {
+                helper = (IDLEntityHelper) _helperMap.get(theClass);
+                if (helper == null) {
+                    helper = new IDLEntityHelper(theClass);
+                    _helperMap.put(theClass, helper);
+                }
+            }
+        }
+        return helper;
+    }
+
+    private IDLEntityHelper(Class theClass) {
+        try {
+            Class helper = ThreadContext.loadClass(theClass.getName() + "Helper", theClass);
+            _id = helper.getDeclaredMethod("id", EMPTY_CLASS_ARRAY);
+            _type = helper.getDeclaredMethod("type", EMPTY_CLASS_ARRAY);
+            _read = helper.getDeclaredMethod("read", new Class[]{org.omg.CORBA.portable.InputStream.class});
+            _write = helper.getDeclaredMethod("write", new Class[]{org.omg.CORBA.portable.OutputStream.class, theClass});
+        } catch (SystemException ex) {
+            throw ex;
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+    }
+
+    public String id() {
+        try {
+            return (String) _id.invoke(null, EMPTY_OBJECT_ARRAY);
+        } catch (SystemException ex) {
+            throw ex;
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+    }
+
+    public org.omg.CORBA.TypeCode type() {
+        try {
+            return (org.omg.CORBA.TypeCode) _type.invoke(null, EMPTY_OBJECT_ARRAY);
+        } catch (SystemException ex) {
+            throw ex;
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+    }
+
+    public Object read(ObjectInputStream input) {
+        try {
+            return _read.invoke(null, new Object[]{input._cdrInput});
+        } catch (SystemException ex) {
+            throw ex;
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+    }
+
+    public void write(ObjectOutputStream output, Object value) {
+        try {
+            _write.invoke(null, new Object[]{output._cdrOutput, value});
+        } catch (SystemException ex) {
+            throw ex;
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/IiopVersion.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/IiopVersion.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/IiopVersion.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,21 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop;
+
+public class IiopVersion {
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ListenerInfo.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ListenerInfo.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ListenerInfo.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,26 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop;
+
+public class ListenerInfo {
+    public int protocol;
+
+    public String host;
+
+    public int port;
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/NameServiceOperations_Skeleton.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/NameServiceOperations_Skeleton.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/NameServiceOperations_Skeleton.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,373 @@
+// 
+// CORBA RMI-IIOP Skeleton Generator
+//   Interface: NameServiceOperations_Skeleton
+//   Date: Wed Dec 08 15:22:39 EST 2004
+
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop;
+
+import java.util.HashMap;
+
+
+public class NameServiceOperations_Skeleton
+        extends RemoteObject
+        implements RemoteInterface {
+    // 
+    // Fields
+    // 
+    public java.lang.String[] _ids = {"org.apache.geronimo.interop.rmi.iiop.NameServiceOperations", "RMI:org.apache.geronimo.interop.rmi.iiop.NameServiceOperations:0000000000000000", "NameService"};
+    public java.util.HashMap _methods = new HashMap(10);
+    public org.apache.geronimo.interop.rmi.iiop.NameServiceOperations _servant = null;
+    public java.lang.String _f3 = "f1";
+    public java.lang.String[] _f4 = {"f1", "f2"};
+    public org.apache.geronimo.interop.rmi.iiop.ValueType vt$0 = org.apache.geronimo.interop.rmi.iiop.ValueType.getInstance(java.lang.String.class);
+    public org.apache.geronimo.interop.rmi.iiop.ValueType vt$1 = org.apache.geronimo.interop.rmi.iiop.ValueType.getInstance(org.apache.geronimo.interop.CosNaming.NameComponent[].class);
+    public org.apache.geronimo.interop.rmi.iiop.ValueType vt$2 = org.apache.geronimo.interop.rmi.iiop.ValueType.getInstance(org.omg.CORBA.Object.class);
+    public org.apache.geronimo.interop.rmi.iiop.ValueType vt$3 = org.apache.geronimo.interop.rmi.iiop.ValueType.getInstance(org.apache.geronimo.interop.CosNaming.BindingListHolder.class);
+    public org.apache.geronimo.interop.rmi.iiop.ValueType vt$4 = org.apache.geronimo.interop.rmi.iiop.ValueType.getInstance(org.apache.geronimo.interop.CosNaming.BindingIteratorHolder.class);
+    public org.apache.geronimo.interop.rmi.iiop.ValueType vt$5 = org.apache.geronimo.interop.rmi.iiop.ValueType.getInstance(org.apache.geronimo.interop.CosNaming.NamingContext.class);
+
+    //
+    // Constructors
+    // 
+    public NameServiceOperations_Skeleton() {
+        super();
+
+        registerMethods();
+    }
+
+    protected void registerMethods() {
+        super.registerMethods();
+
+        registerMethod("resolve_host", 0);
+        registerMethod("to_string", 1);
+        registerMethod("to_name", 2);
+        registerMethod("to_url", 3);
+        registerMethod("resolve_str", 4);
+        registerMethod("list", 5);
+        registerMethod("resolve", 6);
+        registerMethod("bind", 7);
+        registerMethod("bind_context", 8);
+        registerMethod("rebind", 9);
+        registerMethod("rebind_context", 10);
+        registerMethod("unbind", 11);
+        registerMethod("new_context", 12);
+        registerMethod("bind_new_context", 13);
+    }
+    
+    // 
+    // Methods
+    // 
+    
+    public void registerMethod(java.lang.String name, int id) {
+        _methods.put(name, new Integer(id));
+    }
+
+    public java.lang.String[] getIds() {
+        return _ids;
+    }
+
+    public RemoteInterface $getSkeleton() {
+        return this;
+    }
+
+    public ObjectRef $getObjectRef() {
+        org.apache.geronimo.interop.rmi.iiop.ObjectRef or = new ObjectRef();
+        or.$setID("RMI:org.apache.geronimo.interop.rmi.iiop.NameServiceOperations:0000000000000000");
+        or.$setObjectKey("org.apache.geronimo.interop.rmi.iiop.NameServiceOperations");
+        return or;
+    }
+
+    public void $invoke(java.lang.String methodName, byte[] objectKey, java.lang.Object instance, org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input, org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) {
+        java.lang.Integer m = (Integer) _methods.get(methodName);
+        if (m == null) {
+            throw new org.omg.CORBA.BAD_OPERATION(methodName);
+        }
+
+        _servant = (org.apache.geronimo.interop.rmi.iiop.NameServiceOperations) instance;
+
+        if (m.intValue() < 0) {
+            super.invoke(m.intValue(), objectKey, instance, input, output);
+        }
+
+
+        switch (m.intValue()) {
+            case 0:
+                {
+                    resolve_host(input, output);
+                }
+                break;
+            case 1:
+                {
+                    to_string(input, output);
+                }
+                break;
+            case 2:
+                {
+                    to_name(input, output);
+                }
+                break;
+            case 3:
+                {
+                    to_url(input, output);
+                }
+                break;
+            case 4:
+                {
+                    resolve_str(input, output);
+                }
+                break;
+            case 5:
+                {
+                    list(input, output);
+                }
+                break;
+            case 6:
+                {
+                    resolve(input, output);
+                }
+                break;
+            case 7:
+                {
+                    bind(input, output);
+                }
+                break;
+            case 8:
+                {
+                    bind_context(input, output);
+                }
+                break;
+            case 9:
+                {
+                    rebind(input, output);
+                }
+                break;
+            case 10:
+                {
+                    rebind_context(input, output);
+                }
+                break;
+            case 11:
+                {
+                    unbind(input, output);
+                }
+                break;
+            case 12:
+                {
+                    new_context(input, output);
+                }
+                break;
+            case 13:
+                {
+                    bind_new_context(input, output);
+                }
+                break;
+        }
+    }
+
+    public void resolve_host(org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input, org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) {
+        java.lang.String rc;
+
+        try {
+            java.lang.String p0 = (java.lang.String) input.readObject(vt$0);
+            rc = _servant.resolve_host(p0);
+            output.writeObject(vt$0, rc);
+        } catch (java.lang.Exception ex) {
+            ex.printStackTrace();
+        } catch (java.lang.Error er) {
+            er.printStackTrace();
+        }
+    }
+
+    public void to_string(org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input, org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) {
+        java.lang.String rc;
+
+        try {
+            org.apache.geronimo.interop.CosNaming.NameComponent[] p0 = (org.apache.geronimo.interop.CosNaming.NameComponent[]) input.readObject(vt$1);
+            rc = _servant.to_string(p0);
+            output.writeObject(vt$0, rc);
+        } catch (java.lang.Exception ex) {
+            ex.printStackTrace();
+        } catch (java.lang.Error er) {
+            er.printStackTrace();
+        }
+    }
+
+    public void to_name(org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input, org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) {
+        org.apache.geronimo.interop.CosNaming.NameComponent[] rc;
+
+        try {
+            java.lang.String p0 = (java.lang.String) input.readObject(vt$0);
+            rc = _servant.to_name(p0);
+            output.writeObject(vt$1, rc);
+        } catch (java.lang.Exception ex) {
+            ex.printStackTrace();
+        } catch (java.lang.Error er) {
+            er.printStackTrace();
+        }
+    }
+
+    public void to_url(org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input, org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) {
+        java.lang.String rc;
+
+        try {
+            java.lang.String p0 = (java.lang.String) input.readObject(vt$0);
+            java.lang.String p1 = (java.lang.String) input.readObject(vt$0);
+            rc = _servant.to_url(p0, p1);
+            output.writeObject(vt$0, rc);
+        } catch (java.lang.Exception ex) {
+            ex.printStackTrace();
+        } catch (java.lang.Error er) {
+            er.printStackTrace();
+        }
+    }
+
+    public void resolve_str(org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input, org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) {
+        org.omg.CORBA.Object rc;
+
+        try {
+            java.lang.String p0 = (java.lang.String) input.readObject(vt$0);
+            rc = _servant.resolve_str(p0);
+            output.writeObject(vt$2, rc);
+        } catch (java.lang.Exception ex) {
+            ex.printStackTrace();
+        } catch (java.lang.Error er) {
+            er.printStackTrace();
+        }
+    }
+
+    public void list(org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input, org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) {
+
+        try {
+            int p0 = input.readInt();
+            org.apache.geronimo.interop.CosNaming.BindingListHolder p1 = (org.apache.geronimo.interop.CosNaming.BindingListHolder) input.readObject(vt$3);
+            org.apache.geronimo.interop.CosNaming.BindingIteratorHolder p2 = (org.apache.geronimo.interop.CosNaming.BindingIteratorHolder) input.readObject(vt$4);
+            _servant.list(p0, p1, p2);
+        } catch (java.lang.Exception ex) {
+            ex.printStackTrace();
+        } catch (java.lang.Error er) {
+            er.printStackTrace();
+        }
+    }
+
+    public void resolve(org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input, org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) {
+        org.omg.CORBA.Object rc;
+
+        try {
+            org.apache.geronimo.interop.CosNaming.NameComponent[] p0 = (org.apache.geronimo.interop.CosNaming.NameComponent[]) input.readObject(vt$1);
+            rc = _servant.resolve(p0);
+            output.writeObject(vt$2, rc);
+        } catch (java.lang.Exception ex) {
+            ex.printStackTrace();
+        } catch (java.lang.Error er) {
+            er.printStackTrace();
+        }
+    }
+
+    public void bind(org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input, org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) {
+
+        try {
+            org.apache.geronimo.interop.CosNaming.NameComponent[] p0 = (org.apache.geronimo.interop.CosNaming.NameComponent[]) input.readObject(vt$1);
+            org.omg.CORBA.Object p1 = (org.omg.CORBA.Object) input.readObject(vt$2);
+            _servant.bind(p0, p1);
+        } catch (java.lang.Exception ex) {
+            ex.printStackTrace();
+        } catch (java.lang.Error er) {
+            er.printStackTrace();
+        }
+    }
+
+    public void bind_context(org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input, org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) {
+
+        try {
+            org.apache.geronimo.interop.CosNaming.NameComponent[] p0 = (org.apache.geronimo.interop.CosNaming.NameComponent[]) input.readObject(vt$1);
+            org.apache.geronimo.interop.CosNaming.NamingContext p1 = (org.apache.geronimo.interop.CosNaming.NamingContext) input.readObject(vt$5);
+            _servant.bind_context(p0, p1);
+        } catch (java.lang.Exception ex) {
+            ex.printStackTrace();
+        } catch (java.lang.Error er) {
+            er.printStackTrace();
+        }
+    }
+
+    public void rebind(org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input, org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) {
+
+        try {
+            org.apache.geronimo.interop.CosNaming.NameComponent[] p0 = (org.apache.geronimo.interop.CosNaming.NameComponent[]) input.readObject(vt$1);
+            org.omg.CORBA.Object p1 = (org.omg.CORBA.Object) input.readObject(vt$2);
+            _servant.rebind(p0, p1);
+        } catch (java.lang.Exception ex) {
+            ex.printStackTrace();
+        } catch (java.lang.Error er) {
+            er.printStackTrace();
+        }
+    }
+
+    public void rebind_context(org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input, org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) {
+
+        try {
+            org.apache.geronimo.interop.CosNaming.NameComponent[] p0 = (org.apache.geronimo.interop.CosNaming.NameComponent[]) input.readObject(vt$1);
+            org.apache.geronimo.interop.CosNaming.NamingContext p1 = (org.apache.geronimo.interop.CosNaming.NamingContext) input.readObject(vt$5);
+            _servant.rebind_context(p0, p1);
+        } catch (java.lang.Exception ex) {
+            ex.printStackTrace();
+        } catch (java.lang.Error er) {
+            er.printStackTrace();
+        }
+    }
+
+    public void unbind(org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input, org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) {
+
+        try {
+            org.apache.geronimo.interop.CosNaming.NameComponent[] p0 = (org.apache.geronimo.interop.CosNaming.NameComponent[]) input.readObject(vt$1);
+            _servant.unbind(p0);
+        } catch (java.lang.Exception ex) {
+            ex.printStackTrace();
+        } catch (java.lang.Error er) {
+            er.printStackTrace();
+        }
+    }
+
+    public void new_context(org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input, org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) {
+        org.apache.geronimo.interop.CosNaming.NamingContext rc;
+
+        try {
+            rc = _servant.new_context();
+            output.writeObject(vt$5, rc);
+        } catch (java.lang.Exception ex) {
+            ex.printStackTrace();
+        } catch (java.lang.Error er) {
+            er.printStackTrace();
+        }
+    }
+
+    public void bind_new_context(org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input, org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) {
+        org.apache.geronimo.interop.CosNaming.NamingContext rc;
+
+        try {
+            org.apache.geronimo.interop.CosNaming.NameComponent[] p0 = (org.apache.geronimo.interop.CosNaming.NameComponent[]) input.readObject(vt$1);
+            rc = _servant.bind_new_context(p0);
+            output.writeObject(vt$5, rc);
+        } catch (java.lang.Exception ex) {
+            ex.printStackTrace();
+        } catch (java.lang.Error er) {
+            er.printStackTrace();
+        }
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectHelper.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectHelper.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectHelper.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,25 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop;
+
+public interface ObjectHelper {
+    public Object read(ObjectInputStream input);
+
+    public void write(ObjectOutputStream output, Object value);
+}
+

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectInputStream.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectInputStream.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectInputStream.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,589 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop;
+
+import java.io.IOException;
+import java.io.NotActiveException;
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.omg.CORBA.TCKind;
+
+import org.apache.geronimo.interop.SystemException;
+import org.apache.geronimo.interop.util.ArrayUtil;
+import org.apache.geronimo.interop.util.IntegerCache;
+
+
+public class ObjectInputStream extends java.io.ObjectInputStream {
+    public static ObjectInputStream getInstance() {
+        return getInstance(CdrInputStream.getInstance());
+    }
+
+    public static ObjectInputStream getInstance(org.apache.geronimo.interop.rmi.iiop.CdrInputStream cdrInput) {
+        ObjectInputStream input = null;
+        try {
+            input = new ObjectInputStream();
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+
+        input.init(cdrInput);
+        return input;
+    }
+
+    public static ObjectInputStream getPooledInstance() {
+        ObjectInputStream input = null; //(ObjectInputStream)_pool.get();
+        if (input == null) {
+            input = getInstance();
+        }
+        return input;
+    }
+
+    // -----------------------------------------------------------------------
+    // inner classes
+    // -----------------------------------------------------------------------
+
+    protected static class StreamState {
+        ValueType type;
+        Object value;
+        int offset;
+
+        StreamState(ValueType type, Object value, int offset) {
+            this.type = type;
+            this.value = value;
+            this.offset = offset;
+        }
+    }
+
+    // -----------------------------------------------------------------------
+    // public data
+    // -----------------------------------------------------------------------
+
+    public static final int MAXIMUM_BLOCK_LENGTH = 0x7fffff00;
+
+    public CdrInputStream _cdrInput;
+
+    public Object[] thisAsObjectArray;
+
+    // -----------------------------------------------------------------------
+    // private data
+    // -----------------------------------------------------------------------
+
+    //private static ThreadLocalInstancePool _pool = new ThreadLocalInstancePool(ObjectInputStream.class.getName());
+
+    private int _blockLength = MAXIMUM_BLOCK_LENGTH;
+
+    private int _endLevel = 0;
+
+    private HashMap _indirection;
+
+    private boolean _isChunked = false;
+
+    private ArrayList _stack;
+
+    // -----------------------------------------------------------------------
+    // public methods
+    // -----------------------------------------------------------------------
+
+    public ObjectInputStream() throws IOException {
+    }
+
+    public void $reset() {
+        _cdrInput.reset();
+        if (_indirection != null) {
+            _indirection.clear();
+        }
+        if (_stack != null) {
+            _stack.clear();
+        }
+        _blockLength = MAXIMUM_BLOCK_LENGTH;
+        _endLevel = 0;
+        _isChunked = false;
+    }
+
+    public void recycle() {
+        $reset();
+        //_pool.put(this);
+    }
+
+    // public methods from java.io.ObjectInputStream
+
+    public boolean readBoolean() {
+        return _cdrInput.read_boolean();
+    }
+
+    public char readChar() {
+        return _cdrInput.read_wchar();
+    }
+
+    public byte readByte() {
+        return _cdrInput.read_octet();
+    }
+
+    public short readShort() {
+        return _cdrInput.read_short();
+    }
+
+    public int readInt() {
+        return _cdrInput.read_long();
+    }
+
+    public long readLong() {
+        return _cdrInput.read_longlong();
+    }
+
+    public float readFloat() {
+        return _cdrInput.read_float();
+    }
+
+    public double readDouble() {
+        return _cdrInput.read_double();
+    }
+
+    public Object readObjectOverride() {
+        return readObject(ValueType.OBJECT_VALUE_TYPE, false);
+    }
+
+    public void defaultReadObject() throws IOException, ClassNotFoundException, NotActiveException {
+        StreamState state = top();
+        readDeclaredFields(state.type, state.value);
+    }
+
+    // -----------------------------------------------------------------------
+    // public methods used by generated and package-internal code
+    // -----------------------------------------------------------------------
+
+    public Exception readException(ValueType type) {
+        return (Exception) readObject(type, false);
+    }
+
+    public Object readObject(ValueType type) {
+        return readObject(type, false);
+    }
+
+    // -----------------------------------------------------------------------
+    // protected methods
+    // -----------------------------------------------------------------------
+
+    protected void init(org.apache.geronimo.interop.rmi.iiop.CdrInputStream cdrInput) {
+        _cdrInput = cdrInput;
+        thisAsObjectArray = new Object[]{this};
+    }
+
+    protected void putIndirection(Integer key, Object value) {
+        if (_indirection == null) {
+            _indirection = new HashMap();
+        }
+        _indirection.put(key, value);
+    }
+
+    protected Object readObject(ValueType declaredType, boolean calledByCustomSerialization) {
+        org.omg.CORBA.TypeCode tc = null;
+
+        int tag = _cdrInput.read_ulong();
+        int saveOffset = _cdrInput._offset - 4;
+        Object value;
+
+        if (tag == ValueType.INDIRECTION_TAG) {
+            // Indirection to value already read (or cyclic value being read).
+            saveOffset = _cdrInput._offset;
+            int offset = _cdrInput.read_long();
+            Integer key = IntegerCache.get(saveOffset + offset);
+            if (_indirection != null) {
+                value = _indirection.get(key);
+                if (value != null) {
+                    return value;
+                }
+            }
+            throw new org.omg.CORBA.MARSHAL("invalid indirection offset = " + offset);
+        } else {
+            _cdrInput._offset = saveOffset;
+        }
+
+        if (calledByCustomSerialization) {
+            boolean isObjectRef = _cdrInput.read_boolean();
+            if (isObjectRef) {
+                org.omg.CORBA.Object ref = _cdrInput.read_Object();
+                endBlock();
+                if (_blockLength == MAXIMUM_BLOCK_LENGTH) {
+                    startBlock();
+                }
+                return ref;
+            } else {
+                _cdrInput._offset = saveOffset;
+            }
+        } else if (declaredType.isAnyOrObjectRefOrAbstractInterface) {
+            boolean isObjectRef = false;
+            if (declaredType.isObjectRef) {
+                return _cdrInput.read_Object();
+            } else if (declaredType.isAny) {
+                tc = _cdrInput.read_TypeCode();
+                int kind = tc.kind().value();
+                if (kind == TCKind._tk_null) {
+                    return null;
+                }
+                if (kind == TCKind._tk_objref) {
+                    isObjectRef = true;
+                } else if (kind == TCKind._tk_abstract_interface) {
+                    isObjectRef = _cdrInput.read_boolean();
+                }
+                if (isObjectRef) {
+                    saveOffset = _cdrInput._offset;
+                    int checkValue = _cdrInput.read_ulong();
+                    if (checkValue == 0) {
+                        return null;
+                    }
+
+                    _cdrInput._offset = saveOffset;
+                    return _cdrInput.read_Object();
+                }
+            } else if (declaredType.isAbstractInterface) {
+                isObjectRef = _cdrInput.read_boolean();
+                if (isObjectRef) {
+                    return _cdrInput.read_Object();
+                }
+            } else {
+                throw new IllegalStateException(declaredType.toString());
+            }
+        }
+
+        saveOffset = _cdrInput._offset;
+        tag = _cdrInput.read_long();
+        if (tag == ValueType.NULL_VALUE_TAG) {
+            return null;
+        }
+        if (tag == ValueType.INDIRECTION_TAG) {
+            // Indirection to value already read (or cyclic value being read).
+            saveOffset = _cdrInput._offset;
+            int offset = _cdrInput.read_long();
+            Integer key = IntegerCache.get(saveOffset + offset);
+            if (_indirection != null) {
+                value = _indirection.get(key);
+                if (value != null) {
+                    return value;
+                }
+            }
+            throw new org.omg.CORBA.MARSHAL("invalid indirection offset = " + offset);
+        }
+        ValueType actualType;
+        boolean saveIsChunked = _isChunked;
+        _isChunked = (tag & 0x00000008) != 0;
+        String codebaseURL = null;
+        if ((tag & 0x00000001) == 1) {
+            codebaseURL = readMetaString();
+        }
+        switch (tag & 0x00000006) {
+            case 0: // NO_TYPE_VALUE_TAG
+                {
+                    actualType = declaredType;
+                    if (tc != null) {
+                        try {
+                            String id = tc.id();
+                            if (id != null) {
+                                int kind = tc.kind().value();
+                                if (kind == TCKind._tk_value_box) {
+                                    kind = tc.content_type().kind().value();
+                                    if (kind == TCKind._tk_wstring) {
+                                        actualType = ValueType.STRING_VALUE_TYPE;
+                                    }
+                                }
+                            }
+                        } catch (Exception ex) {
+                            throw new SystemException(ex);
+                        }
+                    }
+                }
+                break;
+            case 2: // SINGLE_TYPE_VALUE_TAG
+                {
+                    String repositoryID = readMetaString();
+// TODO                    requiresCustomSerialization = (Boolean)_specialCaseReposIds.get(repositoryID);
+                    actualType = ValueType.getInstanceByID(repositoryID);
+                }
+                break;
+            case 6: // TYPE_LIST_VALUE_TAG
+                {
+                    int n = _cdrInput.read_ulong();
+                    if (n < 1) {
+                        throw new org.omg.CORBA.MARSHAL("invalid type list length = " + n);
+                    }
+                    String repositoryID = readMetaString();
+// TODO                    requiresCustomSerialization = (Boolean)_specialCaseReposIds.get(repositoryID);
+                    actualType = ValueType.getInstanceByID(repositoryID);
+                    for (int i = 1; i < n; i++) {
+                        String ignore = readMetaString();
+                    }
+                }
+                break;
+            default:
+                throw new org.omg.CORBA.MARSHAL("invalid value tag = " + tag);
+        }
+        if (actualType.isObjectRef) {
+            value = actualType.helper.read(this);
+            return value;
+        }
+        startBlock();
+        if (_isChunked) {
+            _endLevel--;
+        }
+        Integer key = new Integer(saveOffset);
+        switch (actualType.readWriteCase) {
+            case ValueType.CASE_ARRAY:
+                value = readArray(actualType, key);
+                break;
+            case ValueType.CASE_CLASS:
+                value = readClassDesc();
+                putIndirection(key, value);
+                break;
+            case ValueType.CASE_IDL_ENTITY:
+                value = actualType.helper.read(this);
+                putIndirection(key, value);
+                break;
+                // case ValueType.CASE_IDL_OBJECT: // already handled above
+            case ValueType.CASE_STRING:
+                value = _cdrInput.read_wstring();
+                putIndirection(key, value);
+                break;
+            default:
+                value = actualType.newInstance();
+                putIndirection(key, value);
+                Object newValue = readObjectState(actualType, value, false); // requiresCustomSerialization);
+                if (newValue != value) {
+                    value = newValue;
+                    putIndirection(key, value);
+                }
+        }
+        endBlock();
+        readEndTag();
+        _isChunked = saveIsChunked;
+        startBlock();
+        return value;
+    }
+
+    protected String readMetaString() {
+        String id;
+        int saveOffset = _cdrInput._offset;
+        int tag = _cdrInput.read_long();
+        if (tag == ValueType.INDIRECTION_TAG) {
+            saveOffset = _cdrInput._offset;
+            int offset = _cdrInput.read_long();
+            Integer key = IntegerCache.get(saveOffset + offset);
+            id = _indirection == null ? null : (String) _indirection.get(key);
+            if (id == null) {
+                throw new org.omg.CORBA.MARSHAL("invalid indirection offset = " + offset);
+            }
+        } else {
+            _cdrInput._offset = saveOffset;
+            id = _cdrInput.read_string();
+            putIndirection(IntegerCache.get(saveOffset), id);
+        }
+        return id;
+    }
+
+    protected Object readObjectState(ValueType valueType, Object value, boolean requiresCustomSerialization) {
+        if (valueType.isExternalizable) {
+            byte format = _cdrInput.read_octet();
+            valueType.readExternal(value, this);
+            return value;
+        }
+        if (valueType.hasParentState) {
+            value = readObjectState(valueType.parent, value, false);
+        }
+        if (valueType.hasReadObject) {
+            push(new StreamState(valueType, value, _cdrInput._offset));
+            /* TODO
+            if (repositoryID.equals(_SUN_JDK_BIG_DECIMAL_REPOSID))
+            {
+                // Sun's first field is an int
+                int scale = readInt();
+                // Sun's second field is a java.math.BigInteger
+                java.math.BigInteger intVal = (java.math.BigInteger)readObject(java.math.BigInteger.class);
+                // Create BigDecimal using scale and intVal
+                value = new java.math.BigDecimal(intVal, scale);
+            }
+            else if (repositoryID.equals(_IBM_JDK_BIG_DECIMAL_REPOSID))
+            {
+                byte format = _cdrInput.read_octet();
+                boolean defaultWriteObjectCalled = _cdrInput.read_boolean();
+                // IBM's first field is a long
+                long intLong = readLong();
+                // IBM's second field is a int
+                int scale = readInt();
+                // IBM's third field is a java.math.BigInteger
+                java.math.BigInteger intVal = (java.math.BigInteger)readObject(java.math.BigInteger.class);
+                // We can ignore the long, since IBM doesn't use it
+                // in the writeObject, to ensure backward's compatibility
+                // with their previous versions which don't have the long.
+                value = new java.math.BigDecimal(intVal, scale);
+            }
+            else
+            */
+            {
+                if (valueType.hasWriteObject || requiresCustomSerialization) {
+                    byte format = _cdrInput.read_octet();
+                    boolean defaultWriteObjectCalled = _cdrInput.read_boolean();
+                }
+                valueType.readObject(value, this);
+            }
+            pop();
+        } else {
+            readDeclaredFields(valueType, value);
+        }
+        if (valueType.hasReadResolve) {
+            value = valueType.readResolve(value);
+        }
+        return value;
+    }
+
+    protected void readDeclaredFields(ValueType valueType, Object value) {
+        int n = valueType.fields.length;
+        for (int f = 0; f < n; f++) {
+            ValueTypeField field = valueType.fields[f];
+            int primitive = field.primitive;
+            if (primitive != 0) {
+                readPrimitive(primitive, field, value);
+            } else {
+                field.set(value, readObject(field.type, false));
+            }
+        }
+    }
+
+    protected Object readClassDesc() {
+        String codebase = (String) readObject(ValueType.STRING_VALUE_TYPE);
+        String id = (String) readObject(ValueType.STRING_VALUE_TYPE);
+        return ValueType.getInstanceByID(id)._class;
+    }
+
+    protected Object readArray(ValueType arrayType, Integer key) {
+        Object value = null;
+        int primitive = arrayType.primitiveArray;
+        int n = _cdrInput.read_ulong();
+        if (primitive != 0) {
+            value = arrayType.helper.read(this);
+            putIndirection(key, value);
+        } else {
+            Object[] array;
+            try {
+                array = n == 0 ? ArrayUtil.EMPTY_OBJECT_ARRAY : (Object[]) Array.newInstance(arrayType.element._class, n);
+            } catch (Exception ex) {
+                throw new SystemException(ex);
+            }
+            putIndirection(key, array);
+            for (int i = 0; i < n; i++) {
+                array[i] = readObject(arrayType.element, false);
+            }
+            value = array;
+        }
+        return value;
+    }
+
+    private void readPrimitive(int primitive, ValueTypeField field, Object value) {
+        switch (primitive) {
+            case PrimitiveType.BOOLEAN:
+                field.setBoolean(value, _cdrInput.read_boolean());
+                break;
+            case PrimitiveType.BYTE:
+                field.setByte(value, _cdrInput.read_octet());
+                break;
+            case PrimitiveType.CHAR:
+                field.setChar(value, _cdrInput.read_wchar());
+                break;
+            case PrimitiveType.DOUBLE:
+                field.setDouble(value, _cdrInput.read_double());
+                break;
+            case PrimitiveType.FLOAT:
+                field.setFloat(value, _cdrInput.read_float());
+                break;
+            case PrimitiveType.INT:
+                field.setInt(value, _cdrInput.read_long());
+                break;
+            case PrimitiveType.LONG:
+                field.setLong(value, _cdrInput.read_longlong());
+                break;
+            case PrimitiveType.SHORT:
+                field.setShort(value, _cdrInput.read_short());
+                break;
+            default:
+                throw new IllegalStateException();
+        }
+    }
+
+    /**
+     * * This method handle end tag compaction.  Note that it is lazy in the
+     * * sense that it always assumes a tag has been compacted if the end tag
+     * * is not what it expected.
+     */
+    protected void readEndTag() {
+        if (_isChunked) {
+            int anEndTag = _cdrInput.read_long();
+            if (anEndTag != _endLevel) {
+                _cdrInput._offset -= 4;
+            }
+            _endLevel++;
+        }
+    }
+
+    protected void startBlock() {
+        if (!_isChunked) {
+            return;
+        }
+        _blockLength = _cdrInput.read_long();
+        if (_blockLength >= 0
+            && _blockLength < MAXIMUM_BLOCK_LENGTH) {
+            _blockLength += _cdrInput._offset;
+        } else {
+            // Not a chunk length field.
+            _blockLength = MAXIMUM_BLOCK_LENGTH;
+            _cdrInput._offset -= 4;
+        }
+    }
+
+    protected void endBlock() {
+        // If in a chunk, check for underflow or overflow.
+        if (_blockLength != MAXIMUM_BLOCK_LENGTH) {
+            if (_blockLength == _cdrInput._offset) {
+                // Chunk ended correctly.
+                _blockLength = MAXIMUM_BLOCK_LENGTH;
+            }
+        }
+    }
+
+    protected void push(StreamState state) {
+        if (_stack == null) {
+            _stack = new ArrayList();
+        }
+        _stack.add(state);
+    }
+
+    protected void pop() {
+        int n = _stack.size();
+        if (n == 0) {
+            throw new SystemException("pop: state stack empty");
+        }
+        _stack.remove(n - 1);
+    }
+
+    protected StreamState top() {
+        int n = _stack.size();
+        if (n == 0) {
+            throw new SystemException("top: state stack empty");
+        }
+        return (StreamState) _stack.get(n - 1);
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectKey.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectKey.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectKey.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,80 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.geronimo.interop.security.User;
+import org.apache.geronimo.interop.util.ListUtil;
+
+
+public class ObjectKey {
+    public static final int TYPE_MANAGER = 'M';
+
+    public static final int TYPE_SESSION = 'S';
+
+    public int type;
+    public String username = "";
+    public String password = "";
+    public String component = "";
+    public String sessionID = "";
+
+    public byte[] encode() {
+        int un = username.length();
+        int pn = password.length();
+        int cn = component.length();
+        int sn = sessionID.length();
+        StringBuffer keyBuffer = new StringBuffer(12 + un + pn + cn + sn);
+        keyBuffer.append("U=");
+        keyBuffer.append(username);
+        keyBuffer.append("\tP=");
+        keyBuffer.append(password);
+        keyBuffer.append("\tC=");
+        keyBuffer.append(component);
+        if (sn > 0) {
+            keyBuffer.append("\tS=");
+            keyBuffer.append(sessionID);
+        }
+        byte[] bytes = SecurityInfo.encode(keyBuffer.toString());
+        bytes[0] = (byte) type;
+        return bytes;
+    }
+
+    public void decode(byte[] bytes) {
+        type = bytes.length == 0 ? 0 : bytes[0];
+        String key = SecurityInfo.decode(bytes);
+        List items = ListUtil.getListWithSeparator(key, "\t");
+        for (Iterator i = items.iterator(); i.hasNext();) {
+            String item = (String) i.next();
+            if (item.startsWith("U=")) {
+                username = item.substring(2);
+            } else if (item.startsWith("P=")) {
+                password = item.substring(2);
+            } else if (item.startsWith("C=")) {
+                component = item.substring(2);
+            } else if (item.startsWith("S=")) {
+                sessionID = item.substring(2);
+            }
+        }
+    }
+
+    public void checkPassword() {
+        User.getInstance(username).login(password);
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectOutputStream.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectOutputStream.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectOutputStream.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,515 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+import org.apache.geronimo.interop.SystemException;
+import org.apache.geronimo.interop.util.IntegerCache;
+import org.apache.geronimo.interop.util.SimpleIdentityHashMap;
+
+
+public class ObjectOutputStream extends java.io.ObjectOutputStream {
+    public static ObjectOutputStream getInstance() {
+        return getInstance(CdrOutputStream.getInstance());
+    }
+
+    public static ObjectOutputStream getInstance(CdrOutputStream cdrOutput) {
+        ObjectOutputStream output = null;
+        try {
+            output = new ObjectOutputStream();
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+
+        output.init(cdrOutput);
+        return output;
+    }
+
+    public static ObjectOutputStream getPooledInstance() {
+        ObjectOutputStream output = null; //(ObjectOutputStream)_pool.get();
+        if (output == null) {
+            output = getInstance();
+        }
+        return output;
+    }
+
+    // -----------------------------------------------------------------------
+    // private data
+    // -----------------------------------------------------------------------
+
+    protected static class StreamState {
+        ValueType type;
+        Object value;
+        int offset;
+
+        StreamState(ValueType type, Object value, int offset) {
+            this.type = type;
+            this.value = value;
+            this.offset = offset;
+        }
+    }
+
+    // -----------------------------------------------------------------------
+    // public data
+    // -----------------------------------------------------------------------
+
+    public CdrOutputStream _cdrOutput;
+
+    public boolean _hasException;
+
+    public Object[] thisAsObjectArray;
+
+    // -----------------------------------------------------------------------
+    // private data
+    // -----------------------------------------------------------------------
+
+    private static ValueType OBJECT_VALUE_TYPE = ValueType.getInstance(java.lang.Object.class);
+
+    private static boolean OBJECT_VALUE_TYPE_INIT = false;
+
+    //private static ThreadLocalInstancePool _pool = new ThreadLocalInstancePool(ObjectOutputStream.class.getName());
+
+    private ArrayList _stack = null;
+
+    private SimpleIdentityHashMap _indirection;
+
+    private int _blockSizeIndex = -1;
+
+    private int _endLevel;
+
+    private int _endTagIndex;
+
+    private boolean _inBlock = false;
+
+    private boolean _isChunked = false;
+
+    private int _booleanIndex = -1;
+
+    // -----------------------------------------------------------------------
+    // public methods
+    // -----------------------------------------------------------------------
+
+    public ObjectOutputStream() throws IOException {
+        super();
+    }
+
+    public void $reset() {
+        _cdrOutput.reset();
+        if (_indirection != null) {
+            _indirection.clear();
+        }
+        if (_stack != null) {
+            _stack.clear();
+        }
+        _blockSizeIndex = -1;
+        _endLevel = 0;
+        _endTagIndex = 0;
+        _inBlock = false;
+        _isChunked = false;
+        _booleanIndex = -1;
+    }
+
+    public void recycle() {
+        $reset();
+        //_pool.put(this);
+    }
+
+    // -----------------------------------------------------------------------
+    // public methods from java.io.ObjectOutputStream
+    // -----------------------------------------------------------------------
+
+    public void writeBoolean(boolean value) {
+        _cdrOutput.write_boolean(value);
+    }
+
+    public void writeChar(char value) {
+        _cdrOutput.write_wchar(value);
+    }
+
+    public void writeByte(byte value) {
+        _cdrOutput.write_octet(value);
+    }
+
+    public void writeShort(short value) {
+        _cdrOutput.write_short(value);
+    }
+
+    public void writeInt(int value) {
+        _cdrOutput.write_long(value);
+    }
+
+    public void writeLong(long value) {
+        _cdrOutput.write_longlong(value);
+    }
+
+    public void writeFloat(float value) {
+        _cdrOutput.write_float(value);
+    }
+
+    public void writeDouble(double value) {
+        _cdrOutput.write_double(value);
+    }
+
+    public void writeObjectOverride(Object value) {
+        writeObject(OBJECT_VALUE_TYPE, value);
+    }
+
+    public void defaultWriteObject() throws IOException {
+        StreamState state = top();
+        // TODO: check this
+        int saveOffset = _cdrOutput._offset;
+        _cdrOutput._offset = _booleanIndex;
+        _cdrOutput.write_boolean(true);
+        _cdrOutput._offset = saveOffset;
+        writeDeclaredFields(state.type, state.value);
+    }
+
+    // -----------------------------------------------------------------------
+    // public methods used by generated and package-internal code
+    // -----------------------------------------------------------------------
+
+    public boolean hasException() {
+        return _hasException;
+    }
+
+    public void writeException(ValueType type, Exception value) {
+        writeObject(type, value);
+        _hasException = true;
+    }
+
+    public void writeObject(ValueType type, Object value) {
+        writeObject(type, value, false);
+    }
+
+    // -----------------------------------------------------------------------
+    // protected methods
+    // -----------------------------------------------------------------------
+
+    protected void init(CdrOutputStream cdrOutput) {
+        _cdrOutput = cdrOutput;
+        thisAsObjectArray = new Object[]{this};
+    }
+
+    protected void putIndirection(Object value, Integer ref) {
+        if (_indirection == null) {
+            _indirection = new SimpleIdentityHashMap(8);
+        }
+        _indirection.put(value, ref);
+    }
+
+    protected void writeObject(ValueType declaredType, Object value, boolean calledFromCustomSerialization) {
+        ValueType actualType = declaredType;
+        if (value != null) {
+            Class vc = value.getClass();
+            if (vc != declaredType._class) {
+                actualType = ValueType.getInstance(vc);
+            }
+            if (actualType.hasWriteReplace) {
+                value = actualType.writeReplace(value);
+            }
+        }
+        boolean saveIsChunked = _isChunked;
+        if (_inBlock) {
+            if (actualType != null) {
+                if (!(declaredType.isAny && actualType.isObjectRef)) {
+                    endBlock();
+                }
+            }
+        }
+        if (value == null) {
+            if (calledFromCustomSerialization) {
+                _cdrOutput.write_boolean(actualType.isObjectRef);
+                if (actualType.isObjectRef) {
+                    _cdrOutput.write_Object((org.omg.CORBA.Object) value);
+                    endBlock();
+                } else {
+                    _cdrOutput.write_long(ValueType.NULL_VALUE_TAG);
+                }
+                return;
+            }
+            if (declaredType.isAny) {
+                _cdrOutput.write_TypeCode(ValueType.TC_ABSTRACT_BASE);
+                _cdrOutput.write_boolean(false);
+            }
+            if (declaredType.isObjectRef) {
+                _cdrOutput.write_Object((org.omg.CORBA.Object) value);
+            } else {
+                if (declaredType.isAbstractInterface) {
+                    _cdrOutput.write_boolean(false);
+                }
+                _cdrOutput.write_long(ValueType.NULL_VALUE_TAG);
+            }
+            return;
+        }
+        if (declaredType.isAny && !calledFromCustomSerialization) {
+            org.omg.CORBA.TypeCode tc = actualType.tc;
+            _cdrOutput.write_TypeCode(tc);
+        } else if (declaredType.isAbstractInterface || calledFromCustomSerialization) {
+            _cdrOutput.write_boolean(actualType.isObjectRef);
+            if (actualType.isObjectRef) {
+                _cdrOutput.write_Object((org.omg.CORBA.Object) value);
+                return;
+            }
+        }
+        if (actualType.isObjectRef) {
+            if (value instanceof RemoteInterface) {
+                value = ((RemoteInterface) value).$getObjectRef();
+            }
+            _cdrOutput.write_Object((org.omg.CORBA.Object) value);
+            return;
+        }
+        Integer ref = _indirection == null ? null : (Integer) _indirection.get(value);
+        if (ref != null) {
+            _cdrOutput.write_long(ValueType.INDIRECTION_TAG);
+            _cdrOutput.write_long(ref.intValue() - _cdrOutput._offset);
+            return;
+        } else {
+            _cdrOutput.write_align(4, 4); // write any necessary padding
+            ref = IntegerCache.get(_cdrOutput._offset);
+            putIndirection(value, ref);
+        }
+        if (saveIsChunked || actualType.requiresCustomSerialization) {
+            _cdrOutput.write_long(ValueType.TRUNCATABLE_SINGLE_TYPE_VALUE_TAG);
+            _isChunked = true;
+        } else {
+            _cdrOutput.write_long(ValueType.SINGLE_TYPE_VALUE_TAG);
+            _isChunked = false;
+        }
+        writeMetaString(actualType.id);
+        startBlock();
+        switch (actualType.readWriteCase) {
+            case ValueType.CASE_ARRAY:
+                writeArray(actualType, value);
+                break;
+            case ValueType.CASE_CLASS:
+                writeClassDesc((java.lang.Class) value);
+                break;
+            case ValueType.CASE_IDL_ENTITY:
+                actualType.helper.write(this, value);
+                break;
+                // case ValueType.IDL_OBJECT: // already handled above
+            case ValueType.CASE_STRING:
+                _cdrOutput.write_wstring((String) value);
+                break;
+            default:
+                writeObjectState(actualType, value);
+        }
+        endBlock();
+        writeEndTag();
+        _isChunked = saveIsChunked;
+    }
+
+    protected void writeMetaString(String ms) {
+        Integer ref = (Integer) _indirection.get(ms);
+        if (ref != null) {
+            _cdrOutput.write_long(ValueType.INDIRECTION_TAG);
+            _cdrOutput.write_long(ref.intValue() - _cdrOutput._offset);
+        } else {
+            ref = IntegerCache.get(_cdrOutput._offset);
+            _cdrOutput.write_string(ms);
+            putIndirection(ms, ref);
+        }
+    }
+
+    protected void writeObjectState(ValueType type, Object value) {
+        if (type.isExternalizable) {
+            _cdrOutput.write_octet((byte) 1);
+            type.writeExternal(value, this);
+            return;
+        }
+        if (type.hasParentState) {
+            writeObjectState(type.parent, value);
+        }
+        if (type.hasWriteObject && type.hasReadObject) {
+            push(new StreamState(type, value, _cdrOutput._offset));
+            if (type.skipCustomFlags) {
+                _booleanIndex = _cdrOutput._offset;
+            } else {
+                _cdrOutput.write_octet((byte) 1);
+                _cdrOutput.write_boolean(false);
+                _booleanIndex = _cdrOutput._offset - 1;
+            }
+            type.writeObject(value, this);
+            pop();
+        } else {
+            writeDeclaredFields(type, value);
+        }
+    }
+
+    protected void writeDeclaredFields(ValueType type, Object value) {
+        int n = type.fields.length;
+        for (int f = 0; f < n; f++) {
+            ValueTypeField field = type.fields[f];
+            int primitive = field.primitive;
+            if (primitive != 0) {
+                writePrimitive(primitive, field, value);
+            } else {
+                writeObject(field.type, field.get(value), false);
+            }
+        }
+    }
+
+    protected void writeClassDesc(Class theClass) {
+        writeObject(ValueType.STRING_VALUE_TYPE, null); // codebase URL
+        writeObject(ValueType.STRING_VALUE_TYPE, ValueType.getInstance(theClass).id);
+    }
+
+    protected void writeArray(ValueType arrayType, Object value) {
+        int primitive = arrayType.primitiveArray;
+        if (primitive != 0) {
+            arrayType.helper.write(this, value);
+        } else {
+            Object[] array = (Object[]) value;
+            int n = array.length;
+            _cdrOutput.write_ulong(n);
+            for (int i = 0; i < n; i++) {
+                writeObject(arrayType.element, array[i], false);
+            }
+        }
+    }
+
+    protected void writePrimitive(int primitive, ValueTypeField field, Object value) {
+        switch (primitive) {
+            case PrimitiveType.BOOLEAN:
+                _cdrOutput.write_boolean(field.getBoolean(value));
+                break;
+            case PrimitiveType.BYTE:
+                _cdrOutput.write_octet(field.getByte(value));
+                break;
+            case PrimitiveType.CHAR:
+                _cdrOutput.write_wchar(field.getChar(value));
+                break;
+            case PrimitiveType.DOUBLE:
+                _cdrOutput.write_double(field.getDouble(value));
+                break;
+            case PrimitiveType.FLOAT:
+                _cdrOutput.write_float(field.getFloat(value));
+                break;
+            case PrimitiveType.INT:
+                _cdrOutput.write_long(field.getInt(value));
+                break;
+            case PrimitiveType.LONG:
+                _cdrOutput.write_longlong(field.getLong(value));
+                break;
+            case PrimitiveType.SHORT:
+                _cdrOutput.write_short(field.getShort(value));
+                break;
+            default:
+                throw new IllegalStateException();
+        }
+    }
+
+    public void startBlock() {
+        if (!_isChunked) {
+            return;
+        }
+        _endLevel--;
+        _cdrOutput.write_long(0);
+        _inBlock = true;
+        _blockSizeIndex = _cdrOutput._offset - 4;
+    }
+
+    public void endBlock() {
+        if (!_inBlock) {
+            return;
+        }
+        _inBlock = false;
+        int oldSize = _cdrOutput._offset;
+        _cdrOutput._offset = _blockSizeIndex;
+        _cdrOutput.write_long(oldSize - _blockSizeIndex - 4);
+        _cdrOutput._offset = oldSize;
+        _blockSizeIndex = -1;
+    }
+
+    protected void writeEndTag() {
+        if (_isChunked) {
+            if (_endTagIndex == _cdrOutput._offset - 8) {
+                _cdrOutput._offset -= 8;
+            }
+            _cdrOutput.write_long(_endLevel);
+            _endTagIndex = _cdrOutput._offset - 4;
+            if (_endLevel != -1) {
+                _cdrOutput.write_long(1);
+            } else // _endLevel == -1
+            {
+                _cdrOutput._offset -= 4;
+                _cdrOutput.write_long(-1);
+                _isChunked = false;
+            }
+            _endLevel++;
+        }
+    }
+
+    /*
+    public java.io.ObjectOutputStream.PutField putFields() throws IOException
+    {
+        StreamState state = top();
+
+        Class currentClass = state.type.getTheClass();
+        if(currentClass == null)
+        {
+            throw new IOException("putFields: class from ValueType is null");
+        }
+
+        java.io.ObjectStreamClass osc = ObjectStreamClass.lookup(currentClass);
+        if(osc == null)
+        {
+            throw new IOException("putFields: ObjectSteamClass is null");
+        }
+        state.putField = new com.sybase.CORBA.iiop.PutField(osc);
+        return state.putField;
+    }
+
+    public void writeFields() throws IOException
+    {
+
+        StreamState state = top();
+        if(state.putField == null)
+        {
+            throw new IOException("writeFields: PutField object is null");
+        }
+
+        state.putField.writeFields(this);
+    }
+    */
+
+    protected void push(StreamState state) {
+        if (_stack == null) {
+            _stack = new ArrayList();
+        }
+        _stack.add(state);
+    }
+
+    protected void pop() {
+        int n = _stack.size();
+        if (n == 0) {
+            throw new SystemException("pop: state stack empty");
+        }
+        _stack.remove(n - 1);
+    }
+
+    private StreamState top() {
+        int n = _stack.size();
+        if (n == 0) {
+            throw new SystemException("top: state stack empty");
+        }
+        return (StreamState) _stack.get(n - 1);
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectRef.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectRef.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectRef.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,354 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop;
+
+import java.util.Hashtable;
+
+import org.apache.geronimo.interop.IIOP.*;
+import org.apache.geronimo.interop.IOP.*;
+import org.apache.geronimo.interop.SystemException;
+import org.apache.geronimo.interop.rmi.iiop.client.ClientNamingContext;
+import org.apache.geronimo.interop.rmi.iiop.client.Connection;
+import org.apache.geronimo.interop.security.SimpleSubject;
+import org.apache.geronimo.interop.util.FutureObject;
+import org.apache.geronimo.interop.util.ThreadContext;
+import org.apache.geronimo.interop.util.UTF8;
+import org.apache.geronimo.interop.util.UnsignedShort;
+
+
+public class ObjectRef implements org.omg.CORBA.Object {
+    // -----------------------------------------------------------------------
+    // public data
+    // -----------------------------------------------------------------------
+
+    public static final int IIOP_VERSION_1_0 = 0;
+    public static final int IIOP_VERSION_1_1 = 1;
+    public static final int IIOP_VERSION_1_2 = 2;
+
+    // -----------------------------------------------------------------------
+    // private data
+    // -----------------------------------------------------------------------
+
+    private static FutureObject _defaultNamingContext = new FutureObject() {
+        public Object evaluate() {
+            Hashtable env = new Hashtable();
+            return ClientNamingContext.getInstance(env);
+        }
+    };
+
+    private static Version VERSION_1_1 = new Version((byte) 1, (byte) 1);
+
+    private static Version VERSION_1_2 = new Version((byte) 1, (byte) 2);
+
+    private static TaggedComponent[] NO_PROFILE_COMPONENTS = {};
+
+    private int _iiopVersion = IIOP_VERSION_1_2;
+
+    private org.apache.geronimo.interop.IOP.IOR _ior;
+
+    private ClientNamingContext _namingContext;
+
+    private String _repositoryID; // CORBA repository ID e.g. "RMI:xyz:0000000000000000"
+
+    private int _protocol;
+
+    private String _endpoint;
+
+    private String _host;
+
+    private int _port = -1;
+
+    public byte[] _objectKey;
+
+    public byte[] _objectState;
+
+    public long _objectVersion;
+
+    // public methods
+
+    public ObjectRef() {
+    }
+
+    public Connection $connect() {
+        Connection conn = $getNamingContext().getConnectionPool().get(_protocol, $getEndpoint(), this);
+        conn.beforeInvoke();
+        return conn;
+    }
+
+    public int $getIiopVersion() {
+        return _iiopVersion;
+    }
+
+    public void $setIiopVersion(int version) {
+        _iiopVersion = version;
+    }
+
+    public String $getID() {
+        if (_repositoryID == null) {
+            return "";
+        } else {
+            return _repositoryID;
+        }
+    }
+
+    public void $setID(String id) {
+        _repositoryID = id;
+    }
+
+    public org.apache.geronimo.interop.IOP.IOR $getIOR() {
+        if (_ior == null) {
+            ProfileBody_1_1 profileBody = new ProfileBody_1_1();
+            profileBody.iiop_version = _iiopVersion == IIOP_VERSION_1_1
+                                       ? VERSION_1_1 : VERSION_1_2;
+            if (_host == null || _host.length() == 0) {
+                profileBody.host = ThreadContext.getDefaultRmiHost();
+            } else {
+                profileBody.host = _host;
+            }
+            if (_port == -1) {
+                profileBody.port = (short) ThreadContext.getDefaultRmiPort();
+            } else {
+                profileBody.port = (short) _port;
+            }
+            profileBody.object_key = _objectKey;
+            // TODO: if protocol using SSL, set port to 0 and set components
+            profileBody.components = NO_PROFILE_COMPONENTS;
+
+            TaggedProfile profile = new TaggedProfile();
+            profile.tag = TAG_INTERNET_IOP.value;
+            CdrOutputStream output = CdrOutputStream.getInstanceForEncapsulation();
+            ProfileBody_1_1Helper.write(output, profileBody);
+            profile.profile_data = output.getEncapsulation();
+
+            IOR ior = new IOR();
+            ior.type_id = $getID();
+            ior.profiles = new TaggedProfile[]{profile};
+            return ior;
+        }
+        return _ior;
+    }
+
+    public void $setIOR(org.apache.geronimo.interop.IOP.IOR ior) {
+        _ior = ior;
+        _endpoint = null;
+        _objectKey = null;
+        $getObjectKey(); // set _protocol, _host, _port, _objectKey
+    }
+
+    public ClientNamingContext $getNamingContext() {
+        if (_namingContext == null) {
+            _namingContext = (ClientNamingContext) _defaultNamingContext.getValue();
+        }
+        return _namingContext;
+    }
+
+    public void $setNamingContext(ClientNamingContext namingContext) {
+        _namingContext = namingContext;
+    }
+
+    public int $getProtocol() {
+        if (_objectKey == null) {
+            $getObjectKey(); // to set _protocol
+        }
+        return _protocol;
+    }
+
+    public void $setProtocol(int protocol) {
+        _protocol = protocol;
+        _ior = null;
+    }
+
+    public String $getHost() {
+        if (_objectKey == null) {
+            $getObjectKey(); // to set _host
+        }
+        return _host;
+    }
+
+    public void $setHost(String host) {
+        _host = host;
+        _endpoint = null;
+        _ior = null;
+    }
+
+    public int $getPort() {
+        if (_objectKey == null) {
+            $getObjectKey(); // to set _port
+        }
+        return _port;
+    }
+
+    public void $setPort(int port) {
+        _port = port;
+        _endpoint = null;
+        _ior = null;
+    }
+
+    public String $getEndpoint() {
+        if (_endpoint == null) {
+            _endpoint = _host + ":" + _port;
+        }
+        return _endpoint;
+    }
+
+    public byte[] $getObjectKey() {
+        if (_objectKey == null) {
+            if (_ior == null) {
+                throw new IllegalStateException("$getObjectKey: _ior == null && _objectKey = null");
+            }
+            TaggedProfile profile = _ior.profiles[0];
+            if (profile.tag == TAG_INTERNET_IOP.value
+                && _ior.profiles.length == 1) {
+                ProfileBody_1_1 profileBody;
+                CdrInputStream input = CdrInputStream.getInstanceForEncapsulation();
+                input.setEncapsulation(profile.profile_data);
+                profileBody = ProfileBody_1_1Helper.read(input);
+                input.recycle();
+
+                _protocol = Protocol.IIOP; // TODO: IIOP/SSL etc.
+                _iiopVersion = profileBody.iiop_version.minor;
+                _host = profileBody.host;
+                _port = UnsignedShort.intValue(profileBody.port);
+                _objectKey = profileBody.object_key;
+            } else {
+                throw new SystemException("TODO");
+            }
+        }
+        return _objectKey;
+    }
+
+    public String $getObjectKeyString() {
+        return UTF8.toString($getObjectKey());
+    }
+
+    public void $setObjectKey(byte[] objectKey) {
+        _objectKey = objectKey;
+        _ior = null;
+    }
+
+    public void $setObjectKey(String objectKey) {
+        $setObjectKey(UTF8.fromString(objectKey));
+    }
+
+    public void $setObjectKey(String prefix, byte[] suffixBytes) {
+        byte[] prefixBytes = UTF8.fromString(prefix);
+        int p = prefixBytes.length;
+        int s = suffixBytes.length;
+        byte[] objectKey = new byte[p + 1 + s];
+        System.arraycopy(prefixBytes, 0, objectKey, 0, p);
+        objectKey[p] = (byte) ':';
+        System.arraycopy(suffixBytes, 0, objectKey, p + 1, s);
+        $setObjectKey(objectKey);
+    }
+
+    public void $setObjectKey(Class compClass) {
+        SimpleSubject subject = SimpleSubject.getCurrent();
+        if (subject != null
+            && (subject.getFlags() & SimpleSubject.FLAG_SESSION_MANAGER) != 0) {
+            // Initialize for simple IDL interoperability.
+            ObjectKey objectKey = new ObjectKey();
+            objectKey.component = compClass.getName();
+            objectKey.username = subject.getUsername();
+            objectKey.password = subject.getPassword();
+            byte[] key = objectKey.encode();
+            key[0] = 'I';
+            _iiopVersion = IIOP_VERSION_1_1;
+            $setObjectKey(key);
+        } else {
+            // Initialize for RMI-IIOP.
+            $setObjectKey(compClass.getName());
+        }
+    }
+
+    public String[] _ids() {
+        String[] ids =
+                {
+                    "" //_type
+                }
+                ;
+        return ids;
+    }
+
+    public Object $getRequestKey() {
+        //
+        //if (_automaticFailover)
+        //{
+        //    return $getNamingContext().getRequestKey();
+        //}
+        //else
+        //{
+        return null;
+        //}
+    }
+
+    public boolean _is_a(String id) {
+        return false;
+    }
+
+    // -----------------------------------------------------------------------
+    // unimplemented public methods (only required for full CORBA ORB)
+    // -----------------------------------------------------------------------
+
+    public org.omg.CORBA.Request _create_request(org.omg.CORBA.Context p1, String p2, org.omg.CORBA.NVList p3, org.omg.CORBA.NamedValue p4) {
+        throw new org.omg.CORBA.BAD_OPERATION("_create_request");
+    }
+
+    public org.omg.CORBA.Request _create_request(org.omg.CORBA.Context p1, String p2, org.omg.CORBA.NVList p3, org.omg.CORBA.NamedValue p4, org.omg.CORBA.ExceptionList p5, org.omg.CORBA.ContextList p6) {
+        throw new org.omg.CORBA.BAD_OPERATION("_create_request");
+    }
+
+    public org.omg.CORBA.Object _duplicate() {
+        throw new org.omg.CORBA.BAD_OPERATION("_duplicate");
+    }
+
+    public org.omg.CORBA.DomainManager[] _get_domain_managers() {
+        throw new org.omg.CORBA.BAD_OPERATION("_get_domain_manager");
+    }
+
+    public org.omg.CORBA.Object _get_interface_def() {
+        throw new org.omg.CORBA.BAD_OPERATION("_get_interface_def");
+    }
+
+    public org.omg.CORBA.Policy _get_policy(int p1) {
+        throw new org.omg.CORBA.BAD_OPERATION("_get_policy");
+    }
+
+    public int _hash(int p1) {
+        throw new org.omg.CORBA.BAD_OPERATION("_hash");
+    }
+
+    public boolean _is_equivalent(org.omg.CORBA.Object p1) {
+        throw new org.omg.CORBA.BAD_OPERATION("_is_equivalent");
+    }
+
+    public boolean _non_existent() {
+        throw new org.omg.CORBA.BAD_OPERATION("_non_existent");
+    }
+
+    public void _release() {
+        throw new org.omg.CORBA.BAD_OPERATION("_release");
+    }
+
+    public org.omg.CORBA.Request _request(String p1) {
+        throw new org.omg.CORBA.BAD_OPERATION("_request");
+    }
+
+    public org.omg.CORBA.Object _set_policy_override(org.omg.CORBA.Policy[] p1, org.omg.CORBA.SetOverrideType p2) {
+        throw new org.omg.CORBA.BAD_OPERATION("_set_policy_override");
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectRefHelper.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectRefHelper.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectRefHelper.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,42 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop;
+
+
+
+
+public class ObjectRefHelper implements ObjectHelper {
+    public static ObjectRefHelper getInstance(Class theClass) {
+        return new ObjectRefHelper();
+    }
+
+    public Object read(ObjectInputStream input) {
+        return input._cdrInput.read_Object();
+    }
+
+    public void write(ObjectOutputStream output, Object value) {
+        if (value == null || value instanceof ObjectRef) {
+            output._cdrOutput.write_Object((org.omg.CORBA.Object) value);
+        } else if (value instanceof RemoteInterface) {
+            RemoteInterface remote = (RemoteInterface) value;
+            output._cdrOutput.write_Object((org.omg.CORBA.Object) remote.$getObjectRef());
+        } else {
+            throw new IllegalArgumentException("class = " + value.getClass());
+        }
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/PrimitiveType.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/PrimitiveType.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/PrimitiveType.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,259 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop;
+
+import org.apache.geronimo.interop.util.ArrayUtil;
+
+
+public class PrimitiveType {
+    public static final int BOOLEAN = 1;
+    public static final int BYTE = 2;
+    public static final int CHAR = 3;
+    public static final int DOUBLE = 4;
+    public static final int FLOAT = 5;
+    public static final int INT = 6;
+    public static final int LONG = 7;
+    public static final int SHORT = 8;
+
+    public static final ObjectHelper BOOLEAN_ARRAY_HELPER = new ObjectHelper() {
+        public Object read(ObjectInputStream input) {
+            int n = input._cdrInput.read_long();
+            if (n == 0) {
+                return ArrayUtil.EMPTY_BOOLEAN_ARRAY;
+            }
+            boolean[] array = new boolean[n];
+            input._cdrInput.read_boolean_array(array, 0, n);
+            return array;
+        }
+
+        public void write(ObjectOutputStream output, Object value) {
+            boolean[] array = (boolean[]) value;
+            int n = array.length;
+            output._cdrOutput.write_long(n);
+            output._cdrOutput.write_boolean_array(array, 0, n);
+        }
+    }
+            ;
+
+    public static final ObjectHelper BYTE_ARRAY_HELPER = new ObjectHelper() {
+        public Object read(ObjectInputStream input) {
+            int n = input._cdrInput.read_long();
+            if (n == 0) {
+                return ArrayUtil.EMPTY_BYTE_ARRAY;
+            }
+            byte[] array = new byte[n];
+            input._cdrInput.read_octet_array(array, 0, n);
+            return array;
+        }
+
+        public void write(ObjectOutputStream output, Object value) {
+            byte[] array = (byte[]) value;
+            int n = array.length;
+            output._cdrOutput.write_long(n);
+            output._cdrOutput.write_octet_array(array, 0, n);
+        }
+    }
+            ;
+
+    public static final ObjectHelper CHAR_ARRAY_HELPER = new ObjectHelper() {
+        public Object read(ObjectInputStream input) {
+            int n = input._cdrInput.read_long();
+            if (n == 0) {
+                return ArrayUtil.EMPTY_CHAR_ARRAY;
+            }
+            char[] array = new char[n];
+            input._cdrInput.read_char_array(array, 0, n);
+            return array;
+        }
+
+        public void write(ObjectOutputStream output, Object value) {
+            char[] array = (char[]) value;
+            int n = array.length;
+            output._cdrOutput.write_long(n);
+            output._cdrOutput.write_char_array(array, 0, n);
+        }
+    }
+            ;
+
+    public static final ObjectHelper DOUBLE_ARRAY_HELPER = new ObjectHelper() {
+        public Object read(ObjectInputStream input) {
+            int n = input._cdrInput.read_long();
+            if (n == 0) {
+                return ArrayUtil.EMPTY_DOUBLE_ARRAY;
+            }
+            double[] array = new double[n];
+            input._cdrInput.read_double_array(array, 0, n);
+            return array;
+        }
+
+        public void write(ObjectOutputStream output, Object value) {
+            double[] array = (double[]) value;
+            int n = array.length;
+            output._cdrOutput.write_long(n);
+            output._cdrOutput.write_double_array(array, 0, n);
+        }
+    }
+            ;
+
+    public static final ObjectHelper FLOAT_ARRAY_HELPER = new ObjectHelper() {
+        public Object read(ObjectInputStream input) {
+            int n = input._cdrInput.read_long();
+            if (n == 0) {
+                return ArrayUtil.EMPTY_FLOAT_ARRAY;
+            }
+            float[] array = new float[n];
+            input._cdrInput.read_float_array(array, 0, n);
+            return array;
+        }
+
+        public void write(ObjectOutputStream output, Object value) {
+            float[] array = (float[]) value;
+            int n = array.length;
+            output._cdrOutput.write_long(n);
+            output._cdrOutput.write_float_array(array, 0, n);
+        }
+    }
+            ;
+
+    public static final ObjectHelper INT_ARRAY_HELPER = new ObjectHelper() {
+        public Object read(ObjectInputStream input) {
+            int n = input._cdrInput.read_long();
+            if (n == 0) {
+                return ArrayUtil.EMPTY_INT_ARRAY;
+            }
+            int[] array = new int[n];
+            input._cdrInput.read_long_array(array, 0, n);
+            return array;
+        }
+
+        public void write(ObjectOutputStream output, Object value) {
+            int[] array = (int[]) value;
+            int n = array.length;
+            output._cdrOutput.write_long(n);
+            output._cdrOutput.write_long_array(array, 0, n);
+        }
+    }
+            ;
+
+    public static final ObjectHelper LONG_ARRAY_HELPER = new ObjectHelper() {
+        public Object read(ObjectInputStream input) {
+            int n = input._cdrInput.read_long();
+            if (n == 0) {
+                return ArrayUtil.EMPTY_LONG_ARRAY;
+            }
+            long[] array = new long[n];
+            input._cdrInput.read_longlong_array(array, 0, n);
+            return array;
+        }
+
+        public void write(ObjectOutputStream output, Object value) {
+            long[] array = (long[]) value;
+            int n = array.length;
+            output._cdrOutput.write_long(n);
+            output._cdrOutput.write_longlong_array(array, 0, n);
+        }
+    }
+            ;
+
+    public static final ObjectHelper SHORT_ARRAY_HELPER = new ObjectHelper() {
+        public Object read(ObjectInputStream input) {
+            int n = input._cdrInput.read_long();
+            if (n == 0) {
+                return ArrayUtil.EMPTY_SHORT_ARRAY;
+            }
+            short[] array = new short[n];
+            input._cdrInput.read_short_array(array, 0, n);
+            return array;
+        }
+
+        public void write(ObjectOutputStream output, Object value) {
+            short[] array = (short[]) value;
+            int n = array.length;
+            output._cdrOutput.write_long(n);
+            output._cdrOutput.write_short_array(array, 0, n);
+        }
+    }
+            ;
+
+    public static int get(Class _class) {
+        if (_class == boolean.class) {
+            return BOOLEAN;
+        } else if (_class == byte.class) {
+            return BYTE;
+        } else if (_class == char.class) {
+            return CHAR;
+        } else if (_class == double.class) {
+            return DOUBLE;
+        } else if (_class == float.class) {
+            return FLOAT;
+        } else if (_class == int.class) {
+            return INT;
+        } else if (_class == long.class) {
+            return LONG;
+        } else if (_class == short.class) {
+            return SHORT;
+        } else {
+            throw new IllegalArgumentException("class = " + _class.getName());
+        }
+    }
+
+    public static ObjectHelper getArrayHelper(Class _class) {
+        if (_class == boolean.class) {
+            return BOOLEAN_ARRAY_HELPER;
+        } else if (_class == byte.class) {
+            return BYTE_ARRAY_HELPER;
+        } else if (_class == char.class) {
+            return CHAR_ARRAY_HELPER;
+        } else if (_class == double.class) {
+            return DOUBLE_ARRAY_HELPER;
+        } else if (_class == float.class) {
+            return FLOAT_ARRAY_HELPER;
+        } else if (_class == int.class) {
+            return INT_ARRAY_HELPER;
+        } else if (_class == long.class) {
+            return LONG_ARRAY_HELPER;
+        } else if (_class == short.class) {
+            return SHORT_ARRAY_HELPER;
+        } else {
+            throw new IllegalArgumentException("class = " + _class.getName());
+        }
+    }
+
+    public static org.omg.CORBA.TypeCode getTypeCode(int p) {
+        switch (p) {
+            case BOOLEAN:
+                return TypeCode.BOOLEAN;
+            case BYTE:    // java byte is IDL octet
+                return TypeCode.OCTET;
+            case CHAR:
+                return TypeCode.CHAR;
+            case DOUBLE:
+                return TypeCode.DOUBLE;
+            case FLOAT:
+                return TypeCode.FLOAT;
+            case INT:     // java int is IDL long
+                return TypeCode.LONG;
+            case LONG:    // java long is IDL long long
+                return TypeCode.LONGLONG;
+            case SHORT:
+                return TypeCode.SHORT;
+            default:
+                throw new IllegalArgumentException("primitive type = " + p);
+        }
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/Protocol.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/Protocol.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/Protocol.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,69 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop;
+
+public abstract class Protocol {
+    public static final int IIOP = 1;
+    public static final int IIOPS = 2;
+    public static final int HTTP = 3;
+    public static final int HTTPS = 4;
+
+    public static String getName(int protocol) {
+        switch (protocol) {
+            case IIOP:
+                return "iiop";
+            case IIOPS:
+                return "iiop";
+            case HTTP:
+                return "http";
+            case HTTPS:
+                return "https";
+            default:
+                throw new IllegalArgumentException("protocol = " + protocol);
+        }
+    }
+
+    public static String getScheme(int protocol) {
+        switch (protocol) {
+            case IIOP:
+                return "iiop:";
+            case IIOPS:
+                return "iiop:";
+            case HTTP:
+                return "http:";
+            case HTTPS:
+                return "https:";
+            default:
+                throw new IllegalArgumentException("protocol = " + protocol);
+        }
+    }
+
+    public static int getNumber(String protocol) {
+        if (protocol.equals("iiop")) {
+            return IIOP;
+        } else if (protocol.equals("iiops")) {
+            return IIOPS;
+        } else if (protocol.equals("http")) {
+            return HTTP;
+        } else if (protocol.equals("https")) {
+            return HTTPS;
+        } else {
+            throw new IllegalArgumentException("protocol = " + protocol);
+        }
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/RemoteExceptionFactory.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/RemoteExceptionFactory.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/RemoteExceptionFactory.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,39 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop;
+
+import org.apache.geronimo.interop.SystemException;
+import org.apache.geronimo.interop.util.ExceptionUtil;
+
+
+public abstract class RemoteExceptionFactory {
+    public static java.rmi.RemoteException getException(Exception ex) {
+        if (ex instanceof SystemException) {
+            Throwable cause = ((SystemException) ex).getCause();
+            if (cause instanceof org.omg.CORBA.SystemException) {
+                org.omg.CORBA.SystemException corbaException = (org.omg.CORBA.SystemException) cause;
+                if (ex.getMessage() == null) {
+                    return new java.rmi.ServerException(corbaException.getClass().getName(), corbaException);
+                } else {
+                    return new java.rmi.ServerException(ex.getMessage(), corbaException);
+                }
+            }
+        }
+        return new java.rmi.RemoteException(ExceptionUtil.getStackTrace(ex));
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/RemoteInterface.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/RemoteInterface.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/RemoteInterface.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,26 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop;
+
+public interface RemoteInterface {
+    public ObjectRef $getObjectRef();
+
+    public RemoteInterface $getSkeleton();
+
+    public void $invoke(String method, byte[] objectKey, Object instance, ObjectInputStream input, ObjectOutputStream output);
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/RemoteObject.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/RemoteObject.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/RemoteObject.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,58 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop;
+
+public abstract class RemoteObject {
+    public RemoteObject() {
+    }
+
+    protected void registerMethods() {
+        registerMethod("_is_a", -1);
+    }
+
+    public void invoke(int id, byte[] objectKey, Object instance, ObjectInputStream input, ObjectOutputStream output) {
+        switch (id) {
+            case -1:
+                {
+                    output.writeBoolean(_is_a(objectKey));
+                    break;
+                }
+        }
+    }
+
+    public boolean _is_a(byte[] objectKey) {
+        String ids[] = getIds();
+        boolean isa = false;
+
+        String id = new String(objectKey);
+
+        if (ids != null && ids.length > 0) {
+            int i;
+            for (i = 0; i < ids.length && !isa; i++) {
+                isa = ids[i].equals(id);
+
+            }
+        }
+
+        return isa;
+    }
+
+    public abstract String[] getIds();
+
+    public abstract void registerMethod(String name, int id);
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/SecurityInfo.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/SecurityInfo.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/SecurityInfo.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,114 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop;
+
+import java.util.Random;
+
+import org.apache.geronimo.interop.util.BigEndian;
+import org.apache.geronimo.interop.util.UTF8;
+
+
+public class SecurityInfo {
+    // public data
+
+    public static final int TAG_USERNAME = BigEndian.getInt(new byte[]
+    {
+        (byte) 'U', (byte) 'S', (byte) 'E', (byte) 'R'
+    });
+
+    public static final int TAG_PASSWORD = BigEndian.getInt(new byte[]
+    {
+        (byte) 'P', (byte) 'A', (byte) 'S', (byte) 'S'
+    });
+
+    public static Random _seedFactory = new Random();
+
+    public String username;
+
+    public String password;
+
+    // private data
+
+    private static ThreadLocal _current = new ThreadLocal();
+
+    public static SecurityInfo getCurrent() {
+        return (SecurityInfo) _current.get();
+    }
+
+    public static void setCurrent(SecurityInfo info) {
+        _current.set(info);
+    }
+
+    // TODO: delegate to use DataProtection class
+
+    /**
+     * * Encode a username or password to prevent accidental disclosure
+     * * by packet sniffers etc. The intention is not to provide strong
+     * * encryption, SSL should be used for that.
+     * *
+     * * Note: this algorithm is not to be changed, or it will cause
+     * * version incompatibilites between client and server. See also
+     * * similar requirements in Random.java.
+     */
+    public static byte[] encode(String plainText) {
+        int seed = _seedFactory.nextInt(); // data race, but we don't care
+        Random random = new Random(seed);
+        byte[] utf8 = UTF8.fromString(plainText);
+        int n = utf8.length;
+        int pad = 0;
+        // Try to mask password length by padding to 4 byte boundaries.
+        while ((1 + n + pad) % 4 != 0) {
+            pad++;
+        }
+        byte[] data = new byte[6 + n + pad];
+        data[0] = (byte) 'E'; // Can be overwritten by caller after return.
+        BigEndian.setInt(data, 1, seed);
+        data[5] = (byte) (pad + random.nextInt());
+        for (int i = 0; i < n + pad; i++) {
+            if (i < n) {
+                data[6 + i] = (byte) (utf8[i] + random.nextInt());
+            } else {
+                data[6 + i] = (byte) random.nextInt(); // random padding.
+            }
+        }
+        return data;
+    }
+
+    /**
+     * * Inverse of encode.
+     */
+    public static String decode(byte[] data) {
+        int n = data.length - 6;
+        if (n < 0) {
+            throw new IllegalArgumentException("data.length = " + data.length);
+        }
+        int seed = BigEndian.getInt(data, 1);
+        Random random = new Random(seed);
+        int pad = ((data[5] - random.nextInt()) + 0x100) & 0xff;
+        if (pad < 0 || pad > 3) {
+            throw new IllegalArgumentException("pad = " + pad);
+        }
+        n -= pad;
+        byte[] utf8 = new byte[n];
+        for (int i = 0; i < n; i++) {
+            utf8[i] = (byte) (data[i + 6] - random.nextInt());
+        }
+        String plainText = UTF8.toString(utf8);
+        return plainText;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/SimpleObjectInputStream.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/SimpleObjectInputStream.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/SimpleObjectInputStream.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,84 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop;
+
+import java.io.IOException;
+
+import org.apache.geronimo.interop.SystemException;
+import org.apache.geronimo.interop.util.JavaObject;
+
+
+public class SimpleObjectInputStream extends ObjectInputStream {
+    public static ObjectInputStream getInstance() {
+        return getInstance(CdrInputStream.getInstance());
+    }
+
+    public static ObjectInputStream getInstance(byte[] bytes) {
+        return getInstance(CdrInputStream.getInstance(bytes));
+    }
+
+    public static ObjectInputStream getInstance(org.apache.geronimo.interop.rmi.iiop.CdrInputStream cdrInput) {
+        ObjectInputStream input = null;
+        try {
+            input = new SimpleObjectInputStream();
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+
+        input.init(cdrInput);
+        return input;
+    }
+
+    // -----------------------------------------------------------------------
+    // private data
+    // -----------------------------------------------------------------------
+
+    // -----------------------------------------------------------------------
+    // public methods
+    // -----------------------------------------------------------------------
+
+    public SimpleObjectInputStream() throws IOException {
+        super();
+    }
+
+    public void $reset() {
+        _cdrInput.reset();
+    }
+
+    public void recycle() {
+        $reset();
+    }
+
+    public Object readObject(ValueType type) {
+        ObjectHelper h = type.helper;
+        if (h != null) {
+            return h.read(this);
+        }
+        byte[] bytes = _cdrInput.read_octet_sequence();
+        Object value = bytes.length == 0 ? null : JavaObject.fromByteArray(bytes);
+        return value;
+    }
+
+    // -----------------------------------------------------------------------
+    // protected methods
+    // -----------------------------------------------------------------------
+
+    protected void init(org.apache.geronimo.interop.rmi.iiop.CdrInputStream cdrInput) {
+        super.init(cdrInput);
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/SimpleObjectOutputStream.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/SimpleObjectOutputStream.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/SimpleObjectOutputStream.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,82 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop;
+
+import java.io.IOException;
+
+import org.apache.geronimo.interop.SystemException;
+import org.apache.geronimo.interop.util.ArrayUtil;
+import org.apache.geronimo.interop.util.JavaObject;
+
+
+public class SimpleObjectOutputStream extends ObjectOutputStream {
+    public static ObjectOutputStream getInstance() {
+        return getInstance(CdrOutputStream.getInstance());
+    }
+
+    public static ObjectOutputStream getInstance(CdrOutputStream cdrOutput) {
+        ObjectOutputStream output = null;
+        try {
+            output = new SimpleObjectOutputStream();
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+
+        output.init(cdrOutput);
+        return output;
+    }
+
+    // -----------------------------------------------------------------------
+    // private data
+    // -----------------------------------------------------------------------
+
+    // -----------------------------------------------------------------------
+    // public methods
+    // -----------------------------------------------------------------------
+
+    public SimpleObjectOutputStream() throws IOException {
+        super();
+    }
+
+    public void $reset() {
+        _cdrOutput.reset();
+    }
+
+    public void recycle() {
+        $reset();
+    }
+
+    public void writeObject(ValueType type, Object value) {
+        ObjectHelper h = type.helper;
+        if (h != null) {
+            h.write(this, value);
+            return;
+        }
+        byte[] bytes = JavaObject.toByteArray(value);
+        if (bytes == null) bytes = ArrayUtil.EMPTY_BYTE_ARRAY;
+        _cdrOutput.write_octet_sequence(bytes);
+    }
+
+    // -----------------------------------------------------------------------
+    // protected methods
+    // -----------------------------------------------------------------------
+
+    protected void init(CdrOutputStream cdrOutput) {
+        super.init(cdrOutput);
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/StringHelper.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/StringHelper.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/StringHelper.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,30 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop;
+
+public class StringHelper implements ObjectHelper {
+    public static final StringHelper SINGLETON = new StringHelper();
+
+    public Object read(ObjectInputStream input) {
+        return input._cdrInput.read_string();
+    }
+
+    public void write(ObjectOutputStream output, Object value) {
+        output._cdrOutput.write_string((String) value);
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/StringValueHelper.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/StringValueHelper.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/StringValueHelper.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,30 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop;
+
+public class StringValueHelper implements ObjectHelper {
+    public static final StringValueHelper SINGLETON = new StringValueHelper();
+
+    public Object read(ObjectInputStream input) {
+        return input._cdrInput.read_string();
+    }
+
+    public void write(ObjectOutputStream output, Object value) {
+        output._cdrOutput.write_string((String) value);
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/SystemExceptionFactory.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/SystemExceptionFactory.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/SystemExceptionFactory.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,39 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop;
+
+import org.apache.geronimo.interop.SystemException;
+
+
+public abstract class SystemExceptionFactory {
+    public static RuntimeException getException(Exception ex) {
+        if (ex instanceof SystemException) {
+            Throwable cause = ((SystemException) ex).getCause();
+            if (cause instanceof org.omg.CORBA.SystemException) {
+                if (ex.getMessage() == null) {
+                    return (org.omg.CORBA.SystemException) cause;
+                }
+            }
+        }
+        if (ex instanceof RuntimeException) {
+            return (RuntimeException) ex;
+        } else {
+            return new RuntimeException(ex);
+        }
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/TypeCode.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/TypeCode.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/TypeCode.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,694 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop;
+
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+import org.omg.CORBA.TypeCodePackage.Bounds;
+
+
+/**
+ * * An implementation of CORBA 'TypeCode' for use with RMI-IIOP.
+ */
+public class TypeCode extends org.omg.CORBA.TypeCode {
+    // -----------------------------------------------------------------------
+    // public data
+    // -----------------------------------------------------------------------
+
+    public static final TypeCode NULL = new TypeCode(TCKind.tk_null);
+    public static final TypeCode VOID = new TypeCode(TCKind.tk_void);
+    public static final TypeCode ANY = new TypeCode(TCKind.tk_any);
+    public static final TypeCode BOOLEAN = new TypeCode(TCKind.tk_boolean);
+    public static final TypeCode CHAR = new TypeCode(TCKind.tk_char);
+    public static final TypeCode WCHAR = new TypeCode(TCKind.tk_wchar);
+    public static final TypeCode OCTET = new TypeCode(TCKind.tk_octet);
+    public static final TypeCode SHORT = new TypeCode(TCKind.tk_short);
+    public static final TypeCode USHORT = new TypeCode(TCKind.tk_ushort);
+    public static final TypeCode LONG = new TypeCode(TCKind.tk_long);
+    public static final TypeCode ULONG = new TypeCode(TCKind.tk_ulong);
+    public static final TypeCode LONGLONG = new TypeCode(TCKind.tk_longlong);
+    public static final TypeCode ULONGLONG = new TypeCode(TCKind.tk_ulonglong);
+    public static final TypeCode FLOAT = new TypeCode(TCKind.tk_float);
+    public static final TypeCode DOUBLE = new TypeCode(TCKind.tk_double);
+    public static final TypeCode LONGDOUBLE = new TypeCode(TCKind.tk_longdouble);
+    public static final TypeCode STRING = new TypeCode(TCKind.tk_string);
+    public static final TypeCode WSTRING = new TypeCode(TCKind.tk_wstring);
+    public static final TypeCode OBJREF = new TypeCode(TCKind.tk_objref);
+    public static final TypeCode TYPECODE = new TypeCode(TCKind.tk_TypeCode);
+
+    // -----------------------------------------------------------------------
+    // private data
+    // -----------------------------------------------------------------------
+
+    private TCKind _kind;
+
+    private String _name;
+
+    private String _type;
+
+    private String _id;
+
+    private String _label;
+
+    // content type, discriminator type, concrete base type,
+    // or other TypeCode for indirection.
+    private org.omg.CORBA.TypeCode _ref;
+
+    private String[] _member_name;
+
+    private org.omg.CORBA.TypeCode[] _member_type;
+
+    private org.omg.CORBA.Any[] _member_label;
+
+    private short[] _member_visibility;
+
+    private int _default;
+
+    private int _length;
+
+    private short _digits;
+
+    private short _scale;
+
+    private short _type_modifier;
+
+    private boolean _indirection;
+
+    // -----------------------------------------------------------------------
+    // public methods
+    // -----------------------------------------------------------------------
+    /**
+     * @param kind
+     */
+    public TypeCode(TCKind kind) {
+        _kind = kind;
+        _default = -1;
+        if (kind.value() == TCKind._tk_objref) {
+            _type = "Object";
+        }
+    }
+
+    /**
+     * @param tc
+     * @return
+     */
+    public boolean equal(org.omg.CORBA.TypeCode tc) {
+        if (_indirection) {
+            return _ref.equal(tc);
+        }
+        try {
+            int tk = _kind.value();
+            if (tk != tc.kind().value()) {
+                return false;
+            }
+            // TODO: compare id()
+            if (_member_name != null) {
+                int n = _member_name.length;
+                if (n != tc.member_count()) {
+                    return false;
+                }
+                for (int i = 0; i < n; i++) {
+                    if (!equalIfNotEmpty(member_name(i), tc.member_name(i))) {
+                        return false;
+                    }
+                    if (!member_type(i).equal(tc.member_type(i))) {
+                        return false;
+                    }
+                }
+            }
+            if (tk == TCKind._tk_union) {
+                if (!discriminator_type().equal(tc.discriminator_type())) {
+                    return false;
+                }
+                int n = _member_name.length;
+                for (int i = 0; i < n; i++) {
+                    if (!member_label(i).equal(tc.member_label(i))) {
+                        return false;
+                    }
+                }
+            }
+            if (tk == TCKind._tk_array
+                || tk == TCKind._tk_sequence
+                || tk == TCKind._tk_string
+                || tk == TCKind._tk_wstring) {
+                if (length() != tc.length()) {
+                    return false;
+                }
+            }
+            if (tk == TCKind._tk_alias
+                || tk == TCKind._tk_array
+                || tk == TCKind._tk_sequence) {
+                if (!content_type().equal(tc.content_type())) {
+                    return false;
+                }
+            }
+            return true;
+        } catch (org.omg.CORBA.TypeCodePackage.BadKind ex) {
+            throw new org.omg.CORBA.UNKNOWN(ex.toString());
+        } catch (org.omg.CORBA.TypeCodePackage.Bounds ex) {
+            throw new org.omg.CORBA.UNKNOWN(ex.toString());
+        }
+    }
+
+    /**
+     * @param tc
+     * @return
+     */
+    public boolean equivalent
+            (org.omg.CORBA.TypeCode tc) {
+        throw new org.omg.CORBA.NO_IMPLEMENT();
+    }
+
+    /**
+     * @return
+     */
+    public org.omg.CORBA.TypeCode get_compact_typecode() {
+        throw new org.omg.CORBA.NO_IMPLEMENT();
+    }
+
+    /**
+     * @param a
+     * @param b
+     * @return
+     */
+    private boolean equalIfNotEmpty(String a, String b) {
+        if (a.length() == 0 || b.length() == 0) {
+            return true;
+        } else {
+            return a.equals(b);
+        }
+    }
+
+    /**
+     * @return
+     */
+    public TCKind kind() {
+        if (_indirection) {
+            return _ref.kind();
+        }
+        return _kind;
+    }
+
+    /**
+     * @return
+     * @throws BadKind
+     */
+    public String id()
+            throws BadKind {
+        if (_indirection) {
+            return _ref.id();
+        }
+        if (_id != null) {
+            return _id;
+        }
+        if (_type != null && _type.equals("Object")) {
+            return "";
+        }
+        return default_id();
+    }
+
+    // Sybase-internal
+    /**
+     * @param id
+     */
+    public void id(String id) {
+        if (!id.equals("")) {
+            _id = id;
+            if (id.startsWith("IDL:") && id.endsWith(":1.0")) {
+                // Infer _type field from standard IDL format _id
+                id = id.substring(4, id.length() - 4);
+                if (id.startsWith("omg.org/")) {
+                    id = id.substring(8);
+                }
+                _type = "";
+                for (; ;) {
+                    int slash = id.indexOf('/');
+                    if (slash == -1) {
+                        break;
+                    }
+                    _type = _type + id.substring(0, slash) + "::";
+                    id = id.substring(slash + 1);
+                }
+                _type = _type + id;
+            }
+        }
+    }
+
+    /**
+     * @return
+     * @throws BadKind
+     */
+    public String name()
+            throws BadKind {
+        if (_indirection) {
+            return _ref.name();
+        }
+        /* TODO?
+        if (_name == null)
+        {
+            _name = (String)_names.get(new Integer(_kind.value()));
+        }
+        */
+        if (_name == null) {
+            throw new BadKind();
+        }
+        return _name;
+    }
+
+    // Sybase-internal
+    /**
+     * @param name
+     */
+    public void name(String name) {
+        _name = name;
+    }
+
+    /**
+     * @return
+     * @throws BadKind
+     */
+    public int member_count()
+            throws BadKind {
+        if (_indirection) {
+            return _ref.member_count();
+        }
+        if (_member_name == null) {
+            throw new BadKind();
+        }
+        return _member_name.length;
+    }
+
+    // Sybase-internal
+    /**
+     * @param count
+     */
+    public void member_count(int count) {
+        _member_name = new String[count];
+        _member_type = new org.omg.CORBA.TypeCode[count];
+        if (_kind.value() == TCKind._tk_union) {
+            _member_label = new org.omg.CORBA.Any[count];
+        }
+        if (_kind.value() == TCKind._tk_value) {
+            _member_visibility = new short[count];
+        }
+    }
+
+    /**
+     * @param index
+     * @return
+     * @throws BadKind
+     * @throws Bounds
+     */
+    public String member_name(int index)
+            throws BadKind, Bounds {
+        if (_indirection) {
+            return _ref.member_name(index);
+        }
+        if (_member_name == null) {
+            throw new BadKind();
+        }
+        if (index < 0 || index >= _member_name.length) {
+            throw new Bounds();
+        }
+        return _member_name[index];
+    }
+
+    // Sybase-internal
+    /**
+     * @param index
+     * @param name
+     */
+    public void member_name(int index, String name) {
+        _member_name[index] = name;
+    }
+
+    /**
+     * @param index
+     * @return
+     * @throws BadKind
+     * @throws Bounds
+     */
+    public org.omg.CORBA.TypeCode member_type(int index)
+            throws BadKind, Bounds {
+        if (_indirection) {
+            return _ref.member_type(index);
+        }
+        if (_member_type == null) {
+            throw new BadKind();
+        }
+        if (index < 0 || index >= _member_type.length) {
+            throw new Bounds();
+        }
+        return _member_type[index];
+    }
+
+    // Sybase-internal
+    /**
+     * @param index
+     * @param type
+     */
+    public void member_type(int index, org.omg.CORBA.TypeCode type) {
+        _member_type[index] = type;
+    }
+
+    /**
+     * @param index
+     * @return
+     * @throws BadKind
+     * @throws Bounds
+     */
+    public org.omg.CORBA.Any member_label(int index)
+            throws BadKind, Bounds {
+        if (_indirection) {
+            return _ref.member_label(index);
+        }
+        if (_member_label == null) {
+            throw new BadKind();
+        }
+        if (index < 0 || index >= _member_label.length) {
+            throw new Bounds();
+        }
+        return _member_label[index];
+    }
+
+    // Sybase-internal
+    /**
+     * @param index
+     * @param label
+     */
+    public void member_label(int index, org.omg.CORBA.Any label) {
+        _member_label[index] = label;
+    }
+
+    /**
+     * @return
+     * @throws BadKind
+     */
+    public org.omg.CORBA.TypeCode discriminator_type()
+            throws BadKind {
+        if (_indirection) {
+            return _ref.discriminator_type();
+        }
+        if (_ref == null
+            || _kind.value() != TCKind._tk_union) {
+            throw new BadKind();
+        }
+        return _ref;
+    }
+
+    // Sybase-internal
+    /**
+     * @param disc
+     */
+    public void discriminator_type(org.omg.CORBA.TypeCode disc) {
+        _ref = disc;
+    }
+
+    /**
+     * @return
+     * @throws BadKind
+     */
+    public int default_index()
+            throws BadKind {
+        if (_indirection) {
+            return _ref.default_index();
+        }
+        if (_kind.value() != TCKind._tk_union) {
+            throw new BadKind();
+        }
+        return _default;
+    }
+
+    // Sybase-internal
+    /**
+     * @param index
+     */
+    public void default_index(int index) {
+        _default = index;
+        if (index != -1) {
+            // We must store the member label for the discriminator type
+            // as some legal value, so we use zero.
+            _member_label[index] = new Any(_ref, "0");
+        }
+    }
+
+    /**
+     * @return
+     * @throws BadKind
+     */
+    public int length()
+            throws BadKind {
+        if (_indirection) {
+            return _ref.length();
+        }
+        int tk = _kind.value();
+        if (tk != TCKind._tk_string && tk != TCKind._tk_wstring
+            && tk != TCKind._tk_sequence && tk != TCKind._tk_array) {
+            throw new BadKind();
+        }
+        return _length;
+    }
+
+    // Sybase-internal
+    /**
+     * @param length
+     */
+    public void length(int length) {
+        _length = length;
+    }
+
+    /**
+     * @return
+     * @throws BadKind
+     */
+    public org.omg.CORBA.TypeCode content_type()
+            throws BadKind {
+        if (_indirection) {
+            return _ref.content_type();
+        }
+        int tk = _kind.value();
+        if (_ref == null
+            || (tk != TCKind._tk_alias
+                && tk != TCKind._tk_array
+                && tk != TCKind._tk_sequence
+                && tk != TCKind._tk_value_box)) {
+            throw new BadKind();
+        }
+        return _ref;
+    }
+
+    // Sybase-internal
+    /**
+     * @param type
+     */
+    public void content_type(org.omg.CORBA.TypeCode type) {
+        _ref = type;
+    }
+
+    /**
+     * @return
+     * @throws BadKind
+     */
+    public short fixed_digits()
+            throws BadKind {
+        if (_indirection) {
+            return _ref.fixed_digits();
+        }
+        int tk = _kind.value();
+        if (tk != TCKind._tk_fixed) {
+            throw new BadKind();
+        }
+        return _digits;
+    }
+
+    // Sybase-internal
+    /**
+     * @param digits
+     */
+    public void fixed_digits(short digits) {
+        _digits = digits;
+    }
+
+    /**
+     * @return
+     * @throws BadKind
+     */
+    public short fixed_scale()
+            throws BadKind {
+        if (_indirection) {
+            return _ref.fixed_scale();
+        }
+        int tk = _kind.value();
+        if (tk != TCKind._tk_fixed) {
+            throw new BadKind();
+        }
+        return _scale;
+    }
+
+    // Sybase-internal
+    /**
+     * @param scale
+     */
+    public void fixed_scale(short scale) {
+        _scale = scale;
+    }
+
+    /**
+     * @param index
+     * @return
+     * @throws BadKind
+     * @throws Bounds
+     */
+    public short member_visibility
+            (int index)
+            throws BadKind, Bounds {
+        if (_indirection) {
+            return _ref.member_visibility(index);
+        }
+        if (_member_type == null) {
+            throw new BadKind();
+        }
+        if (index < 0 || index >= _member_visibility.length) {
+            throw new Bounds();
+        }
+        return _member_visibility[index];
+    }
+
+    // Sybase-internal
+    /**
+     * @param index
+     * @param visibility
+     */
+    public void member_visibility(int index, short visibility) {
+        _member_visibility[index] = visibility;
+    }
+
+    /**
+     * @return
+     * @throws BadKind
+     */
+    public short type_modifier()
+            throws BadKind {
+        if (_indirection) {
+            return _ref.type_modifier();
+        }
+        int tk = _kind.value();
+        if (tk != TCKind._tk_value) {
+            throw new BadKind();
+        }
+        return _type_modifier;
+    }
+
+    // Sybase-internal
+    /**
+     * @param modifier
+     */
+    public void type_modifier(short modifier) {
+        _type_modifier = modifier;
+    }
+
+    /**
+     * @return
+     * @throws BadKind
+     */
+    public org.omg.CORBA.TypeCode concrete_base_type()
+            throws BadKind {
+        if (_indirection) {
+            return _ref.concrete_base_type();
+        }
+        int tk = _kind.value();
+        if (tk != TCKind._tk_value) {
+            throw new BadKind();
+        }
+        return _ref;
+    }
+
+    // Sybase-internal
+    /**
+     * @param base
+     */
+    public void concrete_base_type(org.omg.CORBA.TypeCode base) {
+        _ref = base;
+    }
+
+    // Sybase-internal
+    /**
+     * @param ref
+     */
+    public void indirection(org.omg.CORBA.TypeCode ref) {
+        _ref = ref;
+        _indirection = true;
+    }
+
+    // Sybase-internal
+    /**
+     * @param id
+     */
+    public void recursive(String id) {
+        _id = id;
+        _ref = null;
+        _indirection = true;
+    }
+
+    // Sybase-internal
+    /**
+     *
+     */
+    public void fix_recursive_members() {
+        String id = _id == null ? default_id() : _id;
+        int n = _member_type.length;
+        for (int i = 0; i < n; i++) {
+            TypeCode mt = (TypeCode) _member_type[i];
+            if (mt._kind.value() == TCKind._tk_sequence) {
+                TypeCode ct = (TypeCode) mt._ref;
+                if (ct._indirection
+                    && ct._ref == null
+                    && ct._id.equals(id)) {
+                    ct._ref = this;
+                }
+            }
+        }
+    }
+
+    // -----------------------------------------------------------------------
+    // private methods
+    // -----------------------------------------------------------------------
+    /**
+     * @return
+     */
+    private String default_id() {
+        // Take _type, and generate _id, e.g.
+        // if _type = "SessionManager::Manager",
+        // then _id = "IDL:SessionManager/Manager:1.0".
+        if (_type == null) {
+            return "";
+        }
+        StringBuffer id = new StringBuffer(_type.length() + 10);
+        id.append("IDL:");
+        int n = _type.length();
+        for (int i = 0; i < n; i++) {
+            char c = _type.charAt(i);
+            if (c == ':' && i + 1 < n && _type.charAt(i + 1) == ':') {
+                i++;
+            }
+            id.append(c == ':' ? '/' : c);
+        }
+        id.append(":1.0");
+        return id.toString();
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/UnsupportedProtocolVersionException.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/UnsupportedProtocolVersionException.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/UnsupportedProtocolVersionException.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,24 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop;
+
+public class UnsupportedProtocolVersionException extends RuntimeException {
+    public UnsupportedProtocolVersionException(String version) {
+        super(version);
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ValueType.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ValueType.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ValueType.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,674 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.ObjectStreamClass;
+import java.io.Serializable;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.security.DigestOutputStream;
+import java.security.MessageDigest;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+
+import org.omg.CORBA.TCKind;
+
+import org.apache.geronimo.interop.SystemException;
+import org.apache.geronimo.interop.util.ArrayUtil;
+import org.apache.geronimo.interop.util.ExceptionUtil;
+import org.apache.geronimo.interop.util.JavaClass;
+import org.apache.geronimo.interop.util.JavaType;
+import org.apache.geronimo.interop.util.SystemUtil;
+
+
+/**
+ * * A wrapper over java.lang.Class to help improve performance of using
+ * * the Java reflection API for valuetype marshalling. We keep as much
+ * * derived information as possible for optimal performance.
+ */
+public class ValueType {
+    public static ValueType getInstance(Class forClass) {
+        ValueType vt = (ValueType) _valueTypeMap.get(forClass);
+        if (vt == null) {
+            synchronized (_valueTypeMap) {
+                vt = (ValueType) _valueTypeMap.get(forClass);
+                if (vt == null) {
+                    vt = new ValueType();
+                    vt.init(forClass);
+                    _valueTypeMap.put(forClass, vt);
+                }
+            }
+        }
+        return vt;
+    }
+
+    public static ValueType getInstanceByID(String id) {
+        // TODO: handle multiple class loaders???
+        ValueType vt = (ValueType) _idTypeMap.get(id);
+        if (vt == null) {
+            synchronized (_idTypeMap) {
+                vt = (ValueType) _idTypeMap.get(id);
+                if (vt == null) {
+                    Class theClass = getClass(id);
+                    vt = getInstance(theClass);
+                    _idTypeMap.put(id, vt);
+                }
+            }
+        }
+        return vt;
+    }
+
+    // -----------------------------------------------------------------------
+    // public data
+    // -----------------------------------------------------------------------
+
+    public Class _class;
+
+    public org.apache.geronimo.interop.rmi.iiop.ObjectHelper helper;
+
+    // -----------------------------------------------------------------------
+    // private data
+    // -----------------------------------------------------------------------
+
+    private static HashMap _valueTypeMap = new HashMap();
+
+    private static HashMap _initMap = new HashMap();
+
+    private static HashMap _idTypeMap = new HashMap();
+
+    private static final boolean JDK14 = SystemUtil.isJDK14();
+
+    private static Method _allocateNewObject;
+
+    private static Object[] _allocateNewObjectArgs;
+
+    private static Method _newInstance;
+
+    private ObjectStreamClass _objectStreamClass;
+
+    private Method _readExternal;
+    private Method _readObject;
+    private Method _readResolve;
+    private Method _writeExternal;
+    private Method _writeObject;
+    private Method _writeReplace;
+
+    // -----------------------------------------------------------------------
+    // package-private data
+    // -----------------------------------------------------------------------
+
+    static final int NULL_VALUE_TAG = 0;
+    static final int NO_TYPE_VALUE_TAG = 0x7fffff00;
+    static final int SINGLE_TYPE_VALUE_TAG = 0x7fffff02;
+    static final int TRUNCATABLE_NO_TYPE_VALUE_TAG = 0x7fffff08;
+    static final int TRUNCATABLE_SINGLE_TYPE_VALUE_TAG = 0x7fffff0a;
+    static final int TYPE_LIST_VALUE_TAG = 0x7fffff06;
+    static final int INDIRECTION_TAG = 0xffffffff;
+
+    static final int CASE_ARRAY = 1;
+    static final int CASE_CLASS = 2;
+    static final int CASE_IDL_ENTITY = 3;
+    static final int CASE_IDL_OBJECT = 4;
+    static final int CASE_STRING = 5;
+
+    static final ValueType OBJECT_VALUE_TYPE = getInstance(Object.class);
+
+    static final ValueType STRING_VALUE_TYPE = getInstance(String.class);
+
+    static final org.omg.CORBA.TypeCode TC_NULL = new TypeCode(TCKind.tk_null);
+
+    static TypeCode TC_ABSTRACT_BASE;
+
+    String id; // CORBA Repository ID
+
+    TypeCode tc;
+
+    ValueType parent;
+
+    ValueTypeField[] fields; // just the serializable fields.
+
+    ValueType element; // if array, this is ValueType for elements.
+
+    boolean hasParentState;
+    boolean hasReadObject;
+    boolean hasReadOrWriteObject;
+    boolean hasWriteObject;
+    boolean hasReadResolve;
+    boolean hasWriteReplace;
+
+    boolean isAbstractInterface;
+    boolean isAny;
+    boolean isAnyOrObjectRefOrAbstractInterface;
+    boolean isArray;
+    boolean isExternalizable;
+    boolean isIDLEntity;
+    boolean isObjectRef;
+
+    int primitiveArray;
+
+    int readWriteCase;
+
+    boolean requiresCustomSerialization;
+
+    boolean skipCustomFlags; // TODO: init this
+
+    // -----------------------------------------------------------------------
+    // static initializer
+    // -----------------------------------------------------------------------
+
+    static {
+        TC_ABSTRACT_BASE = new TypeCode(TCKind.tk_abstract_interface);
+        TC_ABSTRACT_BASE.id("IDL:omg.org/CORBA/AbstractBase:1.0");
+        TC_ABSTRACT_BASE.name("");
+
+        try {
+            if (JDK14) {
+                _newInstance = java.io.ObjectStreamClass.class.getDeclaredMethod("newInstance", new Class[]{});
+                _newInstance.setAccessible(true);
+            } else {
+                _allocateNewObject = java.io.ObjectInputStream.class.getDeclaredMethod("allocateNewObject", new Class[]{Class.class, Class.class});
+                _allocateNewObject.setAccessible(true);
+            }
+        } catch (Exception ex) {
+            throw ExceptionUtil.getRuntimeException(ex);
+        }
+    }
+
+    // -----------------------------------------------------------------------
+    // public methods
+    // -----------------------------------------------------------------------
+
+    public Object newInstance() {
+        try {
+            if (JDK14) {
+                if (_class == Object.class) {
+                    return new Object();
+                } else {
+                    return _newInstance.invoke(_objectStreamClass, ArrayUtil.EMPTY_OBJECT_ARRAY);
+                }
+            } else {
+                return _allocateNewObject.invoke(null, _allocateNewObjectArgs);
+            }
+        } catch (Exception ex) {
+            throw ExceptionUtil.getRuntimeException(ex);
+        }
+    }
+
+    public String toString() {
+        return "ValueType:" + JavaType.getName(_class);
+    }
+
+    public void readObject(Object _this, org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input) {
+        try {
+            _readObject.invoke(_this, input.thisAsObjectArray);
+        } catch (Exception ex) {
+            throw ExceptionUtil.getRuntimeException(ex);
+        }
+    }
+
+    public void writeObject(Object _this, org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) {
+        try {
+            _writeObject.invoke(_this, output.thisAsObjectArray);
+        } catch (Exception ex) {
+            throw ExceptionUtil.getRuntimeException(ex);
+        }
+    }
+
+    public Object readResolve(Object _this) {
+        try {
+            return _readResolve.invoke(_this, ArrayUtil.EMPTY_OBJECT_ARRAY);
+        } catch (Exception ex) {
+            throw ExceptionUtil.getRuntimeException(ex);
+        }
+    }
+
+    public Object writeReplace(Object _this) {
+        try {
+            return _writeReplace.invoke(_this, ArrayUtil.EMPTY_OBJECT_ARRAY);
+        } catch (Exception ex) {
+            throw ExceptionUtil.getRuntimeException(ex);
+        }
+    }
+
+    public void readExternal(Object _this, org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input) {
+        try {
+            _readExternal.invoke(_this, input.thisAsObjectArray);
+        } catch (Exception ex) {
+            throw ExceptionUtil.getRuntimeException(ex);
+        }
+    }
+
+    public void writeExternal(Object _this, org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) {
+        try {
+            _writeExternal.invoke(_this, output.thisAsObjectArray);
+        } catch (Exception ex) {
+            throw ExceptionUtil.getRuntimeException(ex);
+        }
+    }
+
+    // -----------------------------------------------------------------------
+    // protected methods
+    // -----------------------------------------------------------------------
+
+    protected void init(Class theClass) {
+        boolean recursive = false;
+        if (_initMap.get(theClass) != null) {
+//              recursive = true;
+            return; // Already initializing (recursive 'init' call).
+        }
+        _initMap.put(theClass, Boolean.TRUE);
+        try {
+            _class = theClass;
+            _objectStreamClass = ObjectStreamClass.lookup(_class);
+            if (org.omg.CORBA.Object.class.isAssignableFrom(theClass)
+                || javax.ejb.EJBHome.class.isAssignableFrom(theClass)
+                || javax.ejb.EJBObject.class.isAssignableFrom(theClass)
+                || java.rmi.Remote.class.isAssignableFrom(theClass)) {
+                helper = ObjectRefHelper.getInstance(theClass);
+                isObjectRef = true;
+                readWriteCase = CASE_IDL_OBJECT;
+            } else if (org.omg.CORBA.portable.IDLEntity.class.isAssignableFrom(theClass)) {
+                helper = IDLEntityHelper.getInstance(theClass);
+                isIDLEntity = true;
+                readWriteCase = CASE_IDL_ENTITY;
+            } else if (theClass == String.class) {
+                helper = StringHelper.SINGLETON;
+                readWriteCase = CASE_STRING;
+            } else if (theClass.isArray()) {
+                Class elementClass = theClass.getComponentType();
+                element = getInstance(elementClass);
+                isArray = true;
+                if (elementClass.isPrimitive()) {
+                    primitiveArray = PrimitiveType.get(elementClass);
+                    helper = PrimitiveType.getArrayHelper(elementClass);
+                } else {
+                    helper = new ArrayHelper(elementClass);
+                }
+                readWriteCase = CASE_ARRAY;
+            } else if (theClass == Class.class) {
+                readWriteCase = CASE_CLASS;
+            }
+            if (_allocateNewObject != null) {
+                Class bc = _class;
+                while (Serializable.class.isAssignableFrom(bc) && (bc.getSuperclass() != null)) {
+                    bc = bc.getSuperclass();
+                }
+                _allocateNewObjectArgs = new Object[]{_class, bc};
+            }
+
+            isAny = _class == java.lang.Object.class
+                    || _class == java.io.Externalizable.class
+                    || _class == java.io.Serializable.class;
+
+            isExternalizable = java.io.Externalizable.class.isAssignableFrom(_class);
+            if (isExternalizable) {
+                _readExternal = _class.getDeclaredMethod("readExternal", new Class[]{ObjectInput.class});
+                _writeExternal = _class.getDeclaredMethod("writeExternal", new Class[]{ObjectOutput.class});
+            }
+
+            // SG: Hopefully we got all the info that is needed
+            if (recursive) {
+                return;
+            }
+
+
+            java.lang.Class tmpClass = _class;
+            ArrayList fieldList = new ArrayList();
+            Field[] javaFields = tmpClass.getDeclaredFields();
+    
+            // TODO: suppress sort for IDL-generated valuetypes
+            Arrays.sort(javaFields, FieldComparator.SINGLETON);
+    
+            // Create vector of non-static, non-transient fields.
+            // Ensure that all fields are readable/writable using reflection.
+            int nf = javaFields.length;
+            for (int f = 0; f < nf; f++) {
+                Field javaField = javaFields[f];
+                int modifiers = javaField.getModifiers();
+                if ((modifiers & (Modifier.STATIC | Modifier.TRANSIENT)) != 0) {
+                    continue;
+                }
+                if (!javaField.isAccessible()) {
+                    javaField.setAccessible(true);
+                }
+                ValueTypeField field = new ValueTypeField(javaField);
+                fieldList.add(field);
+            }
+
+            fields = (ValueTypeField[]) fieldList.toArray(new ValueTypeField[fieldList.size()]);
+
+            // Check methods for readObject/writeObject. Also check for
+            // abstract interfaces.
+            Method[] methods = _class.getDeclaredMethods();
+            int countThrowsRemoteException = 0;
+            int nm = methods.length;
+            for (int m = 0; m < nm; m++) {
+                Method method = methods[m];
+                Class[] types = method.getParameterTypes();
+                if (types.length == 1
+                    && types[0] == java.io.ObjectInputStream.class
+                    && (method.getModifiers() & Modifier.PRIVATE) != 0
+                    && method.getName().equals("readObject")) {
+                    _readObject = method;
+                    if (!_readObject.isAccessible()) {
+                        _readObject.setAccessible(true);
+                    }
+                }
+                if (types.length == 1
+                    && types[0] == java.io.ObjectOutputStream.class
+                    && (method.getModifiers() & Modifier.PRIVATE) != 0
+                    && method.getName().equals("writeObject")) {
+                    _writeObject = method;
+                    if (!_writeObject.isAccessible()) {
+                        _writeObject.setAccessible(true);
+                    }
+                }
+
+                if (types.length == 0
+                    && method.getReturnType() == java.lang.Object.class
+                    && method.getName().equals("writeReplace")) {
+                    _writeReplace = method;
+                    if (!_writeReplace.isAccessible()) {
+                        _writeReplace.setAccessible(true);
+                    }
+                }
+                if (types.length == 0
+                    && method.getReturnType() == java.lang.Object.class
+                    && method.getName().equals("readResolve")) {
+                    _readResolve = method;
+                    if (!_readResolve.isAccessible()) {
+                        _readResolve.setAccessible(true);
+                    }
+                }
+                Class[] exceptions = method.getExceptionTypes();
+                for (int i = 0; i < exceptions.length; i++) {
+                    Class exception = exceptions[i];
+                    if (exception.isAssignableFrom(java.rmi.RemoteException.class)) {
+                        // TODO: check Java to IDL wording for this
+                        countThrowsRemoteException++;
+                        break;
+                    }
+                }
+            }
+
+            hasReadOrWriteObject = _readObject != null || _writeObject != null;
+            hasReadObject = _readObject != null;
+            hasWriteObject = _writeObject != null;
+            hasWriteReplace = _writeReplace != null;
+            hasReadResolve = _readResolve != null;
+
+            isAbstractInterface = !isObjectRef
+                                  && _class.isInterface()
+                                  && countThrowsRemoteException == methods.length;
+
+            Class superclass = _class.getSuperclass();
+            if ((superclass != null) && (superclass != java.lang.Object.class) && (!isIDLEntity)) {
+                parent = getInstance(superclass);
+            }
+
+            hasParentState = parent != null
+                             && (parent.fields.length > 0
+                                 || parent.isExternalizable
+                                 || parent.hasReadOrWriteObject
+                                 || parent.hasParentState);
+
+            requiresCustomSerialization = hasWriteObject || isExternalizable;
+
+            initRepositoryID();
+            initTypeCode();
+
+            isAnyOrObjectRefOrAbstractInterface = isAny || isObjectRef || isAbstractInterface;
+        } catch (Exception ex) {
+            throw ExceptionUtil.getRuntimeException(ex);
+        } finally {
+            if (!recursive) {
+                _initMap.remove(theClass);
+            }
+        }
+    }
+
+    protected void initRepositoryID() {
+        final String sixteenZeros = "0000000000000000";
+        final int requiredLength = 16;
+        if (isAny) {
+            id = "#ANY-TODO#";
+            return;
+        }
+        if (isArray && primitiveArray != 0) {
+            id = "#ARRAY-TODO#";
+            return;
+        }
+        if (_class == String.class) {
+            id = "IDL:omg.org/CORBA/WStringValue:1.0";
+            return;
+        }
+        if (isObjectRef) {
+            id = "RMI:" + _class.getName() + ":" + sixteenZeros;
+            return;
+        }
+        if (_class == java.lang.Class.class) {
+            id = "RMI:javax.rmi.CORBA.ClassDesc:2BABDA04587ADCCC:CFBF02CF5294176B";
+            return;
+        }
+        if (_class == java.math.BigInteger.class) {
+            id = "RMI:java.math.BigInteger:8CAD1A3C6C0A9DF0:8CFC9F1FA93BFB1D";
+            skipCustomFlags = true; // TODO: move this and check usage
+            return;
+        }
+        if (_objectStreamClass == null) {
+            id = "???";
+            return;
+        }
+        long structuralUID = computeStructuralUID(this);
+        long serialVersionUID = _objectStreamClass.getSerialVersionUID();
+        String structuralUIDString = Long.toHexString(structuralUID).toUpperCase();
+        String serialVersionUIDString = Long.toHexString(serialVersionUID).toUpperCase();
+        int currentLength;
+        int lengthNeeded;
+        currentLength = structuralUIDString.length();
+        if (currentLength < requiredLength) {
+            lengthNeeded = requiredLength - currentLength;
+            structuralUIDString = sixteenZeros.substring(0, lengthNeeded) + structuralUIDString;
+        }
+        currentLength = serialVersionUIDString.length();
+        if (currentLength < requiredLength) {
+            lengthNeeded = requiredLength - currentLength;
+            serialVersionUIDString = sixteenZeros.substring(0, lengthNeeded) + serialVersionUIDString;
+        }
+        id = "RMI:" + _class.getName() + ":" + structuralUIDString + ":" + serialVersionUIDString;
+    }
+
+    protected void initTypeCode() {
+        if (isObjectRef) {
+            tc = new TypeCode(TCKind.tk_objref);
+            tc.id(id);
+            tc.name("");
+        } else if (isArray || isIDLEntity || _class == String.class) {
+            tc = new TypeCode(TCKind.tk_value_box);
+            tc.id(id);
+            tc.name("");
+            if (_class == String.class) {
+                tc.content_type(new TypeCode(TCKind.tk_wstring));
+            } else if (isArray) {
+                TypeCode seqTC = new TypeCode(TCKind.tk_sequence);
+                if (primitiveArray != 0) {
+                    seqTC.content_type(PrimitiveType.getTypeCode(primitiveArray));
+                } else {
+                    seqTC.content_type(element.tc);
+                }
+                tc.content_type(seqTC);
+            } else if (isIDLEntity) {
+                // TODO tc.content_type(helper.type());
+            }
+        } else {
+            tc = new TypeCode(TCKind.tk_value);
+            tc.id(id);
+            tc.name("");
+
+            // TODO: value modifier
+            if (requiresCustomSerialization) {
+                tc.type_modifier((short) 1);
+            } else if (isAbstractInterface) {
+                tc.type_modifier((short) 2);
+            } else {
+                tc.type_modifier((short) 0);
+            }
+            if (parent == null) {
+                tc.concrete_base_type(TC_NULL);
+            } else {
+                // TODO: check validity of this
+                tc.concrete_base_type(TC_NULL);
+                // tc.concrete_base_type(getTypeCode(parent));
+            }
+            // TODO: member fields
+            tc.member_count(0);
+        }
+    }
+
+    static long computeStructuralUID(ValueType vt) {
+        Class c = vt._class;
+        ObjectStreamClass osc = vt._objectStreamClass;
+        ByteArrayOutputStream devnull = new ByteArrayOutputStream(512);
+        long h = 0;
+        try {
+            if (!java.io.Serializable.class.isAssignableFrom(c)
+                || c.isInterface()) {
+                return 0;
+            }
+            if (java.io.Externalizable.class.isAssignableFrom(c)) {
+                return 1;
+            }
+            MessageDigest md = MessageDigest.getInstance("SHA");
+            DigestOutputStream mdo = new DigestOutputStream(devnull, md);
+            DataOutputStream data = new DataOutputStream(mdo);
+            if (vt.parent != null) {
+                data.writeLong(computeStructuralUID(vt.parent));
+            }
+            if (vt.hasWriteObject) {
+                data.writeInt(2);
+            } else {
+                data.writeInt(1);
+            }
+            List fieldList = new ArrayList(vt.fields.length);
+            for (int i = 0; i < vt.fields.length; i++) {
+                fieldList.add(vt.fields[i].javaField);
+            }
+            Field[] fields = (Field[]) fieldList.toArray(new Field[fieldList.size()]);
+            Arrays.sort(fields, FieldByNameComparator.SINGLETON);
+            for (int i = 0; i < vt.fields.length; i++) {
+                Field f = fields[i];
+                data.writeUTF(f.getName());
+                data.writeUTF(JavaClass.getSignature(f.getType()));
+            }
+            data.flush();
+            byte[] hasharray = md.digest();
+            for (int i = 0; i < Math.min(8, hasharray.length); i++) {
+                h += (long) (hasharray[i] & 255) << (i * 8);
+            }
+            return h;
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+    }
+
+    /**
+     * * Map an RMI/IDL Repository ID to a java.lang.Class.
+     */
+    static Class getClass(String id) {
+        if (id.startsWith("RMI:")) {
+            int endClass = id.indexOf(':', 4);
+            if (endClass == -1) {
+                throw new org.omg.CORBA.INV_IDENT(id);
+            }
+            String className = id.substring(4, endClass);
+            if (className.equals("javax.rmi.CORBA.ClassDesc")) {
+                return Class.class;
+            } else {
+                return loadClass(className);
+            }
+        } else if (id.equals("IDL:omg.org/CORBA/WStringValue:1.0")) {
+            return java.lang.String.class;
+        } else if (id.startsWith("IDL:omg.org/")) {
+            int endClass = id.indexOf(':', 12);
+            if (endClass == -1) {
+                throw new org.omg.CORBA.INV_IDENT(id);
+            }
+            String className = "org.omg" + id.substring("IDL:omg.org".length(), endClass).replace('/', '.');
+            return loadClass(className);
+        } else if (id.startsWith("IDL:")) {
+            int endClass = id.indexOf(':', 4);
+            if (endClass == -1) {
+                throw new org.omg.CORBA.INV_IDENT(id);
+            }
+            String className = id.substring(4, endClass).replace('/', '.');
+            return loadClass(className);
+        } else {
+            throw new org.omg.CORBA.INV_IDENT(id);
+        }
+    }
+
+    static Class loadClass(String className) {
+        Class c = null;
+
+        System.out.println("loadClass(): " + className);
+
+        try {
+            //c = Class.forName( className );
+            c = ClassLoader.getSystemClassLoader().loadClass(className);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        //return ThreadContext.loadClass(className);
+        return c;
+    }
+
+    public static void main(String args[])
+            throws Exception {
+        Class c = Class.forName(args[0]);
+        ValueType vt = ValueType.getInstance(c);
+        System.out.println("vt = " + vt.toString());
+        System.out.println("vt.id = " + vt.id);
+        System.out.println("vt.tc = " + vt.tc.id());
+
+        c = Class.forName("org.omg.CosNaming.NameComponent");
+        vt = ValueType.getInstance(c);
+        System.out.println("vt = " + vt.toString());
+        System.out.println("vt.id = " + vt.id);
+        System.out.println("vt.tc = " + vt.tc.id());
+
+        c = ValueType.getClass("RMI:mark.comps.Add:0000000000000000");
+        System.out.println("c.getName() = " + c.getName());
+
+        c = ValueType.getClass("RMI:org.omg.CosNaming.NameComponent:7FD3FB2290230F5E:F164A2194A66282A");
+        System.out.println("c.getName() = " + c.getName());
+
+        c = ValueType.getClass("IDL:omg.org/CosNaming/NameComponent:1.0");
+        System.out.println("c.getName() = " + c.getName());
+
+        c = ValueType.getClass("RMI:mark.AddData:4165959D0B2418DD:747FE23938318E95");
+        System.out.println("c.getName() = " + c.getName());
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ValueTypeField.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ValueTypeField.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ValueTypeField.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,186 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop;
+
+import java.lang.reflect.Field;
+
+import org.apache.geronimo.interop.SystemException;
+
+
+public class ValueTypeField {
+    public final Field javaField;
+
+    public final int primitive;
+
+    public final ValueType type;
+
+    public ValueTypeField(Field field) {
+        javaField = field;
+        if (field.getType().isPrimitive()) {
+            primitive = PrimitiveType.get(field.getType());
+            type = null;
+        } else {
+            primitive = 0;
+            type = ValueType.getInstance(field.getType());
+        }
+    }
+
+    public boolean getBoolean(Object that) {
+        try {
+            return javaField.getBoolean(that);
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+    }
+
+    public byte getByte(Object that) {
+        try {
+            return javaField.getByte(that);
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+    }
+
+    public char getChar(Object that) {
+        try {
+            return javaField.getChar(that);
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+    }
+
+    public double getDouble(Object that) {
+        try {
+            return javaField.getDouble(that);
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+    }
+
+    public float getFloat(Object that) {
+        try {
+            return javaField.getFloat(that);
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+    }
+
+    public int getInt(Object that) {
+        try {
+            return javaField.getInt(that);
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+    }
+
+    public long getLong(Object that) {
+        try {
+            return javaField.getLong(that);
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+    }
+
+    public short getShort(Object that) {
+        try {
+            return javaField.getShort(that);
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+    }
+
+    public Object get(Object that) {
+        try {
+            return javaField.get(that);
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+    }
+
+    public void setBoolean(Object that, boolean value) {
+        try {
+            javaField.setBoolean(that, value);
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+    }
+
+    public void setByte(Object that, byte value) {
+        try {
+            javaField.setByte(that, value);
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+    }
+
+    public void setChar(Object that, char value) {
+        try {
+            javaField.setChar(that, value);
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+    }
+
+    public void setDouble(Object that, double value) {
+        try {
+            javaField.setDouble(that, value);
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+    }
+
+    public void setFloat(Object that, float value) {
+        try {
+            javaField.setFloat(that, value);
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+    }
+
+    public void setInt(Object that, int value) {
+        try {
+            javaField.setInt(that, value);
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+    }
+
+    public void setLong(Object that, long value) {
+        try {
+            javaField.setLong(that, value);
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+    }
+
+    public void setShort(Object that, short value) {
+        try {
+            javaField.setShort(that, value);
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+    }
+
+    public void set(Object that, Object value) {
+        try {
+            javaField.set(that, value);
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/client/ClientNamingContext.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/client/ClientNamingContext.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/client/ClientNamingContext.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,388 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop.client;
+
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Random;
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NameNotFoundException;
+import javax.naming.NameParser;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.OperationNotSupportedException;
+
+import org.apache.geronimo.interop.properties.IntProperty;
+import org.apache.geronimo.interop.properties.PropertyMap;
+import org.apache.geronimo.interop.properties.StringProperty;
+import org.apache.geronimo.interop.properties.SystemProperties;
+import org.apache.geronimo.interop.rmi.iiop.ObjectRef;
+import org.apache.geronimo.interop.rmi.iiop.compiler.StubFactory;
+import org.apache.geronimo.interop.util.ExceptionUtil;
+
+
+public class ClientNamingContext implements Context, java.io.Serializable {
+    public static ClientNamingContext getInstance(Hashtable env) {
+        ClientNamingContext nc = (ClientNamingContext) _contextMap.get(env);
+        if (nc == null) {
+            synchronized (_contextMap) {
+                nc = (ClientNamingContext) _contextMap.get(env);
+                if (nc == null) {
+                    nc = new ClientNamingContext();
+                    nc.init(env);
+                    _contextMap.put(env, nc);
+                }
+            }
+        }
+        return nc;
+    }
+
+    // -----------------------------------------------------------------------
+    // properties
+    // -----------------------------------------------------------------------
+
+    public static final StringProperty usernameProperty =
+            new StringProperty(SystemProperties.class, "java.naming.security.principal");
+
+    public static final StringProperty passwordProperty =
+            new StringProperty(SystemProperties.class, "java.naming.security.credentials");
+
+    public static final IntProperty idleConnectionTimeoutProperty =
+            new IntProperty(SystemProperties.class, "org.apache.geronimo.interop.rmi.idleConnectionTimeout")
+            .defaultValue(60); // seconds
+
+    // -----------------------------------------------------------------------
+    // private data
+    // -----------------------------------------------------------------------
+
+    private static int _idleConnectionTimeout =
+            idleConnectionTimeoutProperty.getInt();
+
+    private static int _namingContextCacheTimeout =
+            SystemProperties.rmiNamingContextCacheTimeoutProperty.getInt();
+
+    private static HashMap _contextMap = new HashMap();
+
+    private static HashMap _hostListCache = new HashMap();
+
+    private static HashMap _multiHostMap = new HashMap();
+
+    private static Random _random = new Random();
+
+    private HashMap _cache = new HashMap();
+
+    private Hashtable _env;
+
+    private ConnectionPool _connectionPool;
+
+    private PropertyMap _connectionProperties;
+
+    private org.apache.geronimo.interop.CosNaming.NamingContext _serverNamingContext;
+    static private HashMap _nameMap = new HashMap();
+
+
+    private String _prefix;
+
+    private String _username;
+
+    private String _password;
+
+    // -----------------------------------------------------------------------
+    // public methods
+    // -----------------------------------------------------------------------
+
+    public ConnectionPool getConnectionPool() {
+        return _connectionPool;
+    }
+
+    public PropertyMap getConnectionProperties() {
+        return _connectionProperties;
+    }
+
+    public int getIdleConnectionTimeout() {
+        return _idleConnectionTimeout;
+    }
+
+    public String getUsername() {
+        return _username;
+    }
+
+    public String getPassword() {
+        return _password;
+    }
+
+    // -----------------------------------------------------------------------
+    // public methods from interface javax.naming.Context
+    // -----------------------------------------------------------------------
+
+    public Object lookup(Name name) throws NamingException {
+        return lookup(name.toString());
+    }
+
+    public Object lookup(String name) throws NamingException {
+        if (name.startsWith("java:comp/env/")) {
+            name = name.substring(14);
+        }
+
+        String newName = (String) _nameMap.get(name);
+        if (newName != null) {
+            name = newName;
+        }
+
+        NameBinding nb = (NameBinding) _cache.get(name);
+        if (nb == null) {
+            synchronized (_cache) {
+                nb = (NameBinding) _cache.get(name);
+                if (nb != null && nb.hasExpired()) {
+                    _cache.remove(name);
+                    nb = null;
+                }
+                if (nb == null) {
+                    nb = resolve(name);
+                    _cache.put(name, nb);
+                }
+            }
+        }
+        return nb.object;
+    }
+
+    public HostList lookupHost(String name) {
+        NameBinding nb = (NameBinding) _hostListCache.get(name);
+        if (nb == null) {
+            synchronized (_hostListCache) {
+                nb = (NameBinding) _hostListCache.get(name);
+                if (nb != null && nb.hasExpired()) {
+                    _hostListCache.remove(name);
+                    nb = null;
+                }
+                if (nb == null) {
+                    nb = resolve_host(name);
+                    _hostListCache.put(name, nb);
+                }
+            }
+        }
+        return (HostList) nb.object;
+    }
+
+    public static void bind(String bindName, String name) throws NamingException {
+        _nameMap.put(bindName, name);
+    }
+
+    public void bind(Name name, Object obj) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public void bind(String name, Object obj) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public void rebind(Name name, Object obj) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public void rebind(String name, Object obj) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public void unbind(Name name) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public void unbind(String name) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public void rename(Name oldName, Name newName) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public void rename(String oldName, String newName) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public NamingEnumeration list(Name name) throws NamingException {
+        // TODO: support this
+        throw new OperationNotSupportedException();
+    }
+
+    public NamingEnumeration list(String name) throws NamingException {
+        // TODO: support this
+        throw new OperationNotSupportedException();
+    }
+
+    public NamingEnumeration listBindings(Name name) throws NamingException {
+        // TODO: support this
+        throw new OperationNotSupportedException();
+    }
+
+    public NamingEnumeration listBindings(String name) throws NamingException {
+        // TODO: support this
+        throw new OperationNotSupportedException();
+    }
+
+    public void destroySubcontext(Name name) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public void destroySubcontext(String name) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public Context createSubcontext(Name name) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public Context createSubcontext(String name) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public Object lookupLink(Name name) throws NamingException {
+        // TODO: support this
+        throw new OperationNotSupportedException();
+    }
+
+    public Object lookupLink(String name) throws NamingException {
+        // TODO: support this
+        throw new OperationNotSupportedException();
+    }
+
+    public NameParser getNameParser(Name name) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public NameParser getNameParser(String name) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public Name composeName(Name name, Name prefix) throws NamingException {
+        // TODO: support this
+        throw new OperationNotSupportedException();
+    }
+
+    public String composeName(String name, String prefix) throws NamingException {
+        // TODO: support this
+        throw new OperationNotSupportedException();
+    }
+
+    public Object addToEnvironment(String propName, Object propVal) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public Object removeFromEnvironment(String propName) throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public Hashtable getEnvironment() throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public String getNameInNamespace() throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    public void close() throws NamingException {
+        throw new OperationNotSupportedException();
+    }
+
+    // -----------------------------------------------------------------------
+    // protected methods
+    // -----------------------------------------------------------------------
+
+    protected void init(Hashtable env) {
+        _env = env;
+        Object urlObject = env.get(Context.PROVIDER_URL);
+        if (urlObject == null) {
+            System.out.println("ClientNamingContext.init(): TODO: urlObject was null, create one based on the current hostname.");
+            urlObject = SystemProperties.getInstance().getProperty("java.naming.provider.url",
+                                                                   "iiop://" + "delafran-t30" + ":2000");
+        }
+        String url = urlObject.toString();
+        UrlInfo urlInfo = UrlInfo.getInstance(url);
+        _serverNamingContext = (org.apache.geronimo.interop.CosNaming.NamingContext)
+                StubFactory.getInstance().getStub(org.apache.geronimo.interop.CosNaming.NamingContext.class);
+        ObjectRef ncRef = (ObjectRef) _serverNamingContext;
+        ncRef.$setNamingContext(this);
+        ncRef.$setProtocol(urlInfo.getProtocol());
+        ncRef.$setHost("ns~" + urlInfo.getHost());
+        ncRef.$setPort(urlInfo.getPort());
+        ncRef.$setObjectKey(urlInfo.getObjectKey());
+        _connectionProperties = urlInfo.getProperties();
+        _connectionPool = ConnectionPool.getInstance(this);
+        Object u = env.get(Context.SECURITY_PRINCIPAL);
+        Object p = env.get(Context.SECURITY_CREDENTIALS);
+        if (u == null) {
+            u = usernameProperty.getString();
+        }
+        if (p == null) {
+            p = passwordProperty.getString();
+        }
+        _username = u != null ? u.toString() : null;
+        _password = p != null ? p.toString() : null;
+
+        /*
+        if (_serverNamingContext._is_a("IDL:org.apache.geronimo.interop/rmi/iiop/NameService:1.0"))
+        {
+            _serverNamingContext = (org.apache.geronimo.interop.rmi.iiop.NameService)
+                StubFactory.getInstance().getStub(org.apache.geronimo.interop.rmi.iiop.NameService.class);
+            ncRef = (ObjectRef)_serverNamingContext;
+            ncRef.$setNamingContext(this);
+            ncRef.$setProtocol(urlInfo.getProtocol());
+            ncRef.$setHost("ns~" + urlInfo.getHost());
+            ncRef.$setPort(urlInfo.getPort());
+            ncRef.$setObjectKey(urlInfo.getObjectKey());
+        }
+        */
+    }
+
+    protected NameBinding resolve(String name) throws NamingException {
+        Object value = org.apache.geronimo.interop.naming.NameService.getInitialContext().lookupReturnNullIfNotFound(name);
+        if (value != null) {
+            NameBinding nb = new NameBinding();
+            nb.object = value;
+            nb.cacheTimeout = System.currentTimeMillis() + _namingContextCacheTimeout;
+            return nb;
+        }
+        try {
+            org.apache.geronimo.interop.CosNaming.NameComponent[] resolveName =
+                    {new org.apache.geronimo.interop.CosNaming.NameComponent(name, "")};
+            org.omg.CORBA.Object object = _serverNamingContext.resolve(resolveName);
+            NameBinding nb = new NameBinding();
+            nb.object = object;
+            nb.cacheTimeout = System.currentTimeMillis() + _namingContextCacheTimeout;
+            return nb;
+        } catch (org.apache.geronimo.interop.CosNaming.NamingContextPackage.NotFound notFound) {
+            throw new NameNotFoundException(name);
+        } catch (Exception ex) {
+            throw new javax.naming.NamingException(ExceptionUtil.getStackTrace(ex));
+        }
+    }
+
+    protected NameBinding resolve_host(String host) {
+        HostList list = null;
+        if (_serverNamingContext instanceof org.apache.geronimo.interop.rmi.iiop.NameService) {
+            org.apache.geronimo.interop.rmi.iiop.NameService nameService = (org.apache.geronimo.interop.rmi.iiop.NameService) _serverNamingContext;
+            list = new HostList(nameService.resolve_host(host));
+        }
+        NameBinding nb = new NameBinding();
+        nb.object = list;
+        //nb.cacheTimeout = System.currentTimeMillis()
+        //   + (list != null ? list.getCacheTimeout() : _namingContextCacheTimeout);
+        return nb;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/client/Connection.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/client/Connection.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/client/Connection.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,461 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop.client;
+
+import java.net.Socket;
+
+import org.apache.geronimo.interop.GIOP.*;
+import org.apache.geronimo.interop.IOP.*;
+import org.apache.geronimo.interop.SystemException;
+import org.apache.geronimo.interop.properties.BooleanProperty;
+import org.apache.geronimo.interop.properties.IntProperty;
+import org.apache.geronimo.interop.properties.PropertyMap;
+import org.apache.geronimo.interop.properties.SystemProperties;
+import org.apache.geronimo.interop.rmi.iiop.BadMagicException;
+import org.apache.geronimo.interop.rmi.iiop.CdrInputStream;
+import org.apache.geronimo.interop.rmi.iiop.CdrOutputStream;
+import org.apache.geronimo.interop.rmi.iiop.GiopMessage;
+import org.apache.geronimo.interop.rmi.iiop.ObjectRef;
+import org.apache.geronimo.interop.rmi.iiop.SecurityInfo;
+import org.apache.geronimo.interop.rmi.iiop.UnsupportedProtocolVersionException;
+import org.apache.geronimo.interop.util.ExceptionUtil;
+import org.apache.geronimo.interop.util.InstancePool;
+import org.apache.geronimo.interop.util.StringUtil;
+import org.apache.geronimo.interop.util.ThreadContext;
+import org.apache.geronimo.interop.util.UTF8;
+
+
+public class Connection {
+    public Connection() {
+    }
+
+    public static Connection getInstance(String endpoint, ObjectRef objectRef, PropertyMap connProps) {
+        Connection conn = new Connection();
+        conn.init(endpoint, objectRef, connProps);
+        return conn;
+    }
+
+    // -----------------------------------------------------------------------
+    // properties
+    // -----------------------------------------------------------------------
+
+    public static final BooleanProperty simpleIDLProperty =
+            new BooleanProperty(SystemProperties.class, "org.apache.geronimo.interop.simpleIDL");
+
+    public static final IntProperty socketTimeoutProperty =
+            new IntProperty(Connection.class, "socketTimeout")
+            .defaultValue(SystemProperties.rmiSocketTimeoutProperty.getInt());
+
+    // -----------------------------------------------------------------------
+    // private data
+    // -----------------------------------------------------------------------
+
+    private static final boolean SIMPLE_IDL = simpleIDLProperty.getBoolean();
+
+    private ServiceContext[] EMPTY_SERVICE_CONTEXT = {};
+
+    private String _url;
+
+    private boolean _ok;
+
+    private InstancePool _pool;
+
+    private String _serverHost;
+
+    private Socket _socket;
+
+    private org.apache.geronimo.interop.rmi.iiop.ObjectInputStream _input;
+
+    private org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream _output;
+
+    private CdrOutputStream _parameters;
+
+    private CdrOutputStream _requestOut;
+
+    private CdrInputStream _results;
+
+    private String _exceptionType;
+
+    private Exception _exception;
+
+    private RequestHeader_1_2 _requestHeader;
+
+    private int _callForget;
+
+    // -----------------------------------------------------------------------
+    // protected data
+    // -----------------------------------------------------------------------
+
+    protected java.io.InputStream _socketIn;
+
+    protected java.io.OutputStream _socketOut;
+
+    // -----------------------------------------------------------------------
+    // public methods
+    // -----------------------------------------------------------------------
+
+    public String getInstanceName() {
+        return _url;
+    }
+
+    public void close() {
+        _parameters = null;
+//        _results.recycle();
+//        _results = null;
+        _input = null;
+        _output = null;
+        if (_ok) {
+            _pool.put(this);
+        } else {
+            shutdown();
+        }
+    }
+
+    public void beforeInvoke() {
+        _ok = false;
+        _parameters = CdrOutputStream.getInstance();
+    }
+
+    public void forget(Object requestKey) {
+        if (_callForget != 0) {
+            /*
+            String key = (String)requestKey;
+            try
+            {
+                ClusterService cs = _results.getNamingContext().getClusterService();
+                if (_callForget == 0xCFCFCFCF)
+                {
+                    cs.forgetRequest(key);
+                }
+                else if (_callForget == 0xDFDFDFDF)
+                {
+                    cs.forgetResponse(key);
+                }
+            }
+            catch (Exception ignore)
+            {
+                // TODO: log in debug mode?
+            }
+            */
+        }
+    }
+
+    public void invoke(ObjectRef object, String method, Object requestKey, int retryCount) {
+        _callForget = 0; // see 'forget' and 'processReplyServiceContext'
+
+        RequestHeader_1_2 request = _requestHeader;
+
+        request.request_id = 0;
+        request.response_flags = 3;
+        request.target = new TargetAddress();
+        request.target.object_key(object.$getObjectKey());
+        request.operation = method;
+        request.service_context = getServiceContext(object, requestKey, retryCount);
+
+        request.reserved = new byte[3];  // Sun's generated org.omg.GIOP.RequestHeader_1_2Helper wants this....
+
+        if (_requestOut == null) {
+            _requestOut = CdrOutputStream.getInstance();
+        }
+        _requestOut.write_request(request, _parameters);
+
+        try {
+            _requestOut.send_message(_socketOut, _url);//_serverHost);
+        } catch (RuntimeException ex) {
+            //if (object.$getAutomaticFailover())
+            //{
+            //    throw new RetryInvokeException(ex);
+            //}
+            throw ex;
+        }
+
+        _requestOut.reset();
+
+        if (_results == null) {
+            _results = CdrInputStream.getInstance();
+        } else {
+            _results.reset();
+        }
+
+        _results.setNamingContext(object.$getNamingContext());
+        GiopMessage message;
+        try {
+            message = _results.receive_message(_socketIn, _url);//_serverHost);
+        } catch (BadMagicException ex) {
+            throw new SystemException(ex);
+        } catch (UnsupportedProtocolVersionException ex) {
+            throw new SystemException(ex);
+        } catch (RuntimeException ex) {
+            throw new RetryInvokeException(ex);
+        }
+
+        switch (message.type) {
+            case MsgType_1_1._Reply:
+                processReply(message.reply);
+                break;
+
+            default:
+                throw new SystemException("TODO: message type = " + message.type);
+        }
+
+        _ok = true;
+    }
+
+    public InstancePool getInstancePool() {
+        return _pool;
+    }
+
+    public void setInstancePool(InstancePool pool) {
+        _pool = pool;
+    }
+
+    public org.apache.geronimo.interop.rmi.iiop.ObjectInputStream getInputStream() {
+        if (SIMPLE_IDL) {
+            return getSimpleInputStream();
+        }
+        if (_input == null) {
+            _input = org.apache.geronimo.interop.rmi.iiop.ObjectInputStream.getInstance(_results);
+        }
+        return _input;
+    }
+
+    public org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream getOutputStream() {
+        if (SIMPLE_IDL) {
+            return getSimpleOutputStream();
+        }
+        if (_output == null) {
+            _output = org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream.getInstance(_parameters);
+        }
+        return _output;
+    }
+
+    public org.apache.geronimo.interop.rmi.iiop.ObjectInputStream getSimpleInputStream() {
+        if (_input == null) {
+            _input = org.apache.geronimo.interop.rmi.iiop.SimpleObjectInputStream.getInstance(_results);
+        }
+        return _input;
+    }
+
+    public org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream getSimpleOutputStream() {
+        if (_output == null) {
+            _output = org.apache.geronimo.interop.rmi.iiop.SimpleObjectOutputStream.getInstance(_parameters);
+        }
+        return _output;
+    }
+
+    public String getExceptionType() {
+        return _exceptionType;
+    }
+
+    public Exception getException() {
+        if (_exception == null) {
+            if (_exceptionType != null) {
+                return new SystemException(_exceptionType, new org.omg.CORBA.UNKNOWN());
+            } else {
+                throw new IllegalStateException("no exception");
+            }
+        } else {
+            return _exception;
+        }
+    }
+
+    // -----------------------------------------------------------------------
+    // protected methods
+    // -----------------------------------------------------------------------
+
+    // TODO: check why we have 'objectRef' parameter???
+    protected void init(String endpoint, ObjectRef objectRef, PropertyMap connProps) {
+        _url = "iiop://" + endpoint;
+        UrlInfo urlInfo = UrlInfo.getInstance(_url);
+        String host = urlInfo.getHost();
+        int port = urlInfo.getPort();
+        int socketTimeout = socketTimeoutProperty.getInt(endpoint, connProps);
+        try {
+            _socket = new Socket(host, port);
+            _socketIn = _socket.getInputStream();
+            _socketOut = _socket.getOutputStream();
+            _socket.setSoTimeout(1000 * socketTimeout);
+            _serverHost = host;
+        } catch (Exception ex) {
+            throw new SystemException(errorConnectFailed(host, port, ex));
+        }
+        _requestHeader = new RequestHeader_1_2();
+    }
+
+    public ServiceContext[] getServiceContext(ObjectRef object, Object requestKey, int retryCount) {
+        String username;
+        String password;
+        SecurityInfo securityInfo = SecurityInfo.getCurrent();
+        if (securityInfo == null) {
+            ClientNamingContext namingContext = object.$getNamingContext();
+            if (namingContext != null) {
+                username = namingContext.getUsername();
+                password = namingContext.getPassword();
+            } else {
+                username = null;
+                password = null;
+            }
+        } else {
+            username = securityInfo.username;
+            password = securityInfo.password;
+        }
+        if (username != null && username.length() == 0) {
+            username = null; // Save network bandwidth in service context.
+        }
+        if (password != null && password.length() == 0) {
+            password = null; // Save network bandwidth in service context.
+        }
+        int count = 0;
+        if (username != null) {
+            count++;
+        }
+        if (password != null) {
+            count++;
+        }
+        if (requestKey != null) {
+            count++;
+        }
+        if (count == 0) {
+            return EMPTY_SERVICE_CONTEXT; // avoid allocating empty array.
+        }
+        ServiceContext[] context = new ServiceContext[count];
+        int index = 0;
+        if (username != null) {
+            context[index++] = new ServiceContext(SecurityInfo.TAG_USERNAME, SecurityInfo.encode(username));
+        }
+        if (password != null) {
+            context[index++] = new ServiceContext(SecurityInfo.TAG_PASSWORD, SecurityInfo.encode(password));
+        }
+        if (requestKey != null) {
+            if (retryCount == 0) {
+                // 'BF' indicates Before Failure
+                context[index++] = new ServiceContext(0xBFBFBFBF, UTF8.fromString((String) requestKey));
+            } else {
+                // 'AF' indicates After Failure
+                context[index++] = new ServiceContext(0xAFAFAFAF, UTF8.fromString((String) requestKey));
+            }
+        }
+        return context;
+    }
+
+    protected void processReply(ReplyHeader_1_2 reply) {
+        processReplyServiceContext(reply);
+        int status = reply.reply_status.value();
+        switch (status) {
+            case ReplyStatusType_1_2._NO_EXCEPTION:
+                processNormalReply(reply);
+                break;
+            case ReplyStatusType_1_2._USER_EXCEPTION:
+                processUserException(reply);
+                break;
+            case ReplyStatusType_1_2._SYSTEM_EXCEPTION:
+                processSystemException(reply);
+                break;
+            case ReplyStatusType_1_2._LOCATION_FORWARD:
+                throw new SystemException("TODO");
+            case ReplyStatusType_1_2._LOCATION_FORWARD_PERM:
+                throw new SystemException("TODO");
+            case ReplyStatusType_1_2._NEEDS_ADDRESSING_MODE:
+                throw new SystemException("TODO");
+            default:
+                throw new SystemException("reply status = " + status);
+        }
+    }
+
+    protected void processReplyServiceContext(ReplyHeader_1_2 reply) {
+        ServiceContext[] list = reply.service_context;
+        int n = list.length;
+        for (int i = 0; i < n; i++) {
+            ServiceContext sc = list[i];
+            if (sc.context_id == 0xCFCFCFCF
+                || sc.context_id == 0xDFDFDFDF) {
+                // "CF..." indicates "Call Forget Request"
+                // "DF..." indicates "Call Forget Response"
+                _callForget = sc.context_id;
+            }
+        }
+    }
+
+    protected void processNormalReply(ReplyHeader_1_2 reply) {
+        // Intentionally empty.
+    }
+
+    protected void processUserException(ReplyHeader_1_2 reply) {
+        _exception = null;
+        _exceptionType = _results.read_string();
+        _ok = true;
+    }
+
+    protected void processSystemException(ReplyHeader_1_2 reply) {
+        _exceptionType = "???";
+        SystemExceptionReplyBody replyBody = SystemExceptionReplyBodyHelper.read(_results);
+        String id = replyBody.exception_id;
+        id = StringUtil.removePrefix(id, "IDL:omg.org/CORBA/");
+        id = StringUtil.removeSuffix(id, ":1.0");
+        String stackTrace = null;
+        if (_results.hasMoreData()) {
+            stackTrace = _results.read_string() + ExceptionUtil.getDivider();
+        }
+        _ok = true;
+        String exceptionClassName = "org.omg.CORBA." + id;
+        try {
+            Class exceptionClass = ThreadContext.loadClass(exceptionClassName);
+            org.omg.CORBA.SystemException corbaException = (org.omg.CORBA.SystemException) exceptionClass.newInstance();
+            corbaException.minor = replyBody.minor_code_value;
+            corbaException.completed = org.omg.CORBA.CompletionStatus.from_int(replyBody.completion_status);
+            _exception = new org.apache.geronimo.interop.SystemException(stackTrace, corbaException);
+        } catch (Exception ex) {
+            _exception = new org.apache.geronimo.interop.SystemException(stackTrace,
+                                                                         new org.omg.CORBA.UNKNOWN(replyBody.exception_id,
+                                                                                                   replyBody.minor_code_value,
+                                                                                                   org.omg.CORBA.CompletionStatus.from_int(replyBody.completion_status)));
+        }
+    }
+
+    public void shutdown() {
+        if (_socketOut != null) {
+            try {
+                _socketOut.close();
+            } catch (Exception ignore) {
+            }
+            _socketOut = null;
+        }
+        if (_socketIn != null) {
+            try {
+                _socketIn.close();
+            } catch (Exception ignore) {
+            }
+            _socketIn = null;
+        }
+        if (_socket != null) {
+            try {
+                _socket.close();
+            } catch (Exception ignore) {
+            }
+            _socket = null;
+        }
+    }
+
+    // log methods
+
+    protected String errorConnectFailed(String host, int port, Exception ex) {
+        String msg;
+        msg = "Error: errorConnectFailed: host=" + host + ", port=" + port + ", ex = " + ex;
+        return msg;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/client/ConnectionPool.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/client/ConnectionPool.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/client/ConnectionPool.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,267 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop.client;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.apache.geronimo.interop.SystemException;
+import org.apache.geronimo.interop.rmi.RmiTrace;
+import org.apache.geronimo.interop.rmi.iiop.ObjectRef;
+import org.apache.geronimo.interop.rmi.iiop.Protocol;
+import org.apache.geronimo.interop.util.InstancePool;
+import org.apache.geronimo.interop.util.StringUtil;
+
+
+public class ConnectionPool {
+    public static ConnectionPool getInstance(ClientNamingContext namingContext) {
+        ConnectionPool object = new ConnectionPool();
+        object.init(namingContext);
+        return object;
+    }
+
+    // private data
+
+    private ClientNamingContext _namingContext;
+
+    private HashMap _poolMap;
+
+    // public methods
+
+    public Connection get(int protocol, String endpoint, ObjectRef objectRef) {
+        System.out.println("ConnectionPool.get(): protocol: " + protocol + ", endpoint: " + endpoint + ", objectRef: " + objectRef);
+
+        HostList hostList = resolve(endpoint, objectRef);
+        System.out.println("ConnectionPool.get(): hostlist: " + hostList);
+        if (hostList == null) {
+            InstancePool pool = getInstancePool(protocol, endpoint);
+            System.out.println("ConnectionPool.get(): pool: " + pool);
+            Connection conn = (Connection) pool.get();
+            if (conn == null) {
+                conn = newConnection(protocol, endpoint, objectRef, pool);
+            }
+            return conn;
+        } else {
+            for (int pass = 1; pass <= 2; pass++) {
+                int baseIndex;
+                ArrayList servers;
+                if (pass == 1) {
+                    baseIndex = hostList.getPreferredIndex();
+                    servers = hostList.getPreferredServers();
+                } else {
+                    baseIndex = hostList.getAlternateIndex();
+                    servers = hostList.getAlternateServers();
+                }
+                int n = servers.size();
+                for (int i = 0; i < n; i++) {
+                    int tryIndex = (baseIndex + i) % n;
+                    String host = (String) servers.get(tryIndex);
+                    String hostPort = getEndpoint(protocol, host, objectRef);
+                    if (hostPort == null) {
+                        continue;
+                    }
+                    InstancePool pool = getInstancePool(protocol, hostPort);
+                    Connection conn = (Connection) pool.get();
+                    if (conn == null) {
+                        conn = newConnection(protocol, hostPort, objectRef, pool);
+                        hostList.countConnect();
+                    }
+                    return conn;
+                }
+            }
+            // TODO: I18N
+            throw new SystemException("CONNECT FAILED: host list = " + hostList);
+        }
+    }
+
+    public void put(Connection conn) {
+        conn.getInstancePool().put(conn);
+    }
+
+    // protected methods
+
+    protected void init(ClientNamingContext namingContext) {
+        _namingContext = namingContext;
+        _poolMap = new HashMap();
+    }
+
+    /**
+     * * Get the endpoint (host:port) for host, which is either a host name,
+     * * IP address, or URL. If it is a URL, then return null if its protocol
+     * * does not match expectations or if its port number suffix doesn't match
+     * * the object reference. This method is used frequently, so given the
+     * * above requirements should be as efficient as possible.
+     */
+    protected String getEndpoint(int protocol, String host, ObjectRef objectRef) {
+        System.out.println("ConnectionPool.getEndpoint(): protocol: " + protocol + ", host: " + host + ", objectRef: " + objectRef);
+
+        int ssPos = host.indexOf("://");
+        if (ssPos != -1) {
+            String scheme = Protocol.getScheme(protocol); // e.g. "iiop:"
+            if (!host.startsWith(scheme)) {
+                return null;
+            }
+            int portPos = host.lastIndexOf(':');
+            if (portPos > ssPos) {
+                int port = 0;
+                int n = host.length();
+                for (int i = portPos + 1; i < n; i++) {
+                    char c = host.charAt(i);
+                    if (c == ']') {
+                        // Part of IP6 host name, no port number is present.
+                        port = -1;
+                        break;
+                    }
+                    port = 10 * port + (c - '0');
+                }
+                if (port != -1) {
+                    if (port % 10 != objectRef.$getPort() % 10) {
+                        // TODO: make this configurable via HostInfo?
+                        return null;
+                    }
+                    return host.substring(ssPos + 3);
+                }
+            }
+            StringBuffer hp = new StringBuffer(host.length()); // shouldn't require expansion in append
+            hp.append(host.substring(ssPos + 3));
+            hp.append(':');
+            hp.append(objectRef.$getPort());
+            return hp.toString();
+        } else {
+            StringBuffer hp = new StringBuffer(host.length() + 6); // shouldn't require expansion in append
+            hp.append(host);
+            hp.append(':');
+            hp.append(objectRef.$getPort());
+            return hp.toString();
+        }
+    }
+
+    protected InstancePool getInstancePool(final int protocol, final String endpoint) {
+        System.out.println("ConnectionPool.getInstancePool(): protocol: " + protocol + ", endpoint: " + endpoint);
+
+        InstancePool pool = (InstancePool) _poolMap.get(endpoint);
+        if (pool == null) {
+            synchronized (_poolMap) {
+                pool = (InstancePool) _poolMap.get(endpoint);
+                if (pool == null) {
+                    String poolName = Protocol.getName(protocol) + "://" + endpoint;
+                    //long idleTimeout = 1000 * _namingContext.getIdleConnectionTimeout();
+                    //if (idleTimeout > 0)
+                    //{
+/*
+						pool = new InstancePool
+						(
+							poolName,
+							idleTimeout,
+							new TimeoutObject()
+							{
+								public void onTimeout(Object object)
+								{
+									Connection conn = (Connection)object;
+									if (RmiTrace.CONNECT)
+									{
+										RmiTrace.getInstance().traceDisconnect(Protocol.getName(protocol) + "://" + endpoint);
+									}
+									conn.shutdown();
+								}
+							}
+						);
+                        */
+                    //}
+                    //else
+                    //{
+                    pool = new InstancePool(poolName);
+                    //}
+                    _poolMap.put(endpoint, pool);
+                }
+            }
+        }
+        return pool;
+    }
+
+    protected Connection newConnection(int protocol, String endpoint, ObjectRef objectRef, InstancePool pool) {
+        System.out.println("ConnectionPool.newConnection(): protocol: " + protocol + ", endpoint: " + endpoint + ", pool: " + pool);
+
+        if (endpoint == null) {
+            // See getEndpoint above, noting that it may return null.
+            return null;
+        }
+        Connection conn;
+        // Name Service connections use different pools from ordinary
+        // connections. This is achieved using the "ns~" endpoint
+        // prefix. Since this is not valid for host names, we must remove
+        // it now.
+        endpoint = StringUtil.removePrefix(endpoint, "ns~");
+        switch (protocol) {
+            case Protocol.IIOP:
+                conn = iiopConnection(endpoint, objectRef);
+                break;
+            case Protocol.IIOPS:
+                conn = iiopsConnection(endpoint, objectRef);
+                break;
+            case Protocol.HTTP:
+                conn = httpConnection(endpoint, objectRef);
+                break;
+            case Protocol.HTTPS:
+                conn = httpsConnection(endpoint, objectRef);
+                break;
+            default:
+                throw new IllegalArgumentException("protocol = " + protocol);
+        }
+        conn.setInstancePool(pool);
+        if (RmiTrace.CONNECT) {
+            RmiTrace.traceConnect(Protocol.getName(protocol) + "://" + endpoint);
+        }
+        return conn;
+    }
+
+    protected Connection iiopConnection(String endpoint, ObjectRef objectRef) {
+        return Connection.getInstance(endpoint, objectRef, _namingContext.getConnectionProperties());
+    }
+
+    protected Connection iiopsConnection(String endpoint, ObjectRef objectRef) {
+        throw new SystemException("TODO");
+    }
+
+    protected Connection httpConnection(String endpoint, ObjectRef objectRef) {
+        throw new SystemException("TODO");
+    }
+
+    protected Connection httpsConnection(String endpoint, ObjectRef objectRef) {
+        throw new SystemException("TODO");
+    }
+
+    protected HostList resolve(String endpoint, ObjectRef objectRef) {
+/*
+		if (objectRef instanceof org.apache.geronimo.interop.rmi.iiop.NameService
+			&& ! endpoint.startsWith("ns~mh~"))
+		{
+			return null; // Avoid unbounded recursion
+		}
+        */
+        HostList hostList = _namingContext.lookupHost(objectRef.$getHost()); // this uses a cache for good performance
+        if (hostList != null
+            && hostList.getPreferredServers().size() == 0
+            && hostList.getAlternateServers().size() == 0) {
+            // If the host list doesn't have any elements, we are better
+            // off using the original endpoint string.
+            hostList = null;
+        }
+        return hostList;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/client/HostList.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/client/HostList.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/client/HostList.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,136 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop.client;
+
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+
+import org.apache.geronimo.interop.SystemException;
+import org.apache.geronimo.interop.util.ListUtil;
+
+
+public class HostList {
+    private static ArrayList EMPTY_LIST = new ArrayList(0);
+
+    private int _connectCount;
+
+    private boolean _firstConnectAll = true;
+
+    private int _cacheTimeout = 600; // 600 seconds = 10 minutes
+
+    private int _preferredIndex;
+
+    private int _alternateIndex;
+
+    private ArrayList _preferredServers = EMPTY_LIST;
+
+    private ArrayList _alternateServers = EMPTY_LIST;
+
+    public HostList(String hostList) {
+        try {
+            int cycle = -1;
+            for (StringTokenizer st = new StringTokenizer(hostList, ";"); st.hasMoreTokens();) {
+                String token = st.nextToken().trim();
+                if (token.startsWith("cycle=")) {
+                    String value = token.substring(6);
+                    cycle = Integer.parseInt(value);
+                } else if (token.startsWith("cacheTimeout=")) {
+                    String value = token.substring(6);
+                    _cacheTimeout = Integer.parseInt(value);
+                } else if (token.startsWith("preferredServers=")) {
+                    String value = token.substring(17);
+                    _preferredServers = ListUtil.getCommaSeparatedList(value);
+                } else if (token.startsWith("alternateServers=")) {
+                    String value = token.substring(17);
+                    _alternateServers = ListUtil.getCommaSeparatedList(value);
+                }
+                // Otherwise ignore for forwards compabitility
+            }
+            if (cycle < 0) {
+                cycle = 0; //FastRandom.getSharedInstance().nextInt(0, 999999999);
+            }
+            if (_preferredServers.size() > 0) {
+                _preferredIndex = cycle % _preferredServers.size();
+            }
+            if (_alternateServers.size() > 0) {
+                _alternateIndex = cycle % _alternateServers.size();
+            }
+        } catch (Exception ex) {
+            throw new SystemException("hostList = " + hostList, ex);
+        }
+    }
+
+    public boolean connectAll() {
+        synchronized (this) {
+            return _connectCount >= 5; // TODO: make this configurable
+        }
+    }
+
+    public void countConnect() {
+        synchronized (this) {
+            int n = _connectCount;
+            if (n < Integer.MAX_VALUE) {
+                _connectCount = ++n;
+            }
+        }
+    }
+
+    public int getCacheTimeout() {
+        return _cacheTimeout;
+    }
+
+    public int getPreferredIndex() {
+        synchronized (this) {
+            int nextIndex = _preferredIndex;
+            if (connectAll()) {
+                int n = _preferredServers.size();
+                if (n > 0) {
+                    _preferredIndex = (nextIndex + 1) % n;
+                }
+            }
+            return nextIndex;
+        }
+    }
+
+    public int getAlternateIndex() {
+        synchronized (this) {
+            int nextIndex = _alternateIndex;
+            if (connectAll()) {
+                int n = _alternateServers.size();
+                if (n > 0) {
+                    _alternateIndex = (nextIndex + 1) % n;
+                }
+            }
+            return nextIndex;
+        }
+    }
+
+    public ArrayList getPreferredServers() {
+        return _preferredServers;
+    }
+
+    public ArrayList getAlternateServers() {
+        return _alternateServers;
+    }
+
+    public String toString() {
+        return "HostList:cacheTimeout=" + _cacheTimeout
+               + ";preferredServers=" + ListUtil.formatCommaSeparatedList(_preferredServers)
+               + ";alternateServers=" + ListUtil.formatCommaSeparatedList(_alternateServers);
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/client/NameBinding.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/client/NameBinding.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/client/NameBinding.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,29 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop.client;
+
+public class NameBinding {
+    public Object object;
+
+    public long cacheTimeout;
+
+    public boolean hasExpired() {
+        long timeout = cacheTimeout;
+        return timeout > 0 && timeout >= System.currentTimeMillis();
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/client/RetryInvokeException.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/client/RetryInvokeException.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/client/RetryInvokeException.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,28 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop.client;
+
+public class RetryInvokeException extends org.apache.geronimo.interop.SystemException {
+    public RetryInvokeException(RuntimeException cause) {
+        super(cause);
+    }
+
+    public RuntimeException getRuntimeException() {
+        return (RuntimeException) getCause();
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/client/UrlInfo.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/client/UrlInfo.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/client/UrlInfo.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,139 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop.client;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.geronimo.interop.SystemException;
+import org.apache.geronimo.interop.properties.PropertyMap;
+import org.apache.geronimo.interop.rmi.iiop.Protocol;
+import org.apache.geronimo.interop.util.ListUtil;
+import org.apache.geronimo.interop.util.NamedValueList;
+import org.apache.geronimo.interop.util.StringUtil;
+
+
+public class UrlInfo {
+    public static UrlInfo getInstance(String url) {
+        UrlInfo object = new UrlInfo();
+        object.init(url);
+        return object;
+    }
+
+    public static List getList(String urls) {
+        ArrayList list = new ArrayList(3);
+        for (Iterator i = ListUtil.getCommaSeparatedList(urls).iterator(); i.hasNext();) {
+            String url = (String) i.next();
+            list.add(getInstance(url));
+        }
+        return list;
+    }
+
+    // private data
+
+    private int _protocol;
+
+    private String _host;
+
+    private int _port;
+
+    private String _objectKey;
+
+    private PropertyMap _properties;
+
+    // internal methods
+
+    protected void init(String urlString) {
+        int cssPos = urlString.indexOf("://");
+        if (cssPos == -1) {
+            throw new IllegalArgumentException(urlString);
+        }
+        _protocol = Protocol.getNumber(urlString.substring(0, cssPos));
+        try {
+            URL url = new URL("http" + urlString.substring(cssPos));
+            _host = url.getHost();
+            _port = url.getPort();
+            if (_port == -1) {
+                switch (_protocol) {
+                    case Protocol.HTTP:
+                        _port = 80; // see http://www.iana.org/assignments/port-numbers
+                        break;
+                    case Protocol.HTTPS:
+                        _port = 443; // see http://www.iana.org/assignments/port-numbers
+                        break;
+                    case Protocol.IIOP:
+                        _port = 683; // see http://www.iana.org/assignments/port-numbers
+                        break;
+                    case Protocol.IIOPS:
+                        _port = 684; // see http://www.iana.org/assignments/port-numbers
+                        break;
+                    default:
+                        throw new IllegalStateException("url = " + urlString);
+                }
+            }
+            _objectKey = url.getFile();
+            if (_objectKey == null) {
+                _objectKey = "";
+            }
+            int queryPos = _objectKey.indexOf('?');
+            if (queryPos != -1) {
+                _objectKey = _objectKey.substring(0, queryPos);
+            }
+            _objectKey = StringUtil.removePrefix(_objectKey, "/");
+            if (_objectKey.length() == 0) {
+                _objectKey = "NameService";
+            }
+            String query = url.getQuery();
+            if (query == null) {
+                query = "";
+            }
+            String props = StringUtil.removePrefix(query, "?").replace('&', ',');
+            _properties = new NamedValueList(props).getProperties();
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+    }
+
+    // public methods
+
+    public int getProtocol() {
+        return _protocol;
+    }
+
+    public String getHost() {
+        return _host;
+    }
+
+    public int getPort() {
+        return _port;
+    }
+
+    public String getObjectKey() {
+        return _objectKey;
+    }
+
+    public PropertyMap getProperties() {
+        return _properties;
+    }
+
+    public String toString() {
+        return Protocol.getName(_protocol) + "://" + _host + ":" + _port + "/" + _objectKey;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/client/ValueInfo.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/client/ValueInfo.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/client/ValueInfo.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,47 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop.client;
+
+public class ValueInfo {
+    public String _nameToBeResolved = null;
+    public Object _objectToBeBound = null;
+
+    public ValueInfo(String nameToBeResolved) {
+        _nameToBeResolved = nameToBeResolved;
+    }
+
+    public ValueInfo(Object objectToBeBound) {
+        _objectToBeBound = objectToBeBound;
+    }
+
+    public void setNameToBeResolved(String name) {
+        _nameToBeResolved = name;
+    }
+
+    public String getNameToBeResolved() {
+        return _nameToBeResolved;
+    }
+
+    public void setObjectToBeBound(Object object) {
+        _objectToBeBound = object;
+    }
+
+    public Object getObjectToBeBound() {
+        return _objectToBeBound;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/Compiler.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/Compiler.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/Compiler.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,151 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop.compiler;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+
+import org.apache.geronimo.interop.generator.GenOptions;
+import org.apache.geronimo.interop.generator.JParameter;
+import org.apache.geronimo.interop.generator.JVariable;
+
+
+public class Compiler {
+    protected Class _riClass;
+    protected GenOptions _genOptions;
+    protected ClassLoader _cl;
+    protected boolean _simpleIDL = false;
+
+    protected static HashMap _readMethods;
+    protected static HashMap _writeMethods;
+    protected static HashMap _overloadTypes;
+
+    static {
+        _readMethods = new HashMap();
+        _readMethods.put("boolean", "readBoolean");
+        _readMethods.put("char", "readChar");
+        _readMethods.put("byte", "readByte");
+        _readMethods.put("short", "readShort");
+        _readMethods.put("int", "readInt");
+        _readMethods.put("long", "readLong");
+        _readMethods.put("float", "readFloat");
+        _readMethods.put("double", "readDouble");
+
+        _writeMethods = new HashMap();
+        _writeMethods.put("boolean", "writeBoolean");
+        _writeMethods.put("char", "writeChar");
+        _writeMethods.put("byte", "writeByte");
+        _writeMethods.put("short", "writeShort");
+        _writeMethods.put("int", "writeInt");
+        _writeMethods.put("long", "writeLong");
+        _writeMethods.put("float", "writeFloat");
+        _writeMethods.put("double", "writeDouble");
+
+        _overloadTypes = new HashMap();
+        _overloadTypes.put("boolean", "boolean");
+        _overloadTypes.put("byte", "octet");
+        _overloadTypes.put("char", "wchar");
+        _overloadTypes.put("double", "double");
+        _overloadTypes.put("float", "float");
+        _overloadTypes.put("int", "long");
+        _overloadTypes.put("long", "long_long");
+        _overloadTypes.put("short", "short");
+        _overloadTypes.put("java.lang.Class", "javax_rmi_CORBA.ClassDesc");
+        _overloadTypes.put("java.lang.String", "CORBA.WStringValue");
+        _overloadTypes.put("org.omg.CORBA.Object", "Object");
+        _overloadTypes.put("org.omg.CORBA.Any", "org_omg_boxedIDL_CORBA.Any");
+        _overloadTypes.put("org.omg.CORBA.TypeCode", "org_omg_boxedIDL_CORBA.TypeCode");
+    }
+
+    public Compiler(Class remoteInterface) {
+        this(remoteInterface, null);
+    }
+
+    public Compiler(Class riClass, GenOptions go) {
+        _riClass = riClass;
+
+        _cl = _riClass.getClassLoader();
+        if (_cl == null) {
+            _cl = ClassLoader.getSystemClassLoader();
+        }
+
+        if (go == null) {
+            go = new GenOptions();
+        }
+
+        _genOptions = go;
+    }
+
+    //
+    // Properties
+    //
+
+    public boolean isSimpleIDL() {
+        return _simpleIDL;
+    }
+
+    public void setSimpleIDL(boolean simpleIDL) {
+        _simpleIDL = simpleIDL;
+    }
+
+    public GenOptions getGenOptions() {
+        return _genOptions;
+    }
+
+    public void setGenOptions(GenOptions genOptions) {
+        _genOptions = genOptions;
+    }
+
+    public JParameter[] getMethodParms(Method m) {
+        Class p[] = m.getParameterTypes();
+        JParameter parms[] = null;
+
+        if (p != null) {
+            parms = new JParameter[p.length];
+
+            int i;
+            for (i = 0; i < p.length; i++) {
+                parms[i] = new JParameter(p[i], "p" + i);
+            }
+        }
+
+        return parms;
+    }
+
+    protected String getReadMethod(JVariable v) {
+        String rc = null;
+
+        if (v != null) {
+            rc = (String) _readMethods.get(v.getTypeDecl());
+        }
+
+        return rc;
+    }
+
+    protected String getWriteMethod(JVariable v) {
+        String rc = null;
+
+        if (v != null) {
+            rc = (String) _writeMethods.get(v.getTypeDecl());
+        }
+
+        return rc;
+    }
+
+
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/SkelCompiler.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/SkelCompiler.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/SkelCompiler.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,490 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop.compiler;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import org.apache.geronimo.interop.generator.GenOptions;
+import org.apache.geronimo.interop.generator.JCaseStatement;
+import org.apache.geronimo.interop.generator.JCatchStatement;
+import org.apache.geronimo.interop.generator.JClass;
+import org.apache.geronimo.interop.generator.JCodeStatement;
+import org.apache.geronimo.interop.generator.JConstructor;
+import org.apache.geronimo.interop.generator.JDeclareStatement;
+import org.apache.geronimo.interop.generator.JExpression;
+import org.apache.geronimo.interop.generator.JField;
+import org.apache.geronimo.interop.generator.JLocalVariable;
+import org.apache.geronimo.interop.generator.JMethod;
+import org.apache.geronimo.interop.generator.JPackage;
+import org.apache.geronimo.interop.generator.JParameter;
+import org.apache.geronimo.interop.generator.JReturnType;
+import org.apache.geronimo.interop.generator.JSwitchStatement;
+import org.apache.geronimo.interop.generator.JTryCatchFinallyStatement;
+import org.apache.geronimo.interop.generator.JTryStatement;
+import org.apache.geronimo.interop.generator.JVariable;
+import org.apache.geronimo.interop.generator.JavaGenerator;
+
+
+public class SkelCompiler
+        extends Compiler {
+    protected ValueTypeContext _vtc = new ValueTypeContext();
+    protected static JParameter _objInputVar = new JParameter(org.apache.geronimo.interop.rmi.iiop.ObjectInputStream.class, "input");
+    protected static JParameter _objOutputVar = new JParameter(org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream.class, "output");
+
+    public SkelCompiler(Class remoteInterface) {
+        super(remoteInterface);
+    }
+
+    public SkelCompiler(Class remoteInterface, GenOptions go) {
+        super(remoteInterface, go);
+    }
+
+    //
+    // Methods
+    //
+
+    public void addMethodGetIds(JClass jc) {
+        /*
+        public String[] getIds()
+        {
+            return _ids;
+        }
+        */
+
+        JMethod jm = jc.newMethod(new JReturnType(String.class, true),
+                                  "getIds",
+                                  (JParameter[]) null,
+                                  (Class[]) null);
+
+        jm.addStatement(new JCodeStatement("return _ids;"));
+    }
+
+    public void addMethodRegisterMethod(JClass jc) {
+        /*
+        public void registerMethod( String name, int id )
+        {
+            _methodMap.put( name, new Integer(id) );
+        }
+        */
+
+        JMethod jm = jc.newMethod(new JReturnType(void.class),
+                                  "registerMethod",
+                                  new JParameter[]{new JParameter(String.class, "name"),
+                                                   new JParameter(int.class, "id")},
+                                  (Class[]) null);
+
+        jm.addStatement(new JCodeStatement("_methods.put( name, new Integer(id) );"));
+    }
+
+    public void addMethodGetObjectRef(JClass jc, Class c) {
+        /*
+        public ObjectRef $getObjectRef()
+        {
+            ObjectRef or = new ObjectRef();
+            or.$setID("RMI:mark.comps.Add:0000000000000000");
+            or.$setObjectKey( "mark.comps.Add" );
+            return or;
+        }
+        */
+
+        JMethod jm = jc.newMethod(new JReturnType("ObjectRef"),
+                                  "$getObjectRef",
+                                  (JParameter[]) null,
+                                  (Class[]) null);
+
+        JLocalVariable jvor = jm.newLocalVariable(org.apache.geronimo.interop.rmi.iiop.ObjectRef.class, "or", new JExpression(new JCodeStatement("new ObjectRef()")));
+        jm.addStatement(new JCodeStatement(jvor.getName() + ".$setID(\"RMI:" + c.getName() + ":0000000000000000\");"));
+        jm.addStatement(new JCodeStatement(jvor.getName() + ".$setObjectKey(\"" + c.getName() + "\");"));
+        jm.addStatement(new JCodeStatement("return " + jvor.getName() + ";"));
+    }
+
+    public void addMethodGetSkeleton(JClass jc) {
+        /*
+        public RemoteInterface $getSkeleton()
+        {
+            return this;
+        }
+        */
+
+        JMethod jm = jc.newMethod(new JReturnType("RemoteInterface"),
+                                  "$getSkeleton",
+                                  (JParameter[]) null,
+                                  (Class[]) null);
+
+        jm.addStatement(new JCodeStatement("return this;"));
+    }
+
+    protected boolean throwsAnRMIRemoteException(Method m) {
+        boolean rc = false;
+
+        Class c[] = m.getExceptionTypes();
+        int i;
+
+        for (i = 0; i < c.length && !rc; i++) {
+            rc = java.rmi.RemoteException.class.isAssignableFrom(c[i]);
+        }
+
+        return rc;
+    }
+
+    public void addMethod(Method m, JClass jc) {
+        String invokeCall;
+        String name = m.getName();
+        JParameter[] sparms = getMethodParms(m);
+        JParameter[] iparms = new JParameter[]{_objInputVar, _objOutputVar};
+
+        if (!isSimpleIDL() && !throwsAnRMIRemoteException(m)) {
+            error("Method " + m.getName() + " does not throw java.rmi.RemoteException or subclass, unable to generate its skeleton method.");
+        }
+
+        JMethod jm = jc.newMethod(new JReturnType(void.class), name, iparms, null);
+
+        JVariable jrc = null;
+        String rc = m.getReturnType().getName();
+        if (rc != null && rc.length() > 0 && (!rc.equals("void"))) {
+            jrc = jm.newLocalVariable(m.getReturnType(), "rc");
+        }
+
+        JTryCatchFinallyStatement tcfs = new JTryCatchFinallyStatement();
+        JTryStatement ts = tcfs.getTryStatement();
+
+        invokeCall = "_servant." + name + "(";
+
+        if (sparms != null && sparms.length > 0) {
+            int i;
+            for (i = 0; i < sparms.length; i++) {
+                String readMethod = getReadMethod(sparms[i]);
+                JCodeStatement jcs = null;
+
+                if (readMethod != null) {
+                    // Primitive Type
+                    // Cast not needed since each method returns the primitive datatype.
+
+                    jcs = new JCodeStatement("input." + readMethod + "()");
+                } else {
+                    String vtVarName = _vtc.getValueTypeVarName(jc, sparms[i]);
+                    if (vtVarName != null) {
+                        jcs = new JCodeStatement("(" + sparms[i].getTypeDecl() + ") input.readObject( " + vtVarName + " )");
+                    } else {
+                        jcs = new JCodeStatement("// Code Gen Error: Class '" + sparms[i].getTypeDecl() + " is not a valid value type.");
+                    }
+                }
+
+                ts.addStatement(new JDeclareStatement(sparms[i], new JExpression(jcs)));
+
+                invokeCall += " " + sparms[i].getName();
+                if (i + 1 < sparms.length) {
+                    invokeCall += ",";
+                }
+            }
+        }
+
+        invokeCall += " )";
+
+        if (jrc != null) {
+            invokeCall = jrc.getName() + " = " + invokeCall;
+        }
+
+        invokeCall = invokeCall + ";";
+
+        ts.addStatement(new JCodeStatement(invokeCall));
+
+        JVariable jv = new JVariable(java.lang.Exception.class, "ex");
+        JCatchStatement cs = tcfs.newCatch(jv);
+        cs.addStatement(new JCodeStatement(jv.getName() + ".printStackTrace();"));
+
+        jv = new JVariable(java.lang.Error.class, "er");
+        cs = tcfs.newCatch(jv);
+        cs.addStatement(new JCodeStatement(jv.getName() + ".printStackTrace();"));
+
+        jm.addStatement(tcfs);
+
+        if (jrc != null) {
+            String writeMethod = getWriteMethod(jrc);
+            JCodeStatement jcs = null;
+
+            if (writeMethod != null) {
+                // Primitive Type
+                // Cast not needed since each method returns the primitive datatype.
+
+                jcs = new JCodeStatement("output." + writeMethod + "( " + jrc.getName() + " );");
+            } else {
+                String vtVarName = _vtc.getValueTypeVarName(jc, jrc);
+                if (vtVarName != null) {
+                    jcs = new JCodeStatement("output.writeObject( " + vtVarName + ", " + jrc.getName() + " );");
+                } else {
+                    jcs = new JCodeStatement("// Code Gen Error: Class '" + jrc.getTypeDecl() + " is not a valid value type.");
+                }
+            }
+
+            ts.addStatement(jcs);
+        }
+    }
+
+    protected boolean isVariableAValueType(JVariable jv) {
+        boolean rc = false;
+
+        if (jv != null) {
+            Class c = jv.getType();
+
+            rc = isClassAValueType(c);
+        }
+
+        return rc;
+    }
+
+    protected boolean isClassAValueType(Class c) {
+        boolean rc = false;
+
+        if (c != null) {
+            if (java.io.Serializable.class.isAssignableFrom(c)) {
+                if (java.io.Externalizable.class.isAssignableFrom(c)) {
+                    // Ok - but use the writeExternal and readExternal methods for serialization
+                }
+
+                if (!isClassARMIRemote(c)) {
+                    if (Modifier.isStatic(c.getModifiers()) &&
+                        c.getName().indexOf("$") != -1) {
+                        // TODO: How do we determine the inner-classes contained class?
+                        // Parse the <containedclass>$<innerclass> ?
+
+                        //rc = isClassAValueType( c.getSuperclass() );
+                        rc = true;
+                    }
+
+                    rc = true;
+                } else {
+                    error("Class: " + c.getName() + " is not proper value type as it is an instance of java.rmi.Remote or subclass.");
+                }
+            }
+        }
+
+        return rc;
+    }
+
+    protected boolean isClassARMIRemote(Class c) {
+        boolean rc = false;
+
+        if (c != null) {
+            rc = java.rmi.Remote.class.isAssignableFrom(c);
+        }
+
+        return rc;
+    }
+
+    protected void error(String msg) {
+        System.out.println("Error: " + msg);
+    }
+
+    protected void error(String msg, Throwable t) {
+        error(msg);
+        t.printStackTrace();
+    }
+
+    public void generate()
+            throws Exception {
+        _vtc.clear();
+
+        if (!isSimpleIDL() && !isClassARMIRemote(_riClass)) {
+            error("Class '" + _riClass.getName() + "' must be an instance of either java.rmi.Remote or of a subclass.");
+        }
+
+        ClassLoader cl = _riClass.getClassLoader();
+        if (cl == null) {
+            cl = ClassLoader.getSystemClassLoader();
+        }
+
+        String fullGenDir = _genOptions.getGenDir();
+
+        JavaGenerator jg = new JavaGenerator(_genOptions);
+
+        String className = _riClass.getName();
+
+        JPackage p = new JPackage("");
+        if (_riClass.getPackage() != null) {
+            p = new JPackage(_riClass.getPackage().getName());
+            className = className.substring(className.lastIndexOf(".") + 1);
+        }
+
+        JClass jc = p.newClass(className + "_Skeleton");
+
+        /*
+        jw.comment( "" );
+        jw.comment( "CORBA RMI-IIOP Skeleton Generator" );
+        jw.comment( "  Interface: " + c.getName() );
+        jw.comment( "  Date: " + (new Date(System.currentTimeMillis())).toString() );
+        jw.comment( "" );
+        */
+
+        jc.addImport("org.apache.geronimo.interop.rmi.iiop", "ObjectInputStream");
+        jc.addImport("org.apache.geronimo.interop.rmi.iiop", "ObjectOutputStream");
+        jc.addImport("org.apache.geronimo.interop.rmi.iiop", "RemoteInterface");
+        jc.addImport("org.apache.geronimo.interop.rmi.iiop", "RemoteInterface");
+        jc.addImport("org.apache.geronimo.interop.rmi.iiop", "ObjectRef");
+        jc.addImport("org.apache.geronimo.interop.rmi.iiop", "RemoteObject");
+        jc.addImport("org.apache.geronimo.interop.rmi.iiop.server", "Adapter");
+        jc.addImport("java.util", "HashMap");
+
+        jc.setExtends("RemoteObject");
+        jc.addImplements("RemoteInterface");
+
+        JField idsField = jc.newField(String[].class, "_ids", new JExpression(new JCodeStatement("{ \"" + _riClass.getName() + "\", \"RMI:" + _riClass.getName() + ":0000000000000000\"}")), true);
+        JField methodsField = jc.newField(java.util.HashMap.class, "_methods", new JExpression(new JCodeStatement("new HashMap(10)")));
+        JField servantField = jc.newField(_riClass, "_servant", new JExpression(new JCodeStatement("null")));
+
+        JConstructor jcCon = jc.newConstructor((JParameter[]) null, (Class[]) null);
+        jcCon.addStatement(new JCodeStatement("super();"));
+
+        addMethodRegisterMethod(jc);
+        addMethodGetIds(jc);
+        addMethodGetSkeleton(jc);
+        addMethodGetObjectRef(jc, _riClass);
+
+        JMethod jmInvoke = jc.newMethod(new JReturnType(void.class),
+                                        "$invoke",
+                                        new JParameter[]{new JParameter(String.class, "methodName"),
+                                                         new JParameter(byte[].class, "objectKey"),
+                                                         new JParameter(Object.class, "instance"),
+                                                         _objInputVar,
+                                                         _objOutputVar},
+                                        (Class[]) null);
+
+        jmInvoke.setModifier(Modifier.PUBLIC, true);
+
+        JLocalVariable jvM = jmInvoke.newLocalVariable(Integer.class, "m", new JExpression(new JCodeStatement("(Integer)_methods.get(methodName)")));
+
+        jmInvoke.addStatement(new JCodeStatement("if (m == null)"));
+        jmInvoke.addStatement(new JCodeStatement("{"));
+        jmInvoke.addStatement(new JCodeStatement("    throw new org.omg.CORBA.BAD_OPERATION(methodName);"));
+        jmInvoke.addStatement(new JCodeStatement("}"));
+        jmInvoke.addStatement(new JCodeStatement(""));
+        jmInvoke.addStatement(new JCodeStatement("_servant = (" + _riClass.getName() + ")instance;"));
+        jmInvoke.addStatement(new JCodeStatement(""));
+        jmInvoke.addStatement(new JCodeStatement("if (m.intValue() < 0)"));
+        jmInvoke.addStatement(new JCodeStatement("{"));
+        jmInvoke.addStatement(new JCodeStatement("    super.invoke( m.intValue(), objectKey, instance, input, output );"));
+        jmInvoke.addStatement(new JCodeStatement("}"));
+        jmInvoke.addStatement(new JCodeStatement(""));
+
+        JSwitchStatement ss = new JSwitchStatement(new JExpression(new JCodeStatement("m.intValue()")));
+        JCaseStatement cs = null;
+        jmInvoke.addStatement(ss);
+
+        Method m[] = null;
+
+        if (isSimpleIDL()) {
+            m = _riClass.getMethods();
+        } else {
+            m = _riClass.getDeclaredMethods();
+        }
+
+        if (m != null && m.length > 0) {
+            int i;
+            for (i = 0; i < m.length; i++) {
+                // Enter a new method id in the _methods hashtable.
+                jcCon.addStatement(new JCodeStatement("registerMethod( \"" + m[i].getName() + "\", " + i + ");"));
+
+                // Add a new case statement to the invoke swtich
+                cs = ss.newCase(new JExpression(new JCodeStatement("" + i)));
+                cs.addStatement(new JCodeStatement(m[i].getName() + "(input,output);"));
+
+                // Generate the method wrapper
+                addMethod(m[i], jc);
+            }
+        }
+
+        jg.generate(p);
+    }
+
+    public void compile()
+            throws Exception {
+    }
+
+    public Class getSkelClass() {
+        Class c = null;
+
+        try {
+            //generate();
+            compile();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+
+        return c;
+    }
+
+    public static void main(String args[])
+            throws Exception {
+        boolean generate = false;
+        boolean compile = false;
+        boolean simpleIDL = false;
+        String ri = "";
+        GenOptions go = new GenOptions();
+
+        go.setGenDir("./src");
+        go.setOverwrite(false);
+        go.setVerbose(false);
+
+        for (int i = 0; i < args.length; i++) {
+            if (args[i].equals("-g")) {
+                generate = true;
+            } else if (args[i].equals("-c")) {
+                compile = true;
+            } else if (args[i].equals("-d") && ((i + 1) < args.length)) {
+                go.setGenDir(args[++i]);
+            } else if (args[i].equals("-v")) {
+                go.setVerbose(true);
+            } else if (args[i].equals("-o")) {
+                go.setOverwrite(true);
+            } else if (args[i].equals("-s")) {
+                simpleIDL = true;
+            } else if (args[i].startsWith("-")) {
+                System.out.println("Warning: Ignoring unrecognized options: '" + args[i] + "'");
+            } else {
+                ri = args[i];
+            }
+        }
+
+        Class riClass = Class.forName(ri);
+
+        SkelCompiler sg = new SkelCompiler(riClass, go);
+
+        sg.setSimpleIDL(simpleIDL);
+
+        if (generate) {
+            if (go.isVerbose()) {
+                System.out.println("Generating: " + ri);
+            }
+
+            sg.generate();
+        }
+
+        if (compile) {
+            if (go.isVerbose()) {
+                System.out.println("Compiling: " + ri);
+            }
+
+            sg.compile();
+        }
+
+        // sg.setSimpleIDL( true );
+        // sg.generate( "org.apache.geronimo.interop.rmi.iiop.NameServiceOperations");
+    }
+}
+

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/SkelFactory.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/SkelFactory.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/SkelFactory.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,113 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop.compiler;
+
+import java.util.HashMap;
+
+import org.apache.geronimo.interop.SystemException;
+import org.apache.geronimo.interop.rmi.iiop.RemoteObject;
+import org.apache.geronimo.interop.util.ThreadContext;
+
+
+public class SkelFactory {
+    protected static SkelFactory _sf = new SkelFactory();
+
+    protected SkelFactory() {
+    }
+
+    public static SkelFactory getInstance() {
+        return _sf;
+    }
+
+    // private data
+
+    private static HashMap _skelClassMap;
+
+    // internal methods
+
+    protected void init() {
+        _skelClassMap = new HashMap();
+    }
+
+    protected Class loadStub(Class remoteInterface) {
+        String className = remoteInterface.getName();
+        String skelClassName = className + "_Skeleton";
+
+        /*
+        StubClass sc = new StubClass();
+        if (sc.skelClass == null)
+        {
+            // Try generating skel class now.
+            System.out.println( "TODO: StubFactory.loadStub(): className = " + className );
+            StubCompiler skelCompiler = StubCompiler.getInstance(remoteInterface);
+            sc.skelClass = skelCompiler.getStubClass();
+        }
+
+        if (sc.skelClass != null)
+        {
+            try
+            {
+                sc.getInstance = sc.skelClass.getMethod("$getInstance", ArrayUtil.EMPTY_CLASS_ARRAY);
+            }
+            catch (Exception ex)
+            {
+                throw new SystemException(ex);
+            }
+        }
+
+        return sc;
+        */
+
+        Class sc = null;
+        try {
+            sc = Class.forName(skelClassName);
+            SkelCompiler skelCompiler = new SkelCompiler(sc);
+            sc = skelCompiler.getSkelClass();
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+
+        return sc;
+    }
+
+    // public methods
+
+    public RemoteObject getSkel(Class remoteInterface) {
+        System.out.println("SkelFactory.getSkel(): remoteInterface: " + remoteInterface);
+        try {
+            Class sc = (Class) _skelClassMap.get(remoteInterface);
+            if (sc == null) {
+                synchronized (_skelClassMap) {
+                    sc = (Class) _skelClassMap.get(remoteInterface);
+                    if (sc == null) {
+                        sc = loadStub(remoteInterface);
+                        _skelClassMap.put(remoteInterface, sc);
+                    }
+                }
+            }
+            //return (ObjectRef)sc.getInstance.invoke(sc.skelClass, ArrayUtil.EMPTY_OBJECT_ARRAY);
+            return (RemoteObject) sc.newInstance();
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+    }
+
+    public Object getSkel(String remoteInterface) {
+        return getSkel(ThreadContext.loadClass(remoteInterface));
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/StubClass.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/StubClass.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/StubClass.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,27 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop.compiler;
+
+import java.lang.reflect.Method;
+
+
+public class StubClass {
+    public Class stubClass;
+
+    public Method getInstance;
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/StubCompiler.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/StubCompiler.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/StubCompiler.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,390 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop.compiler;
+
+import java.lang.reflect.Method;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.geronimo.interop.generator.GenOptions;
+import org.apache.geronimo.interop.generator.JBlockStatement;
+import org.apache.geronimo.interop.generator.JCatchStatement;
+import org.apache.geronimo.interop.generator.JClass;
+import org.apache.geronimo.interop.generator.JCodeStatement;
+import org.apache.geronimo.interop.generator.JConstructor;
+import org.apache.geronimo.interop.generator.JExpression;
+import org.apache.geronimo.interop.generator.JField;
+import org.apache.geronimo.interop.generator.JForStatement;
+import org.apache.geronimo.interop.generator.JIfElseIfElseStatement;
+import org.apache.geronimo.interop.generator.JIfStatement;
+import org.apache.geronimo.interop.generator.JLocalVariable;
+import org.apache.geronimo.interop.generator.JMethod;
+import org.apache.geronimo.interop.generator.JPackage;
+import org.apache.geronimo.interop.generator.JParameter;
+import org.apache.geronimo.interop.generator.JReturnType;
+import org.apache.geronimo.interop.generator.JTryCatchFinallyStatement;
+import org.apache.geronimo.interop.generator.JTryStatement;
+import org.apache.geronimo.interop.generator.JVariable;
+import org.apache.geronimo.interop.generator.JavaGenerator;
+import org.apache.geronimo.interop.util.JavaClass;
+import org.apache.geronimo.interop.util.ProcessUtil;
+
+
+public class StubCompiler
+        extends Compiler {
+    protected ValueTypeContext _vtc = new ValueTypeContext();
+    protected static JParameter _objInputVar = new JParameter(org.apache.geronimo.interop.rmi.iiop.ObjectInputStream.class, "input");
+    protected static JParameter _objOutputVar = new JParameter(org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream.class, "output");
+
+    protected String _stubClassName = "";
+    protected Class _stubClass = null;
+
+    protected String _inStreamName = "getInputStream";
+    protected String _outStreamName = "getOutputStream";
+
+    public StubCompiler(Class riClass) {
+        super(riClass);
+        init();
+    }
+
+    public StubCompiler(Class riClass, GenOptions go) {
+        super(riClass, go);
+        init();
+    }
+
+    protected void init() {
+        String className = _riClass.getName();
+        _stubClassName = JavaClass.addPackageSuffix(className, "iiop_stubs") + "_Stub";
+    }
+
+    protected void addMethod(JClass jc, JReturnType jrc, String name, JParameter[] jparms, Class[] excepts) {
+//        java.lang.Object $key_1 = $getRequestKey();
+//        for (int $retry = 0; ; $retry++)
+//        {
+//            try
+//            {
+//                org.apache.geronimo.interop.rmi.iiop.client.Connection $connection_2 = this.$connect();
+//                org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream $output_3 = $connection_2.getSimpleOutputStream();  // simple idl
+//                org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream $output_3 = $connection_2.getOutputStream();        // rmi-iiop
+//                $output_3.writeObject(type$1, p1);
+//                $connection_2.invoke(this, "_is_a", $key_1, $retry);
+//                org.apache.geronimo.interop.rmi.iiop.ObjectInputStream $input_4 = $connection_2.getSimpleInputStream();     // simple idl
+//                org.apache.geronimo.interop.rmi.iiop.ObjectInputStream $input_4 = $connection_2.getInputStream();           // rmi-iiop
+//                $connection_2.forget($key_1);
+//                $connection_2.close();
+//                java.lang.String $et_5 = $connection_2.getExceptionType();
+//                if ($et_5 != null)
+//                {
+//                    throw org.apache.geronimo.interop.rmi.iiop.SystemExceptionFactory.getException($connection_2.getException());
+//                }
+//                boolean $djc_result;
+//                $djc_result = $input_4.readBoolean();
+//                return $djc_result;
+//            }
+//            catch (org.apache.geronimo.interop.rmi.iiop.client.RetryInvokeException $ex_6)
+//            {
+//                if ($retry == 3)
+//                {
+//                    throw $ex_6.getRuntimeException();
+//                }
+//            }
+//        }
+
+        //JParameter jpID = new JParameter( java.lang.String.class, "id" );
+        JMethod jm = jc.newMethod(jrc, name, jparms, excepts);
+
+        JLocalVariable jlvKey = jm.newLocalVariable(Object.class, "$key", new JExpression(new JCodeStatement("$getRequestKey()")));
+        JLocalVariable jlvRetry = jm.newLocalVariable(int.class, "$retry");
+
+        JForStatement jfs = new JForStatement(new JCodeStatement(jlvRetry.getName() + " = 0"),
+                                              new JExpression(new JCodeStatement(" ; ")),
+                                              new JCodeStatement(jlvRetry.getName() + "++"));
+
+        jm.addStatement(jfs);
+
+        JTryCatchFinallyStatement tcfs = new JTryCatchFinallyStatement();
+        JTryStatement ts = tcfs.getTryStatement();
+
+        JBlockStatement jbs = (JBlockStatement) ts;
+
+        JLocalVariable jlvConn = jbs.newLocalVariable(org.apache.geronimo.interop.rmi.iiop.client.Connection.class, "$conn");
+        JLocalVariable jlvOutput = jbs.newLocalVariable(org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream.class, "$out");
+        JLocalVariable jlvEt = jbs.newLocalVariable(java.lang.String.class, "$et");
+        JLocalVariable jlvInput = null;
+
+        JLocalVariable jlvRc = null;
+        if (jrc != null && jrc.getType() != void.class) {
+            jlvRc = jbs.newLocalVariable(jrc.getType(), "$rc");
+            jlvInput = jbs.newLocalVariable(org.apache.geronimo.interop.rmi.iiop.ObjectInputStream.class, "$in");
+        }
+
+        jbs.addStatement(new JCodeStatement(jlvConn.getName() + " = this.$connect();"));
+        jbs.addStatement(new JCodeStatement(jlvOutput.getName() + " = " + jlvConn.getName() + "." + _outStreamName + "();"));
+
+        String writeMethod = null;
+        String writeCall = "";
+        for (int i = 0; i < jparms.length; i++) {
+            writeMethod = getWriteMethod(jparms[i]);
+
+            if (writeMethod != null) {
+                writeCall = writeMethod + "( " + jparms[i].getName() + " )";
+            } else {
+                writeCall = "writeObject( " + _vtc.getValueTypeVarName(jc, jparms[i]) + ", " + jparms[i].getName() + ")";
+            }
+
+            jbs.addStatement(new JCodeStatement(jlvOutput.getName() + "." + writeCall + ";"));
+        }
+
+        jbs.addStatement(new JCodeStatement(jlvConn.getName() + ".invoke(this, \"" + name + "\", " + jlvKey.getName() + ", $retry);"));
+        if (jlvRc != null) {
+            jbs.addStatement(new JCodeStatement(jlvInput.getName() + " = " + jlvConn.getName() + "." + _inStreamName + "();"));
+        }
+        jbs.addStatement(new JCodeStatement(jlvConn.getName() + ".forget(" + jlvKey.getName() + ");"));
+        jbs.addStatement(new JCodeStatement(jlvConn.getName() + ".close();"));
+        jbs.addStatement(new JCodeStatement(jlvEt.getName() + " = " + jlvConn.getName() + ".getExceptionType();"));
+
+        JIfElseIfElseStatement jiefs = new JIfElseIfElseStatement(new JExpression(new JCodeStatement(jlvEt.getName() + " != null")));
+        JIfStatement jis = jiefs.getIfStatement();
+        jis.addStatement(new JCodeStatement("throw org.apache.geronimo.interop.rmi.iiop.SystemExceptionFactory.getException(" + jlvConn.getName() + ".getException());"));
+        jbs.addStatement(jiefs);
+
+        if (jlvRc != null) {
+            String readMethod = getReadMethod(jlvRc);
+            String readCall = "";
+
+            if (readMethod != null) {
+                readCall = jlvInput.getName() + "." + readMethod + "()";
+            } else {
+                readCall = "(" + jlvRc.getTypeDecl() + ")" + jlvInput.getName() + "." + "readObject( " + _vtc.getValueTypeVarName(jc, jlvRc) + ")";
+            }
+
+            jbs.addStatement(new JCodeStatement(jlvRc.getName() + " = " + readCall + ";"));
+            jbs.addStatement(new JCodeStatement("return " + jlvRc.getName() + ";"));
+        }
+
+        ts.addStatement(jbs);
+
+        JVariable jv = new JVariable(org.apache.geronimo.interop.rmi.iiop.client.RetryInvokeException.class, "$ex");
+        JCatchStatement cs = tcfs.newCatch(jv);
+
+        jiefs = new JIfElseIfElseStatement(new JExpression(new JCodeStatement(jlvRetry.getName() + " == 3")));
+        jis = jiefs.getIfStatement();
+        jis.addStatement(new JCodeStatement("throw " + jv.getName() + ".getRuntimeException();"));
+        cs.addStatement(jiefs);
+
+        jfs.addStatement(tcfs);
+    }
+
+    // public methods
+
+    public void addMethod_is_a(JClass jc) {
+        JParameter jpID = new JParameter(java.lang.String.class, "id");
+        addMethod(jc, new JReturnType(boolean.class),
+                  "_is_a",
+                  new JParameter[]{jpID},
+                  (Class[]) null);
+
+    }
+
+    public void addMethod(Method m, JClass jc) {
+        String name = m.getName();
+        JParameter[] sparms = getMethodParms(m);
+
+        addMethod(jc, new JReturnType(m.getReturnType()),
+                  name,
+                  sparms,
+                  m.getExceptionTypes());
+
+    }
+
+    protected Method[] getMethods() {
+        Method myMethods[] = _riClass.getDeclaredMethods();
+        Method myOpsMethods[] = null;
+        Class myInterfaces[] = _riClass.getInterfaces();
+
+        if (myInterfaces != null && myInterfaces.length > 0) {
+            String opsName = _riClass.getName() + "Operations";
+
+            for (int i = 0; i < myInterfaces.length; i++) {
+                if (myInterfaces[i].getName().equals(opsName)) {
+                    myOpsMethods = myInterfaces[i].getDeclaredMethods();
+                    break;
+                }
+            }
+        }
+
+        Method m[] = null;
+
+        if (myOpsMethods == null) {
+            m = myMethods;
+        } else {
+            m = new Method[myMethods.length + myOpsMethods.length];
+            System.arraycopy(myMethods, 0, m, 0, myMethods.length);
+            System.arraycopy(myOpsMethods, 0, m, myMethods.length, myOpsMethods.length);
+        }
+
+        return m;
+    }
+
+    public void generate()
+            throws Exception {
+        _vtc.clear();
+
+        if (_simpleIDL) {
+            _inStreamName = "getSimpleInputStream";
+            _outStreamName = "getSimpleOutputStream";
+        }
+
+        JavaGenerator jg = new JavaGenerator(_genOptions);
+
+        String className;
+        JPackage p = new JPackage(JavaClass.getNamePrefix(_stubClassName));
+        className = JavaClass.getNameSuffix(_stubClassName);
+
+        JClass jc = p.newClass(className);
+        jc.addImport("org.apache.geronimo.interop.rmi.iiop", "ObjectRef");
+        jc.setExtends("ObjectRef");
+        jc.addImplements(_riClass.getName());
+
+        JField idsField = jc.newField(String[].class, "_ids", new JExpression(new JCodeStatement("{ \"" + _riClass.getName() + "\", \"RMI:" + _riClass.getName() + ":0000000000000000\"}")), true);
+
+        JConstructor jcCon = jc.newConstructor((JParameter[]) null, (Class[]) null);
+        jcCon.addStatement(new JCodeStatement("super();"));
+
+        addMethod_is_a(jc);
+
+        Method m[] = null;
+        m = getMethods();
+        for (int i = 0; m != null && i < m.length; i++) {
+            addMethod(m[i], jc);
+        }
+
+        jg.generate(p);
+    }
+
+    public void compile()
+            throws Exception {
+        String className = _riClass.getName();
+        String stubClassName = JavaClass.addPackageSuffix(className, "iiop_stubs");
+        String stubPackage = JavaClass.getNamePrefix(stubClassName);
+
+        System.out.println("Compiling Package: " + stubPackage);
+        System.out.println("Compiling Stub: " + stubClassName);
+
+        String javac = "javac -d ../classes -classpath ../classes;D:/Dev/3rdparty.jag/ejb21/ejb-2_1-api.jar " + stubPackage.replace('.', '/') + "/*.java";
+
+        ProcessUtil pu = ProcessUtil.getInstance();
+        pu.setEcho(System.out);
+        pu.run(javac, (String[]) null, "./src");
+    }
+
+    public Class getStubClass() {
+        System.out.println("StubCompiler.getStubClass(): riClass: " + _riClass);
+
+        if (_stubClass == null) {
+            try {
+                _stubClass = Class.forName(_stubClassName);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+
+            try {
+                if (_stubClass == null) {
+                    generate();
+                    compile();
+                    _stubClass = Class.forName(_stubClassName);
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+
+        return _stubClass;
+    }
+
+    public static void main(String args[])
+            throws Exception {
+        boolean generate = false;
+        boolean compile = false;
+        boolean loadclass = false;
+        boolean simpleidl = false;
+        List interfaces = new LinkedList();
+        GenOptions go = new GenOptions();
+
+        go.setGenDir("./");
+        go.setOverwrite(false);
+        go.setVerbose(false);
+
+        for (int i = 0; i < args.length; i++) {
+            if (args[i].equals("-g")) {
+                generate = true;
+            } else if (args[i].equals("-c")) {
+                compile = true;
+            } else if (args[i].equals("-l")) {
+                loadclass = true;
+            } else if (args[i].equals("-s")) {
+                simpleidl = true;
+            } else if (args[i].equals("-d") && ((i + 1) < args.length)) {
+                go.setGenDir(args[++i]);
+            } else if (args[i].equals("-v")) {
+                go.setVerbose(true);
+            } else if (args[i].equals("-o")) {
+                go.setOverwrite(true);
+            } else if (args[i].startsWith("-")) {
+                System.out.println("Warning: Ignoring unrecognized options: '" + args[i] + "'");
+            } else {
+                interfaces.add(args[i]);
+            }
+        }
+
+        Iterator i = interfaces.iterator();
+        while (i != null && i.hasNext()) {
+            String intfName = (String) i.next();
+
+            if (intfName.startsWith("RMI:")) {
+                simpleidl = false;
+                intfName = intfName.substring(4);
+            } else if (intfName.startsWith("IDL:")) {
+                simpleidl = true;
+                intfName = intfName.substring(4);
+            }
+
+            Class riClass = Class.forName(intfName);
+            StubCompiler sg = new StubCompiler(riClass, go);
+            sg.setSimpleIDL(simpleidl);
+
+            if (generate) {
+                sg.generate();
+            }
+
+            if (compile) {
+                sg.compile();
+            }
+
+            if (loadclass) {
+                Class c = sg.getStubClass();
+                System.out.println("StubClass: " + c);
+            }
+        }
+
+        // sg.setSimpleIDL( true );
+        // sg.generate( "org.apache.geronimo.interop.rmi.iiop.NameServiceOperations");
+    }
+
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/StubCompiler.txt
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/StubCompiler.txt?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/StubCompiler.txt	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,571 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop.client;
+
+import org.apache.geronimo.interop.*;
+import org.apache.geronimo.interop.attributes.*;
+import org.apache.geronimo.interop.compiler.*;
+import org.apache.geronimo.interop.properties.*;
+import org.apache.geronimo.interop.rmi.*;
+import org.apache.geronimo.interop.rmi.iiop.*;
+import org.apache.geronimo.interop.util.*;
+import java.lang.reflect.*;
+import java.io .*;
+import java.util.*;
+
+public class StubCompiler
+{
+    //public static final Component component = new Component(StubCompiler.class);
+
+    public static StubCompiler getInstance(Class remoteInterface)
+    {
+        //StubCompiler sc = (StubCompiler)component.getInstance();
+        StubCompiler sc = new StubCompiler();
+        sc.init(remoteInterface);
+        return sc;
+    }
+
+    // private data
+   
+    private Class _remoteInterface;
+
+    private static HashMap _readMethods;
+    private static HashMap _writeMethods;
+    private static HashMap _overloadTypes;
+
+    static
+    {
+        _readMethods = new HashMap();
+        _readMethods.put("boolean", "readBoolean");
+        _readMethods.put("char", "readChar");
+        _readMethods.put("byte", "readByte");
+        _readMethods.put("short", "readShort");
+        _readMethods.put("int", "readInt");
+        _readMethods.put("long", "readLong");
+        _readMethods.put("float", "readFloat");
+        _readMethods.put("double", "readDouble");
+
+        _writeMethods = new HashMap();
+        _writeMethods.put("boolean", "writeBoolean");
+        _writeMethods.put("char", "writeChar");
+        _writeMethods.put("byte", "writeByte");
+        _writeMethods.put("short", "writeShort");
+        _writeMethods.put("int", "writeInt");
+        _writeMethods.put("long", "writeLong");
+        _writeMethods.put("float", "writeFloat");
+        _writeMethods.put("double", "writeDouble");
+
+        _overloadTypes = new HashMap();
+        _overloadTypes.put("boolean", "boolean");
+        _overloadTypes.put("byte", "octet");
+        _overloadTypes.put("char", "wchar");
+        _overloadTypes.put("double", "double");
+        _overloadTypes.put("float", "float");
+        _overloadTypes.put("int", "long");
+        _overloadTypes.put("long", "long_long");
+        _overloadTypes.put("short", "short");
+        _overloadTypes.put("java.lang.Class", "javax_rmi_CORBA.ClassDesc");
+        _overloadTypes.put("java.lang.String", "CORBA.WStringValue");
+        _overloadTypes.put("org.omg.CORBA.Object", "Object");
+        _overloadTypes.put("org.omg.CORBA.Any", "org_omg_boxedIDL_CORBA.Any");
+        _overloadTypes.put("org.omg.CORBA.TypeCode", "org_omg_boxedIDL_CORBA.TypeCode");
+    }
+
+    // public methods
+
+    protected void init( Class remoteInterface )
+    {
+        _remoteInterface = remoteInterface;
+    }
+
+    public static void main(String[] args)
+    {
+        for (int i = 0; i < args.length; i++)
+        {
+            String className = args[i];
+            Class remoteInterface = ThreadContext.loadClass(className);
+            StubCompiler sc = new StubCompiler();
+            sc.init( remoteInterface );
+            sc.getStubClass();
+        }
+    }
+
+    public Class getStubClass()
+    {
+        ClassWriter cw = getStubClassWriter();
+        return cw.compile(_remoteInterface);
+    }
+
+    public String getStubClassName()
+    {
+        String className = _remoteInterface.getName();
+        return JavaClass.addPackageSuffix(className, "iiop_stubs");
+    }
+
+    public ClassWriter getStubClassWriter()
+    {
+        String stubClassName = getStubClassName();
+        boolean isCorbaStub = ! java.rmi.Remote.class.isAssignableFrom(_remoteInterface);
+        String simple = isCorbaStub ? "Simple" : "";
+
+        ClassWriter cw = new ClassWriter(stubClassName);
+        cw.setAbstract();
+        cw.setSuperclass(ObjectRef.class);
+        cw.addImplements(_remoteInterface);
+        cw.beginClass();
+
+        StaticField attributesField = cw.newStaticField(Attribute[].class, "$attributes", "{}");
+        attributesField.setPublic();
+        attributesField.setFinal();
+
+        StaticField componentField = cw.newStaticField(Component.class, "$component",
+            cw.newObject("org.apache.geronimo.interop.Component", stubClassName + ".class"));
+        componentField.setPublic();
+        componentField.setFinal();
+
+        MethodWriter mw = cw.newMethod(stubClassName, "$getInstance");
+        mw.setStatic();
+        mw.beginMethod();
+        mw.returnValue(mw.cast(stubClassName, mw.invoke("$component.getInstance")));
+        mw.endMethod();
+
+        mw = cw.newMethod(String.class, "$getID");
+        mw.beginMethod();
+        String id = "RMI:" + _remoteInterface.getName() + ":0000000000000000";
+        // TODO: IDL type ids???
+        mw.returnValue(mw.string(id));
+        mw.endMethod();
+
+        HashMap vtMap = new HashMap();
+
+        Method[] methods = getRemoteMethods();
+        for (int i = 0; i < methods.length; i++)
+        {
+            Method method = methods[i];
+            String remoteMethodName = getOperation(method); // TODO: RMI-IIOP name
+            mw = cw.newMethod(method);
+            ParameterList parameters = mw.getParameterList();
+            ExceptionList exceptions = mw.getExceptionList();
+            String returnType = mw.getReturnType();
+            mw.beginMethod();
+            LocalVariable request = mw.newLocalVariable(Connection.class, "connection",
+                mw.invoke("this.$connect"));
+            if (parameters.size() != 0)
+            {
+                LocalVariable output = mw.newLocalVariable(org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream.class,
+                    "output", mw.invoke(request + ".get" + simple + "OutputStream"));
+                Class[] parameterTypes = method.getParameterTypes();
+                int pi = 0;
+                for (Iterator j = parameters.iterator(); j.hasNext(); pi++)
+                {
+                    MethodParameter mp = (MethodParameter)j.next();
+                    String name = mp.name;
+                    String type = mp.type;
+                    if (isHolder(parameterTypes[pi]))
+                    {
+                        name = name + ".value";
+                        type = getHolderValueType(parameterTypes[pi]);
+                    }
+                    String writeMethod = getWriteMethod(type);
+                    if (writeMethod.equals("writeObject"))
+                    {
+                        Integer vtIndex = getValueTypeIndex(cw, vtMap, type);
+                        mw.call(output + "." + writeMethod, "type$" + vtIndex, name);
+                    }
+                    else
+                    {
+                        mw.call(output + "." + writeMethod, name);
+                    }
+                }
+            }
+            mw.call(request + ".invoke", "this", mw.string(remoteMethodName));
+            LocalVariable input = mw.newLocalVariable(org.apache.geronimo.interop.rmi.iiop.ObjectInputStream.class,
+                "input", mw.invoke(request + ".get" + simple + "InputStream"));
+            mw.call(request + ".close");
+            LocalVariable et = mw.newLocalVariable(String.class, "et",
+                mw.invoke(request + ".getExceptionType"));
+            mw.beginIf(et + " != null");
+            for (Iterator j = exceptions.iterator(); j.hasNext();)
+            {
+                String exception = (String)j.next();
+                // TODO: generate correct repository ids for user exceptions
+                mw.beginIf(mw.invoke(et + ".equals", mw.string(exception)));
+                Integer vtIndex = getValueTypeIndex(cw, vtMap, exception);
+                mw.throwCheckedException(mw.cast(exception, mw.invoke(input + ".readException", "type$" + vtIndex)));
+                mw.endIf();
+            }
+            if (isCorbaStub
+                || method.getName().equals("_is_a"))
+            {
+                mw.throwRuntimeException(mw.invoke("org.apache.geronimo.interop.rmi.iiop.SystemExceptionFactory.getException",
+                    mw.invoke(request + ".getException")));
+            }
+            else
+            {
+                mw.throwCheckedException(mw.invoke("org.apache.geronimo.interop.rmi.iiop.RemoteExceptionFactory.getException",
+                    mw.invoke(request + ".getException")));
+            }
+            mw.endIf();
+            if (method.getReturnType() != void.class)
+            {
+                String readMethod = getReadMethod(returnType);
+                mw.newResult();
+                if (readMethod.equals("readObject"))
+                {
+                    Integer vtIndex = getValueTypeIndex(cw, vtMap, returnType);
+                    mw.setResult(mw.cast(returnType, mw.invoke(input + "." + readMethod, "type$" + vtIndex)));
+                }
+                else
+                {
+                    mw.setResult(mw.invoke(input + "." + readMethod));
+                }
+                mw.returnResult();
+            }
+            mw.endMethod();
+        }
+        cw.endClass();
+        return cw;
+    }
+
+    public String getHolderValueType(Class c)
+    {
+        try
+        {
+            Field f = c.getField("value");
+            return JavaType.getName(f.getType());
+        }
+        catch (Exception ex)
+        {
+            throw new SystemException(c.getName() + ".value", ex);
+        }
+    }
+
+    public Method[] getRemoteMethods()
+    {
+        Method[] methods = _remoteInterface.getMethods();
+        TreeMap map = new TreeMap();
+        int n = methods.length;
+        for (int i = 0; i < n; i++)
+        {
+            Method method = methods[i];
+            String methodSig = JavaMethod.getShortSignature(method);
+            if (map.get(methodSig) != null)
+            {
+                continue;
+            }
+            String methodName = method.getName();
+            if (methodName.startsWith("_"))
+            {
+                if (! methodName.equals("_is_a"))
+                {
+                    continue;
+                }
+            }
+            map.put(methodSig, method);
+        }
+        n = map.size();
+        methods = new Method[n];
+        Iterator v = map.values().iterator();
+        for (int i = 0; i < n; i++)
+        {
+            Method method = (Method)v.next();
+            methods[i] = method;
+        }
+        return methods;
+    }
+
+    /**
+     ** Return the RMI-IIOP operation name for a remote method.
+     **/
+    public String getOperation(Method method)
+    {
+        if (! isOverloaded(method))
+        {
+            if (isGetAttribute(method) || isSetAttribute(method))
+            {
+                String prefix = method.getName().startsWith("set") ? "set" : "get";
+                String attribute = getAttributeName(method);
+                return "_" + prefix + "_" + attribute;
+            }
+            return method.getName();
+        }
+        Class[] types = method.getParameterTypes();
+        String suffix = "";
+        if (types.length == 0)
+        {
+            suffix = "__";
+        }
+        else
+        {
+            for (int i = 0; i < types.length; i++)
+            {
+                Class type = types[i];
+                suffix += "__" + overload(type, 0);
+            }
+        }
+        return method.getName() + suffix;
+    }
+
+    public String getReadMethod(String type)
+    {
+        String m = (String)_readMethods.get(type);
+        if (m == null)
+        {
+            m = "readObject";
+        }
+        return m;
+    }
+
+    public String getWriteMethod(String type)
+    {
+        String m = (String)_writeMethods.get(type);
+        if (m == null)
+        {
+            m = "writeObject";
+        }
+        return m;
+    }
+
+    public Integer getValueTypeIndex(ClassWriter cw, HashMap vtMap, String type)
+    {
+        Integer vtIndex = (Integer)vtMap.get(type);
+        if (vtIndex == null)
+        {
+            vtIndex = new Integer(vtMap.size() + 1);
+            vtMap.put(type, vtIndex);
+            StaticField vt = cw.newStaticField(ValueType.class, "type$" + vtIndex,
+                cw.invoke("org.apache.geronimo.interop.rmi.iiop.ValueType.getInstance",
+                    type + ".class"));
+            vt.setPrivate();
+            vt.setFinal();
+        }
+        return vtIndex;
+    }
+
+    public boolean isHolder(Class c)
+    {
+        if (c.getName().endsWith("Holder"))
+        {
+            if (org.omg.CORBA.portable.Streamable.class.isAssignableFrom(c))
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    //public boolean isOutParameter(Method method, int parameter)
+    public boolean isOutParameter(Component comp, Method method, int parameter)
+    {
+        AttributeList attributes = comp.getAttributes();
+        for (Iterator i = attributes.iterator(); i.hasNext();)
+        {
+            Attribute a = (Attribute)i.next();
+            /*
+             * How does an EJB have an out parameter?
+
+            if (a instanceof IdlOutAttribute)
+            {
+                IdlOutAttribute ioa = (IdlOutAttribute)a;
+                if (ioa.matches(method) && ioa.getParameterIndex() == parameter)
+                {
+                    return true;
+                }
+            }
+            */
+        }
+
+        return false;
+    }
+
+    public boolean isOverloaded(Method method)
+    {
+        String name = method.getName();
+        String sig1 = null;
+        Method[] methods = _remoteInterface.getMethods();
+        for (int i = 0; i < methods.length; i++)
+        {
+            Method otherMethod = methods[i];
+            if (otherMethod.getName().equals(name))
+            {
+                if (sig1 == null)
+                {
+                    sig1 = JavaMethod.getShortSignature(method);
+                }
+                String sig2 = JavaMethod.getShortSignature(otherMethod);
+                if (! sig1.equals(sig2))
+                {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    // protected methods
+
+    protected String getAttributeName(Method method)
+    {
+        String name = method.getName();
+        if (name.startsWith("get") || name.startsWith("set"))
+        {
+            return StringUtil.getLowerFirstIfFirst2NotUpper(name.substring(3));
+        }
+        else if (name.startsWith("is"))
+        {
+            return StringUtil.getLowerFirstIfFirst2NotUpper(name.substring(2));
+        }
+        else
+        {
+            throw new IllegalArgumentException("method = " + method);
+        }
+    }
+
+    private boolean isGetAttribute(Method method)
+    {
+        String name = method.getName();
+        if (name.startsWith("get"))
+        {
+            if (name.length() < 4)
+            {
+                return false;
+            }
+        }
+        else if (name.startsWith("is"))
+        {
+            if (name.length() < 3)
+            {
+                return false;
+            }
+        }
+        else
+        {
+            return false;
+        }
+        return method.getExceptionTypes().length == 0
+            && method.getParameterTypes().length == 0
+            && method.getReturnType() != null;
+    }
+
+    protected boolean isSetAttribute(Method method)
+    {
+        String name = method.getName();
+        if (name.startsWith("set"))
+        {
+            if (name.length() < 4)
+            {
+                return false;
+            }
+        }
+        String attribute = name.substring(3);
+        Method getMethod;
+        try
+        {
+            String getAttribute = "get" + attribute;
+            getMethod = _remoteInterface.getMethod(getAttribute, new Class[0]);
+        }
+        catch (Exception noGetAttribute)
+        {
+            try
+            {
+                String isAttribute  = "is" + attribute;
+                getMethod = _remoteInterface.getMethod(isAttribute, new Class[0]);
+            }
+            catch (Exception noIsAttribute)
+            {
+                return false;
+            }
+        }
+        if (getMethod.getExceptionTypes().length != 0)
+        {
+            return false;
+        }
+        Class getReturnType = getMethod.getReturnType();
+        if (getReturnType == null)
+        {
+            return false;
+        }
+        if (method.getExceptionTypes().length != 0)
+        {
+            return false;
+        }
+        Class[] setParameters = method.getParameterTypes();
+        if (setParameters.length != 1)
+        {
+            return false;
+        }
+        Class setParameterType = setParameters[0];
+        return setParameterType == getReturnType;
+    }
+
+    /**
+     ** Get mangled parameter type for RMI-IIOP overloading.
+     **/
+    protected String overload(Class type)
+    {
+        return overload(type, 0);
+    }
+
+    /**
+     ** Get mangled parameter type for RMI-IIOP overloading.
+     **/
+    protected String overload(Class type, int dim)
+    {
+        String typeName = JavaType.getName(type);
+        String overload = (String)_overloadTypes.get(typeName);
+        boolean wasInOverloadTypes = false;
+        if (overload != null)
+        {
+            typeName = overload;
+            overload = null;
+            wasInOverloadTypes = true;
+        }
+        if (type.isArray())
+        {
+            dim = 1;
+            Class element = type.getComponentType();
+            while (element.isArray())
+            {
+                dim++;
+                element = element.getComponentType();
+            }
+            return "org_omg_boxedRMI_" + overload(element, dim);
+        }
+        else
+        {
+            if (dim != 0)
+            {
+                int pos = typeName.lastIndexOf(".");
+                if (pos != -1)
+                {
+                    typeName = typeName.substring(0, pos) + "_seq" + dim
+                               + "_" + typeName.substring(pos + 1);
+                }
+            }
+            if (overload == null && ! wasInOverloadTypes)
+            {
+                if (org.omg.CORBA.portable.IDLEntity.class.isAssignableFrom(type))
+                {
+                    // TODO: don't do this for valuetype as IDL entity?
+                    typeName = "org_omg_boxedIDL_" + typeName;
+                }
+            }
+            return typeName.replace('.', '_');
+        }
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/StubFactory.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/StubFactory.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/StubFactory.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,140 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop.compiler;
+
+import java.util.HashMap;
+
+import org.apache.geronimo.interop.SystemException;
+import org.apache.geronimo.interop.rmi.iiop.ObjectRef;
+import org.apache.geronimo.interop.util.JavaClass;
+import org.apache.geronimo.interop.util.ThreadContext;
+
+
+public class StubFactory {
+    protected static StubFactory _sf;
+
+    protected StubFactory() {
+    }
+
+    public static StubFactory getInstance() {
+        if (_sf == null) {
+            synchronized (StubFactory.class) {
+                if (_sf == null) {
+                    _sf = new StubFactory();
+                    _sf.init();
+                }
+            }
+        }
+
+        return _sf;
+    }
+
+    // private data
+
+    private static HashMap _stubClassMap;
+
+    // internal methods
+
+    protected void init() {
+        _stubClassMap = new HashMap();
+    }
+
+    protected Class loadStub(Class remoteInterface) {
+        System.out.println("StubFactory.loadStub(): remoteInterface: " + remoteInterface);
+        String className = remoteInterface.getName();
+        String stubClassName = JavaClass.addPackageSuffix(className, "iiop_stubs");
+        System.out.println("StubFactory.loadStub(): stubClassName: " + stubClassName);
+
+        Class sc = null;
+        //
+        // Try to load the stub.  No need to generate if the stub is already present.
+        //
+        try {
+            sc = Class.forName(stubClassName + "_Stub");
+        } catch (ClassNotFoundException e) {
+            e.printStackTrace();
+        }
+
+
+        if (sc == null) {
+            //
+            // Try generating stub class now.
+            //
+
+            StubCompiler stubCompiler = new StubCompiler(remoteInterface);
+            System.out.println("StubFactory.loadStub(): stubCompiler: " + stubCompiler);
+            sc = stubCompiler.getStubClass();
+            System.out.println("StubFactory.loadStub(): sc: " + sc);
+        }
+
+        /*
+        if (sc.stubClass != null)
+        {
+            try
+            {
+                sc.getInstance = sc.stubClass.getMethod("$getInstance", ArrayUtil.EMPTY_CLASS_ARRAY);
+            }
+            catch (Exception ex)
+            {
+                throw new SystemException(ex);
+            }
+        }
+        */
+
+        return sc;
+    }
+
+    // public methods
+
+    public ObjectRef getStub(Class remoteInterface) {
+        System.out.println("StubFactory.getStub(): remoteInterface: " + remoteInterface);
+        try {
+            Class sc = (Class) _stubClassMap.get(remoteInterface);
+            System.out.println("StubFactory.getStub(): sc: " + sc);
+            if (sc == null) {
+                synchronized (_stubClassMap) {
+                    sc = (Class) _stubClassMap.get(remoteInterface);
+                    if (sc == null) {
+                        sc = loadStub(remoteInterface);
+                        System.out.println("StubFactory.getStub(): sc: " + sc);
+                        _stubClassMap.put(remoteInterface, sc);
+                    }
+                }
+            }
+
+            if (sc == null) {
+                throw new SystemException("Error: Unable to load stub for remote interface: " + remoteInterface);
+            }
+
+            java.lang.Object sobj = sc.newInstance();
+
+            if (!(sobj instanceof ObjectRef)) {
+                throw new SystemException("Error: Stub for remote interface: '" + remoteInterface + "' is not a valid ObjectRef.");
+            }
+
+            return (ObjectRef) sobj;
+            //return (ObjectRef)sc.getInstance.invoke(sc.stubClass, ArrayUtil.EMPTY_OBJECT_ARRAY);
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+    }
+
+    public Object getStub(String remoteInterface) {
+        return getStub(ThreadContext.loadClass(remoteInterface));
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/ValueTypeContext.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/ValueTypeContext.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/compiler/ValueTypeContext.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,58 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop.compiler;
+
+import java.lang.reflect.Modifier;
+import java.util.HashMap;
+
+import org.apache.geronimo.interop.generator.JClass;
+import org.apache.geronimo.interop.generator.JCodeStatement;
+import org.apache.geronimo.interop.generator.JExpression;
+import org.apache.geronimo.interop.generator.JField;
+import org.apache.geronimo.interop.generator.JVariable;
+
+
+public class ValueTypeContext {
+    protected int _vTypeId = 0;
+    protected HashMap _vTypeMap = new HashMap(20);
+
+    public ValueTypeContext() {
+        clear();
+    }
+
+    public void clear() {
+        _vTypeId = 0;
+        _vTypeMap.clear();
+    }
+
+    protected String getValueTypeVarName(JClass jc, JVariable jv) {
+        String rc = null;
+
+        rc = (String) _vTypeMap.get(jv.getTypeDecl());
+
+        if (rc == null) {
+            rc = "vt$" + _vTypeId++;
+            _vTypeMap.put(jv.getTypeDecl(), rc);
+
+            JField vtField = jc.newField(org.apache.geronimo.interop.rmi.iiop.ValueType.class, rc, new JExpression(new JCodeStatement("org.apache.geronimo.interop.rmi.iiop.ValueType.getInstance( " + jv.getTypeDecl() + ".class )")));
+            vtField.setModifiers(Modifier.PRIVATE | Modifier.STATIC | Modifier.FINAL);
+        }
+
+        return rc;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/MessageHandler.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/MessageHandler.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/MessageHandler.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,424 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop.server;
+
+import java.net.InetAddress;
+import java.net.Socket;
+
+import org.apache.geronimo.interop.GIOP.*;
+import org.apache.geronimo.interop.IOP.*;
+import org.apache.geronimo.interop.SystemException;
+import org.apache.geronimo.interop.adapter.Adapter;
+import org.apache.geronimo.interop.adapter.AdapterManager;
+import org.apache.geronimo.interop.naming.NameService;
+import org.apache.geronimo.interop.properties.BooleanProperty;
+import org.apache.geronimo.interop.properties.SystemProperties;
+import org.apache.geronimo.interop.rmi.iiop.BadMagicException;
+import org.apache.geronimo.interop.rmi.iiop.CdrInputStream;
+import org.apache.geronimo.interop.rmi.iiop.CdrOutputStream;
+import org.apache.geronimo.interop.rmi.iiop.GiopMessage;
+import org.apache.geronimo.interop.rmi.iiop.ListenerInfo;
+import org.apache.geronimo.interop.rmi.iiop.UnsupportedProtocolVersionException;
+import org.apache.geronimo.interop.util.ExceptionUtil;
+import org.apache.geronimo.interop.util.ThreadContext;
+import org.apache.geronimo.interop.util.UTF8;
+
+
+public class MessageHandler extends Thread {
+    public static MessageHandler getInstance(ListenerInfo listenerInfo, Socket socket) {
+        MessageHandler object = new MessageHandler();
+        object.init(listenerInfo, socket);
+        return object;
+    }
+
+    // -----------------------------------------------------------------------
+    // properties
+    // -----------------------------------------------------------------------
+
+
+    public static final BooleanProperty simpleIDLProperty =
+            new BooleanProperty(SystemProperties.class, "org.apache.geronimo.interop.simpleIDL");
+
+    public static BooleanProperty writeSystemExceptionStackTraceProperty =
+            new BooleanProperty(SystemProperties.class, "org.apache.geronimo.interop.rmi.iiop.writeSystemExceptionStackTrace")
+            .defaultValue(true);
+
+    // -----------------------------------------------------------------------
+    // private data
+    // -----------------------------------------------------------------------
+
+    private static final boolean SIMPLE_IDL = simpleIDLProperty.getBoolean();
+
+    private static boolean _writeSystemExceptionStackTrace = writeSystemExceptionStackTraceProperty.getBoolean();
+
+    private static RequestHandler[] _handlers = new RequestHandler[128];
+
+    private NameService _nameService;
+    private ListenerInfo _listenerInfo;
+    private java.net.Socket _socket;
+    private java.io.InputStream _socketIn;
+    private java.io.OutputStream _socketOut;
+    private String _clientHostName;
+    private String _clientHostAddress;
+    private String _clientInfo;
+    private org.apache.geronimo.interop.rmi.iiop.ObjectInputStream _objectInput;
+    private org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream _objectOutput;
+    private org.apache.geronimo.interop.rmi.iiop.ObjectInputStream _simpleInput;
+    private org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream _simpleOutput;
+
+    // -----------------------------------------------------------------------
+    // public methods
+    // -----------------------------------------------------------------------
+
+    public static void registerHandler(char keyType, RequestHandler handler) {
+        _handlers[keyType] = handler;
+    }
+
+    public void run() {
+        ThreadContext.setDefaultRmiHost(_listenerInfo.host);
+        ThreadContext.setDefaultRmiPort(_listenerInfo.port);
+        boolean firstMessage = true;
+        CdrInputStream input = CdrInputStream.getInstance();
+        CdrOutputStream output = CdrOutputStream.getInstance();
+        CdrOutputStream results = CdrOutputStream.getInstance();
+        for (; ;) {
+            boolean sendResponse = true;
+            GiopMessage inputMessage;
+            try {
+                inputMessage = input.receive_message(_socketIn, _clientInfo);
+                firstMessage = false;
+            } catch (BadMagicException ex) {
+                if (firstMessage) {
+                    warnBadMagic(_clientInfo, ex);
+                } else {
+                    warnBadMagicBadSize(_clientInfo, ex);
+                }
+                closeSocket();
+                return;
+            } catch (UnsupportedProtocolVersionException ex) {
+                warnGiopVersion(_clientInfo, ex);
+                closeSocket();
+                return;
+            } catch (Exception ex) {
+                if (input.getOffset() > 0) {
+                    ex.printStackTrace();
+                    warnReceiveFailed(_clientInfo, ex);
+                }
+                // Otherwise client shutdown was not in the middle of a
+                // request, i.e. probably 'normal' and unworthy of a
+                // log message.
+                closeSocket();
+                return;
+            }
+            output.setGiopVersion(input.getGiopVersion());
+            switch (inputMessage.type) {
+                case MsgType_1_1._Request:
+                    processRequest(input, output, results, inputMessage.request);
+                    if ((inputMessage.request.response_flags & 1) == 0) {
+                        sendResponse = false; // oneway request
+                    }
+                    break;
+                case MsgType_1_1._LocateRequest:
+                    processLocateRequest(output, inputMessage.locateRequest);
+                    break;
+                default:
+                    throw new SystemException("TODO: message type = " + inputMessage.type);
+            }
+            if (sendResponse) {
+                try {
+                    output.send_message(_socketOut, _clientInfo);
+                } catch (Exception ex) {
+                    warnSendFailed(_clientInfo, ex);
+                    closeSocket();
+                    return;
+                }
+            }
+            input.reset();
+            output.reset();
+            results.reset();
+        }
+    }
+
+    // -----------------------------------------------------------------------
+    // protected methods
+    // -----------------------------------------------------------------------
+
+    protected void init(ListenerInfo listenerInfo, Socket socket) {
+        setDaemon(true);
+        _nameService = NameService.getInstance();
+        _listenerInfo = listenerInfo;
+        _socket = socket;
+        try {
+            _socketIn = _socket.getInputStream();
+            _socketOut = _socket.getOutputStream();
+            InetAddress addr = _socket.getInetAddress();
+            _clientHostName = addr.getHostName();
+            _clientHostAddress = addr.getHostAddress();
+            _clientInfo = _clientHostName;
+            if (!_clientHostAddress.equals(_clientHostName)) {
+                _clientInfo += " (" + _clientHostAddress + ")";
+            }
+        } catch (Throwable ex) {
+            closeSocket();
+            throw ExceptionUtil.rethrow(ex);
+        }
+    }
+
+    protected void closeSocket() {
+        try {
+            if (_socketIn != null) {
+                _socketIn.close();
+            }
+        } catch (Exception ignore) {
+        }
+        try {
+            if (_socketOut != null) {
+                _socketOut.close();
+            }
+        } catch (Exception ignore) {
+        }
+        try {
+            _socket.close();
+        } catch (Exception ignore) {
+        }
+    }
+
+    protected byte[] getObjectKey(TargetAddress target) {
+        switch (target.discriminator()) {
+            case KeyAddr.value:
+                return target.object_key();
+            case ProfileAddr.value:
+            case ReferenceAddr.value:
+                throw new SystemException("TODO");
+            default:
+                throw new IllegalArgumentException("target discriminator = " + target.discriminator());
+        }
+    }
+
+    protected void processRequest(CdrInputStream parameters, CdrOutputStream output, CdrOutputStream results, RequestHeader_1_2 request) {
+        byte[] objectKey = getObjectKey(request.target);
+        int keyLength = objectKey.length;
+        int keyType = keyLength == 0 ? 0 : objectKey[0];
+        if (keyType >= 'A' && keyType <= 'Z') {
+            RequestHandler handler = _handlers[keyType];
+            if (handler != null) {
+                handler.processRequest(objectKey, request.operation, parameters, output);
+                return;
+            }
+        }
+
+        ReplyHeader_1_2 reply = new ReplyHeader_1_2();
+        reply.request_id = request.request_id;
+
+        org.apache.geronimo.interop.rmi.iiop.ObjectInputStream objectIn;
+        org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream objectOut;
+
+        if (SIMPLE_IDL || keyType == 'N' || keyType == 'J') {
+            // Name Service and JMS use simple IDL interoperability.
+            objectIn = org.apache.geronimo.interop.rmi.iiop.SimpleObjectInputStream.getInstance(parameters);
+            objectOut = org.apache.geronimo.interop.rmi.iiop.SimpleObjectOutputStream.getInstance(results);
+        } else {
+            // Otherwise use RMI-IIOP interoperability.
+            objectIn = org.apache.geronimo.interop.rmi.iiop.ObjectInputStream.getInstance(parameters);
+            objectOut = org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream.getInstance(results);
+        }
+
+        try {
+            String objectName = null;
+            for (int colonPos = 0; colonPos < keyLength; colonPos++) {
+                if (objectKey[colonPos] == ':') {
+                    objectName = UTF8.toString(objectKey, 0, colonPos);
+                    int newKeyLength = keyLength - colonPos - 1;
+                    byte[] newObjectKey = new byte[newKeyLength];
+                    System.arraycopy(objectKey, colonPos + 1, newObjectKey, 0, newKeyLength);
+                    objectKey = newObjectKey;
+                    break;
+                }
+            }
+
+            if (objectName == null) {
+                objectName = UTF8.toString(objectKey);
+            }
+
+            /*
+            if (objectName.startsWith("EJB~"))
+            {
+                // Compact encoding of component class names,
+                // saves 11 bytes per request.
+                objectName = "ejb.components." + objectName.substring(4);
+            }
+            */
+
+            processServiceContext(request);
+
+            /*
+            Object object;
+            try
+            {
+                object = null; //_nameService.lookup(objectName);
+            }
+            catch (javax.naming.NameNotFoundException notFound)
+            {
+                warnLookupFailed(_clientInfo, notFound);
+                throw new org.omg.CORBA.OBJECT_NOT_EXIST(objectName);
+            }
+
+            if (object instanceof RemoteInterface)
+            {
+                RemoteInterface skeleton = ((RemoteInterface)object).$getSkeleton();
+                skeleton.$invoke(request.operation, objectKey, objectIn, objectOut);
+                if (objectOut.hasException())
+                {
+                    reply.reply_status = ReplyStatusType_1_2.USER_EXCEPTION;
+                }
+                else
+                {
+                    reply.reply_status = ReplyStatusType_1_2.NO_EXCEPTION;
+                }
+                output.write_reply(reply, results);
+            }
+            else
+            {
+                warnInvokeFailedNoRemoteInterface(_clientInfo, object, object.getClass());
+                throw new org.omg.CORBA.OBJECT_NOT_EXIST(objectName);
+            }
+            */
+
+            Object object;
+            try {
+                object = _nameService.lookup(objectName);
+            } catch (javax.naming.NameNotFoundException notFound) {
+                object = AdapterManager.getInstance().getAdapter(objectName);
+
+                if (object == null) {
+                    warnLookupFailed(_clientInfo, notFound);
+                    throw new org.omg.CORBA.OBJECT_NOT_EXIST(objectName);
+                }
+            }
+
+//            Adapter a = AdapterManager.getInstance().getAdapter(objectName);
+//            if (a != null)
+            if (object != null && object instanceof Adapter) {
+                Adapter a = (Adapter) object;
+                //RemoteInterface skeleton = a.getRemoteInterface();
+                a.invoke(request.operation, objectKey, objectIn, objectOut);
+
+                if (objectOut.hasException()) {
+                    reply.reply_status = ReplyStatusType_1_2.USER_EXCEPTION;
+                } else {
+                    reply.reply_status = ReplyStatusType_1_2.NO_EXCEPTION;
+                }
+                output.write_reply(reply, results);
+            } else {
+                throw new org.omg.CORBA.OBJECT_NOT_EXIST(objectName);
+            }
+        } catch (Exception ex) {
+            warnSystemException(_clientInfo, ex);
+            results = CdrOutputStream.getInstance(); // in case we already wrote to it
+            results.write_SystemException(ex, _writeSystemExceptionStackTrace);
+            reply.reply_status = ReplyStatusType_1_2.SYSTEM_EXCEPTION;
+            output.write_reply(reply, results);
+        }
+    }
+
+    protected void processLocateRequest(CdrOutputStream output, LocateRequestHeader_1_2 request) {
+        // Fake LocateReply, pretend we host any object.
+        // Since we never move objects, this is sufficient.
+        LocateReplyHeader_1_2 reply = new LocateReplyHeader_1_2();
+        reply.request_id = request.request_id;
+        reply.locate_status = LocateStatusType_1_2.OBJECT_HERE;
+        output.write_reply(reply);
+    }
+
+    protected void processServiceContext(RequestHeader_1_2 request) {
+        ServiceContext[] contextList = request.service_context;
+        int n = contextList.length;
+        String username = null;
+        String password = null;
+
+        for (int i = 0; i < n; i++) {
+            ServiceContext context = contextList[i];
+            int tag = context.context_id;
+
+            /*
+            if (tag == SecurityInfo.TAG_USERNAME)
+            {
+                username = SecurityInfo.decode(context.context_data);
+            }
+            else if (tag == SecurityInfo.TAG_PASSWORD)
+            {
+                password = SecurityInfo.decode(context.context_data);
+            }
+            */
+            // Otherwise OK to ignore unknown tags.
+        }
+
+        // Default security info.
+        /*
+        if (username == null)
+        {
+            username = User.GUEST;
+        }
+        if (password == null)
+        {
+            password = "";
+        }
+
+        // Check if the password is correct.
+        User user = User.getInstance(username);
+        user.login(password); // may throw SecurityException
+        User.setCurrent(user);
+        SimpleSubject.setCurrent(new SimpleSubject(username, password));
+        */
+    }
+
+    // log methods
+
+    protected void warnBadMagic(String clientHost, Exception ex) {
+        System.out.println("MH.warnBadMagic: clientHost: " + clientHost + ", ex = " + ex);
+    }
+
+    protected void warnBadMagicBadSize(String clientHost, Exception ex) {
+        System.out.println("MH.warnBadMagicBadSize: clientHost: " + clientHost + ", ex = " + ex);
+    }
+
+    protected void warnGiopVersion(String clientHost, Exception ex) {
+        System.out.println("MH.warnGiopVersion: clientHost: " + clientHost + ", ex = " + ex);
+    }
+
+    protected void warnInvokeFailedNoRemoteInterface(String clientHost, Object object, Class type) {
+        System.out.println("MH.warnInvokeFailedNoRemoteInterface: clientHost: " + clientHost + ", object = " + object + ", type: " + type);
+    }
+
+    protected void warnLookupFailed(String clientHost, Exception ex) {
+        System.out.println("MH.warnLookupFailed: clientHost: " + clientHost + ", ex = " + ex);
+    }
+
+    protected void warnReceiveFailed(String clientHost, Exception ex) {
+        System.out.println("MH.warnReceiveFailed: clientHost: " + clientHost + ", ex = " + ex);
+    }
+
+    protected void warnSendFailed(String clientHost, Exception ex) {
+        System.out.println("MH.warnSendFailed: clientHost: " + clientHost + ", ex = " + ex);
+    }
+
+    protected void warnSystemException(String clientHost, Exception ex) {
+        System.out.println("MH.warnSystemException: clientHost: " + clientHost + ", ex = " + ex);
+    }
+
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/RequestHandler.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/RequestHandler.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/RequestHandler.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,26 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop.server;
+
+import org.apache.geronimo.interop.rmi.iiop.CdrInputStream;
+import org.apache.geronimo.interop.rmi.iiop.CdrOutputStream;
+
+
+public interface RequestHandler {
+    public void processRequest(byte[] key, String method, CdrInputStream parameters, CdrOutputStream results);
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/ServerNamingContext.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/ServerNamingContext.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/ServerNamingContext.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,204 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop.server;
+
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+
+import org.apache.geronimo.interop.CosNaming.BindingIteratorHolder;
+import org.apache.geronimo.interop.CosNaming.BindingListHolder;
+import org.apache.geronimo.interop.CosNaming.NameComponent;
+import org.apache.geronimo.interop.CosNaming.NamingContext;
+import org.apache.geronimo.interop.CosNaming.NamingContextExtPackage.InvalidAddress;
+import org.apache.geronimo.interop.CosNaming.NamingContextPackage.AlreadyBound;
+import org.apache.geronimo.interop.CosNaming.NamingContextPackage.CannotProceed;
+import org.apache.geronimo.interop.CosNaming.NamingContextPackage.InvalidName;
+import org.apache.geronimo.interop.CosNaming.NamingContextPackage.NotFound;
+import org.apache.geronimo.interop.CosNaming.NamingContextPackage.NotFoundReason;
+import org.apache.geronimo.interop.adapter.Adapter;
+import org.apache.geronimo.interop.naming.NameService;
+import org.apache.geronimo.interop.naming.NameServiceLog;
+import org.apache.geronimo.interop.rmi.iiop.RemoteInterface;
+
+
+public class ServerNamingContext implements org.apache.geronimo.interop.rmi.iiop.NameServiceOperations {
+    
+    protected static ServerNamingContext _snc = null;
+
+    public static ServerNamingContext getInstance() {
+        if (_snc == null) {
+            synchronized (ServerNamingContext.class) {
+                _snc = new ServerNamingContext();
+                _snc.init();
+            }
+        }
+
+        return _snc;
+    }
+
+    // -----------------------------------------------------------------------
+    // private data
+    // -----------------------------------------------------------------------
+
+    private NameService _nameService;
+
+    private volatile int _cycle;
+
+    // -----------------------------------------------------------------------
+    // public methods from interface NamingContextExtOperations
+    // -----------------------------------------------------------------------
+
+    public org.omg.CORBA.Object resolve_str(String name) throws NotFound, CannotProceed, InvalidName {
+        return lookup(name, null);
+    }
+
+
+    public String to_string(NameComponent[] n) throws InvalidName {
+        throw NoImplement();
+    }
+
+    public NameComponent[] to_name(String sn) throws InvalidName {
+        throw NoImplement();
+    }
+
+    public String to_url(String addr, String sn) throws InvalidAddress, InvalidName {
+        throw NoImplement();
+    }
+
+    // -----------------------------------------------------------------------
+    // public methods from interface NamingContextOperations
+    // -----------------------------------------------------------------------
+
+    public org.omg.CORBA.Object resolve(NameComponent[] name) throws NotFound, CannotProceed, InvalidName {
+        return lookup(toString(name), name);
+    }
+
+    public void bind(NameComponent[] n, org.omg.CORBA.Object obj) throws NotFound, CannotProceed, InvalidName, AlreadyBound {
+        throw NoImplement();
+    }
+
+    public void bind_context(org.apache.geronimo.interop.CosNaming.NameComponent[] n, org.apache.geronimo.interop.CosNaming.NamingContext nc) throws NotFound, CannotProceed, InvalidName, AlreadyBound {
+        throw NoImplement();
+    }
+
+    public void rebind(org.apache.geronimo.interop.CosNaming.NameComponent[] n, org.omg.CORBA.Object obj) throws NotFound, CannotProceed, InvalidName {
+        throw NoImplement();
+    }
+
+    public void rebind_context(org.apache.geronimo.interop.CosNaming.NameComponent[] n, org.apache.geronimo.interop.CosNaming.NamingContext nc) throws NotFound, CannotProceed, InvalidName {
+        throw NoImplement();
+    }
+
+    public void unbind(NameComponent[] n) throws NotFound, CannotProceed, InvalidName {
+        throw NoImplement();
+    }
+
+    public void list(int how_many, BindingListHolder bl, BindingIteratorHolder bi) {
+        throw NoImplement();
+    }
+
+    public NamingContext new_context() {
+        throw NoImplement();
+    }
+
+    public NamingContext bind_new_context(NameComponent[] n) throws NotFound, AlreadyBound, CannotProceed, InvalidName {
+        throw NoImplement();
+    }
+
+    protected org.omg.CORBA.NO_IMPLEMENT NoImplement() {
+        return new org.omg.CORBA.NO_IMPLEMENT();
+    }
+
+    // -----------------------------------------------------------------------
+    // public methods from interface NameServiceOperations (Sybase proprietary)
+    // -----------------------------------------------------------------------
+
+    public String resolve_host(String host) {
+        System.out.println("ServerNamingContext.resolve_host(): TODO host = " + host);
+
+        //String resolvedHost = ClusterPartition.getInstance(host).resolveHost();
+        //return "cycle=" + Math.max(1, ++_cycle) + ";" + resolvedHost;
+        
+        // Cycle prefix for round-robin load balancing.
+        // Any weighted balancing is applied by client.
+
+        return host;
+    }
+
+    // -----------------------------------------------------------------------
+    // protected methods
+    // -----------------------------------------------------------------------
+
+    protected void init() {
+        _nameService = NameService.getInstance();
+    }
+
+    protected org.omg.CORBA.Object lookup(String nameString, NameComponent[] name) throws NotFound {
+        try {
+            Object object = _nameService.lookup(nameString);
+
+            /*
+            if (object instanceof RemoteInterface)
+            {
+                RemoteInterface remote = (RemoteInterface)object;
+                return remote.$getObjectRef();
+            }
+            else
+            {
+                NameServiceLog.getInstance().warnObjectHasNoRemoteInterface(nameString, object.getClass().getName());
+                throw new NotFound(NotFoundReason.not_object, name);
+            }
+            */
+
+            if (object instanceof Adapter) {
+                Adapter a = (Adapter) object;
+                RemoteInterface remote = a.getRemoteInterface();
+                return remote.$getObjectRef();
+            } else {
+                NameServiceLog.getInstance().warnObjectHasNoRemoteInterface(nameString, object.getClass().getName());
+                throw new NotFound(NotFoundReason.not_object, name);
+            }
+        } catch (NameNotFoundException notFound) {
+            // Assume warning message has already been logged.
+            throw new NotFound(NotFoundReason.missing_node, name);
+        } catch (NamingException ex) {
+            NameServiceLog.getInstance().warnNameNotFound(nameString, ex);
+            throw new NotFound(NotFoundReason.missing_node, name);
+        }
+    }
+
+    protected String toString(NameComponent[] name) {
+        int n = name.length;
+        if (n == 1) {
+            return name[0].id;
+        } else {
+            StringBuffer nameBuffer = new StringBuffer();
+            for (int i = 0; i < n; i++) {
+                if (i > 0) {
+                    nameBuffer.append('/');
+                }
+                nameBuffer.append(name[i].id);
+                if (name[i].kind.length() > 0) {
+                    nameBuffer.append(",kind=");
+                    nameBuffer.append(name[i].kind);
+                }
+            }
+            return nameBuffer.toString();
+        }
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/SocketListener.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/SocketListener.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/SocketListener.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,128 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.rmi.iiop.server;
+
+import java.net.InetAddress;
+import java.net.Socket;
+
+import org.apache.geronimo.interop.SystemException;
+import org.apache.geronimo.interop.properties.SystemProperties;
+import org.apache.geronimo.interop.rmi.iiop.ListenerInfo;
+import org.apache.geronimo.interop.rmi.iiop.Protocol;
+
+
+public class SocketListener extends Thread {
+    public static SocketListener getInstance() {
+        return new SocketListener();
+    }
+
+    // private data
+
+    private String _name;
+
+    private String _host;
+
+    private int _port;
+
+    private int _listenBacklog;
+
+    private java.net.ServerSocket _listener;
+
+    // internal methods
+
+    protected void init() {
+        _host = "localhost";
+        _port = 2000;
+        _listenBacklog = 10;
+        setDaemon(true);
+    }
+
+    // public methods
+
+    public void setHost(String host) {
+        _host = host;
+    }
+
+    public void setPort(int port) {
+        _port = port;
+    }
+
+    public void setListenBacklog(int backlog) {
+        _listenBacklog = backlog;
+    }
+
+    public void run() {
+        String iiopURL = "iiop://" + _host + ":" + _port;
+        ListenerInfo listenerInfo = new ListenerInfo();
+        listenerInfo.protocol = Protocol.IIOP; // TODO: other protocols (IIOPS etc.)
+        listenerInfo.host = _host;
+        listenerInfo.port = _port;
+        try {
+            InetAddress addr = InetAddress.getByName(_host);
+            _listener = new java.net.ServerSocket(_port, _listenBacklog, addr);
+        } catch (Exception ex) {
+            System.out.println("SocketListener: Error creating server socket.");
+            ex.printStackTrace();
+            try {
+                Socket socket = new Socket(_host, _port);
+                socket.close();
+                System.out.println("SocketListener: Error server already running: " + iiopURL);
+                ex.printStackTrace();
+            } catch (Exception ignore) {
+            }
+            return;
+        }
+        new CheckConnect().start();
+        for (; ;) {
+            java.net.Socket socket;
+            try {
+                socket = _listener.accept();
+            } catch (Exception ex) {
+                throw new SystemException(ex); // TODO: log error message
+            }
+            MessageHandler.getInstance(listenerInfo, socket).start();
+        }
+    }
+
+    private class CheckConnect extends Thread {
+        public void run() {
+            try {
+                Socket socket = new Socket(_host, _port);
+                socket.close();
+                if (!SystemProperties.quiet()) {
+                    System.out.println(formatAcceptingIiopConnections());
+                }
+            } catch (Exception ex) {
+                warnConnectFailed(_host, _port);
+            }
+        }
+    }
+
+    // format methods
+
+    protected String formatAcceptingIiopConnections() {
+        String msg = "SocketListener.formatAcceptingIiopConnection(): ";
+        return msg;
+    }
+
+    // log methods
+
+    protected void warnConnectFailed(String host, int port) {
+        System.out.println("SocketListener.warnConnectFailed(): host = " + host + ", port = " + port);
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/security/Role.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/security/Role.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/security/Role.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,111 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.security;
+
+import java.util.HashMap;
+
+import org.apache.geronimo.interop.properties.StringProperty;
+
+
+public class Role {
+    public static Role getInstance(String rolename) {
+        Role role = (Role) _roleMap.get(rolename);
+        if (role == null) {
+            synchronized (_roleMap) {
+                role = (Role) _roleMap.get(rolename);
+                if (role == null) {
+                    role = new Role();
+                    role.init(rolename);
+                    _roleMap.put(rolename, role);
+                }
+            }
+        }
+        return role;
+    }
+
+    public static Role getExistingInstance(String rolename) {
+        return (Role) _roleMap.get(rolename);
+    }
+
+    // properties
+
+    public static final StringProperty assignedRolesProperty =
+            new StringProperty(Role.class, "assignedRoles")
+            .displayName("Assigned Roles")
+            .consoleHelp("Names of roles which have been explicitly assigned to this role.")
+            .list()
+            .sortOrder(1);
+
+    public static final StringProperty excludedRolesProperty =
+            new StringProperty(Role.class, "excludedRoles")
+            .displayName("Excluded Roles")
+            .consoleHelp("Names of roles which must be excluded from this role.")
+            .list()
+            .sortOrder(2);
+
+    public static final StringProperty excludedUsersProperty =
+            new StringProperty(Role.class, "excludedUsers")
+            .displayName("Excluded Users")
+            .consoleHelp("Names of users who must be excluded from this role.")
+            .list()
+            .sortOrder(3);
+
+    public static final StringProperty inheritedRolesProperty =
+            new StringProperty(Role.class, "inheritedRoles")
+            .displayName("Inherited Roles")
+            .consoleHelp("Names of roles which have been inherited from this role's assigned roles. This list is read only. It is derived from the assigned roles.")
+            .list()
+            .readOnly()
+            .sortOrder(4);
+
+    public static final StringProperty roleMembersProperty =
+            new StringProperty(Role.class, "roleMembers")
+            .displayName("Role Members")
+            .consoleHelp("Names of users who have been assigned this role, or who have inherited it from an assigned role. This list is read only. To add a user to a role, please edit the user's properties")
+            .list()
+            .readOnly()
+            .sortOrder(5);
+
+    // public constants
+
+    public static final String CLIENT = "[client]";
+
+    public static final String SYSTEM = "[system]";
+
+    // private data
+
+    private static HashMap _roleMap = new HashMap();
+
+    private String _name;
+
+    // internal methods
+
+    protected void init(String rolename) {
+        _name = rolename;
+    }
+
+    // public methods
+
+    public String getName() {
+        return _name;
+    }
+
+    public String toString() {
+        return super.toString() + ":" + _name;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/security/SimpleSubject.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/security/SimpleSubject.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/security/SimpleSubject.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,71 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.security;
+
+public class SimpleSubject {
+    // -----------------------------------------------------------------------
+    // public data
+    // -----------------------------------------------------------------------
+
+    public static final int FLAG_SESSION_MANAGER = 1;
+
+    // -----------------------------------------------------------------------
+    // private data
+    // -----------------------------------------------------------------------
+
+    private static ThreadLocal _current = new ThreadLocal();
+
+    private String _username;
+
+    private String _password;
+
+    private int _flags;
+
+    // -----------------------------------------------------------------------
+    // public methods
+    // -----------------------------------------------------------------------
+
+    public static SimpleSubject getCurrent() {
+        return (SimpleSubject) _current.get();
+    }
+
+    public static void setCurrent(SimpleSubject subject) {
+        _current.set(subject);
+    }
+
+    public SimpleSubject(String username, String password) {
+        _username = username;
+        _password = password;
+    }
+
+    public String getUsername() {
+        return _username;
+    }
+
+    public String getPassword() {
+        return _password;
+    }
+
+    public int getFlags() {
+        return _flags;
+    }
+
+    public void setFlags(int flags) {
+        _flags = flags;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/security/User.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/security/User.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/security/User.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,143 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.security;
+
+import java.util.HashMap;
+
+
+public class User
+        implements java.security.Principal {
+    public static User getInstance(String username) {
+        User user = (User) _userMap.get(username);
+        if (user == null) {
+            synchronized (_userMap) {
+                user = (User) _userMap.get(username);
+                if (user == null) {
+                    user = new User();
+                    user.init(username);
+                    _userMap.put(username, user);
+                }
+            }
+        }
+        return user;
+    }
+
+    // properties
+
+    // public constants
+
+    public static final String GUEST = "guest";
+    public static final String NOBODY = "[nobody]";
+    public static final String USER_INFO = "org.apache.geronimo.interop.security.UserInfo";
+
+    // private data
+
+    private static ThreadLocal _current = new ThreadLocal();
+    private static HashMap _userMap = new HashMap();
+    private String _username;
+    private String _lastValidPassword;
+
+    // internal methods
+
+    protected void init(String username) {
+        _username = username;
+    }
+
+    // public methods
+
+    public int hashCode() {
+        return _username.hashCode();
+    }
+
+    public boolean equals(Object thatObject) {
+        if (thatObject == this) {
+            return true;
+        }
+        if (thatObject == null || !(thatObject instanceof User)) {
+            return false;
+        }
+        User that = (User) thatObject;
+        //return this._domain == that._domain
+        //   && this._username.equals(that._username);
+        return true;
+    }
+
+    public static User getCurrent() {
+        return (User) _current.get();
+    }
+
+    public static User getCurrentNotNull() {
+        User user = (User) _current.get();
+        if (user == null) {
+            throw new SecurityException("Error: No Current User");
+        }
+        return user;
+    }
+
+    public static User getUnauthenticated() {
+        return User.getInstance("unauthenticated");
+    }
+
+    public static void setCurrent(User user) {
+        _current.set(user);
+    }
+
+    public String getName() {
+        return _username;
+    }
+
+    public String getPassword() {
+        return _lastValidPassword == null ? "" : _lastValidPassword;
+    }
+
+    public String toString() {
+        return User.class.getName() + ":" + _username + "@domain";
+    }
+
+    /**
+     * * Check password for login. Use cached result if available.
+     */
+    public void login(String password) {
+        System.out.println("User.login(): username = " + _username + ", password = " + password);
+        boolean ok = true;
+        if (ok) {
+            SimpleSubject.setCurrent(new SimpleSubject(_username, password));
+        } else {
+            SimpleSubject.setCurrent(null);
+        }
+        if (!ok) {
+            throw new SecurityException("Warn: Login Failed. Username: " + _username);
+        }
+    }
+
+    public boolean hasRole(Role role) {
+        return true;
+    }
+
+    public boolean hasRole(String rolename) {
+        boolean hasRole = true;
+        ;
+        return hasRole;
+    }
+
+    // protected methods
+
+    protected synchronized boolean hasLocalRole(String rolename) {
+        return true;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/server/IIOPDaemon.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/server/IIOPDaemon.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/server/IIOPDaemon.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,166 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.server;
+
+import java.net.InetSocketAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+import org.apache.geronimo.interop.adapter.Adapter;
+import org.apache.geronimo.interop.adapter.AdapterManager;
+import org.apache.geronimo.interop.naming.NameService;
+import org.apache.geronimo.interop.rmi.iiop.ListenerInfo;
+import org.apache.geronimo.interop.rmi.iiop.server.MessageHandler;
+
+
+public class IIOPDaemon implements Runnable {
+    protected String _host = "localhost";
+    protected int _port = 9000;
+    protected String _name = "IIOP";
+    protected ServerSocket _ss = null;
+    protected boolean _ready = false;
+
+    public void setHost(String host) {
+        _host = host;
+    }
+
+    public String getHost() {
+        return _host;
+    }
+
+    public void setPort(int port) {
+        _port = port;
+    }
+
+    public int getPort() {
+        return _port;
+    }
+
+    public void setName(String name) {
+        _name = name;
+    }
+
+    public String getName() {
+        return _name;
+    }
+
+    public void setReady() {
+        _ready = true;
+    }
+
+    public boolean isReady() {
+        return _ready;
+    }
+
+    public ServerSocket getServerSocket() {
+        if (_ss == null) {
+            synchronized (this) {
+                try {
+                    InetSocketAddress isa = new InetSocketAddress(_host, _port);
+                    _ss = new ServerSocket();
+                    _ss.bind(isa);
+                    setReady();
+                } catch (Exception ex) {
+                    ex.printStackTrace();
+                }
+            }
+        }
+
+        return _ss;
+    }
+
+    public void run() {
+        ListenerInfo li = new ListenerInfo();
+        li.protocol = 1;
+        li.host = getHost();
+        li.port = getPort();
+
+        ServerSocket ss = getServerSocket();
+        Socket s = null;
+        System.out.println("[" + getName() + "-" + getHost() + ":" + getPort() + "] Accepting Connections...");
+        while (isReady()) {
+            try {
+                s = ss.accept();
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+
+            MessageHandler mh;
+            mh = MessageHandler.getInstance(li, s);
+            mh.start();
+        }
+    }
+
+    public static void main(String args[]) {
+        IIOPDaemon id = new IIOPDaemon();
+        id.setHost("localhost");
+        id.setPort(9000);
+
+        Thread t = new Thread(id);
+        t.setName(id.getName() + " Daemon");
+        t.start();
+
+        NameService ns = NameService.getInstance();
+        AdapterManager am = AdapterManager.getInstance();
+
+        //
+        // NameService
+        //
+        Adapter a = new Adapter();
+        a.setBindName("NameService");
+        a.setRemoteClassName("org.apache.geronimo.interop.rmi.iiop.server.ServerNamingContext");
+        a.setRemoteInterfaceName("org.apache.geronimo.interop.rmi.iiop.NameServiceOperations");
+        a.setShared(true);
+        a.addId("IDL:org.apache.geronimo.interop/rmi/iiop/NameService:1.0");
+        a.addId("IDL:omg.org/CosNaming/NamingContext:1.0");
+        a.addId("IDL:omg.org/CosNaming/NamingContextExt:1.0");
+        a.addId("NameService"); // this gets passed in by the J2SE 1.4 ORB
+        a.setClassLoader(id.getClass().getClassLoader());
+        //a.generateSkels();
+        //a.compileSkels();
+
+        am.registerAdapter(a);
+        ns.bindAdapter(a);
+
+        //
+        // Component
+        //
+        a = new Adapter();
+        a.setBindName("mark.comps.Add");
+        a.setRemoteClassName("mark.comps.AddImpl");
+        a.setRemoteInterfaceName("mark.comps.Add");
+        a.addId("RMI:mark.comps.Add:0000000000000000");
+        a.setClassLoader(id.getClass().getClassLoader());
+
+        am.registerAdapter(a);
+        ns.bindAdapter(a);
+
+        //
+        // Component
+        //
+        a = new Adapter();
+        a.setBindName("mark.comps.Add2");
+        a.setRemoteClassName("mark.comps.Add2Impl");
+        a.setRemoteInterfaceName("mark.comps.Add2");
+        a.addId("RMI:mark.comps.Add2:0000000000000000");
+        a.setClassLoader(id.getClass().getClassLoader());
+
+        am.registerAdapter(a);
+        ns.bindAdapter(a);
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/server/IIOPSDaemon.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/server/IIOPSDaemon.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/server/IIOPSDaemon.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,33 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.server;
+
+
+
+
+public class IIOPSDaemon extends IIOPDaemon {
+    public static void main(String args[]) {
+        IIOPSDaemon id = new IIOPSDaemon();
+        id.setName("IIOPS");
+        id.setHost("localhost");
+        id.setPort(9000);
+
+        Thread t = new Thread(id);
+        t.start();
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/ArrayUtil.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/ArrayUtil.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/ArrayUtil.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,176 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.util;
+
+public class ArrayUtil {
+    public static final boolean[] EMPTY_BOOLEAN_ARRAY =
+            {
+            }
+            ;
+    public static final char[] EMPTY_CHAR_ARRAY =
+            {
+            }
+            ;
+    public static final byte[] EMPTY_BYTE_ARRAY =
+            {
+            }
+            ;
+    public static final short[] EMPTY_SHORT_ARRAY =
+            {
+            }
+            ;
+    public static final int[] EMPTY_INT_ARRAY =
+            {
+            }
+            ;
+    public static final long[] EMPTY_LONG_ARRAY =
+            {
+            }
+            ;
+    public static final float[] EMPTY_FLOAT_ARRAY =
+            {
+            }
+            ;
+    public static final double[] EMPTY_DOUBLE_ARRAY =
+            {
+            }
+            ;
+    public static final Class[] EMPTY_CLASS_ARRAY =
+            {
+            }
+            ;
+    public static final Object[] EMPTY_OBJECT_ARRAY =
+            {
+            }
+            ;
+    public static final String[] EMPTY_STRING_ARRAY =
+            {
+            }
+            ;
+
+    public static byte[] copy(byte[] x) {
+        return getBytes(x, 0, x.length);
+    }
+
+    public static byte[] concat(byte[] x, byte[] y) {
+        byte[] z = new byte[x.length + y.length];
+        System.arraycopy(x, 0, z, 0, x.length);
+        System.arraycopy(y, 0, z, x.length, y.length);
+        return z;
+    }
+
+    public static byte[] getBytes(byte[] x, int offset, int length) {
+        byte[] y = new byte[length];
+        System.arraycopy(x, offset, y, 0, length);
+        return y;
+    }
+
+    public static int indexOf(byte[] x, byte b) {
+        return indexOf(x, b, 0);
+    }
+
+    public static int indexOf(byte[] x, byte b, int startOffset) {
+        int n = x.length;
+        for (int i = startOffset; i < n; i++) {
+            if (x[i] == b) {
+                return i;
+            }
+        }
+        return -1;
+    }
+
+    public static boolean[] newBooleanArray(int size, boolean[] init) {
+        boolean[] array = new boolean[size];
+        if (init != null) {
+            System.arraycopy(init, 0, array, 0, Math.min(size, init.length));
+        }
+        return array;
+    }
+
+    public static char[] newCharArray(int size, char[] init) {
+        char[] array = new char[size];
+        if (init != null) {
+            System.arraycopy(init, 0, array, 0, Math.min(size, init.length));
+        }
+        return array;
+    }
+
+    public static byte[] newByteArray(int size, byte[] init) {
+        byte[] array = new byte[size];
+        if (init != null) {
+            System.arraycopy(init, 0, array, 0, Math.min(size, init.length));
+        }
+        return array;
+    }
+
+    public static short[] newShortArray(int size, short[] init) {
+        short[] array = new short[size];
+        if (init != null) {
+            System.arraycopy(init, 0, array, 0, Math.min(size, init.length));
+        }
+        return array;
+    }
+
+    public static int[] newIntArray(int size, int[] init) {
+        int[] array = new int[size];
+        if (init != null) {
+            System.arraycopy(init, 0, array, 0, Math.min(size, init.length));
+        }
+        return array;
+    }
+
+    public static long[] newLongArray(int size, long[] init) {
+        long[] array = new long[size];
+        if (init != null) {
+            System.arraycopy(init, 0, array, 0, Math.min(size, init.length));
+        }
+        return array;
+    }
+
+    public static float[] newFloatArray(int size, float[] init) {
+        float[] array = new float[size];
+        if (init != null) {
+            System.arraycopy(init, 0, array, 0, Math.min(size, init.length));
+        }
+        return array;
+    }
+
+    public static double[] newDoubleArray(int size, double[] init) {
+        double[] array = new double[size];
+        if (init != null) {
+            System.arraycopy(init, 0, array, 0, Math.min(size, init.length));
+        }
+        return array;
+    }
+
+    public static Object[] newObjectArray(int size, Object[] init) {
+        Object[] array = new Object[size];
+        if (init != null) {
+            System.arraycopy(init, 0, array, 0, Math.min(size, init.length));
+        }
+        return array;
+    }
+
+    public static Object[] newObjectArray(int size, Object[] init, Class type) {
+        Object[] array = (Object[]) java.lang.reflect.Array.newInstance(type, size);
+        if (init != null) {
+            System.arraycopy(init, 0, array, 0, Math.min(size, init.length));
+        }
+        return array;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/Base16Binary.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/Base16Binary.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/Base16Binary.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,63 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.util;
+
+public class Base16Binary {
+    /**
+     * * Convert from hexadecimal string to byte array.
+     */
+    public static byte[] fromString(String string) {
+        return fromString(string, 0, string.length());
+    }
+
+    /**
+     * * Convert from hexadecimal string to byte array.
+     */
+    public static byte[] fromString(String string, int offset, int length) {
+        byte[] bytes = new byte[length / 2];
+        for (int j = 0, k = 0; k < length; j++, k += 2) {
+            int hi = Character.digit(string.charAt(offset + k), 16);
+            int lo = Character.digit(string.charAt(offset + k + 1), 16);
+            if (hi == -1 || lo == -1) {
+                throw new IllegalArgumentException(string);
+            }
+            bytes[j] = (byte) (16 * hi + lo);
+        }
+        return bytes;
+    }
+
+    /**
+     * * Convert from byte array to hexadecimal string.
+     */
+    public static String toString(byte[] bytes) {
+        return toString(bytes, 0, bytes.length);
+    }
+
+    /**
+     * * Convert from byte array to hexadecimal string.
+     */
+    public static String toString(byte[] bytes, int offset, int length) {
+        char[] chars = new char[length * 2];
+        for (int j = 0, k = 0; j < length; j++, k += 2) {
+            int value = (bytes[offset + j] + 256) & 255;
+            chars[k] = Character.forDigit(value >> 4, 16);
+            chars[k + 1] = Character.forDigit(value & 15, 16);
+        }
+        return new String(chars);
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/Base64Binary.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/Base64Binary.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/Base64Binary.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,83 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.util;
+
+public class Base64Binary {
+    /**
+     * * Convert from byte array to base 64 encoded string.
+     */
+    public static String toString(byte[] bytes) {
+        return toString(bytes, 0, bytes.length);
+    }
+
+    public static String toString(byte[] bytes, int offset, int length) {
+        StringBuffer s = new StringBuffer((length * 4) / 3 + 1);
+        int n = offset + length;
+        for (int i = offset; i < n; i += 3) {
+            /* TODO: make this optional???
+            if (i != 0 && i % 18 == 0)
+            {
+                // Must have at most 76 characters per line.
+                s.append('\n');
+            }
+            */
+            int value;
+            int chars;
+            if (i < n - 2) {
+                value = (0x00FF0000 & (bytes[i] << 16))
+                        | (0x0000FF00 & (bytes[i + 1] << 8))
+                        | (0x000000FF & bytes[i + 2]);
+                chars = 4;
+            } else if (i < n - 1) {
+                value = (0x00FF0000 & (bytes[i] << 16))
+                        | (0x0000FF00 & (bytes[i + 1] << 8));
+                chars = 3;
+            } else {
+                value = (0x00FF0000 & (bytes[i] << 16));
+                chars = 2;
+            }
+            while (chars-- > 0) {
+                int x = (0x00FC0000 & value) >> 18;
+                char c = getChar(x);
+                s.append(c);
+                value = value << 6;
+            }
+            if (i == n - 1) {
+                s.append("==");
+            } else if (i == n - 2) {
+                s.append('=');
+            }
+        }
+        return s.toString();
+    }
+
+    private static char getChar(int c) {
+        if (c < 26) {
+            return (char) ('A' + c);
+        } else if (c < 52) {
+            return (char) ('a' + (c - 26));
+        } else if (c < 62) {
+            return (char) ('0' + (c - 52));
+        } else if (c == 62) {
+            return '+';
+        } else // c == 63
+        {
+            return '/';
+        }
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/BigEndian.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/BigEndian.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/BigEndian.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,128 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.util;
+
+public abstract class BigEndian {
+    public static byte[] getShortBytes(short value) {
+        byte[] bytes = new byte[2];
+        setShort(bytes, value);
+        return bytes;
+    }
+
+    public static byte[] getIntBytes(int value) {
+        byte[] bytes = new byte[4];
+        setInt(bytes, value);
+        return bytes;
+    }
+
+    public static byte[] getLongBytes(long value) {
+        byte[] bytes = new byte[8];
+        setLong(bytes, value);
+        return bytes;
+    }
+
+    public static byte[] get48BitLongBytes(long value) {
+        byte[] bytes = new byte[6];
+        set48BitLong(bytes, value);
+        return bytes;
+    }
+
+    public static short getShort(byte[] bytes) {
+        return getShort(bytes, 0);
+    }
+
+    public static short getShort(byte[] bytes, int offset) {
+        int b1 = (bytes[offset] << 8) & 0x0000ff00;
+        int b0 = bytes[offset + 1] & 0x000000ff;
+        return (short) (b1 | b0);
+    }
+
+    public static int getInt(byte[] bytes) {
+        return getInt(bytes, 0);
+    }
+
+    public static int getInt(byte[] bytes, int offset) {
+        int b3 = (bytes[offset] << 24) & 0xff000000;
+        int b2 = (bytes[offset + 1] << 16) & 0x00ff0000;
+        int b1 = (bytes[offset + 2] << 8) & 0x0000ff00;
+        int b0 = bytes[offset + 3] & 0x000000ff;
+        return b3 | b2 | b1 | b0;
+    }
+
+    public static long getLong(byte[] bytes) {
+        return getLong(bytes, 0);
+    }
+
+    public static long getLong(byte[] bytes, int offset) {
+        long hi = getInt(bytes, offset) & 0xffffffffL;
+        long lo = getInt(bytes, offset + 4) & 0xffffffffL;
+        return (hi << 32) | lo;
+    }
+
+    public static long get48BitLong(byte[] bytes) {
+        return get48BitLong(bytes, 0);
+    }
+
+    public static long get48BitLong(byte[] bytes, int offset) {
+        long hi = getShort(bytes, offset) & 0xffffL;
+        long lo = getInt(bytes, offset + 2) & 0xffffffffL;
+        return (hi << 32) | lo;
+    }
+
+    public static void setShort(byte[] bytes, short value) {
+        setShort(bytes, 0, value);
+    }
+
+    public static void setShort(byte[] bytes, int offset, short value) {
+        bytes[offset] = (byte) ((value >>> 8) & 0xff);
+        bytes[offset + 1] = (byte) (value & 0xff);
+    }
+
+    public static void setInt(byte[] bytes, int value) {
+        setInt(bytes, 0, value);
+    }
+
+    public static void setInt(byte[] bytes, int offset, int value) {
+        bytes[offset] = (byte) ((value >>> 24) & 0xff);
+        bytes[offset + 1] = (byte) ((value >>> 16) & 0xff);
+        bytes[offset + 2] = (byte) ((value >>> 8) & 0xff);
+        bytes[offset + 3] = (byte) (value & 0xff);
+    }
+
+    public static void setLong(byte[] bytes, long value) {
+        setLong(bytes, 0, value);
+    }
+
+    public static void setLong(byte[] bytes, int offset, long value) {
+        int hi = (int) (value >>> 32);
+        int lo = (int) value;
+        setInt(bytes, offset, hi);
+        setInt(bytes, offset + 4, lo);
+    }
+
+    public static void set48BitLong(byte[] bytes, long value) {
+        set48BitLong(bytes, 0, value);
+    }
+
+    public static void set48BitLong(byte[] bytes, int offset, long value) {
+        int hi = (int) (value >>> 32);
+        int lo = (int) value;
+        setShort(bytes, offset, (short) hi);
+        setInt(bytes, offset + 2, lo);
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/ExceptionList.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/ExceptionList.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/ExceptionList.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,78 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.util;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+
+public class ExceptionList extends ArrayList {
+    public ExceptionList() {
+    }
+
+    public ExceptionList(Constructor template) {
+        Class[] types = template.getExceptionTypes();
+        add(types);
+    }
+
+    public ExceptionList(Method template) {
+        Class[] types = template.getExceptionTypes();
+        add(types);
+    }
+
+    public ExceptionList(Class[] types) {
+        add(types);
+    }
+
+    public void add(Class[] types) {
+        int n = types.length;
+        for (int i = 0; i < n; i++) {
+            Class type = types[i];
+            if (ExceptionUtil.isUserException(type)) {
+                add(type);
+            }
+        }
+    }
+
+    public ExceptionList add(String type) {
+        super.add(type);
+        return this;
+    }
+
+    public ExceptionList add(Class type) {
+        return add(JavaType.getName(type));
+    }
+
+    public String toString() {
+        if (size() == 0) {
+            return "";
+        }
+        StringBuffer sb = new StringBuffer(" throws ");
+        int comma = 0;
+        for (Iterator i = iterator(); i.hasNext(); comma++) {
+            String type = (String) i.next();
+            if (comma > 0) {
+                sb.append(", ");
+            }
+            sb.append(type);
+        }
+        return sb.toString();
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/ExceptionUtil.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/ExceptionUtil.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/ExceptionUtil.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,151 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.util;
+
+import java.io.BufferedReader;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.geronimo.interop.CheckedException;
+import org.apache.geronimo.interop.SystemException;
+
+
+public abstract class ExceptionUtil {
+    public static List addException(List exceptions, Throwable ex) {
+        if (exceptions == null) {
+            exceptions = new ArrayList(1);
+        }
+        exceptions.add(ex);
+        return exceptions;
+    }
+
+    public static void checkExceptions(List exceptions) {
+        if (exceptions != null) {
+            int n = exceptions.size();
+            if (n == 1) {
+                Throwable ex = (Throwable) exceptions.get(0);
+                if (ex instanceof Error) {
+                    throw (Error) ex;
+                }
+                if (ex instanceof RuntimeException) {
+                    throw (RuntimeException) ex;
+                }
+                throw new SystemException(ex);
+            } else {
+                StringBuffer buffer = new StringBuffer();
+                for (Iterator i = exceptions.iterator(); i.hasNext();) {
+                    Exception ex = (Exception) i.next();
+                    if (buffer.length() > 0) {
+                        buffer.append("\n______________________________________________________________\n\n");
+                    }
+                    buffer.append(ExceptionUtil.getStackTrace(ex));
+                }
+                throw new SystemException(buffer.toString());
+            }
+        }
+    }
+
+    public static String getDivider() {
+        return "\n        ______________________________________________________________\n";
+    }
+
+    /**
+     * * Construct a detail message for an exception which doesn't take a
+     * * cause parameter in its constructor.
+     */
+    public static String causedBy(Throwable ex) {
+        return "\nCaused by: " + getStackTrace(ex) + getDivider();
+    }
+
+    public static String getCauseChain(Throwable ex) {
+        String stackTrace = getStackTrace(ex);
+        return getCauseChain(stackTrace);
+    }
+
+    public static String getCauseChain(String stackTrace) {
+        try {
+            BufferedReader input = new BufferedReader(new StringReader(stackTrace));
+            StringBuffer output = new StringBuffer(100);
+            String line;
+            while ((line = input.readLine()) != null) {
+                line = line.trim();
+                if (!line.startsWith("at ") && !line.startsWith("... ")) {
+                    output.append(line);
+                    output.append('\n');
+                }
+            }
+            return output.toString();
+        } catch (Exception ex2) {
+            ex2.printStackTrace();
+            return stackTrace;
+        }
+    }
+
+    public static String getStackTrace(Throwable ex) {
+        java.io.StringWriter sw = new java.io.StringWriter();
+        java.io.PrintWriter pw = new java.io.PrintWriter(sw);
+        ex.printStackTrace(pw);
+        return sw.toString().trim();
+    }
+
+    public static String getCurrentStackTrace() {
+        return StringUtil.removePrefix(getStackTrace(new Exception()), "java.lang.Exception:");
+    }
+
+    public static String indentLines(String lines) {
+        return "    " + StringUtil.replace(lines.trim(), "\n", "\n    ");
+    }
+
+    public static boolean isApplicationException(Throwable ex) {
+        return !isSystemException(ex);
+    }
+
+    public static boolean isSystemException(Throwable ex) {
+        Class exClass = ex.getClass();
+        return Error.class.isAssignableFrom(exClass)
+               || RuntimeException.class.isAssignableFrom(exClass);
+    }
+
+    public static boolean isUserException(Class exClass) {
+        if (RuntimeException.class.isAssignableFrom(exClass)
+            || Error.class.isAssignableFrom(exClass)) {
+            return false;
+        }
+        return true;
+    }
+
+    public static RuntimeException getRuntimeException(Exception ex) {
+        if (ex instanceof RuntimeException) {
+            return (RuntimeException) ex;
+        } else {
+            return new SystemException(ex);
+        }
+    }
+
+    public static RuntimeException rethrow(Throwable ex) {
+        if (ex instanceof Error) {
+            throw (Error) ex;
+        } else if (ex instanceof RuntimeException) {
+            return (RuntimeException) ex;
+        } else {
+            return new CheckedException(ex);
+        }
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/FileUtil.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/FileUtil.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/FileUtil.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,301 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.util;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.geronimo.interop.SystemException;
+import org.apache.geronimo.interop.properties.SystemProperties;
+
+
+public abstract class FileUtil {
+    // private data
+
+    private static int _tempIndex;
+
+    private static Object _tempIndexLock = new Object();
+
+    // public methods
+
+    public static int compareLines(String file1, String file2) {
+        return compareLines(file1, file2, false);
+    }
+
+    public static int compareLines(String file1, String file2, boolean removeTopLevelComments) {
+        String lines1 = readLines(file1, removeTopLevelComments);
+        String lines2 = readLines(file2, removeTopLevelComments);
+        return lines1.compareTo(lines2);
+    }
+
+    public static void copyDir(String fromDir, String toDir) {
+        copyDir(fromDir, toDir, true);
+    }
+
+    public static void copyDir(String fromDir, String toDir, boolean rec) {
+        File dirFile = new File(fromDir);
+        if (!dirFile.exists()) {
+            return;
+        }
+
+        File toDirFile = new File(toDir);
+        if (!toDirFile.exists()) {
+            toDirFile.mkdir();
+        }
+        String[] fileList = dirFile.list();
+        if (fileList != null) {
+            for (int i = 0; i < fileList.length; i++) {
+                String name = fileList[i];
+                String from = fromDir + File.separator + name;
+                String to = toDir + File.separatorChar + name;
+                File file = new File(from);
+                if (file.isDirectory()) {
+                    if (rec) {
+                        copyDir(from, to);
+                    }
+                } else {
+                    copyFile(from, to);
+                }
+            }
+        }
+    }
+
+    public static void copyFile(String from, String to) {
+        mkdirs(to);
+        try {
+            InputStream input = new BufferedInputStream(new FileInputStream(from));
+            OutputStream output = new BufferedOutputStream(new FileOutputStream(to));
+            int c;
+            while ((c = input.read()) != -1) {
+                output.write(c);
+            }
+            input.close();
+            output.close();
+        } catch (IOException ex) {
+            throw new SystemException(ex);
+        }
+    }
+
+    public static void copyFiles(String fromDir, String toDir, List files) {
+        for (Iterator i = files.iterator(); i.hasNext();) {
+            String file = (String) i.next();
+            copyFile(fromDir + "/" + file, toDir + "/" + file);
+        }
+    }
+
+    public static void deleteDir(String dir) {
+        File dirFile = new File(dir);
+        if (dirFile.exists()) {
+            deleteFilesInDir(dir);
+            dirFile.delete();
+        }
+    }
+
+    public static void deleteFile(String file) {
+        new File(file).delete();
+    }
+
+    public static void deleteFiles(List files) {
+        for (Iterator i = files.iterator(); i.hasNext();) {
+            String fileName = (String) i.next();
+            File file = new File(fileName);
+            file.delete();
+        }
+    }
+
+    public static void deleteFilesInDir(String dir) {
+        File dirFile = new File(dir);
+        String[] fileList = dirFile.list();
+        if (fileList != null) {
+            for (int i = 0; i < fileList.length; i++) {
+                String path = dir + File.separator + fileList[i];
+                File file = new File(path);
+                if (file.isDirectory()) {
+                    deleteDir(path);
+                }
+                file.delete();
+            }
+        }
+    }
+
+    public static String expandHomeRelativePath(String path) {
+        if (path.startsWith("~")) {
+            path = SystemProperties.getHome() + path.substring(1);
+        }
+        return path;
+    }
+
+    public static List findFiles(String baseDir) {
+        return findFiles(baseDir, "", true, true, "");
+    }
+
+    public static List findFiles(String baseDir, String pattern) {
+        return findFiles(baseDir, pattern, true, true, "");
+    }
+
+    public static List findFiles(String baseDir, String pattern, boolean fullPath, boolean recursive) {
+        return findFiles(baseDir, pattern, fullPath, recursive, "");
+    }
+
+    private static List findFiles(String baseDir, String pattern, boolean fullPath, boolean recursive, String relativeBase) {
+        if (pattern.equals("**")) {
+            pattern = ""; // Equivalent to "*"
+            recursive = true;
+        }
+        final String prefix = StringUtil.beforeFirst("*", pattern);
+        final String suffix = StringUtil.afterFirst("*", pattern);
+        final boolean finalRecursive = recursive;
+        FilenameFilter filter = new FilenameFilter() {
+            public boolean accept(File file, String name) {
+                if (finalRecursive && new File(file.getPath() + File.separator + name).isDirectory()) {
+                    return true;
+                }
+                return name.startsWith(prefix) && name.endsWith(suffix);
+            }
+        }
+                ;
+        List list = new LinkedList();
+        File dirFile = new File(baseDir);
+        String[] files = dirFile.list(filter);
+        if (files != null) {
+            int n = files.length;
+            for (int i = 0; i < n; i++) {
+                String fileName = files[i];
+                String fullName = baseDir.length() == 0 ? fileName
+                                  : (baseDir + (fullPath ? File.separatorChar : '/') + fileName);
+                File file = new File(fullName);
+                if (file.isDirectory()) {
+                    if (recursive) {
+                        String relativeName = relativeBase.length() == 0 ? fileName
+                                              : (relativeBase + '/' + fileName);
+                        list.addAll(findFiles(fullName, pattern, fullPath,
+                                              recursive, relativeName));
+                    }
+                } else if (fullPath) {
+                    list.add(fullName);
+                } else {
+                    String relativeName = relativeBase.length() == 0 ? fileName
+                                          : (relativeBase + '/' + fileName);
+                    list.add(relativeName);
+                }
+            }
+        }
+        return list;
+    }
+
+    public static void mkdir(String dir) {
+        try {
+            new File(dir).mkdirs();
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+    }
+
+    public static void mkdirs(String file) {
+        try {
+            file = file.replace('/', File.separatorChar);
+            int pos = file.lastIndexOf(File.separatorChar);
+            if (pos != -1) {
+                String dir = file.substring(0, pos);
+                mkdir(dir);
+            }
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+    }
+
+    public static String newTempDir() {
+        String tempDir = SystemProperties.getTempDir();
+        synchronized (_tempIndexLock) {
+            tempDir += "/" + (++_tempIndex);
+        }
+        tempDir = pretty(tempDir);
+        deleteFilesInDir(tempDir);
+        mkdirs(tempDir + "/x.x");
+        return tempDir;
+    }
+
+    public static String pretty(String file) {
+        try {
+            return new File(file).getCanonicalPath();
+        } catch (Exception ignore) {
+            return file.replace('/', File.separatorChar);
+        }
+    }
+
+    /**
+     * * Read all bytes of a file into an array.
+     */
+    public static byte[] readBytes(String fileName) {
+        try {
+            ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+            InputStream input = new BufferedInputStream(new FileInputStream(fileName));
+            int c;
+            while ((c = input.read()) != -1) {
+                bytes.write((byte) c);
+            }
+            input.close();
+            return bytes.toByteArray();
+        } catch (IOException ex) {
+            throw new SystemException(ex);
+        }
+    }
+
+    public static String readLines(String fileName) {
+        return readLines(fileName, false);
+    }
+
+    /**
+     * * Read all lines of a file into a string, optionally removing comments.
+     */
+    public static String readLines(String fileName, boolean removeTopLevelComments) {
+        try {
+            StringBuffer code = new StringBuffer();
+            BufferedReader input = new BufferedReader(new FileReader(fileName));
+            String line;
+            while ((line = input.readLine()) != null) {
+                if (removeTopLevelComments && line.length() >= 3) {
+                    char c1 = line.charAt(1);
+                    char c2 = line.charAt(2);
+                    if (c1 == '*' && c2 == '*') {
+                        continue;
+                    }
+                }
+                code.append(line);
+                code.append('\n');
+            }
+            input.close();
+            return code.toString();
+        } catch (IOException ex) {
+            throw new SystemException(ex);
+        }
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/FutureObject.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/FutureObject.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/FutureObject.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,57 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.util;
+
+/**
+ * * A multiprocessor-safe wrapper to defer evaluation of an object until it
+ * * is needed.
+ */
+public abstract class FutureObject {
+    private static final boolean _volatileIsEffectiveMemoryBarrier = MemoryBarrier.USE_VOLATILE;
+
+    private volatile boolean _evaluated = false;
+
+    private Object _value;
+
+    /**
+     * * Sub-classes should override this method to get the object's value
+     * * when it is first needed.
+     */
+    public abstract Object evaluate();
+
+    public final Object getValue() {
+        if (_volatileIsEffectiveMemoryBarrier) {
+            if (!_evaluated) {
+                synchronized (this) {
+                    if (!_evaluated) {
+                        _value = evaluate();
+                        _evaluated = true;
+                    }
+                }
+            }
+        } else {
+            synchronized (this) {
+                if (!_evaluated) {
+                    _value = evaluate();
+                    _evaluated = true;
+                }
+            }
+        }
+        return _value;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/InstancePool.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/InstancePool.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/InstancePool.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,165 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.util;
+
+
+
+
+public class InstancePool {
+    // -----------------------------------------------------------------------
+    // inner classes
+    // -----------------------------------------------------------------------
+
+    private static class Entry {
+        Object object;
+        long timeout;
+        Entry next;
+    }
+
+    // -----------------------------------------------------------------------
+    // private data
+    // -----------------------------------------------------------------------
+
+    private Entry _stack = null;
+
+    private Entry _freeList = null;
+
+    private long _idleTimeout;
+
+    // -----------------------------------------------------------------------
+    // public methods
+    // -----------------------------------------------------------------------
+
+    public InstancePool(String name) {
+        init(name, 0); //, null);
+    }
+
+    public InstancePool(String name, long idleTimeout) // , TimeoutObject timeoutObject)
+    {
+        init(name, idleTimeout); //, timeoutObject);
+    }
+
+    public Object get() {
+        synchronized (this) {
+            Entry top = _stack;
+            if (top != null) {
+                _stack = top.next;
+                //_size.decrement();
+                Object object = top.object;
+                top.object = null;
+                top.next = _freeList;
+                _freeList = top;
+                return object;
+            } else {
+                return null;
+            }
+        }
+    }
+
+    public void put(Object object) {
+        synchronized (this) {
+            //_size.increment();
+            Entry top = _freeList;
+            if (top != null) {
+                _freeList = top.next;
+            } else {
+                top = new Entry();
+            }
+            top.object = object;
+            if (_idleTimeout > 0) {
+                top.timeout = System.currentTimeMillis() + _idleTimeout;
+            }
+            top.next = _stack;
+            _stack = top;
+        }
+    }
+
+    // -----------------------------------------------------------------------
+    // private methods
+    // -----------------------------------------------------------------------
+
+    private void init(final String name, long idleTimeout) //, final TimeoutObject timeoutObject)
+    {
+        //_size = sizeStatistic.getInstance(name);
+        _idleTimeout = idleTimeout;
+
+        if (_idleTimeout > 0) {
+            /*
+            long now = SystemClock.getLastSampleTime();
+            final long checkInterval = _idleTimeout > 10 ? (_idleTimeout / 10) : _idleTimeout;
+            Task timeoutTask = new Task()
+            {
+                public long run(long time)
+                {
+                    Entry restoreStack = null;
+                    Entry timeoutChain = null;
+                    synchronized (InstancePool.this)
+                    {
+                        while (_stack != null)
+                        {
+                            Entry entry = _stack;
+                            _stack = entry.next;
+                            if (entry.timeout > time)
+                            {
+                                entry.next = restoreStack;
+                                restoreStack = entry;
+                            }
+                            else
+                            {
+                                entry.next = timeoutChain;
+                                timeoutChain = entry;
+                                _size.decrement();
+                            }
+                        }
+
+                        // Restore still-active entries to the stack in
+                        // their original order. This ensures that less
+                        // frequently used entries stay at the bottom of
+                        // the stack, becoming elegible for timeout.
+                        while (restoreStack != null)
+                        {
+                            Entry entry = restoreStack;
+                            restoreStack = entry.next;
+                            entry.next = _stack;
+                            _stack = entry;
+                        }
+                    }
+                    while (timeoutChain != null)
+                    {
+                        Entry entry = timeoutChain;
+                        timeoutChain = entry.next;
+                        try
+                        {
+                            timeoutObject.onTimeout(entry.object);
+                        }
+                        catch (Throwable ex)
+                        {
+                            ExceptionLog.getInstance().log(ex, InstancePool.class.getName() + ".onTimeout(" + name + ")");
+                        }
+                        entry.object = null;
+                        entry.next = null;
+                    }
+                    return time + checkInterval;
+                }
+            }
+            ;
+            TaskScheduler.getInstance().start(timeoutTask, now);
+            */
+        }
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/IntegerCache.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/IntegerCache.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/IntegerCache.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,41 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.util;
+
+public abstract class IntegerCache {
+    private static final int MIN_VALUE = -999;
+    private static final int MAX_VALUE = 9999;
+
+    private static final Integer[] CACHE = getCache();
+
+    public static Integer get(int i) {
+        if (i >= MIN_VALUE && i <= MAX_VALUE) {
+            return CACHE[i - MIN_VALUE];
+        } else {
+            return new Integer(i);
+        }
+    }
+
+    private static Integer[] getCache() {
+        Integer[] cache = new Integer[1 + MAX_VALUE - MIN_VALUE];
+        for (int i = MIN_VALUE; i <= MAX_VALUE; i++) {
+            cache[i - MIN_VALUE] = new Integer(i);
+        }
+        return cache;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/JavaClass.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/JavaClass.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/JavaClass.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,197 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.util;
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.geronimo.interop.properties.StringProperty;
+import org.apache.geronimo.interop.properties.SystemProperties;
+
+
+public abstract class JavaClass {
+    // -----------------------------------------------------------------------
+    // properties
+    // -----------------------------------------------------------------------
+
+    public static final StringProperty classDirProperty =
+            new StringProperty(SystemProperties.class, "org.apache.geronimo.interop.classDir")
+            .defaultValue(FileUtil.pretty(SystemProperties.getHome() + "/genfiles/java/classes"));
+
+    public static final StringProperty classPathProperty =
+            new StringProperty(SystemProperties.class, "org.apache.geronimo.interop.classPath")
+            .defaultValue(FileUtil.pretty(SystemProperties.getHome() + "/genfiles/java/classes"));
+
+    public static final StringProperty sourceDirProperty =
+            new StringProperty(SystemProperties.class, "org.apache.geronimo.interop.sourceDir")
+            .defaultValue(FileUtil.pretty(SystemProperties.getHome() + "/genfiles/java/src"));
+
+    public static final StringProperty sourcePathProperty =
+            new StringProperty(SystemProperties.class, "org.apache.geronimo.interop.sourcePath")
+            .defaultValue(FileUtil.pretty(SystemProperties.getHome() + "/src/java")
+                          + File.pathSeparator
+                          + FileUtil.pretty(SystemProperties.getHome() + "/genfiles/java/src"));
+
+    // -----------------------------------------------------------------------
+    // private data
+    // -----------------------------------------------------------------------
+
+    private static String _classDir = classDirProperty.getString();
+
+    private static List _classPath = ListUtil.getPathList(classPathProperty.getString());
+
+    private static String _sourceDir = sourceDirProperty.getString();
+
+    private static List _sourcePath = ListUtil.getPathList(sourcePathProperty.getString());
+
+    // -----------------------------------------------------------------------
+    // public methods
+    // -----------------------------------------------------------------------
+
+    public static String addPackageSuffix(String className, String suffix) {
+        String jp = getPackagePrefix(className);
+        if (jp.length() == 0) {
+            jp = suffix;
+        } else {
+            jp += "." + suffix;
+        }
+        return jp + "." + getNameSuffix(className);
+    }
+
+    public static String getClassDir() {
+        return _classDir;
+    }
+
+    public static List getClassPath() {
+        return _classPath;
+    }
+
+    public static File getClassFile(Class theClass) {
+        return getClassFile(theClass.getName());
+    }
+
+    public static File getClassFile(String className) {
+        for (Iterator i = _classPath.iterator(); i.hasNext();) {
+            String dir = (String) i.next();
+            String fileName = FileUtil.pretty(dir + "/" + className.replace('.', '/') + ".class");
+            File classFile = new File(fileName);
+            if (classFile.exists()) {
+                return classFile;
+            }
+        }
+        return null;
+    }
+
+    public static String getName(String packagePrefix, String nameSuffix) {
+        if (packagePrefix == null || packagePrefix.length() == 0) {
+            return nameSuffix;
+        } else {
+            return packagePrefix + "." + nameSuffix;
+        }
+    }
+
+    public static String getNamePrefix(String className) {
+        return StringUtil.beforeLast(".", className);
+    }
+
+    public static String getNameSuffix(String className) {
+        return StringUtil.afterLast(".", className);
+    }
+
+    public static String getPackagePrefix(String className) {
+        return getNamePrefix(className);
+    }
+
+    /**
+     * * Compute the JVM signature for a class.
+     */
+    public static String getSignature(Class clazz) {
+        String type = null;
+        if (clazz.isArray()) {
+            Class cl = clazz;
+            int dimensions = 0;
+            while (cl.isArray()) {
+                dimensions++;
+                cl = cl.getComponentType();
+            }
+            StringBuffer sb = new StringBuffer();
+            for (int i = 0; i < dimensions; i++) {
+                sb.append("[");
+            }
+            sb.append(getSignature(cl));
+            type = sb.toString();
+        } else if (clazz.isPrimitive()) {
+            if (clazz == Integer.TYPE) {
+                type = "I";
+            } else if (clazz == Byte.TYPE) {
+                type = "B";
+            } else if (clazz == Long.TYPE) {
+                type = "J";
+            } else if (clazz == Float.TYPE) {
+                type = "F";
+            } else if (clazz == Double.TYPE) {
+                type = "D";
+            } else if (clazz == Short.TYPE) {
+                type = "S";
+            } else if (clazz == Character.TYPE) {
+                type = "C";
+            } else if (clazz == Boolean.TYPE) {
+                type = "Z";
+            } else if (clazz == Void.TYPE) {
+                type = "V";
+            }
+
+        } else {
+            type = "L" + clazz.getName().replace('.', '/') + ";";
+        }
+        return type;
+    }
+
+    public static String getSourceDir() {
+        return _sourceDir;
+    }
+
+    public static File getSourceFile(Class theClass) {
+        return getSourceFile(theClass.getName());
+    }
+
+    public static File getSourceFile(String className) {
+        for (Iterator i = _sourcePath.iterator(); ;) {
+            String dir;
+            if (i.hasNext()) {
+                dir = (String) i.next();
+            } else {
+                dir = _sourceDir;
+            }
+            String fileName = FileUtil.pretty(dir + "/" + className.replace('.', '/') + ".java");
+            File sourceFile = new File(fileName);
+            if (sourceFile.exists()) {
+                return sourceFile;
+            }
+            if (dir == _sourceDir) {
+                break;
+            }
+        }
+        return null;
+    }
+
+    public static List getSourcePath() {
+        return _sourcePath;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/JavaMethod.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/JavaMethod.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/JavaMethod.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,163 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.util;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.HashMap;
+
+import org.apache.geronimo.interop.SystemException;
+
+
+/**
+ * * Utility methods for obtaining method signatures and calling static
+ * * methods on dynamically loaded classes.
+ */
+public class JavaMethod {
+    private static HashMap _methodMap = new HashMap();
+
+    public static Method[] add(Method m, Method[] a) {
+        Method[] b = new Method[a.length + 1];
+        System.arraycopy(a, 0, b, 0, a.length);
+        b[a.length] = m;
+        return b;
+    }
+
+    /**
+     * * Return the short signature of a method.
+     * * A short signature is "method-name(parameter-type, ...)".
+     */
+    public static String getShortSignature(String methodName, Class[] parameterTypes) {
+        StringBuffer sb = new StringBuffer();
+        sb.append(methodName);
+        sb.append('(');
+        int n = parameterTypes.length;
+        for (int i = 0; i < n; i++) {
+            if (i > 0) {
+                sb.append(", ");
+            }
+            sb.append(JavaType.getName(parameterTypes[i]));
+        }
+        sb.append(')');
+        return sb.toString();
+    }
+
+    public static String getShortSignature(Method m) {
+        return getShortSignature(m.getName(), m.getParameterTypes());
+    }
+
+    /**
+     * * Return the long signature of a method.
+     * * A long signature is "return-type class-name.method-name(parameter-type, ...)".
+     */
+    public static String getLongSignature(Class returnType, String className, String methodName, Class[] parameterTypes) {
+        return JavaType.getName(returnType) + " " + className + "." + getShortSignature(methodName, parameterTypes);
+    }
+
+    public static String getLongSignature(Method m) {
+        return getLongSignature(m.getReturnType(), m.getDeclaringClass().getName(), m.getName(), m.getParameterTypes());
+    }
+
+    public static String getLongSignature(Class c, Method m) {
+        return getLongSignature(m.getReturnType(), c.getName(), m.getName(), m.getParameterTypes());
+    }
+
+    public static Method getMethod(String methodSignature) {
+        Method method = (Method) _methodMap.get(methodSignature);
+        if (method == null) {
+            synchronized (_methodMap) {
+                method = (Method) _methodMap.get(methodSignature);
+                if (method == null) {
+                    int parenPos = methodSignature.indexOf('(');
+                    if (parenPos == -1) {
+                        throw new IllegalArgumentException("methodSignature = " + methodSignature);
+                    }
+                    String fullMethodName = methodSignature.substring(0, parenPos);
+                    String className = JavaClass.getNamePrefix(fullMethodName);
+                    String methodName = JavaClass.getNameSuffix(fullMethodName);
+                    String parameters = methodSignature.substring(parenPos);
+                    String shortSig = methodName + parameters;
+                    Class theClass = ThreadContext.loadClass(className);
+                    Method[] methods = theClass.getMethods();
+                    int n = methods.length;
+                    for (int i = 0; i < n; i++) {
+                        method = methods[i];
+                        if (shortSig.equals(JavaMethod.getShortSignature(method))) {
+                            _methodMap.put(methodSignature, method);
+                            break;
+                        }
+                    }
+                }
+            }
+        }
+        if (method == null) {
+            throw new IllegalArgumentException("method = " + methodSignature + " (not found)");
+        }
+        return method;
+    }
+
+    public static Method getInstanceMethod(String methodSignature) {
+        Method method = getMethod(methodSignature);
+        if (Modifier.isStatic(method.getModifiers())) {
+            throw new IllegalArgumentException("method = " + methodSignature + " (static)");
+        }
+        return method;
+    }
+
+    public static Method getStaticMethod(String methodSignature) {
+        Method method = getMethod(methodSignature);
+        if (!Modifier.isStatic(method.getModifiers())) {
+            throw new IllegalArgumentException("method = " + methodSignature + " (not static)");
+        }
+        return method;
+    }
+
+    public static Object invokeStatic(String methodSignature, Object p1) {
+        return invokeStatic(methodSignature, new Object[]
+        {
+            p1
+        });
+    }
+
+    public static Object invokeStatic(String methodSignature, Object p1, Object p2) {
+        return invokeStatic(methodSignature, new Object[]
+        {
+            p1, p2
+        });
+    }
+
+    public static Object invokeStatic(String methodSignature, Object p1, Object p2, Object p3) {
+        return invokeStatic(methodSignature, new Object[]
+        {
+            p1, p2, p3
+        });
+    }
+
+    public static Object invokeStatic(String methodSignature, Object[] args) {
+        try {
+            return getStaticMethod(methodSignature).invoke(null, args);
+        } catch (InvocationTargetException ite) {
+            throw new SystemException(ite.getTargetException());
+        } catch (RuntimeException ex) {
+            throw ex;
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/JavaObject.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/JavaObject.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/JavaObject.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,65 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import org.apache.geronimo.interop.SystemException;
+
+
+public abstract class JavaObject {
+    public static byte[] toByteArray(Object object) {
+        if (object == null) {
+            return null;
+        }
+        try {
+            ByteArrayOutputStream bs = new ByteArrayOutputStream();
+            ObjectOutputStream os = new ObjectOutputStream(bs);
+            os.writeObject(object);
+            // Ensure last byte is not NUL. Avoids truncation of values when
+            // stored in Sybase ASE databases.
+            os.writeByte((byte) '.');
+            os.flush();
+            byte[] buffer = bs.toByteArray();
+            os.close();
+            bs.close();
+            return buffer;
+        } catch (Exception ex) {
+            throw new SystemException("JavaObject.toByteArray", ex);
+        }
+    }
+
+    public static java.lang.Object fromByteArray(byte[] buffer) {
+        if (buffer == null) {
+            return null;
+        }
+        try {
+            ByteArrayInputStream bs = new ByteArrayInputStream(buffer);
+            ObjectInputStream is = new ObjectInputStream(bs);
+            Object object = is.readObject();
+            is.close();
+            bs.close();
+            return object;
+        } catch (Exception ex) {
+            throw new SystemException("JavaObject.fromByteArray", ex);
+        }
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/JavaType.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/JavaType.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/JavaType.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,91 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.util;
+
+import java.util.HashMap;
+
+
+public abstract class JavaType {
+    private static HashMap _wrapper = new HashMap();
+
+    static {
+        _wrapper.put("boolean", "java.lang.Boolean");
+        _wrapper.put("byte", "java.lang.Byte");
+        _wrapper.put("char", "java.lang.Character");
+        _wrapper.put("double", "java.lang.Double");
+        _wrapper.put("float", "java.lang.Float");
+        _wrapper.put("int", "java.lang.Integer");
+        _wrapper.put("long", "java.lang.Long");
+        _wrapper.put("short", "java.lang.Short");
+    }
+
+    /**
+     * * Return the name of a type as would be referenced in source code,
+     * * e.g. "int", "byte[]", "java.lang.String", "java.lang.Object[][]".
+     */
+    public static String getName(Class t) {
+        if (t.isArray()) {
+            return getName(t.getComponentType()) + "[]";
+        } else {
+            return t.getName().replace('$', '.');
+        }
+    }
+
+    public static String wrapper(String type) {
+        return (String) _wrapper.get(type);
+    }
+
+    public static String wrapper(Class type) {
+        return wrapper(getName(type));
+    }
+
+    public static String wrap(String type, String name) {
+        String w = wrapper(type);
+        return w != null ? ("new " + w + "(" + name + ")") : name;
+    }
+
+    public static String wrap(Class type, String name) {
+        return wrap(getName(type), name);
+    }
+
+    public static String unwrap(String type, String name) {
+        String w = wrapper(type);
+        return w != null ? ("((" + w + ")" + name + ")." + type + "Value()") : name;
+    }
+
+    public static String unwrap(Class type, String name) {
+        return unwrap(getName(type), name);
+    }
+
+    public static String unwrapObject(Class type, Object expression) {
+        return unwrapObject(getName(type), expression);
+    }
+
+    public static String unwrapObject(String type, Object expression) {
+        String w = wrapper(type);
+        if (w == null) {
+            if (type.equals("java.lang.Object")) {
+                return expression.toString();
+            } else {
+                return "(" + type + ")" + expression;
+            }
+        } else {
+            return "((" + w + ")" + expression + ")." + type + "Value()";
+        }
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/ListUtil.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/ListUtil.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/ListUtil.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,135 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+
+public class ListUtil {
+    // -----------------------------------------------------------------------
+    // public methods
+    // -----------------------------------------------------------------------
+
+    public static void addIfNotPresent(List list, Object item) {
+        if (!list.contains(item)) {
+            list.add(item);
+        }
+    }
+
+    public static ArrayList getCommaSeparatedList(String arg) {
+        return getListWithSeparator(arg, ",");
+    }
+
+    public static ArrayList getPathList(String arg) {
+        return getListWithSeparator(arg, java.io.File.pathSeparator);
+    }
+
+    public static ArrayList getSpaceSeparatedList(String arg) {
+        return getListWithSeparator(arg.replace('\t', ' ').replace('\r', ' ').replace('\n', ' '), " ");
+    }
+
+    public static ArrayList getListWithSeparator(String text, String separator) {
+        ArrayList list = new ArrayList();
+        int n = text.length();
+        StringBuffer item = new StringBuffer();
+        char endQuote = 0;
+        for (int i = 0; i < n; i++) {
+            if (endQuote == 0 && text.startsWith(separator, i)) {
+                add(list, item);
+                i += separator.length() - 1;
+            } else {
+                char c = text.charAt(i);
+                item.append(c);
+                if (endQuote != 0) {
+                    if (c == endQuote) {
+                        endQuote = 0;
+                    }
+                } else if (c == '\'' || c == '\"') {
+                    endQuote = c;
+                }
+            }
+        }
+        add(list, item);
+        return list;
+    }
+
+    public static String formatCommaSeparatedList(Collection list) {
+        return formatListWithSeparator(list, ",");
+    }
+
+    public static String formatSpaceSeparatedList(Collection list) {
+        return formatListWithSeparator(list, " ");
+    }
+
+    public static String formatListWithSeparator(Collection list, String separator) {
+        StringBuffer buffer = new StringBuffer();
+        for (Iterator i = list.iterator(); i.hasNext();) {
+            Object item = i.next();
+            if (buffer.length() != 0) {
+                buffer.append(separator);
+            }
+            buffer.append(item.toString());
+        }
+        return buffer.toString();
+    }
+
+    public static ArrayList getArrayList(Object[] array) {
+        int n = array.length;
+        ArrayList list = new ArrayList(n);
+        for (int i = 0; i < n; i++) {
+            list.add(array[i]);
+        }
+        return list;
+    }
+
+    public static String[] getStringArray(List list) {
+        int n = list.size();
+        String[] array = new String[n];
+        int i = 0;
+        for (Iterator j = list.iterator(); j.hasNext(); i++) {
+            String s = (String) j.next();
+            array[i] = s;
+        }
+        return array;
+    }
+
+    public static void printAll(java.io.PrintStream out, String rowPrefix, Collection values) {
+        for (Iterator i = values.iterator(); i.hasNext();) {
+            Object value = i.next();
+            if (rowPrefix != null) {
+                out.print(rowPrefix);
+            }
+            out.println(value);
+        }
+    }
+
+    // -----------------------------------------------------------------------
+    // private methods
+    // -----------------------------------------------------------------------
+
+    private static void add(List list, StringBuffer itemBuffer) {
+        String item = itemBuffer.toString().trim();
+        if (item.length() != 0) {
+            list.add(item);
+        }
+        itemBuffer.setLength(0);
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/LittleEndian.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/LittleEndian.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/LittleEndian.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,101 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.util;
+
+public abstract class LittleEndian {
+    public static byte[] getShortBytes(short value) {
+        byte[] bytes = new byte[2];
+        setShort(bytes, value);
+        return bytes;
+    }
+
+    public static byte[] getIntBytes(int value) {
+        byte[] bytes = new byte[4];
+        setInt(bytes, value);
+        return bytes;
+    }
+
+    public static byte[] getLongBytes(long value) {
+        byte[] bytes = new byte[8];
+        setLong(bytes, value);
+        return bytes;
+    }
+
+    public static short getShort(byte[] bytes) {
+        return getShort(bytes, 0);
+    }
+
+    public static short getShort(byte[] bytes, int offset) {
+        int b1 = (bytes[offset + 1] << 8) & 0x0000ff00;
+        int b0 = bytes[offset] & 0x000000ff;
+        return (short) (b1 | b0);
+    }
+
+    public static int getInt(byte[] bytes) {
+        return getInt(bytes, 0);
+    }
+
+    public static int getInt(byte[] bytes, int offset) {
+        int b3 = (bytes[offset + 3] << 24) & 0xff000000;
+        int b2 = (bytes[offset + 2] << 16) & 0x00ff0000;
+        int b1 = (bytes[offset + 1] << 8) & 0x0000ff00;
+        int b0 = bytes[offset] & 0x000000ff;
+        return b3 | b2 | b1 | b0;
+    }
+
+    public static long getLong(byte[] bytes) {
+        return getLong(bytes, 0);
+    }
+
+    public static long getLong(byte[] bytes, int offset) {
+        long hi = getInt(bytes, offset + 4) & 0xffffffffL;
+        long lo = getInt(bytes, offset) & 0xffffffffL;
+        return (lo << 32) | hi;
+    }
+
+    public static void setShort(byte[] bytes, short value) {
+        setShort(bytes, 0, value);
+    }
+
+    public static void setShort(byte[] bytes, int offset, short value) {
+        bytes[offset] = (byte) (value & 0xff);
+        bytes[offset + 1] = (byte) ((value >>> 8) & 0xff);
+    }
+
+    public static void setInt(byte[] bytes, int value) {
+        setInt(bytes, 0, value);
+    }
+
+    public static void setInt(byte[] bytes, int offset, int value) {
+        bytes[offset] = (byte) (value & 0xff);
+        bytes[offset + 1] = (byte) ((value >>> 8) & 0xff);
+        bytes[offset + 2] = (byte) ((value >>> 16) & 0xff);
+        bytes[offset + 3] = (byte) ((value >>> 24) & 0xff);
+    }
+
+    public static void setLong(byte[] bytes, long value) {
+        setLong(bytes, 0, value);
+    }
+
+    public static void setLong(byte[] bytes, int offset, long value) {
+        int hi = (int) (value >>> 32);
+        int lo = (int) value;
+        setInt(bytes, offset + 4, hi);
+        setInt(bytes, offset, lo);
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/MemoryBarrier.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/MemoryBarrier.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/MemoryBarrier.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,30 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.util;
+
+import org.apache.geronimo.interop.properties.BooleanProperty;
+import org.apache.geronimo.interop.properties.SystemProperties;
+
+
+public abstract class MemoryBarrier {
+    public static BooleanProperty useVolatileMemoryBarrierProperty =
+            new BooleanProperty(SystemProperties.class, "org.apache.geronimo.interop.useVolatileMemoryBarrier")
+            .defaultValue(true);
+
+    public static final boolean USE_VOLATILE = useVolatileMemoryBarrierProperty.getBoolean();
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/MethodParameter.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/MethodParameter.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/MethodParameter.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,42 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.util;
+
+public class MethodParameter {
+    public final String type;
+
+    public String name; // allow renaming
+
+    public MethodParameter(String type, String name) {
+        this.type = type;
+        this.name = name;
+    }
+
+    public MethodParameter(Class type, String name) {
+        this.type = JavaType.getName(type);
+        this.name = name;
+    }
+
+    public String getObject() {
+        return JavaType.wrap(type, name);
+    }
+
+    public String toString() {
+        return "[MethodParameter: " + type + " " + name + "]";
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/NamedValue.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/NamedValue.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/NamedValue.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,41 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.util;
+
+public class NamedValue {
+    public String name;
+
+    public String value;
+
+    public NamedValue(String name, String value) {
+        this.name = name;
+        this.value = value;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public String toString() {
+        return name + "=" + value;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/NamedValueList.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/NamedValueList.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/NamedValueList.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,76 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.util;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.geronimo.interop.properties.PropertyMap;
+
+
+public class NamedValueList extends LinkedList {
+    public NamedValueList() {
+    }
+
+    public NamedValueList(String namedValueList) {
+        List csvList = ListUtil.getCommaSeparatedList(namedValueList);
+        for (Iterator i = csvList.iterator(); i.hasNext();) {
+            String item = (String) i.next();
+            int eqPos = item.indexOf("=");
+            if (eqPos == -1) {
+                badList(namedValueList);
+            }
+            String name = item.substring(0, eqPos).trim();
+            if (name.length() == 0) {
+                badList(namedValueList);
+            }
+            String value = item.substring(eqPos + 1).trim();
+            add(new NamedValue(name, value));
+        }
+    }
+
+    // public methods
+
+    public PropertyMap getProperties() {
+        PropertyMap props = new PropertyMap();
+        for (Iterator i = this.iterator(); i.hasNext();) {
+            NamedValue nv = (NamedValue) i.next();
+            props.put(nv.name, nv.value);
+        }
+        return props;
+    }
+
+    public String getValue(String name) {
+        return getValue(name, null);
+    }
+
+    public String getValue(String name, String defaultValue) {
+        return (String) getProperties().getProperty(name, defaultValue);
+    }
+
+    public String toString() {
+        return ListUtil.formatCommaSeparatedList(this);
+    }
+
+    // protected methods
+
+    protected void badList(String namedValueList) {
+        throw new IllegalArgumentException("namedValueList = " + namedValueList);
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/ParameterList.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/ParameterList.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/ParameterList.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,210 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.util;
+
+import java.lang.reflect.Method;
+import java.util.Iterator;
+import java.util.LinkedList;
+
+
+public class ParameterList extends LinkedList {
+    public ParameterList() {
+    }
+
+    public ParameterList(Class[] types) {
+        init(types);
+    }
+
+    public ParameterList(Method template) {
+        Class[] types = template.getParameterTypes();
+        init(types);
+    }
+
+    private void init(Class[] types) {
+        int n = types.length;
+        for (int i = 0; i < n; i++) {
+            Class type = types[i];
+            add(type, "p" + (i + 1));
+        }
+    }
+
+    public ParameterList add(String type, String name) {
+        add(new MethodParameter(type, name));
+        return this;
+    }
+
+    public ParameterList add(Class type, String name) {
+        return add(JavaType.getName(type), name);
+    }
+
+    public ParameterList add(String name) {
+        return add("?", name);
+    }
+
+    public MethodParameter find(String parameter) {
+        for (Iterator i = iterator(); i.hasNext();) {
+            MethodParameter mp = (MethodParameter) i.next();
+            if (mp.name.equals(parameter)) {
+                return mp;
+            }
+        }
+        return null;
+    }
+
+    public MethodParameter getParameter(int index) {
+        return (MethodParameter) get(index);
+    }
+
+    public boolean hasSameTypes(ParameterList that) {
+        if (this.size() != that.size()) {
+            return false;
+        }
+        Iterator i = this.iterator();
+        Iterator j = that.iterator();
+        for (; i.hasNext();) {
+            MethodParameter mp1 = (MethodParameter) i.next();
+            MethodParameter mp2 = (MethodParameter) j.next();
+            if (!mp1.type.equals(mp2.type)) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    public String toString() {
+        StringBuffer sb = new StringBuffer("(");
+        int comma = 0;
+        for (Iterator i = iterator(); i.hasNext(); comma++) {
+            MethodParameter mp = (MethodParameter) i.next();
+            if (comma > 0) {
+                sb.append(", ");
+            }
+            sb.append(mp.name);
+        }
+        sb.append(")");
+        return sb.toString();
+    }
+
+    public String toStringWithNoSpaces() {
+        StringBuffer sb = new StringBuffer("(");
+        int comma = 0;
+        for (Iterator i = iterator(); i.hasNext(); comma++) {
+            MethodParameter mp = (MethodParameter) i.next();
+            if (comma > 0) {
+                sb.append(",");
+            }
+            sb.append(mp.name);
+        }
+        sb.append(")");
+        return sb.toString();
+    }
+
+    public String toStringWithTypesOnly() {
+        StringBuffer sb = new StringBuffer("(");
+        int comma = 0;
+        for (Iterator i = iterator(); i.hasNext(); comma++) {
+            MethodParameter mp = (MethodParameter) i.next();
+            if (comma > 0) {
+                sb.append(", ");
+            }
+            sb.append(mp.type);
+        }
+        sb.append(")");
+        return sb.toString();
+    }
+
+    public String toStringWithTypes() {
+        StringBuffer sb = new StringBuffer("(");
+        int comma = 0;
+        for (Iterator i = iterator(); i.hasNext(); comma++) {
+            MethodParameter mp = (MethodParameter) i.next();
+            if (comma > 0) {
+                sb.append(", ");
+            }
+            sb.append(mp.type);
+            sb.append(' ');
+            sb.append(mp.name);
+        }
+        sb.append(")");
+        return sb.toString();
+    }
+
+    public String toStringWithFinalTypes() {
+        StringBuffer sb = new StringBuffer("(");
+        int comma = 0;
+        for (Iterator i = iterator(); i.hasNext(); comma++) {
+            MethodParameter mp = (MethodParameter) i.next();
+            if (comma > 0) {
+                sb.append(", ");
+            }
+            sb.append("final ");
+            sb.append(mp.type);
+            sb.append(' ');
+            sb.append(mp.name);
+        }
+        sb.append(")");
+        return sb.toString();
+    }
+
+    public String getClassArray() {
+        if (isEmpty()) {
+            return "org.apache.geronimo.interop.util.ArrayUtil.EMPTY_CLASS_ARRAY";
+        }
+        StringBuffer sb = new StringBuffer("new java.lang.Class[] {");
+        int comma = 0;
+        for (Iterator i = iterator(); i.hasNext(); comma++) {
+            MethodParameter mp = (MethodParameter) i.next();
+            if (comma > 0) {
+                sb.append(", ");
+            }
+            sb.append(mp.type + ".class");
+        }
+        sb.append("}");
+        return sb.toString();
+    }
+
+    public String getObjectArray() {
+        if (isEmpty()) {
+            return "org.apache.geronimo.interop.util.ArrayUtil.EMPTY_OBJECT_ARRAY";
+        }
+        StringBuffer sb = new StringBuffer("new java.lang.Object[] {");
+        int comma = 0;
+        for (Iterator i = iterator(); i.hasNext(); comma++) {
+            MethodParameter mp = (MethodParameter) i.next();
+            if (comma > 0) {
+                sb.append(", ");
+            }
+            sb.append(mp.getObject());
+        }
+        sb.append("}");
+        return sb.toString();
+    }
+
+    public String wrapAll() {
+        StringBuffer sb = new StringBuffer();
+        int comma = 0;
+        for (Iterator i = iterator(); i.hasNext(); comma++) {
+            MethodParameter mp = (MethodParameter) i.next();
+            if (comma > 0) {
+                sb.append(", ");
+            }
+            sb.append(mp.getObject());
+        }
+        return sb.toString();
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/ProcessUtil.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/ProcessUtil.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/ProcessUtil.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,221 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.util;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.InputStream;
+import java.io.PrintStream;
+
+import org.apache.geronimo.interop.SystemException;
+
+
+public class ProcessUtil
+        //implements org.apache.geronimo.interop.bootstrap.BootstrapObject
+        {
+    /*
+    public static final Attribute[] attributes =
+    {
+        // Bootstrap classes must have inline static attributes.
+    }
+    ;
+    */
+
+    //public static final Component component = new Component(ProcessUtil.class);
+
+    public static ProcessUtil getInstance() {
+        /*
+        if (component == null || SystemProperties.bootstrap())
+        {
+            return new ProcessUtil();
+        }
+        else
+        {
+            return (ProcessUtil)component.getInstance();
+        }
+        */
+
+        return new ProcessUtil();
+    }
+
+    // private data
+
+    private String _cmd;
+
+    private boolean _echo;
+
+    private PrintStream _echoStream;
+
+    private int _exitValue;
+
+    private byte[] _errorBytes;
+
+    private byte[] _inputBytes;
+
+    // internal methods
+
+    protected ProcessUtil() {
+        // Used by getInstance in bootstrap mode.
+        // Prevents direct instantiation of class.
+    }
+
+    // public methods
+
+    public void setEcho(boolean echo) {
+        _echo = echo;
+        if (_echo) {
+            _echoStream = System.out;
+        } else {
+            _echoStream = null;
+        }
+    }
+
+    public void setEcho(PrintStream stream) {
+        _echo = stream != null;
+        _echoStream = stream;
+    }
+
+    public void run(String cmd) {
+        run(cmd, null, null);
+    }
+
+    public void run(String cmd, String[] env, String dir) {
+        _cmd = cmd;
+        Process process;
+        try {
+            if (_echo) {
+                _echoStream.println(cmd);
+            }
+            File dirFile = dir == null ? null : new File(dir);
+            process = Runtime.getRuntime().exec(cmd, env, dirFile);
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+        run(process);
+    }
+
+    public void run(String[] cmd, String[] env, String dir) {
+        _cmd = cmd.length == 0 ? "" : cmd[0];
+        for (int i = 1; i < cmd.length; i++) {
+            _cmd += " " + cmd[i];
+        }
+        Process process;
+        try {
+            if (_echo) {
+                _echoStream.println(cmd);
+            }
+            File dirFile = dir == null ? null : new File(dir);
+            process = Runtime.getRuntime().exec(cmd, env, dirFile);
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+        run(process);
+    }
+
+    public void run(Process process) {
+        try {
+            GetBytesThread errorThread = new GetBytesThread(process.getErrorStream());
+            GetBytesThread inputThread = new GetBytesThread(process.getInputStream());
+            errorThread.start();
+            inputThread.start();
+            process.waitFor();
+            errorThread.join();
+            inputThread.join();
+            _errorBytes = errorThread.getBytes();
+            _inputBytes = inputThread.getBytes();
+            _exitValue = process.exitValue();
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+    }
+
+    public void checkStatus() {
+        if (_exitValue != 0) {
+            // TODO: I18N
+            String result = getResult();
+            throw new SystemException("Command Failed: " + _cmd
+                                      + "\nExit Status: " + _exitValue
+                                      + (result.length() == 0 ? "" : ("\nOutput: " + getResult())));
+        }
+    }
+
+    public int exitValue() {
+        return _exitValue;
+    }
+
+    public String getResult() {
+        return new String(getResultBytes());
+    }
+
+    public String getError() {
+        return new String(getErrorBytes());
+    }
+
+    public String getInput() {
+        return new String(getInputBytes());
+    }
+
+    public byte[] getResultBytes() {
+        byte[] bytes = new byte[_errorBytes.length + _inputBytes.length];
+        System.arraycopy(_errorBytes, 0, bytes, 0, _errorBytes.length);
+        System.arraycopy(_inputBytes, 0, bytes, _errorBytes.length, _inputBytes.length);
+        return bytes;
+    }
+
+    public byte[] getErrorBytes() {
+        return _errorBytes;
+    }
+
+    public byte[] getInputBytes() {
+        return _inputBytes;
+    }
+
+    private class GetBytesThread extends Thread {
+        InputStream _input;
+
+        ByteArrayOutputStream _bytes;
+
+        GetBytesThread(InputStream input) {
+            _input = new BufferedInputStream(input);
+            _bytes = new ByteArrayOutputStream();
+            setDaemon(true);
+        }
+
+        public void run() {
+            try {
+                int c;
+                while ((c = _input.read()) != -1) {
+                    _bytes.write(c);
+                    if (_echo) {
+                        _echoStream.print((char) c);
+                        if (c == '\n') {
+                            _echoStream.flush();
+                        }
+                    }
+                }
+            } catch (Exception ex) {
+                throw new SystemException(ex);
+            }
+        }
+
+        public byte[] getBytes() {
+            return _bytes.toByteArray();
+        }
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/SimpleIdentityHashMap.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/SimpleIdentityHashMap.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/SimpleIdentityHashMap.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,32 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.util;
+
+import java.util.IdentityHashMap;
+
+
+/**
+ * * Wrapper over IdentityHashMap that we can use to avoid explicit
+ * * JDK 1.4 dependencies. J2SE1.3 source folder has alternate
+ * * implementation.
+ */
+public class SimpleIdentityHashMap extends IdentityHashMap {
+    public SimpleIdentityHashMap(int initialCapacity) {
+        super(initialCapacity);
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/StringUtil.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/StringUtil.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/StringUtil.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,245 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.util;
+
+public abstract class StringUtil {
+    public static boolean endsWithIgnoreCase(String name, String suffix) {
+        return name.toLowerCase().endsWith(suffix.toLowerCase());
+    }
+
+    public static String afterFirst(String separator, String str) {
+        int pos = str.indexOf(separator);
+        if (pos != -1) {
+            return str.substring(pos + separator.length());
+        } else {
+            return str;
+        }
+    }
+
+    public static String afterLast(String separator, String str) {
+        int pos = str.lastIndexOf(separator);
+        if (pos != -1) {
+            return str.substring(pos + separator.length());
+        } else {
+            return str;
+        }
+    }
+
+    public static String beforeFirst(String separator, String str) {
+        int pos = str.indexOf(separator);
+        if (pos != -1) {
+            return str.substring(0, pos);
+        } else {
+            return str;
+        }
+    }
+
+    public static String beforeLast(String separator, String str) {
+        int pos = str.lastIndexOf(separator);
+        if (pos != -1) {
+            return str.substring(0, pos);
+        } else {
+            return str;
+        }
+    }
+
+    public static String afterLastSlashOrDot(String str) {
+        int pos = str.lastIndexOf('/');
+        int dot = str.lastIndexOf('.');
+        if (pos != -1 && dot > pos) {
+            pos = dot;
+        }
+        if (pos == -1) {
+            return "";
+        } else {
+            return str.substring(pos + 1);
+        }
+    }
+
+    public static boolean equalOrBothNull(String a, String b) {
+        if (a == null) {
+            return b == null;
+        } else {
+            return b != null && a.equals(b);
+        }
+    }
+
+    /**
+     * * Mangle an arbitrary string to produce a valid Java identifier.
+     */
+    public static String getJavaIdentifier(String str) {
+        // TODO: revise mangling
+        int n = str.length();
+        StringBuffer s = new StringBuffer(n);
+        for (int i = 0; i < n; i++) {
+            char c = str.charAt(i);
+            if (c == '_') {
+                s.append("__");
+            } else if (i == 0) {
+                if (!Character.isJavaIdentifierStart(c)) {
+                    s.append("_");
+                } else {
+                    s.append(c);
+                }
+            } else {
+                if (!Character.isJavaIdentifierPart(c)) {
+                    s.append('_');
+                    s.append((int) c);
+                    s.append('_');
+                } else {
+                    s.append(c);
+                }
+            }
+        }
+        return s.toString();
+    }
+
+    public static String getLowerFirst(String name) {
+        if (name.length() == 0) {
+            return name;
+        } else {
+            return Character.toLowerCase(name.charAt(0)) + name.substring(1);
+        }
+    }
+
+    public static String getLowerFirstIfFirst2NotUpper(String name) {
+        if (name.length() >= 2) {
+            char c1 = name.charAt(0);
+            char c2 = name.charAt(1);
+            if (Character.isUpperCase(c1) && Character.isUpperCase(c2)) {
+                return name;
+            }
+        }
+        return getLowerFirst(name);
+    }
+
+    public static String getUpperFirst(String name) {
+        if (name.length() == 0) {
+            return name;
+        } else {
+            return Character.toUpperCase(name.charAt(0)) + name.substring(1);
+        }
+    }
+
+    public static String padLeft(String s, char c, int n) {
+        if (s.length() < n) {
+            StringBuffer sb = new StringBuffer(n);
+            padLeftAppend(sb, s, c, n);
+            return sb.toString();
+        } else {
+            return s;
+        }
+    }
+
+    public static void padLeftAppend(StringBuffer sb, String s, char c, int n) {
+        int p = n - s.length();
+        for (int i = 0; i < p; i++) {
+            sb.append(c);
+        }
+        sb.append(s);
+    }
+
+    public static String padRight(String s, char c, int n) {
+        if (s.length() < n) {
+            StringBuffer sb = new StringBuffer(n);
+            padRightAppend(sb, s, c, n);
+            return sb.toString();
+        } else {
+            return s;
+        }
+    }
+
+    public static void padRightAppend(StringBuffer sb, String s, char c, int n) {
+        sb.append(s);
+        int p = n - s.length();
+        for (int i = 0; i < p; i++) {
+            sb.append(c);
+        }
+    }
+
+    public static boolean startsWithIgnoreCase(String name, String prefix) {
+        return name.toLowerCase().startsWith(prefix.toLowerCase());
+    }
+
+    public static String removePrefix(String name, String prefix) {
+        if (name.startsWith(prefix)) {
+            return name.substring(prefix.length());
+        } else {
+            return name;
+        }
+    }
+
+    public static String removePrefixIgnoreCase(String name, String prefix) {
+        if (startsWithIgnoreCase(name, prefix)) {
+            return name.substring(prefix.length());
+        } else {
+            return name;
+        }
+    }
+
+    public static String removeSuffix(String name, String suffix) {
+        if (name.endsWith(suffix)) {
+            return name.substring(0, name.length() - suffix.length());
+        } else {
+            return name;
+        }
+    }
+
+    public static String removeSuffixIgnoreCase(String name, String suffix) {
+        if (endsWithIgnoreCase(name, suffix)) {
+            return name.substring(0, name.length() - suffix.length());
+        } else {
+            return name;
+        }
+    }
+
+    /**
+     * * Replace all occurrences of a substring with another substring.
+     */
+    public static String replace(String str, String what, String with) {
+        int pos = str.indexOf(what);
+        if (pos == -1) {
+            return str;
+        }
+        return str.substring(0, pos) + with + replace(str.substring(pos + what.length()), what, with);
+    }
+
+    /**
+     * * Replace first occurrence of a substring with another substring.
+     */
+    public static String replaceFirst(String str, String what, String with) {
+        int pos = str.indexOf(what);
+        if (pos == -1) {
+            return str;
+        }
+        return str.substring(0, pos) + with + str.substring(pos + what.length());
+    }
+
+    public static String reverse(String str) {
+        int n = str.length();
+        char[] chars = new char[n];
+        for (int i = 0; i < n; i++) {
+            chars[i] = str.charAt(n - i - 1);
+        }
+        return new String(chars);
+    }
+
+    public static String trimIfNotNull(String str) {
+        return str == null ? null : str.trim();
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/SystemUtil.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/SystemUtil.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/SystemUtil.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,60 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.util;
+
+import org.apache.geronimo.interop.properties.StringProperty;
+import org.apache.geronimo.interop.properties.SystemProperties;
+
+
+public class SystemUtil {
+    // properties
+
+    public static final StringProperty vmVersionProperty =
+            new StringProperty(SystemProperties.class, "java.vm.version");
+
+    // private data
+
+    private static String _vmVersion = vmVersionProperty.getString();
+
+    private static boolean _isJDK13 = _vmVersion.startsWith("1.3")
+                                      || _vmVersion.startsWith("CrE-ME V4.00");
+
+    private static boolean _isJDK14 = _vmVersion.startsWith("1.4");
+
+    // public methods
+
+    public static String getExecutableSuffix() {
+        return isWindows() ? ".exe" : "";
+    }
+
+    public static String getShellScriptSuffix() {
+        return isWindows() ? ".bat" : ".sh";
+    }
+
+    public static boolean isJDK13() {
+        return _isJDK13;
+    }
+
+    public static boolean isJDK14() {
+        return _isJDK14;
+    }
+
+    public static boolean isWindows() {
+        return java.io.File.separatorChar == '\\';
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/ThreadContext.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/ThreadContext.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/ThreadContext.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,135 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.util;
+
+import java.util.HashMap;
+
+import org.apache.geronimo.interop.SystemException;
+
+
+public abstract class ThreadContext {
+    private static HashMap _primTypes;
+
+    private static ThreadLocal _defaultRmiHost = new ThreadLocal();
+
+    private static ThreadLocal _defaultRmiPort = new ThreadLocal();
+
+    static {
+        _primTypes = new HashMap();
+        _primTypes.put("boolean", boolean.class);
+        _primTypes.put("char", char.class);
+        _primTypes.put("byte", byte.class);
+        _primTypes.put("short", short.class);
+        _primTypes.put("int", int.class);
+        _primTypes.put("long", long.class);
+        _primTypes.put("float", float.class);
+        _primTypes.put("double", double.class);
+        _primTypes.put("boolean[]", boolean[].class);
+        _primTypes.put("char[]", char[].class);
+        _primTypes.put("byte[]", byte[].class);
+        _primTypes.put("short[]", short[].class);
+        _primTypes.put("int[]", int[].class);
+        _primTypes.put("long[]", long[].class);
+        _primTypes.put("float[]", float[].class);
+        _primTypes.put("double[]", double[].class);
+    }
+
+    public static String getDefaultRmiHost() {
+        String host = (String) _defaultRmiHost.get();
+        if (host == null) {
+            host = "0";
+        }
+        return host;
+    }
+
+    public static int getDefaultRmiPort() {
+        Integer port = (Integer) _defaultRmiPort.get();
+        if (port == null) {
+            port = IntegerCache.get(0);
+        }
+        return port.intValue();
+    }
+
+    public static Class loadClass(String className) {
+        Class t = (Class) _primTypes.get(className);
+        if (t != null) {
+            return t;
+        }
+        try {
+            ClassLoader loader = Thread.currentThread().getContextClassLoader();
+            if (loader == null) {
+                return Class.forName(className);
+            } else {
+                return loader.loadClass(className);
+            }
+        } catch (RuntimeException ex) {
+            throw (RuntimeException) ex;
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+    }
+
+    public static Class loadClass(String className, Class parentClass) {
+        if (parentClass == null) {
+            return loadClass(className);
+        }
+        Class t = (Class) _primTypes.get(className);
+        if (t != null) {
+            return t;
+        }
+        try {
+            ClassLoader loader = parentClass.getClassLoader();
+            if (loader == null) {
+                return loadClass(className);
+            } else {
+                return loader.loadClass(className);
+            }
+        } catch (RuntimeException ex) {
+            throw (RuntimeException) ex;
+        } catch (Exception ex) {
+            throw new SystemException(ex);
+        }
+    }
+
+    public static Class loadClassOrReturnNullIfNotFound(String className) {
+        try {
+            return loadClass(className);
+        } catch (RuntimeException ex) {
+            return null;
+        }
+    }
+
+    public static Class loadClassOrReturnNullIfNotFound(String className, Class parentClass) {
+        if (parentClass == null) {
+            return loadClassOrReturnNullIfNotFound(className);
+        }
+        try {
+            return loadClass(className, parentClass);
+        } catch (RuntimeException ex) {
+            return null;
+        }
+    }
+
+    public static void setDefaultRmiHost(String host) {
+        _defaultRmiHost.set(host);
+    }
+
+    public static void setDefaultRmiPort(int port) {
+        _defaultRmiPort.set(IntegerCache.get(port));
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/UTF8.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/UTF8.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/UTF8.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,139 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.util;
+
+public abstract class UTF8 {
+    public static byte[] fromString(String value) {
+        int n = value.length(), u = 0;
+        for (int i = 0; i < n; i++) {
+            int c = value.charAt(i);
+            if (c >= 0x0001 && c <= 0x007F) {
+                u++;
+            } else if (c > 0x07FF) {
+                u += 3;
+            } else {
+                u += 2;
+            }
+        }
+        byte[] bytes = new byte[u];
+        for (int i = 0, j = 0; i < n; i++) {
+            int c = value.charAt(i);
+            if (c >= 0x0001 && c <= 0x007F) {
+                bytes[j++] = (byte) c;
+            } else if (c > 0x07FF) {
+                bytes[j++] = (byte) (0xE0 | ((c >> 12) & 0x0F));
+                bytes[j++] = (byte) (0x80 | ((c >> 6) & 0x3F));
+                bytes[j++] = (byte) (0x80 | (c & 0x3F));
+            } else {
+                bytes[j++] = (byte) (0xC0 | ((c >> 6) & 0x1F));
+                bytes[j++] = (byte) (0x80 | (c & 0x3F));
+            }
+        }
+        return bytes;
+    }
+
+    /**
+     * * If there is sufficient space in buffer from offset to convert value
+     * * without allocating a new byte array, do so now and return the number
+     * * of bytes written. Otherwise return -1. This method is intended for
+     * * use in optimized string marshalling.
+     */
+    public static int fromString(String value, byte[] buffer, int offset, int length) {
+        int n = value.length(), j = offset;
+        for (int i = 0; i < n; i++) {
+            if (j + 3 > length) {
+                return -1;
+            }
+            int c = value.charAt(i);
+            if (c >= 0x0001 && c <= 0x007F) {
+                buffer[j++] = (byte) c;
+            } else if (c > 0x07FF) {
+                buffer[j++] = (byte) (0xE0 | ((c >> 12) & 0x0F));
+                buffer[j++] = (byte) (0x80 | ((c >> 6) & 0x3F));
+                buffer[j++] = (byte) (0x80 | (c & 0x3F));
+            } else {
+                buffer[j++] = (byte) (0xC0 | ((c >> 6) & 0x1F));
+                buffer[j++] = (byte) (0x80 | (c & 0x3F));
+            }
+        }
+        return j - offset;
+    }
+
+    public static String toString(byte[] value) {
+        return toString(value, 0, value.length);
+    }
+
+    public static String toString(byte[] value, int offset, int length) {
+        int n = offset + length, j = 0;
+        char[] chars = new char[length]; // May be more than we need, but not less
+        for (int i = offset; i < n; i++) {
+            int c = (value[i] + 256) & 255; // byte is signed, we need unsigned
+            int c2, c3;
+
+            switch (c >> 4) {
+                case 0:
+                case 1:
+                case 2:
+                case 3:
+                case 4:
+                case 5:
+                case 6:
+                case 7:
+                    // 0xxx xxxx
+                    chars[j++] = (char) c;
+                    break;
+
+                case 12:
+                case 13:
+                    // 110x xxxx  10xx xxxx
+                    if (i + 1 >= n) {
+                        badUtf8Data();
+                    }
+                    c2 = (value[++i] + 256) & 255; // byte is signed, we need unsigned
+                    if ((c2 & 0xC0) != 0x80) {
+                        badUtf8Data();
+                    }
+                    chars[j++] = (char) (((c & 0x1F) << 6) | (c2 & 0x3F));
+                    break;
+
+                case 14:
+                    // 1110 xxxx  10xx xxxx  10xx xxxx
+                    if (i + 2 >= n) {
+                        badUtf8Data();
+                    }
+                    c2 = (value[++i] + 256) & 255; // byte is signed, we need unsigned
+                    c3 = (value[++i] + 256) & 255; // byte is signed, we need unsigned
+                    if ((c2 & 0xC0) != 0x80 || (c3 & 0xC0) != 0x80) {
+                        badUtf8Data();
+                    }
+                    chars[j++] = (char) (((c & 0x0F) << 12)
+                                         | ((c2 & 0x3F) << 6)
+                                         | (c3 & 0x3F));
+                    break;
+
+                default:
+                    badUtf8Data();
+            }
+        }
+        return new String(chars, 0, j);
+    }
+
+    private static void badUtf8Data() {
+        throw new org.omg.CORBA.MARSHAL("bad UTF-8 data");
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/UnsignedByte.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/UnsignedByte.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/UnsignedByte.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,24 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.util;
+
+public class UnsignedByte {
+    public static int intValue(byte value) {
+        return ((int) value + 0x100) & 0xff;
+    }
+}

Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/UnsignedShort.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/UnsignedShort.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/UnsignedShort.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,24 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop.util;
+
+public class UnsignedShort {
+    public static int intValue(short value) {
+        return ((int) value + 0x10000) & 0xffff;
+    }
+}

Added: geronimo/trunk/modules/interop/src/test/org/apache/geronimo/interop/InteropGBeanTest.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/test/org/apache/geronimo/interop/InteropGBeanTest.java?view=auto&rev=126264
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/interop/src/test/org/apache/geronimo/interop/InteropGBeanTest.java	Sun Jan 23 23:33:10 2005
@@ -0,0 +1,113 @@
+/**
+ *
+ * Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.geronimo.interop;
+
+import javax.management.ObjectName;
+
+import junit.framework.TestCase;
+
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.jmx.GBeanMBean;
+import org.apache.geronimo.kernel.Kernel;
+
+
+/**
+ * @version $Rev: $ $Date: $
+ */
+public class InteropGBeanTest extends TestCase {
+
+    private Kernel kernel;
+    private ObjectName objName;
+    private static final String KERNEL_NAME = "testKernel";
+
+    public void testFoo() throws Exception {
+        log("testFoo():");
+    }
+
+    public void testProperties() throws Exception {
+        try {
+            log("testProperties():");
+
+            GBeanInfo gbi = InteropGBean.getGBeanInfo();
+            log("testProperties(): gbi = " + gbi);
+
+            GBeanMBean cmf = new GBeanMBean(gbi);
+            log("testProperties(): cmf = " + cmf);
+
+            /*
+            cmf.setAttribute("strprop", "strvalue");
+            log( "testProperties(): strprop set" );
+
+            objName = ObjectName.getInstance("interop: name=default");
+            log( "testProperties(): objName = " + objName );
+
+            kernel.loadGBean(objName, cmf);
+            kernel.startGBean(objName);
+
+            Object proxy = kernel.invoke(objName, "$getResource");
+
+            log( "proxy = " + proxy );
+
+            kernel.stopGBean(objName);
+            */
+        } catch (Error er) {
+            // JUnit did not print out the stack trace for this messsage.
+            log("er = " + er);
+            er.printStackTrace(System.out);
+            throw new Exception(er.toString());
+        } catch (Exception ex) {
+            // JUnit did not print out the stack trace for this messsage.
+            log("ex = " + ex);
+            ex.printStackTrace(System.out);
+            throw new Exception(ex.toString());
+        }
+    }
+
+    /*
+     * Hum, testError and testException will result in a test failure, but
+     * no information about which test or why it failed is sent to the console
+     * even with maven -X.
+     */
+    public void testError() {
+        log("testError()");
+        //throw new java.lang.ExceptionInInitializerError( "Error: Unable to find constructor" );
+    }
+
+    public void testException()
+            throws Exception {
+        log("testException()");
+        //throw new java.lang.Exception( "Exception: Something went wrong." );
+    }
+
+    protected void setUp() throws Exception {
+        log("setUp():");
+        kernel = new Kernel(KERNEL_NAME, "test.domain");
+
+        log("setUp(): kernel = " + kernel);
+
+        kernel.boot();
+    }
+
+    protected void tearDown() throws Exception {
+        log("tearDown():");
+        kernel.shutdown();
+    }
+
+    protected void log(String msg) {
+        System.out.println(msg);
+    }
+}

Re: Review - svn commit: r126264

Posted by Dain Sundstrom <ds...@gluecode.com>.
On Mar 14, 2005, at 7:07 AM, Mark wrote:

> Many appologies - I just haven't had the time to clean up the code on 
> my laptop with all my changes and then get them submitted for a commit 
> by somebody else.  I have a few outstanding items to resolve before 
> submitting the code to check in.  I know that you have been busy 
> working towards CTS certification and since the interop code won't be 
> used for the certification, I have lowered the priority on my code. 
> :-(  However, ...
>
> Yes, my code properly handles the method name overload as per the 
> RMI-IIOP spec.
>
> Hopefully within the next few days, I will have a new zip file with 
> all my changes so they can be committed.

Can you create a diff instead of a zip?  Diffs are much easier to deal 
with.

My guess is you already know this, but I'll go over it again for the 
lurkers on the list.  Creating a diff with subversion is very easy.  
You can add and remove files with 'svn add' and 'svn remove' 
respectively.  Then just run 'svn diff' from the root directory, and 
pipe the result to a file.  Post this in a JIRA issue, and one of the 
committers will look it over.

-dain


Re: Review - svn commit: r126264

Posted by Mark <de...@hotmail.com>.
Many appologies - I just haven't had the time to clean up the code on my 
laptop with all my changes and then get them submitted for a commit by 
somebody else.  I have a few outstanding items to resolve before 
submitting the code to check in.  I know that you have been busy working 
towards CTS certification and since the interop code won't be used for 
the certification, I have lowered the priority on my code. :-(  However, ...

Yes, my code properly handles the method name overload as per the 
RMI-IIOP spec.

Hopefully within the next few days, I will have a new zip file with all 
my changes so they can be committed.

Thanks
Mark

David Jencks wrote:

> I started looking through this also -- it looks very nice.  However, 
> I  have an ulterior motive :-)  If I understand the stub/skeleton  
> generation code correctly, it does not currently handle overloaded  
> methods properly, it just assumes the IDL operation name is the same 
> as  the java method name.  Do you have just sitting there waiting to 
> submit  or are you planning to write soon code to translate java names 
> to IDL  operation names taking account of overloaded methods?
>
> Many thanks,
> david jencks
>
>
> On Jan 24, 2005, at 7:28 PM, Mark wrote:
>
>> Thanks for the review.  I will go through your comments one-by-one  
>> over the next few days.
>>
>> A few things to keep in mind:
>>
>> 1. The rmi/iiop code is fairly solid (with my fingers crossed).  I  
>> hope to get in a bunch of test cases that following the Geronimo  
>> design.
>> 2. The stub/skeleton generation is farily *dirty* it.  You can  
>> convience it to work, code generation style/speed were not my 
>> primary  objective.  The rmi-iiop was.  So I fully anticipate this to 
>> change in  the near future.
>> 3. The original code was stand alone, hence there are a few other  
>> interop.* packages.  Once I learn more about Geronimo, I anticipate 
>> a  much neater/tighter integration.  Of course, I think I will have 
>> lots  of help from Alan.  :-)
>> 4. I don't mind making the code or style changes to conform tothe  
>> Apache project.  The current style is a required habit for other  
>> projects that I work on.  :-)
>>
>> I've added a few quick answers below see MD>>
>>
>> ( I only made it 1/2 way through this email... )
>>
>> Expect that I will be submitting lots more changes to Alan over the  
>> comming days.
>>
>> Thanks
>> Mark
>>
>> Dain Sundstrom wrote:
>>
>>> Mark,
>>>
>>> Wow!  This is very impressive work. I spent some time reading over  
>>> this  (well the first half... the thing is huge).  Most of the  
>>> comments, I  have are just my curiosity and don't really need to be  
>>> fixed.  Other  are notes on differences between this code an  
>>> geronimo, and I these  cases I think we should change current  
>>> geronimo or this new code so we  don't have multiple ways to do the  
>>> same thing (BTW, I generally don't  have a preference on which code  
>>> we change unless one is broken :)  Then  there are the few coding  
>>> convention things, and finally there are a few  nit picky things :)
>>>
>>> Thanks for the great work,
>>>
>>> -dain
>>>
>>>
>>> On Jan 23, 2005, at 11:33 PM, adc@apache.org wrote:
>>>
>>>> Added: geronimo/trunk/modules/interop/src/idl/CosNaming.idl
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> idl/ CosNaming.idl?view=auto&rev=126264
>>>>
>>>> Added: geronimo/trunk/modules/interop/src/idl/GIOP.idl
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> idl/ GIOP.idl?view=auto&rev=126264
>>>>
>>>> Added: geronimo/trunk/modules/interop/src/idl/IIOP.idl
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> idl/ IIOP.idl?view=auto&rev=126264
>>>>
>>>> Added: geronimo/trunk/modules/interop/src/idl/IOP.idl
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> idl/ IOP.idl?view=auto&rev=126264
>>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/idl/org-apache-geronimo-interop-  
>>>> rmi-iiop.idl
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> idl/ org-apache-geronimo-interop-rmi-iiop.idl?view=auto&rev=126264
>>>
>>>
>>>
>>> The idl files need Apache license headers... maybe in the comments  
>>> that  are copied into the generated code.
>>
>>
>>
>> MD>> If these are taken from the www.omg.org website, should we  
>> include the apache headers?
>>
>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> CheckedException.java
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/  org/apache/geronimo/interop/CheckedException.java? 
>>>> view=auto&rev=126264
>>>>
>>>> +/**
>>>> + * * A wrapper that allows checked exceptions to be thrown as   
>>>> unchecked.
>>>> + */
>>>> +public class CheckedException extends RuntimeException {
>>>> +    public CheckedException(Throwable cause) {
>>>> +        super(cause);
>>>> +    }
>>>> +}
>>>
>>>
>>>
>>> How is this used?  Normally in Geronimo we have our invocation 
>>> chains   (interceptor stacks) throw Throwable, and we just let 
>>> exceptions  flow  up.  In other cases, we divide exceptions into 
>>> System and  Application.   We let the System exceptions flow up and 
>>> the  Application exceptions are  wrapped in the results object since 
>>> they  are treated as a normal return  for ejbs.  Anyway, I'm just 
>>> curious.   If it falls into one of the basic  scenarios we already 
>>> have a  preferred solution for, I'd like to either  switch the 
>>> exiting code  to follow the new pattern or switch the new  iiop code 
>>> to follow the  current pattern.
>>
>>
>>
>> MD>> Its most likely that this class will go away soon.
>>
>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> CosNaming/iiop_stubs/NamingContext_Stub.1.txt
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/ org/apache/geronimo/interop/CosNaming/iiop_stubs/  
>>>> NamingContext_Stub.1.txt?view=auto&rev=126264
>>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> CosNaming/iiop_stubs/NamingContext_Stub.java
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/ org/apache/geronimo/interop/CosNaming/iiop_stubs/  
>>>> NamingContext_Stub.java?view=auto&rev=126264
>>>
>>>
>>>
>>> Are these generated stubs based on the IDL above?  Normally, we 
>>> don't   check in generated code, but I bet these almost never change.
>>
>>
>>
>> MD>> The name service stubs/skels are generated.  Right now, due to 
>> a  couple of issues, I have hand modified them and simply checked 
>> them  in.  This will need to change.  All other generated files go 
>> under  interop/target/src
>>
>>
>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> InteropGBean.java
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/  
>>>> org/apache/geronimo/interop/InteropGBean.java?view=auto&rev=126264
>>>> ===================================================================== 
>>>> == =======
>>>> --- (empty file)
>>>> +++   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> InteropGBean.java    Sun Jan 23 23:33:10 2005
>>>>
>>>> +/**
>>>> + * A GBean that provides an example interop
>>>> + *
>>>> + * @version $Rev: $ $Date: $
>>>> + */
>>>> +public class InteropGBean implements GBeanLifecycle {
>>>
>>>
>>>
>>> Is this test code?  If it is an example we want to ship with the   
>>> server, maybe we should put it in an example package or rename it   
>>> ExampleInteropGBean.
>>
>>
>>
>> MD>> This GBean was the interop/corba container loader.  maybe a  
>> better name is in order.  I haven't had a chance to flesh out the  
>> details for the Geronimo integration.  I'd like to see the interop  
>> container be loaded by the InteropGBean.  The InteropGBean could be 
>> a  seperate plan or as part of the j2ee-server plan.  For the J2EE 
>> 1.4  configuration, the interop container would be enabled, but if a  
>> customer didn't care about the interop container they could remove 
>> the  plan from the server configuration.
>>
>>>
>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> SystemException.java
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/  org/apache/geronimo/interop/SystemException.java? 
>>>> view=auto&rev=126264
>>>
>>>
>>>
>>> Same comment as above for CheckedException.
>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> adapter/Adapter.java
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/  org/apache/geronimo/interop/adapter/Adapter.java? 
>>>> view=auto&rev=126264
>>>> ===================================================================== 
>>>> == =======
>>>> +public class Adapter {
>>>> +    //
>>>> +    // Public Accessible Properties
>>>> +    //
>>>
>>>
>>>
>>> I don't think we need comments like this... it is self explanatory.
>>
>>
>>
>> MD>>  Default template code .. Comments can be taken out. :-)
>>
>>>
>>>
>>>> +    protected String _bindName;
>>>> +    protected String _remoteClassName;
>>>> +    protected String _remoteInterfaceName;
>>>> +    protected Vector _idVector;
>>>> +    protected boolean _shared;
>>>> +    protected ClassLoader _cl;
>>>> +    protected RemoteInterface _ri;
>>>
>>>
>>>
>>> Our naming convention doesn't use lead underscores.  Also we tend 
>>> not   to use protected fields.  Maybe there is a subclass or some 
>>> reason.
>>
>>
>>
>> MD>> I have noticed that.  Will be changed.
>>
>>>
>>>> +    //
>>>> +    // Internal Properrties
>>>> +    //
>>>> +
>>>> +    protected Object _sharedObject;
>>>> +    protected HashMap _objects;
>>>> +    protected Class _remoteClassClass;
>>>> +    protected Class _remoteInterfaceClass;
>>>> +
>>>> +    public Adapter() {
>>>> +        _objects = new HashMap();
>>>> +        _idVector = new Vector();
>>>> +    }
>>>> +
>>>> +    /*
>>>> +     * BindName is the name that will be registered with the INS   
>>>> (Inter-operable Name Service)
>>>> +     */
>>>> +    public String getBindName() {
>>>> +        return _bindName;
>>>> +    }
>>>> +
>>>> +    public void setBindName(String bindName) {
>>>> +        _bindName = bindName;
>>>> +    }
>>>> +
>>>> +    /*
>>>> +     * Is this a shared component?  If so this will invoke the   
>>>> getInstance method on
>>>> +     * the component ...
>>>> +     */
>>>> +    public boolean isShared() {
>>>> +        return _shared;
>>>> +    }
>>>> +
>>>> +    public void setShared(boolean shared) {
>>>> +        _shared = shared;
>>>> +    }
>>>> +
>>>> +    /*
>>>> +     * The classloader that will load any dependancies of the  
>>>> adapter  or corba skel interfaces.
>>>> +     * Its should be set by the ejb container
>>>> +     */
>>>> +    public ClassLoader getClassLoader() {
>>>> +        return _cl;
>>>> +    }
>>>> +
>>>> +    public void setClassLoader(ClassLoader cl) {
>>>> +        _cl = cl;
>>>> +    }
>>>
>>>
>>>
>>> Can we change these to be constructor injected and make the fields   
>>> final?
>>
>>
>> MD>> Its possible, I have to discuss this more with Alan .
>>
>>>
>>>> +    /*
>>>> +     * This is the name of the remote class that implements the   
>>>> remote interface.
>>>> +     *
>>>> +     * This is only used if this adapter is going to directly  
>>>> invoke  an object.  For the
>>>> +     * EJB Container, the adapter will pass through the method   
>>>> invocations.
>>>> +     */
>>>> +    public String getRemoteClassName() {
>>>> +        return _remoteClassName;
>>>> +    }
>>>> +
>>>> +    public void setRemoteClassName(String rcName) {
>>>> +        _remoteClassName = rcName;
>>>> +    }
>>>> +
>>>> +    /*
>>>> +     * The remote interface name for the remote object.  This 
>>>> will   most likely be the name
>>>> +     * of the EJB's RemoteInterface and RemoteHomeInterface
>>>> +     *
>>>> +     * The stub/skel generator will use this interface name.
>>>> +     */
>>>> +    public String getRemoteInterfaceName() {
>>>> +        return _remoteInterfaceName;
>>>> +    }
>>>> +
>>>> +    public void setRemoteInterfaceName(String riName) {
>>>> +        _remoteInterfaceName = riName;
>>>> +    }
>>>> +
>>>> +    /*
>>>> +     * A list of public IDs that the remote object implements:
>>>> +     *
>>>> +     * IDL:....:1.0
>>>> +     * RMI:....:X:Y
>>>> +     */
>>>> +    public Vector getIds() {
>>>> +        return _idVector;
>>>> +    }
>>>> +
>>>> +    public void addId(String id) {
>>>> +        _idVector.add(id);
>>>> +    }
>>>> +
>>>> +    public void removeId(String id) {
>>>> +        _idVector.remove(id);
>>>> +    }
>>>> +
>>>> +    /*
>>>> +     * Return the skeleton implemention for the remote 
>>>> interface.    This interface has the
>>>> +     * invoke method to handle the rmi/iiop messages.
>>>> +     */
>>>> +    public RemoteInterface getRemoteInterface() {
>>>> +        if (_ri == null) {
>>>> +            synchronized (this) {
>>>> +                String riName = _remoteInterfaceName + "_Skeleton";
>>>> +                _remoteInterfaceClass = loadClass(riName);
>>>> +
>>>> +                try {
>>>> +                    _ri = (RemoteInterface)   
>>>> _remoteInterfaceClass.newInstance();
>>>> +                } catch (InstantiationException e) {
>>>> +                    e.printStackTrace();  //To change body of 
>>>> catch   statement use File | Settings | File Templates.
>>>> +                } catch (IllegalAccessException e) {
>>>> +                    e.printStackTrace();  //To change body of 
>>>> catch   statement use File | Settings | File Templates.
>>>> +                }
>>>> +            }
>>>> +        }
>>>> +
>>>> +        return _ri;
>>>> +    }
>>>
>>>
>>>
>>> This is double check locking.  The whole method needs to be   
>>> synchronized.
>>
>>
>> MD>> The double check code is wrong and I need to change it.    Does  
>> the method require sync?  Maybe.  I recently came accross a strategy  
>> for multiprocessor locking that uses a transient int as a memory  
>> barrier.  Probably best if I don't attempt to explain it.  We can  
>> optimize our locking.  The template that I came accross is as follows:
>>
>>    private volatile boolean _evaluated = false;
>>
>>    private Object _value;
>>
>>    /**
>>     ** Sub-classes should override this method to get the object's  
>> value
>>     ** when it is first needed.
>>     **/
>>    public abstract Object evaluate();
>>
>>    public final Object getValue()
>>    {
>>        if (_volatileIsEffectiveMemoryBarrier)
>>        {
>>            if (! _evaluated)
>>            {
>>                synchronized (this)
>>                {
>>                    if (! _evaluated)
>>                    {
>>                        _value = evaluate();
>>                        _evaluated = true;
>>                    }
>>                }
>>            }
>>        }
>>        else
>>        {
>>            synchronized (this)
>>            {
>>                if (! _evaluated)
>>                {
>>                    _value = evaluate();
>>                    _evaluated = true;
>>                }
>>            }
>>        }
>>        return _value;
>>    }
>>
>>>
>>>> +    /*
>>>> +     * Get an object instance to invoke based on the object key.
>>>> +     *
>>>> +     * The objectKey could probably be passed to the EJB 
>>>> container  so  that the
>>>> +     * container can directly invoke the ejb object as required.
>>>> +     */
>>>> +    public Object getInstance(byte[] objectKey) {
>>>> +        String key = new String(objectKey);
>>>> +        return getInstance(key);
>>>> +    }
>>>> +
>>>> +    public Object getInstance(String key) {
>>>> +        Object o = _objects.get(key);
>>>> +
>>>> +        if (o == null) {
>>>> +            o = newInstance(key);
>>>> +        }
>>>> +
>>>> +        return o;
>>>> +    }
>>>> +
>>>> +    public Object newInstance(byte[] objectKey) {
>>>> +        String key = new String(objectKey);
>>>> +        return newInstance(key);
>>>> +    }
>>>> +
>>>> +    public Object newInstance(String key) {
>>>> +        Object o = null;
>>>> +
>>>> +        if (_remoteClassClass == null) {
>>>> +            synchronized (this) {
>>>> +                _remoteClassClass = loadClass(_remoteClassName);
>>>> +            }
>>>> +
>>>> +            try {
>>>> +                if (_shared) {
>>>> +                    synchronized (this) {
>>>> +                        Method m =   
>>>> _remoteClassClass.getMethod("getInstance", (Class[]) null);
>>>> +                        o = m.invoke(_remoteClassClass, 
>>>> (Object[])   null);
>>>> +
>>>> +                        if (o != null) {
>>>> +                            _objects.put(key, o);
>>>> +                        }
>>>> +                    }
>>>> +                } else {
>>>> +                    o = _remoteClassClass.newInstance();
>>>> +                    _objects.put(key, o);
>>>> +                }
>>>> +            } catch (InstantiationException e) {
>>>> +                e.printStackTrace();  //To change body of catch   
>>>> statement use File | Settings | File Templates.
>>>> +            } catch (IllegalAccessException e) {
>>>> +                e.printStackTrace();  //To change body of catch   
>>>> statement use File | Settings | File Templates.
>>>> +            } catch (NoSuchMethodException e) {
>>>> +                e.printStackTrace();
>>>> +            } catch (InvocationTargetException e) {
>>>> +                e.printStackTrace();
>>>> +            }
>>>> +        }
>>>> +
>>>> +        return o;
>>>> +    }
>>>
>>>
>>>
>>> Again there is double check locking.  Also, if this is called in 
>>> the   critical path, I suggest we use CGLIB instead of reflection 
>>> for   construction as it is way faster.
>>
>>
>> MD>>  I can look into CGLIB.
>>
>>>
>>>> +    /*
>>>> +     * Invoke method from the IIOP Message Handler.  The adapter 
>>>> is   bound to the INS name service.
>>>> +     * When an RMI/IIOP message is processed by the server, the   
>>>> message handler will perform a lookup
>>>> +     * on the name service to get the Adapter, then the 
>>>> invocation   will be passed to the adapter
>>>> +     * The adapter will obtain the object key and then determine   
>>>> which object instance to pass the
>>>> +     * invocation to.
>>>> +     */
>>>
>>>
>>>
>>> This comment is missing the double star at the top to signify javadoc.
>>>
>>>> +    public void invoke(java.lang.String methodName, byte[]  
>>>> objectKey,  org.apache.geronimo.interop.rmi.iiop.ObjectInputStream  
>>>> input,  org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream  
>>>> output) {
>>>> +        RemoteInterface skeleton = getRemoteInterface();
>>>> +        Object instance = getInstance(objectKey);
>>>> +
>>>> +        if (instance != null) {
>>>> +            skeleton.$invoke(methodName, objectKey, instance,  
>>>> input,  output);
>>>> +        } else {
>>>> +            throw new org.omg.CORBA.OBJECT_NOT_EXIST(new   
>>>> String(objectKey));
>>>> +        }
>>>> +    }
>>>> +
>>>> +    /*
>>>> +     * Helper function to load a class.  This uses classloader 
>>>> for   the adapter.
>>>> +     */
>>>> +    protected Class loadClass(String name) {
>>>> +        Class c = null;
>>>> +
>>>> +        try {
>>>> +            c = _cl.loadClass(name);
>>>> +        } catch (Exception e) {
>>>> +            e.printStackTrace();
>>>> +        }
>>>> +
>>>> +        return c;
>>>> +    }
>>>> +}
>>>
>>>
>>>
>>> I think we should be at least logging the error or actually letting  
>>> the  ClassNotFoundException through.  We also have a ClassLoading  
>>> class  which you may want to use as it handles some of the more 
>>> weird  class  name formats.
>>
>>
>> MD >> Will change with better Geronimo integration.
>>
>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> adapter/AdapterManager.java
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/ org/apache/geronimo/interop/adapter/AdapterManager.java?  
>>>> view=auto&rev=126264
>>>> ===================================================================== 
>>>> == =======
>>>> --- (empty file)
>>>> +++   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> adapter/AdapterManager.java    Sun Jan 23 23:33:10 2005
>>>> @@ -0,0 +1,43 @@
>>>> +/**
>>>> + *
>>>> + *  Copyright 2004-2005 The Apache Software Foundation
>>>> + *
>>>> + *  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.
>>>> + */
>>>> +package org.apache.geronimo.interop.adapter;
>>>> +
>>>> +import java.util.Hashtable;
>>>> +
>>>> +
>>>> +public class AdapterManager {
>>>> +    protected Hashtable _adapters;
>>>> +    protected static AdapterManager _me = new AdapterManager();
>>>
>>>
>>>
>>> Underscores and protected...
>>
>>
>> MD>> Will do.
>>
>>>
>>>> +    protected AdapterManager() {
>>>> +        _adapters = new Hashtable();
>>>> +    }
>>>> +
>>>> +    public static AdapterManager getInstance() {
>>>> +        return _me;
>>>> +    }
>>>
>>>
>>>
>>> This is a bad idea.  Instead we should have a manger gbean and the   
>>> singletonness would be handled by there being only one GBean 
>>> instance   registered.
>>
>>
>> MD>> Sure, this will change with the introduction of GBeans, better  
>> integration...
>>
>>>
>>>> +    public void registerAdapter(Adapter a) {
>>>> +
>>>> +        _adapters.put(a.getBindName(), a);
>>>> +    }
>>>> +
>>>> +    public Adapter getAdapter(String objectName) {
>>>> +        return (Adapter) _adapters.get(objectName);
>>>> +    }
>>>
>>>
>>>
>>> I prefer HashMap and synchronizing the methods that access the Map,  
>>> but  this works in this case.
>>
>>
>> MD>> Hashtables are going to be dead soon.  ;-)
>>
>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> client/InitialContextFactory.java
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/ 
>>>> org/apache/geronimo/interop/client/InitialContextFactory.java?  
>>>> view=auto&rev=126264
>>>> ===================================================================== 
>>>> == =======
>>>> +public class InitialContextFactory
>>>> +        implements javax.naming.spi.InitialContextFactory {
>>>> +    private HashMap _startMap = new HashMap();
>>>> +
>>>> +    public Context getInitialContext(java.util.Hashtable env)  
>>>> throws  NamingException {
>>>> +        return   
>>>> org.apache.geronimo.interop.rmi.iiop.client.ClientNamingContext.getIn 
>>>> st ance(env);
>>>> +    }
>>>> +}
>>>
>>>
>>>
>>> Is the _startMap variable used anywhere?
>>
>>
>> MD>> I'd like to remove any naming in the interop and just use the  
>> naming provided in Geronimo.
>>
>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> client/InitialContextFactoryBuilder.java
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/  org/apache/geronimo/interop/client/ 
>>>> InitialContextFactoryBuilder.java? view=auto&rev=126264
>>>> ===================================================================== 
>>>> == =======
>>>> +public class InitialContextFactoryBuilder
>>>> +        implements javax.naming.spi.InitialContextFactoryBuilder {
>>>> +    public javax.naming.spi.InitialContextFactory   
>>>> createInitialContextFactory(Hashtable env) {
>>>> +        return new InitialContextFactory();
>>>> +    }
>>>> +}
>>>
>>>
>>>
>>> What is this for?  Just curious...
>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> generator/GenException.java
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/ org/apache/geronimo/interop/generator/GenException.java?  
>>>> view=auto&rev=126264
>>>> ===================================================================== 
>>>> == =======
>>>> +/**
>>>> + * User: Mark
>>>> + * Date: Dec 21, 2004
>>>> + * Time: 3:49:45 PM
>>>> + */
>>>
>>>
>>>
>>> Oops :)
>>>
>>>> +public class GenException
>>>> +        extends Exception {
>>>> +    public GenException() {
>>>> +        super();
>>>> +    }
>>>> +
>>>> +    public GenException(String message) {
>>>> +        super(message);
>>>> +    }
>>>> +
>>>> +    public GenException(Throwable cause) {
>>>> +        super(cause);
>>>> +    }
>>>> +
>>>> +    public GenException(String message, Throwable cause) {
>>>> +        super(message, cause);
>>>> +    }
>>>> +}
>>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> generator/GenOptions.java
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/ org/apache/geronimo/interop/generator/GenOptions.java?  
>>>> view=auto&rev=126264
>>>> ===================================================================== 
>>>> == =======
>>>> +public class GenOptions {
>>>> +    protected String _genDir = "./";
>>>> +    protected boolean _overwrite = false;
>>>> +    protected boolean _verbose = false;
>>>> +
>>>> +    public GenOptions() {
>>>> +    }
>>>> +
>>>> +    public GenOptions(String genDir, boolean overwrite, boolean   
>>>> verbose) {
>>>> +        _genDir = genDir;
>>>> +        _overwrite = overwrite;
>>>> +        _verbose = verbose;
>>>> +    }
>>>> +
>>>> +    public String getGenDir() {
>>>> +        return _genDir;
>>>> +    }
>>>> +
>>>> +    public void setGenDir(String genDir) {
>>>> +        _genDir = genDir;
>>>> +    }
>>>> +
>>>> +    public boolean isOverwrite() {
>>>> +        return _overwrite;
>>>> +    }
>>>> +
>>>> +    public void setOverwrite(boolean overwrite) {
>>>> +        _overwrite = overwrite;
>>>> +    }
>>>> +
>>>> +    public boolean isVerbose() {
>>>> +        return _verbose;
>>>> +    }
>>>> +
>>>> +    public void setVerbose(boolean verbose) {
>>>> +        _verbose = verbose;
>>>> +    }
>>>> +
>>>> +}
>>>
>>>
>>>
>>> Do we need both the constructor args and the setters?  If I set a   
>>> variable is whatever is using this class going to adapt to the  
>>> recently  changed variable?
>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> naming/NameService.java
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/ org/apache/geronimo/interop/naming/NameService.java?  
>>>> view=auto&rev=126264
>>>> ===================================================================== 
>>>> == =======
>>>> --- (empty file)
>>>> +++   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> naming/NameService.java    Sun Jan 23 23:33:10 2005
>>>> @@ -0,0 +1,66 @@
>>>> +/**
>>>> + *
>>>> + *  Copyright 2004-2005 The Apache Software Foundation
>>>> + *
>>>> + *  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.
>>>> + */
>>>> +package org.apache.geronimo.interop.naming;
>>>> +
>>>> +import java.util.HashMap;
>>>> +import javax.naming.NamingException;
>>>> +
>>>> +import org.apache.geronimo.interop.adapter.Adapter;
>>>> +
>>>> +
>>>> +public class NameService {
>>>> +    protected static NameService _ns = null;
>>>
>>>
>>>
>>> protected and underscore
>>>
>>>> +    public static NameService getInstance() {
>>>> +        if (_ns == null) {
>>>> +            synchronized (NameService.class) {
>>>> +                if (_ns == null) {
>>>> +                    _ns = new NameService();
>>>> +                    _ns.init();
>>>> +                }
>>>> +            }
>>>> +        }
>>>> +
>>>> +        return _ns;
>>>> +    }
>>>
>>>
>>>
>>> Double check locking
>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> naming/NamingContext.java
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/ org/apache/geronimo/interop/naming/NamingContext.java?  
>>>> view=auto&rev=126264
>>>> ===================================================================== 
>>>> == =======
>>>> --- (empty file)
>>>> +++   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> naming/NamingContext.java    Sun Jan 23 23:33:10 2005
>>>> @@ -0,0 +1,150 @@
>>>> +/**
>>>> + *
>>>> + *  Copyright 2004-2005 The Apache Software Foundation
>>>> + *
>>>> + *  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.
>>>> + */
>>>> +package org.apache.geronimo.interop.naming;
>>>> +
>>>> +import java.util.HashMap;
>>>> +import javax.naming.NameNotFoundException;
>>>> +import javax.naming.NamingException;
>>>> +
>>>> +import org.apache.geronimo.interop.adapter.Adapter;
>>>> +
>>>> +
>>>> +public class NamingContext {
>>>> +    public static final NamingContext getInstance(Class baseClass) {
>>>> +        NamingContext context;
>>>> +        synchronized (_contextMap) {
>>>> +            context = (NamingContext) _contextMap.get(baseClass);
>>>> +            if (context == null) {
>>>> +                context = new NamingContext();
>>>> +                _contextMap.put(baseClass, context);
>>>> +                context.init(baseClass);
>>>> +            }
>>>> +        }
>>>> +        return context;
>>>> +    }
>>>> +
>>>> +    private static ThreadLocal _current = new ThreadLocal();
>>>
>>>
>>>
>>> Should this be an InheritableThreadLocal?
>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> properties/BooleanProperty.java
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/ org/apache/geronimo/interop/properties/BooleanProperty.java?  
>>>> view=auto&rev=126264
>>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> properties/ByteProperty.java
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/ org/apache/geronimo/interop/properties/ByteProperty.java?  
>>>> view=auto&rev=126264
>>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> properties/DoubleProperty.java
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/ org/apache/geronimo/interop/properties/DoubleProperty.java?  
>>>> view=auto&rev=126264
>>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> properties/FloatProperty.java
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/ org/apache/geronimo/interop/properties/FloatProperty.java?  
>>>> view=auto&rev=126264
>>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> properties/IntProperty.java
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/ org/apache/geronimo/interop/properties/IntProperty.java?  
>>>> view=auto&rev=126264
>>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> properties/LongProperty.java
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/ org/apache/geronimo/interop/properties/LongProperty.java?  
>>>> view=auto&rev=126264
>>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> properties/ShortProperty.java
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/ org/apache/geronimo/interop/properties/ShortProperty.java?  
>>>> view=auto&rev=126264
>>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> properties/StringProperty.java
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/ org/apache/geronimo/interop/properties/StringProperty.java?  
>>>> view=auto&rev=126264
>>>
>>>
>>>
>>> How are these used?
>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> properties/SystemProperties.java
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/ 
>>>> org/apache/geronimo/interop/properties/SystemProperties.java?  
>>>> view=auto&rev=126264
>>>
>>>
>>>
>>> Is this a bridge to java.lang.System properties?  If so, do we 
>>> really   want to support system properties?
>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> repository/Repository.java
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/ org/apache/geronimo/interop/repository/Repository.java?  
>>>> view=auto&rev=126264
>>>> ===================================================================== 
>>>> == =======
>>>> +public class Repository {
>>>> +    // ??
>>>> +}
>>>
>>>
>>>
>>> Say what? :)
>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> rmi/iiop/IiopVersion.java
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/ org/apache/geronimo/interop/rmi/iiop/IiopVersion.java?  
>>>> view=auto&rev=126264
>>>> ===================================================================== 
>>>> == =======
>>>> +public class IiopVersion {
>>>> +}
>>>
>>>
>>>
>>> What's this for?
>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> rmi/iiop/ListenerInfo.java
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/ org/apache/geronimo/interop/rmi/iiop/ListenerInfo.java?  
>>>> view=auto&rev=126264
>>>> +public class ListenerInfo {
>>>> +    public int protocol;
>>>> +
>>>> +    public String host;
>>>> +
>>>> +    public int port;
>>>> +}
>>>
>>>
>>>
>>> Do these have to be public fields?  Normally we use, private 
>>> fields   with getters and setters.
>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> rmi/iiop/NameServiceOperations_Skeleton.java
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/ org/apache/geronimo/interop/rmi/iiop/  
>>>> NameServiceOperations_Skeleton.java?view=auto&rev=126264
>>>
>>>
>>>
>>> Do we want the Skeletons checked in?
>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> rmi/iiop/ObjectKey.java
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/ org/apache/geronimo/interop/rmi/iiop/ObjectKey.java?  
>>>> view=auto&rev=126264
>>>> ===================================================================== 
>>>> == =======
>>>> +public class ObjectKey {
>>>> +    public static final int TYPE_MANAGER = 'M';
>>>> +
>>>> +    public static final int TYPE_SESSION = 'S';
>>>> +
>>>> +    public int type;
>>>> +    public String username = "";
>>>> +    public String password = "";
>>>> +    public String component = "";
>>>> +    public String sessionID = "";
>>>
>>>
>>>
>>> public fields?
>>>
>>>> +    public void checkPassword() {
>>>> +        User.getInstance(username).login(password);
>>>> +    }
>>>
>>>
>>>
>>> Shouldn't this go though Geronimo security?
>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> rmi/iiop/ObjectRef.java
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/ org/apache/geronimo/interop/rmi/iiop/ObjectRef.java?  
>>>> view=auto&rev=126264
>>>> ===================================================================== 
>>>> == =======
>>>> +    public int $getIiopVersion() {
>>>> +        return _iiopVersion;
>>>> +    }
>>>
>>>
>>>
>>> Why do all the methods in this class start with a dollar sign?
>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> rmi/iiop/client/ClientNamingContext.java
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/  org/apache/geronimo/interop/rmi/iiop/client/ 
>>>> ClientNamingContext.java? view=auto&rev=126264
>>>
>>>
>>>
>>> We should consider merging this with the Geronimo naming stuff... 
>>> not  a  task for today, but (much) later on :)
>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> rmi/iiop/compiler/StubCompiler.txt
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/  
>>>> org/apache/geronimo/interop/rmi/iiop/compiler/StubCompiler.txt?  
>>>> view=auto&rev=126264
>>>
>>>
>>>
>>> Why is this a text file?
>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> rmi/iiop/server/SocketListener.java
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/  
>>>> org/apache/geronimo/interop/rmi/iiop/server/SocketListener.java?  
>>>> view=auto&rev=126264
>>>> ===================================================================== 
>>>> == =======
>>>> +public class SocketListener extends Thread {
>>>> +    public static SocketListener getInstance() {
>>>> +        return new SocketListener();
>>>> +    }
>>>
>>>
>>>
>>> Why is there a static factory?
>>>
>>>> +    // private data
>>>> +
>>>> +    private String _name;
>>>> +
>>>> +    private String _host;
>>>> +
>>>> +    private int _port;
>>>> +
>>>> +    private int _listenBacklog;
>>>> +
>>>> +    private java.net.ServerSocket _listener;
>>>> +
>>>> +    // internal methods
>>>> +
>>>> +    protected void init() {
>>>> +        _host = "localhost";
>>>> +        _port = 2000;
>>>> +        _listenBacklog = 10;
>>>> +        setDaemon(true);
>>>> +    }
>>>> +
>>>> +    // public methods
>>>> +
>>>> +    public void setHost(String host) {
>>>> +        _host = host;
>>>> +    }
>>>> +
>>>> +    public void setPort(int port) {
>>>> +        _port = port;
>>>> +    }
>>>> +
>>>> +    public void setListenBacklog(int backlog) {
>>>> +        _listenBacklog = backlog;
>>>> +    }
>>>> +
>>>> +    public void run() {
>>>> +        String iiopURL = "iiop://" + _host + ":" + _port;
>>>> +        ListenerInfo listenerInfo = new ListenerInfo();
>>>> +        listenerInfo.protocol = Protocol.IIOP; // TODO: other   
>>>> protocols (IIOPS etc.)
>>>> +        listenerInfo.host = _host;
>>>> +        listenerInfo.port = _port;
>>>> +        try {
>>>> +            InetAddress addr = InetAddress.getByName(_host);
>>>> +            _listener = new java.net.ServerSocket(_port,   
>>>> _listenBacklog, addr);
>>>> +        } catch (Exception ex) {
>>>> +            System.out.println("SocketListener: Error creating  
>>>> server  socket.");
>>>> +            ex.printStackTrace();
>>>> +            try {
>>>> +                Socket socket = new Socket(_host, _port);
>>>> +                socket.close();
>>>> +                System.out.println("SocketListener: Error server   
>>>> already running: " + iiopURL);
>>>> +                ex.printStackTrace();
>>>> +            } catch (Exception ignore) {
>>>> +            }
>>>> +            return;
>>>> +        }
>>>> +        new CheckConnect().start();
>>>> +        for (; ;) {
>>>> +            java.net.Socket socket;
>>>> +            try {
>>>> +                socket = _listener.accept();
>>>> +            } catch (Exception ex) {
>>>> +                throw new SystemException(ex); // TODO: log 
>>>> error   message
>>>> +            }
>>>> +            MessageHandler.getInstance(listenerInfo,  
>>>> socket).start();
>>>> +        }
>>>> +    }
>>>> +
>>>> +    private class CheckConnect extends Thread {
>>>> +        public void run() {
>>>> +            try {
>>>> +                Socket socket = new Socket(_host, _port);
>>>> +                socket.close();
>>>> +                if (!SystemProperties.quiet()) {
>>>> +                      
>>>> System.out.println(formatAcceptingIiopConnections());
>>>> +                }
>>>> +            } catch (Exception ex) {
>>>> +                warnConnectFailed(_host, _port);
>>>> +            }
>>>> +        }
>>>> +    }
>>>> +
>>>> +    // format methods
>>>> +
>>>> +    protected String formatAcceptingIiopConnections() {
>>>> +        String msg =  
>>>> "SocketListener.formatAcceptingIiopConnection():  ";
>>>> +        return msg;
>>>> +    }
>>>> +
>>>> +    // log methods
>>>> +
>>>> +    protected void warnConnectFailed(String host, int port) {
>>>> +        System.out.println("SocketListener.warnConnectFailed():  
>>>> host  = " + host + ", port = " + port);
>>>> +    }
>>>> +}
>>>
>>>
>>>
>>> I suggest, you either require all state data such as host and port 
>>> be   passed in via the constructor, or make the setters throw an 
>>> "already   running" exception.  Otherwise people mistakenly think 
>>> the can  change  the port.
>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> security/Role.java
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/  
>>>> org/apache/geronimo/interop/security/Role.java?view=auto&rev=126264
>>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> security/SimpleSubject.java
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/ org/apache/geronimo/interop/security/SimpleSubject.java?  
>>>> view=auto&rev=126264
>>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> security/User.java
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/  
>>>> org/apache/geronimo/interop/security/User.java?view=auto&rev=126264
>>>
>>>
>>>
>>> What is the plan for these with regards to the Geronimo security  
>>> module?
>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> util/SystemUtil.java
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/  org/apache/geronimo/interop/util/SystemUtil.java? 
>>>> view=auto&rev=126264
>>>> ===================================================================== 
>>>> == =======
>>>> +public class SystemUtil {
>>>> +    // properties
>>>> +
>>>> +    public static final StringProperty vmVersionProperty =
>>>> +            new StringProperty(SystemProperties.class,   
>>>> "java.vm.version");
>>>> +
>>>> +    // private data
>>>> +
>>>> +    private static String _vmVersion =  
>>>> vmVersionProperty.getString();
>>>> +
>>>> +    private static boolean _isJDK13 = _vmVersion.startsWith("1.3")
>>>> +                                      ||   
>>>> _vmVersion.startsWith("CrE-ME V4.00");
>>>> +
>>>> +    private static boolean _isJDK14 = _vmVersion.startsWith("1.4");
>>>> +
>>>> +    // public methods
>>>> +
>>>> +    public static String getExecutableSuffix() {
>>>> +        return isWindows() ? ".exe" : "";
>>>> +    }
>>>> +
>>>> +    public static String getShellScriptSuffix() {
>>>> +        return isWindows() ? ".bat" : ".sh";
>>>> +    }
>>>> +
>>>> +    public static boolean isJDK13() {
>>>> +        return _isJDK13;
>>>> +    }
>>>> +
>>>> +    public static boolean isJDK14() {
>>>> +        return _isJDK14;
>>>> +    }
>>>> +
>>>> +    public static boolean isWindows() {
>>>> +        return java.io.File.separatorChar == '\\';
>>>> +    }
>>>> +}
>>>
>>>
>>>
>>> How is this used?
>>>
>>>> Added:   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> util/ThreadContext.java
>>>> Url:   
>>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>>> java/ org/apache/geronimo/interop/util/ThreadContext.java?  
>>>> view=auto&rev=126264
>>>> ===================================================================== 
>>>> == =======
>>>> --- (empty file)
>>>> +++   
>>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>>> util/ThreadContext.java    Sun Jan 23 23:33:10 2005
>>>> @@ -0,0 +1,135 @@
>>>> +/**
>>>> + *
>>>> + *  Copyright 2004-2005 The Apache Software Foundation
>>>> + *
>>>> + *  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.
>>>> + */
>>>> +package org.apache.geronimo.interop.util;
>>>> +
>>>> +import java.util.HashMap;
>>>> +
>>>> +import org.apache.geronimo.interop.SystemException;
>>>> +
>>>> +
>>>> +public abstract class ThreadContext {
>>>> +    private static HashMap _primTypes;
>>>> +
>>>> +    private static ThreadLocal _defaultRmiHost = new ThreadLocal();
>>>> +
>>>> +    private static ThreadLocal _defaultRmiPort = new ThreadLocal();
>>>> +
>>>> +    static {
>>>> +        _primTypes = new HashMap();
>>>> +        _primTypes.put("boolean", boolean.class);
>>>> +        _primTypes.put("char", char.class);
>>>> +        _primTypes.put("byte", byte.class);
>>>> +        _primTypes.put("short", short.class);
>>>> +        _primTypes.put("int", int.class);
>>>> +        _primTypes.put("long", long.class);
>>>> +        _primTypes.put("float", float.class);
>>>> +        _primTypes.put("double", double.class);
>>>> +        _primTypes.put("boolean[]", boolean[].class);
>>>> +        _primTypes.put("char[]", char[].class);
>>>> +        _primTypes.put("byte[]", byte[].class);
>>>> +        _primTypes.put("short[]", short[].class);
>>>> +        _primTypes.put("int[]", int[].class);
>>>> +        _primTypes.put("long[]", long[].class);
>>>> +        _primTypes.put("float[]", float[].class);
>>>> +        _primTypes.put("double[]", double[].class);
>>>> +    }
>>>> +
>>>> +    public static String getDefaultRmiHost() {
>>>> +        String host = (String) _defaultRmiHost.get();
>>>> +        if (host == null) {
>>>> +            host = "0";
>>>> +        }
>>>> +        return host;
>>>> +    }
>>>> +
>>>> +    public static int getDefaultRmiPort() {
>>>> +        Integer port = (Integer) _defaultRmiPort.get();
>>>> +        if (port == null) {
>>>> +            port = IntegerCache.get(0);
>>>> +        }
>>>> +        return port.intValue();
>>>> +    }
>>>> +
>>>> +    public static Class loadClass(String className) {
>>>> +        Class t = (Class) _primTypes.get(className);
>>>> +        if (t != null) {
>>>> +            return t;
>>>> +        }
>>>> +        try {
>>>> +            ClassLoader loader =   
>>>> Thread.currentThread().getContextClassLoader();
>>>> +            if (loader == null) {
>>>> +                return Class.forName(className);
>>>> +            } else {
>>>> +                return loader.loadClass(className);
>>>> +            }
>>>> +        } catch (RuntimeException ex) {
>>>> +            throw (RuntimeException) ex;
>>>> +        } catch (Exception ex) {
>>>> +            throw new SystemException(ex);
>>>> +        }
>>>> +    }
>>>
>>>
>>>
>>> This is unlikely to work in Geronimo as we almost never set 
>>> context   class loader.  Normally we try to explicitly pass around 
>>> the   classloader.
>>>
>>>> +
>>>> +    public static Class loadClass(String className, Class   
>>>> parentClass) {
>>>> +        if (parentClass == null) {
>>>> +            return loadClass(className);
>>>> +        }
>>>> +        Class t = (Class) _primTypes.get(className);
>>>> +        if (t != null) {
>>>> +            return t;
>>>> +        }
>>>> +        try {
>>>> +            ClassLoader loader = parentClass.getClassLoader();
>>>> +            if (loader == null) {
>>>> +                return loadClass(className);
>>>> +            } else {
>>>> +                return loader.loadClass(className);
>>>> +            }
>>>> +        } catch (RuntimeException ex) {
>>>> +            throw (RuntimeException) ex;
>>>> +        } catch (Exception ex) {
>>>> +            throw new SystemException(ex);
>>>> +        }
>>>> +    }
>>>> +
>>>> +    public static Class loadClassOrReturnNullIfNotFound(String   
>>>> className) {
>>>> +        try {
>>>> +            return loadClass(className);
>>>> +        } catch (RuntimeException ex) {
>>>> +            return null;
>>>> +        }
>>>> +    }
>>>> +
>>>> +    public static Class loadClassOrReturnNullIfNotFound(String   
>>>> className, Class parentClass) {
>>>> +        if (parentClass == null) {
>>>> +            return loadClassOrReturnNullIfNotFound(className);
>>>> +        }
>>>> +        try {
>>>> +            return loadClass(className, parentClass);
>>>> +        } catch (RuntimeException ex) {
>>>> +            return null;
>>>> +        }
>>>> +    }
>>>
>>>
>>>
>>> Most of this class loader stuff is handled by the class 
>>> ClassLoading   which handles some of the more weird stuff.
>>>
>>>
>>> .
>>>
>>
>
>
> .
>


Re: Review - svn commit: r126264

Posted by David Jencks <da...@yahoo.com>.
I started looking through this also -- it looks very nice.  However, I  
have an ulterior motive :-)  If I understand the stub/skeleton  
generation code correctly, it does not currently handle overloaded  
methods properly, it just assumes the IDL operation name is the same as  
the java method name.  Do you have just sitting there waiting to submit  
or are you planning to write soon code to translate java names to IDL  
operation names taking account of overloaded methods?

Many thanks,
david jencks


On Jan 24, 2005, at 7:28 PM, Mark wrote:

> Thanks for the review.  I will go through your comments one-by-one  
> over the next few days.
>
> A few things to keep in mind:
>
> 1. The rmi/iiop code is fairly solid (with my fingers crossed).  I  
> hope to get in a bunch of test cases that following the Geronimo  
> design.
> 2. The stub/skeleton generation is farily *dirty* it.  You can  
> convience it to work, code generation style/speed were not my primary  
> objective.  The rmi-iiop was.  So I fully anticipate this to change in  
> the near future.
> 3. The original code was stand alone, hence there are a few other  
> interop.* packages.  Once I learn more about Geronimo, I anticipate a  
> much neater/tighter integration.  Of course, I think I will have lots  
> of help from Alan.  :-)
> 4. I don't mind making the code or style changes to conform tothe  
> Apache project.  The current style is a required habit for other  
> projects that I work on.  :-)
>
> I've added a few quick answers below see MD>>
>
> ( I only made it 1/2 way through this email... )
>
> Expect that I will be submitting lots more changes to Alan over the  
> comming days.
>
> Thanks
> Mark
>
> Dain Sundstrom wrote:
>
>> Mark,
>>
>> Wow!  This is very impressive work. I spent some time reading over  
>> this  (well the first half... the thing is huge).  Most of the  
>> comments, I  have are just my curiosity and don't really need to be  
>> fixed.  Other  are notes on differences between this code an  
>> geronimo, and I these  cases I think we should change current  
>> geronimo or this new code so we  don't have multiple ways to do the  
>> same thing (BTW, I generally don't  have a preference on which code  
>> we change unless one is broken :)  Then  there are the few coding  
>> convention things, and finally there are a few  nit picky things :)
>>
>> Thanks for the great work,
>>
>> -dain
>>
>>
>> On Jan 23, 2005, at 11:33 PM, adc@apache.org wrote:
>>
>>> Added: geronimo/trunk/modules/interop/src/idl/CosNaming.idl
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> idl/ CosNaming.idl?view=auto&rev=126264
>>>
>>> Added: geronimo/trunk/modules/interop/src/idl/GIOP.idl
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> idl/ GIOP.idl?view=auto&rev=126264
>>>
>>> Added: geronimo/trunk/modules/interop/src/idl/IIOP.idl
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> idl/ IIOP.idl?view=auto&rev=126264
>>>
>>> Added: geronimo/trunk/modules/interop/src/idl/IOP.idl
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> idl/ IOP.idl?view=auto&rev=126264
>>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/idl/org-apache-geronimo-interop-  
>>> rmi-iiop.idl
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> idl/ org-apache-geronimo-interop-rmi-iiop.idl?view=auto&rev=126264
>>
>>
>> The idl files need Apache license headers... maybe in the comments  
>> that  are copied into the generated code.
>
>
> MD>> If these are taken from the www.omg.org website, should we  
> include the apache headers?
>
>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> CheckedException.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/  
>>> org/apache/geronimo/interop/CheckedException.java? 
>>> view=auto&rev=126264
>>>
>>> +/**
>>> + * * A wrapper that allows checked exceptions to be thrown as   
>>> unchecked.
>>> + */
>>> +public class CheckedException extends RuntimeException {
>>> +    public CheckedException(Throwable cause) {
>>> +        super(cause);
>>> +    }
>>> +}
>>
>>
>> How is this used?  Normally in Geronimo we have our invocation chains  
>>  (interceptor stacks) throw Throwable, and we just let exceptions  
>> flow  up.  In other cases, we divide exceptions into System and  
>> Application.   We let the System exceptions flow up and the  
>> Application exceptions are  wrapped in the results object since they  
>> are treated as a normal return  for ejbs.  Anyway, I'm just curious.   
>> If it falls into one of the basic  scenarios we already have a  
>> preferred solution for, I'd like to either  switch the exiting code  
>> to follow the new pattern or switch the new  iiop code to follow the  
>> current pattern.
>
>
> MD>> Its most likely that this class will go away soon.
>
>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> CosNaming/iiop_stubs/NamingContext_Stub.1.txt
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/ org/apache/geronimo/interop/CosNaming/iiop_stubs/  
>>> NamingContext_Stub.1.txt?view=auto&rev=126264
>>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> CosNaming/iiop_stubs/NamingContext_Stub.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/ org/apache/geronimo/interop/CosNaming/iiop_stubs/  
>>> NamingContext_Stub.java?view=auto&rev=126264
>>
>>
>> Are these generated stubs based on the IDL above?  Normally, we don't  
>>  check in generated code, but I bet these almost never change.
>
>
> MD>> The name service stubs/skels are generated.  Right now, due to a  
> couple of issues, I have hand modified them and simply checked them  
> in.  This will need to change.  All other generated files go under  
> interop/target/src
>
>
>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> InteropGBean.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/  
>>> org/apache/geronimo/interop/InteropGBean.java?view=auto&rev=126264
>>> ===================================================================== 
>>> == =======
>>> --- (empty file)
>>> +++   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> InteropGBean.java    Sun Jan 23 23:33:10 2005
>>>
>>> +/**
>>> + * A GBean that provides an example interop
>>> + *
>>> + * @version $Rev: $ $Date: $
>>> + */
>>> +public class InteropGBean implements GBeanLifecycle {
>>
>>
>> Is this test code?  If it is an example we want to ship with the   
>> server, maybe we should put it in an example package or rename it   
>> ExampleInteropGBean.
>
>
> MD>> This GBean was the interop/corba container loader.  maybe a  
> better name is in order.  I haven't had a chance to flesh out the  
> details for the Geronimo integration.  I'd like to see the interop  
> container be loaded by the InteropGBean.  The InteropGBean could be a  
> seperate plan or as part of the j2ee-server plan.  For the J2EE 1.4  
> configuration, the interop container would be enabled, but if a  
> customer didn't care about the interop container they could remove the  
> plan from the server configuration.
>
>>
>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> SystemException.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/  
>>> org/apache/geronimo/interop/SystemException.java? 
>>> view=auto&rev=126264
>>
>>
>> Same comment as above for CheckedException.
>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> adapter/Adapter.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/  
>>> org/apache/geronimo/interop/adapter/Adapter.java? 
>>> view=auto&rev=126264
>>> ===================================================================== 
>>> == =======
>>> +public class Adapter {
>>> +    //
>>> +    // Public Accessible Properties
>>> +    //
>>
>>
>> I don't think we need comments like this... it is self explanatory.
>
>
> MD>>  Default template code .. Comments can be taken out. :-)
>
>>
>>
>>> +    protected String _bindName;
>>> +    protected String _remoteClassName;
>>> +    protected String _remoteInterfaceName;
>>> +    protected Vector _idVector;
>>> +    protected boolean _shared;
>>> +    protected ClassLoader _cl;
>>> +    protected RemoteInterface _ri;
>>
>>
>> Our naming convention doesn't use lead underscores.  Also we tend not  
>>  to use protected fields.  Maybe there is a subclass or some reason.
>
>
> MD>> I have noticed that.  Will be changed.
>
>>
>>> +    //
>>> +    // Internal Properrties
>>> +    //
>>> +
>>> +    protected Object _sharedObject;
>>> +    protected HashMap _objects;
>>> +    protected Class _remoteClassClass;
>>> +    protected Class _remoteInterfaceClass;
>>> +
>>> +    public Adapter() {
>>> +        _objects = new HashMap();
>>> +        _idVector = new Vector();
>>> +    }
>>> +
>>> +    /*
>>> +     * BindName is the name that will be registered with the INS   
>>> (Inter-operable Name Service)
>>> +     */
>>> +    public String getBindName() {
>>> +        return _bindName;
>>> +    }
>>> +
>>> +    public void setBindName(String bindName) {
>>> +        _bindName = bindName;
>>> +    }
>>> +
>>> +    /*
>>> +     * Is this a shared component?  If so this will invoke the   
>>> getInstance method on
>>> +     * the component ...
>>> +     */
>>> +    public boolean isShared() {
>>> +        return _shared;
>>> +    }
>>> +
>>> +    public void setShared(boolean shared) {
>>> +        _shared = shared;
>>> +    }
>>> +
>>> +    /*
>>> +     * The classloader that will load any dependancies of the  
>>> adapter  or corba skel interfaces.
>>> +     * Its should be set by the ejb container
>>> +     */
>>> +    public ClassLoader getClassLoader() {
>>> +        return _cl;
>>> +    }
>>> +
>>> +    public void setClassLoader(ClassLoader cl) {
>>> +        _cl = cl;
>>> +    }
>>
>>
>> Can we change these to be constructor injected and make the fields   
>> final?
>
> MD>> Its possible, I have to discuss this more with Alan .
>
>>
>>> +    /*
>>> +     * This is the name of the remote class that implements the   
>>> remote interface.
>>> +     *
>>> +     * This is only used if this adapter is going to directly  
>>> invoke  an object.  For the
>>> +     * EJB Container, the adapter will pass through the method   
>>> invocations.
>>> +     */
>>> +    public String getRemoteClassName() {
>>> +        return _remoteClassName;
>>> +    }
>>> +
>>> +    public void setRemoteClassName(String rcName) {
>>> +        _remoteClassName = rcName;
>>> +    }
>>> +
>>> +    /*
>>> +     * The remote interface name for the remote object.  This will   
>>> most likely be the name
>>> +     * of the EJB's RemoteInterface and RemoteHomeInterface
>>> +     *
>>> +     * The stub/skel generator will use this interface name.
>>> +     */
>>> +    public String getRemoteInterfaceName() {
>>> +        return _remoteInterfaceName;
>>> +    }
>>> +
>>> +    public void setRemoteInterfaceName(String riName) {
>>> +        _remoteInterfaceName = riName;
>>> +    }
>>> +
>>> +    /*
>>> +     * A list of public IDs that the remote object implements:
>>> +     *
>>> +     * IDL:....:1.0
>>> +     * RMI:....:X:Y
>>> +     */
>>> +    public Vector getIds() {
>>> +        return _idVector;
>>> +    }
>>> +
>>> +    public void addId(String id) {
>>> +        _idVector.add(id);
>>> +    }
>>> +
>>> +    public void removeId(String id) {
>>> +        _idVector.remove(id);
>>> +    }
>>> +
>>> +    /*
>>> +     * Return the skeleton implemention for the remote interface.    
>>> This interface has the
>>> +     * invoke method to handle the rmi/iiop messages.
>>> +     */
>>> +    public RemoteInterface getRemoteInterface() {
>>> +        if (_ri == null) {
>>> +            synchronized (this) {
>>> +                String riName = _remoteInterfaceName + "_Skeleton";
>>> +                _remoteInterfaceClass = loadClass(riName);
>>> +
>>> +                try {
>>> +                    _ri = (RemoteInterface)   
>>> _remoteInterfaceClass.newInstance();
>>> +                } catch (InstantiationException e) {
>>> +                    e.printStackTrace();  //To change body of catch  
>>>  statement use File | Settings | File Templates.
>>> +                } catch (IllegalAccessException e) {
>>> +                    e.printStackTrace();  //To change body of catch  
>>>  statement use File | Settings | File Templates.
>>> +                }
>>> +            }
>>> +        }
>>> +
>>> +        return _ri;
>>> +    }
>>
>>
>> This is double check locking.  The whole method needs to be   
>> synchronized.
>
> MD>> The double check code is wrong and I need to change it.    Does  
> the method require sync?  Maybe.  I recently came accross a strategy  
> for multiprocessor locking that uses a transient int as a memory  
> barrier.  Probably best if I don't attempt to explain it.  We can  
> optimize our locking.  The template that I came accross is as follows:
>
>    private volatile boolean _evaluated = false;
>
>    private Object _value;
>
>    /**
>     ** Sub-classes should override this method to get the object's  
> value
>     ** when it is first needed.
>     **/
>    public abstract Object evaluate();
>
>    public final Object getValue()
>    {
>        if (_volatileIsEffectiveMemoryBarrier)
>        {
>            if (! _evaluated)
>            {
>                synchronized (this)
>                {
>                    if (! _evaluated)
>                    {
>                        _value = evaluate();
>                        _evaluated = true;
>                    }
>                }
>            }
>        }
>        else
>        {
>            synchronized (this)
>            {
>                if (! _evaluated)
>                {
>                    _value = evaluate();
>                    _evaluated = true;
>                }
>            }
>        }
>        return _value;
>    }
>
>>
>>> +    /*
>>> +     * Get an object instance to invoke based on the object key.
>>> +     *
>>> +     * The objectKey could probably be passed to the EJB container  
>>> so  that the
>>> +     * container can directly invoke the ejb object as required.
>>> +     */
>>> +    public Object getInstance(byte[] objectKey) {
>>> +        String key = new String(objectKey);
>>> +        return getInstance(key);
>>> +    }
>>> +
>>> +    public Object getInstance(String key) {
>>> +        Object o = _objects.get(key);
>>> +
>>> +        if (o == null) {
>>> +            o = newInstance(key);
>>> +        }
>>> +
>>> +        return o;
>>> +    }
>>> +
>>> +    public Object newInstance(byte[] objectKey) {
>>> +        String key = new String(objectKey);
>>> +        return newInstance(key);
>>> +    }
>>> +
>>> +    public Object newInstance(String key) {
>>> +        Object o = null;
>>> +
>>> +        if (_remoteClassClass == null) {
>>> +            synchronized (this) {
>>> +                _remoteClassClass = loadClass(_remoteClassName);
>>> +            }
>>> +
>>> +            try {
>>> +                if (_shared) {
>>> +                    synchronized (this) {
>>> +                        Method m =   
>>> _remoteClassClass.getMethod("getInstance", (Class[]) null);
>>> +                        o = m.invoke(_remoteClassClass, (Object[])   
>>> null);
>>> +
>>> +                        if (o != null) {
>>> +                            _objects.put(key, o);
>>> +                        }
>>> +                    }
>>> +                } else {
>>> +                    o = _remoteClassClass.newInstance();
>>> +                    _objects.put(key, o);
>>> +                }
>>> +            } catch (InstantiationException e) {
>>> +                e.printStackTrace();  //To change body of catch   
>>> statement use File | Settings | File Templates.
>>> +            } catch (IllegalAccessException e) {
>>> +                e.printStackTrace();  //To change body of catch   
>>> statement use File | Settings | File Templates.
>>> +            } catch (NoSuchMethodException e) {
>>> +                e.printStackTrace();
>>> +            } catch (InvocationTargetException e) {
>>> +                e.printStackTrace();
>>> +            }
>>> +        }
>>> +
>>> +        return o;
>>> +    }
>>
>>
>> Again there is double check locking.  Also, if this is called in the   
>> critical path, I suggest we use CGLIB instead of reflection for   
>> construction as it is way faster.
>
> MD>>  I can look into CGLIB.
>
>>
>>> +    /*
>>> +     * Invoke method from the IIOP Message Handler.  The adapter is  
>>>  bound to the INS name service.
>>> +     * When an RMI/IIOP message is processed by the server, the   
>>> message handler will perform a lookup
>>> +     * on the name service to get the Adapter, then the invocation   
>>> will be passed to the adapter
>>> +     * The adapter will obtain the object key and then determine   
>>> which object instance to pass the
>>> +     * invocation to.
>>> +     */
>>
>>
>> This comment is missing the double star at the top to signify javadoc.
>>
>>> +    public void invoke(java.lang.String methodName, byte[]  
>>> objectKey,  org.apache.geronimo.interop.rmi.iiop.ObjectInputStream  
>>> input,  org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream  
>>> output) {
>>> +        RemoteInterface skeleton = getRemoteInterface();
>>> +        Object instance = getInstance(objectKey);
>>> +
>>> +        if (instance != null) {
>>> +            skeleton.$invoke(methodName, objectKey, instance,  
>>> input,  output);
>>> +        } else {
>>> +            throw new org.omg.CORBA.OBJECT_NOT_EXIST(new   
>>> String(objectKey));
>>> +        }
>>> +    }
>>> +
>>> +    /*
>>> +     * Helper function to load a class.  This uses classloader for   
>>> the adapter.
>>> +     */
>>> +    protected Class loadClass(String name) {
>>> +        Class c = null;
>>> +
>>> +        try {
>>> +            c = _cl.loadClass(name);
>>> +        } catch (Exception e) {
>>> +            e.printStackTrace();
>>> +        }
>>> +
>>> +        return c;
>>> +    }
>>> +}
>>
>>
>> I think we should be at least logging the error or actually letting  
>> the  ClassNotFoundException through.  We also have a ClassLoading  
>> class  which you may want to use as it handles some of the more weird  
>> class  name formats.
>
> MD >> Will change with better Geronimo integration.
>
>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> adapter/AdapterManager.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/ org/apache/geronimo/interop/adapter/AdapterManager.java?  
>>> view=auto&rev=126264
>>> ===================================================================== 
>>> == =======
>>> --- (empty file)
>>> +++   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> adapter/AdapterManager.java    Sun Jan 23 23:33:10 2005
>>> @@ -0,0 +1,43 @@
>>> +/**
>>> + *
>>> + *  Copyright 2004-2005 The Apache Software Foundation
>>> + *
>>> + *  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.
>>> + */
>>> +package org.apache.geronimo.interop.adapter;
>>> +
>>> +import java.util.Hashtable;
>>> +
>>> +
>>> +public class AdapterManager {
>>> +    protected Hashtable _adapters;
>>> +    protected static AdapterManager _me = new AdapterManager();
>>
>>
>> Underscores and protected...
>
> MD>> Will do.
>
>>
>>> +    protected AdapterManager() {
>>> +        _adapters = new Hashtable();
>>> +    }
>>> +
>>> +    public static AdapterManager getInstance() {
>>> +        return _me;
>>> +    }
>>
>>
>> This is a bad idea.  Instead we should have a manger gbean and the   
>> singletonness would be handled by there being only one GBean instance  
>>  registered.
>
> MD>> Sure, this will change with the introduction of GBeans, better  
> integration...
>
>>
>>> +    public void registerAdapter(Adapter a) {
>>> +
>>> +        _adapters.put(a.getBindName(), a);
>>> +    }
>>> +
>>> +    public Adapter getAdapter(String objectName) {
>>> +        return (Adapter) _adapters.get(objectName);
>>> +    }
>>
>>
>> I prefer HashMap and synchronizing the methods that access the Map,  
>> but  this works in this case.
>
> MD>> Hashtables are going to be dead soon.  ;-)
>
>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> client/InitialContextFactory.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/ org/apache/geronimo/interop/client/InitialContextFactory.java?  
>>> view=auto&rev=126264
>>> ===================================================================== 
>>> == =======
>>> +public class InitialContextFactory
>>> +        implements javax.naming.spi.InitialContextFactory {
>>> +    private HashMap _startMap = new HashMap();
>>> +
>>> +    public Context getInitialContext(java.util.Hashtable env)  
>>> throws  NamingException {
>>> +        return   
>>> org.apache.geronimo.interop.rmi.iiop.client.ClientNamingContext.getIn 
>>> st ance(env);
>>> +    }
>>> +}
>>
>>
>> Is the _startMap variable used anywhere?
>
> MD>> I'd like to remove any naming in the interop and just use the  
> naming provided in Geronimo.
>
>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> client/InitialContextFactoryBuilder.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/  
>>> org/apache/geronimo/interop/client/ 
>>> InitialContextFactoryBuilder.java? view=auto&rev=126264
>>> ===================================================================== 
>>> == =======
>>> +public class InitialContextFactoryBuilder
>>> +        implements javax.naming.spi.InitialContextFactoryBuilder {
>>> +    public javax.naming.spi.InitialContextFactory   
>>> createInitialContextFactory(Hashtable env) {
>>> +        return new InitialContextFactory();
>>> +    }
>>> +}
>>
>>
>> What is this for?  Just curious...
>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> generator/GenException.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/ org/apache/geronimo/interop/generator/GenException.java?  
>>> view=auto&rev=126264
>>> ===================================================================== 
>>> == =======
>>> +/**
>>> + * User: Mark
>>> + * Date: Dec 21, 2004
>>> + * Time: 3:49:45 PM
>>> + */
>>
>>
>> Oops :)
>>
>>> +public class GenException
>>> +        extends Exception {
>>> +    public GenException() {
>>> +        super();
>>> +    }
>>> +
>>> +    public GenException(String message) {
>>> +        super(message);
>>> +    }
>>> +
>>> +    public GenException(Throwable cause) {
>>> +        super(cause);
>>> +    }
>>> +
>>> +    public GenException(String message, Throwable cause) {
>>> +        super(message, cause);
>>> +    }
>>> +}
>>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> generator/GenOptions.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/ org/apache/geronimo/interop/generator/GenOptions.java?  
>>> view=auto&rev=126264
>>> ===================================================================== 
>>> == =======
>>> +public class GenOptions {
>>> +    protected String _genDir = "./";
>>> +    protected boolean _overwrite = false;
>>> +    protected boolean _verbose = false;
>>> +
>>> +    public GenOptions() {
>>> +    }
>>> +
>>> +    public GenOptions(String genDir, boolean overwrite, boolean   
>>> verbose) {
>>> +        _genDir = genDir;
>>> +        _overwrite = overwrite;
>>> +        _verbose = verbose;
>>> +    }
>>> +
>>> +    public String getGenDir() {
>>> +        return _genDir;
>>> +    }
>>> +
>>> +    public void setGenDir(String genDir) {
>>> +        _genDir = genDir;
>>> +    }
>>> +
>>> +    public boolean isOverwrite() {
>>> +        return _overwrite;
>>> +    }
>>> +
>>> +    public void setOverwrite(boolean overwrite) {
>>> +        _overwrite = overwrite;
>>> +    }
>>> +
>>> +    public boolean isVerbose() {
>>> +        return _verbose;
>>> +    }
>>> +
>>> +    public void setVerbose(boolean verbose) {
>>> +        _verbose = verbose;
>>> +    }
>>> +
>>> +}
>>
>>
>> Do we need both the constructor args and the setters?  If I set a   
>> variable is whatever is using this class going to adapt to the  
>> recently  changed variable?
>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> naming/NameService.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/ org/apache/geronimo/interop/naming/NameService.java?  
>>> view=auto&rev=126264
>>> ===================================================================== 
>>> == =======
>>> --- (empty file)
>>> +++   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> naming/NameService.java    Sun Jan 23 23:33:10 2005
>>> @@ -0,0 +1,66 @@
>>> +/**
>>> + *
>>> + *  Copyright 2004-2005 The Apache Software Foundation
>>> + *
>>> + *  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.
>>> + */
>>> +package org.apache.geronimo.interop.naming;
>>> +
>>> +import java.util.HashMap;
>>> +import javax.naming.NamingException;
>>> +
>>> +import org.apache.geronimo.interop.adapter.Adapter;
>>> +
>>> +
>>> +public class NameService {
>>> +    protected static NameService _ns = null;
>>
>>
>> protected and underscore
>>
>>> +    public static NameService getInstance() {
>>> +        if (_ns == null) {
>>> +            synchronized (NameService.class) {
>>> +                if (_ns == null) {
>>> +                    _ns = new NameService();
>>> +                    _ns.init();
>>> +                }
>>> +            }
>>> +        }
>>> +
>>> +        return _ns;
>>> +    }
>>
>>
>> Double check locking
>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> naming/NamingContext.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/ org/apache/geronimo/interop/naming/NamingContext.java?  
>>> view=auto&rev=126264
>>> ===================================================================== 
>>> == =======
>>> --- (empty file)
>>> +++   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> naming/NamingContext.java    Sun Jan 23 23:33:10 2005
>>> @@ -0,0 +1,150 @@
>>> +/**
>>> + *
>>> + *  Copyright 2004-2005 The Apache Software Foundation
>>> + *
>>> + *  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.
>>> + */
>>> +package org.apache.geronimo.interop.naming;
>>> +
>>> +import java.util.HashMap;
>>> +import javax.naming.NameNotFoundException;
>>> +import javax.naming.NamingException;
>>> +
>>> +import org.apache.geronimo.interop.adapter.Adapter;
>>> +
>>> +
>>> +public class NamingContext {
>>> +    public static final NamingContext getInstance(Class baseClass) {
>>> +        NamingContext context;
>>> +        synchronized (_contextMap) {
>>> +            context = (NamingContext) _contextMap.get(baseClass);
>>> +            if (context == null) {
>>> +                context = new NamingContext();
>>> +                _contextMap.put(baseClass, context);
>>> +                context.init(baseClass);
>>> +            }
>>> +        }
>>> +        return context;
>>> +    }
>>> +
>>> +    private static ThreadLocal _current = new ThreadLocal();
>>
>>
>> Should this be an InheritableThreadLocal?
>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> properties/BooleanProperty.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/ org/apache/geronimo/interop/properties/BooleanProperty.java?  
>>> view=auto&rev=126264
>>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> properties/ByteProperty.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/ org/apache/geronimo/interop/properties/ByteProperty.java?  
>>> view=auto&rev=126264
>>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> properties/DoubleProperty.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/ org/apache/geronimo/interop/properties/DoubleProperty.java?  
>>> view=auto&rev=126264
>>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> properties/FloatProperty.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/ org/apache/geronimo/interop/properties/FloatProperty.java?  
>>> view=auto&rev=126264
>>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> properties/IntProperty.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/ org/apache/geronimo/interop/properties/IntProperty.java?  
>>> view=auto&rev=126264
>>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> properties/LongProperty.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/ org/apache/geronimo/interop/properties/LongProperty.java?  
>>> view=auto&rev=126264
>>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> properties/ShortProperty.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/ org/apache/geronimo/interop/properties/ShortProperty.java?  
>>> view=auto&rev=126264
>>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> properties/StringProperty.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/ org/apache/geronimo/interop/properties/StringProperty.java?  
>>> view=auto&rev=126264
>>
>>
>> How are these used?
>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> properties/SystemProperties.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/ org/apache/geronimo/interop/properties/SystemProperties.java?  
>>> view=auto&rev=126264
>>
>>
>> Is this a bridge to java.lang.System properties?  If so, do we really  
>>  want to support system properties?
>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> repository/Repository.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/ org/apache/geronimo/interop/repository/Repository.java?  
>>> view=auto&rev=126264
>>> ===================================================================== 
>>> == =======
>>> +public class Repository {
>>> +    // ??
>>> +}
>>
>>
>> Say what? :)
>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> rmi/iiop/IiopVersion.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/ org/apache/geronimo/interop/rmi/iiop/IiopVersion.java?  
>>> view=auto&rev=126264
>>> ===================================================================== 
>>> == =======
>>> +public class IiopVersion {
>>> +}
>>
>>
>> What's this for?
>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> rmi/iiop/ListenerInfo.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/ org/apache/geronimo/interop/rmi/iiop/ListenerInfo.java?  
>>> view=auto&rev=126264
>>> +public class ListenerInfo {
>>> +    public int protocol;
>>> +
>>> +    public String host;
>>> +
>>> +    public int port;
>>> +}
>>
>>
>> Do these have to be public fields?  Normally we use, private fields   
>> with getters and setters.
>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> rmi/iiop/NameServiceOperations_Skeleton.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/ org/apache/geronimo/interop/rmi/iiop/  
>>> NameServiceOperations_Skeleton.java?view=auto&rev=126264
>>
>>
>> Do we want the Skeletons checked in?
>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> rmi/iiop/ObjectKey.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/ org/apache/geronimo/interop/rmi/iiop/ObjectKey.java?  
>>> view=auto&rev=126264
>>> ===================================================================== 
>>> == =======
>>> +public class ObjectKey {
>>> +    public static final int TYPE_MANAGER = 'M';
>>> +
>>> +    public static final int TYPE_SESSION = 'S';
>>> +
>>> +    public int type;
>>> +    public String username = "";
>>> +    public String password = "";
>>> +    public String component = "";
>>> +    public String sessionID = "";
>>
>>
>> public fields?
>>
>>> +    public void checkPassword() {
>>> +        User.getInstance(username).login(password);
>>> +    }
>>
>>
>> Shouldn't this go though Geronimo security?
>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> rmi/iiop/ObjectRef.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/ org/apache/geronimo/interop/rmi/iiop/ObjectRef.java?  
>>> view=auto&rev=126264
>>> ===================================================================== 
>>> == =======
>>> +    public int $getIiopVersion() {
>>> +        return _iiopVersion;
>>> +    }
>>
>>
>> Why do all the methods in this class start with a dollar sign?
>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> rmi/iiop/client/ClientNamingContext.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/  
>>> org/apache/geronimo/interop/rmi/iiop/client/ 
>>> ClientNamingContext.java? view=auto&rev=126264
>>
>>
>> We should consider merging this with the Geronimo naming stuff... not  
>> a  task for today, but (much) later on :)
>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> rmi/iiop/compiler/StubCompiler.txt
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/  
>>> org/apache/geronimo/interop/rmi/iiop/compiler/StubCompiler.txt?  
>>> view=auto&rev=126264
>>
>>
>> Why is this a text file?
>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> rmi/iiop/server/SocketListener.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/  
>>> org/apache/geronimo/interop/rmi/iiop/server/SocketListener.java?  
>>> view=auto&rev=126264
>>> ===================================================================== 
>>> == =======
>>> +public class SocketListener extends Thread {
>>> +    public static SocketListener getInstance() {
>>> +        return new SocketListener();
>>> +    }
>>
>>
>> Why is there a static factory?
>>
>>> +    // private data
>>> +
>>> +    private String _name;
>>> +
>>> +    private String _host;
>>> +
>>> +    private int _port;
>>> +
>>> +    private int _listenBacklog;
>>> +
>>> +    private java.net.ServerSocket _listener;
>>> +
>>> +    // internal methods
>>> +
>>> +    protected void init() {
>>> +        _host = "localhost";
>>> +        _port = 2000;
>>> +        _listenBacklog = 10;
>>> +        setDaemon(true);
>>> +    }
>>> +
>>> +    // public methods
>>> +
>>> +    public void setHost(String host) {
>>> +        _host = host;
>>> +    }
>>> +
>>> +    public void setPort(int port) {
>>> +        _port = port;
>>> +    }
>>> +
>>> +    public void setListenBacklog(int backlog) {
>>> +        _listenBacklog = backlog;
>>> +    }
>>> +
>>> +    public void run() {
>>> +        String iiopURL = "iiop://" + _host + ":" + _port;
>>> +        ListenerInfo listenerInfo = new ListenerInfo();
>>> +        listenerInfo.protocol = Protocol.IIOP; // TODO: other   
>>> protocols (IIOPS etc.)
>>> +        listenerInfo.host = _host;
>>> +        listenerInfo.port = _port;
>>> +        try {
>>> +            InetAddress addr = InetAddress.getByName(_host);
>>> +            _listener = new java.net.ServerSocket(_port,   
>>> _listenBacklog, addr);
>>> +        } catch (Exception ex) {
>>> +            System.out.println("SocketListener: Error creating  
>>> server  socket.");
>>> +            ex.printStackTrace();
>>> +            try {
>>> +                Socket socket = new Socket(_host, _port);
>>> +                socket.close();
>>> +                System.out.println("SocketListener: Error server   
>>> already running: " + iiopURL);
>>> +                ex.printStackTrace();
>>> +            } catch (Exception ignore) {
>>> +            }
>>> +            return;
>>> +        }
>>> +        new CheckConnect().start();
>>> +        for (; ;) {
>>> +            java.net.Socket socket;
>>> +            try {
>>> +                socket = _listener.accept();
>>> +            } catch (Exception ex) {
>>> +                throw new SystemException(ex); // TODO: log error   
>>> message
>>> +            }
>>> +            MessageHandler.getInstance(listenerInfo,  
>>> socket).start();
>>> +        }
>>> +    }
>>> +
>>> +    private class CheckConnect extends Thread {
>>> +        public void run() {
>>> +            try {
>>> +                Socket socket = new Socket(_host, _port);
>>> +                socket.close();
>>> +                if (!SystemProperties.quiet()) {
>>> +                      
>>> System.out.println(formatAcceptingIiopConnections());
>>> +                }
>>> +            } catch (Exception ex) {
>>> +                warnConnectFailed(_host, _port);
>>> +            }
>>> +        }
>>> +    }
>>> +
>>> +    // format methods
>>> +
>>> +    protected String formatAcceptingIiopConnections() {
>>> +        String msg =  
>>> "SocketListener.formatAcceptingIiopConnection():  ";
>>> +        return msg;
>>> +    }
>>> +
>>> +    // log methods
>>> +
>>> +    protected void warnConnectFailed(String host, int port) {
>>> +        System.out.println("SocketListener.warnConnectFailed():  
>>> host  = " + host + ", port = " + port);
>>> +    }
>>> +}
>>
>>
>> I suggest, you either require all state data such as host and port be  
>>  passed in via the constructor, or make the setters throw an "already  
>>  running" exception.  Otherwise people mistakenly think the can  
>> change  the port.
>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> security/Role.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/  
>>> org/apache/geronimo/interop/security/Role.java?view=auto&rev=126264
>>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> security/SimpleSubject.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/ org/apache/geronimo/interop/security/SimpleSubject.java?  
>>> view=auto&rev=126264
>>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> security/User.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/  
>>> org/apache/geronimo/interop/security/User.java?view=auto&rev=126264
>>
>>
>> What is the plan for these with regards to the Geronimo security  
>> module?
>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> util/SystemUtil.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/  
>>> org/apache/geronimo/interop/util/SystemUtil.java? 
>>> view=auto&rev=126264
>>> ===================================================================== 
>>> == =======
>>> +public class SystemUtil {
>>> +    // properties
>>> +
>>> +    public static final StringProperty vmVersionProperty =
>>> +            new StringProperty(SystemProperties.class,   
>>> "java.vm.version");
>>> +
>>> +    // private data
>>> +
>>> +    private static String _vmVersion =  
>>> vmVersionProperty.getString();
>>> +
>>> +    private static boolean _isJDK13 = _vmVersion.startsWith("1.3")
>>> +                                      ||   
>>> _vmVersion.startsWith("CrE-ME V4.00");
>>> +
>>> +    private static boolean _isJDK14 = _vmVersion.startsWith("1.4");
>>> +
>>> +    // public methods
>>> +
>>> +    public static String getExecutableSuffix() {
>>> +        return isWindows() ? ".exe" : "";
>>> +    }
>>> +
>>> +    public static String getShellScriptSuffix() {
>>> +        return isWindows() ? ".bat" : ".sh";
>>> +    }
>>> +
>>> +    public static boolean isJDK13() {
>>> +        return _isJDK13;
>>> +    }
>>> +
>>> +    public static boolean isJDK14() {
>>> +        return _isJDK14;
>>> +    }
>>> +
>>> +    public static boolean isWindows() {
>>> +        return java.io.File.separatorChar == '\\';
>>> +    }
>>> +}
>>
>>
>> How is this used?
>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> util/ThreadContext.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/ org/apache/geronimo/interop/util/ThreadContext.java?  
>>> view=auto&rev=126264
>>> ===================================================================== 
>>> == =======
>>> --- (empty file)
>>> +++   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> util/ThreadContext.java    Sun Jan 23 23:33:10 2005
>>> @@ -0,0 +1,135 @@
>>> +/**
>>> + *
>>> + *  Copyright 2004-2005 The Apache Software Foundation
>>> + *
>>> + *  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.
>>> + */
>>> +package org.apache.geronimo.interop.util;
>>> +
>>> +import java.util.HashMap;
>>> +
>>> +import org.apache.geronimo.interop.SystemException;
>>> +
>>> +
>>> +public abstract class ThreadContext {
>>> +    private static HashMap _primTypes;
>>> +
>>> +    private static ThreadLocal _defaultRmiHost = new ThreadLocal();
>>> +
>>> +    private static ThreadLocal _defaultRmiPort = new ThreadLocal();
>>> +
>>> +    static {
>>> +        _primTypes = new HashMap();
>>> +        _primTypes.put("boolean", boolean.class);
>>> +        _primTypes.put("char", char.class);
>>> +        _primTypes.put("byte", byte.class);
>>> +        _primTypes.put("short", short.class);
>>> +        _primTypes.put("int", int.class);
>>> +        _primTypes.put("long", long.class);
>>> +        _primTypes.put("float", float.class);
>>> +        _primTypes.put("double", double.class);
>>> +        _primTypes.put("boolean[]", boolean[].class);
>>> +        _primTypes.put("char[]", char[].class);
>>> +        _primTypes.put("byte[]", byte[].class);
>>> +        _primTypes.put("short[]", short[].class);
>>> +        _primTypes.put("int[]", int[].class);
>>> +        _primTypes.put("long[]", long[].class);
>>> +        _primTypes.put("float[]", float[].class);
>>> +        _primTypes.put("double[]", double[].class);
>>> +    }
>>> +
>>> +    public static String getDefaultRmiHost() {
>>> +        String host = (String) _defaultRmiHost.get();
>>> +        if (host == null) {
>>> +            host = "0";
>>> +        }
>>> +        return host;
>>> +    }
>>> +
>>> +    public static int getDefaultRmiPort() {
>>> +        Integer port = (Integer) _defaultRmiPort.get();
>>> +        if (port == null) {
>>> +            port = IntegerCache.get(0);
>>> +        }
>>> +        return port.intValue();
>>> +    }
>>> +
>>> +    public static Class loadClass(String className) {
>>> +        Class t = (Class) _primTypes.get(className);
>>> +        if (t != null) {
>>> +            return t;
>>> +        }
>>> +        try {
>>> +            ClassLoader loader =   
>>> Thread.currentThread().getContextClassLoader();
>>> +            if (loader == null) {
>>> +                return Class.forName(className);
>>> +            } else {
>>> +                return loader.loadClass(className);
>>> +            }
>>> +        } catch (RuntimeException ex) {
>>> +            throw (RuntimeException) ex;
>>> +        } catch (Exception ex) {
>>> +            throw new SystemException(ex);
>>> +        }
>>> +    }
>>
>>
>> This is unlikely to work in Geronimo as we almost never set context   
>> class loader.  Normally we try to explicitly pass around the   
>> classloader.
>>
>>> +
>>> +    public static Class loadClass(String className, Class   
>>> parentClass) {
>>> +        if (parentClass == null) {
>>> +            return loadClass(className);
>>> +        }
>>> +        Class t = (Class) _primTypes.get(className);
>>> +        if (t != null) {
>>> +            return t;
>>> +        }
>>> +        try {
>>> +            ClassLoader loader = parentClass.getClassLoader();
>>> +            if (loader == null) {
>>> +                return loadClass(className);
>>> +            } else {
>>> +                return loader.loadClass(className);
>>> +            }
>>> +        } catch (RuntimeException ex) {
>>> +            throw (RuntimeException) ex;
>>> +        } catch (Exception ex) {
>>> +            throw new SystemException(ex);
>>> +        }
>>> +    }
>>> +
>>> +    public static Class loadClassOrReturnNullIfNotFound(String   
>>> className) {
>>> +        try {
>>> +            return loadClass(className);
>>> +        } catch (RuntimeException ex) {
>>> +            return null;
>>> +        }
>>> +    }
>>> +
>>> +    public static Class loadClassOrReturnNullIfNotFound(String   
>>> className, Class parentClass) {
>>> +        if (parentClass == null) {
>>> +            return loadClassOrReturnNullIfNotFound(className);
>>> +        }
>>> +        try {
>>> +            return loadClass(className, parentClass);
>>> +        } catch (RuntimeException ex) {
>>> +            return null;
>>> +        }
>>> +    }
>>
>>
>> Most of this class loader stuff is handled by the class ClassLoading   
>> which handles some of the more weird stuff.
>>
>>
>> .
>>
>


Re: Review - svn commit: r126264

Posted by David Jencks <dj...@gluecode.com>.
On Jan 26, 2005, at 7:55 AM, Mark wrote:

> Is it safe to say the we should use CGLIB instead of the 
> java.lang.reflect package?

For deployment/startup code it doesn't matter much.  For code executed 
during a request it is a good idea to use CGLIB.

I'm in favor of enhancing the classes during deployment and including 
the enhanced classes in the generated configuration.  An example of how 
to do this is in the AxisBuilder.  Please ask if you have any 
questions.

thanks
david jencks

>
> Thanks
> Mark
>
>>>> Again there is double check locking.  Also, if this is called in 
>>>> the   critical path, I suggest we use CGLIB instead of reflection 
>>>> for   construction as it is way faster.
>>>
>>>
>>> MD>>  I can look into CGLIB.
>>
>>
>> No rush on that one... it's for the polish phase.
>>
>


Re: Review - svn commit: r126264

Posted by Mark <de...@hotmail.com>.
Is it safe to say the we should use CGLIB instead of the 
java.lang.reflect package?

Thanks
Mark

>>> Again there is double check locking.  Also, if this is called in 
>>> the   critical path, I suggest we use CGLIB instead of reflection 
>>> for   construction as it is way faster.
>>
>>
>> MD>>  I can look into CGLIB.
>
>
> No rush on that one... it's for the polish phase.
>

Re: Review - svn commit: r126264

Posted by Dain Sundstrom <ds...@gluecode.com>.
Finally got some free time to respond again :)

On Jan 24, 2005, at 7:28 PM, Mark wrote:

> Thanks for the review.  I will go through your comments one-by-one  
> over the next few days.
>
> A few things to keep in mind:
>
> 1. The rmi/iiop code is fairly solid (with my fingers crossed).  I  
> hope to get in a bunch of test cases that following the Geronimo  
> design.

Excellent!

> 2. The stub/skeleton generation is farily *dirty* it.  You can  
> convience it to work, code generation style/speed were not my primary  
> objective.  The rmi-iiop was.  So I fully anticipate this to change in  
> the near future.

Yep.  The Geronimo deployment code is similar; not fast or that  
beautiful, but works.

> 3. The original code was stand alone, hence there are a few other  
> interop.* packages.  Once I learn more about Geronimo, I anticipate a  
> much neater/tighter integration.  Of course, I think I will have lots  
> of help from Alan.  :-)

I just wanted to point out some of the stuff I noticed.  I figure the  
neat/tight integration will take long time (months) as all of us get  
accustomed to new integrated code base.

> 4. I don't mind making the code or style changes to conform tothe  
> Apache project.  The current style is a required habit for other  
> projects that I work on.  :-)
>
> I've added a few quick answers below see MD>>
>
> ( I only made it 1/2 way through this email... )
>
> Expect that I will be submitting lots more changes to Alan over the  
> comming days.

Great... the rest of my comments are inline (I sniped out the stuff  
where I don't have any other comments... darn thing is just too long :)

> Dain Sundstrom wrote:

>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> CosNaming/iiop_stubs/NamingContext_Stub.1.txt
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/ org/apache/geronimo/interop/CosNaming/iiop_stubs/  
>>> NamingContext_Stub.1.txt?view=auto&rev=126264
>>>
>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> CosNaming/iiop_stubs/NamingContext_Stub.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/ org/apache/geronimo/interop/CosNaming/iiop_stubs/  
>>> NamingContext_Stub.java?view=auto&rev=126264
>>
>>
>> Are these generated stubs based on the IDL above?  Normally, we don't  
>>  check in generated code, but I bet these almost never change.
>
>
> MD>> The name service stubs/skels are generated.  Right now, due to a  
> couple of issues, I have hand modified them and simply checked them  
> in.  This will need to change.  All other generated files go under  
> interop/target/src

I see. You many want to put a big warning at the top saying "don't  
bother messing with this is generated and going away".

>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> InteropGBean.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/  
>>> org/apache/geronimo/interop/InteropGBean.java?view=auto&rev=126264
>>> ===================================================================== 
>>> == =======
>>> --- (empty file)
>>> +++   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> InteropGBean.java    Sun Jan 23 23:33:10 2005
>>>
>>> +/**
>>> + * A GBean that provides an example interop
>>> + *
>>> + * @version $Rev: $ $Date: $
>>> + */
>>> +public class InteropGBean implements GBeanLifecycle {
>>
>>
>> Is this test code?  If it is an example we want to ship with the   
>> server, maybe we should put it in an example package or rename it   
>> ExampleInteropGBean.
>
>
> MD>> This GBean was the interop/corba container loader.  maybe a  
> better name is in order.

I think you lost me.  What is it?  The reason I thought is was test  
code was because it had an echo method that looks like test code I  
normally write.

> I haven't had a chance to flesh out the details for the Geronimo  
> integration.  I'd like to see the interop container be loaded by the  
> InteropGBean.  The InteropGBean could be a seperate plan or as part of  
> the j2ee-server plan.  For the J2EE 1.4 configuration, the interop  
> container would be enabled, but if a customer didn't care about the  
> interop container they could remove the plan from the server  
> configuration.

I personally would like to see less plans in Geronimo.  I personally  
find all the plans confusing, but others disagree with me :)

>>> +    /*
>>> +     * Return the skeleton implemention for the remote interface.    
>>> This interface has the
>>> +     * invoke method to handle the rmi/iiop messages.
>>> +     */
>>> +    public RemoteInterface getRemoteInterface() {
>>> +        if (_ri == null) {
>>> +            synchronized (this) {
>>> +                String riName = _remoteInterfaceName + "_Skeleton";
>>> +                _remoteInterfaceClass = loadClass(riName);
>>> +
>>> +                try {
>>> +                    _ri = (RemoteInterface)   
>>> _remoteInterfaceClass.newInstance();
>>> +                } catch (InstantiationException e) {
>>> +                    e.printStackTrace();  //To change body of catch  
>>>  statement use File | Settings | File Templates.
>>> +                } catch (IllegalAccessException e) {
>>> +                    e.printStackTrace();  //To change body of catch  
>>>  statement use File | Settings | File Templates.
>>> +                }
>>> +            }
>>> +        }
>>> +
>>> +        return _ri;
>>> +    }
>>
>>
>> This is double check locking.  The whole method needs to be   
>> synchronized.
>
> MD>> The double check code is wrong and I need to change it.    Does  
> the method require sync?  Maybe.  I recently came accross a strategy  
> for multiprocessor locking that uses a transient int as a memory  
> barrier.  Probably best if I don't attempt to explain it.  We can  
> optimize our locking.  The template that I came accross is as follows:
>
>    private volatile boolean _evaluated = false;
>
>    private Object _value;
>
>    /**
>     ** Sub-classes should override this method to get the object's  
> value
>     ** when it is first needed.
>     **/
>    public abstract Object evaluate();
>
>    public final Object getValue()
>    {
>        if (_volatileIsEffectiveMemoryBarrier)
>        {
>            if (! _evaluated)
>            {
>                synchronized (this)
>                {
>                    if (! _evaluated)
>                    {
>                        _value = evaluate();
>                        _evaluated = true;
>                    }
>                }
>            }
>        }
>        else
>        {
>            synchronized (this)
>            {
>                if (! _evaluated)
>                {
>                    _value = evaluate();
>                    _evaluated = true;
>                }
>            }
>        }
>        return _value;
>    }

Jeremy and I tried a structure like this when we were building locking  
code for geronimo.  The problem we found was evaluating a volatile is  
like 10 (maybe 100) times slower then entering a synchronized block.   
It seems that Sun has worked a ton on optimizing synchronized blocked  
and virtually no work on volatiles.  Regardless, I'd go for the easier  
to read simple synchronize code unless it's on the critical path (and  
then I'd do some testing :)

>> Again there is double check locking.  Also, if this is called in the   
>> critical path, I suggest we use CGLIB instead of reflection for   
>> construction as it is way faster.
>
> MD>>  I can look into CGLIB.

No rush on that one... it's for the polish phase.

>>> Added:   
>>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/  
>>> client/InitialContextFactory.java
>>> Url:   
>>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/ 
>>> java/ org/apache/geronimo/interop/client/InitialContextFactory.java?  
>>> view=auto&rev=126264
>>> ===================================================================== 
>>> == =======
>>> +public class InitialContextFactory
>>> +        implements javax.naming.spi.InitialContextFactory {
>>> +    private HashMap _startMap = new HashMap();
>>> +
>>> +    public Context getInitialContext(java.util.Hashtable env)  
>>> throws  NamingException {
>>> +        return   
>>> org.apache.geronimo.interop.rmi.iiop.client.ClientNamingContext.getIn 
>>> st ance(env);
>>> +    }
>>> +}
>>
>>
>> Is the _startMap variable used anywhere?
>
> MD>> I'd like to remove any naming in the interop and just use the  
> naming provided in Geronimo.

I just recently re-read the code in geronimo and the code is almost  
identical.  I think the only difference is the implementation in  
geronimo-naming supports compound name (java:comp/env) lookup from  
within a context.


Re: Review - svn commit: r126264

Posted by Mark <de...@hotmail.com>.
Thanks for the review.  I will go through your comments one-by-one over 
the next few days.

A few things to keep in mind:

1. The rmi/iiop code is fairly solid (with my fingers crossed).  I hope 
to get in a bunch of test cases that following the Geronimo design.
2. The stub/skeleton generation is farily *dirty* it.  You can convience 
it to work, code generation style/speed were not my primary objective.  
The rmi-iiop was.  So I fully anticipate this to change in the near future.
3. The original code was stand alone, hence there are a few other 
interop.* packages.  Once I learn more about Geronimo, I anticipate a 
much neater/tighter integration.  Of course, I think I will have lots of 
help from Alan.  :-)
4. I don't mind making the code or style changes to conform tothe Apache 
project.  The current style is a required habit for other projects that 
I work on.  :-)

I've added a few quick answers below see MD>>

( I only made it 1/2 way through this email... )

Expect that I will be submitting lots more changes to Alan over the 
comming days.

Thanks
Mark

Dain Sundstrom wrote:

> Mark,
>
> Wow!  This is very impressive work. I spent some time reading over 
> this  (well the first half... the thing is huge).  Most of the 
> comments, I  have are just my curiosity and don't really need to be 
> fixed.  Other  are notes on differences between this code an geronimo, 
> and I these  cases I think we should change current geronimo or this 
> new code so we  don't have multiple ways to do the same thing (BTW, I 
> generally don't  have a preference on which code we change unless one 
> is broken :)  Then  there are the few coding convention things, and 
> finally there are a few  nit picky things :)
>
> Thanks for the great work,
>
> -dain
>
>
> On Jan 23, 2005, at 11:33 PM, adc@apache.org wrote:
>
>> Added: geronimo/trunk/modules/interop/src/idl/CosNaming.idl
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/idl/ 
>> CosNaming.idl?view=auto&rev=126264
>>
>> Added: geronimo/trunk/modules/interop/src/idl/GIOP.idl
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/idl/ 
>> GIOP.idl?view=auto&rev=126264
>>
>> Added: geronimo/trunk/modules/interop/src/idl/IIOP.idl
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/idl/ 
>> IIOP.idl?view=auto&rev=126264
>>
>> Added: geronimo/trunk/modules/interop/src/idl/IOP.idl
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/idl/ 
>> IOP.idl?view=auto&rev=126264
>>
>> Added:  
>> geronimo/trunk/modules/interop/src/idl/org-apache-geronimo-interop- 
>> rmi-iiop.idl
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/idl/ 
>> org-apache-geronimo-interop-rmi-iiop.idl?view=auto&rev=126264
>
>
> The idl files need Apache license headers... maybe in the comments 
> that  are copied into the generated code.


MD>> If these are taken from the www.omg.org website, should we include 
the apache headers?

>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> CheckedException.java
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/CheckedException.java?view=auto&rev=126264
>>
>> +/**
>> + * * A wrapper that allows checked exceptions to be thrown as  
>> unchecked.
>> + */
>> +public class CheckedException extends RuntimeException {
>> +    public CheckedException(Throwable cause) {
>> +        super(cause);
>> +    }
>> +}
>
>
> How is this used?  Normally in Geronimo we have our invocation chains  
> (interceptor stacks) throw Throwable, and we just let exceptions flow  
> up.  In other cases, we divide exceptions into System and 
> Application.   We let the System exceptions flow up and the 
> Application exceptions are  wrapped in the results object since they 
> are treated as a normal return  for ejbs.  Anyway, I'm just curious.  
> If it falls into one of the basic  scenarios we already have a 
> preferred solution for, I'd like to either  switch the exiting code to 
> follow the new pattern or switch the new  iiop code to follow the 
> current pattern.


MD>> Its most likely that this class will go away soon.

>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> CosNaming/iiop_stubs/NamingContext_Stub.1.txt
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/CosNaming/iiop_stubs/ 
>> NamingContext_Stub.1.txt?view=auto&rev=126264
>>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> CosNaming/iiop_stubs/NamingContext_Stub.java
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/CosNaming/iiop_stubs/ 
>> NamingContext_Stub.java?view=auto&rev=126264
>
>
> Are these generated stubs based on the IDL above?  Normally, we don't  
> check in generated code, but I bet these almost never change.


MD>> The name service stubs/skels are generated.  Right now, due to a 
couple of issues, I have hand modified them and simply checked them in.  
This will need to change.  All other generated files go under 
interop/target/src


>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> InteropGBean.java
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/InteropGBean.java?view=auto&rev=126264
>> ======================================================================= 
>> =======
>> --- (empty file)
>> +++  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> InteropGBean.java    Sun Jan 23 23:33:10 2005
>>
>> +/**
>> + * A GBean that provides an example interop
>> + *
>> + * @version $Rev: $ $Date: $
>> + */
>> +public class InteropGBean implements GBeanLifecycle {
>
>
> Is this test code?  If it is an example we want to ship with the  
> server, maybe we should put it in an example package or rename it  
> ExampleInteropGBean.


MD>> This GBean was the interop/corba container loader.  maybe a better 
name is in order.  I haven't had a chance to flesh out the details for 
the Geronimo integration.  I'd like to see the interop container be 
loaded by the InteropGBean.  The InteropGBean could be a seperate plan 
or as part of the j2ee-server plan.  For the J2EE 1.4 configuration, the 
interop container would be enabled, but if a customer didn't care about 
the interop container they could remove the plan from the server 
configuration.

>
>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> SystemException.java
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/SystemException.java?view=auto&rev=126264
>
>
> Same comment as above for CheckedException.
>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> adapter/Adapter.java
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/adapter/Adapter.java?view=auto&rev=126264
>> ======================================================================= 
>> =======
>> +public class Adapter {
>> +    //
>> +    // Public Accessible Properties
>> +    //
>
>
> I don't think we need comments like this... it is self explanatory.


MD>>  Default template code .. Comments can be taken out. :-)

>
>
>> +    protected String _bindName;
>> +    protected String _remoteClassName;
>> +    protected String _remoteInterfaceName;
>> +    protected Vector _idVector;
>> +    protected boolean _shared;
>> +    protected ClassLoader _cl;
>> +    protected RemoteInterface _ri;
>
>
> Our naming convention doesn't use lead underscores.  Also we tend not  
> to use protected fields.  Maybe there is a subclass or some reason.


MD>> I have noticed that.  Will be changed.

>
>> +    //
>> +    // Internal Properrties
>> +    //
>> +
>> +    protected Object _sharedObject;
>> +    protected HashMap _objects;
>> +    protected Class _remoteClassClass;
>> +    protected Class _remoteInterfaceClass;
>> +
>> +    public Adapter() {
>> +        _objects = new HashMap();
>> +        _idVector = new Vector();
>> +    }
>> +
>> +    /*
>> +     * BindName is the name that will be registered with the INS  
>> (Inter-operable Name Service)
>> +     */
>> +    public String getBindName() {
>> +        return _bindName;
>> +    }
>> +
>> +    public void setBindName(String bindName) {
>> +        _bindName = bindName;
>> +    }
>> +
>> +    /*
>> +     * Is this a shared component?  If so this will invoke the  
>> getInstance method on
>> +     * the component ...
>> +     */
>> +    public boolean isShared() {
>> +        return _shared;
>> +    }
>> +
>> +    public void setShared(boolean shared) {
>> +        _shared = shared;
>> +    }
>> +
>> +    /*
>> +     * The classloader that will load any dependancies of the 
>> adapter  or corba skel interfaces.
>> +     * Its should be set by the ejb container
>> +     */
>> +    public ClassLoader getClassLoader() {
>> +        return _cl;
>> +    }
>> +
>> +    public void setClassLoader(ClassLoader cl) {
>> +        _cl = cl;
>> +    }
>
>
> Can we change these to be constructor injected and make the fields  
> final?

MD>> Its possible, I have to discuss this more with Alan .

>
>> +    /*
>> +     * This is the name of the remote class that implements the  
>> remote interface.
>> +     *
>> +     * This is only used if this adapter is going to directly 
>> invoke  an object.  For the
>> +     * EJB Container, the adapter will pass through the method  
>> invocations.
>> +     */
>> +    public String getRemoteClassName() {
>> +        return _remoteClassName;
>> +    }
>> +
>> +    public void setRemoteClassName(String rcName) {
>> +        _remoteClassName = rcName;
>> +    }
>> +
>> +    /*
>> +     * The remote interface name for the remote object.  This will  
>> most likely be the name
>> +     * of the EJB's RemoteInterface and RemoteHomeInterface
>> +     *
>> +     * The stub/skel generator will use this interface name.
>> +     */
>> +    public String getRemoteInterfaceName() {
>> +        return _remoteInterfaceName;
>> +    }
>> +
>> +    public void setRemoteInterfaceName(String riName) {
>> +        _remoteInterfaceName = riName;
>> +    }
>> +
>> +    /*
>> +     * A list of public IDs that the remote object implements:
>> +     *
>> +     * IDL:....:1.0
>> +     * RMI:....:X:Y
>> +     */
>> +    public Vector getIds() {
>> +        return _idVector;
>> +    }
>> +
>> +    public void addId(String id) {
>> +        _idVector.add(id);
>> +    }
>> +
>> +    public void removeId(String id) {
>> +        _idVector.remove(id);
>> +    }
>> +
>> +    /*
>> +     * Return the skeleton implemention for the remote interface.   
>> This interface has the
>> +     * invoke method to handle the rmi/iiop messages.
>> +     */
>> +    public RemoteInterface getRemoteInterface() {
>> +        if (_ri == null) {
>> +            synchronized (this) {
>> +                String riName = _remoteInterfaceName + "_Skeleton";
>> +                _remoteInterfaceClass = loadClass(riName);
>> +
>> +                try {
>> +                    _ri = (RemoteInterface)  
>> _remoteInterfaceClass.newInstance();
>> +                } catch (InstantiationException e) {
>> +                    e.printStackTrace();  //To change body of catch  
>> statement use File | Settings | File Templates.
>> +                } catch (IllegalAccessException e) {
>> +                    e.printStackTrace();  //To change body of catch  
>> statement use File | Settings | File Templates.
>> +                }
>> +            }
>> +        }
>> +
>> +        return _ri;
>> +    }
>
>
> This is double check locking.  The whole method needs to be  
> synchronized.

MD>> The double check code is wrong and I need to change it.    Does the 
method require sync?  Maybe.  I recently came accross a strategy for 
multiprocessor locking that uses a transient int as a memory barrier.  
Probably best if I don't attempt to explain it.  We can optimize our 
locking.  The template that I came accross is as follows:

    private volatile boolean _evaluated = false;

    private Object _value;

    /**
     ** Sub-classes should override this method to get the object's value
     ** when it is first needed.
     **/
    public abstract Object evaluate();

    public final Object getValue()
    {
        if (_volatileIsEffectiveMemoryBarrier)
        {
            if (! _evaluated)
            {
                synchronized (this)
                {
                    if (! _evaluated)
                    {
                        _value = evaluate();
                        _evaluated = true;
                    }
                }
            }
        }
        else
        {
            synchronized (this)
            {
                if (! _evaluated)
                {
                    _value = evaluate();
                    _evaluated = true;
                }
            }
        }
        return _value;
    }

>
>> +    /*
>> +     * Get an object instance to invoke based on the object key.
>> +     *
>> +     * The objectKey could probably be passed to the EJB container 
>> so  that the
>> +     * container can directly invoke the ejb object as required.
>> +     */
>> +    public Object getInstance(byte[] objectKey) {
>> +        String key = new String(objectKey);
>> +        return getInstance(key);
>> +    }
>> +
>> +    public Object getInstance(String key) {
>> +        Object o = _objects.get(key);
>> +
>> +        if (o == null) {
>> +            o = newInstance(key);
>> +        }
>> +
>> +        return o;
>> +    }
>> +
>> +    public Object newInstance(byte[] objectKey) {
>> +        String key = new String(objectKey);
>> +        return newInstance(key);
>> +    }
>> +
>> +    public Object newInstance(String key) {
>> +        Object o = null;
>> +
>> +        if (_remoteClassClass == null) {
>> +            synchronized (this) {
>> +                _remoteClassClass = loadClass(_remoteClassName);
>> +            }
>> +
>> +            try {
>> +                if (_shared) {
>> +                    synchronized (this) {
>> +                        Method m =  
>> _remoteClassClass.getMethod("getInstance", (Class[]) null);
>> +                        o = m.invoke(_remoteClassClass, (Object[])  
>> null);
>> +
>> +                        if (o != null) {
>> +                            _objects.put(key, o);
>> +                        }
>> +                    }
>> +                } else {
>> +                    o = _remoteClassClass.newInstance();
>> +                    _objects.put(key, o);
>> +                }
>> +            } catch (InstantiationException e) {
>> +                e.printStackTrace();  //To change body of catch  
>> statement use File | Settings | File Templates.
>> +            } catch (IllegalAccessException e) {
>> +                e.printStackTrace();  //To change body of catch  
>> statement use File | Settings | File Templates.
>> +            } catch (NoSuchMethodException e) {
>> +                e.printStackTrace();
>> +            } catch (InvocationTargetException e) {
>> +                e.printStackTrace();
>> +            }
>> +        }
>> +
>> +        return o;
>> +    }
>
>
> Again there is double check locking.  Also, if this is called in the  
> critical path, I suggest we use CGLIB instead of reflection for  
> construction as it is way faster.

MD>>  I can look into CGLIB.

>
>> +    /*
>> +     * Invoke method from the IIOP Message Handler.  The adapter is  
>> bound to the INS name service.
>> +     * When an RMI/IIOP message is processed by the server, the  
>> message handler will perform a lookup
>> +     * on the name service to get the Adapter, then the invocation  
>> will be passed to the adapter
>> +     * The adapter will obtain the object key and then determine  
>> which object instance to pass the
>> +     * invocation to.
>> +     */
>
>
> This comment is missing the double star at the top to signify javadoc.
>
>> +    public void invoke(java.lang.String methodName, byte[] 
>> objectKey,  org.apache.geronimo.interop.rmi.iiop.ObjectInputStream 
>> input,  org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream 
>> output) {
>> +        RemoteInterface skeleton = getRemoteInterface();
>> +        Object instance = getInstance(objectKey);
>> +
>> +        if (instance != null) {
>> +            skeleton.$invoke(methodName, objectKey, instance, 
>> input,  output);
>> +        } else {
>> +            throw new org.omg.CORBA.OBJECT_NOT_EXIST(new  
>> String(objectKey));
>> +        }
>> +    }
>> +
>> +    /*
>> +     * Helper function to load a class.  This uses classloader for  
>> the adapter.
>> +     */
>> +    protected Class loadClass(String name) {
>> +        Class c = null;
>> +
>> +        try {
>> +            c = _cl.loadClass(name);
>> +        } catch (Exception e) {
>> +            e.printStackTrace();
>> +        }
>> +
>> +        return c;
>> +    }
>> +}
>
>
> I think we should be at least logging the error or actually letting 
> the  ClassNotFoundException through.  We also have a ClassLoading 
> class  which you may want to use as it handles some of the more weird 
> class  name formats.

MD >> Will change with better Geronimo integration.

>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> adapter/AdapterManager.java
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/adapter/AdapterManager.java? 
>> view=auto&rev=126264
>> ======================================================================= 
>> =======
>> --- (empty file)
>> +++  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> adapter/AdapterManager.java    Sun Jan 23 23:33:10 2005
>> @@ -0,0 +1,43 @@
>> +/**
>> + *
>> + *  Copyright 2004-2005 The Apache Software Foundation
>> + *
>> + *  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.
>> + */
>> +package org.apache.geronimo.interop.adapter;
>> +
>> +import java.util.Hashtable;
>> +
>> +
>> +public class AdapterManager {
>> +    protected Hashtable _adapters;
>> +    protected static AdapterManager _me = new AdapterManager();
>
>
> Underscores and protected...

MD>> Will do.

>
>> +    protected AdapterManager() {
>> +        _adapters = new Hashtable();
>> +    }
>> +
>> +    public static AdapterManager getInstance() {
>> +        return _me;
>> +    }
>
>
> This is a bad idea.  Instead we should have a manger gbean and the  
> singletonness would be handled by there being only one GBean instance  
> registered.

MD>> Sure, this will change with the introduction of GBeans, better 
integration...

>
>> +    public void registerAdapter(Adapter a) {
>> +
>> +        _adapters.put(a.getBindName(), a);
>> +    }
>> +
>> +    public Adapter getAdapter(String objectName) {
>> +        return (Adapter) _adapters.get(objectName);
>> +    }
>
>
> I prefer HashMap and synchronizing the methods that access the Map, 
> but  this works in this case.

MD>> Hashtables are going to be dead soon.  ;-)

>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> client/InitialContextFactory.java
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/client/InitialContextFactory.java? 
>> view=auto&rev=126264
>> ======================================================================= 
>> =======
>> +public class InitialContextFactory
>> +        implements javax.naming.spi.InitialContextFactory {
>> +    private HashMap _startMap = new HashMap();
>> +
>> +    public Context getInitialContext(java.util.Hashtable env) 
>> throws  NamingException {
>> +        return  
>> org.apache.geronimo.interop.rmi.iiop.client.ClientNamingContext.getInst 
>> ance(env);
>> +    }
>> +}
>
>
> Is the _startMap variable used anywhere?

MD>> I'd like to remove any naming in the interop and just use the 
naming provided in Geronimo.

>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> client/InitialContextFactoryBuilder.java
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/client/InitialContextFactoryBuilder.java? 
>> view=auto&rev=126264
>> ======================================================================= 
>> =======
>> +public class InitialContextFactoryBuilder
>> +        implements javax.naming.spi.InitialContextFactoryBuilder {
>> +    public javax.naming.spi.InitialContextFactory  
>> createInitialContextFactory(Hashtable env) {
>> +        return new InitialContextFactory();
>> +    }
>> +}
>
>
> What is this for?  Just curious...
>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> generator/GenException.java
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/generator/GenException.java? 
>> view=auto&rev=126264
>> ======================================================================= 
>> =======
>> +/**
>> + * User: Mark
>> + * Date: Dec 21, 2004
>> + * Time: 3:49:45 PM
>> + */
>
>
> Oops :)
>
>> +public class GenException
>> +        extends Exception {
>> +    public GenException() {
>> +        super();
>> +    }
>> +
>> +    public GenException(String message) {
>> +        super(message);
>> +    }
>> +
>> +    public GenException(Throwable cause) {
>> +        super(cause);
>> +    }
>> +
>> +    public GenException(String message, Throwable cause) {
>> +        super(message, cause);
>> +    }
>> +}
>>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> generator/GenOptions.java
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/generator/GenOptions.java? 
>> view=auto&rev=126264
>> ======================================================================= 
>> =======
>> +public class GenOptions {
>> +    protected String _genDir = "./";
>> +    protected boolean _overwrite = false;
>> +    protected boolean _verbose = false;
>> +
>> +    public GenOptions() {
>> +    }
>> +
>> +    public GenOptions(String genDir, boolean overwrite, boolean  
>> verbose) {
>> +        _genDir = genDir;
>> +        _overwrite = overwrite;
>> +        _verbose = verbose;
>> +    }
>> +
>> +    public String getGenDir() {
>> +        return _genDir;
>> +    }
>> +
>> +    public void setGenDir(String genDir) {
>> +        _genDir = genDir;
>> +    }
>> +
>> +    public boolean isOverwrite() {
>> +        return _overwrite;
>> +    }
>> +
>> +    public void setOverwrite(boolean overwrite) {
>> +        _overwrite = overwrite;
>> +    }
>> +
>> +    public boolean isVerbose() {
>> +        return _verbose;
>> +    }
>> +
>> +    public void setVerbose(boolean verbose) {
>> +        _verbose = verbose;
>> +    }
>> +
>> +}
>
>
> Do we need both the constructor args and the setters?  If I set a  
> variable is whatever is using this class going to adapt to the 
> recently  changed variable?
>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> naming/NameService.java
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/naming/NameService.java? 
>> view=auto&rev=126264
>> ======================================================================= 
>> =======
>> --- (empty file)
>> +++  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> naming/NameService.java    Sun Jan 23 23:33:10 2005
>> @@ -0,0 +1,66 @@
>> +/**
>> + *
>> + *  Copyright 2004-2005 The Apache Software Foundation
>> + *
>> + *  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.
>> + */
>> +package org.apache.geronimo.interop.naming;
>> +
>> +import java.util.HashMap;
>> +import javax.naming.NamingException;
>> +
>> +import org.apache.geronimo.interop.adapter.Adapter;
>> +
>> +
>> +public class NameService {
>> +    protected static NameService _ns = null;
>
>
> protected and underscore
>
>> +    public static NameService getInstance() {
>> +        if (_ns == null) {
>> +            synchronized (NameService.class) {
>> +                if (_ns == null) {
>> +                    _ns = new NameService();
>> +                    _ns.init();
>> +                }
>> +            }
>> +        }
>> +
>> +        return _ns;
>> +    }
>
>
> Double check locking
>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> naming/NamingContext.java
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/naming/NamingContext.java? 
>> view=auto&rev=126264
>> ======================================================================= 
>> =======
>> --- (empty file)
>> +++  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> naming/NamingContext.java    Sun Jan 23 23:33:10 2005
>> @@ -0,0 +1,150 @@
>> +/**
>> + *
>> + *  Copyright 2004-2005 The Apache Software Foundation
>> + *
>> + *  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.
>> + */
>> +package org.apache.geronimo.interop.naming;
>> +
>> +import java.util.HashMap;
>> +import javax.naming.NameNotFoundException;
>> +import javax.naming.NamingException;
>> +
>> +import org.apache.geronimo.interop.adapter.Adapter;
>> +
>> +
>> +public class NamingContext {
>> +    public static final NamingContext getInstance(Class baseClass) {
>> +        NamingContext context;
>> +        synchronized (_contextMap) {
>> +            context = (NamingContext) _contextMap.get(baseClass);
>> +            if (context == null) {
>> +                context = new NamingContext();
>> +                _contextMap.put(baseClass, context);
>> +                context.init(baseClass);
>> +            }
>> +        }
>> +        return context;
>> +    }
>> +
>> +    private static ThreadLocal _current = new ThreadLocal();
>
>
> Should this be an InheritableThreadLocal?
>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> properties/BooleanProperty.java
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/properties/BooleanProperty.java? 
>> view=auto&rev=126264
>>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> properties/ByteProperty.java
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/properties/ByteProperty.java? 
>> view=auto&rev=126264
>>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> properties/DoubleProperty.java
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/properties/DoubleProperty.java? 
>> view=auto&rev=126264
>>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> properties/FloatProperty.java
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/properties/FloatProperty.java? 
>> view=auto&rev=126264
>>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> properties/IntProperty.java
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/properties/IntProperty.java? 
>> view=auto&rev=126264
>>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> properties/LongProperty.java
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/properties/LongProperty.java? 
>> view=auto&rev=126264
>>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> properties/ShortProperty.java
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/properties/ShortProperty.java? 
>> view=auto&rev=126264
>>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> properties/StringProperty.java
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/properties/StringProperty.java? 
>> view=auto&rev=126264
>
>
> How are these used?
>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> properties/SystemProperties.java
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/properties/SystemProperties.java? 
>> view=auto&rev=126264
>
>
> Is this a bridge to java.lang.System properties?  If so, do we really  
> want to support system properties?
>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> repository/Repository.java
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/repository/Repository.java? 
>> view=auto&rev=126264
>> ======================================================================= 
>> =======
>> +public class Repository {
>> +    // ??
>> +}
>
>
> Say what? :)
>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> rmi/iiop/IiopVersion.java
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/rmi/iiop/IiopVersion.java? 
>> view=auto&rev=126264
>> ======================================================================= 
>> =======
>> +public class IiopVersion {
>> +}
>
>
> What's this for?
>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> rmi/iiop/ListenerInfo.java
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/rmi/iiop/ListenerInfo.java? 
>> view=auto&rev=126264
>> +public class ListenerInfo {
>> +    public int protocol;
>> +
>> +    public String host;
>> +
>> +    public int port;
>> +}
>
>
> Do these have to be public fields?  Normally we use, private fields  
> with getters and setters.
>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> rmi/iiop/NameServiceOperations_Skeleton.java
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/rmi/iiop/ 
>> NameServiceOperations_Skeleton.java?view=auto&rev=126264
>
>
> Do we want the Skeletons checked in?
>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> rmi/iiop/ObjectKey.java
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/rmi/iiop/ObjectKey.java? 
>> view=auto&rev=126264
>> ======================================================================= 
>> =======
>> +public class ObjectKey {
>> +    public static final int TYPE_MANAGER = 'M';
>> +
>> +    public static final int TYPE_SESSION = 'S';
>> +
>> +    public int type;
>> +    public String username = "";
>> +    public String password = "";
>> +    public String component = "";
>> +    public String sessionID = "";
>
>
> public fields?
>
>> +    public void checkPassword() {
>> +        User.getInstance(username).login(password);
>> +    }
>
>
> Shouldn't this go though Geronimo security?
>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> rmi/iiop/ObjectRef.java
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/rmi/iiop/ObjectRef.java? 
>> view=auto&rev=126264
>> ======================================================================= 
>> =======
>> +    public int $getIiopVersion() {
>> +        return _iiopVersion;
>> +    }
>
>
> Why do all the methods in this class start with a dollar sign?
>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> rmi/iiop/client/ClientNamingContext.java
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/rmi/iiop/client/ClientNamingContext.java? 
>> view=auto&rev=126264
>
>
> We should consider merging this with the Geronimo naming stuff... not 
> a  task for today, but (much) later on :)
>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> rmi/iiop/compiler/StubCompiler.txt
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/rmi/iiop/compiler/StubCompiler.txt? 
>> view=auto&rev=126264
>
>
> Why is this a text file?
>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> rmi/iiop/server/SocketListener.java
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/rmi/iiop/server/SocketListener.java? 
>> view=auto&rev=126264
>> ======================================================================= 
>> =======
>> +public class SocketListener extends Thread {
>> +    public static SocketListener getInstance() {
>> +        return new SocketListener();
>> +    }
>
>
> Why is there a static factory?
>
>> +    // private data
>> +
>> +    private String _name;
>> +
>> +    private String _host;
>> +
>> +    private int _port;
>> +
>> +    private int _listenBacklog;
>> +
>> +    private java.net.ServerSocket _listener;
>> +
>> +    // internal methods
>> +
>> +    protected void init() {
>> +        _host = "localhost";
>> +        _port = 2000;
>> +        _listenBacklog = 10;
>> +        setDaemon(true);
>> +    }
>> +
>> +    // public methods
>> +
>> +    public void setHost(String host) {
>> +        _host = host;
>> +    }
>> +
>> +    public void setPort(int port) {
>> +        _port = port;
>> +    }
>> +
>> +    public void setListenBacklog(int backlog) {
>> +        _listenBacklog = backlog;
>> +    }
>> +
>> +    public void run() {
>> +        String iiopURL = "iiop://" + _host + ":" + _port;
>> +        ListenerInfo listenerInfo = new ListenerInfo();
>> +        listenerInfo.protocol = Protocol.IIOP; // TODO: other  
>> protocols (IIOPS etc.)
>> +        listenerInfo.host = _host;
>> +        listenerInfo.port = _port;
>> +        try {
>> +            InetAddress addr = InetAddress.getByName(_host);
>> +            _listener = new java.net.ServerSocket(_port,  
>> _listenBacklog, addr);
>> +        } catch (Exception ex) {
>> +            System.out.println("SocketListener: Error creating 
>> server  socket.");
>> +            ex.printStackTrace();
>> +            try {
>> +                Socket socket = new Socket(_host, _port);
>> +                socket.close();
>> +                System.out.println("SocketListener: Error server  
>> already running: " + iiopURL);
>> +                ex.printStackTrace();
>> +            } catch (Exception ignore) {
>> +            }
>> +            return;
>> +        }
>> +        new CheckConnect().start();
>> +        for (; ;) {
>> +            java.net.Socket socket;
>> +            try {
>> +                socket = _listener.accept();
>> +            } catch (Exception ex) {
>> +                throw new SystemException(ex); // TODO: log error  
>> message
>> +            }
>> +            MessageHandler.getInstance(listenerInfo, socket).start();
>> +        }
>> +    }
>> +
>> +    private class CheckConnect extends Thread {
>> +        public void run() {
>> +            try {
>> +                Socket socket = new Socket(_host, _port);
>> +                socket.close();
>> +                if (!SystemProperties.quiet()) {
>> +                     
>> System.out.println(formatAcceptingIiopConnections());
>> +                }
>> +            } catch (Exception ex) {
>> +                warnConnectFailed(_host, _port);
>> +            }
>> +        }
>> +    }
>> +
>> +    // format methods
>> +
>> +    protected String formatAcceptingIiopConnections() {
>> +        String msg = 
>> "SocketListener.formatAcceptingIiopConnection():  ";
>> +        return msg;
>> +    }
>> +
>> +    // log methods
>> +
>> +    protected void warnConnectFailed(String host, int port) {
>> +        System.out.println("SocketListener.warnConnectFailed(): 
>> host  = " + host + ", port = " + port);
>> +    }
>> +}
>
>
> I suggest, you either require all state data such as host and port be  
> passed in via the constructor, or make the setters throw an "already  
> running" exception.  Otherwise people mistakenly think the can change  
> the port.
>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> security/Role.java
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/security/Role.java?view=auto&rev=126264
>>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> security/SimpleSubject.java
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/security/SimpleSubject.java? 
>> view=auto&rev=126264
>>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> security/User.java
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/security/User.java?view=auto&rev=126264
>
>
> What is the plan for these with regards to the Geronimo security module?
>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> util/SystemUtil.java
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/util/SystemUtil.java?view=auto&rev=126264
>> ======================================================================= 
>> =======
>> +public class SystemUtil {
>> +    // properties
>> +
>> +    public static final StringProperty vmVersionProperty =
>> +            new StringProperty(SystemProperties.class,  
>> "java.vm.version");
>> +
>> +    // private data
>> +
>> +    private static String _vmVersion = vmVersionProperty.getString();
>> +
>> +    private static boolean _isJDK13 = _vmVersion.startsWith("1.3")
>> +                                      ||  
>> _vmVersion.startsWith("CrE-ME V4.00");
>> +
>> +    private static boolean _isJDK14 = _vmVersion.startsWith("1.4");
>> +
>> +    // public methods
>> +
>> +    public static String getExecutableSuffix() {
>> +        return isWindows() ? ".exe" : "";
>> +    }
>> +
>> +    public static String getShellScriptSuffix() {
>> +        return isWindows() ? ".bat" : ".sh";
>> +    }
>> +
>> +    public static boolean isJDK13() {
>> +        return _isJDK13;
>> +    }
>> +
>> +    public static boolean isJDK14() {
>> +        return _isJDK14;
>> +    }
>> +
>> +    public static boolean isWindows() {
>> +        return java.io.File.separatorChar == '\\';
>> +    }
>> +}
>
>
> How is this used?
>
>> Added:  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> util/ThreadContext.java
>> Url:  
>> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
>> org/apache/geronimo/interop/util/ThreadContext.java? 
>> view=auto&rev=126264
>> ======================================================================= 
>> =======
>> --- (empty file)
>> +++  
>> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
>> util/ThreadContext.java    Sun Jan 23 23:33:10 2005
>> @@ -0,0 +1,135 @@
>> +/**
>> + *
>> + *  Copyright 2004-2005 The Apache Software Foundation
>> + *
>> + *  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.
>> + */
>> +package org.apache.geronimo.interop.util;
>> +
>> +import java.util.HashMap;
>> +
>> +import org.apache.geronimo.interop.SystemException;
>> +
>> +
>> +public abstract class ThreadContext {
>> +    private static HashMap _primTypes;
>> +
>> +    private static ThreadLocal _defaultRmiHost = new ThreadLocal();
>> +
>> +    private static ThreadLocal _defaultRmiPort = new ThreadLocal();
>> +
>> +    static {
>> +        _primTypes = new HashMap();
>> +        _primTypes.put("boolean", boolean.class);
>> +        _primTypes.put("char", char.class);
>> +        _primTypes.put("byte", byte.class);
>> +        _primTypes.put("short", short.class);
>> +        _primTypes.put("int", int.class);
>> +        _primTypes.put("long", long.class);
>> +        _primTypes.put("float", float.class);
>> +        _primTypes.put("double", double.class);
>> +        _primTypes.put("boolean[]", boolean[].class);
>> +        _primTypes.put("char[]", char[].class);
>> +        _primTypes.put("byte[]", byte[].class);
>> +        _primTypes.put("short[]", short[].class);
>> +        _primTypes.put("int[]", int[].class);
>> +        _primTypes.put("long[]", long[].class);
>> +        _primTypes.put("float[]", float[].class);
>> +        _primTypes.put("double[]", double[].class);
>> +    }
>> +
>> +    public static String getDefaultRmiHost() {
>> +        String host = (String) _defaultRmiHost.get();
>> +        if (host == null) {
>> +            host = "0";
>> +        }
>> +        return host;
>> +    }
>> +
>> +    public static int getDefaultRmiPort() {
>> +        Integer port = (Integer) _defaultRmiPort.get();
>> +        if (port == null) {
>> +            port = IntegerCache.get(0);
>> +        }
>> +        return port.intValue();
>> +    }
>> +
>> +    public static Class loadClass(String className) {
>> +        Class t = (Class) _primTypes.get(className);
>> +        if (t != null) {
>> +            return t;
>> +        }
>> +        try {
>> +            ClassLoader loader =  
>> Thread.currentThread().getContextClassLoader();
>> +            if (loader == null) {
>> +                return Class.forName(className);
>> +            } else {
>> +                return loader.loadClass(className);
>> +            }
>> +        } catch (RuntimeException ex) {
>> +            throw (RuntimeException) ex;
>> +        } catch (Exception ex) {
>> +            throw new SystemException(ex);
>> +        }
>> +    }
>
>
> This is unlikely to work in Geronimo as we almost never set context  
> class loader.  Normally we try to explicitly pass around the  
> classloader.
>
>> +
>> +    public static Class loadClass(String className, Class  
>> parentClass) {
>> +        if (parentClass == null) {
>> +            return loadClass(className);
>> +        }
>> +        Class t = (Class) _primTypes.get(className);
>> +        if (t != null) {
>> +            return t;
>> +        }
>> +        try {
>> +            ClassLoader loader = parentClass.getClassLoader();
>> +            if (loader == null) {
>> +                return loadClass(className);
>> +            } else {
>> +                return loader.loadClass(className);
>> +            }
>> +        } catch (RuntimeException ex) {
>> +            throw (RuntimeException) ex;
>> +        } catch (Exception ex) {
>> +            throw new SystemException(ex);
>> +        }
>> +    }
>> +
>> +    public static Class loadClassOrReturnNullIfNotFound(String  
>> className) {
>> +        try {
>> +            return loadClass(className);
>> +        } catch (RuntimeException ex) {
>> +            return null;
>> +        }
>> +    }
>> +
>> +    public static Class loadClassOrReturnNullIfNotFound(String  
>> className, Class parentClass) {
>> +        if (parentClass == null) {
>> +            return loadClassOrReturnNullIfNotFound(className);
>> +        }
>> +        try {
>> +            return loadClass(className, parentClass);
>> +        } catch (RuntimeException ex) {
>> +            return null;
>> +        }
>> +    }
>
>
> Most of this class loader stuff is handled by the class ClassLoading  
> which handles some of the more weird stuff.
>
>
> .
>


Review - svn commit: r126264

Posted by Dain Sundstrom <ds...@gluecode.com>.
Mark,

Wow!  This is very impressive work. I spent some time reading over this  
(well the first half... the thing is huge).  Most of the comments, I  
have are just my curiosity and don't really need to be fixed.  Other  
are notes on differences between this code an geronimo, and I these  
cases I think we should change current geronimo or this new code so we  
don't have multiple ways to do the same thing (BTW, I generally don't  
have a preference on which code we change unless one is broken :)  Then  
there are the few coding convention things, and finally there are a few  
nit picky things :)

Thanks for the great work,

-dain


On Jan 23, 2005, at 11:33 PM, adc@apache.org wrote:

> Added: geronimo/trunk/modules/interop/src/idl/CosNaming.idl
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/idl/ 
> CosNaming.idl?view=auto&rev=126264
>
> Added: geronimo/trunk/modules/interop/src/idl/GIOP.idl
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/idl/ 
> GIOP.idl?view=auto&rev=126264
>
> Added: geronimo/trunk/modules/interop/src/idl/IIOP.idl
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/idl/ 
> IIOP.idl?view=auto&rev=126264
>
> Added: geronimo/trunk/modules/interop/src/idl/IOP.idl
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/idl/ 
> IOP.idl?view=auto&rev=126264
>
> Added:  
> geronimo/trunk/modules/interop/src/idl/org-apache-geronimo-interop- 
> rmi-iiop.idl
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/idl/ 
> org-apache-geronimo-interop-rmi-iiop.idl?view=auto&rev=126264

The idl files need Apache license headers... maybe in the comments that  
are copied into the generated code.

> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> CheckedException.java
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/CheckedException.java?view=auto&rev=126264
>
> +/**
> + * * A wrapper that allows checked exceptions to be thrown as  
> unchecked.
> + */
> +public class CheckedException extends RuntimeException {
> +    public CheckedException(Throwable cause) {
> +        super(cause);
> +    }
> +}

How is this used?  Normally in Geronimo we have our invocation chains  
(interceptor stacks) throw Throwable, and we just let exceptions flow  
up.  In other cases, we divide exceptions into System and Application.   
We let the System exceptions flow up and the Application exceptions are  
wrapped in the results object since they are treated as a normal return  
for ejbs.  Anyway, I'm just curious.  If it falls into one of the basic  
scenarios we already have a preferred solution for, I'd like to either  
switch the exiting code to follow the new pattern or switch the new  
iiop code to follow the current pattern.

> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> CosNaming/iiop_stubs/NamingContext_Stub.1.txt
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/CosNaming/iiop_stubs/ 
> NamingContext_Stub.1.txt?view=auto&rev=126264
>
> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> CosNaming/iiop_stubs/NamingContext_Stub.java
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/CosNaming/iiop_stubs/ 
> NamingContext_Stub.java?view=auto&rev=126264

Are these generated stubs based on the IDL above?  Normally, we don't  
check in generated code, but I bet these almost never change.

> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> InteropGBean.java
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/InteropGBean.java?view=auto&rev=126264
> ======================================================================= 
> =======
> --- (empty file)
> +++  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> InteropGBean.java	Sun Jan 23 23:33:10 2005
>
> +/**
> + * A GBean that provides an example interop
> + *
> + * @version $Rev: $ $Date: $
> + */
> +public class InteropGBean implements GBeanLifecycle {

Is this test code?  If it is an example we want to ship with the  
server, maybe we should put it in an example package or rename it  
ExampleInteropGBean.


> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> SystemException.java
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/SystemException.java?view=auto&rev=126264

Same comment as above for CheckedException.

> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> adapter/Adapter.java
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/adapter/Adapter.java?view=auto&rev=126264
> ======================================================================= 
> =======
> +public class Adapter {
> +    //
> +    // Public Accessible Properties
> +    //

I don't think we need comments like this... it is self explanatory.


> +    protected String _bindName;
> +    protected String _remoteClassName;
> +    protected String _remoteInterfaceName;
> +    protected Vector _idVector;
> +    protected boolean _shared;
> +    protected ClassLoader _cl;
> +    protected RemoteInterface _ri;

Our naming convention doesn't use lead underscores.  Also we tend not  
to use protected fields.  Maybe there is a subclass or some reason.

> +    //
> +    // Internal Properrties
> +    //
> +
> +    protected Object _sharedObject;
> +    protected HashMap _objects;
> +    protected Class _remoteClassClass;
> +    protected Class _remoteInterfaceClass;
> +
> +    public Adapter() {
> +        _objects = new HashMap();
> +        _idVector = new Vector();
> +    }
> +
> +    /*
> +     * BindName is the name that will be registered with the INS  
> (Inter-operable Name Service)
> +     */
> +    public String getBindName() {
> +        return _bindName;
> +    }
> +
> +    public void setBindName(String bindName) {
> +        _bindName = bindName;
> +    }
> +
> +    /*
> +     * Is this a shared component?  If so this will invoke the  
> getInstance method on
> +     * the component ...
> +     */
> +    public boolean isShared() {
> +        return _shared;
> +    }
> +
> +    public void setShared(boolean shared) {
> +        _shared = shared;
> +    }
> +
> +    /*
> +     * The classloader that will load any dependancies of the adapter  
> or corba skel interfaces.
> +     * Its should be set by the ejb container
> +     */
> +    public ClassLoader getClassLoader() {
> +        return _cl;
> +    }
> +
> +    public void setClassLoader(ClassLoader cl) {
> +        _cl = cl;
> +    }

Can we change these to be constructor injected and make the fields  
final?

> +    /*
> +     * This is the name of the remote class that implements the  
> remote interface.
> +     *
> +     * This is only used if this adapter is going to directly invoke  
> an object.  For the
> +     * EJB Container, the adapter will pass through the method  
> invocations.
> +     */
> +    public String getRemoteClassName() {
> +        return _remoteClassName;
> +    }
> +
> +    public void setRemoteClassName(String rcName) {
> +        _remoteClassName = rcName;
> +    }
> +
> +    /*
> +     * The remote interface name for the remote object.  This will  
> most likely be the name
> +     * of the EJB's RemoteInterface and RemoteHomeInterface
> +     *
> +     * The stub/skel generator will use this interface name.
> +     */
> +    public String getRemoteInterfaceName() {
> +        return _remoteInterfaceName;
> +    }
> +
> +    public void setRemoteInterfaceName(String riName) {
> +        _remoteInterfaceName = riName;
> +    }
> +
> +    /*
> +     * A list of public IDs that the remote object implements:
> +     *
> +     * IDL:....:1.0
> +     * RMI:....:X:Y
> +     */
> +    public Vector getIds() {
> +        return _idVector;
> +    }
> +
> +    public void addId(String id) {
> +        _idVector.add(id);
> +    }
> +
> +    public void removeId(String id) {
> +        _idVector.remove(id);
> +    }
> +
> +    /*
> +     * Return the skeleton implemention for the remote interface.   
> This interface has the
> +     * invoke method to handle the rmi/iiop messages.
> +     */
> +    public RemoteInterface getRemoteInterface() {
> +        if (_ri == null) {
> +            synchronized (this) {
> +                String riName = _remoteInterfaceName + "_Skeleton";
> +                _remoteInterfaceClass = loadClass(riName);
> +
> +                try {
> +                    _ri = (RemoteInterface)  
> _remoteInterfaceClass.newInstance();
> +                } catch (InstantiationException e) {
> +                    e.printStackTrace();  //To change body of catch  
> statement use File | Settings | File Templates.
> +                } catch (IllegalAccessException e) {
> +                    e.printStackTrace();  //To change body of catch  
> statement use File | Settings | File Templates.
> +                }
> +            }
> +        }
> +
> +        return _ri;
> +    }

This is double check locking.  The whole method needs to be  
synchronized.

> +    /*
> +     * Get an object instance to invoke based on the object key.
> +     *
> +     * The objectKey could probably be passed to the EJB container so  
> that the
> +     * container can directly invoke the ejb object as required.
> +     */
> +    public Object getInstance(byte[] objectKey) {
> +        String key = new String(objectKey);
> +        return getInstance(key);
> +    }
> +
> +    public Object getInstance(String key) {
> +        Object o = _objects.get(key);
> +
> +        if (o == null) {
> +            o = newInstance(key);
> +        }
> +
> +        return o;
> +    }
> +
> +    public Object newInstance(byte[] objectKey) {
> +        String key = new String(objectKey);
> +        return newInstance(key);
> +    }
> +
> +    public Object newInstance(String key) {
> +        Object o = null;
> +
> +        if (_remoteClassClass == null) {
> +            synchronized (this) {
> +                _remoteClassClass = loadClass(_remoteClassName);
> +            }
> +
> +            try {
> +                if (_shared) {
> +                    synchronized (this) {
> +                        Method m =  
> _remoteClassClass.getMethod("getInstance", (Class[]) null);
> +                        o = m.invoke(_remoteClassClass, (Object[])  
> null);
> +
> +                        if (o != null) {
> +                            _objects.put(key, o);
> +                        }
> +                    }
> +                } else {
> +                    o = _remoteClassClass.newInstance();
> +                    _objects.put(key, o);
> +                }
> +            } catch (InstantiationException e) {
> +                e.printStackTrace();  //To change body of catch  
> statement use File | Settings | File Templates.
> +            } catch (IllegalAccessException e) {
> +                e.printStackTrace();  //To change body of catch  
> statement use File | Settings | File Templates.
> +            } catch (NoSuchMethodException e) {
> +                e.printStackTrace();
> +            } catch (InvocationTargetException e) {
> +                e.printStackTrace();
> +            }
> +        }
> +
> +        return o;
> +    }

Again there is double check locking.  Also, if this is called in the  
critical path, I suggest we use CGLIB instead of reflection for  
construction as it is way faster.

> +    /*
> +     * Invoke method from the IIOP Message Handler.  The adapter is  
> bound to the INS name service.
> +     * When an RMI/IIOP message is processed by the server, the  
> message handler will perform a lookup
> +     * on the name service to get the Adapter, then the invocation  
> will be passed to the adapter
> +     * The adapter will obtain the object key and then determine  
> which object instance to pass the
> +     * invocation to.
> +     */

This comment is missing the double star at the top to signify javadoc.

> +    public void invoke(java.lang.String methodName, byte[] objectKey,  
> org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input,  
> org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) {
> +        RemoteInterface skeleton = getRemoteInterface();
> +        Object instance = getInstance(objectKey);
> +
> +        if (instance != null) {
> +            skeleton.$invoke(methodName, objectKey, instance, input,  
> output);
> +        } else {
> +            throw new org.omg.CORBA.OBJECT_NOT_EXIST(new  
> String(objectKey));
> +        }
> +    }
> +
> +    /*
> +     * Helper function to load a class.  This uses classloader for  
> the adapter.
> +     */
> +    protected Class loadClass(String name) {
> +        Class c = null;
> +
> +        try {
> +            c = _cl.loadClass(name);
> +        } catch (Exception e) {
> +            e.printStackTrace();
> +        }
> +
> +        return c;
> +    }
> +}

I think we should be at least logging the error or actually letting the  
ClassNotFoundException through.  We also have a ClassLoading class  
which you may want to use as it handles some of the more weird class  
name formats.

> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> adapter/AdapterManager.java
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/adapter/AdapterManager.java? 
> view=auto&rev=126264
> ======================================================================= 
> =======
> --- (empty file)
> +++  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> adapter/AdapterManager.java	Sun Jan 23 23:33:10 2005
> @@ -0,0 +1,43 @@
> +/**
> + *
> + *  Copyright 2004-2005 The Apache Software Foundation
> + *
> + *  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.
> + */
> +package org.apache.geronimo.interop.adapter;
> +
> +import java.util.Hashtable;
> +
> +
> +public class AdapterManager {
> +    protected Hashtable _adapters;
> +    protected static AdapterManager _me = new AdapterManager();

Underscores and protected...

> +    protected AdapterManager() {
> +        _adapters = new Hashtable();
> +    }
> +
> +    public static AdapterManager getInstance() {
> +        return _me;
> +    }

This is a bad idea.  Instead we should have a manger gbean and the  
singletonness would be handled by there being only one GBean instance  
registered.

> +    public void registerAdapter(Adapter a) {
> +
> +        _adapters.put(a.getBindName(), a);
> +    }
> +
> +    public Adapter getAdapter(String objectName) {
> +        return (Adapter) _adapters.get(objectName);
> +    }

I prefer HashMap and synchronizing the methods that access the Map, but  
this works in this case.

> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> client/InitialContextFactory.java
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/client/InitialContextFactory.java? 
> view=auto&rev=126264
> ======================================================================= 
> =======
> +public class InitialContextFactory
> +        implements javax.naming.spi.InitialContextFactory {
> +    private HashMap _startMap = new HashMap();
> +
> +    public Context getInitialContext(java.util.Hashtable env) throws  
> NamingException {
> +        return  
> org.apache.geronimo.interop.rmi.iiop.client.ClientNamingContext.getInst 
> ance(env);
> +    }
> +}

Is the _startMap variable used anywhere?

> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> client/InitialContextFactoryBuilder.java
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/client/InitialContextFactoryBuilder.java? 
> view=auto&rev=126264
> ======================================================================= 
> =======
> +public class InitialContextFactoryBuilder
> +        implements javax.naming.spi.InitialContextFactoryBuilder {
> +    public javax.naming.spi.InitialContextFactory  
> createInitialContextFactory(Hashtable env) {
> +        return new InitialContextFactory();
> +    }
> +}

What is this for?  Just curious...

> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> generator/GenException.java
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/generator/GenException.java? 
> view=auto&rev=126264
> ======================================================================= 
> =======
> +/**
> + * User: Mark
> + * Date: Dec 21, 2004
> + * Time: 3:49:45 PM
> + */

Oops :)

> +public class GenException
> +        extends Exception {
> +    public GenException() {
> +        super();
> +    }
> +
> +    public GenException(String message) {
> +        super(message);
> +    }
> +
> +    public GenException(Throwable cause) {
> +        super(cause);
> +    }
> +
> +    public GenException(String message, Throwable cause) {
> +        super(message, cause);
> +    }
> +}
>
> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> generator/GenOptions.java
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/generator/GenOptions.java? 
> view=auto&rev=126264
> ======================================================================= 
> =======
> +public class GenOptions {
> +    protected String _genDir = "./";
> +    protected boolean _overwrite = false;
> +    protected boolean _verbose = false;
> +
> +    public GenOptions() {
> +    }
> +
> +    public GenOptions(String genDir, boolean overwrite, boolean  
> verbose) {
> +        _genDir = genDir;
> +        _overwrite = overwrite;
> +        _verbose = verbose;
> +    }
> +
> +    public String getGenDir() {
> +        return _genDir;
> +    }
> +
> +    public void setGenDir(String genDir) {
> +        _genDir = genDir;
> +    }
> +
> +    public boolean isOverwrite() {
> +        return _overwrite;
> +    }
> +
> +    public void setOverwrite(boolean overwrite) {
> +        _overwrite = overwrite;
> +    }
> +
> +    public boolean isVerbose() {
> +        return _verbose;
> +    }
> +
> +    public void setVerbose(boolean verbose) {
> +        _verbose = verbose;
> +    }
> +
> +}

Do we need both the constructor args and the setters?  If I set a  
variable is whatever is using this class going to adapt to the recently  
changed variable?

> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> naming/NameService.java
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/naming/NameService.java? 
> view=auto&rev=126264
> ======================================================================= 
> =======
> --- (empty file)
> +++  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> naming/NameService.java	Sun Jan 23 23:33:10 2005
> @@ -0,0 +1,66 @@
> +/**
> + *
> + *  Copyright 2004-2005 The Apache Software Foundation
> + *
> + *  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.
> + */
> +package org.apache.geronimo.interop.naming;
> +
> +import java.util.HashMap;
> +import javax.naming.NamingException;
> +
> +import org.apache.geronimo.interop.adapter.Adapter;
> +
> +
> +public class NameService {
> +    protected static NameService _ns = null;

protected and underscore

> +    public static NameService getInstance() {
> +        if (_ns == null) {
> +            synchronized (NameService.class) {
> +                if (_ns == null) {
> +                    _ns = new NameService();
> +                    _ns.init();
> +                }
> +            }
> +        }
> +
> +        return _ns;
> +    }

Double check locking

> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> naming/NamingContext.java
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/naming/NamingContext.java? 
> view=auto&rev=126264
> ======================================================================= 
> =======
> --- (empty file)
> +++  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> naming/NamingContext.java	Sun Jan 23 23:33:10 2005
> @@ -0,0 +1,150 @@
> +/**
> + *
> + *  Copyright 2004-2005 The Apache Software Foundation
> + *
> + *  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.
> + */
> +package org.apache.geronimo.interop.naming;
> +
> +import java.util.HashMap;
> +import javax.naming.NameNotFoundException;
> +import javax.naming.NamingException;
> +
> +import org.apache.geronimo.interop.adapter.Adapter;
> +
> +
> +public class NamingContext {
> +    public static final NamingContext getInstance(Class baseClass) {
> +        NamingContext context;
> +        synchronized (_contextMap) {
> +            context = (NamingContext) _contextMap.get(baseClass);
> +            if (context == null) {
> +                context = new NamingContext();
> +                _contextMap.put(baseClass, context);
> +                context.init(baseClass);
> +            }
> +        }
> +        return context;
> +    }
> +
> +    private static ThreadLocal _current = new ThreadLocal();

Should this be an InheritableThreadLocal?

> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> properties/BooleanProperty.java
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/properties/BooleanProperty.java? 
> view=auto&rev=126264
>
> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> properties/ByteProperty.java
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/properties/ByteProperty.java? 
> view=auto&rev=126264
>
> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> properties/DoubleProperty.java
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/properties/DoubleProperty.java? 
> view=auto&rev=126264
>
> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> properties/FloatProperty.java
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/properties/FloatProperty.java? 
> view=auto&rev=126264
>
> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> properties/IntProperty.java
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/properties/IntProperty.java? 
> view=auto&rev=126264
>
> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> properties/LongProperty.java
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/properties/LongProperty.java? 
> view=auto&rev=126264
>
> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> properties/ShortProperty.java
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/properties/ShortProperty.java? 
> view=auto&rev=126264
>
> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> properties/StringProperty.java
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/properties/StringProperty.java? 
> view=auto&rev=126264

How are these used?

> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> properties/SystemProperties.java
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/properties/SystemProperties.java? 
> view=auto&rev=126264

Is this a bridge to java.lang.System properties?  If so, do we really  
want to support system properties?

> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> repository/Repository.java
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/repository/Repository.java? 
> view=auto&rev=126264
> ======================================================================= 
> =======
> +public class Repository {
> +    // ??
> +}

Say what? :)

> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> rmi/iiop/IiopVersion.java
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/rmi/iiop/IiopVersion.java? 
> view=auto&rev=126264
> ======================================================================= 
> =======
> +public class IiopVersion {
> +}

What's this for?

> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> rmi/iiop/ListenerInfo.java
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/rmi/iiop/ListenerInfo.java? 
> view=auto&rev=126264
> +public class ListenerInfo {
> +    public int protocol;
> +
> +    public String host;
> +
> +    public int port;
> +}

Do these have to be public fields?  Normally we use, private fields  
with getters and setters.

> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> rmi/iiop/NameServiceOperations_Skeleton.java
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/rmi/iiop/ 
> NameServiceOperations_Skeleton.java?view=auto&rev=126264

Do we want the Skeletons checked in?

> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> rmi/iiop/ObjectKey.java
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/rmi/iiop/ObjectKey.java? 
> view=auto&rev=126264
> ======================================================================= 
> =======
> +public class ObjectKey {
> +    public static final int TYPE_MANAGER = 'M';
> +
> +    public static final int TYPE_SESSION = 'S';
> +
> +    public int type;
> +    public String username = "";
> +    public String password = "";
> +    public String component = "";
> +    public String sessionID = "";

public fields?

> +    public void checkPassword() {
> +        User.getInstance(username).login(password);
> +    }

Shouldn't this go though Geronimo security?

> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> rmi/iiop/ObjectRef.java
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/rmi/iiop/ObjectRef.java? 
> view=auto&rev=126264
> ======================================================================= 
> =======
> +    public int $getIiopVersion() {
> +        return _iiopVersion;
> +    }

Why do all the methods in this class start with a dollar sign?

> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> rmi/iiop/client/ClientNamingContext.java
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/rmi/iiop/client/ClientNamingContext.java? 
> view=auto&rev=126264

We should consider merging this with the Geronimo naming stuff... not a  
task for today, but (much) later on :)

> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> rmi/iiop/compiler/StubCompiler.txt
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/rmi/iiop/compiler/StubCompiler.txt? 
> view=auto&rev=126264

Why is this a text file?

> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> rmi/iiop/server/SocketListener.java
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/rmi/iiop/server/SocketListener.java? 
> view=auto&rev=126264
> ======================================================================= 
> =======
> +public class SocketListener extends Thread {
> +    public static SocketListener getInstance() {
> +        return new SocketListener();
> +    }

Why is there a static factory?

> +    // private data
> +
> +    private String _name;
> +
> +    private String _host;
> +
> +    private int _port;
> +
> +    private int _listenBacklog;
> +
> +    private java.net.ServerSocket _listener;
> +
> +    // internal methods
> +
> +    protected void init() {
> +        _host = "localhost";
> +        _port = 2000;
> +        _listenBacklog = 10;
> +        setDaemon(true);
> +    }
> +
> +    // public methods
> +
> +    public void setHost(String host) {
> +        _host = host;
> +    }
> +
> +    public void setPort(int port) {
> +        _port = port;
> +    }
> +
> +    public void setListenBacklog(int backlog) {
> +        _listenBacklog = backlog;
> +    }
> +
> +    public void run() {
> +        String iiopURL = "iiop://" + _host + ":" + _port;
> +        ListenerInfo listenerInfo = new ListenerInfo();
> +        listenerInfo.protocol = Protocol.IIOP; // TODO: other  
> protocols (IIOPS etc.)
> +        listenerInfo.host = _host;
> +        listenerInfo.port = _port;
> +        try {
> +            InetAddress addr = InetAddress.getByName(_host);
> +            _listener = new java.net.ServerSocket(_port,  
> _listenBacklog, addr);
> +        } catch (Exception ex) {
> +            System.out.println("SocketListener: Error creating server  
> socket.");
> +            ex.printStackTrace();
> +            try {
> +                Socket socket = new Socket(_host, _port);
> +                socket.close();
> +                System.out.println("SocketListener: Error server  
> already running: " + iiopURL);
> +                ex.printStackTrace();
> +            } catch (Exception ignore) {
> +            }
> +            return;
> +        }
> +        new CheckConnect().start();
> +        for (; ;) {
> +            java.net.Socket socket;
> +            try {
> +                socket = _listener.accept();
> +            } catch (Exception ex) {
> +                throw new SystemException(ex); // TODO: log error  
> message
> +            }
> +            MessageHandler.getInstance(listenerInfo, socket).start();
> +        }
> +    }
> +
> +    private class CheckConnect extends Thread {
> +        public void run() {
> +            try {
> +                Socket socket = new Socket(_host, _port);
> +                socket.close();
> +                if (!SystemProperties.quiet()) {
> +                     
> System.out.println(formatAcceptingIiopConnections());
> +                }
> +            } catch (Exception ex) {
> +                warnConnectFailed(_host, _port);
> +            }
> +        }
> +    }
> +
> +    // format methods
> +
> +    protected String formatAcceptingIiopConnections() {
> +        String msg = "SocketListener.formatAcceptingIiopConnection():  
> ";
> +        return msg;
> +    }
> +
> +    // log methods
> +
> +    protected void warnConnectFailed(String host, int port) {
> +        System.out.println("SocketListener.warnConnectFailed(): host  
> = " + host + ", port = " + port);
> +    }
> +}

I suggest, you either require all state data such as host and port be  
passed in via the constructor, or make the setters throw an "already  
running" exception.  Otherwise people mistakenly think the can change  
the port.

> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> security/Role.java
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/security/Role.java?view=auto&rev=126264
>
> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> security/SimpleSubject.java
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/security/SimpleSubject.java? 
> view=auto&rev=126264
>
> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> security/User.java
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/security/User.java?view=auto&rev=126264

What is the plan for these with regards to the Geronimo security module?

> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> util/SystemUtil.java
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/util/SystemUtil.java?view=auto&rev=126264
> ======================================================================= 
> =======
> +public class SystemUtil {
> +    // properties
> +
> +    public static final StringProperty vmVersionProperty =
> +            new StringProperty(SystemProperties.class,  
> "java.vm.version");
> +
> +    // private data
> +
> +    private static String _vmVersion = vmVersionProperty.getString();
> +
> +    private static boolean _isJDK13 = _vmVersion.startsWith("1.3")
> +                                      ||  
> _vmVersion.startsWith("CrE-ME V4.00");
> +
> +    private static boolean _isJDK14 = _vmVersion.startsWith("1.4");
> +
> +    // public methods
> +
> +    public static String getExecutableSuffix() {
> +        return isWindows() ? ".exe" : "";
> +    }
> +
> +    public static String getShellScriptSuffix() {
> +        return isWindows() ? ".bat" : ".sh";
> +    }
> +
> +    public static boolean isJDK13() {
> +        return _isJDK13;
> +    }
> +
> +    public static boolean isJDK14() {
> +        return _isJDK14;
> +    }
> +
> +    public static boolean isWindows() {
> +        return java.io.File.separatorChar == '\\';
> +    }
> +}

How is this used?

> Added:  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> util/ThreadContext.java
> Url:  
> http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/ 
> org/apache/geronimo/interop/util/ThreadContext.java? 
> view=auto&rev=126264
> ======================================================================= 
> =======
> --- (empty file)
> +++  
> geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/ 
> util/ThreadContext.java	Sun Jan 23 23:33:10 2005
> @@ -0,0 +1,135 @@
> +/**
> + *
> + *  Copyright 2004-2005 The Apache Software Foundation
> + *
> + *  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.
> + */
> +package org.apache.geronimo.interop.util;
> +
> +import java.util.HashMap;
> +
> +import org.apache.geronimo.interop.SystemException;
> +
> +
> +public abstract class ThreadContext {
> +    private static HashMap _primTypes;
> +
> +    private static ThreadLocal _defaultRmiHost = new ThreadLocal();
> +
> +    private static ThreadLocal _defaultRmiPort = new ThreadLocal();
> +
> +    static {
> +        _primTypes = new HashMap();
> +        _primTypes.put("boolean", boolean.class);
> +        _primTypes.put("char", char.class);
> +        _primTypes.put("byte", byte.class);
> +        _primTypes.put("short", short.class);
> +        _primTypes.put("int", int.class);
> +        _primTypes.put("long", long.class);
> +        _primTypes.put("float", float.class);
> +        _primTypes.put("double", double.class);
> +        _primTypes.put("boolean[]", boolean[].class);
> +        _primTypes.put("char[]", char[].class);
> +        _primTypes.put("byte[]", byte[].class);
> +        _primTypes.put("short[]", short[].class);
> +        _primTypes.put("int[]", int[].class);
> +        _primTypes.put("long[]", long[].class);
> +        _primTypes.put("float[]", float[].class);
> +        _primTypes.put("double[]", double[].class);
> +    }
> +
> +    public static String getDefaultRmiHost() {
> +        String host = (String) _defaultRmiHost.get();
> +        if (host == null) {
> +            host = "0";
> +        }
> +        return host;
> +    }
> +
> +    public static int getDefaultRmiPort() {
> +        Integer port = (Integer) _defaultRmiPort.get();
> +        if (port == null) {
> +            port = IntegerCache.get(0);
> +        }
> +        return port.intValue();
> +    }
> +
> +    public static Class loadClass(String className) {
> +        Class t = (Class) _primTypes.get(className);
> +        if (t != null) {
> +            return t;
> +        }
> +        try {
> +            ClassLoader loader =  
> Thread.currentThread().getContextClassLoader();
> +            if (loader == null) {
> +                return Class.forName(className);
> +            } else {
> +                return loader.loadClass(className);
> +            }
> +        } catch (RuntimeException ex) {
> +            throw (RuntimeException) ex;
> +        } catch (Exception ex) {
> +            throw new SystemException(ex);
> +        }
> +    }

This is unlikely to work in Geronimo as we almost never set context  
class loader.  Normally we try to explicitly pass around the  
classloader.

> +
> +    public static Class loadClass(String className, Class  
> parentClass) {
> +        if (parentClass == null) {
> +            return loadClass(className);
> +        }
> +        Class t = (Class) _primTypes.get(className);
> +        if (t != null) {
> +            return t;
> +        }
> +        try {
> +            ClassLoader loader = parentClass.getClassLoader();
> +            if (loader == null) {
> +                return loadClass(className);
> +            } else {
> +                return loader.loadClass(className);
> +            }
> +        } catch (RuntimeException ex) {
> +            throw (RuntimeException) ex;
> +        } catch (Exception ex) {
> +            throw new SystemException(ex);
> +        }
> +    }
> +
> +    public static Class loadClassOrReturnNullIfNotFound(String  
> className) {
> +        try {
> +            return loadClass(className);
> +        } catch (RuntimeException ex) {
> +            return null;
> +        }
> +    }
> +
> +    public static Class loadClassOrReturnNullIfNotFound(String  
> className, Class parentClass) {
> +        if (parentClass == null) {
> +            return loadClassOrReturnNullIfNotFound(className);
> +        }
> +        try {
> +            return loadClass(className, parentClass);
> +        } catch (RuntimeException ex) {
> +            return null;
> +        }
> +    }

Most of this class loader stuff is handled by the class ClassLoading  
which handles some of the more weird stuff.