summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAudrius Meskauskas <audriusa@Bioinformatics.org>2005-05-15 01:09:29 +0000
committerAudrius Meskauskas <audriusa@Bioinformatics.org>2005-05-15 01:09:29 +0000
commit9d73465b2160dbf3c3f3e514898ae1998307f49a (patch)
tree5c4cb0294394665245b5e49311c61d529dd1c05f
parent3fd2cc47b58f0a8a34f65074dd23680074c7a45b (diff)
downloadclasspath-9d73465b2160dbf3c3f3e514898ae1998307f49a.tar.gz
Contributing the working CORBA prototype.
2005-05-15 Audrius Meskauskas, Lithuania <AudriusA@Bioinformatics.org> * gnu/CORBA/Version.java, gnu/CORBA/IOR.java, gnu/CORBA/IOR_contructed_object.java, gnu/CORBA/Restricted_ORB.java, gnu/CORBA/Functional_ORB.java, gnu/CORBA/gnuAny.java, gnu/CORBA/gnuContext.java, gnu/CORBA/gnuContextList.java, gnu/CORBA/gnuEnvironment.java, gnu/CORBA/gnuExceptionList.java, gnu/CORBA/gnuRequest.java, gnu/CORBA/gnuNVList.java, gnu/CORBA/gnuNamedValue.java, gnu/CORBA/Simple_delegate.java, gnu/CORBA/BigDecimalHelper.java, gnu/CORBA/Unexpected.java, gnu/CORBA/OctetHolder.java, gnu/CORBA/TypeCodeHelper.java, gnu/CORBA/corbaArrayList.java, gnu/CORBA/WCharHolder.java, gnu/CORBA/WStringHolder.java, gnu/CORBA/IOR_Delegate.java, gnu/CORBA/fixedTypeCode.java, gnu/CORBA/generalTypeCode.java, gnu/CORBA/holderFactory.java, gnu/CORBA/recordTypeCode.java, gnu/CORBA/recursiveTypeCode.java, gnu/CORBA/stringTypeCode.java, gnu/CORBA/Connected_objects.java, gnu/CORBA/ByteArrayComparator.java, gnu/CORBA/binaryReply.java, gnu/CORBA/typeNamer.java, gnu/CORBA/streamRequest.java, gnu/CORBA/stubFinder.java, gnu/CORBA/bufferedResponseHandler.java, gnu/CORBA/ExceptionCreator.java, gnu/CORBA/ObjectCreator.java, gnu/CORBA/aliasTypeCode.java: New files. * gnu/CORBA/NamingService/snConverter.java, gnu/CORBA/NamingService/Ext.java, gnu/CORBA/NamingService/cmpNameComponent.java, gnu/CORBA/NamingService/TransientContext.java, gnu/CORBA/NamingService/NamingMap.java, gnu/CORBA/NamingService/Binding_iterator_impl.java, gnu/CORBA/NamingService/NamingServiceTransient.java, gnu/CORBA/NamingService/NameValidator.java: New files. * gnu/CORBA/CDR/aligningInputStream.java, gnu/CORBA/CDR/aligningOutputStream.java, gnu/CORBA/CDR/cdrOutput.java, gnu/CORBA/CDR/cdrInput.java, gnu/CORBA/CDR/cdrBufOutput.java, gnu/CORBA/CDR/encapsulatedOutput.java, gnu/CORBA/CDR/cdrBufInput.java, gnu/CORBA/CDR/testBinaryIO.java: New files. * org/omg/CORBA/StringHolder.java, * org/omg/CORBA/StringSeqHelper.java, * org/omg/CORBA/StringSeqHolder.java: Read and write string, not wstring and use stringTypeCode. * org/omg/CORBA/Any.java: Adding serialVersionUID. * org/omg/CORBA/FixedHolder: Use fixedTypeCode. * org/omg/CORBA/UNKNOWN.java: Making constructors public. * org/omg/CORBA/UserException.java: Inherit from org.omg.CORBA.portable.IDLEntity. * org/omg/CORBA/ORB.java, org/omg/CORBA/Object.java: Replacing empty class declarations with implementation. * gnu/CORBA/primitiveTypeCode.java: Exception fixes. * gnu/CORBA/primitiveArrayTypeCode.java: Adding extra parameter in constructor. * gnu/CORBA/GIOP/CancelHeader.java, gnu/CORBA/GIOP/ErrorMessage.java, gnu/CORBA/GIOP/MessageHeader.java, gnu/CORBA/GIOP/ReplyHeader.java, gnu/CORBA/GIOP/RequestHeader.java, gnu/CORBA/GIOP/ServiceContext.java, gnu/CORBA/GIOP/cxCodeSet.java, gnu/CORBA/GIOP/CharSets_OSF.java, gnu/CORBA/GIOP/v1_0/CancelHeader.java, gnu/CORBA/GIOP/v1_0/RequestHeader.java, gnu/CORBA/GIOP/v1_0/ReplyHeader.java, gnu/CORBA/GIOP/v1_2/RequestHeader.java, gnu/CORBA/GIOP/v1_2/ReplyHeader.java: New files. org/omg/CosNaming/_NamingContextStub.java, org/omg/CosNaming/_NamingContextImplBase.java, org/omg/CosNaming/BindingHelper.java, org/omg/CosNaming/BindingListHelper.java, org/omg/CosNaming/NameComponentHelper.java, org/omg/CosNaming/NameHelper.java, org/omg/CosNaming/BindingTypeHelper.java, org/omg/CosNaming/NamingContextHelper.java, org/omg/CosNaming/BindingIteratorHelper.java, org/omg/CosNaming/_NamingContextExtStub.java, org/omg/CosNaming/NamingContextExt.java, org/omg/CosNaming/NamingContextExtHelper.java, org/omg/CosNaming/NamingContextExtHolder.java, org/omg/CosNaming/NamingContextExtOperations.java, org/omg/CosNaming/_NamingContextExtImplBase.java, org/omg/CosNaming/NamingContextOperations.java, org/omg/CosNaming/NamingContext.java, org/omg/CosNaming/NameComponent.java, org/omg/CosNaming/BindingIterator.java, org/omg/CosNaming/_BindingIteratorStub.java, org/omg/CosNaming/Binding.java, org/omg/CosNaming/BindingType.java, org/omg/CosNaming/BindingIteratorHolder.java, org/omg/CosNaming/BindingListHolder.java, org/omg/CosNaming/BindingHolder.java, org/omg/CosNaming/BindingTypeHolder.java, org/omg/CosNaming/NameComponentHolder.java, org/omg/CosNaming/NameHolder.java, org/omg/CosNaming/NamingContextHolder.java, org/omg/CosNaming/_BindingIteratorImplBase.java, org/omg/CosNaming/package.html, org/omg/CosNaming/NamingContextExtPackage/InvalidAddress.java, org/omg/CosNaming/NamingContextExtPackage/InvalidAddressHolder.java, org/omg/CosNaming/NamingContextExtPackage/package.html, org/omg/CosNaming/NamingContextExtPackage/AddressHelper.java, org/omg/CosNaming/NamingContextExtPackage/URLStringHelper.java, org/omg/CosNaming/NamingContextExtPackage/StringNameHelper.java, org/omg/CosNaming/NamingContextExtPackage/InvalidAddressHelper.java, org/omg/CosNaming/NamingContextPackage/NotEmpty.java, org/omg/CosNaming/NamingContextPackage/NotFound.java, org/omg/CosNaming/NamingContextPackage/NotFoundReason.java, org/omg/CosNaming/NamingContextPackage/NotFoundReasonHolder.java, org/omg/CosNaming/NamingContextPackage/NotFoundHolder.java, org/omg/CosNaming/NamingContextPackage/NotEmptyHolder.java, org/omg/CosNaming/NamingContextPackage/AlreadyBoundHolder.java, org/omg/CosNaming/NamingContextPackage/CannotProceedHolder.java, org/omg/CosNaming/NamingContextPackage/InvalidNameHolder.java, org/omg/CosNaming/NamingContextPackage/CannotProceed.java, org/omg/CosNaming/NamingContextPackage/InvalidName.java, org/omg/CosNaming/NamingContextPackage/AlreadyBound.java, org/omg/CosNaming/NamingContextPackage/NotFoundHelper.java, org/omg/CosNaming/NamingContextPackage/NotEmptyHelper.java, org/omg/CosNaming/NamingContextPackage/AlreadyBoundHelper.java, org/omg/CosNaming/NamingContextPackage/InvalidNameHelper.java, org/omg/CosNaming/NamingContextPackage/NotFoundReasonHelper.java, org/omg/CosNaming/NamingContextPackage/CannotProceedHelper.java, org/omg/CosNaming/NamingContextPackage/package.html: New files. * examples/gnu/classpath/examples/CORBA/NamingService/Demo.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/Demo.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/comServer.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThisHelper.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThisHolder.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThis.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThis.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThisHelper.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThisHolder.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DirectTest.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/RequestTest.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/comServant.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserException.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/node.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/nodeHelper.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/nodeHolder.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_comTesterStub.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserExceptionHelper.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_comTesterImplBase.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/comTester.java: New files.
-rw-r--r--ChangeLog163
-rw-r--r--gnu/CORBA/BigDecimalHelper.java193
-rw-r--r--gnu/CORBA/ByteArrayComparator.java91
-rw-r--r--gnu/CORBA/CDR/aligningInputStream.java112
-rw-r--r--gnu/CORBA/CDR/aligningOutputStream.java119
-rw-r--r--gnu/CORBA/CDR/cdrBufInput.java115
-rw-r--r--gnu/CORBA/CDR/cdrBufOutput.java115
-rw-r--r--gnu/CORBA/CDR/cdrInput.java1129
-rw-r--r--gnu/CORBA/CDR/cdrOutput.java926
-rw-r--r--gnu/CORBA/CDR/encapsulatedOutput.java138
-rw-r--r--gnu/CORBA/CDR/testBinaryIO.java90
-rw-r--r--gnu/CORBA/Connected_objects.java159
-rw-r--r--gnu/CORBA/ExceptionCreator.java248
-rw-r--r--gnu/CORBA/Functional_ORB.java882
-rw-r--r--gnu/CORBA/GIOP/CancelHeader.java70
-rw-r--r--gnu/CORBA/GIOP/CharSets_OSF.java235
-rw-r--r--gnu/CORBA/GIOP/ErrorMessage.java95
-rw-r--r--gnu/CORBA/GIOP/MessageHeader.java316
-rw-r--r--gnu/CORBA/GIOP/ReplyHeader.java156
-rw-r--r--gnu/CORBA/GIOP/RequestHeader.java161
-rw-r--r--gnu/CORBA/GIOP/ServiceContext.java131
-rw-r--r--gnu/CORBA/GIOP/cxCodeSet.java222
-rw-r--r--gnu/CORBA/GIOP/v1_0/CancelHeader.java72
-rw-r--r--gnu/CORBA/GIOP/v1_0/ReplyHeader.java139
-rw-r--r--gnu/CORBA/GIOP/v1_0/RequestHeader.java157
-rw-r--r--gnu/CORBA/GIOP/v1_2/ReplyHeader.java118
-rw-r--r--gnu/CORBA/GIOP/v1_2/RequestHeader.java211
-rw-r--r--gnu/CORBA/IOR.java529
-rw-r--r--gnu/CORBA/IOR_Delegate.java282
-rw-r--r--gnu/CORBA/IOR_contructed_object.java100
-rw-r--r--gnu/CORBA/NamingService/Binding_iterator_impl.java139
-rw-r--r--gnu/CORBA/NamingService/Ext.java230
-rw-r--r--gnu/CORBA/NamingService/NameValidator.java79
-rw-r--r--gnu/CORBA/NamingService/NamingMap.java187
-rw-r--r--gnu/CORBA/NamingService/NamingServiceTransient.java159
-rw-r--r--gnu/CORBA/NamingService/TransientContext.java416
-rw-r--r--gnu/CORBA/NamingService/cmpNameComponent.java98
-rw-r--r--gnu/CORBA/NamingService/snConverter.java328
-rw-r--r--gnu/CORBA/ObjectCreator.java267
-rw-r--r--gnu/CORBA/OctetHolder.java129
-rw-r--r--gnu/CORBA/Restricted_ORB.java368
-rw-r--r--gnu/CORBA/Simple_delegate.java250
-rw-r--r--gnu/CORBA/TypeCodeHelper.java297
-rw-r--r--gnu/CORBA/Unexpected.java128
-rw-r--r--gnu/CORBA/Version.java206
-rw-r--r--gnu/CORBA/WCharHolder.java126
-rw-r--r--gnu/CORBA/WStringHolder.java129
-rw-r--r--gnu/CORBA/aliasTypeCode.java142
-rw-r--r--gnu/CORBA/binaryReply.java94
-rw-r--r--gnu/CORBA/bufferedResponseHandler.java187
-rw-r--r--gnu/CORBA/corbaArrayList.java115
-rw-r--r--gnu/CORBA/fixedTypeCode.java149
-rw-r--r--gnu/CORBA/generalTypeCode.java243
-rw-r--r--gnu/CORBA/gnuAny.java788
-rw-r--r--gnu/CORBA/gnuContext.java202
-rw-r--r--gnu/CORBA/gnuContextList.java83
-rw-r--r--gnu/CORBA/gnuEnvironment.java72
-rw-r--r--gnu/CORBA/gnuExceptionList.java84
-rw-r--r--gnu/CORBA/gnuNVList.java127
-rw-r--r--gnu/CORBA/gnuNamedValue.java112
-rw-r--r--gnu/CORBA/gnuRequest.java893
-rw-r--r--gnu/CORBA/holderFactory.java184
-rw-r--r--gnu/CORBA/primitiveArrayTypeCode.java21
-rw-r--r--gnu/CORBA/primitiveTypeCode.java60
-rw-r--r--gnu/CORBA/recordTypeCode.java245
-rw-r--r--gnu/CORBA/recursiveTypeCode.java78
-rw-r--r--gnu/CORBA/streamRequest.java60
-rw-r--r--gnu/CORBA/stringTypeCode.java83
-rw-r--r--gnu/CORBA/stubFinder.java110
-rw-r--r--gnu/CORBA/typeNamer.java171
-rw-r--r--org/omg/CORBA/Any.java8
-rw-r--r--org/omg/CORBA/DomainManager.java57
-rw-r--r--org/omg/CORBA/DomainManagerOperations.java59
-rw-r--r--org/omg/CORBA/FixedHolder.java13
-rw-r--r--org/omg/CORBA/ORB.java693
-rw-r--r--org/omg/CORBA/Object.java151
-rw-r--r--org/omg/CORBA/ObjectHelper.java113
-rw-r--r--org/omg/CORBA/ObjectHolder.java127
-rw-r--r--org/omg/CORBA/Policy.java55
-rw-r--r--org/omg/CORBA/PolicyOperations.java70
-rw-r--r--org/omg/CORBA/SetOverrideType.java136
-rw-r--r--org/omg/CORBA/StringHolder.java13
-rw-r--r--org/omg/CORBA/StringSeqHelper.java4
-rwxr-xr-xorg/omg/CORBA/StringSeqHolder.java4
-rw-r--r--org/omg/CORBA/TestContextList.java50
-rw-r--r--org/omg/CORBA/UNKNOWN.java8
-rw-r--r--org/omg/CORBA/UserException.java10
-rw-r--r--org/omg/CORBA/package.html61
-rw-r--r--org/omg/CORBA/portable/ApplicationException.java91
-rw-r--r--org/omg/CORBA/portable/ApplicationException.jbx6
-rw-r--r--org/omg/CORBA/portable/Delegate.java433
-rw-r--r--org/omg/CORBA/portable/IndirectionException.java77
-rw-r--r--org/omg/CORBA/portable/InvokeHandler.java66
-rw-r--r--org/omg/CORBA/portable/ObjectImpl.java414
-rw-r--r--org/omg/CORBA/portable/RemarshalException.java54
-rw-r--r--org/omg/CORBA/portable/ResponseHandler.java58
-rw-r--r--org/omg/CORBA/portable/ServantObject.java61
-rw-r--r--org/omg/CORBA/portable/UnknownException.java76
-rw-r--r--org/omg/CORBA/portable/package.html50
-rw-r--r--org/omg/CosNaming/Binding.java81
-rw-r--r--org/omg/CosNaming/BindingHelper.java138
-rw-r--r--org/omg/CosNaming/BindingHolder.java94
-rw-r--r--org/omg/CosNaming/BindingIterator.java76
-rw-r--r--org/omg/CosNaming/BindingIteratorHelper.java148
-rw-r--r--org/omg/CosNaming/BindingIteratorHolder.java97
-rw-r--r--org/omg/CosNaming/BindingListHelper.java132
-rw-r--r--org/omg/CosNaming/BindingListHolder.java97
-rw-r--r--org/omg/CosNaming/BindingType.java124
-rw-r--r--org/omg/CosNaming/BindingTypeHelper.java122
-rw-r--r--org/omg/CosNaming/BindingTypeHolder.java93
-rw-r--r--org/omg/CosNaming/NameComponent.java113
-rw-r--r--org/omg/CosNaming/NameComponentHelper.java140
-rw-r--r--org/omg/CosNaming/NameComponentHolder.java97
-rw-r--r--org/omg/CosNaming/NameHelper.java135
-rw-r--r--org/omg/CosNaming/NameHolder.java99
-rw-r--r--org/omg/CosNaming/NamingContext.java177
-rw-r--r--org/omg/CosNaming/NamingContextExt.java55
-rw-r--r--org/omg/CosNaming/NamingContextExtHelper.java152
-rw-r--r--org/omg/CosNaming/NamingContextExtHolder.java97
-rw-r--r--org/omg/CosNaming/NamingContextExtOperations.java97
-rw-r--r--org/omg/CosNaming/NamingContextExtPackage/AddressHelper.java119
-rw-r--r--org/omg/CosNaming/NamingContextExtPackage/InvalidAddress.java53
-rw-r--r--org/omg/CosNaming/NamingContextExtPackage/InvalidAddressHelper.java122
-rw-r--r--org/omg/CosNaming/NamingContextExtPackage/InvalidAddressHolder.java97
-rw-r--r--org/omg/CosNaming/NamingContextExtPackage/StringNameHelper.java120
-rw-r--r--org/omg/CosNaming/NamingContextExtPackage/URLStringHelper.java119
-rw-r--r--org/omg/CosNaming/NamingContextExtPackage/package.html47
-rw-r--r--org/omg/CosNaming/NamingContextHelper.java157
-rw-r--r--org/omg/CosNaming/NamingContextHolder.java97
-rw-r--r--org/omg/CosNaming/NamingContextOperations.java176
-rw-r--r--org/omg/CosNaming/NamingContextPackage/AlreadyBound.java70
-rw-r--r--org/omg/CosNaming/NamingContextPackage/AlreadyBoundHelper.java128
-rw-r--r--org/omg/CosNaming/NamingContextPackage/AlreadyBoundHolder.java97
-rw-r--r--org/omg/CosNaming/NamingContextPackage/CannotProceed.java82
-rw-r--r--org/omg/CosNaming/NamingContextPackage/CannotProceedHelper.java147
-rw-r--r--org/omg/CosNaming/NamingContextPackage/CannotProceedHolder.java97
-rw-r--r--org/omg/CosNaming/NamingContextPackage/InvalidName.java71
-rw-r--r--org/omg/CosNaming/NamingContextPackage/InvalidNameHelper.java133
-rw-r--r--org/omg/CosNaming/NamingContextPackage/InvalidNameHolder.java97
-rw-r--r--org/omg/CosNaming/NamingContextPackage/NotEmpty.java53
-rw-r--r--org/omg/CosNaming/NamingContextPackage/NotEmptyHelper.java128
-rw-r--r--org/omg/CosNaming/NamingContextPackage/NotEmptyHolder.java97
-rw-r--r--org/omg/CosNaming/NamingContextPackage/NotFound.java81
-rw-r--r--org/omg/CosNaming/NamingContextPackage/NotFoundHelper.java145
-rw-r--r--org/omg/CosNaming/NamingContextPackage/NotFoundHolder.java97
-rw-r--r--org/omg/CosNaming/NamingContextPackage/NotFoundReason.java129
-rw-r--r--org/omg/CosNaming/NamingContextPackage/NotFoundReasonHelper.java128
-rw-r--r--org/omg/CosNaming/NamingContextPackage/NotFoundReasonHolder.java98
-rw-r--r--org/omg/CosNaming/NamingContextPackage/package.html46
-rw-r--r--org/omg/CosNaming/_BindingIteratorImplBase.java113
-rw-r--r--org/omg/CosNaming/_BindingIteratorStub.java198
-rw-r--r--org/omg/CosNaming/_NamingContextExtImplBase.java195
-rw-r--r--org/omg/CosNaming/_NamingContextExtStub.java205
-rw-r--r--org/omg/CosNaming/_NamingContextImplBase.java368
-rw-r--r--org/omg/CosNaming/_NamingContextStub.java446
-rw-r--r--org/omg/CosNaming/package.html50
156 files changed, 25236 insertions, 65 deletions
diff --git a/ChangeLog b/ChangeLog
index fe2c3a979..033541533 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,166 @@
+2005-05-15 Audrius Meskauskas, Lithuania <AudriusA@Bioinformatics.org>
+
+ * gnu/CORBA/Version.java,
+ gnu/CORBA/IOR.java,
+ gnu/CORBA/IOR_contructed_object.java,
+ gnu/CORBA/Restricted_ORB.java,
+ gnu/CORBA/Functional_ORB.java,
+ gnu/CORBA/gnuAny.java,
+ gnu/CORBA/gnuContext.java,
+ gnu/CORBA/gnuContextList.java,
+ gnu/CORBA/gnuEnvironment.java,
+ gnu/CORBA/gnuExceptionList.java,
+ gnu/CORBA/gnuRequest.java,
+ gnu/CORBA/gnuNVList.java,
+ gnu/CORBA/gnuNamedValue.java,
+ gnu/CORBA/Simple_delegate.java,
+ gnu/CORBA/BigDecimalHelper.java,
+ gnu/CORBA/Unexpected.java,
+ gnu/CORBA/OctetHolder.java,
+ gnu/CORBA/TypeCodeHelper.java,
+ gnu/CORBA/corbaArrayList.java,
+ gnu/CORBA/WCharHolder.java,
+ gnu/CORBA/WStringHolder.java,
+ gnu/CORBA/IOR_Delegate.java,
+ gnu/CORBA/fixedTypeCode.java,
+ gnu/CORBA/generalTypeCode.java,
+ gnu/CORBA/holderFactory.java,
+ gnu/CORBA/recordTypeCode.java,
+ gnu/CORBA/recursiveTypeCode.java,
+ gnu/CORBA/stringTypeCode.java,
+ gnu/CORBA/Connected_objects.java,
+ gnu/CORBA/ByteArrayComparator.java,
+ gnu/CORBA/binaryReply.java,
+ gnu/CORBA/typeNamer.java,
+ gnu/CORBA/streamRequest.java,
+ gnu/CORBA/stubFinder.java,
+ gnu/CORBA/bufferedResponseHandler.java,
+ gnu/CORBA/ExceptionCreator.java,
+ gnu/CORBA/ObjectCreator.java,
+ gnu/CORBA/aliasTypeCode.java: New files.
+ * gnu/CORBA/NamingService/snConverter.java,
+ gnu/CORBA/NamingService/Ext.java,
+ gnu/CORBA/NamingService/cmpNameComponent.java,
+ gnu/CORBA/NamingService/TransientContext.java,
+ gnu/CORBA/NamingService/NamingMap.java,
+ gnu/CORBA/NamingService/Binding_iterator_impl.java,
+ gnu/CORBA/NamingService/NamingServiceTransient.java,
+ gnu/CORBA/NamingService/NameValidator.java: New files.
+ * gnu/CORBA/CDR/aligningInputStream.java,
+ gnu/CORBA/CDR/aligningOutputStream.java,
+ gnu/CORBA/CDR/cdrOutput.java,
+ gnu/CORBA/CDR/cdrInput.java,
+ gnu/CORBA/CDR/cdrBufOutput.java,
+ gnu/CORBA/CDR/encapsulatedOutput.java,
+ gnu/CORBA/CDR/cdrBufInput.java,
+ gnu/CORBA/CDR/testBinaryIO.java: New files.
+ * org/omg/CORBA/StringHolder.java,
+ * org/omg/CORBA/StringSeqHelper.java,
+ * org/omg/CORBA/StringSeqHolder.java: Read and write string,
+ not wstring and use stringTypeCode.
+ * org/omg/CORBA/Any.java: Adding serialVersionUID.
+ * org/omg/CORBA/FixedHolder: Use fixedTypeCode.
+ * org/omg/CORBA/UNKNOWN.java: Making constructors public.
+ * org/omg/CORBA/UserException.java: Inherit
+ from org.omg.CORBA.portable.IDLEntity.
+ * org/omg/CORBA/ORB.java,
+ org/omg/CORBA/Object.java: Replacing empty class
+ declarations with implementation.
+ * gnu/CORBA/primitiveTypeCode.java: Exception fixes.
+ * gnu/CORBA/primitiveArrayTypeCode.java: Adding extra
+ parameter in constructor.
+ * gnu/CORBA/GIOP/CancelHeader.java,
+ gnu/CORBA/GIOP/ErrorMessage.java,
+ gnu/CORBA/GIOP/MessageHeader.java,
+ gnu/CORBA/GIOP/ReplyHeader.java,
+ gnu/CORBA/GIOP/RequestHeader.java,
+ gnu/CORBA/GIOP/ServiceContext.java,
+ gnu/CORBA/GIOP/cxCodeSet.java,
+ gnu/CORBA/GIOP/CharSets_OSF.java,
+ gnu/CORBA/GIOP/v1_0/CancelHeader.java,
+ gnu/CORBA/GIOP/v1_0/RequestHeader.java,
+ gnu/CORBA/GIOP/v1_0/ReplyHeader.java,
+ gnu/CORBA/GIOP/v1_2/RequestHeader.java,
+ gnu/CORBA/GIOP/v1_2/ReplyHeader.java: New files.
+ org/omg/CosNaming/_NamingContextStub.java,
+ org/omg/CosNaming/_NamingContextImplBase.java,
+ org/omg/CosNaming/BindingHelper.java,
+ org/omg/CosNaming/BindingListHelper.java,
+ org/omg/CosNaming/NameComponentHelper.java,
+ org/omg/CosNaming/NameHelper.java,
+ org/omg/CosNaming/BindingTypeHelper.java,
+ org/omg/CosNaming/NamingContextHelper.java,
+ org/omg/CosNaming/BindingIteratorHelper.java,
+ org/omg/CosNaming/_NamingContextExtStub.java,
+ org/omg/CosNaming/NamingContextExt.java,
+ org/omg/CosNaming/NamingContextExtHelper.java,
+ org/omg/CosNaming/NamingContextExtHolder.java,
+ org/omg/CosNaming/NamingContextExtOperations.java,
+ org/omg/CosNaming/_NamingContextExtImplBase.java,
+ org/omg/CosNaming/NamingContextOperations.java,
+ org/omg/CosNaming/NamingContext.java,
+ org/omg/CosNaming/NameComponent.java,
+ org/omg/CosNaming/BindingIterator.java,
+ org/omg/CosNaming/_BindingIteratorStub.java,
+ org/omg/CosNaming/Binding.java,
+ org/omg/CosNaming/BindingType.java,
+ org/omg/CosNaming/BindingIteratorHolder.java,
+ org/omg/CosNaming/BindingListHolder.java,
+ org/omg/CosNaming/BindingHolder.java,
+ org/omg/CosNaming/BindingTypeHolder.java,
+ org/omg/CosNaming/NameComponentHolder.java,
+ org/omg/CosNaming/NameHolder.java,
+ org/omg/CosNaming/NamingContextHolder.java,
+ org/omg/CosNaming/_BindingIteratorImplBase.java,
+ org/omg/CosNaming/package.html,
+ org/omg/CosNaming/NamingContextExtPackage/InvalidAddress.java,
+ org/omg/CosNaming/NamingContextExtPackage/InvalidAddressHolder.java,
+ org/omg/CosNaming/NamingContextExtPackage/package.html,
+ org/omg/CosNaming/NamingContextExtPackage/AddressHelper.java,
+ org/omg/CosNaming/NamingContextExtPackage/URLStringHelper.java,
+ org/omg/CosNaming/NamingContextExtPackage/StringNameHelper.java,
+ org/omg/CosNaming/NamingContextExtPackage/InvalidAddressHelper.java,
+ org/omg/CosNaming/NamingContextPackage/NotEmpty.java,
+ org/omg/CosNaming/NamingContextPackage/NotFound.java,
+ org/omg/CosNaming/NamingContextPackage/NotFoundReason.java,
+ org/omg/CosNaming/NamingContextPackage/NotFoundReasonHolder.java,
+ org/omg/CosNaming/NamingContextPackage/NotFoundHolder.java,
+ org/omg/CosNaming/NamingContextPackage/NotEmptyHolder.java,
+ org/omg/CosNaming/NamingContextPackage/AlreadyBoundHolder.java,
+ org/omg/CosNaming/NamingContextPackage/CannotProceedHolder.java,
+ org/omg/CosNaming/NamingContextPackage/InvalidNameHolder.java,
+ org/omg/CosNaming/NamingContextPackage/CannotProceed.java,
+ org/omg/CosNaming/NamingContextPackage/InvalidName.java,
+ org/omg/CosNaming/NamingContextPackage/AlreadyBound.java,
+ org/omg/CosNaming/NamingContextPackage/NotFoundHelper.java,
+ org/omg/CosNaming/NamingContextPackage/NotEmptyHelper.java,
+ org/omg/CosNaming/NamingContextPackage/AlreadyBoundHelper.java,
+ org/omg/CosNaming/NamingContextPackage/InvalidNameHelper.java,
+ org/omg/CosNaming/NamingContextPackage/NotFoundReasonHelper.java,
+ org/omg/CosNaming/NamingContextPackage/CannotProceedHelper.java,
+ org/omg/CosNaming/NamingContextPackage/package.html: New files.
+ * examples/gnu/classpath/examples/CORBA/NamingService/Demo.java,
+ examples/gnu/classpath/examples/CORBA/SimpleCommunication/Demo.java,
+ examples/gnu/classpath/examples/CORBA/SimpleCommunication/comServer.java,
+ examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThisHelper.java,
+ examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThisHolder.java,
+ examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThis.java,
+ examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThis.java,
+ examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThisHelper.java,
+ examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThisHolder.java,
+ examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DirectTest.java,
+ examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/RequestTest.java,
+ examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/comServant.java,
+ examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserException.java,
+ examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/node.java,
+ examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/nodeHelper.java,
+ examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/nodeHolder.java,
+ examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_comTesterStub.java,
+ examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserExceptionHelper.java,
+ examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_comTesterImplBase.java,
+ examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/comTester.java:
+ New IIOP (CORBA) examples.
+
2005-05-14 Chris Burdess <dog@gnu.org>
* gnu/xml/dom/DomDocumentBuilder.java,
diff --git a/gnu/CORBA/BigDecimalHelper.java b/gnu/CORBA/BigDecimalHelper.java
new file mode 100644
index 000000000..9ef7ad151
--- /dev/null
+++ b/gnu/CORBA/BigDecimalHelper.java
@@ -0,0 +1,193 @@
+/* BigDecimalHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+
+/**
+ * Reads and writes BigDecimal as CORBA <code>fixed</code>.
+ * The format, described in CORBA specification, requires to store
+ * data in hexadecimal format, two digits per byte (oceted), most
+ * significant digit first. The last half-byte in the representation
+ * stores the sign, being 0xD for negative numbers and 0xC for
+ * zero and positive numbers. To have the even number of half bytes,
+ * 0x0 is appended to the beginning, if required. The position of the
+ * decimal point is not stored.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class BigDecimalHelper
+{
+ {
+ }
+
+ /**
+ * @todo remove from the release version.
+ */
+ public static void main(String[] args)
+ {
+ try
+ {
+ ByteArrayOutputStream b = new ByteArrayOutputStream();
+ BigDecimal d = new BigDecimal("12234.54689");
+
+ write(b, d);
+
+ byte[] a = b.toByteArray();
+
+ for (int i = 0; i < a.length; i++)
+ {
+ int k = a [ i ] & 0xFF;
+ System.out.print(Integer.toHexString(k) + " ");
+ }
+
+ System.out.println("Now reading");
+
+ ByteArrayInputStream bin = new ByteArrayInputStream(a);
+
+ BigDecimal r = read(bin, d.scale());
+
+ System.out.println(r);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * Read the CORBA fixed, autodetecting the number of bytes
+ * and assuming the given scale.
+ */
+ public static BigDecimal read(java.io.InputStream in, int scale)
+ throws IOException
+ {
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+
+ int f;
+
+ do
+ {
+ f = in.read();
+ if (f >= 0)
+ bout.write(f);
+ }
+ // The last byte has 0xC or 0xD in the last halfbyte.
+ while ((f & 0xF) <= 0x9);
+
+ return createFixed(scale, bout.toByteArray());
+ }
+
+ /**
+ * Write the big decimal as CORBA <code>fixed<.code>.
+ * The scale will not be stored.
+ *
+ * @param out a stream to write into.
+ * @param x a big decimal to write.
+ * @param digits a number of the decimal digits in the record
+ * being written. For the smaller
+ * numbers, zeroes are added to the left.
+ *
+ * @throws IOException if the stream write method throws one.
+ * @throws BadKind if this BigDecimal has more digits than
+ * specified.
+ */
+ public static void write(java.io.OutputStream out, BigDecimal x)
+ throws IOException, BadKind
+ {
+ StringBuffer v = new StringBuffer(x.unscaledValue().toString());
+
+ boolean negative = v.charAt(0) == '-';
+
+ if (negative)
+ v = v.deleteCharAt(0);
+
+ if ( (v.length() & 1) == 0)
+ v.insert(0, '0');
+
+ int c;
+
+ for (int i = 0; i < v.length() - 1; i = i + 2)
+ {
+ c = ((v.charAt(i) - '0') << 4) | (v.charAt(i + 1) - '0');
+ out.write(c);
+ }
+
+ c = ((v.charAt(v.length() - 1) - '0') << 4) | (negative ? 0xD : 0xC);
+
+ out.write(c);
+ }
+
+ /**
+ * Convert the loaded byte array, representing
+ * CORBA <code>fixed</code>, into an instance of
+ * the {@link BigDecimal}
+ */
+ private static BigDecimal createFixed(int scale, byte[] d)
+ {
+ StringBuffer s = new StringBuffer(2 * d.length);
+
+ int last = d.length - 1;
+
+ if ((d [ last ] & 0xF) == 0xD)
+ s.append('-');
+
+ if (last > 0)
+ for (int i = 0; i < last; i++)
+ {
+ s.append((char) (((d [ i ] >> 4) & 0xF) + '0'));
+ s.append((char) (((d [ i ]) & 0xF) + '0'));
+ }
+
+ s.append((char) (((d [ last ] >> 4) & 0xF) + '0'));
+
+ BigInteger b = new BigInteger(s.toString());
+ BigDecimal dec = new BigDecimal(b, scale);
+
+ return dec;
+ }
+}
diff --git a/gnu/CORBA/ByteArrayComparator.java b/gnu/CORBA/ByteArrayComparator.java
new file mode 100644
index 000000000..3dedc7f96
--- /dev/null
+++ b/gnu/CORBA/ByteArrayComparator.java
@@ -0,0 +1,91 @@
+/* ByteArrayComparator.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import java.util.Arrays;
+import java.util.Comparator;
+
+/**
+ * A byte array comparator for mapping with CORBA object keys.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class ByteArrayComparator
+ implements Comparator
+{
+ /**
+ * Compare arrays first by absolute equality, then by length
+ * and then (byte to byte) by content.
+ *
+ * @return 0 if arrays are equal, some comparison value otherwise.
+ */
+ public int compare(Object an_a, Object a_b)
+ {
+ if (an_a == a_b)
+ return 0;
+
+ byte[] a = null;
+ byte[] b = null;
+ try
+ {
+ a = (byte[]) an_a;
+ b = (byte[]) a_b;
+ }
+ catch (Exception ex)
+ {
+ throw new InternalError(an_a.getClass().getName() + "," +
+ a_b.getClass().getName()
+ );
+ }
+
+ if (a.length != b.length)
+ return a.length - b.length;
+ else
+ {
+ // The array sizes must be equal.
+ for (int i = 0; i < b.length; i++)
+ {
+ if (a [ i ] != b [ i ])
+ return a [ i ] - b [ i ];
+ }
+ }
+
+ return 0;
+ }
+}
diff --git a/gnu/CORBA/CDR/aligningInputStream.java b/gnu/CORBA/CDR/aligningInputStream.java
new file mode 100644
index 000000000..f1aa2317e
--- /dev/null
+++ b/gnu/CORBA/CDR/aligningInputStream.java
@@ -0,0 +1,112 @@
+/* aligningInputStream.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.CDR;
+
+import java.io.ByteArrayInputStream;
+
+import org.omg.CORBA.BAD_PARAM;
+
+/**
+ * The input stream with the possibility to align on the
+ * word (arbitrary size) boundary.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class aligningInputStream
+ extends ByteArrayInputStream
+{
+ /**
+ * The alignment offset.
+ */
+ private int offset = 0;
+
+ /**
+ * Create a stream, reading form the given buffer.
+ *
+ * @param a_buffer a buffer to read from.
+ */
+ public aligningInputStream(byte[] a_buffer)
+ {
+ super(a_buffer);
+ }
+
+ /**
+ * Create a stream, reading from the given buffer region.
+ *
+ * @param a_buffer a buffer to read from.
+ * @param offset the offset of the region.
+ * @param length thr length of the region.
+ */
+ public aligningInputStream(byte[] a_buffer, int offset, int length)
+ {
+ super(a_buffer, offset, length);
+ }
+
+ /**
+ * Set the alignment offset, if the index of the first byte in the
+ * stream is different from 0.
+ */
+ public void setOffset(int an_offset)
+ {
+ offset = an_offset;
+ }
+
+ /**
+ * Skip several bytes, aligning the internal pointer on the
+ * selected boundary.
+ *
+ * @throws BAD_PARAM, minor code 0, the alignment is not possible,
+ * usually due the wrong parameter value.
+ */
+ public void align(int alignment)
+ {
+ try
+ {
+ int d = (pos + offset) % alignment;
+ if (d > 0)
+ {
+ skip(alignment - d);
+ }
+ }
+ catch (Exception ex)
+ {
+ throw new BAD_PARAM("Unable to align at " + alignment);
+ }
+ }
+}
diff --git a/gnu/CORBA/CDR/aligningOutputStream.java b/gnu/CORBA/CDR/aligningOutputStream.java
new file mode 100644
index 000000000..b4a96f8bb
--- /dev/null
+++ b/gnu/CORBA/CDR/aligningOutputStream.java
@@ -0,0 +1,119 @@
+/* aligningOutputStream.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.CDR;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+
+import org.omg.CORBA.BAD_PARAM;
+
+/**
+ * The input stream with the possibility to align on the
+ * word (arbitrary size) boundary.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class aligningOutputStream
+ extends ByteArrayOutputStream
+{
+ /**
+ * The alignment offset.
+ */
+ private int offset = 0;
+
+ /**
+ * Create a stream with the default intial buffer size.
+ */
+ public aligningOutputStream()
+ {
+ }
+
+ /**
+ * Create a stream with the given intial buffer size.
+ */
+ public aligningOutputStream(int initial_size)
+ {
+ super(initial_size);
+ }
+
+ /**
+ * Set the alignment offset, if the index of the first byte in the
+ * stream is different from 0.
+ */
+ public void setOffset(int an_offset)
+ {
+ offset = an_offset;
+ }
+
+ /**
+ * Skip several bytes, aligning the internal pointer on the
+ * selected boundary.
+ *
+ * @throws BAD_PARAM, minor code 0, the alignment is not possible,
+ * usually due the wrong parameter value.
+ */
+ public void align(int alignment)
+ {
+ try
+ {
+ int d = (count + offset) % alignment;
+ if (d > 0)
+ {
+ skip(alignment - d);
+ }
+ }
+ catch (Exception ex)
+ {
+ throw new BAD_PARAM("Unable to align at " + alignment);
+ }
+ }
+
+ /**
+ * Write the specified number of zero bytes.
+ *
+ * @param bytes the number of zero bytes to write.
+ */
+ public void skip(int bytes)
+ {
+ for (int i = 0; i < bytes; i++)
+ {
+ write(0);
+ }
+ }
+}
diff --git a/gnu/CORBA/CDR/cdrBufInput.java b/gnu/CORBA/CDR/cdrBufInput.java
new file mode 100644
index 000000000..58715c64a
--- /dev/null
+++ b/gnu/CORBA/CDR/cdrBufInput.java
@@ -0,0 +1,115 @@
+/* cdrBufInput.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.CDR;
+
+
+/**
+ * The CDR input stream that reads data from the byte buffer.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ *
+ * TODO character encoding. Now the encoding can be set, but it is ignored.
+ * If you take this task, scan 'TODO character encoding' for
+ * relevant places.
+ */
+public class cdrBufInput
+ extends cdrInput
+{
+ /**
+ * The byte array input stream to read data from.
+ */
+ public final aligningInputStream buffer;
+
+ /**
+ * Creates the CDR input stream that reads from the given buffer
+ * array.
+ *
+ * @param a_buffer an array to read from.
+ */
+ public cdrBufInput(byte[] a_buffer)
+ {
+ buffer = new aligningInputStream(a_buffer);
+ setInputStream(buffer);
+ }
+
+ /**
+ * Set the alignment offset, if the index of the first byte in the
+ * stream is different from 0.
+ */
+ public void setOffset(int offset)
+ {
+ buffer.setOffset(offset);
+ }
+
+ /**
+ * Skip several bytes, aligning the internal pointer on the
+ * selected boundary.
+ */
+ public void align(int alignment)
+ {
+ buffer.align(alignment);
+ }
+
+ /**
+ * Mark the current position.
+ * @param ahead
+ */
+ public synchronized void mark(int ahead)
+ {
+ buffer.mark(ahead);
+ }
+
+ /**
+ * Checks if marking is supported.
+ * @return
+ */
+ public boolean markSupported()
+ {
+ return buffer.markSupported();
+ }
+
+ /**
+ * Resets the stream to the previously marked position.
+ */
+ public void reset()
+ {
+ buffer.reset();
+ setInputStream(buffer);
+ }
+}
diff --git a/gnu/CORBA/CDR/cdrBufOutput.java b/gnu/CORBA/CDR/cdrBufOutput.java
new file mode 100644
index 000000000..d8d34f7d4
--- /dev/null
+++ b/gnu/CORBA/CDR/cdrBufOutput.java
@@ -0,0 +1,115 @@
+/* cdrBufOutput.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.CDR;
+
+import java.io.ByteArrayOutputStream;
+
+/**
+ * A CORBA output stream, writing data into the internal
+ * buffer ({@link ByteArrayOutputStream}).
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class cdrBufOutput
+ extends cdrOutput
+{
+ /**
+ * The byte buffer.
+ */
+ public final aligningOutputStream buffer;
+
+ /**
+ * Creates the instance with the given initial buffer size.
+ * @param bufSize the buffer size.
+ */
+ public cdrBufOutput(int bufSize)
+ {
+ buffer = new aligningOutputStream(bufSize);
+ setOutputStream(buffer);
+ }
+
+ /**
+ * Creates the instance with the default buffer size.
+ */
+ public cdrBufOutput()
+ {
+ buffer = new aligningOutputStream();
+ setOutputStream(buffer);
+ }
+
+ /**
+ * Set the alignment offset, if the index of the first byte in the
+ * stream is different from 0.
+ */
+ public void setOffset(int an_offset)
+ {
+ buffer.setOffset(an_offset);
+ }
+
+ /**
+ * Align the curretn position at the given natural boundary.
+ */
+ public void align(int boundary)
+ {
+ buffer.align(boundary);
+ }
+
+ /**
+ * Return the input stream that reads the previously written values.
+ */
+ public org.omg.CORBA.portable.InputStream create_input_stream()
+ {
+ cdrBufInput in = new cdrBufInput(buffer.toByteArray());
+ in.setOrb(orb);
+
+ in.setVersion(giop);
+ in.setCodeSet(getCodeSet());
+
+ return in;
+ }
+
+ /**
+ * Resets (clears) the buffer.
+ */
+ public void reset()
+ {
+ buffer.reset();
+ setOutputStream(buffer);
+ }
+}
diff --git a/gnu/CORBA/CDR/cdrInput.java b/gnu/CORBA/CDR/cdrInput.java
new file mode 100644
index 000000000..03be3363b
--- /dev/null
+++ b/gnu/CORBA/CDR/cdrInput.java
@@ -0,0 +1,1129 @@
+/* cdrInput.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.CDR;
+
+import gnu.CORBA.BigDecimalHelper;
+import gnu.CORBA.Functional_ORB;
+import gnu.CORBA.GIOP.CharSets_OSF;
+import gnu.CORBA.GIOP.cxCodeSet;
+import gnu.CORBA.IOR;
+import gnu.CORBA.IOR_Delegate;
+import gnu.CORBA.TypeCodeHelper;
+import gnu.CORBA.Unexpected;
+import gnu.CORBA.Version;
+import gnu.CORBA.gnuAny;
+import gnu.CORBA.stubFinder;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.NO_IMPLEMENT;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Object;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+import org.omg.CORBA.TypeCodePackage.Bounds;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.ObjectImpl;
+
+import java.io.DataInputStream;
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import java.math.BigDecimal;
+
+/**
+ * A simple CORBA CDR (common data representation)
+ * input stream, reading data from the
+ * given {@link java.io.InputStream}. The primitive types
+ * are aligned on they natural boundaries by implamenting the
+ * abstract method {@link #align(int boundary)}.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public abstract class cdrInput
+ extends org.omg.CORBA.portable.InputStream
+{
+ /**
+ * The message, explaining that the exception has been thrown due
+ * unexpected end of the input stream. This usually happens the
+ * server and client disagree on communication or data representation
+ * rules.
+ */
+ protected static final String UNEXP_EOF = "Unexpected end of stream";
+
+ /**
+ * This instance is used to convert primitive data types into the
+ * byte sequences.
+ */
+ protected DataInputStream b;
+
+ /**
+ * The associated orb, if any.
+ */
+ protected ORB orb;
+
+ /**
+ * The GIOP version.
+ */
+ protected Version giop = new Version(1, 0);
+
+ /**
+ * The code set information.
+ */
+ protected cxCodeSet codeset = cxCodeSet.STANDARD;
+
+ /**
+ * The name of the currently used narrow charset, null if
+ * the native narrow charset is used.
+ */
+ private String narrow_charset = null;
+
+ /**
+ * The name of the currently used wide charset, null if
+ * the native wide charset is used.
+ */
+ private String wide_charset = null;
+
+ /**
+ * True if the native code set is used for narrow characters.
+ * If the set is native, no the intermediate Reader object
+ * is instantiated when writing characters.
+ */
+ private boolean narrow_native;
+
+ /**
+ * True if the native code set is used for wide characters.
+ * If the set is native, no the intermediate Reader object
+ * is instantiated when writing characters.
+ */
+ private boolean wide_native;
+
+ /**
+ * Creates the stream.
+ *
+ * @param readFrom a stream to read CORBA input from.
+ */
+ public cdrInput(java.io.InputStream readFrom)
+ {
+ setInputStream(readFrom);
+ setCodeSet(cxCodeSet.STANDARD);
+ }
+
+ /**
+ * Creates the stream, requiring the subsequent call
+ * of {@link #setInputStream(java.io.InputStream)}.
+ */
+ public cdrInput()
+ {
+ setCodeSet(cxCodeSet.STANDARD);
+ }
+
+ /**
+ * Set the input stream that receives the CORBA input.
+ *
+ * @param readFrom the stream.
+ */
+ public void setInputStream(java.io.InputStream readFrom)
+ {
+ b = new DataInputStream(readFrom);
+ }
+
+ /**
+ * Set the alignment offset, if the index of the first byte in the
+ * stream is different from 0.
+ */
+ public abstract void setOffset(int offset);
+
+ /**
+ * Set the orb, associated with this stream.
+ * @param an_orb
+ */
+ public void setOrb(ORB an_orb)
+ {
+ orb = an_orb;
+ }
+
+ /**
+ * Set the GIOP version. Some data types are written differently
+ * for the different versions. The default version is 1.0 .
+ */
+ public void setVersion(Version giop_version)
+ {
+ giop = giop_version;
+ }
+
+ /**
+ * Align the curretn position at the given natural boundary.
+ */
+ public abstract void align(int boundary);
+
+ /**
+ * Reads the CORBA unsigned long (java int), returning the
+ * value in the sufficiently large java long.
+ */
+ public long gnu_read_ulong()
+ {
+ try
+ {
+ long l = b.readInt();
+ l &= 0xFFFFFFF;
+ return l;
+ }
+ catch (EOFException ex)
+ {
+ throw new MARSHAL(UNEXP_EOF);
+ }
+ catch (IOException ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /**
+ * Read the unsigned short integer value and return it as java
+ * int, sufficiently large to hold all values.
+ */
+ public int gnu_read_ushort()
+ {
+ try
+ {
+ align(2);
+ return b.readUnsignedShort();
+ }
+ catch (EOFException ex)
+ {
+ throw new MARSHAL(UNEXP_EOF);
+ }
+
+ catch (IOException ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /**
+ * Return the associated {@link ORB}.
+ * @return the associated {@link ORB} or null is no such is set.
+ */
+ public ORB orb()
+ {
+ return orb;
+ }
+
+ /**
+ * Read a single byte directly from the buffer.
+ */
+ public int read()
+ throws java.io.IOException
+ {
+ try
+ {
+ return b.read();
+ }
+ catch (EOFException ex)
+ {
+ throw new MARSHAL(UNEXP_EOF);
+ }
+ }
+
+ /**
+ * Read bytes directly from the buffer.
+ */
+ public int read(byte[] x, int ofs, int len)
+ throws java.io.IOException
+ {
+ try
+ {
+ return b.read(x, ofs, len);
+ }
+ catch (EOFException ex)
+ {
+ throw new MARSHAL(UNEXP_EOF);
+ }
+ }
+
+ /**
+ * Read bytes directly from the buffer.
+ */
+ public int read(byte[] x)
+ throws java.io.IOException
+ {
+ try
+ {
+ return b.read(x);
+ }
+ catch (EOFException ex)
+ {
+ throw new MARSHAL(UNEXP_EOF);
+ }
+ }
+
+ /**
+ * Read the CORBA object. The object to read is represented in the
+ * form of the plain (not a string-encoded) IOR profile without the
+ * heading endian indicator. The responsible method for reading such
+ * data is {@link IOR.read_no_endian}.
+ *
+ * The returned object is usually casted into the given type using
+ * the .narrow method of its helper, despite in some cases the direct
+ * cast would also work.
+ *
+ * @return the loaded and constructed object.
+ */
+ public Object read_Object()
+ {
+ try
+ {
+ IOR ior = new IOR();
+ ior._read_no_endian(this);
+
+ // Check maybe this is a remote reference to the local object.
+ // This is only possible if we access the repository of the
+ // connected object.
+ if (orb instanceof Functional_ORB)
+ {
+ Functional_ORB forb = (Functional_ORB) orb;
+ Object local = forb.find_local_object(ior);
+ if (local != null)
+ return local;
+ }
+
+ // Search for the available stubs.
+ ObjectImpl impl = stubFinder.search(orb, ior);
+ try
+ {
+ if (impl._get_delegate() == null)
+ impl._set_delegate(new IOR_Delegate(orb, ior));
+ }
+ catch (BAD_OPERATION ex)
+ {
+ // Some colaborants may throw this exception
+ // in response to the attempt to get the unset delegate.
+ impl._set_delegate(new IOR_Delegate(orb, ior));
+ }
+
+ return impl;
+ }
+ catch (IOException ex)
+ {
+ throw new BAD_OPERATION(ex.toString());
+ }
+ }
+
+ /**
+ * Read the type code. The type code format is defined in the
+ * CORBA documenation.
+ */
+ public TypeCode read_TypeCode()
+ {
+ try
+ {
+ return TypeCodeHelper.read(this);
+ }
+
+ catch (Bounds ex)
+ {
+ throw new Unexpected();
+ }
+ catch (BadKind ex)
+ {
+ throw new Unexpected();
+ }
+ }
+
+ /**
+ * Read the CORBA {@link Any}. This method first reads the
+ * type code, then delegates the functionality
+ * to {@link Any#read_value}.
+ */
+ public Any read_any()
+ {
+ TypeCode ty = read_TypeCode();
+ gnuAny any = new gnuAny();
+ any.read_value(this, ty);
+ return any;
+ }
+
+ /**
+ * Read the boolean, treating any non zero byte as true,
+ * zero byte as false.
+ */
+ public boolean read_boolean()
+ {
+ try
+ {
+ return b.read() == 0 ? false : true;
+ }
+ catch (EOFException ex)
+ {
+ throw new MARSHAL(UNEXP_EOF);
+ }
+ catch (IOException ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /**
+ * Read the array of boolean.
+ */
+ public void read_boolean_array(boolean[] x, int offs, int len)
+ {
+ try
+ {
+ for (int i = offs; i < offs + len; i++)
+ {
+ x [ i ] = b.read() == 0 ? false : true;
+ }
+ }
+ catch (EOFException ex)
+ {
+ throw new MARSHAL(UNEXP_EOF);
+ }
+
+ catch (IOException ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /**
+ * Read a character using narrow charset encoding. Depending form
+ * which encoding is set, this still can be Unicode or ever wider.
+ */
+ public char read_char()
+ {
+ try
+ {
+ if (narrow_native)
+ return (char) b.read();
+ else
+ return (char) new InputStreamReader(b, narrow_charset).read();
+ }
+ catch (EOFException ex)
+ {
+ throw new MARSHAL(UNEXP_EOF);
+ }
+
+ catch (IOException ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /**
+ * Read a character array, using narrow charset encoding.
+ */
+ public void read_char_array(char[] x, int offset, int length)
+ {
+ try
+ {
+ if (narrow_native)
+ {
+ for (int i = offset; i < offset + length; i++)
+ x [ i ] = (char) b.read();
+ }
+ else
+ {
+ InputStreamReader reader = new InputStreamReader(b, narrow_charset);
+ reader.read(x, offset, length);
+ }
+ }
+ catch (EOFException ex)
+ {
+ throw new MARSHAL(UNEXP_EOF);
+ }
+
+ catch (IOException ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /**
+ * Read the double value, IEEE 754 format.
+ */
+ public double read_double()
+ {
+ try
+ {
+ align(8);
+ return b.readDouble();
+ }
+ catch (EOFException ex)
+ {
+ throw new MARSHAL(UNEXP_EOF);
+ }
+
+ catch (IOException ex)
+ {
+ throw new Unexpected();
+ }
+ }
+
+ /**
+ * Read the array of double values, IEEE 754 format.
+ */
+ public void read_double_array(double[] x, int offs, int len)
+ {
+ try
+ {
+ align(8);
+ for (int i = offs; i < offs + len; i++)
+ {
+ x [ i ] = b.readDouble();
+ }
+ }
+ catch (EOFException ex)
+ {
+ throw new MARSHAL(UNEXP_EOF);
+ }
+
+ catch (IOException ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /**
+ * Read the encapsulated stream. The endian flag is already extracted from
+ * the returned stream.
+ */
+ public cdrBufInput read_encapsulation()
+ {
+ try
+ {
+ int l = read_long();
+
+ byte[] r = new byte[ l ];
+ int n = 0;
+ reading:
+ while (n < r.length)
+ {
+ n = read(r, n, r.length - n);
+ }
+
+ cdrBufInput capsule = new cdrBufInput(r);
+ capsule.setOrb(orb);
+
+ int endian = capsule.read_octet();
+
+ // TODO FIXME implement little endian.
+ if (endian != 0)
+ {
+ throw new NO_IMPLEMENT("Little endian not supported.");
+ }
+
+ return capsule;
+ }
+ catch (EOFException ex)
+ {
+ throw new MARSHAL(UNEXP_EOF);
+ }
+
+ catch (IOException ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /**
+ * Read the CORBA fixed (the end of the <code>fixed</code>
+ * can be determined by its last byte). The scale is always
+ * assumed to be zero.
+ */
+ public BigDecimal read_fixed()
+ {
+ try
+ {
+ return BigDecimalHelper.read(this, 0);
+ }
+ catch (EOFException ex)
+ {
+ throw new MARSHAL(UNEXP_EOF);
+ }
+
+ catch (IOException ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /**
+ * Read the float value, IEEE 754 format.
+ */
+ public float read_float()
+ {
+ try
+ {
+ align(4);
+ return b.readFloat();
+ }
+ catch (EOFException ex)
+ {
+ throw new MARSHAL(UNEXP_EOF);
+ }
+
+ catch (IOException ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /**
+ * Read an array of float values, IEEE 754 format.
+ */
+ public void read_float_array(float[] x, int offs, int len)
+ {
+ try
+ {
+ align(4);
+ for (int i = offs; i < offs + len; i++)
+ {
+ x [ i ] = b.readFloat();
+ }
+ }
+ catch (EOFException ex)
+ {
+ throw new MARSHAL(UNEXP_EOF);
+ }
+
+ catch (IOException ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /**
+ * Read the CORBA long (java int), high byte first.
+ */
+ public int read_long()
+ {
+ try
+ {
+ align(4);
+ return b.readInt();
+ }
+ catch (EOFException ex)
+ {
+ throw new MARSHAL(UNEXP_EOF);
+ }
+
+ catch (IOException ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /**
+ * Read an array of CORBA longs (java ints).
+ */
+ public void read_long_array(int[] x, int offs, int len)
+ {
+ try
+ {
+ align(4);
+ for (int i = offs; i < offs + len; i++)
+ {
+ x [ i ] = b.readInt();
+ }
+ }
+ catch (EOFException ex)
+ {
+ throw new MARSHAL(UNEXP_EOF);
+ }
+
+ catch (IOException ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /**
+ * Read the CORBA long long (java long).
+ */
+ public long read_longlong()
+ {
+ try
+ {
+ align(8);
+ return b.readLong();
+ }
+ catch (EOFException ex)
+ {
+ throw new MARSHAL(UNEXP_EOF);
+ }
+
+ catch (IOException ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /**
+ * Read an array of CORBA long longs (java longs).
+ */
+ public void read_longlong_array(long[] x, int offs, int len)
+ {
+ try
+ {
+ align(8);
+ for (int i = offs; i < offs + len; i++)
+ {
+ x [ i ] = b.readLong();
+ }
+ }
+ catch (EOFException ex)
+ {
+ throw new MARSHAL(UNEXP_EOF);
+ }
+
+ catch (IOException ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /**
+ * Read a single byte.
+ */
+ public byte read_octet()
+ {
+ try
+ {
+ return b.readByte();
+ }
+ catch (EOFException ex)
+ {
+ throw new MARSHAL(UNEXP_EOF);
+ }
+
+ catch (IOException ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /**
+ * Read the byte array.
+ */
+ public void read_octet_array(byte[] x, int offs, int len)
+ {
+ try
+ {
+ b.read(x, offs, len);
+ }
+ catch (EOFException ex)
+ {
+ throw new MARSHAL(UNEXP_EOF);
+ }
+
+ catch (IOException ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /**
+ * Read the length of the byte array as CORBA long and then
+ * the array itseld.
+ */
+ public byte[] read_sequence()
+ {
+ try
+ {
+ int l = read_long();
+ byte[] b = new byte[ l ];
+ if (l > 0)
+ {
+ read(b);
+ }
+ return b;
+ }
+ catch (EOFException ex)
+ {
+ throw new MARSHAL(UNEXP_EOF);
+ }
+
+ catch (IOException ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /**
+ * Read the CORBA short integer.
+ */
+ public short read_short()
+ {
+ try
+ {
+ align(2);
+ return b.readShort();
+ }
+ catch (EOFException ex)
+ {
+ throw new MARSHAL(UNEXP_EOF);
+ }
+
+ catch (IOException ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /**
+ * Read the array of CORBA short integer values.
+ */
+ public void read_short_array(short[] x, int offs, int len)
+ {
+ try
+ {
+ align(2);
+ for (int i = offs; i < offs + len; i++)
+ {
+ x [ i ] = b.readShort();
+ }
+ }
+ catch (EOFException ex)
+ {
+ throw new MARSHAL(UNEXP_EOF);
+ }
+
+ catch (IOException ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /**
+ * Read a singe byte string. The method firs reads the
+ * byte array and then calls a constructor to create a
+ * string from this array. The character encoding, if
+ * previously set, is taken into consideration.
+ *
+ * @return a loaded string.
+ */
+ public String read_string()
+ {
+ try
+ {
+ align(4);
+
+ int n = b.readInt();
+ byte[] s = new byte[ n ];
+ b.read(s);
+
+ // Discard the null terminator.
+ if (narrow_charset == null)
+ return new String(s, 0, n - 1);
+ else
+ return new String(s, 0, n - 1, narrow_charset);
+ }
+ catch (EOFException ex)
+ {
+ throw new MARSHAL(UNEXP_EOF);
+ }
+
+ catch (IOException ex)
+ {
+ throw new Unexpected();
+ }
+ }
+
+ /**
+ * Reads the CORBA unsigned long (java int), delegating
+ * functionality to {@link #read_long}.
+ */
+ public int read_ulong()
+ {
+ return read_long();
+ }
+
+ /**
+ * Reads the array of CORBA unsigned long (java integer) values,
+ * delegating functionality to
+ * {@link #real_long_array}.
+ */
+ public void read_ulong_array(int[] x, int offs, int len)
+ {
+ read_long_array(x, offs, len);
+ }
+
+ /**
+ * Read the CORBA unsigned long long value,
+ * delegating functionality to {@link #read_longlong}.
+ * There is no way to return values over the limit of
+ * the java signed long in other way than returning
+ * the negative value.
+ */
+ public long read_ulonglong()
+ {
+ return read_longlong();
+ }
+
+ /**
+ * Reads the array of CORBA long long (java long) values,
+ * delegating functionality to
+ * {@link #real_longlong_array}.
+ */
+ public void read_ulonglong_array(long[] x, int offs, int len)
+ {
+ read_longlong_array(x, offs, len);
+ }
+
+ /**
+ * Read the unsigned short integer value. Due strange specification,
+ * the returned value must be the short type as well, so the
+ * the best solution seems just to delegete functionality to
+ * read_short.
+ */
+ public short read_ushort()
+ {
+ return read_short();
+ }
+
+ /**
+ * Read an array of unsigned short values, delegating the
+ * functionality to {@link read_short_array}.
+ */
+ public void read_ushort_array(short[] x, int offs, int len)
+ {
+ read_short_array(x, offs, len);
+ }
+
+ /**
+ * Reads the wide character using the encoding, specified in the
+ * wide_charset.
+ */
+ public char read_wchar()
+ {
+ try
+ {
+ if (giop.until_inclusive(1, 1))
+ align(2);
+
+ if (wide_native)
+ return (char) b.readShort();
+ else
+ return (char) new InputStreamReader(b, wide_charset).read();
+ }
+ catch (EOFException ex)
+ {
+ throw new MARSHAL(UNEXP_EOF);
+ }
+ catch (IOException ex)
+ {
+ throw new Unexpected();
+ }
+ }
+
+ /**
+ * Read an array of "wide chars", each representing a two byte
+ * Unicode character, high byte first.
+ */
+ public void read_wchar_array(char[] x, int offset, int length)
+ {
+ try
+ {
+ if (giop.until_inclusive(1, 1))
+ align(2);
+
+ if (wide_native)
+ {
+ for (int i = offset; i < offset + length; i++)
+ x [ i ] = (char) b.readShort();
+ }
+ else
+ {
+ InputStreamReader reader = new InputStreamReader(b, wide_charset);
+ reader.read(x, offset, length);
+ }
+ }
+ catch (EOFException ex)
+ {
+ throw new MARSHAL(UNEXP_EOF);
+ }
+
+ catch (IOException ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /**
+ * Reads the string in wide character format
+ * (ussually UTF-16, Unicode). Takes the currently set charset
+ * into consideration.
+ *
+ * If the native (UTF-16) encoding is used
+ * of the GIOP protocol is before 1.2, delegates functionality
+ * to "plain" {@link #read_wstring_UTF_16}.
+ */
+ public String read_wstring()
+ {
+ // Native encoding or word oriented data.
+ if (wide_charset == null || giop.until_inclusive(1, 1))
+ return read_wstring_UTF_16();
+ try
+ {
+ align(4);
+
+ int n = b.readInt();
+ byte[] s = new byte[ n ];
+ b.read(s);
+
+ return new String(s, 0, n, wide_charset);
+ }
+ catch (EOFException ex)
+ {
+ throw new MARSHAL(UNEXP_EOF);
+ }
+
+ catch (IOException ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /**
+ * Reads first length of the string and the all characters as an
+ * Unicode (UTF-16) characters. Mind that GIOP 1.1 has the extra
+ * null character at the end that must be discarded.
+ */
+ public String read_wstring_UTF_16()
+ {
+ try
+ {
+ int p = 0;
+ int n = read_long();
+
+ // The null terminator that is no longer present since 1.2 .
+ int nt = giop.since_inclusive(1, 2) ? 0 : 1;
+
+ // Convert bytes to shorts.
+ n = n / 2;
+
+ char[] s = new char[ n ];
+
+ for (int i = 0; i < s.length; i++)
+ s [ i ] = (char) b.readShort();
+
+ // Check for the byte order marker here.
+ if (s [ 0 ] == 0xFEFF)
+ {
+ // Big endian encoding - do nothing, but move the pointer
+ // one position forward.
+ p = 1;
+ }
+ else if (s [ 0 ] == 0xFFFE)
+ {
+ // Little endian encoding, swap the bytes and move one
+ // position forward.
+ p = 1;
+
+ for (int i = p; i < s.length; i++)
+ s [ i ] = swap(s [ i ]);
+ }
+
+ // Discard the null terminator and, if needed, the endian marker.
+ return new String(s, p, n - nt - p);
+ }
+ catch (EOFException ex)
+ {
+ throw new MARSHAL(UNEXP_EOF);
+ }
+
+ catch (IOException ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /**
+ * Swap bytes in the character.
+ */
+ public static char swap(char x)
+ {
+ int hi;
+ int lo;
+
+ lo = x & 0xFF;
+ hi = (x >> 8) & 0xFF;
+
+ return (char) ((lo << 8) | hi);
+ }
+
+ /**
+ * Set the current code set context.
+ */
+ public void setCodeSet(cxCodeSet a_codeset)
+ {
+ this.codeset = a_codeset;
+ narrow_charset = CharSets_OSF.getName(codeset.char_data);
+ wide_charset = CharSets_OSF.getName(codeset.wide_char_data);
+
+ narrow_native = CharSets_OSF.NATIVE_CHARACTER == codeset.char_data;
+ wide_native = CharSets_OSF.NATIVE_WIDE_CHARACTER == codeset.wide_char_data;
+ }
+
+ /**
+ * Get the current code set context.
+ */
+ public cxCodeSet getCodeSet()
+ {
+ return codeset;
+ }
+
+ /**
+ * Read the object that is an instance of the given class. The current
+ * implementation delegates functionality to the parameterless
+ * {@link readObject()}.
+ *
+ * @param klass a class of that this object the instance is.
+ *
+ * @return the returned object.
+ */
+ public Object read_Object(Class klass)
+ {
+ return read_Object();
+ }
+}
diff --git a/gnu/CORBA/CDR/cdrOutput.java b/gnu/CORBA/CDR/cdrOutput.java
new file mode 100644
index 000000000..55c5eb9db
--- /dev/null
+++ b/gnu/CORBA/CDR/cdrOutput.java
@@ -0,0 +1,926 @@
+/* cdrOutput.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.CDR;
+
+import gnu.CORBA.BigDecimalHelper;
+import gnu.CORBA.GIOP.CharSets_OSF;
+import gnu.CORBA.GIOP.cxCodeSet;
+import gnu.CORBA.IOR;
+import gnu.CORBA.Simple_delegate;
+import gnu.CORBA.TypeCodeHelper;
+import gnu.CORBA.Unexpected;
+import gnu.CORBA.Version;
+import gnu.CORBA.primitiveTypeCode;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.Context;
+import org.omg.CORBA.ContextList;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.NO_IMPLEMENT;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+import org.omg.CORBA.UserException;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+
+import java.math.BigDecimal;
+
+/**
+ * A simple CORBA CDR (common data representation)
+ * output stream, writing data into the
+ * given {@link java.io.OutputStream}.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ *
+ * TODO the standalone chars and char arrays are still written using
+ * the native encoding, as the size under arbitrary encoding is not
+ * evident.
+ */
+public abstract class cdrOutput
+ extends org.omg.CORBA.portable.OutputStream
+{
+ /**
+ * This instance is used to convert primitive data types into the
+ * byte sequences.
+ */
+ protected DataOutputStream b;
+
+ /**
+ * The associated orb, if any.
+ */
+ protected ORB orb;
+
+ /**
+ * The GIOP version.
+ */
+ protected Version giop = new Version(1, 0);
+
+ /**
+ * The code set information.
+ */
+ protected cxCodeSet codeset;
+
+ /**
+ * The name of the currently used narrow charset.
+ */
+ private String narrow_charset;
+
+ /**
+ * The name of the currently used wide charset, null if
+ * the native wide charset is used.
+ */
+ private String wide_charset;
+
+ /**
+ * True if the native code set is used for narrow characters.
+ * If the set is native, no the intermediate Reader object
+ * is instantiated when writing characters.
+ */
+ private boolean narrow_native;
+
+ /**
+ * True if the native code set is used for wide characters.
+ * If the set is native, no the intermediate Reader object
+ * is instantiated when writing characters.
+ */
+ private boolean wide_native;
+
+ /**
+ * Creates the stream.
+ *
+ * @param writeTo a stream to write CORBA output to.
+ */
+ public cdrOutput(java.io.OutputStream writeTo)
+ {
+ setOutputStream(writeTo);
+ setCodeSet(cxCodeSet.STANDARD);
+ }
+
+ /**
+ * Creates the stream, requiring the subsequent call
+ * of {@link #setOutputStream(java.io.OutputStream)}.
+ */
+ public cdrOutput()
+ {
+ setCodeSet(cxCodeSet.STANDARD);
+ }
+
+ /**
+ * Set the alignment offset, if the index of the first byte in the
+ * stream is different from 0.
+ */
+ public abstract void setOffset(int an_offset);
+
+ /**
+ * Set the current code set context.
+ */
+ public void setCodeSet(cxCodeSet a_codeset)
+ {
+ this.codeset = a_codeset;
+ narrow_charset = CharSets_OSF.getName(codeset.char_data);
+ wide_charset = CharSets_OSF.getName(codeset.wide_char_data);
+
+ narrow_native = CharSets_OSF.NATIVE_CHARACTER == codeset.char_data;
+ wide_native = CharSets_OSF.NATIVE_WIDE_CHARACTER == codeset.wide_char_data;
+ }
+
+ /**
+ * Get the current code set context.
+ */
+ public cxCodeSet getCodeSet()
+ {
+ return codeset;
+ }
+
+ /**
+ * Set the orb, associated with this stream.
+ * @param an_orb
+ */
+ public void setOrb(ORB an_orb)
+ {
+ orb = an_orb;
+ }
+
+ /**
+ * Set the output stream that receives the CORBA output.
+ *
+ * @param writeTo the stream.
+ */
+ public void setOutputStream(java.io.OutputStream writeTo)
+ {
+ b = new DataOutputStream(writeTo);
+ }
+
+ /**
+ * Set the GIOP version. Some data types are written differently
+ * for the different versions. The default version is 1.0 .
+ */
+ public void setVersion(Version giop_version)
+ {
+ giop = giop_version;
+ }
+
+ /**
+ * Align the curretn position at the given natural boundary.
+ */
+ public abstract void align(int boundary);
+
+ /**
+ * Create the encapsulation stream, associated with the current
+ * stream. The encapsulated stream must be closed. When being
+ * closed, the encapsulation stream writes its buffer into
+ * this stream using the CORBA CDR encapsulation rules.
+ *
+ * It is not allowed to write to the current stream directly
+ * before the encapsulation stream is closed.
+ *
+ * @return the encapsulated stream.
+ */
+ public cdrOutput createEncapsulation()
+ {
+ return new encapsulatedOutput(this);
+ }
+
+ /**
+ * Return the associated {@link ORB}.
+ * @return the associated {@link ORB} or null is no such is set.
+ */
+ public ORB orb()
+ {
+ return orb;
+ }
+
+ /**
+ * Write a single byte.
+ * @param a byte to write (low 8 bits are written).
+ */
+ public void write(int n)
+ {
+ try
+ {
+ b.write(n);
+ }
+ catch (IOException ex)
+ {
+ Unexpected.error(ex);
+ }
+ }
+
+ /**
+ * Write bytes directly into the underlying stream.
+ */
+ public void write(byte[] x)
+ throws java.io.IOException
+ {
+ b.write(x);
+ }
+
+ /**
+ * Write bytes directly into the underlying stream.
+ */
+ public void write(byte[] x, int ofs, int len)
+ throws java.io.IOException
+ {
+ b.write(x, ofs, len);
+ }
+
+ /**
+ * Following the specification, this is not implemented.
+ * Override to get the functionality.
+ */
+ public void write_Context(Context context, ContextList contexts)
+ {
+ throw new NO_IMPLEMENT();
+ }
+
+ /**
+ * Read the CORBA object. The object is written
+ * form of the plain (not a string-encoded) IOR profile without the
+ * heading endian indicator. The responsible method for reading such
+ * data is {@link IOR.write_no_endian}.
+ */
+ public void write_Object(org.omg.CORBA.Object x)
+ {
+ if (x instanceof ObjectImpl)
+ {
+ Delegate d = ((ObjectImpl) x)._get_delegate();
+
+ if (d instanceof Simple_delegate)
+ {
+ Simple_delegate ido = (Simple_delegate) d;
+ ido.getIor()._write_no_endian(this);
+ return;
+ }
+ }
+
+ // Either this is not an ObjectImpl or it has the
+ // unexpected delegate. Try to convert via ORBs
+ // object_to_string().
+ if (orb != null)
+ {
+ IOR ior = IOR.parse(orb.object_to_string(x));
+ ior._write_no_endian(this);
+ return;
+ }
+ else
+ throw new BAD_OPERATION("Please set the ORB for this stream.");
+ }
+
+ /**
+ * Write the TypeCode. This implementation delegates functionality
+ * to {@link cdrTypeCode}.
+ *
+ * @param x a TypeCode to write.
+ */
+ public void write_TypeCode(TypeCode x)
+ {
+ try
+ {
+ TypeCodeHelper.write(this, x);
+ }
+ catch (UserException ex)
+ {
+ Unexpected.error(ex);
+ }
+ }
+
+ /**
+ * Writes an instance of the CORBA {@link Any}.
+ * This method writes the typecode, followed
+ * by value itself. In Any contains null
+ * (value not set), the {@link TCKind#tk_null}
+ * is written.
+ *
+ * @param x the {@link Any} to write.
+ */
+ public void write_any(Any x)
+ {
+ Streamable value = x.extract_Streamable();
+ if (value != null)
+ {
+ write_TypeCode(x.type());
+ value._write(this);
+ }
+ else
+ {
+ primitiveTypeCode p = new primitiveTypeCode(TCKind.tk_null);
+ write_TypeCode(p);
+ }
+ }
+
+ /**
+ * Writes a single byte, 0 for <code>false</code>,
+ * 1 for <code>true</code>.
+ *
+ * @param x the value to write
+ */
+ public void write_boolean(boolean x)
+ {
+ try
+ {
+ b.write(x ? 1 : 0);
+ }
+ catch (IOException ex)
+ {
+ Unexpected.error(ex);
+ }
+ }
+
+ /**
+ * Writes the boolean array.
+ *
+ * @param x array
+ * @param ofs offset
+ * @param len length.
+ */
+ public void write_boolean_array(boolean[] x, int ofs, int len)
+ {
+ try
+ {
+ for (int i = ofs; i < ofs + len; i++)
+ {
+ b.write(x [ i ] ? 1 : 0);
+ }
+ }
+ catch (IOException ex)
+ {
+ Unexpected.error(ex);
+ }
+ }
+
+ /**
+ * Writes the lower byte of the passed parameter.
+ * @param x the char to write
+ *
+ * It is effective to write more characters at once.
+ */
+ public void write_char(char x)
+ {
+ try
+ {
+ if (narrow_native)
+ b.write(x);
+ else
+ {
+ OutputStreamWriter ow = new OutputStreamWriter(b, narrow_charset);
+ ow.write(x);
+ ow.flush();
+ }
+ }
+ catch (IOException ex)
+ {
+ Unexpected.error(ex);
+ }
+ }
+
+ /**
+ * Writes the lower bytes of the passed array members.
+ *
+ * @param chars an array
+ * @param offsets offset
+ * @param length length
+ */
+ public void write_char_array(char[] chars, int offset, int length)
+ {
+ try
+ {
+ if (narrow_native)
+ {
+ for (int i = offset; i < offset + length; i++)
+ {
+ b.write(chars [ i ]);
+ }
+ }
+ else
+ {
+ OutputStreamWriter ow = new OutputStreamWriter(b, narrow_charset);
+ ow.write(chars, offset, length);
+ ow.flush();
+ }
+ }
+ catch (IOException ex)
+ {
+ Unexpected.error(ex);
+ }
+ }
+
+ /**
+ * Writes the double value (IEEE 754 format).
+ */
+ public void write_double(double x)
+ {
+ try
+ {
+ align(8);
+ b.writeDouble(x);
+ }
+ catch (Exception ex)
+ {
+ Unexpected.error(ex);
+ }
+ }
+
+ /**
+ * Writes the array of double values.
+ */
+ public void write_double_array(double[] x, int ofs, int len)
+ {
+ try
+ {
+ align(8);
+ for (int i = ofs; i < ofs + len; i++)
+ {
+ b.writeDouble(x [ i ]);
+ }
+ }
+ catch (IOException ex)
+ {
+ Unexpected.error(ex);
+ }
+ }
+
+ /**
+ * Writes CORBA fixed, storing all digits but not the scale.
+ * The end of the record on <code>fixed</code> can
+ * be determined from its last byte.
+ */
+ public void write_fixed(BigDecimal fixed)
+ {
+ try
+ {
+ BigDecimalHelper.write(this, fixed);
+ }
+ catch (IOException ex)
+ {
+ Unexpected.error(ex);
+ }
+ catch (BadKind ex)
+ {
+ Unexpected.error(ex);
+ }
+ }
+
+ /**
+ * Write the float value (IEEE 754 format).
+ */
+ public void write_float(float x)
+ {
+ try
+ {
+ align(4);
+ b.writeFloat(x);
+ }
+ catch (IOException ex)
+ {
+ Unexpected.error(ex);
+ }
+ }
+
+ /**
+ * Writes an array of the float values.
+ */
+ public void write_float_array(float[] x, int ofs, int len)
+ {
+ try
+ {
+ align(4);
+ for (int i = ofs; i < ofs + len; i++)
+ {
+ b.writeFloat(x [ i ]);
+ }
+ }
+ catch (IOException ex)
+ {
+ Unexpected.error(ex);
+ }
+ }
+
+ /**
+ * Writes the integer value (CORBA long, four bytes, high byte first).
+ * @param x the value to write.
+ */
+ public void write_long(int x)
+ {
+ try
+ {
+ align(4);
+ b.writeInt(x);
+ }
+ catch (IOException ex)
+ {
+ Unexpected.error(ex);
+ }
+ }
+
+ /**
+ * Writes the array of integer (CORBA long) values.
+ *
+ * @param x value
+ * @param ofs offset
+ * @param len length
+ */
+ public void write_long_array(int[] x, int ofs, int len)
+ {
+ try
+ {
+ align(4);
+ for (int i = ofs; i < ofs + len; i++)
+ {
+ b.writeInt(x [ i ]);
+ }
+ }
+ catch (IOException ex)
+ {
+ Unexpected.error(ex);
+ }
+ }
+
+ /**
+ * Writes the long (CORBA long long) value, 8 bytes,
+ * high byte first.
+ *
+ * @param x the value to write.
+ */
+ public void write_longlong(long x)
+ {
+ try
+ {
+ align(8);
+ b.writeLong(x);
+ }
+ catch (IOException ex)
+ {
+ Unexpected.error(ex);
+ }
+ }
+
+ /**
+ * Writes the array of longs (CORBA long longs) values.
+ *
+ * @param x value
+ * @param ofs offset
+ * @param len length
+ */
+ public void write_longlong_array(long[] x, int ofs, int len)
+ {
+ try
+ {
+ align(8);
+ for (int i = ofs; i < ofs + len; i++)
+ {
+ b.writeLong(x [ i ]);
+ }
+ }
+ catch (IOException ex)
+ {
+ Unexpected.error(ex);
+ }
+ }
+
+ /**
+ * Writes this byte.
+ * @param x
+ */
+ public void write_octet(byte x)
+ {
+ try
+ {
+ b.writeByte(x);
+ }
+ catch (IOException ex)
+ {
+ Unexpected.error(ex);
+ }
+ }
+
+ /**
+ * Writes the array of bytes (CORBA octets) values.
+ *
+ * @param x value
+ * @param ofs offset
+ * @param len length
+ */
+ public void write_octet_array(byte[] x, int ofs, int len)
+ {
+ for (int i = ofs; i < ofs + len; i++)
+ {
+ try
+ {
+ b.write(x, ofs, len);
+ }
+ catch (IOException ex)
+ {
+ Unexpected.error(ex);
+ }
+ }
+ }
+
+ /**
+ * Writes first the size of array, and then the byte array using
+ * the {@link java.io.OutputStream#write(byte[]) }. The sequence
+ * being written is preceeded by the int, representing the array
+ * length.
+ */
+ public void write_sequence(byte[] buf)
+ {
+ try
+ {
+ write_long(buf.length);
+ write(buf);
+ }
+ catch (IOException ex)
+ {
+ throw new MARSHAL("IOException while writing the data");
+ }
+ }
+
+ /**
+ * Writes the contents of the provided stream.
+ * The sequence being written is preceeded by the int,
+ * representing the stream buffer length (the number of
+ * bytes being subsequently written).
+ */
+ public void write_sequence(cdrBufOutput from)
+ {
+ try
+ {
+ write_long(from.buffer.size());
+ from.buffer.writeTo(this);
+ }
+ catch (IOException ex)
+ {
+ throw new MARSHAL("IOException while writing the data");
+ }
+ }
+
+ /**
+ * Writes the two byte integer (short), high byte first.
+ *
+ * @param x the integer to write.
+ */
+ public void write_short(short x)
+ {
+ try
+ {
+ align(2);
+ b.writeShort(x);
+ }
+ catch (IOException ex)
+ {
+ Unexpected.error(ex);
+ }
+ }
+
+ /**
+ * Writes the array of short (two byte integer) values.
+ *
+ * @param x value
+ * @param ofs offset
+ * @param len length
+ */
+ public void write_short_array(short[] x, int ofs, int len)
+ {
+ try
+ {
+ align(2);
+ for (int i = ofs; i < ofs + len; i++)
+ {
+ b.writeShort(x [ i ]);
+ }
+ }
+ catch (IOException ex)
+ {
+ Unexpected.error(ex);
+ }
+ }
+
+ /**
+ * Writes the string. This implementation first calls
+ * String.getBytes() and then writes the length of the returned
+ * array (as CORBA ulong) and the returned array itself.
+ *
+ * The encoding information, if previously set, is taken
+ * into consideration.
+ *
+ * @param x the string to write.
+ */
+ public void write_string(String x)
+ {
+ try
+ {
+ byte[] ab = x.getBytes(narrow_charset);
+ write_long(ab.length + 1);
+ write(ab);
+
+ // write null terminator.
+ write(0);
+ }
+ catch (IOException ex)
+ {
+ Unexpected.error(ex);
+ }
+ }
+
+ /**
+ * Writes the CORBA unsigned long in the same way as CORBA long.
+ */
+ public void write_ulong(int x)
+ {
+ write_long(x);
+ }
+
+ /**
+ * Writes the array of CORBA unsigned longs in the same way as
+ * array of ordinary longs.
+ */
+ public void write_ulong_array(int[] x, int ofs, int len)
+ {
+ write_long_array(x, ofs, len);
+ }
+
+ /**
+ * Write the unsigned long long in the same way as an ordinary long long.
+ *
+ * @param x a value to write.
+ */
+ public void write_ulonglong(long x)
+ {
+ write_longlong(x);
+ }
+
+ /**
+ * Write the array of unsingel long longs in the same way
+ * an an array of the ordinary long longs.
+ */
+ public void write_ulonglong_array(long[] x, int ofs, int len)
+ {
+ write_longlong_array(x, ofs, len);
+ }
+
+ /**
+ * Write the unsigned short in the same way as an ordinary short.
+ */
+ public void write_ushort(short x)
+ {
+ write_short(x);
+ }
+
+ /**
+ * Write an array of unsigned short integersin the same way
+ * as an array of ordinary short integers.
+ */
+ public void write_ushort_array(short[] x, int ofs, int len)
+ {
+ write_short_array(x, ofs, len);
+ }
+
+ /**
+ * Writes the character as two byte short integer (Unicode value),
+ * high byte first. Writes in Big Endian, but never writes the
+ * endian indicator.
+ *
+ * The character is always written using the native UTF-16BE charset
+ * because its size under arbitrary encoding is not evident.
+ */
+ public void write_wchar(char x)
+ {
+ try
+ {
+ if (giop.until_inclusive(1, 1))
+ align(2);
+
+ if (wide_native)
+ b.writeShort(x);
+ else
+ {
+ OutputStreamWriter ow = new OutputStreamWriter(b, wide_charset);
+ ow.write(x);
+ ow.flush();
+ }
+ }
+ catch (IOException ex)
+ {
+ Unexpected.error(ex);
+ }
+ }
+
+ /**
+ * Write the array of wide chars.
+ *
+ * @param chars the array of wide chars
+ * @param offset offset
+ * @param length length
+ *
+ * The char array is always written using the native UTF-16BE charset
+ * because the character size under arbitrary encoding is not evident.
+ */
+ public void write_wchar_array(char[] chars, int offset, int length)
+ {
+ try
+ {
+ if (giop.until_inclusive(1, 1))
+ align(2);
+
+ if (wide_native)
+ {
+ for (int i = offset; i < offset + length; i++)
+ {
+ b.writeShort(chars [ i ]);
+ }
+ }
+ else
+ {
+ OutputStreamWriter ow = new OutputStreamWriter(b, wide_charset);
+ ow.write(chars, offset, length);
+ ow.flush();
+ }
+ }
+ catch (IOException ex)
+ {
+ Unexpected.error(ex);
+ }
+ }
+
+ /**
+ * Writes the length of the string in bytes (not characters) and
+ * then all characters as two byte unicode chars. Adds the
+ * Big Endian indicator, 0xFFFE, at the beginning and null wide char at
+ * the end.
+ *
+ * @param x the string to write.
+ */
+ public void write_wstring(String x)
+ {
+ try
+ {
+ if (giop.since_inclusive(1, 2))
+ {
+ byte[] bytes = x.getBytes(wide_charset);
+ write_sequence(bytes);
+ }
+ else
+ {
+ // Encoding with null terminator always in UTF-16.
+ // The wide null terminator needs extra two bytes.
+ write_long(2 * x.length() + 2);
+
+ for (int i = 0; i < x.length(); i++)
+ {
+ b.writeShort(x.charAt(i));
+ }
+
+ // Write null terminator.
+ b.writeShort(0);
+ }
+ }
+ catch (IOException ex)
+ {
+ Unexpected.error(ex);
+ }
+ }
+}
diff --git a/gnu/CORBA/CDR/encapsulatedOutput.java b/gnu/CORBA/CDR/encapsulatedOutput.java
new file mode 100644
index 000000000..656bf066f
--- /dev/null
+++ b/gnu/CORBA/CDR/encapsulatedOutput.java
@@ -0,0 +1,138 @@
+/* EncapsulationOutput.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.CDR;
+
+import java.io.IOException;
+
+/**
+ * The encapsulated data, as they are defined by CORBA specification.
+ * This includes the extra 0 byte (Big endian) in the beginning.
+ * When written to the parent steam, the encapsulated data are preceeded
+ * by the data length in bytes.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class encapsulatedOutput
+ extends cdrOutput
+{
+ /**
+ * The Big Endian (most siginificant byte first flag).
+ */
+ public static final byte BIG_ENDIAN = 0;
+
+ /**
+ * The byte buffer.
+ */
+ public final aligningOutputStream buffer;
+
+ /**
+ * The stream, where the data are being encapsulated.
+ */
+ public final org.omg.CORBA.portable.OutputStream parent;
+
+ /**
+ * Create the EncapsulationOutput with the default buffer size
+ * and the given parent stream.
+ */
+ public encapsulatedOutput(org.omg.CORBA.portable.OutputStream _parent)
+ {
+ super();
+ buffer = new aligningOutputStream();
+ setOutputStream(buffer);
+ parent = _parent;
+ write(BIG_ENDIAN);
+ }
+
+ /**
+ * Set the alignment offset, if the index of the first byte in the
+ * stream is different from 0.
+ */
+ public void setOffset(int an_offset)
+ {
+ buffer.setOffset(an_offset);
+ }
+
+ /**
+ * Align the curretn position at the given natural boundary.
+ */
+ public void align(int boundary)
+ {
+ buffer.align(boundary);
+ }
+
+ /**
+ * Writes the content of the encapsulated output into the parent
+ * buffer.
+ */
+ public void close()
+ {
+ try
+ {
+ parent.write_long(buffer.size());
+ buffer.writeTo(parent);
+ }
+ catch (IOException ex)
+ {
+ throw new InternalError();
+ }
+ }
+
+ /**
+ * Return the input stream that reads the previously written values.
+ */
+ public org.omg.CORBA.portable.InputStream create_input_stream()
+ {
+ cdrBufInput in = new cdrBufInput(buffer.toByteArray());
+ in.setOrb(orb);
+
+ in.setVersion(giop);
+ in.setCodeSet(getCodeSet());
+
+ return in;
+ }
+
+ /**
+ * Resets (clears) the buffer.
+ */
+ public void reset()
+ {
+ buffer.reset();
+ setOutputStream(buffer);
+ }
+}
diff --git a/gnu/CORBA/CDR/testBinaryIO.java b/gnu/CORBA/CDR/testBinaryIO.java
new file mode 100644
index 000000000..f39d7fb55
--- /dev/null
+++ b/gnu/CORBA/CDR/testBinaryIO.java
@@ -0,0 +1,90 @@
+
+
+package gnu.CORBA.CDR;
+
+import junit.framework.TestCase;
+
+import java.io.IOException;
+
+import java.util.Arrays;
+import java.util.Random;
+
+import org.omg.CORBA.NO_IMPLEMENT;
+import org.omg.CORBA.ORB;
+
+/**
+ * Test the low level (binary) io routines.
+ *
+ * In some ORBs, provided by different vendors, this may not be implemented.
+ */
+public class testBinaryIO
+ extends TestCase
+{
+ ORB orb = ORB.init();
+ Random r = new Random();
+ private org.omg.CORBA.portable.InputStream in;
+ private org.omg.CORBA.portable.OutputStream out;
+
+ public void testBinary()
+ throws IOException
+ {
+ byte wByte = (byte) (r.nextInt(Byte.MAX_VALUE));
+ byte[] wBytes = new byte[ 24 + r.nextInt(24) ];
+ byte[] rBytes = new byte[ wBytes.length ];
+
+ for (int i = 0; i < wBytes.length; i++)
+ {
+ wBytes [ i ] = (byte) (r.nextInt(Byte.MAX_VALUE) - Byte.MAX_VALUE / 2);
+ }
+ ;
+
+ int ofs = r.nextInt(7);
+ int len = 4;
+
+ try
+ {
+ out = orb.create_any().create_output_stream();
+ out.write(wBytes);
+ in = out.create_input_stream();
+ in.read(rBytes);
+ assertTrue(Arrays.equals(rBytes, wBytes));
+ }
+ catch (NO_IMPLEMENT ex)
+ {
+ fail("write(byte []) not implemented by this vendor.");
+ }
+
+ try
+ {
+ out = orb.create_any().create_output_stream();
+ out.write(wBytes, ofs, len);
+ in = out.create_input_stream();
+ rBytes = new byte[ wBytes.length ];
+ in.read(rBytes, ofs, len);
+
+ boolean eq = true;
+ for (int i = ofs; i < ofs; i++)
+ {
+ if (rBytes [ i ] != wBytes [ i ])
+ eq = false;
+ }
+ assertTrue(eq);
+ }
+ catch (NO_IMPLEMENT ex)
+ {
+ fail("write(byte[], ofs, len) not implemented by this vendor.");
+ }
+
+ try
+ {
+ out = orb.create_any().create_output_stream();
+ out.write(wByte);
+ in = out.create_input_stream();
+ assertEquals(in.read(), wByte);
+ }
+ catch (NO_IMPLEMENT ex)
+ {
+ fail("write(int) not implemented by this vendor.");
+ }
+ }
+}
diff --git a/gnu/CORBA/Connected_objects.java b/gnu/CORBA/Connected_objects.java
new file mode 100644
index 000000000..2e04df31e
--- /dev/null
+++ b/gnu/CORBA/Connected_objects.java
@@ -0,0 +1,159 @@
+/* Connected_objects.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * The repository of objects, that have been connected to the
+ * {@link FunctionalORB} by the method
+ * {@link ORB.connect(org.omg.CORBA.Object)}.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class Connected_objects
+{
+ /**
+ * The free number to give for the next instance.
+ * This field is incremented each time the
+ * new collection of the connected objects is created.
+ * Each collection has its own unique instance number.
+ */
+ private static long free_object_number;
+
+ /**
+ * The map of the all connected objects, maps the object key to the
+ * object.
+ */
+ private Map objects = new TreeMap(new ByteArrayComparator());
+
+ /**
+ * Get the key of the stored object.
+ *
+ * @param object the stored object
+ *
+ * @return the key of the stored object, null if
+ * this object is not stored here.
+ */
+ public byte[] getKey(org.omg.CORBA.Object stored_object)
+ {
+ Map.Entry item;
+ Iterator iter = objects.entrySet().iterator();
+ while (iter.hasNext())
+ {
+ item = (Map.Entry) iter.next();
+ if (stored_object._is_equivalent((org.omg.CORBA.Object) item.getValue())
+ )
+ return (byte[]) item.getKey();
+ }
+ return null;
+ }
+
+ /**
+ * Add the new object to the repository. The object key is
+ * generated automatically.
+ *
+ * @param object the object to add.
+ */
+ public void add(org.omg.CORBA.Object object)
+ {
+ add(generateObjectKey(object), object);
+ }
+
+ /**
+ * Add the new object to the repository.
+ *
+ * @param key the object key.
+ * @param object the object to add.
+ */
+ public void add(byte[] key, org.omg.CORBA.Object object)
+ {
+ objects.put(key, object);
+ }
+
+ /**
+ * Get the stored object.
+ *
+ * @param key the key (in the byte array form).
+ *
+ * @return the matching object, null if none is matching.
+ */
+ public org.omg.CORBA.Object get(byte[] key)
+ {
+ return (org.omg.CORBA.Object) objects.get(key);
+ }
+
+ /**
+ * Remover the given object.
+ *
+ * @param object the object to remove.
+ */
+ public void remove(org.omg.CORBA.Object object)
+ {
+ byte[] key = getKey(object);
+ if (key != null)
+ objects.remove(key);
+ }
+
+ /**
+ * Generate the object key, unique in the currently
+ * running java virtual machine.
+ *
+ * The generated key includes the object class name
+ * and the absolute instance number.
+ *
+ * @return the generated key.
+ */
+ protected byte[] generateObjectKey(org.omg.CORBA.Object object)
+ {
+ return (object.getClass().getName() + ":" + getFreeInstanceNumber()).getBytes();
+ }
+
+ /**
+ * Get next free instance number.
+ */
+ private static synchronized long getFreeInstanceNumber()
+ {
+ long instance_number = free_object_number;
+ free_object_number++;
+ return instance_number;
+ }
+}
diff --git a/gnu/CORBA/ExceptionCreator.java b/gnu/CORBA/ExceptionCreator.java
new file mode 100644
index 000000000..724eb86d4
--- /dev/null
+++ b/gnu/CORBA/ExceptionCreator.java
@@ -0,0 +1,248 @@
+/* ExceptionCreator.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.CompletionStatusHelper;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.UNKNOWN;
+import org.omg.CORBA.UserException;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+
+/**
+ * Creates the objects from the agreed IDL names.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class ExceptionCreator
+{
+ /**
+ * The standard OMG prefix.
+ */
+ public static final String OMG_PREFIX = "omg.org/";
+
+ /**
+ * The standard java prefix.
+ */
+ public static final String JAVA_PREFIX = "org.omg.";
+
+ /**
+ * Create the system exception with the given idl name.
+ *
+ * @param idl the exception IDL name, must match the syntax
+ * "IDL:<class/name>:1.0".
+ * @param minor the exception minor code.
+ * @param completed the exception completion status.
+ *
+ * @return the created exception.
+ */
+ public static SystemException createSystemException(String idl, int minor,
+ CompletionStatus completed
+ )
+ {
+ try
+ {
+ String cl = toClassName(idl);
+ Class exClass = Class.forName(cl);
+
+ Constructor constructor =
+ exClass.getConstructor(new Class[]
+ {
+ String.class, int.class,
+ CompletionStatus.class
+ }
+ );
+
+ Object exception =
+ constructor.newInstance(new Object[]
+ {
+ " Remote exception " + idl + ", minor " +
+ minor + ", " + completed + ".",
+ new Integer(minor), completed
+ }
+ );
+
+ return (SystemException) exception;
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ return new UNKNOWN("Unsupported system exception", minor, completed);
+ }
+ }
+
+ /**
+ * Read the system exception from the given stream.
+ * @param input the CDR stream to read from.
+ * @return the exception that has been stored in the stream
+ * (IDL name, minor code and completion status).
+ */
+ public static SystemException readSystemException(InputStream input)
+ {
+ String idl = input.read_string();
+ int minor = input.read_ulong();
+ CompletionStatus status = CompletionStatusHelper.read(input);
+
+ SystemException exception =
+ ExceptionCreator.createSystemException(idl, minor, status);
+
+ return exception;
+ }
+
+ /**
+ * Reads the user exception, having the given Id, from the
+ * input stream. The id is expected to be in the form like
+ * 'IDL:test/org/omg/CORBA/ORB/communication/ourUserException:1.0'
+ *
+ * @param idl the exception idl name.
+ * @param input the stream to read from.
+ *
+ * @return the loaded exception.
+ * @return null if the helper class cannot be found.
+ */
+ public static UserException readUserException(String idl, InputStream input)
+ {
+ try
+ {
+ String holder = toHelperName(idl);
+
+ System.out.println("Helper " + holder);
+
+ Class holderClass = Class.forName(holder);
+
+ Method read =
+ holderClass.getMethod("read",
+ new Class[]
+ {
+ org.omg.CORBA.portable.InputStream.class
+ }
+ );
+
+ return (UserException) read.invoke(null, new Object[] { input });
+ }
+ catch (MARSHAL mex)
+ {
+ // This one is ok to throw
+ throw mex;
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ return null;
+ }
+ }
+
+ /**
+ * Writes the system exception data to CDR output stream.
+ *
+ * @param output a stream to write data to.
+ * @param ex an exception to write.
+ */
+ public static void writeSystemException(OutputStream output,
+ SystemException ex
+ )
+ {
+ String exIDL = toIDL(ex.getClass().getName());
+ output.write_string(exIDL);
+ output.write_ulong(ex.minor);
+ CompletionStatusHelper.write(output, ex.completed);
+ }
+
+ /**
+ * Converts teh given IDL name to class name.
+ *
+ * @param IDL the idl name.
+ *
+ */
+ protected static String toClassName(String IDL)
+ {
+ String s = IDL;
+ int a = s.indexOf(':') + 1;
+ int b = s.lastIndexOf(':');
+
+ s = IDL.substring(a, b);
+
+ if (s.startsWith(OMG_PREFIX))
+ s = JAVA_PREFIX + s.substring(OMG_PREFIX.length());
+
+ return s.replace('/', '.');
+ }
+
+ /**
+ * Gets the helper class name from the string like
+ * 'IDL:test/org/omg/CORBA/ORB/communication/ourUserException:1.0'
+ *
+ * @param IDL the idl name.
+ */
+ protected static String toHelperName(String IDL)
+ {
+ String s = IDL;
+ int a = s.indexOf(':') + 1;
+ int b = s.lastIndexOf(':');
+
+ s = IDL.substring(a, b);
+
+ if (s.startsWith(OMG_PREFIX))
+ s = JAVA_PREFIX + s.substring(OMG_PREFIX.length());
+
+ return s.replace('/', '.') + "Helper";
+ }
+
+ /**
+ * Convert the class name to IDL name.
+ *
+ * @param cn the class name.
+ *
+ * @return the idl name.
+ */
+ protected static String toIDL(String cn)
+ {
+ if (cn.startsWith(JAVA_PREFIX))
+ cn = cn.substring(JAVA_PREFIX.length());
+
+ cn = cn.replace('.', '/');
+
+ return "IDL:" + OMG_PREFIX + cn + ":1.0";
+ }
+}
diff --git a/gnu/CORBA/Functional_ORB.java b/gnu/CORBA/Functional_ORB.java
new file mode 100644
index 000000000..828e0bf9e
--- /dev/null
+++ b/gnu/CORBA/Functional_ORB.java
@@ -0,0 +1,882 @@
+/* FunctionalORB.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import gnu.CORBA.CDR.cdrBufInput;
+import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.GIOP.ErrorMessage;
+import gnu.CORBA.GIOP.MessageHeader;
+import gnu.CORBA.GIOP.ReplyHeader;
+import gnu.CORBA.GIOP.RequestHeader;
+import gnu.CORBA.NamingService.NamingServiceTransient;
+
+import org.omg.CORBA.BAD_INV_ORDER;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.OBJECT_NOT_EXIST;
+import org.omg.CORBA.ORBPackage.InvalidName;
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.UNKNOWN;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.CORBA.portable.InvokeHandler;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.CosNaming.NamingContextExt;
+import org.omg.CosNaming.NamingContextExtHelper;
+
+import java.applet.Applet;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.UnknownHostException;
+
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+import java.util.StringTokenizer;
+import java.util.TreeMap;
+
+/**
+ * The ORB implementation, capable to handle remote invocations on the
+ * registered object.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class Functional_ORB
+ extends Restricted_ORB
+{
+ /**
+ * The property of port, on that this ORB is listening for requests from clients.
+ * This class supports one port per ORB only.
+ */
+ public static final String LISTEN_ON = "gnu.classpath.CORBA.ListenOn";
+
+ /**
+ * The property, defining the IOR of the intial reference to resolve.
+ */
+ public static final String REFERENCE = "org.omg.CORBA.ORBInitRef";
+
+ /**
+ * The property, defining the port on that the default name service is running.
+ */
+ public static final String NS_PORT = "org.omg.CORBA.ORBInitialPort";
+
+ /**
+ * The property, defining the host on that the default name service is running.
+ */
+ public static final String NS_HOST = "org.omg.CORBA.ORBInitialHost";
+
+ /**
+ * The string, defining the naming service initial reference.
+ */
+ public static final String NAME_SERVICE = "NameService";
+
+ /**
+ * The address of the local host.
+ */
+ public final String LOCAL_HOST;
+
+ /**
+ * The map of the already conncted objects.
+ */
+ protected final Connected_objects connected_objects = new Connected_objects();
+
+ /**
+ * The maximal CORBA version, supported by this ORB. The default value
+ * 0 means that the ORB will not check the request version while trying
+ * to respond.
+ */
+ protected Version max_version;
+
+ /**
+ * Setting this value to false causes the ORB to shutdown after the
+ * latest serving operation is complete.
+ */
+ protected boolean running;
+
+ /**
+ * The map of the initial references.
+ */
+ private Map initial_references = new TreeMap();
+
+ /**
+ * The host, on that the name service is expected to be running.
+ */
+ private String ns_host;
+
+ /**
+ * The port, under that the ORB is listening for remote requests.
+ * In this implementation, all objects, served by this ORB, share
+ * the same port, 1126.
+ */
+ private int Port = 1126;
+
+ /**
+ * The port, on that the name service is expected to be running.
+ */
+ private int ns_port = 900;
+
+ /**
+ * Create the instance of the Functional ORB.
+ */
+ public Functional_ORB()
+ {
+ try
+ {
+ LOCAL_HOST = ns_host = InetAddress.getLocalHost().getHostAddress();
+ }
+ catch (UnknownHostException ex)
+ {
+ throw new BAD_OPERATION("Unable to resolve the local host address.");
+ }
+ }
+
+ /**
+ * If the max version is assigned, the orb replies with the error
+ * message if the request version is above the supported 1.2 version.
+ * This behavior is recommended by OMG, but not all implementations
+ * respond that error message by re-sending the request, encoded in the older
+ * version.
+ */
+ public void setMaxVersion(Version max_supported)
+ {
+ max_version = max_supported;
+ }
+
+ /**
+ * Get the maximal supported GIOP version or null if the version is
+ * not checked.
+ */
+ public Version getMaxVersion()
+ {
+ return max_version;
+ }
+
+ /**
+ * Set the port, on that the server is listening for the client requests.
+ * In this implementation, the server is listening at only one port,
+ * the default value being 1126.
+ *
+ * @param a_Port a port, on that the server is listening for requests.
+ *
+ * @throws BAD_INV_ORDER if the server has already been started. The port
+ * can only be changed when the server is not yet started.
+ */
+ public void setPort(int a_Port)
+ {
+ if (running)
+ throw new BAD_INV_ORDER("The server is running");
+ this.Port = a_Port;
+ }
+
+ /**
+ * Get the port, on that the server is listening for the client requests.
+ * In this implementation, the server is listening at only one port,
+ * the default value being 1126.
+ *
+ * @return the port.
+ */
+ public int getPort()
+ {
+ return Port;
+ }
+
+ /**
+ * Connect the given CORBA object to this ORB. After the object is
+ * connected, it starts receiving remote invocations via this ORB.
+ *
+ * @param object the object, must implement the {@link InvokeHandler})
+ * interface.
+ *
+ * @throws BAD_PARAM if the object does not implement the
+ * {@link InvokeHandler}).
+ */
+ public void connect(org.omg.CORBA.Object object)
+ {
+ connected_objects.add(object);
+
+ IOR ior = createIOR(object, connected_objects.getKey(object));
+ prepareObject(object, ior);
+ }
+
+ /**
+ * Connect the given CORBA object to this ORB, explicitly specifying
+ * the object key.
+ *
+ * @param object the object, must implement the {@link InvokeHandler})
+ * interface.
+ * @param key the object key, usually used to identify the object from
+ * remote side.
+ *
+ * @throws BAD_PARAM if the object does not implement the
+ * {@link InvokeHandler}).
+ */
+ public void connect(org.omg.CORBA.Object object, byte[] key)
+ {
+ prepareObject(object, createIOR(object, key));
+ connected_objects.add(key, object);
+ }
+
+ /**
+ * Destroy this server, releasing the occupied resources.
+ */
+ public void destroy()
+ {
+ super.destroy();
+ }
+
+ /**
+ * Disconnect the given CORBA object from this ORB. The object will be
+ * no longer receiving the remote invocations. In response to the
+ * remote invocation on this object, the ORB will send the
+ * exception {@link OBJECT_NOT_EXIST}. The object, however, is not
+ * destroyed and can receive the local invocations.
+
+ * @param object the object to disconnect.
+ */
+ public void disconnect(org.omg.CORBA.Object object)
+ {
+ connected_objects.remove(object);
+ }
+
+ /**
+ * Find the local object, connected to this ORB.
+ *
+ * @param ior the ior of the potentially local object.
+ *
+ * @return the local object, represented by the given IOR,
+ * or null if this is not a local connected object.
+ */
+ public org.omg.CORBA.Object find_local_object(IOR ior)
+ {
+ // Must be the same host.
+ if (!ior.Internet.host.equals(LOCAL_HOST))
+ return null;
+
+ // Must be the same port.
+ if (ior.Internet.port != Port)
+ return null;
+
+ return find_connected_object(ior.key);
+ }
+
+ /**
+ * List the initially available CORBA objects (services).
+ *
+ * @return a list of services.
+ *
+ * @see resolve_initial_references(String)
+ */
+ public String[] list_initial_services()
+ {
+ String[] refs = new String[ initial_references.size() ];
+ int p = 0;
+
+ Iterator iter = initial_references.keySet().iterator();
+ while (iter.hasNext())
+ refs [ p++ ] = (String) iter.next();
+
+ return refs;
+ }
+
+ /**
+ * Get the IOR reference string for the given object.
+ * The string embeds information about the object
+ * repository Id, its access key and the server internet
+ * address and port. With this information, the object
+ * can be found by another ORB, possibly located on remote
+ * computer.
+ *
+ * @param the CORBA object
+ * @return the object IOR representation.
+ *
+ * @throws BAD_PARAM if the object has not been previously
+ * connected to this ORB.
+ * @throws BAD_OPERATION in the unlikely case if the local host
+ * address cannot be resolved.
+ *
+ * @see string_to_object(String)
+ */
+ public String object_to_string(org.omg.CORBA.Object forObject)
+ {
+ // Handle the case when the object is known, but not local.
+ if (forObject instanceof ObjectImpl)
+ {
+ Delegate delegate = ((ObjectImpl) forObject)._get_delegate();
+ if (delegate instanceof Simple_delegate)
+ return ((Simple_delegate) delegate).getIor().toStringifiedReference();
+ }
+
+ // Handle the case when the object is local.
+ byte[] key = connected_objects.getKey(forObject);
+
+ if (key == null)
+ throw new BAD_PARAM("The object " + forObject +
+ " has not been previously connected to this ORB"
+ );
+
+ IOR ior = createIOR(forObject, key);
+
+ return ior.toStringifiedReference();
+ }
+
+ /**
+ * Find and return the easily accessible CORBA object, addressed
+ * by name.
+ *
+ * @param name the object name.
+ * @return the object
+ *
+ * @throws org.omg.CORBA.ORBPackage.InvalidName if the given name
+ * is not associated with the known object.
+ */
+ public org.omg.CORBA.Object resolve_initial_references(String name)
+ throws InvalidName
+ {
+ org.omg.CORBA.Object object = null;
+ try
+ {
+ object = (org.omg.CORBA.Object) initial_references.get(name);
+ if (object == null && name.equals(NAME_SERVICE))
+ {
+ object = getDefaultNameService();
+ if (object != null)
+ initial_references.put(NAME_SERVICE, object);
+ }
+ }
+ catch (Exception ex)
+ {
+ throw new InvalidName(name + ":" + ex.getMessage());
+ }
+ if (object != null)
+ return object;
+ else
+ throw new InvalidName("Not found: '" + name + "'");
+ }
+
+ /**
+ * Start the ORBs main working cycle
+ * (receive invocation - invoke on the local object - send response -
+ * wait for another invocation).
+ *
+ * The method only returns after calling {@link #shutdown(boolean)}.
+ */
+ public void run()
+ {
+ try
+ {
+ ServerSocket service = new ServerSocket(Port);
+ running = true;
+ while (running)
+ {
+ serve(service);
+ }
+ }
+ catch (IOException ex)
+ {
+ throw new BAD_OPERATION("Unable to open the server socket.");
+ }
+ }
+
+ /**
+ * Shutdown the ORB server.
+ *
+ * @param wait_for_completion if true, the current thread is
+ * suspended untile the shutdown process is complete.
+ */
+ public void shutdown(boolean wait_for_completion)
+ {
+ super.shutdown(wait_for_completion);
+ }
+
+ /**
+ * Find and return the CORBA object, addressed by the given
+ * IOR string representation. The object can (an usually is)
+ * located on a remote computer, possibly running a different
+ * (not necessary java) CORBA implementation.
+ *
+ * @param ior the object IOR representation string.
+ *
+ * @return the found CORBA object.
+ * @see object_to_string(org.omg.CORBA.Object)
+ */
+ public org.omg.CORBA.Object string_to_object(String an_ior)
+ {
+ IOR ior = IOR.parse(an_ior);
+ org.omg.CORBA.Object object = find_local_object(ior);
+ if (object == null)
+ {
+ ObjectImpl impl = stubFinder.search(this, ior);
+ try
+ {
+ if (impl._get_delegate() == null)
+ {
+ impl._set_delegate(new IOR_Delegate(this, ior));
+ }
+ }
+ catch (BAD_OPERATION ex)
+ {
+ // Some colaborants may throw this exception
+ // in response to the attempt to get the unset delegate.
+ impl._set_delegate(new IOR_Delegate(this, ior));
+ }
+
+ object = impl;
+ connected_objects.add(ior.key, impl);
+ }
+ return object;
+ }
+
+ /**
+ * Get the default naming service for the case when there no
+ * NameService entries.
+ */
+ protected org.omg.CORBA.Object getDefaultNameService()
+ {
+ if (initial_references.containsKey(NAME_SERVICE))
+ {
+ return (org.omg.CORBA.Object) initial_references.get(NAME_SERVICE);
+ }
+
+ IOR ior = new IOR();
+ ior.Id = NamingContextExtHelper.id();
+ ior.Internet.host = ns_host;
+ ior.Internet.port = ns_port;
+ ior.key = NamingServiceTransient.getDefaultKey();
+
+ IOR_contructed_object iorc = new IOR_contructed_object(this, ior);
+ NamingContextExt namer = NamingContextExtHelper.narrow(iorc);
+ initial_references.put(NAME_SERVICE, namer);
+ return namer;
+ }
+
+ /**
+ * Find and return the object, that must be previously connected
+ * to this ORB. Return null if no such object is available.
+ *
+ * @param key the object key.
+ *
+ * @return the connected object, null if none.
+ */
+ protected org.omg.CORBA.Object find_connected_object(byte[] key)
+ {
+ return connected_objects.get(key);
+ }
+
+ /**
+ * Set the ORB parameters. This method is normally called from
+ * {@link #init(Applet, Properties)}.
+ *
+ * @param app the current applet.
+ *
+ * @param props application specific properties, passed as the second
+ * parameter in {@link #init(Applet, Properties)}.
+ * Can be <code>null</code>.
+ */
+ protected void set_parameters(Applet app, Properties props)
+ {
+ useProperties(props);
+
+ String[][] para = app.getParameterInfo();
+ if (para != null)
+ {
+ for (int i = 0; i < para.length; i++)
+ {
+ if (para [ i ] [ 0 ].equals(LISTEN_ON))
+ Port = Integer.parseInt(para [ i ] [ 1 ]);
+
+ if (para [ i ] [ 0 ].equals(REFERENCE))
+ {
+ StringTokenizer st = new StringTokenizer(para [ i ] [ 1 ], "=");
+ initial_references.put(st.nextToken(),
+ string_to_object(st.nextToken())
+ );
+ }
+
+ if (para [ i ] [ 0 ].equals(NS_HOST))
+ ns_host = para [ i ] [ 1 ];
+
+ try
+ {
+ if (para [ i ] [ 0 ].equals(NS_PORT))
+ ns_port = Integer.parseInt(para [ i ] [ 1 ]);
+ }
+ catch (NumberFormatException ex)
+ {
+ throw new BAD_PARAM("Invalid " + NS_PORT +
+ "property, unable to parse '" +
+ props.getProperty(NS_PORT) + "'"
+ );
+ }
+ }
+ }
+ }
+
+ /**
+ * Set the ORB parameters. This method is normally called from
+ * {@link #init(String[], Properties)}.
+ *
+ * @param para the parameters, that were passed as the parameters
+ * to the <code>main(String[] args)</code> method of the current standalone
+ * application.
+ *
+ * @param props application specific properties that were passed
+ * as a second parameter in {@link init(String[], Properties)}).
+ * Can be <code>null</code>.
+ */
+ protected void set_parameters(String[] para, Properties props)
+ {
+ if (para.length > 1)
+ for (int i = 0; i < para.length - 1; i++)
+ {
+ if (para [ i ].endsWith("ListenOn"))
+ Port = Integer.parseInt(para [ i + 1 ]);
+
+ if (para [ i ].endsWith("ORBInitRef"))
+ {
+ StringTokenizer st = new StringTokenizer(para [ i + 1 ], "=");
+ initial_references.put(st.nextToken(),
+ string_to_object(st.nextToken())
+ );
+ }
+
+ if (para [ i ].endsWith("ORBInitialHost"))
+ ns_host = para [ i + 1 ];
+
+ try
+ {
+ if (para [ i ].endsWith("ORBInitialPort"))
+ ns_port = Integer.parseInt(para [ i + 1 ]);
+ }
+ catch (NumberFormatException ex)
+ {
+ throw new BAD_PARAM("Invalid " + para [ i ] +
+ "parameter, unable to parse '" +
+ props.getProperty(para [ i + 1 ]) + "'"
+ );
+ }
+ }
+
+ useProperties(props);
+ }
+
+ private IOR createIOR(org.omg.CORBA.Object forObject, byte[] key)
+ throws BAD_OPERATION
+ {
+ IOR ior = new IOR();
+ ior.key = key;
+ ior.Internet.port = Port;
+
+ if (forObject instanceof ObjectImpl)
+ {
+ ObjectImpl imp = (ObjectImpl) forObject;
+ if (imp._ids().length > 0)
+ ior.Id = imp._ids() [ 0 ];
+ }
+ if (ior.Id == null)
+ ior.Id = forObject.getClass().getName();
+
+ try
+ {
+ ior.Internet.host = InetAddress.getLocalHost().getHostAddress();
+ ior.Internet.port = Port;
+ }
+ catch (UnknownHostException ex)
+ {
+ throw new BAD_OPERATION("Cannot resolve the local host address");
+ }
+ return ior;
+ }
+
+ /**
+ * Prepare object for connecting it to this ORB.
+ *
+ * @param object the object being connected.
+ *
+ * @throws BAD_PARAM if the object does not implement the
+ * {@link InvokeHandler}).
+ */
+ private void prepareObject(org.omg.CORBA.Object object, IOR ior)
+ throws BAD_PARAM
+ {
+ if (!(object instanceof InvokeHandler))
+ throw new BAD_PARAM(object.getClass().getName() +
+ " does not implement InvokeHandler. "
+ );
+
+ // If no delegate is set, set the default delegate.
+ if (object instanceof ObjectImpl)
+ {
+ ObjectImpl impl = (ObjectImpl) object;
+ try
+ {
+ if (impl._get_delegate() == null)
+ {
+ impl._set_delegate(new Simple_delegate(this, ior));
+ }
+ }
+ catch (BAD_OPERATION ex)
+ {
+ // Some colaborants may throw this exception.
+ impl._set_delegate(new Simple_delegate(this, ior));
+ }
+ }
+ }
+
+ /**
+ * Write the response message.
+ *
+ * @param net_out the stream to write response into
+ * @param msh_request the request message header
+ * @param rh_request the request header
+ * @param handler the invocation handler that has been used to
+ * invoke the operation
+ * @param sysEx the system exception, thrown during the invocation,
+ * null if none.
+ *
+ * @throws IOException
+ */
+ private void respond_to_client(OutputStream net_out,
+ MessageHeader msh_request,
+ RequestHeader rh_request,
+ bufferedResponseHandler handler,
+ SystemException sysEx
+ )
+ throws IOException
+ {
+ // Set the reply header properties.
+ ReplyHeader reply = handler.reply_header;
+
+ if (sysEx != null)
+ reply.reply_status = reply.SYSTEM_EXCEPTION;
+ else if (handler.isExceptionReply())
+ reply.reply_status = reply.USER_EXCEPTION;
+ else
+ reply.reply_status = reply.NO_EXCEPTION;
+
+ reply.request_id = rh_request.request_id;
+
+ cdrBufOutput out = new cdrBufOutput(50 + handler.getBuffer().buffer.size());
+ out.setOrb(this);
+
+ out.setOffset(msh_request.getHeaderSize());
+
+ reply.write(out);
+
+ // Write the reply data from the handler.
+ handler.getBuffer().buffer.writeTo(out);
+
+ MessageHeader msh_reply = new MessageHeader();
+ msh_reply.version = msh_request.version;
+ msh_reply.message_type = msh_reply.REPLY;
+ msh_reply.message_size = out.buffer.size();
+
+ // Write the reply.
+ msh_reply.write(net_out);
+ out.buffer.writeTo(net_out);
+ net_out.flush();
+ }
+
+ /**
+ * Contains a single servicing step.
+ *
+ * @param serverSocket the ORB server socket.
+ *
+ * @throws MARSHAL
+ * @throws IOException
+ */
+ private void serve(ServerSocket serverSocket)
+ throws MARSHAL, IOException
+ {
+ Socket service = null;
+ try
+ {
+ service = serverSocket.accept();
+ service.setKeepAlive(true);
+
+ InputStream in = service.getInputStream();
+
+ MessageHeader msh_request = new MessageHeader();
+ msh_request.read(in);
+
+ if (max_version != null)
+ if (!msh_request.version.until_inclusive(max_version.major,
+ max_version.minor
+ )
+ )
+ {
+ OutputStream out = service.getOutputStream();
+ new ErrorMessage(max_version).write(out);
+ service.close();
+ return;
+ }
+
+ byte[] r = new byte[ msh_request.message_size ];
+
+ int n = 0;
+
+ reading:
+ while (n < r.length)
+ {
+ n = in.read(r, n, r.length - n);
+ }
+
+ if (msh_request.message_type == msh_request.REQUEST)
+ {
+ RequestHeader rh_request;
+
+ cdrBufInput cin = new cdrBufInput(r);
+ cin.setOrb(this);
+ cin.setVersion(msh_request.version);
+ cin.setOffset(msh_request.getHeaderSize());
+
+ rh_request = msh_request.create_request_header();
+
+ // Read header and auto set the charset.
+ rh_request.read(cin);
+
+ // in 1.2 and higher, align the current position at
+ // 8 octet boundary.
+ if (msh_request.version.since_inclusive(1, 2))
+ cin.align(8);
+
+ // find the target object.
+ InvokeHandler target =
+ (InvokeHandler) find_connected_object(rh_request.object_key);
+
+ // Prepare the reply header. This must be done in advance,
+ // as the size must be known for handler to set alignments
+ // correctly.
+ ReplyHeader rh_reply = msh_request.create_reply_header();
+
+ // TODO log errors about not existing objects and methods.
+ bufferedResponseHandler handler =
+ new bufferedResponseHandler(this, msh_request, rh_reply);
+
+ SystemException sysEx = null;
+
+ try
+ {
+ if (target == null)
+ throw new OBJECT_NOT_EXIST();
+ target._invoke(rh_request.operation, cin, handler);
+ }
+ catch (SystemException ex)
+ {
+ sysEx = ex;
+
+ org.omg.CORBA.portable.OutputStream ech =
+ handler.createExceptionReply();
+ ObjectCreator.writeSystemException(ech, ex);
+ }
+ catch (Exception except)
+ {
+ sysEx =
+ new UNKNOWN("Unknown", 2, CompletionStatus.COMPLETED_MAYBE);
+
+ org.omg.CORBA.portable.OutputStream ech =
+ handler.createExceptionReply();
+
+ ObjectCreator.writeSystemException(ech, sysEx);
+ }
+
+ // Write the response.
+ if (rh_request.isResponseExpected())
+ {
+ respond_to_client(service.getOutputStream(), msh_request,
+ rh_request, handler, sysEx
+ );
+ }
+ }
+ else
+ ;
+
+ // TODO log error: "Not a request message."
+ }
+ finally
+ {
+ if (service != null && !service.isClosed())
+ {
+ service.close();
+ }
+ }
+ }
+
+ private void useProperties(Properties props)
+ {
+ if (props != null)
+ {
+ if (props.containsKey(LISTEN_ON))
+ Port = Integer.parseInt(props.getProperty(LISTEN_ON));
+
+ if (props.containsKey(NS_HOST))
+ ns_host = props.getProperty(NS_HOST);
+
+ try
+ {
+ if (props.containsKey(NS_PORT))
+ ns_port = Integer.parseInt(props.getProperty(NS_PORT));
+ }
+ catch (NumberFormatException ex)
+ {
+ throw new BAD_PARAM("Invalid " + NS_PORT +
+ "property, unable to parse '" +
+ props.getProperty(NS_PORT) + "'"
+ );
+ }
+
+ Enumeration en = props.elements();
+ while (en.hasMoreElements())
+ {
+ String item = (String) en.nextElement();
+ if (item.equals(REFERENCE))
+ initial_references.put(item,
+ string_to_object(props.getProperty(item))
+ );
+ }
+ }
+ }
+}
diff --git a/gnu/CORBA/GIOP/CancelHeader.java b/gnu/CORBA/GIOP/CancelHeader.java
new file mode 100644
index 000000000..d40a32fe6
--- /dev/null
+++ b/gnu/CORBA/GIOP/CancelHeader.java
@@ -0,0 +1,70 @@
+/* CancelHeader.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.GIOP;
+
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * The message header for cancelling the request.
+ *
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public abstract class CancelHeader
+{
+ /**
+ * The Id of request being cancelled.
+ */
+ public int request_id;
+
+ /**
+ * Write the header.
+ *
+ * @param out a stream to write to.
+ */
+ public abstract void read(InputStream input);
+
+ /**
+ * Write the header.
+ *
+ * @param out a stream to write to.
+ */
+ public abstract void write(OutputStream output);
+}
diff --git a/gnu/CORBA/GIOP/CharSets_OSF.java b/gnu/CORBA/GIOP/CharSets_OSF.java
new file mode 100644
index 000000000..7690f3a00
--- /dev/null
+++ b/gnu/CORBA/GIOP/CharSets_OSF.java
@@ -0,0 +1,235 @@
+/* CharSets_OSF.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.GIOP;
+
+import java.nio.charset.Charset;
+
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * This class contains the codes, used to identify character sets
+ * in CORBA. These codes are defined in Open Software Foundation (OSF)
+ * code set registry
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class CharSets_OSF
+{
+ public static final int ASCII = 0x00010020;
+ public static final int ISO8859_1 = 0x00010001;
+ public static final int ISO8859_2 = 0x00010002;
+ public static final int ISO8859_3 = 0x00010003;
+ public static final int ISO8859_4 = 0x00010004;
+ public static final int ISO8859_5 = 0x00010005;
+ public static final int ISO8859_6 = 0x00010006;
+ public static final int ISO8859_7 = 0x00010007;
+ public static final int ISO8859_8 = 0x00010008;
+ public static final int ISO8859_9 = 0x00010009;
+ public static final int ISO8859_15_FDIS = 0x0001000F;
+ public static final int UTF8 = 0x05010001;
+ public static final int UTF16 = 0x00010109;
+ public static final int UCS2 = 0x00010100;
+ public static final int Cp1047 = 0x10020417;
+ public static final int Cp1250 = 0x100204E2;
+ public static final int Cp1251 = 0x100204E3;
+ public static final int Cp1252 = 0x100204E4;
+ public static final int Cp1253 = 0x100204E5;
+ public static final int Cp1254 = 0x100204E6;
+ public static final int Cp1255 = 0x100204E7;
+ public static final int Cp1256 = 0x100204E8;
+ public static final int Cp1257 = 0x100204E9;
+ public static final int Cp1363 = 0x10020553;
+ public static final int Cp1363C = 0x10020553;
+ public static final int Cp1381 = 0x10020565;
+ public static final int Cp1383 = 0x10020567;
+ public static final int Cp1386 = 0x1002056A;
+ public static final int Cp33722 = 0x100283BA;
+ public static final int Cp33722C = 0x100283BA;
+ public static final int Cp930 = 0x100203A2;
+ public static final int Cp943 = 0x100203AF;
+ public static final int Cp943C = 0x100203AF;
+ public static final int Cp949 = 0x100203B5;
+ public static final int Cp949C = 0x100203B5;
+ public static final int Cp950 = 0x100203B6;
+ public static final int Cp964 = 0x100203C4;
+ public static final int Cp970 = 0x100203CA;
+ public static final int EUC_JP = 0x00030010;
+ public static final int EUC_KR = 0x0004000A;
+ public static final int EUC_TW = 0x00050010;
+
+ /**
+ * The native character set for the narrow character.
+ */
+ public static final int NATIVE_CHARACTER = ISO8859_1;
+
+ /**
+ * The native character set for the wide character.
+ */
+ public static final int NATIVE_WIDE_CHARACTER = UTF16;
+
+ /**
+ * Table to convert from the code to string name.
+ */
+ private static Hashtable code_to_string;
+
+ /**
+ * Table to convert from the string name to code.
+ */
+ private static Hashtable string_to_code;
+
+ /**
+ * Get the charset code from its name.
+ *
+ * @return the charset code of 0 if not defined.
+ */
+ public static int getCode(String name)
+ {
+ if (string_to_code == null)
+ makeMap();
+
+ Integer code = (Integer) string_to_code.get(name);
+ return code == null ? 0 : code.intValue();
+ }
+
+ /**
+ * Get the charset name from its code.
+ *
+ * @return the code set name or nullfor the unknown code set.
+ */
+ public static String getName(int code)
+ {
+ if (code_to_string == null)
+ makeMap();
+ return (String) code_to_string.get(new Integer(code));
+ }
+
+ /**
+ * Get the list of supported char sets for that the CORBA codes are
+ * also known.
+ */
+ public static int[] getSupportedCharSets()
+ {
+ Set supported_sets = Charset.availableCharsets().keySet();
+ int[] supported = new int[ supported_sets.size() ];
+ Iterator iter = supported_sets.iterator();
+
+ int i = 0;
+ int code;
+ while (iter.hasNext())
+ {
+ code = getCode(iter.next().toString());
+ if (code > 0)
+ supported [ i++ ] = code;
+ }
+
+ // Truncate the unused part.
+ int[] f = new int[ i ];
+ System.arraycopy(supported, 0, f, 0, f.length);
+
+ return f;
+ }
+
+ /**
+ * Create a convertion map.
+ */
+ private static void makeMap()
+ {
+ code_to_string = new Hashtable();
+ string_to_code = new Hashtable();
+
+ // Put standard char sets.
+ put(ASCII, "US-ASCII");
+ put(ISO8859_1, "ISO-8859-1");
+ put(UTF16, "UTF-16");
+
+ // Put other known char sets.
+ put(ISO8859_2, "ISO-8859-2");
+ put(ISO8859_3, "ISO-8859-3");
+ put(ISO8859_4, "ISO-8859-4");
+ put(ISO8859_5, "ISO-8859-5");
+ put(ISO8859_6, "ISO-8859-6");
+ put(ISO8859_7, "ISO-8859-7");
+ put(ISO8859_8, "ISO-8859-8");
+ put(ISO8859_9, "ISO-8859-9");
+
+ put(UTF8, "UTF-8");
+ put(UCS2, "UCS-2");
+
+ put(ISO8859_15_FDIS, "ISO8859-15-FDIS");
+
+ put(Cp1047, "Cp1047");
+ put(Cp1250, "Cp1250");
+ put(Cp1251, "Cp1251");
+ put(Cp1252, "Cp1252");
+ put(Cp1253, "Cp1253");
+ put(Cp1254, "Cp1254");
+ put(Cp1255, "Cp1255");
+ put(Cp1256, "Cp1256");
+ put(Cp1257, "Cp1257");
+ put(Cp1363, "Cp1363");
+ put(Cp1363C, "Cp1363C");
+ put(Cp1381, "Cp1381");
+ put(Cp1383, "Cp1383");
+ put(Cp1386, "Cp1386");
+ put(Cp33722, "Cp33722");
+ put(Cp33722C, "Cp33722C");
+ put(Cp930, "Cp930");
+ put(Cp943, "Cp943");
+ put(Cp943C, "Cp943C");
+ put(Cp949, "Cp949");
+ put(Cp949C, "Cp949C");
+ put(Cp950, "Cp950");
+ put(Cp964, "Cp964");
+ put(Cp970, "Cp970");
+
+ put(EUC_JP, "EUC-JP");
+ put(EUC_KR, "EUC-KR");
+ put(EUC_TW, "EUC-TW");
+ }
+
+ private static void put(int code, String name)
+ {
+ Integer ic = new Integer(code);
+
+ code_to_string.put(ic, name);
+ string_to_code.put(name, ic);
+ }
+}
diff --git a/gnu/CORBA/GIOP/ErrorMessage.java b/gnu/CORBA/GIOP/ErrorMessage.java
new file mode 100644
index 000000000..fdba54f4b
--- /dev/null
+++ b/gnu/CORBA/GIOP/ErrorMessage.java
@@ -0,0 +1,95 @@
+/* ErrorMessage.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.GIOP;
+
+import gnu.CORBA.IOR;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import java.net.Socket;
+
+import org.omg.CORBA.MARSHAL;
+
+/**
+ * The error message is sent in response to the message, encoded
+ * in the unsupported version of the format or otherwise invalid.
+ *
+ * The error message consists from the message header only and
+ * is the same for GIOP 1.0, 1.1, 1.2 and 1.3.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class ErrorMessage
+ extends MessageHeader
+{
+ /**
+ * Create a new error message, setting the message field
+ * to the {@link MESSAGE_ERROR} and the version number to
+ * the given major and minor values.
+ */
+ public ErrorMessage(gnu.CORBA.Version msg_version)
+ {
+ version = msg_version;
+ message_type = MESSAGE_ERROR;
+ }
+
+ /**
+ * Send the error message to the given IOR address.
+ *
+ * @param to the IOR address (host and port, other fields
+ * are not used).
+ */
+ public void send(IOR ior)
+ {
+ try
+ {
+ Socket socket = new Socket(ior.Internet.host, ior.Internet.port);
+
+ OutputStream socketOutput = socket.getOutputStream();
+ write(socketOutput);
+ socketOutput.close();
+ socket.close();
+ }
+ catch (IOException ex)
+ {
+ throw new MARSHAL(ex.toString());
+ }
+ }
+}
diff --git a/gnu/CORBA/GIOP/MessageHeader.java b/gnu/CORBA/GIOP/MessageHeader.java
new file mode 100644
index 000000000..aef00e37a
--- /dev/null
+++ b/gnu/CORBA/GIOP/MessageHeader.java
@@ -0,0 +1,316 @@
+/* MessageHeader.java -- GIOP 1.0 message header.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.GIOP;
+
+import gnu.CORBA.Version;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import java.util.Arrays;
+
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * The GIOP message header.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class MessageHeader
+ implements IDLEntity
+{
+ /**
+ * Request message.
+ */
+ public static final byte REQUEST = 0;
+
+ /**
+ * Reply message
+ */
+ public static final byte REPLY = 1;
+
+ /**
+ * Cancel request message.
+ */
+ public static final byte CANCEL_REQUEST = 2;
+
+ /**
+ * Locate request message, used to check the server ability to
+ * process requests for the object reference.
+ * This message is also used to get the
+ * address where the object reference should be sent.
+ */
+ public static final byte LOCATE_REQUEST = 3;
+
+ /**
+ * Locate reply message, sent in response to the
+ * {@link #LocateRequest} message.
+ */
+ public static final byte LOCATE_REPLY = 4;
+
+ /**
+ * Instruction to close the connection.
+ */
+ public static final byte CLOSE_CONNECTION = 5;
+
+ /**
+ * Error report.
+ */
+ public static final byte MESSAGE_ERROR = 6;
+
+ /**
+ * The fragment messge, following the previous message that
+ * has more fragments flag set. Added in GIOP 1.1
+ */
+ public static final byte FRAGMENT = 7;
+
+ /**
+ * This must always be "GIOP".
+ */
+ public static final byte[] MAGIC = new byte[] { 'G', 'I', 'O', 'P' };
+
+ /**
+ * The message type names.
+ */
+ protected static String[] types =
+ new String[]
+ {
+ "Request", "Reply", "Cancel", "Locate request", "Locate reply",
+ "Close connection", "Error", "Fragment"
+ };
+
+ /**
+ * The GIOP version. Initialised to 1.0 .
+ */
+ public Version version;
+
+ /**
+ * The flags field, introduced since GIOP 1.1.
+ */
+ public byte flags = 0;
+
+ /**
+ * The message type.
+ */
+ public byte message_type = REQUEST;
+
+ /**
+ * The message size, excluding the message header.
+ */
+ public int message_size = 0;
+
+ /**
+ * Create an empty message header, corresponding version 1.0.
+ */
+ public MessageHeader()
+ {
+ version = new Version(1,0);
+ }
+
+ /**
+ * Create an empty message header, corresponding the given version.
+ *
+ * @param major the major message header version.
+ * @param minor the minot message header version.
+ */
+ public MessageHeader(int major, int minor)
+ {
+ version = new Version(major, minor);
+ }
+
+ /**
+ * Checks if the message is encoded in the Big Endian, most significant
+ * byte first.
+ */
+ public boolean isBigEndian()
+ {
+ return (flags & 0x1) == 0;
+ }
+
+ /**
+ * Get the size of the message header itself. So far, it is always 12 bytes.
+ */
+ public int getHeaderSize()
+ {
+ return 12;
+ }
+
+ /**
+ * Get the message type as string.
+ *
+ * @param type the message type as int (the field {@link message_type}).
+ *
+ * @return the message type as string.
+ */
+ public String getTypeString(int type)
+ {
+ try
+ {
+ return types [ type ];
+ }
+ catch (ArrayIndexOutOfBoundsException ex)
+ {
+ return "unknown type (" + type + ")";
+ }
+ }
+
+ /**
+ * Creates reply header, matching the message header version number.
+ *
+ * @return one of {@link gnu.CORBA.GIOP.v1_0.ReplyHeader},
+ * {@link gnu.CORBA.GIOP.v1_2.ReplyHeader}, etc - depending on
+ * the version number in this header.
+ */
+ public ReplyHeader create_reply_header()
+ {
+ if (version.since_inclusive(1, 2))
+ return new gnu.CORBA.GIOP.v1_2.ReplyHeader();
+ else
+ return new gnu.CORBA.GIOP.v1_0.ReplyHeader();
+ }
+
+ /**
+ * Creates request header, matching the message header version number.
+ *
+ * @return one of {@link gnu.CORBA.GIOP.v1_0.RequestHeader},
+ * {@link gnu.CORBA.GIOP.v1_2.RequestHeader}, etc - depending on
+ * the version number in this header.
+ */
+ public RequestHeader create_request_header()
+ {
+ if (version.since_inclusive(1, 2))
+ return new gnu.CORBA.GIOP.v1_2.RequestHeader();
+ else
+ return new gnu.CORBA.GIOP.v1_0.RequestHeader();
+ }
+
+ /**
+ * Create the cancel header, matching the message header version number.
+ */
+ public CancelHeader create_cancel_header()
+ {
+ return new gnu.CORBA.GIOP.v1_0.CancelHeader();
+ }
+
+ /**
+ * Create the error message.
+ */
+ public ErrorMessage create_error_message()
+ {
+ return new ErrorMessage(version);
+ }
+
+ /**
+ * Read the header from the stream.
+ *
+ * @param istream a stream to read from.
+ *
+ * @throws MARSHAL if this is not a GIOP 1.0 header.
+ */
+ public void read(java.io.InputStream istream)
+ throws MARSHAL
+ {
+ try
+ {
+ DataInputStream din = new DataInputStream(istream);
+
+ byte[] xMagic = new byte[ MAGIC.length ];
+ din.read(xMagic);
+ if (!Arrays.equals(xMagic, MAGIC))
+ throw new MARSHAL("Not a GIOP message");
+
+ version = Version.read_version(din);
+
+ flags = (byte) din.read();
+
+ /** TODO implement support for the little endian. */
+ if (!isBigEndian())
+ throw new MARSHAL("Little endian unsupported.");
+
+ message_type = (byte) din.read();
+ message_size = din.readInt();
+ }
+ catch (IOException ex)
+ {
+ throw new MARSHAL(ex.toString());
+ }
+ }
+
+ /**
+ * Get the short string summary of the message.
+ *
+ * @return a short message summary.
+ */
+ public String toString()
+ {
+ return "GIOP " + version + ", " + (isBigEndian() ? "Big" : "Little") +
+ " endian, " + getTypeString(message_type) + ", " + message_size +
+ " bytes. ";
+ }
+
+ /**
+ * Write the header to stream.
+ *
+ * @param out a stream to write into.
+ */
+ public void write(java.io.OutputStream out)
+ {
+ try
+ {
+ DataOutputStream dout = new DataOutputStream(out);
+
+ // Write magic sequence.
+ dout.write(MAGIC);
+
+ // Write version number.
+ version.write(dout);
+
+ dout.write(flags);
+
+ dout.write(message_type);
+ dout.writeInt(message_size);
+ }
+ catch (IOException ex)
+ {
+ throw new MARSHAL(ex.toString());
+ }
+ }
+}
diff --git a/gnu/CORBA/GIOP/ReplyHeader.java b/gnu/CORBA/GIOP/ReplyHeader.java
new file mode 100644
index 000000000..76c6df944
--- /dev/null
+++ b/gnu/CORBA/GIOP/ReplyHeader.java
@@ -0,0 +1,156 @@
+/* ReplyHeader.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.GIOP;
+
+import gnu.CORBA.CDR.cdrInput;
+import gnu.CORBA.CDR.cdrOutput;
+
+
+/**
+ * The header of the standard reply.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public abstract class ReplyHeader
+{
+ /**
+ * Reply status, if no exception occured.
+ */
+ public static final int NO_EXCEPTION = 0;
+
+ /**
+ * Reply status, user exception.
+ */
+ public static final int USER_EXCEPTION = 1;
+
+ /**
+ * Reply status, system exception.
+ */
+ public static final int SYSTEM_EXCEPTION = 2;
+
+ /**
+ * Reply status, if the client ORB must re - send
+ * the request to another destination. The body
+ * contains IOR.
+ */
+ public static final int LOCATION_FORWARD = 3;
+
+ /**
+ * Reply status, indicating that the target has permanently changed the
+ * address to the supplied IOR.
+ */
+ public static final int LOCATION_FORWARD_PERM = 4;
+
+ /**
+ * Reply status, indicating, that the ORB requires to resend the object
+ * address in the required addressing mode, contained as the reply body.
+ */
+ public static final int NEEDS_ADDRESSING_MODE = 5;
+
+ /**
+ * Empty array, indicating that no service context is available.
+ */
+ protected static final ServiceContext[] NO_CONTEXT = new ServiceContext[ 0 ];
+
+ /**
+ * The ORB service data.
+ */
+ public ServiceContext[] service_context = NO_CONTEXT;
+
+ /**
+ * The status of this reply, holds one of the reply status constants.
+ */
+ public int reply_status;
+
+ /**
+ * The Id of request into response of which this reply has been sent.
+ */
+ public int request_id;
+
+ /**
+ * Return the message status as a string.
+ */
+ public String getStatusString()
+ {
+ switch (reply_status)
+ {
+ case NO_EXCEPTION :
+ return "ok";
+
+ case USER_EXCEPTION :
+ return "user exception";
+
+ case SYSTEM_EXCEPTION :
+ return "system exception";
+
+ case LOCATION_FORWARD :
+ return "moved";
+
+ default :
+ return null;
+ }
+ }
+
+ /**
+ * Reads the header from the stream.
+ *
+ * @param in a stream to read from.
+ */
+ public abstract void read(cdrInput in);
+
+ /**
+ * Returns a short string representation.
+ *
+ * @return a string representation.
+ */
+ public String toString()
+ {
+ String status = getStatusString();
+ if (status == null)
+ status = "status " + reply_status;
+ return request_id + ", " + status;
+ }
+
+ /**
+ * Writes the header to the stream.
+ *
+ * @param out a stream to write into.
+ */
+ public abstract void write(cdrOutput out);
+}
diff --git a/gnu/CORBA/GIOP/RequestHeader.java b/gnu/CORBA/GIOP/RequestHeader.java
new file mode 100644
index 000000000..77ef6dd97
--- /dev/null
+++ b/gnu/CORBA/GIOP/RequestHeader.java
@@ -0,0 +1,161 @@
+/* RequestHeader.java -- The GIOP 1.0 request message.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.GIOP;
+
+import gnu.CORBA.CDR.cdrInput;
+import gnu.CORBA.CDR.cdrOutput;
+
+
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * The GIOP request message.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public abstract class RequestHeader
+ implements IDLEntity
+{
+ /**
+ * The currently free request id. This field is incremented
+ * each time the new request header is constructed. To facilitate
+ * error detection, the first free id is equal to 0x01234567
+ * (19088743).
+ */
+ private static int freeId = 0x01234567;
+
+ /**
+ * The operation being invoked (IDL scope name).
+ */
+ public String operation;
+
+ /**
+ * Identifies the object that is the target of the invocation.
+ */
+ public byte[] object_key;
+
+ /**
+ * A value identifying the requesting principal.
+ * Initialised into a single zero byte.
+ *
+ * @deprecated by CORBA 2.2.
+ */
+ public byte[] requesting_principal;
+
+ /**
+ * Contains the ORB service data being passed. Initialised as the
+ * zero size array by default.
+ */
+ public ServiceContext[] service_context = new ServiceContext[ 0 ];
+
+ /**
+ * This is used to associate the reply message with the
+ * previous request message. Initialised each time by the
+ * different value, increasing form 1 to Integer.MAX_VALUE.
+ */
+ public int request_id = getNextId();
+
+ /**
+ * If true, the response from the server is expected.
+ */
+ protected boolean response_expected = true;
+
+ /**
+ * Get next free request id. The value of the free request
+ * id starts from 0x02345678, it is incremented each time this
+ * function is called and is reset to 1 after reaching
+ * Integer.MAX_VALUE.
+ *
+ * @return the next free request id.
+ */
+ public static synchronized int getNextId()
+ {
+ int f = freeId;
+ if (freeId == Integer.MAX_VALUE)
+ freeId = 1;
+ else
+ freeId++;
+
+ return f;
+ }
+
+ /**
+ * Set if the sender expects any response to this message.
+ */
+ public abstract void setResponseExpected(boolean expected);
+
+ /**
+ * Return true if response is expected.
+ */
+ public abstract boolean isResponseExpected();
+
+ /**
+ * Converts an byte array into hexadecimal string values.
+ * Used in various toString() methods.
+ */
+ public String bytes(byte[] array)
+ {
+ StringBuffer b = new StringBuffer();
+ for (int i = 0; i < array.length; i++)
+ {
+ b.append(Integer.toHexString(array [ i ] & 0xFF));
+ b.append(" ");
+ }
+ return b.toString();
+ }
+
+ /**
+ * Reads the header from the stream.
+ *
+ * @param in a stream to read from.
+ */
+ public abstract void read(cdrInput in);
+
+ /**
+ * Return a string representation.
+ */
+ public abstract String toString();
+
+ /**
+ * Writes the header to the stream.
+ *
+ * @param out a stream to write into.
+ */
+ public abstract void write(cdrOutput out);
+}
diff --git a/gnu/CORBA/GIOP/ServiceContext.java b/gnu/CORBA/GIOP/ServiceContext.java
new file mode 100644
index 000000000..d14eabbc9
--- /dev/null
+++ b/gnu/CORBA/GIOP/ServiceContext.java
@@ -0,0 +1,131 @@
+/* ServiceContext.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.GIOP;
+
+import gnu.CORBA.CDR.cdrInput;
+import gnu.CORBA.CDR.cdrOutput;
+
+
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * Contains the ORB service data being passed.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class ServiceContext
+ implements IDLEntity
+{
+ /**
+ * The context data.
+ */
+ public byte[] context_data;
+
+ /**
+ * The context id.
+ */
+ public int context_id;
+
+ /**
+ * Read the context values from the stream.
+ *
+ * @param istream a stream to read from.
+ */
+ public static ServiceContext read(cdrInput istream)
+ {
+ int id = istream.read_ulong();
+
+ switch (id)
+ {
+ case cxCodeSet.ID :
+
+ cxCodeSet codeset = new cxCodeSet();
+ codeset.readContext(istream);
+ return codeset;
+
+ default :
+
+ ServiceContext ctx = new ServiceContext();
+ ctx.context_id = id;
+ ctx.context_data = istream.read_sequence();
+ return ctx;
+ }
+ }
+
+ /**
+ * Read a sequence of contexts from the input stream.
+ */
+ public static ServiceContext[] readSequence(cdrInput istream)
+ {
+ int size = istream.read_long();
+ ServiceContext[] value = new gnu.CORBA.GIOP.ServiceContext[ size ];
+ for (int i = 0; i < value.length; i++)
+ value [ i ] = read(istream);
+ return value;
+ }
+
+ /**
+ * Write the context values into the stream.
+ *
+ * @param ostream a stream to write the data to.
+ */
+ public void write(cdrOutput ostream)
+ {
+ ostream.write_ulong(context_id);
+ ostream.write_sequence(context_data);
+ }
+
+ /**
+ * Write the sequence of contexts into the input stream.
+ */
+ public static void writeSequence(cdrOutput ostream, ServiceContext[] value)
+ {
+ ostream.write_long(value.length);
+ for (int i = 0; i < value.length; i++)
+ value [ i ].write(ostream);
+ }
+
+ /**
+ * Return a string representation.
+ */
+ public String toString()
+ {
+ return "ctx "+context_id+", size "+context_data.length;
+ }
+}
diff --git a/gnu/CORBA/GIOP/cxCodeSet.java b/gnu/CORBA/GIOP/cxCodeSet.java
new file mode 100644
index 000000000..487a134a7
--- /dev/null
+++ b/gnu/CORBA/GIOP/cxCodeSet.java
@@ -0,0 +1,222 @@
+/* CodeSet_sctx.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.GIOP;
+
+import gnu.CORBA.CDR.cdrInput;
+import gnu.CORBA.CDR.cdrOutput;
+import gnu.CORBA.IOR;
+import gnu.CORBA.IOR.CodeSets_profile;
+
+import java.io.IOException;
+
+/**
+ * The code set service context. This context must be included in all
+ * messages that use wide characters.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class cxCodeSet
+ extends ServiceContext
+{
+ /**
+ * The context code sets id.
+ */
+ public static final int ID = 1;
+
+ /**
+ * The standard component to include in the messages.
+ */
+ public static final cxCodeSet STANDARD = new cxCodeSet();
+
+ /**
+ * The encoding, used to transfer the narrow (1 byte) character data.
+ * The default value is taken from {@link CharSets_OSF#NATIVE_CHARACTER}.
+ */
+ public int char_data = CharSets_OSF.NATIVE_CHARACTER;
+
+ /**
+ * The encoding, used to transfer the wide character data.
+ * The default value is taken from
+ * {@link CharSets_OSF#NATIVE_WIDE_CHARACTER}.
+ */
+ public int wide_char_data = CharSets_OSF.NATIVE_WIDE_CHARACTER;
+
+ /**
+ * Find and return the code set service context in the give
+ * contexts array. Returns {@link #STANDARD} if no code set
+ * context is present.
+ *
+ * @param contexts the array of contexts, can be null.
+ */
+ public static cxCodeSet find(ServiceContext[] contexts)
+ {
+ if (contexts != null)
+ for (int i = 0; i < contexts.length; i++)
+ {
+ if (contexts [ i ] instanceof cxCodeSet)
+ return (cxCodeSet) contexts [ i ];
+ }
+ return STANDARD;
+ }
+
+ /**
+ * Select the suitable encoding that is defined in the provided profile.
+ *
+ * TODO character encoding. Now the encoding can be set, but it is ignored.
+ * If you take this task, scan 'TODO character encoding' for
+ * relevant places.
+ */
+ public static cxCodeSet negotiate(IOR.CodeSets_profile profile)
+ {
+ if (profile.negotiated != null)
+ return profile.negotiated;
+
+ cxCodeSet use = new cxCodeSet();
+
+ use.char_data =
+ negotiate(profile.narrow, STANDARD.char_data, CharSets_OSF.ISO8859_1);
+
+ use.wide_char_data =
+ negotiate(profile.wide, STANDARD.wide_char_data, CharSets_OSF.UTF16);
+
+ profile.negotiated = use;
+
+ return use;
+ }
+
+ /**
+ * Read the context from the given stream. Does not read the
+ * code sets id.
+ */
+ public void readContext(cdrInput input)
+ {
+ cdrInput encap = input.read_encapsulation();
+
+ char_data = encap.read_ulong();
+ wide_char_data = encap.read_ulong();
+ }
+
+ /**
+ * Return a string representation.
+ */
+ public String toString()
+ {
+ return " Encoding: narrow " + name(char_data) + ", wide " +
+ name(wide_char_data) + ". ";
+ }
+
+ /**
+ * Write the context to the given stream, including the code
+ * sets id.
+ */
+ public void write(cdrOutput output)
+ {
+ output.write_ulong(ID);
+
+ cdrOutput enout = output.createEncapsulation();
+
+ enout.write_long(char_data);
+ enout.write_ulong(wide_char_data);
+
+ try
+ {
+ enout.close();
+ }
+ catch (IOException ex)
+ {
+ throw new InternalError();
+ }
+ }
+
+ /**
+ * Negotiate about the character encoding. Prefer our native encoding,
+ * if no, prefer IORs native encoding, if no, find any encoding,
+ * supported by both sides, if no, return the specified final decission.
+ *
+ * @param profile the component profile in IOR.
+ * @param our_native our native encoding
+ * @param final_decission the encoding that must be returned if no
+ * compromise is found.
+ *
+ * @return the resulted encoding.
+ */
+ protected static int negotiate(IOR.CodeSets_profile.CodeSet_component profile,
+ int our_native, int final_decission
+ )
+ {
+ // If our and IORs native sets match, use the native set.
+ if (profile.native_set == our_native)
+ return our_native;
+
+ // If the native sets do not match, but the IOR says it
+ // supports our native set, use our native set.
+ if (profile.conversion != null)
+ for (int i = 0; i < profile.conversion.length; i++)
+ {
+ if (our_native == profile.conversion [ i ])
+ return our_native;
+ }
+
+ // At this point, we suggest to use the IORs native set.
+ int[] allSupported = CharSets_OSF.getSupportedCharSets();
+
+ for (int s = 0; s < allSupported.length; s++)
+ if (allSupported [ s ] == profile.native_set)
+ return profile.native_set;
+
+ // Any compromise left?
+ if (profile.conversion != null)
+ for (int s = 0; s < allSupported.length; s++)
+ for (int i = 0; i < profile.conversion.length; i++)
+ if (allSupported [ s ] == profile.conversion [ i ])
+ return allSupported [ s ];
+
+ // Return the CORBA default char encoding.
+ return final_decission;
+ }
+
+ /**
+ * Conveniency method, used in toString()
+ */
+ private String name(int set)
+ {
+ return "0x" + Integer.toHexString(set) + " (" + CharSets_OSF.getName(set) +
+ ") ";
+ }
+}
diff --git a/gnu/CORBA/GIOP/v1_0/CancelHeader.java b/gnu/CORBA/GIOP/v1_0/CancelHeader.java
new file mode 100644
index 000000000..5b07e89ad
--- /dev/null
+++ b/gnu/CORBA/GIOP/v1_0/CancelHeader.java
@@ -0,0 +1,72 @@
+/* CancelHeader.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.GIOP.v1_0;
+
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * The message header for cancelling the request.
+ *
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class CancelHeader
+ extends gnu.CORBA.GIOP.CancelHeader
+{
+ /**
+ * Write the header.
+ *
+ * @param out a stream to write to.
+ */
+ public void read(InputStream input)
+ {
+ request_id = input.read_ulong();
+ }
+
+ /**
+ * Write the header.
+ *
+ * @param out a stream to write to.
+ */
+ public void write(OutputStream output)
+ {
+ output.write_ulong(request_id);
+ }
+}
diff --git a/gnu/CORBA/GIOP/v1_0/ReplyHeader.java b/gnu/CORBA/GIOP/v1_0/ReplyHeader.java
new file mode 100644
index 000000000..74512d617
--- /dev/null
+++ b/gnu/CORBA/GIOP/v1_0/ReplyHeader.java
@@ -0,0 +1,139 @@
+/* ReplyHeader.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.GIOP.v1_0;
+
+import gnu.CORBA.CDR.cdrInput;
+import gnu.CORBA.CDR.cdrOutput;
+import gnu.CORBA.GIOP.ServiceContext;
+import gnu.CORBA.GIOP.cxCodeSet;
+
+/**
+ * The header of the standard reply.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class ReplyHeader
+ extends gnu.CORBA.GIOP.ReplyHeader
+{
+ /**
+ * Return the message status as a string.
+ */
+ public String getStatusString()
+ {
+ switch (reply_status)
+ {
+ case NO_EXCEPTION :
+ return "ok";
+
+ case USER_EXCEPTION :
+ return "user exception";
+
+ case SYSTEM_EXCEPTION :
+ return "system exception";
+
+ case LOCATION_FORWARD :
+ return "moved";
+
+ default :
+ return null;
+ }
+ }
+
+ /**
+ * Get the string representation of all included contexts.
+ */
+ public String contexts()
+ {
+ StringBuffer b = new StringBuffer();
+ for (int i = 0; i < service_context.length; i++)
+ {
+ b.append(service_context [ i ].toString());
+ b.append(' ');
+ }
+ return b.toString();
+ }
+
+ /**
+ * Reads the header from the stream.
+ *
+ * Sets the code set of this stream to
+ * the code set, specfied in the header.
+ *
+ * @param in a stream to read from.
+ */
+
+ public void read(cdrInput in)
+ {
+ service_context = ServiceContext.readSequence(in);
+ request_id = in.read_ulong();
+ reply_status = in.read_ulong();
+
+ in.setCodeSet(cxCodeSet.find(service_context));
+ }
+
+ /**
+ * Returns a short string representation.
+ *
+ * @return a string representation.
+ */
+ public String toString()
+ {
+ String status = getStatusString();
+ if (status == null)
+ status = "status " + reply_status;
+ return request_id + ", " + status + " " + contexts();
+ }
+
+ /**
+ * Writes the header to the stream.
+ *
+ * Sets the code set of this stream to
+ * the code set, specfied in the header.
+ *
+ * @param out a stream to write into.
+ */
+ public void write(cdrOutput out)
+ {
+ ServiceContext.writeSequence(out, service_context);
+ out.write_ulong(request_id);
+ out.write_ulong(reply_status);
+
+ out.setCodeSet(cxCodeSet.find(service_context));
+ }
+}
diff --git a/gnu/CORBA/GIOP/v1_0/RequestHeader.java b/gnu/CORBA/GIOP/v1_0/RequestHeader.java
new file mode 100644
index 000000000..dd3e20349
--- /dev/null
+++ b/gnu/CORBA/GIOP/v1_0/RequestHeader.java
@@ -0,0 +1,157 @@
+/* RequestHeader.java -- The GIOP 1.0 request message.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.GIOP.v1_0;
+
+import gnu.CORBA.CDR.cdrInput;
+import gnu.CORBA.CDR.cdrOutput;
+
+import org.omg.CORBA.portable.IDLEntity;
+import gnu.CORBA.GIOP.ServiceContext;
+import gnu.CORBA.GIOP.cxCodeSet;
+
+/**
+ * The GIOP 1.0 request message.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class RequestHeader
+ extends gnu.CORBA.GIOP.RequestHeader
+ implements IDLEntity
+{
+ /**
+ * Creates an empty request header, setting requesting principal
+ * to byte[] { 'P' }.
+ */
+ public RequestHeader()
+ {
+ requesting_principal = new byte[] { 'P' };
+ }
+
+ /**
+ * Set if the sender expects any response to this message.
+ */
+ public void setResponseExpected(boolean expected)
+ {
+ response_expected = expected;
+ }
+
+ /**
+ * Return true if response is expected.
+ */
+ public boolean isResponseExpected()
+ {
+ return response_expected;
+ }
+
+ public String bytes(byte[] array)
+ {
+ StringBuffer b = new StringBuffer();
+ for (int i = 0; i < array.length; i++)
+ {
+ b.append(Integer.toHexString(array [ i ] & 0xFF));
+ b.append(" ");
+ }
+ return b.toString();
+ }
+
+ /**
+ * Get the string representation of all included contexts.
+ */
+ public String contexts()
+ {
+ StringBuffer b = new StringBuffer();
+ for (int i = 0; i < service_context.length; i++)
+ {
+ b.append(service_context [ i ].toString());
+ b.append(' ');
+ }
+ return b.toString();
+ }
+
+ /**
+ * Reads the header from the stream.
+ *
+ * Sets the code set of this stream to
+ * the code set, specfied in the header.
+ *
+ * @param in a stream to read from.
+ */
+ public void read(cdrInput in)
+ {
+ service_context = ServiceContext.readSequence(in);
+ request_id = in.read_ulong();
+ response_expected = in.read_boolean();
+ object_key = in.read_sequence();
+ operation = in.read_string();
+ requesting_principal = in.read_sequence();
+
+ in.setCodeSet(cxCodeSet.find(service_context));
+ }
+
+ /**
+ * Return a string representation.
+ */
+ public String toString()
+ {
+ return "Request " + request_id + ", call '" + operation + "' on " +
+ bytes(object_key) + ", " +
+ (response_expected ? "wait response" : "one way") + ", from " +
+ bytes(requesting_principal) + contexts();
+ }
+
+ /**
+ * Writes the header to the stream.
+ *
+ * Sets the code set of this stream to
+ * the code set, specfied in the header.
+ *
+ * @param out a stream to write into.
+ */
+ public void write(cdrOutput out)
+ {
+ ServiceContext.writeSequence(out, service_context);
+ out.write_ulong(request_id);
+ out.write_boolean(response_expected);
+ out.write_sequence(object_key);
+ out.write_string(operation);
+ out.write_sequence(requesting_principal);
+
+ out.setCodeSet(cxCodeSet.find(service_context));
+ }
+}
diff --git a/gnu/CORBA/GIOP/v1_2/ReplyHeader.java b/gnu/CORBA/GIOP/v1_2/ReplyHeader.java
new file mode 100644
index 000000000..87c97b3ec
--- /dev/null
+++ b/gnu/CORBA/GIOP/v1_2/ReplyHeader.java
@@ -0,0 +1,118 @@
+/* ReplyHeader.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.GIOP.v1_2;
+
+import gnu.CORBA.CDR.cdrInput;
+import gnu.CORBA.CDR.cdrOutput;
+import gnu.CORBA.GIOP.ServiceContext;
+import gnu.CORBA.GIOP.cxCodeSet;
+
+/**
+ * GIOP 1.2 reply header.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class ReplyHeader
+ extends gnu.CORBA.GIOP.v1_0.ReplyHeader
+{
+ /**
+ * Adds the standard encoding context.
+ */
+ public ReplyHeader()
+ {
+ service_context = new ServiceContext[] { cxCodeSet.STANDARD };
+ }
+
+ /**
+ * Return the message status as a string.
+ */
+ public String getStatusString()
+ {
+ String s = super.getStatusString();
+ if (s != null)
+ return s;
+ switch (reply_status)
+ {
+ case LOCATION_FORWARD_PERM :
+ return "moved permanently";
+
+ case NEEDS_ADDRESSING_MODE :
+ return "the alternative addressing mode required";
+
+ default :
+ return null;
+ }
+ }
+
+ /**
+ * Reads the header from the stream.
+ * The fields go in different order than in the previous GIOP versions.
+ *
+ * Sets the code set of this stream to
+ * the code set, specfied in the header.
+ *
+ * @param in a stream to read from.
+ */
+ public void read(cdrInput in)
+ {
+ request_id = in.read_ulong();
+ reply_status = in.read_ulong();
+ service_context = gnu.CORBA.GIOP.ServiceContext.readSequence(in);
+
+ in.setCodeSet(cxCodeSet.find(service_context));
+ }
+
+ /**
+ * Writes the header to the stream.
+ * The fields go in different order than in the previous GIOP versions.
+ *
+ * Sets the code set of this stream to
+ * the code set, specfied in the header.
+ *
+ * @param out a stream to write into.
+ */
+ public void write(cdrOutput out)
+ {
+ out.write_ulong(request_id);
+ out.write_ulong(reply_status);
+ gnu.CORBA.GIOP.ServiceContext.writeSequence(out, service_context);
+
+ out.setCodeSet(cxCodeSet.find(service_context));
+ }
+}
diff --git a/gnu/CORBA/GIOP/v1_2/RequestHeader.java b/gnu/CORBA/GIOP/v1_2/RequestHeader.java
new file mode 100644
index 000000000..081bfcaf0
--- /dev/null
+++ b/gnu/CORBA/GIOP/v1_2/RequestHeader.java
@@ -0,0 +1,211 @@
+/* RequestHeader.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.GIOP.v1_2;
+
+import gnu.CORBA.CDR.cdrInput;
+import gnu.CORBA.CDR.cdrOutput;
+import gnu.CORBA.GIOP.ServiceContext;
+import gnu.CORBA.GIOP.cxCodeSet;
+
+import java.io.IOException;
+
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.NO_IMPLEMENT;
+
+/**
+ * The GIOP 1.2 request header. The GIOP 1.1 request header
+ * is the same as GIOP 1.0 request header, if taking the
+ * alignment into consideration.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class RequestHeader
+ extends gnu.CORBA.GIOP.v1_0.RequestHeader
+{
+ /**
+ * Indicates that the object is addressed by the object key.
+ */
+ public static final short KeyAddr = 0;
+
+ /**
+ * Indicates that the object is addressed by the IOP tagged profile.
+ */
+ public static final short ProfileAddr = 1;
+
+ /**
+ * Indicates that the objec is addressed by IOR addressing info.
+ */
+ public static final short ReferenceAddr = 2;
+
+ /**
+ * The response flags of the header. By default, the flags are initialised
+ * by value 0x3 (response expected).
+ */
+ public byte response_flags = 3;
+
+ /**
+ * The used addressing method.
+ */
+ public short AddressingDisposition;
+
+ /**
+ * Adds the standard encoding context.
+ */
+ public RequestHeader()
+ {
+ service_context = new ServiceContext[] { cxCodeSet.STANDARD };
+ }
+
+ /**
+ * Set if the sender expects any response to this message.
+ * Clears or sets the 2 lower bits of flags
+ * (0 - not expected, 0x3 - expected).
+ */
+ public void setResponseExpected(boolean expected)
+ {
+ response_expected = expected;
+
+ if (expected)
+ response_flags = (byte) (response_flags | 0x3);
+ else
+ response_flags = (byte) (response_flags & (~0x3));
+ }
+
+ /**
+ * Return true if response is expected.
+ *
+ * @return true if the two lowest bits of the flags are set or
+ * the response expected is explicitly set to true.
+ */
+ public boolean isResponseExpected()
+ {
+ return response_expected || ((response_flags & 0x3) == 0x3);
+ }
+
+ /**
+ * Read the header from the given stream.
+ *
+ * @param in a stream to read from.
+ */
+ public void read(cdrInput in)
+ {
+ try
+ {
+ request_id = in.read_ulong();
+ response_flags = (byte) in.read();
+
+ // Skip 3 reserved octets:
+ in.skip(3);
+
+ // Read target address.
+ AddressingDisposition = in.read_ushort();
+
+ switch (AddressingDisposition)
+ {
+ case KeyAddr :
+ object_key = in.read_sequence();
+ break;
+
+ // TODO FIXME add other addressing methods.
+ case ProfileAddr :
+ throw new NO_IMPLEMENT("Object addressing by IOP tagged profile");
+
+ case ReferenceAddr :
+ throw new NO_IMPLEMENT("Object addressing by by IOR addressing info");
+
+ default :
+ throw new MARSHAL("Unknow addressing method in request, " +
+ AddressingDisposition
+ );
+ }
+
+ operation = in.read_string();
+ service_context = gnu.CORBA.GIOP.ServiceContext.readSequence(in);
+
+ // No requesting principal in this new format.
+ in.setCodeSet(cxCodeSet.find(service_context));
+ }
+ catch (IOException ex)
+ {
+ throw new MARSHAL(ex.toString());
+ }
+ }
+
+ /**
+ * Return a string representation.
+ */
+ public String toString()
+ {
+ return "Request " + request_id + ", call '" + operation + "' on " +
+ bytes(object_key) + ", " +
+ (response_expected ? "wait response" : "one way") +
+ " addressed by " + " method " + AddressingDisposition + "." +
+ contexts();
+ }
+
+ /**
+ * Write the header to the given stream.
+ *
+ * @param out a stream to write into.
+ */
+ public void write(cdrOutput out)
+ {
+ out.write_ulong(request_id);
+
+ out.write(response_flags);
+
+ // Skip 3 reserved octets:
+ out.write(0);
+ out.write(0);
+ out.write(0);
+
+ // Write addressing disposition from IOR.
+ // TODO FIXME add other addressing methods.
+ out.write_ushort(KeyAddr);
+
+ out.write_sequence(object_key);
+
+ out.write_string(operation);
+
+ ServiceContext.writeSequence(out, service_context);
+
+ // No requesting principal in this new format.
+ out.setCodeSet(cxCodeSet.find(service_context));
+ }
+}
diff --git a/gnu/CORBA/IOR.java b/gnu/CORBA/IOR.java
new file mode 100644
index 000000000..98538593a
--- /dev/null
+++ b/gnu/CORBA/IOR.java
@@ -0,0 +1,529 @@
+/* IOR.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import gnu.CORBA.CDR.cdrBufInput;
+import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.CDR.cdrInput;
+import gnu.CORBA.CDR.cdrOutput;
+import gnu.CORBA.GIOP.CharSets_OSF;
+import gnu.CORBA.GIOP.cxCodeSet;
+
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.ULongSeqHelper;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+/**
+ * The implementaton of the Interoperable Object Reference (IOR).
+ * IOR can be compared with the Internet address for a web page,
+ * it provides means to locate the CORBA service on the web.
+ * IOR contains the host address, port number, the object identifier
+ * (key) inside the server, the communication protocol version,
+ * supported charsets and so on.
+ *
+ * Ths class provides method for encoding and
+ * decoding the IOR information from/to the stringified references,
+ * usually returned by {@link org.omg.CORBA.ORB#String object_to_string()}.
+ *
+ * TODO the current implementation supports the IOP version 1.0 only.
+ * TODO Little Endian (lower byte first) encoding, if anybody needs it.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ *
+ * @see org.mog.CORBA.Object.object_to_string(Object forObject)
+ * @see string_to_object(String IOR)
+ */
+public class IOR
+{
+ /**
+ * The code sets profile.
+ */
+ public static class CodeSets_profile
+ {
+ /**
+ * The code set component.
+ */
+ public static class CodeSet_component
+ {
+ /**
+ * The conversion code sets.
+ */
+ public int[] conversion;
+
+ /**
+ * The native code set.
+ */
+ public int native_set;
+
+ /**
+ * Read from the CDR stream.
+ */
+ public void read(org.omg.CORBA.portable.InputStream in)
+ {
+ native_set = in.read_ulong();
+ conversion = ULongSeqHelper.read(in);
+ }
+
+ /**
+ * Get a string representation.
+ */
+ public String toString()
+ {
+ StringBuffer b = new StringBuffer();
+ b.append("native " + name(native_set));
+ if (conversion != null && conversion.length > 0)
+ {
+ b.append(" conversion ");
+ for (int i = 0; i < conversion.length; i++)
+ {
+ b.append(name(conversion [ i ]));
+ b.append(' ');
+ }
+ }
+ b.append(' ');
+ return b.toString();
+ }
+
+ /**
+ * Write into CDR stream.
+ */
+ public void write(org.omg.CORBA.portable.OutputStream out)
+ {
+ out.write_long(native_set);
+ ULongSeqHelper.write(out, conversion);
+ }
+
+ private String name(int set)
+ {
+ return "0x" + Integer.toHexString(set) + " (" +
+ CharSets_OSF.getName(set) + ") ";
+ }
+ }
+
+ /**
+ * The agreed tag for the Codesets profile.
+ */
+ public static final int TAG_CODE_SETS = 1;
+
+ /**
+ * Information about narrow character encoding (TCS-C).
+ */
+ public CodeSet_component narrow = new CodeSet_component();
+
+ /**
+ * About wide character encoding (TCS-W).
+ */
+ public CodeSet_component wide = new CodeSet_component();
+
+ /**
+ * The negotiated coding result for this IOR. Saves time, requred for
+ * negotiation computations.
+ */
+ public cxCodeSet negotiated;
+
+ /**
+ * Read the code set profile information from the given input stream.
+ *
+ * @param profile a stream to read from.
+ */
+ public void read(cdrInput profile)
+ {
+ cdrBufInput encapsulation = profile.read_encapsulation();
+ narrow.read(encapsulation);
+ wide.read(encapsulation);
+ }
+
+ /**
+ * Returns a string representation.
+ */
+ public String toString()
+ {
+ return "Narrow char: " + narrow + ", Wide char: " + wide;
+ }
+
+ /**
+ * Write the code set profile information into the given input stream.
+ *
+ * @param profile a stream to write into.
+ */
+ public void write(cdrOutput profile)
+ {
+ cdrOutput encapsulation = profile.createEncapsulation();
+ narrow.write(encapsulation);
+ wide.write(encapsulation);
+ try
+ {
+ encapsulation.close();
+ }
+ catch (IOException ex)
+ {
+ throw new InternalError();
+ }
+ }
+ }
+
+ /**
+ * The internet profile.
+ */
+ public static class Internet_profile
+ {
+ /**
+ * The agreed tag for the Internet profile.
+ */
+ public static final int TAG_INTERNET_IOP = 0;
+
+ /**
+ * The host.
+ */
+ public String host;
+
+ /**
+ * The IIOP version (initialised to 1.2 by default).
+ */
+ public Version version = new Version(1, 2);
+
+ /**
+ * The port.
+ */
+ public int port;
+
+ /**
+ * Return the human readable representation.
+ */
+ public String toString()
+ {
+ StringBuffer b = new StringBuffer();
+ b.append(host);
+ b.append(":");
+ b.append(port);
+ b.append(" (v");
+ b.append(version);
+ b.append(")");
+ return b.toString();
+ }
+ }
+
+ /**
+ * The standard minor code, indicating that the string to object
+ * converstio has failed due non specific reasons.
+ */
+ public static final int FAILED = 10;
+
+ /**
+ * The code sets profile of this IOR.
+ */
+ public CodeSets_profile CodeSets = new CodeSets_profile();
+
+ /**
+ * The internet profile of this IOR.
+ */
+ public Internet_profile Internet = new Internet_profile();
+
+ /**
+ * The object repository Id.
+ */
+ public String Id;
+
+ /**
+ * The additional tagged components, encapsulated in
+ * the byte arrays. They are only supported by the
+ * later versions, than currently implemented.
+ */
+ public byte[][] extra;
+
+ /**
+ * The object key.
+ */
+ public byte[] key;
+
+ /**
+ * Create an empty instance, initialising the code sets to default
+ * values.
+ */
+ public IOR()
+ {
+ int[] supported = CharSets_OSF.getSupportedCharSets();
+
+ CodeSets.narrow.native_set = CharSets_OSF.NATIVE_CHARACTER;
+ CodeSets.narrow.conversion = supported;
+
+ CodeSets.wide.native_set = CharSets_OSF.NATIVE_WIDE_CHARACTER;
+ CodeSets.wide.conversion = supported;
+ }
+
+ /**
+ * Parse the provided stringifed reference.
+ *
+ * @param stringified_reference, in the form of
+ * IOR:nnnnnn.....
+ *
+ * @return the parsed IOR
+ *
+ * @throws BAD_PARAM, minor code 10, if the IOR cannot be parsed.
+ *
+ * TODO corballoc and other alternative formats.
+ */
+ public static IOR parse(String stringified_reference)
+ throws BAD_PARAM
+ {
+ try
+ {
+ if (!stringified_reference.startsWith("IOR:"))
+ throw new BAD_PARAM("The string refernce must start with IOR:",
+ FAILED, CompletionStatus.COMPLETED_NO
+ );
+
+ IOR r = new IOR();
+
+ ByteArrayOutputStream buf = new ByteArrayOutputStream();
+ String x = stringified_reference;
+ x = x.substring(x.indexOf(":") + 1);
+
+ char cx;
+
+ for (int i = 0; i < x.length(); i = i + 2)
+ {
+ cx = (char) Integer.parseInt(x.substring(i, i + 2), 16);
+ buf.write(cx);
+ }
+
+ cdrBufInput cdr = new cdrBufInput(buf.toByteArray());
+
+ r._read(cdr);
+ return r;
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ throw new BAD_PARAM(ex + " while parsing " + stringified_reference,
+ FAILED, CompletionStatus.COMPLETED_NO
+ );
+ }
+ }
+
+ /**
+ * Read the IOR from the provided input stream.
+ *
+ * @param c a stream to read from.
+ * @throws IOException if the stream throws it.
+ * @throws BAD_PARAM, minor code 10, if the stream contents
+ * requires to switch into currently unsupported Little Endian mode.
+ *
+ * FIXME TODO Implement Little Endian mode.
+ */
+ public void _read(cdrInput c)
+ throws IOException, BAD_PARAM
+ {
+ int endian;
+
+ endian = c.read_long();
+ if (endian != 0)
+ throw new BAD_PARAM("Little endian is not yet supported", FAILED,
+ CompletionStatus.COMPLETED_NO
+ );
+ _read_no_endian(c);
+ }
+
+ /**
+ * Read the IOR from the provided input stream, not reading
+ * the endian data at the beginning of the stream. The IOR is
+ * thansferred in this form in
+ * {@link write_Object(org.omg.CORBA.Object)}.
+ *
+ * @param c a stream to read from.
+ * @throws IOException if the stream throws it.
+ * @throws BAD_PARAM, minor code 10, if the stream contents
+ * requires to switch into currently unsupported Little Endian mode.
+ */
+ public void _read_no_endian(cdrInput c)
+ throws IOException, BAD_PARAM
+ {
+ Id = c.read_string();
+
+ int n_profiles = c.read_long();
+
+ for (int i = 0; i < n_profiles; i++)
+ {
+ int tag = c.read_long();
+ cdrBufInput profile = c.read_encapsulation();
+
+ if (tag == Internet_profile.TAG_INTERNET_IOP)
+ {
+ Internet = new Internet_profile();
+ Internet.version = Version.read_version(profile);
+ Internet.host = profile.read_string();
+ Internet.port = profile.gnu_read_ushort();
+
+ int lk = profile.read_long();
+ key = new byte[ lk ];
+ profile.read(key);
+
+ // Read tagged components.
+ int n_components = 0;
+
+ try
+ {
+ n_components = profile.read_long();
+
+ for (int t = 0; t < n_components; t++)
+ {
+ int ctag = profile.read_long();
+
+ if (ctag == CodeSets_profile.TAG_CODE_SETS)
+ {
+ CodeSets.read(profile);
+ }
+ }
+ }
+ catch (Unexpected ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ }
+ }
+
+ /**
+ * Write this IOR record to the provided CDR stream.
+ * This procedure writes the zero (Big Endian) marker first.
+ */
+ public void _write(cdrOutput out)
+ {
+ // Always use Big Endian.
+ out.write(0);
+ _write_no_endian(out);
+ }
+
+ /**
+ * Write this IOR record to the provided CDR stream. The procedure
+ * writed data in Big Endian, but does NOT add any endian marker
+ * to the beginning.
+ */
+ public void _write_no_endian(cdrOutput out)
+ {
+ try
+ {
+ // Write repository id.
+ out.write_string(Id);
+
+ // Always one profile.
+ out.write_long(1);
+
+ // It is the Internet profile.
+ out.write_long(Internet_profile.TAG_INTERNET_IOP);
+
+ // Need to write the Internet profile into the separate
+ // stream as we must know the size in advance.
+ cdrOutput b = out.createEncapsulation();
+
+ Internet.version.write(b);
+ b.write_string(Internet.host);
+
+ b.write_ushort((short) (Internet.port & 0xFFFF));
+
+ // Write the object key.
+ b.write_long(key.length);
+ b.write(key);
+
+ // One tagged component.
+ b.write_long(1);
+
+ b.write_long(CodeSets.TAG_CODE_SETS);
+ CodeSets.write(b);
+
+ b.close();
+ }
+ catch (IOException ex)
+ {
+ Unexpected.error(ex);
+ }
+ }
+
+ /**
+ * Returns a human readable string representation of this IOR object.
+ */
+ public String toString()
+ {
+ StringBuffer b = new StringBuffer();
+ b.append(Id);
+ b.append(" at ");
+ b.append(Internet);
+ b.append(" Key ");
+
+ for (int i = 0; i < key.length; i++)
+ {
+ b.append(Integer.toHexString(key [ i ] & 0xFF));
+ }
+
+ b.append(" ");
+ b.append(CodeSets);
+
+ return b.toString();
+ }
+
+ /**
+ * Returs a stringified reference.
+ *
+ * @return a newly constructed stringified reference.
+ */
+ public String toStringifiedReference()
+ {
+ cdrBufOutput out = new cdrBufOutput();
+
+ _write(out);
+
+ StringBuffer b = new StringBuffer("IOR:");
+
+ byte[] binary = out.buffer.toByteArray();
+ String s;
+
+ for (int i = 0; i < binary.length; i++)
+ {
+ s = Integer.toHexString(binary [ i ] & 0xFF);
+ if (s.length() == 1)
+ b.append('0');
+ b.append(s);
+ }
+
+ return b.toString();
+ }
+}
diff --git a/gnu/CORBA/IOR_Delegate.java b/gnu/CORBA/IOR_Delegate.java
new file mode 100644
index 000000000..799704dc5
--- /dev/null
+++ b/gnu/CORBA/IOR_Delegate.java
@@ -0,0 +1,282 @@
+/* gnuDelegate.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import gnu.CORBA.CDR.cdrBufInput;
+import gnu.CORBA.GIOP.ReplyHeader;
+
+import org.omg.CORBA.Context;
+import org.omg.CORBA.ContextList;
+import org.omg.CORBA.ExceptionList;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.NVList;
+import org.omg.CORBA.NamedValue;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Request;
+import org.omg.CORBA.portable.ApplicationException;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.RemarshalException;
+
+import java.io.IOException;
+
+/**
+ * The Classpath implementation of the {@link Delegate} functionality in the
+ * case, when the object was constructed from an IOR object. The IOR can be
+ * constructed from the stringified object reference.
+ *
+ * There is an different instance of this delegate for each CORBA object.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class IOR_Delegate
+ extends Simple_delegate
+{
+ /**
+ * Contructs an instance of object using the given IOR.
+ */
+ public IOR_Delegate(ORB an_orb, IOR an_ior)
+ {
+ super(an_orb, an_ior);
+ }
+
+ /**
+ * Creates the request to invoke the method on this object.
+ *
+ * @param target the object, for that the operation must be invoked.
+ * @param context context (null allowed)
+ * @param operation the method name
+ * @param parameters the method parameters
+ * @param returns the return value holder
+ * @param exceptions the exceptions that can be thrown by the method
+ * @param ctx_list the context list (null allowed)
+ *
+ * @return the created request.
+ */
+ public Request create_request(org.omg.CORBA.Object target, Context context,
+ String operation, NVList parameters,
+ NamedValue returns
+ )
+ {
+ gnuRequest request = new gnuRequest();
+
+ request.setIor(getIor());
+ request.set_target(target);
+
+ request.setOperation(operation);
+ request.set_args(parameters);
+ request.m_context = context;
+ request.set_result(returns);
+ request.setORB(orb);
+
+ return request;
+ }
+
+ /**
+ * Creates the request to invoke the method on this object.
+ *
+ * @param target the object, for that the operation must be invoked.
+ * @param context context (null allowed)
+ * @param operation the method name
+ * @param parameters the method parameters
+ * @param returns the return value holder
+ *
+ * @return the created request.
+ */
+ public Request create_request(org.omg.CORBA.Object target, Context context,
+ String operation, NVList parameters,
+ NamedValue returns, ExceptionList exceptions,
+ ContextList ctx_list
+ )
+ {
+ gnuRequest request = new gnuRequest();
+
+ request.setIor(ior);
+ request.set_target(target);
+
+ request.setOperation(operation);
+ request.set_args(parameters);
+ request.m_context = context;
+ request.set_result(returns);
+ request.set_exceptions(exceptions);
+ request.set_context_list(ctx_list);
+ request.setORB(orb);
+
+ return request;
+ }
+
+ /**
+ * Invoke operation on the given object, writing parameters to the given
+ * output stream.
+ *
+ * @param target the target object.
+ * @param output the output stream, previously returned by
+ * {@link #request(org.omg.CORBA.Object, String, boolean)}.
+ *
+ * @return the input stream, to read the response from or null for a
+ * one-way request.
+ *
+ * @throws SystemException if the SystemException has been thrown on the
+ * remote side (the exact type and the minor code matches the data of
+ * the remote exception that has been thrown).
+ *
+ * @throws org.omg.CORBA.portable.ApplicationException as specified.
+ * @throws org.omg.CORBA.portable.RemarshalException as specified.
+ */
+ public InputStream invoke(org.omg.CORBA.Object target, OutputStream output)
+ throws ApplicationException, RemarshalException
+ {
+ streamRequest request = (streamRequest) output;
+ if (request.response_expected)
+ {
+ binaryReply response = request.request.submit();
+
+ // Read reply header.
+ ReplyHeader rh = response.header.create_reply_header();
+ cdrBufInput input = response.getStream();
+ input.setOrb(orb);
+ rh.read(input);
+
+ boolean moved_permanently = false;
+
+ switch (rh.reply_status)
+ {
+ case ReplyHeader.NO_EXCEPTION :
+ if (response.header.version.since_inclusive(1, 2))
+ input.align(8);
+ return input;
+
+ case ReplyHeader.SYSTEM_EXCEPTION :
+ if (response.header.version.since_inclusive(1, 2))
+ input.align(8);
+ throw ObjectCreator.readSystemException(input);
+
+ case ReplyHeader.USER_EXCEPTION :
+ if (response.header.version.since_inclusive(1, 2))
+ input.align(8);
+ input.mark(2000);
+
+ String uxId = input.read_string();
+ input.reset();
+
+ throw new ApplicationException(uxId, input);
+
+ case ReplyHeader.LOCATION_FORWARD_PERM :
+ moved_permanently = true;
+
+ case ReplyHeader.LOCATION_FORWARD :
+ if (response.header.version.since_inclusive(1, 2))
+ input.align(8);
+
+ IOR forwarded = new IOR();
+ try
+ {
+ forwarded._read_no_endian(input);
+ }
+ catch (IOException ex)
+ {
+ throw new MARSHAL(ex + " while reading the forwarding info");
+ }
+
+ request.request.setIor(forwarded);
+
+ // If the object has moved permanently, its IOR is replaced.
+ if (moved_permanently)
+ setIor(forwarded);
+
+ return invoke(target, request);
+
+ default :
+ throw new MARSHAL("Unknow reply status: " + rh.reply_status);
+ }
+ }
+ else
+ {
+ request.request.send_oneway();
+ return null;
+ }
+ }
+
+ /**
+ * Create a request to invoke the method of this CORBA object.
+ *
+ * @param target the CORBA object, to that this operation must be applied.
+ * @param operation the name of the method to invoke.
+ *
+ * @return the request.
+ */
+ public Request request(org.omg.CORBA.Object target, String operation)
+ {
+ gnuRequest request = new gnuRequest();
+
+ request.setIor(ior);
+ request.set_target(target);
+
+ request.setOperation(operation);
+ request.setORB(orb);
+
+ return request;
+ }
+
+ /**
+ * Create a request to invoke the method of this CORBA object.
+ *
+ * @param target the CORBA object, to that this operation must be applied.
+ * @param operation the name of the method to invoke.
+ * @param response_expected specifies if this is one way message or the
+ * response to the message is expected.
+ *
+ * @return the stream where the method arguments should be written.
+ */
+ public OutputStream request(org.omg.CORBA.Object target, String operation,
+ boolean response_expected
+ )
+ {
+ gnuRequest request = new gnuRequest();
+
+ request.setIor(ior);
+ request.set_target(target);
+ request.setOperation(operation);
+
+ request.getParameterStream().response_expected = response_expected;
+ request.setORB(orb);
+
+ return request.getParameterStream();
+ }
+}
diff --git a/gnu/CORBA/IOR_contructed_object.java b/gnu/CORBA/IOR_contructed_object.java
new file mode 100644
index 000000000..5c8ba7350
--- /dev/null
+++ b/gnu/CORBA/IOR_contructed_object.java
@@ -0,0 +1,100 @@
+/* IOR_contructed_object.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.portable.ObjectImpl;
+
+/**
+ * Implements an object, constructed from an IOR reference.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class IOR_contructed_object
+ extends ObjectImpl
+{
+ /**
+ * The IOR, from which the object was constructed.
+ */
+ protected final IOR ior;
+
+ /**
+ * The object id, as defined in IOR.
+ */
+ protected final String[] id;
+
+ /**
+ * Create the object from the given IOR.
+ *
+ * @param an_ior the IOR.
+ */
+ public IOR_contructed_object(ORB orb, IOR an_ior)
+ {
+ ior = an_ior;
+ _set_delegate(new IOR_Delegate(orb, ior));
+ id = new String[] { ior.Id };
+ }
+
+ /**
+ * Create the object from the given string IOR representation.
+ *
+ * @param an_ior the IOR in the string form.
+ */
+ public IOR_contructed_object(Functional_ORB orb, String an_ior)
+ {
+ ior = IOR.parse(an_ior);
+ _set_delegate(new IOR_Delegate(orb, ior));
+ id = new String[] { ior.Id };
+ }
+
+ public String[] _ids()
+ {
+ return id;
+ }
+
+ /**
+ * Get a string reference for this object.
+ *
+ * @return the class name:IOR profile
+ */
+ public String toString()
+ {
+ return getClass().getName() + ":IOR:" + ior;
+ }
+}
diff --git a/gnu/CORBA/NamingService/Binding_iterator_impl.java b/gnu/CORBA/NamingService/Binding_iterator_impl.java
new file mode 100644
index 000000000..6d00c8529
--- /dev/null
+++ b/gnu/CORBA/NamingService/Binding_iterator_impl.java
@@ -0,0 +1,139 @@
+/* Binding_iterator.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.NamingService;
+
+import org.omg.CosNaming.Binding;
+import org.omg.CosNaming.BindingHolder;
+import org.omg.CosNaming.BindingListHolder;
+import org.omg.CosNaming.BindingType;
+import org.omg.CosNaming.NameComponent;
+import org.omg.CosNaming._BindingIteratorImplBase;
+
+/**
+ * The implementation of the {@link BindingIterator}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class Binding_iterator_impl
+ extends _BindingIteratorImplBase
+{
+ /**
+ * The value, returned by the {@link #next_one} when there
+ * are no bindings available.
+ */
+ private static final Binding no_more_bindings =
+ new Binding(new NameComponent[ 0 ], BindingType.nobject);
+
+ /**
+ * The collection of the available bindings.
+ */
+ private final Binding[] bindings;
+
+ /**
+ * The position of the internal iterator pointer.
+ */
+ private int p;
+
+ public Binding_iterator_impl(Binding[] a_bindings)
+ {
+ bindings = a_bindings;
+ }
+
+ /**
+ * Disconnect the iterator from its ORB. The iterator will
+ * no longer be accessible and will be a subject of the
+ * garbage collection.
+ */
+ public void destroy()
+ {
+ _orb().disconnect(this);
+ }
+
+ /**
+ * Return the desired amount of bindings.
+ *
+ * @param amount the maximal number of bindings to return.
+ * @param a_list a holder to store the returned bindings.
+ *
+ * @return false if there are no more bindings available,
+ * true otherwise.
+ */
+ public boolean next_n(int amount, BindingListHolder a_list)
+ {
+ if (p < bindings.length)
+ {
+ int n = bindings.length - p;
+ if (n > amount)
+ n = amount;
+
+ a_list.value = new Binding[ n ];
+ for (int i = 0; i < n; i++)
+ a_list.value [ i ] = bindings [ p++ ];
+
+ return true;
+ }
+ else
+ {
+ a_list.value = new Binding[ 0 ];
+ return false;
+ }
+ }
+
+ /**
+ * Return the next binding.
+ *
+ * @param a_binding a holder, where the next binding will be stored.
+ *
+ * @return false if there are no more bindings available, true
+ * otherwise.
+ */
+ public boolean next_one(BindingHolder a_binding)
+ {
+ if (p < bindings.length)
+ {
+ a_binding.value = (Binding) bindings [ p++ ];
+ return true;
+ }
+ else
+ {
+ a_binding.value = no_more_bindings;
+ return false;
+ }
+ }
+}
diff --git a/gnu/CORBA/NamingService/Ext.java b/gnu/CORBA/NamingService/Ext.java
new file mode 100644
index 000000000..69e11e275
--- /dev/null
+++ b/gnu/CORBA/NamingService/Ext.java
@@ -0,0 +1,230 @@
+/* TransientContextExt.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.NamingService;
+
+import org.omg.CORBA.NO_IMPLEMENT;
+import org.omg.CORBA.Object;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.CosNaming.BindingIteratorHolder;
+import org.omg.CosNaming.BindingListHolder;
+import org.omg.CosNaming.NameComponent;
+import org.omg.CosNaming.NamingContext;
+import org.omg.CosNaming.NamingContextPackage.AlreadyBound;
+import org.omg.CosNaming.NamingContextPackage.CannotProceed;
+import org.omg.CosNaming.NamingContextPackage.InvalidName;
+import org.omg.CosNaming.NamingContextPackage.NotEmpty;
+import org.omg.CosNaming.NamingContextPackage.NotFound;
+import org.omg.CosNaming._NamingContextExtImplBase;
+
+/**
+ * This naming context that adds the the string based extensions,
+ * defined by {@link NamingContextExt}. The basic functionality
+ * is handled by the enclosed instance of the {@link NamingContext}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class Ext
+ extends _NamingContextExtImplBase
+{
+ /**
+ * The older version of the naming context, where all relevant calls
+ * are forwarded.
+ */
+ private final NamingContext classic;
+
+ /**
+ * The converter class converts between string and array form of the
+ * name.
+ */
+ private snConverter converter = new snConverter();
+
+ /**
+ * Create the extensions for the given instance of the context.
+ *
+ * @param previous_version the previous version of the naming context.
+ */
+ public Ext(NamingContext previous_version)
+ {
+ classic = previous_version;
+ }
+
+ /**
+ * Sets a delegate to this context and, if appropriated, also
+ * sets the same delegate to the enclosing 'classic' context.
+ *
+ * @param a_delegate a delegate to set.
+ */
+ public void _set_delegate(Delegate a_delegate)
+ {
+ super._set_delegate(a_delegate);
+ if (classic instanceof ObjectImpl)
+ ((ObjectImpl) classic)._set_delegate(a_delegate);
+ }
+
+ /** {@inheritDoc} */
+ public void bind(NameComponent[] a_name, Object an_object)
+ throws NotFound, CannotProceed, InvalidName, AlreadyBound
+ {
+ classic.bind(a_name, an_object);
+ }
+
+ /** {@inheritDoc} */
+ public void bind_context(NameComponent[] a_name, NamingContext context)
+ throws NotFound, CannotProceed, InvalidName, AlreadyBound
+ {
+ classic.bind_context(a_name, context);
+ }
+
+ /** {@inheritDoc} */
+ public NamingContext bind_new_context(NameComponent[] a_name)
+ throws NotFound, AlreadyBound, CannotProceed,
+ InvalidName
+ {
+ return classic.bind_new_context(a_name);
+ }
+
+ /** {@inheritDoc} */
+ public void destroy()
+ throws NotEmpty
+ {
+ classic.destroy();
+ }
+
+ /** {@inheritDoc} */
+ public void list(int amount, BindingListHolder a_list,
+ BindingIteratorHolder an_iter
+ )
+ {
+ classic.list(amount, a_list, an_iter);
+ }
+
+ /** {@inheritDoc} */
+ public NamingContext new_context()
+ {
+ return classic.new_context();
+ }
+
+ /** {@inheritDoc} */
+ public void rebind(NameComponent[] a_name, Object an_object)
+ throws NotFound, CannotProceed, InvalidName
+ {
+ classic.rebind(a_name, an_object);
+ }
+
+ /** {@inheritDoc} */
+ public void rebind_context(NameComponent[] a_name, NamingContext context)
+ throws NotFound, CannotProceed, InvalidName
+ {
+ classic.rebind_context(a_name, context);
+ }
+
+ /** {@inheritDoc} */
+ public Object resolve(NameComponent[] a_name)
+ throws NotFound, CannotProceed, InvalidName
+ {
+ return classic.resolve(a_name);
+ }
+
+ /**
+ * Resolves the name, represented in the form of the string. The name
+ * is first parsed into an array representation, then the call
+ * is forwarded to the {@link resolve(NameComponent[])}.
+ *
+ * @param a_name_string a name to resolve.
+ *
+ * @return the resolved object.
+ *
+ * @throws NotFound if the name cannot be resolved.
+ * @throws InvalidName if the name is invalid.
+ * @throws CannotProceed on unexpected circumstances.
+ */
+ public Object resolve_str(String a_name_string)
+ throws NotFound, CannotProceed, InvalidName
+ {
+ return resolve(to_name(a_name_string));
+ }
+
+ /**
+ * Convert the name string representation into array representation.
+ *
+ * @param a_name_string a string to convert.
+ * @return a converted array of the name components
+ *
+ * @throws InvalidName on parsing error.
+ */
+ public NameComponent[] to_name(String a_name_string)
+ throws InvalidName
+ {
+ return converter.toName(a_name_string);
+ }
+
+ /**
+ * Convert a name component array representation into string representation.
+ *
+ * @param a_name a name to convert.
+ *
+ * @return a string form.
+ *
+ * @throws InvalidName if the passed name is invalid.
+ */
+ public String to_string(NameComponent[] a_name)
+ throws InvalidName
+ {
+ return converter.toString(a_name);
+ }
+
+ /**
+ * This method is not yet implemented.
+ * FIXME TODO implement it.
+ */
+ public String to_url(String an_address, String a_name_string)
+ throws org.omg.CosNaming.NamingContextExtPackage.InvalidAddress,
+ InvalidName
+ {
+ throw new NO_IMPLEMENT("Method to_url() not yet implemented.");
+ }
+
+ /** {@inheritDoc} */
+ public void unbind(NameComponent[] a_name)
+ throws NotFound, CannotProceed, InvalidName
+ {
+ classic.unbind(a_name);
+ }
+}
diff --git a/gnu/CORBA/NamingService/NameValidator.java b/gnu/CORBA/NamingService/NameValidator.java
new file mode 100644
index 000000000..797202fd6
--- /dev/null
+++ b/gnu/CORBA/NamingService/NameValidator.java
@@ -0,0 +1,79 @@
+/* NameValidator.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.NamingService;
+
+
+import org.omg.CosNaming.NameComponent;
+import org.omg.CosNaming.NamingContextPackage.InvalidName;
+
+/**
+ * Checks the given name for validity.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class NameValidator
+{
+ /**
+ * Check the given name. This method must be package level, as it is
+ * not defined in the API.
+ *
+ * @param name the name to check.
+ *
+ * @throws InvalidName if the given name is not valid.
+ */
+ public static void check(NameComponent[] name)
+ throws InvalidName
+ {
+ if (name == null)
+ throw new InvalidName("name=null");
+
+ if (name.length == 0)
+ throw new InvalidName("name.length=0");
+
+ for (int i = 0; i < name.length; i++)
+ {
+ if (name [ i ] == null)
+ throw new InvalidName("name[" + i + "]=null");
+ if (name [ i ].id == null)
+ throw new InvalidName("name[" + i + "].id=null");
+ if (name [ i ].kind == null)
+ throw new InvalidName("name[" + i + "].kind=null");
+ }
+ }
+}
diff --git a/gnu/CORBA/NamingService/NamingMap.java b/gnu/CORBA/NamingService/NamingMap.java
new file mode 100644
index 000000000..d9bbf6a8c
--- /dev/null
+++ b/gnu/CORBA/NamingService/NamingMap.java
@@ -0,0 +1,187 @@
+/* NamingMap.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.NamingService;
+
+import org.omg.CosNaming.NameComponent;
+import org.omg.CosNaming.NamingContextPackage.AlreadyBound;
+import org.omg.CosNaming.NamingContextPackage.InvalidName;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+/**
+ * The Naming Map maps the single names components into associated objects or
+ * naming contexts.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class NamingMap
+{
+ /**
+ * The actual map.
+ */
+ private final TreeMap map;
+
+ /**
+ * Creates an instance of the naming map, intialising the comparator
+ * to the {@link cmpNameComparator}.
+ */
+ public NamingMap()
+ {
+ map = new TreeMap(cmpNameComponent.singleton);
+ }
+
+ /**
+ * Put the given CORBA object, specifying the given name as a key.
+ * If the entry with the given name already exists, or if the given
+ * object is already mapped under another name, the
+ * {@link AlreadyBound} exception will be thrown.
+ *
+ * @param name the name
+ * @param object the object
+ */
+ public void bind(NameComponent name, org.omg.CORBA.Object object)
+ throws AlreadyBound, InvalidName
+ {
+ if (containsKey(name))
+ {
+ Object x = get(name);
+
+ // Do not throw an exception if the same object is named by
+ // the same name.
+ if (x.equals(object))
+ throw new AlreadyBound("The name is in use for another object");
+ }
+ else
+ {
+ if (containsValue(object))
+ throw new AlreadyBound("Tha object has another name");
+ }
+ }
+
+ /**
+ * Checks if this map contains the definition of the given name.
+ *
+ * @param key the name to check.
+ */
+ public boolean containsKey(NameComponent key)
+ {
+ return map.containsKey(key);
+ }
+
+ /**
+ * Checks if this map contains the definition of the given object.
+ *
+ * @param object the object to check.
+ */
+ public boolean containsValue(org.omg.CORBA.Object object)
+ {
+ return map.containsValue(object);
+ }
+
+ /**
+ * Returns the map entry set.
+ *
+ * @return the map entry set, containing the instances of the
+ * Map.Entry.
+ */
+ public Set entries()
+ {
+ return map.entrySet();
+ }
+
+ /**
+ * Get the CORBA object, associated with the given name.
+ *
+ * @param name the name.
+ *
+ * @return the associated object, null if none.
+ */
+ public org.omg.CORBA.Object get(NameComponent name)
+ {
+ return (org.omg.CORBA.Object) map.get(name);
+ }
+
+ /**
+ * Put the given CORBA object, specifying the given name as a key.
+ * Remove all pre - existing mappings for the given name and object.
+ *
+ * @param name the name.
+ * @param object
+ */
+ public void rebind(NameComponent name, org.omg.CORBA.Object object)
+ throws InvalidName
+ {
+ // Remove the existing mapping for the given name, if present.
+ remove(name);
+
+ Iterator iter = entries().iterator();
+ Map.Entry item;
+
+ // Remove the existing mapping for the given object, if present.
+ while (iter.hasNext())
+ {
+ item = (Map.Entry) iter.next();
+ if (item.getValue().equals(object))
+ iter.remove();
+ }
+
+ map.put(name, object);
+ }
+
+ /**
+ * Removes the given name, if present.
+ *
+ * @param name a name to remove.
+ */
+ public void remove(NameComponent name)
+ {
+ map.remove(name);
+ }
+
+ /**
+ * Get the size of the map.
+ */
+ public int size()
+ {
+ return map.size();
+ }
+}
diff --git a/gnu/CORBA/NamingService/NamingServiceTransient.java b/gnu/CORBA/NamingService/NamingServiceTransient.java
new file mode 100644
index 000000000..295c0e488
--- /dev/null
+++ b/gnu/CORBA/NamingService/NamingServiceTransient.java
@@ -0,0 +1,159 @@
+/* Server.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.NamingService;
+
+import gnu.CORBA.Functional_ORB;
+
+import org.omg.CosNaming.NamingContextExt;
+
+import java.io.FileOutputStream;
+import java.io.PrintStream;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * The server for the gnu classpath naming service. This is an executable
+ * class that must be started to launch the GNU Classpath CORBA
+ * transient naming service.
+ *
+ * GNU Classpath currently works with this naming service and is also
+ * interoperable with the Sun Microsystems naming services from
+ * releases 1.3 and 1.4, both transient <i>tnameserv</i> and persistent
+ * <i>orbd</i>.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class NamingServiceTransient
+{
+ /**
+ * The default port (900), on that the naming service starts if no
+ * -ORBInitialPort is specified in the command line.
+ */
+ public static final int PORT = 900;
+
+ /**
+ * Get the object key for the naming service. The default
+ * key is the string "NameService" in ASCII.
+ *
+ * @return the byte array.
+ */
+ public static byte[] getDefaultKey()
+ {
+ try
+ { // NameService
+ return "NameService".getBytes("UTF-8");
+ }
+ catch (UnsupportedEncodingException ex)
+ {
+ throw new InternalError("UTF-8 unsupported");
+ }
+ }
+
+ /**
+ * Start the naming service on the current host at the given port.
+ * The parameter -org.omg.CORBA.ORBInitialPort NNN or
+ * -ORBInitialPort NNN, if present, specifies the port, on that
+ * the service must be started. If this key is not specified,
+ * the service starts at the port 900.
+ *
+ * The parameter -ior FILE_NAME, if present, forces to store the ior string
+ * of this naming service to the specified file.
+ *
+ * @param args the parameter string.
+ */
+ public static void main(String[] args)
+ {
+ int port = PORT;
+ String iorf = null;
+ try
+ {
+ // Create and initialize the ORB
+ final Functional_ORB orb = new Functional_ORB();
+ orb.setPort(PORT);
+ orb.init(args, null);
+
+ // Create the servant and register it with the ORB
+ NamingContextExt namer = new Ext(new TransientContext());
+ orb.connect(namer, getDefaultKey());
+
+ if (args.length > 1)
+ for (int i = 0; i < args.length - 1; i++)
+ {
+ if (args [ i ].endsWith("ORBInitialPort"))
+ port = Integer.parseInt(args [ i + 1 ]);
+
+ if (args [ i ].equals("-ior"))
+ iorf = args [ i + 1 ];
+ }
+
+ orb.setPort(port);
+
+ // Storing the IOR reference.
+ String ior = orb.object_to_string(namer);
+ if (iorf != null)
+ {
+ FileOutputStream f = new FileOutputStream(iorf);
+ PrintStream p = new PrintStream(f);
+ p.print(ior);
+ p.close();
+ }
+
+ System.out.println("GNU Classpath, transient naming service. " +
+ "Copyright (C) 2005 Free Software Foundation\n" +
+ "This tool comes with ABSOLUTELY NO WARRANTY. " +
+ "This is free software, and you are\nwelcome to " +
+ "redistribute it under conditions, defined in " +
+ "GNU Classpath license.\n\n" + ior
+ );
+
+ new Thread()
+ {
+ public void run()
+ {
+ // wait for invocations from clients
+ orb.run();
+ }
+ }.start();
+ }
+ catch (Exception e)
+ {
+ System.err.println("ERROR: " + e);
+ e.printStackTrace(System.out);
+ }
+ }
+}
diff --git a/gnu/CORBA/NamingService/TransientContext.java b/gnu/CORBA/NamingService/TransientContext.java
new file mode 100644
index 000000000..70deec28a
--- /dev/null
+++ b/gnu/CORBA/NamingService/TransientContext.java
@@ -0,0 +1,416 @@
+/* nContext.java -- implementation of NamingContext
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.NamingService;
+
+import org.omg.CORBA.Object;
+import org.omg.CosNaming.Binding;
+import org.omg.CosNaming.BindingIteratorHolder;
+import org.omg.CosNaming.BindingListHolder;
+import org.omg.CosNaming.BindingType;
+import org.omg.CosNaming.NameComponent;
+import org.omg.CosNaming.NamingContext;
+import org.omg.CosNaming.NamingContextOperations;
+import org.omg.CosNaming.NamingContextPackage.AlreadyBound;
+import org.omg.CosNaming.NamingContextPackage.CannotProceed;
+import org.omg.CosNaming.NamingContextPackage.InvalidName;
+import org.omg.CosNaming.NamingContextPackage.NotEmpty;
+import org.omg.CosNaming.NamingContextPackage.NotFound;
+import org.omg.CosNaming.NamingContextPackage.NotFoundReason;
+import org.omg.CosNaming._NamingContextImplBase;
+
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * This class implements the transient naming service, defined by
+ * {@link NamingContex}. The 'transient' means that the service does
+ * not store its state into the persistent memory. If the service is
+ * restarted, the named objects must be re-registered again.
+ *
+ * TODO Write the persistent naming service.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class TransientContext
+ extends _NamingContextImplBase
+ implements NamingContext, NamingContextOperations
+{
+ /**
+ * The already named contexts.
+ */
+ protected final NamingMap named_contexts = new NamingMap();
+
+ /**
+ * The already named objects.
+ */
+ protected final NamingMap named_objects = new NamingMap();
+
+ /**
+ * Gives the object a name, valid in this context.
+ *
+ * @param a_name the name, being given to the object.
+ * @param an_object the object, being named.
+ *
+ * @throws AlreadyBound if the object is already named in this context.
+ * @throws InvalidName if the name has zero length or otherwise invalid.
+ */
+ public void bind(NameComponent[] a_name, Object an_object)
+ throws NotFound, CannotProceed, InvalidName, AlreadyBound
+ {
+ if (a_name.length == 1)
+ named_objects.bind(a_name [ 0 ], an_object);
+ else
+ {
+ NamingContext context =
+ (NamingContext) named_contexts.get(a_name [ 0 ]);
+ context.bind(getSuffix(a_name), an_object);
+ }
+ }
+
+ /**
+ * Gives a child context name, valid in this context.
+ *
+ * @param a_name the name, being given to the child context.
+ * @param a_context the child context being named.
+ *
+ * @throws AlreadyBound if the child context is already named in
+ * the current context.
+ */
+ public void bind_context(NameComponent[] a_name, NamingContext a_context)
+ throws NotFound, CannotProceed, InvalidName, AlreadyBound
+ {
+ if (a_name.length == 1)
+ named_contexts.bind(a_name [ 0 ], a_context);
+ else
+ {
+ NamingContext context =
+ (NamingContext) named_contexts.get(a_name [ 0 ]);
+ context.bind_context(getSuffix(a_name), a_context);
+ }
+ }
+
+ /**
+ * Create a new context and give it a given name (bound it)
+ * in the current context.
+ *
+ * The context being created is returned by calling
+ * {@link #new_context()}.
+ *
+ * @param a_name the name being given to the new context.
+ *
+ * @return the newly created context.
+ *
+ * @throws AlreadyBound if the name is already in use.
+ * @throws InvalidName if the name has zero length or otherwise invalid.
+ */
+ public NamingContext bind_new_context(NameComponent[] a_name)
+ throws NotFound, AlreadyBound, CannotProceed,
+ InvalidName
+ {
+ if (named_contexts.containsKey(a_name [ 0 ]) ||
+ named_objects.containsKey(a_name [ 0 ])
+ )
+ throw new AlreadyBound();
+
+ NamingContext child = new_context();
+ bind_context(a_name, child);
+ return child;
+ }
+
+ /**
+ * Destroy this context (must be empty).
+ * @throws NotEmpty if the context being destroyed is not empty.
+ */
+ public void destroy()
+ throws NotEmpty
+ {
+ if (named_contexts.size() > 0 || named_objects.size() > 0)
+ throw new NotEmpty();
+ }
+
+ /**
+ * Iterate over all bindings, defined in this namind context.
+ *
+ * @param amount the maximal number of context to return in the
+ * holder a_list. The remaining bindings are accessible via iterator
+ * an_iter. If the parameter amount is zero, all bindings are accessed only
+ * via this iterator.
+ *
+ * This implementation list contexts first, then objects.
+ *
+ * @param a_list the holder, where the returned bindigs are stored.
+ * @param an_iter the iterator that can be used to access the remaining
+ * bindings.
+ */
+ public void list(int amount, BindingListHolder a_list,
+ BindingIteratorHolder an_iter
+ )
+ {
+ int nb = named_contexts.size() + named_objects.size();
+ int nl = nb;
+ if (nl > amount)
+ nl = amount;
+
+ a_list.value = new Binding[ nl ];
+
+ Iterator contexts = named_contexts.entries().iterator();
+ Iterator objects = named_objects.entries().iterator();
+
+ // Create a binding list.
+ for (int i = 0; i < nl; i++)
+ {
+ if (contexts.hasNext())
+ a_list.value [ i ] = mkBinding(contexts.next(), BindingType.ncontext);
+ else if (objects.hasNext())
+ a_list.value [ i ] = mkBinding(objects.next(), BindingType.nobject);
+ else
+ throw new InternalError();
+ }
+
+ // Create an iterator.
+ Binding[] remainder = new Binding[ nb - nl ];
+ int p = 0;
+
+ while (contexts.hasNext())
+ remainder [ p++ ] = mkBinding(contexts.next(), BindingType.ncontext);
+
+ while (objects.hasNext())
+ remainder [ p++ ] = mkBinding(objects.next(), BindingType.nobject);
+
+ Binding_iterator_impl bit = new Binding_iterator_impl(remainder);
+ _orb().connect(bit);
+ an_iter.value = bit;
+ }
+
+ /**
+ * Creates a new naming context, not bound to any name.
+ */
+ public NamingContext new_context()
+ {
+ Ext context = new Ext(new TransientContext());
+
+ // Connect the context to the current ORB:
+ _orb().connect(context);
+ return context;
+ }
+
+ /**
+ * Names or renames the object.
+ *
+ * @param a_name the new name, being given to the object
+ * in the scope of the current context. If the object is already
+ * named in this context, it is renamed.
+ *
+ * @param an_object the object, being named.
+ *
+ * @throws InvalidName if the name has zero length or otherwise invalid.
+ */
+ public void rebind(NameComponent[] a_name, Object an_object)
+ throws NotFound, CannotProceed, InvalidName
+ {
+ if (a_name.length == 1)
+ named_objects.rebind(a_name [ 0 ], an_object);
+ else
+ {
+ NamingContext context =
+ (NamingContext) named_contexts.get(a_name [ 0 ]);
+ context.rebind(getSuffix(a_name), an_object);
+ }
+ }
+
+ /**
+ * Names or renames the child context.
+ * If the child context is already named in
+ * the current context, it is renamed. The the name being given is in
+ * use, the old meaning of the name is discarded.
+ *
+ * @param a_name the name, being given to the child context in the scope
+ * of the current context.
+ *
+ * @param a_context the child context being named.
+ *
+ * @throws InvalidName if the name has zero length or otherwise invalid.
+ */
+ public void rebind_context(NameComponent[] a_name, NamingContext a_context)
+ throws NotFound, CannotProceed, InvalidName
+ {
+ if (a_name.length == 1)
+ named_contexts.rebind(a_name [ 0 ], a_context);
+ else
+ {
+ NamingContext context =
+ (NamingContext) named_contexts.get(a_name [ 0 ]);
+ context.rebind_context(getSuffix(a_name), a_context);
+ }
+ }
+
+ /**
+ * Get the object, bound to the specified name in this
+ * context. The given object must match the bound
+ * name.
+ *
+ * This implementation resolves the names as defined in specification
+ * of the CORBA naming service. This means, if the beginning of the
+ * name can be resolved to some naming context, the request is
+ * forwarded to this context, passing the unresolved name part as a
+ * parameter. In this way, it is possible to have a hierarchy of the
+ * naming services. The central services resolve the the beginning
+ * of the name. The local services resolve the remaining nodes of the
+ * name that may be relevant to some local details. It can be three or
+ * more ranks of the naming services.
+ *
+ * @param a_name the object name.
+ *
+ * @return the object, matching this name. The client
+ * usually casts or narrows (using the helper) the returned value
+ * to the more specific type.
+ *
+ * @throws NotFound if the name cannot be resolved.
+ * @throws InvalidName if the name has zero length or otherwise invalid.
+ */
+ public Object resolve(NameComponent[] a_name)
+ throws NotFound, CannotProceed, InvalidName
+ {
+ NameValidator.check(a_name);
+
+ if (a_name.length > 1)
+ return resolveSubContext(a_name);
+ else
+ {
+ // A single node name.
+ org.omg.CORBA.Object object;
+
+ object = named_objects.get(a_name [ 0 ]);
+ if (object != null)
+ return object;
+
+ object = named_contexts.get(a_name [ 0 ]);
+ if (object != null)
+ return object;
+ }
+
+ throw new NotFound(NotFoundReason.missing_node, a_name);
+ }
+
+ /**
+ * Removes the name from the binding context.
+ *
+ * @param a_name a name to remove.
+ *
+ * @throws InvalidName if the name has zero length or otherwise invalid.
+ */
+ public void unbind(NameComponent[] a_name)
+ throws NotFound, CannotProceed, InvalidName
+ {
+ NameValidator.check(a_name);
+
+ // Single node name - handle it.
+ if (a_name.length == 1)
+ {
+ if (named_objects.containsKey(a_name [ 0 ]))
+ named_objects.remove(a_name [ 0 ]);
+ else if (named_contexts.containsKey(a_name [ 0 ]))
+ named_contexts.remove(a_name [ 0 ]);
+ else
+ throw new NotFound(NotFoundReason.missing_node, a_name);
+ }
+ else
+ {
+ // Handle the first node and forward the command.
+ NamingContext subcontext =
+ (NamingContext) named_contexts.get(a_name [ 0 ]);
+
+ if (subcontext == null)
+ throw new NotFound(NotFoundReason.missing_node, a_name);
+
+ subcontext.unbind(getSuffix(a_name));
+ }
+ }
+
+ /**
+ * Get the name suffix, discarding the first member.
+ */
+ private NameComponent[] getSuffix(NameComponent[] a_name)
+ {
+ NameComponent[] suffix = new NameComponent[ a_name.length - 1 ];
+ System.arraycopy(a_name, 1, suffix, 0, suffix.length);
+ return suffix;
+ }
+
+ /**
+ * Create a binding.
+ *
+ * @param entry the entry, defining the bound object.
+ * @param type the binding type.
+ * @return the created binding.
+ */
+ private Binding mkBinding(java.lang.Object an_entry, BindingType type)
+ {
+ Map.Entry entry = (Map.Entry) an_entry;
+ Binding b = new Binding();
+
+ // The name component has always only one node (the current context)
+ b.binding_name = new NameComponent[] { (NameComponent) entry.getKey() };
+ b.binding_type = type;
+ return b;
+ }
+
+ /**
+ * Find the context, bound to the first name of the given
+ * name, and pass the remainder (without the first node)
+ * of the name for that context to resolve.
+ *
+ * @param name the name to resolve.
+ *
+ * @return the resolved context
+ */
+ private Object resolveSubContext(NameComponent[] a_name)
+ throws NotFound, CannotProceed, InvalidName
+ {
+ // A multiple node name.
+ // This context resolves the first node only.
+ NamingContext context = (NamingContext) named_contexts.get(a_name [ 0 ]);
+ if (context == null)
+ throw new NotFound(NotFoundReason.missing_node, a_name);
+
+ NameComponent[] suffix = getSuffix(a_name);
+
+ return context.resolve(suffix);
+ }
+}
diff --git a/gnu/CORBA/NamingService/cmpNameComponent.java b/gnu/CORBA/NamingService/cmpNameComponent.java
new file mode 100644
index 000000000..c8cc03ad7
--- /dev/null
+++ b/gnu/CORBA/NamingService/cmpNameComponent.java
@@ -0,0 +1,98 @@
+/* cmpNameComponent.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.NamingService;
+
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CosNaming.NameComponent;
+
+import java.util.Comparator;
+
+/**
+ * This class implements the name component comparator, needed to
+ * sort and compare the name components in maps and sorted sets.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public final class cmpNameComponent
+ implements Comparator
+{
+ /**
+ * The singleton instance of the name comparator.
+ */
+ public static final cmpNameComponent singleton = new cmpNameComponent();
+
+ /**
+ * It is enough to have a singleton.
+ */
+ private cmpNameComponent()
+ {
+ }
+
+ /**
+ * Compare the two names components.
+ *
+ * @param nc_a the first name component.
+ * @param nc_b the second name component.
+ *
+ * @return 0 if the name components are equal, non zero value
+ * as result of comparison otherwise.
+ *
+ * @throws BAD_PARAM if one of the components is empty or
+ * has {@link NameComponent#id} or {@link NameComponent#kind}
+ * field intialised to null.
+ */
+ public final int compare(Object nc_a, Object nc_b)
+ {
+ NameComponent a = (NameComponent) nc_a;
+ NameComponent b = (NameComponent) nc_b;
+
+ int cn = a.id.compareTo(b.id);
+ if (cn != 0)
+ return cn;
+ return a.kind.compareTo(b.kind);
+ }
+
+ /**
+ * All instances of this class are equal.
+ */
+ public boolean equals(Object x)
+ {
+ return x instanceof cmpNameComponent;
+ }
+}
diff --git a/gnu/CORBA/NamingService/snConverter.java b/gnu/CORBA/NamingService/snConverter.java
new file mode 100644
index 000000000..dc46b7ab3
--- /dev/null
+++ b/gnu/CORBA/NamingService/snConverter.java
@@ -0,0 +1,328 @@
+/* snConverter.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.NamingService;
+
+import org.omg.CORBA.IntHolder;
+import org.omg.CosNaming.NameComponent;
+import org.omg.CosNaming.NamingContextPackage.InvalidName;
+
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+
+/**
+ * This class converts between string and array representations of the
+ * multi component object names.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class snConverter
+{
+ /**
+ * A string, indicating the escape character.
+ */
+ public static final String ESCAPE = "\\";
+
+ /**
+ * Convert the string name representation into the array name
+ * representation. See {@link #toString(NameComponent)} for the
+ * description of this format.
+ *
+ * @param name the string form of the name.
+ *
+ * @return the array form of the name.
+ *
+ * @throws InvalidName if the name cannot be parsed.
+ */
+ public NameComponent[] toName(String a_name)
+ throws InvalidName
+ {
+ ArrayList components = new ArrayList();
+ StringTokenizer st = new StringTokenizer(a_name, "./\\", true);
+
+ String id;
+ String kind;
+ String next;
+
+ // Create the buffer array, reserving the last element for null.
+ String[] n = new String[ st.countTokens() + 1 ];
+
+ int pp = 0;
+ while (st.hasMoreTokens())
+ n [ pp++ ] = st.nextToken();
+
+ IntHolder p = new IntHolder();
+
+ NameComponent node = readNode(p, n);
+
+ while (node != null)
+ {
+ components.add(node);
+ node = readNode(p, n);
+ }
+
+ NameComponent[] name = new NameComponent[ components.size() ];
+ for (int i = 0; i < name.length; i++)
+ {
+ name [ i ] = (NameComponent) components.get(i);
+ }
+
+ NameValidator.check(name);
+
+ return name;
+ }
+
+ /**
+ * Converts the name into its string representation, as defined in
+ * the specification CORBA naming service.
+ *
+ * A string representation for the name consists of the name components,
+ * separated by a slash '/' character (for example, 'a/b/c'). If the
+ * {@link NameComponent#kind} field is not empty, it is given after
+ * period ('.'), for example 'a.b/c.d/.' .
+ * The period alone represents node where part where both
+ * {@link NameComponent#kind} and {@link NameComponent#id} are empty strings.
+ *
+ * If slash or dot are part of the name, they are escaped by backslash ('\').
+ * If the backslash itself is part of the name, it is doubled.
+ *
+ * @param a_name a name to convert.
+ * @return a string representation.
+ */
+ public String toString(NameComponent[] a_name)
+ throws InvalidName
+ {
+ NameValidator.check(a_name);
+
+ StringBuffer b = new StringBuffer();
+
+ NameComponent n;
+
+ for (int ni = 0; ni < a_name.length; ni++)
+ {
+ n = a_name [ ni ];
+ appEscaping(b, n.id);
+ if (n.kind.length() > 0)
+ {
+ b.append('.');
+ appEscaping(b, n.kind);
+ }
+
+ if (ni < a_name.length - 1)
+ b.append('/');
+ }
+ return b.toString();
+ }
+
+ /**
+ * Append the contents of the string to this
+ * string buffer, inserting the escape sequences, where required.
+ *
+ * @param b a buffer to append the contents to.
+ * @param s a string to append.
+ */
+ private void appEscaping(StringBuffer b, String s)
+ {
+ char c;
+ for (int i = 0; i < s.length(); i++)
+ {
+ c = s.charAt(i);
+ switch (c)
+ {
+ case '.' :
+ case '/' :
+ case '\\' :
+ b.append('\\');
+ b.append(c);
+ break;
+
+ default :
+ b.append(c);
+ break;
+ }
+ }
+ }
+
+ /**
+ * Assert the end of the current name component.
+ */
+ private void assertEndOfNode(IntHolder p, String[] t)
+ throws InvalidName
+ {
+ if (t [ p.value ] != null)
+ if (!t [ p.value ].equals("/"))
+ throw new InvalidName("End of node expected at token " + p.value);
+ }
+
+ /**
+ * Read the named component node. After reading the current positon
+ * advances to the beginning of the next node in an array.
+ *
+ * @param p the current position being wrapped inside the passed
+ * IntHolder.
+ *
+ * @param t the text buffer.
+ *
+ * @return the created node.
+ */
+ private NameComponent readNode(IntHolder p, String[] t)
+ throws InvalidName
+ {
+ // End of stream has been reached.
+ if (t [ p.value ] == null)
+ return null;
+
+ NameComponent n = new NameComponent();
+
+ if (t [ p.value ].equals("."))
+ {
+ // The 'id' is missing, but the 'kind' may follow.
+ n.id = "";
+ p.value++;
+ n.kind = readPart(p, t);
+ assertEndOfNode(p, t);
+ if (t [ p.value ] != null)
+ p.value++;
+ }
+ else if (t [ p.value ].equals("/"))
+ {
+ // This is not allowed here and may happen only
+ // on two subsequent slashes.
+ throw new InvalidName("Unexpected '/' token " + p.value);
+ }
+ else
+ {
+ n.id = readPart(p, t);
+
+ // If some chars follow the id.
+ if (t [ p.value ] != null)
+ {
+ // Dot means that the kind part follows
+ if (t [ p.value ].equals("."))
+ {
+ p.value++;
+ n.kind = readPart(p, t);
+ assertEndOfNode(p, t);
+ if (t [ p.value ] != null)
+ p.value++;
+ }
+
+ // The next name component follows - advance to
+ // the beginning of the next name component.
+ else if (t [ p.value ].equals("/"))
+ {
+ n.kind = "";
+ p.value++;
+ }
+ else
+ throw new InvalidName("Unexpected '" + t [ p.value ] +
+ "' at token " + p.value
+ );
+ }
+ else
+
+ // Id, and then end of sequence.
+ n.kind = "";
+ }
+
+ return n;
+ }
+
+ /**
+ * Read the name part (id or kind).
+ *
+ * @param p the current position. After reading, advances
+ * to the beginning of the next name fragment.
+ *
+ * @param t the string buffer.
+ *
+ * @return the name part with resolved escape sequences.
+ */
+ private String readPart(IntHolder p, String[] t)
+ {
+ StringBuffer part = new StringBuffer();
+
+ while (t [ p.value ] != null && !t [ p.value ].equals(".") &&
+ !t [ p.value ].equals("/")
+ )
+ {
+ if (t [ p.value ].equals(ESCAPE))
+ {
+ p.value++;
+ part.append(t [ p.value ]);
+ }
+ else
+ part.append(t [ p.value ]);
+
+ p.value++;
+ }
+
+ return part.toString();
+ }
+
+ public static void main(String[] args)
+ {
+ NameComponent a = new NameComponent("a", "ak");
+ NameComponent b = new NameComponent("b/z", "b.k");
+ NameComponent c = new NameComponent("c", "");
+
+ snConverter sn = new snConverter();
+
+ try
+ {
+ String s = sn.toString(new NameComponent[] { a, b, c });
+ System.out.println(s);
+
+ //NameComponent[] k = toName("a.k/b.k2/c/d/.");
+ //NameComponent[] k = toName("a.bc/.b/c.x");
+
+ NameComponent[] k = sn.toName(s);
+ System.out.println("ToString");
+
+ for (int i = 0; i < k.length; i++)
+ {
+ System.out.println(k [ i ].id + ":" + k [ i ].kind);
+ }
+ }
+ catch (InvalidName ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+}
diff --git a/gnu/CORBA/ObjectCreator.java b/gnu/CORBA/ObjectCreator.java
new file mode 100644
index 000000000..312f75e75
--- /dev/null
+++ b/gnu/CORBA/ObjectCreator.java
@@ -0,0 +1,267 @@
+/* ExceptionCreator.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.CompletionStatusHelper;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.UNKNOWN;
+import org.omg.CORBA.UserException;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+
+/**
+ * Creates java objects from the agreed IDL names for the simple
+ * case when the CORBA object is directly mapped into the locally
+ * defined java class.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class ObjectCreator
+{
+ /**
+ * The standard OMG prefix.
+ */
+ public static final String OMG_PREFIX = "omg.org/";
+
+ /**
+ * The standard java prefix.
+ */
+ public static final String JAVA_PREFIX = "org.omg.";
+
+ /**
+ * Try to instantiate an object with the given IDL name.
+ * The object must be mapped to the local java class.
+ *
+ * @param IDL name
+ * @return instantiated object instance or null if no such
+ * available.
+ */
+ public static java.lang.Object createObject(String idl, String suffix)
+ {
+ try
+ {
+ return Class.forName(toClassName(idl) + suffix).newInstance();
+ }
+ catch (Exception ex)
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Create the system exception with the given idl name.
+ *
+ * @param idl the exception IDL name, must match the syntax
+ * "IDL:<class/name>:1.0".
+ * @param minor the exception minor code.
+ * @param completed the exception completion status.
+ *
+ * @return the created exception.
+ */
+ public static SystemException createSystemException(String idl, int minor,
+ CompletionStatus completed
+ )
+ {
+ try
+ {
+ String cl = toClassName(idl);
+ Class exClass = Class.forName(cl);
+
+ Constructor constructor =
+ exClass.getConstructor(new Class[]
+ {
+ String.class, int.class,
+ CompletionStatus.class
+ }
+ );
+
+ Object exception =
+ constructor.newInstance(new Object[]
+ {
+ " Remote exception " + idl + ", minor " +
+ minor + ", " + completed + ".",
+ new Integer(minor), completed
+ }
+ );
+
+ return (SystemException) exception;
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ return new UNKNOWN("Unsupported system exception", minor, completed);
+ }
+ }
+
+ /**
+ * Read the system exception from the given stream.
+ * @param input the CDR stream to read from.
+ * @return the exception that has been stored in the stream
+ * (IDL name, minor code and completion status).
+ */
+ public static SystemException readSystemException(InputStream input)
+ {
+ String idl = input.read_string();
+ int minor = input.read_ulong();
+ CompletionStatus status = CompletionStatusHelper.read(input);
+
+ SystemException exception =
+ ObjectCreator.createSystemException(idl, minor, status);
+
+ return exception;
+ }
+
+ /**
+ * Reads the user exception, having the given Id, from the
+ * input stream. The id is expected to be in the form like
+ * 'IDL:test/org/omg/CORBA/ORB/communication/ourUserException:1.0'
+ *
+ * @param idl the exception idl name.
+ * @param input the stream to read from.
+ *
+ * @return the loaded exception.
+ * @return null if the helper class cannot be found.
+ */
+ public static UserException readUserException(String idl, InputStream input)
+ {
+ try
+ {
+ String holder = toHelperName(idl);
+ Class holderClass = Class.forName(holder);
+
+ Method read =
+ holderClass.getMethod("read",
+ new Class[]
+ {
+ org.omg.CORBA.portable.InputStream.class
+ }
+ );
+
+ return (UserException) read.invoke(null, new Object[] { input });
+ }
+ catch (MARSHAL mex)
+ {
+ // This one is ok to throw
+ throw mex;
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ return null;
+ }
+ }
+
+ /**
+ * Gets the helper class name from the string like
+ * 'IDL:test/org/omg/CORBA/ORB/communication/ourUserException:1.0'
+ *
+ * @param IDL the idl name.
+ */
+ public static String toHelperName(String IDL)
+ {
+ String s = IDL;
+ int a = s.indexOf(':') + 1;
+ int b = s.lastIndexOf(':');
+
+ s = IDL.substring(a, b);
+
+ if (s.startsWith(OMG_PREFIX))
+ s = JAVA_PREFIX + s.substring(OMG_PREFIX.length());
+
+ return s.replace('/', '.') + "Helper";
+ }
+
+ /**
+ * Writes the system exception data to CDR output stream.
+ *
+ * @param output a stream to write data to.
+ * @param ex an exception to write.
+ */
+ public static void writeSystemException(OutputStream output,
+ SystemException ex
+ )
+ {
+ String exIDL = toIDL(ex.getClass().getName());
+ output.write_string(exIDL);
+ output.write_ulong(ex.minor);
+ CompletionStatusHelper.write(output, ex.completed);
+ }
+
+ /**
+ * Converts teh given IDL name to class name.
+ *
+ * @param IDL the idl name.
+ *
+ */
+ protected static String toClassName(String IDL)
+ {
+ String s = IDL;
+ int a = s.indexOf(':') + 1;
+ int b = s.lastIndexOf(':');
+
+ s = IDL.substring(a, b);
+
+ if (s.startsWith(OMG_PREFIX))
+ s = JAVA_PREFIX + s.substring(OMG_PREFIX.length());
+
+ return s.replace('/', '.');
+ }
+
+ /**
+ * Convert the class name to IDL name.
+ *
+ * @param cn the class name.
+ *
+ * @return the idl name.
+ */
+ protected static String toIDL(String cn)
+ {
+ if (cn.startsWith(JAVA_PREFIX))
+ cn = cn.substring(JAVA_PREFIX.length());
+
+ cn = cn.replace('.', '/');
+
+ return "IDL:" + OMG_PREFIX + cn + ":1.0";
+ }
+}
diff --git a/gnu/CORBA/OctetHolder.java b/gnu/CORBA/OctetHolder.java
new file mode 100644
index 000000000..9b0184c16
--- /dev/null
+++ b/gnu/CORBA/OctetHolder.java
@@ -0,0 +1,129 @@
+/* OctetHolder.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import gnu.CORBA.primitiveTypeCode;
+
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+
+/**
+ * A holder for CORBA <code>octet</code> that is mapped into
+ * java <code>long</code>.
+ *
+ * The holders have several application areas. The end user usually
+ * sees them implementing CORBA methods where the primitive type
+ * is passed by reference. While CORBA (or, for example, C) supports
+ * this, the java does not and a wrapper class is required.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public final class OctetHolder
+ implements Streamable
+{
+ /**
+ * The default type code for this holder.
+ */
+ private static final TypeCode t_octet =
+ new primitiveTypeCode(TCKind.tk_octet);
+
+ /**
+ * The <code>long</code> (CORBA <code>octet</code>) value,
+ * held by this OctetHolder.
+ */
+ public byte value;
+
+ /**
+ * Constructs an instance of OctetHolder,
+ * initializing {@link #value} to <code>0 </code>.
+ */
+ public OctetHolder()
+ {
+ }
+
+ /**
+ * Constructs an instance of OctetHolder,
+ * initializing {@link #value} to the given <code>octed</code> (byte).
+ *
+ * @param initial_value a value that will be assigned to the
+ * {@link #value} field.
+ */
+ public OctetHolder(byte initial_value)
+ {
+ value = initial_value;
+ }
+
+ /**
+ * Fill in the {@link value } field by reading the required data
+ * from the given stream. For <code>octet</code>, the functionality
+ * is delegated to
+ * {@link org.omg.CORBA.portable.InputStream#read_octet}.
+ *
+ * @param input the input stream to read from.
+ */
+ public void _read(InputStream input)
+ {
+ value = input.read_octet();
+ }
+
+ /**
+ * Returns the TypeCode, corresponding the CORBA type that is stored
+ * using this holder.
+ */
+ public TypeCode _type()
+ {
+ return t_octet;
+ }
+
+ /**
+ * Write the {@link value } field to the given stream.
+ * For <code>octet</code>, the functionality
+ * is delegated to
+ * {@link org.omg.CORBA.portable.OutputStream#write_octet(long) }.
+ *
+ * @param output the output stream to write into.
+ */
+ public void _write(OutputStream output)
+ {
+ output.write_octet(value);
+ }
+}
diff --git a/gnu/CORBA/Restricted_ORB.java b/gnu/CORBA/Restricted_ORB.java
new file mode 100644
index 000000000..8697f2874
--- /dev/null
+++ b/gnu/CORBA/Restricted_ORB.java
@@ -0,0 +1,368 @@
+/* RestrictedORB.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import gnu.CORBA.CDR.cdrBufOutput;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.ContextList;
+import org.omg.CORBA.Environment;
+import org.omg.CORBA.ExceptionList;
+import org.omg.CORBA.NO_IMPLEMENT;
+import org.omg.CORBA.NVList;
+import org.omg.CORBA.NamedValue;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.ORBPackage.InvalidName;
+import org.omg.CORBA.StructMember;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+import org.omg.CORBA.UnionMember;
+import org.omg.CORBA.portable.OutputStream;
+
+import java.applet.Applet;
+
+import java.util.Properties;
+
+/**
+ * This class implements so-called Singleton ORB, a highly restricted version
+ * that cannot communicate over network. This ORB is provided
+ * for the potentially malicious applets with heavy security restrictions.
+ * It, however, supports some basic features that might be needed even
+ * when the network access is not granted.
+ *
+ * This ORB can only create typecodes,
+ * {@link Any}, {@link ContextList}, {@link NVList} and
+ * {@link org.omg.CORBA.portable.OutputStream} that writes to an
+ * internal buffer.
+ *
+ * All other methods throw the {@link NO_IMPLEMENT} exception.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class Restricted_ORB
+ extends ORB
+{
+ /**
+ * The singleton instance of this ORB.
+ */
+ public static final ORB Singleton = new Restricted_ORB();
+
+ /**
+ * Create a new instance of the RestrictedORB. This is used
+ * in derived classes only.
+ */
+ protected Restricted_ORB()
+ {
+ }
+
+ /** {@inheritDoc} */
+ public TypeCode create_alias_tc(String id, String name, TypeCode typecode)
+ {
+ return new aliasTypeCode(typecode, id, name);
+ }
+
+ /** {@inheritDoc} */
+ public Any create_any()
+ {
+ return new gnuAny();
+ }
+
+ /** {@inheritDoc} */
+ public TypeCode create_array_tc(int length, TypeCode element_type)
+ {
+ primitiveArrayTypeCode p =
+ new primitiveArrayTypeCode(TCKind.tk_array, element_type);
+ p.setLength(length);
+ return p;
+ }
+
+ /** {@inheritDoc} */
+ public ContextList create_context_list()
+ {
+ return new gnuContextList();
+ }
+
+ /** {@inheritDoc} */
+ public TypeCode create_enum_tc(String id, String name, String[] values)
+ {
+ recordTypeCode r = new recordTypeCode(TCKind.tk_enum);
+ for (int i = 0; i < values.length; i++)
+ {
+ r.field().name = values [ i ];
+ }
+
+ r.setId(id);
+ r.setName(name);
+
+ return r;
+ }
+
+ /** {@inheritDoc} */
+ public Environment create_environment()
+ {
+ return new gnuEnvironment();
+ }
+
+ /** {@inheritDoc} */
+ public ExceptionList create_exception_list()
+ {
+ return new gnuExceptionList();
+ }
+
+ /** {@inheritDoc} */
+ public TypeCode create_exception_tc(String id, String name,
+ StructMember[] members
+ )
+ {
+ recordTypeCode r = new recordTypeCode(TCKind.tk_except);
+ r.setId(id);
+ r.setName(name);
+
+ for (int i = 0; i < members.length; i++)
+ {
+ r.add(members [ i ]);
+ }
+
+ return r;
+ }
+
+ /**
+ * This method is not allowed for a RestrictedORB.
+ *
+ * @throws NO_IMPLEMENT, always.
+ */
+ public TypeCode create_interface_tc(String id, String name)
+ {
+ no();
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ public NVList create_list(int count)
+ {
+ return new gnuNVList(count);
+ }
+
+ /** {@inheritDoc} */
+ public NamedValue create_named_value(String s, Any any, int flags)
+ {
+ return new gnuNamedValue();
+ }
+
+ /** {@inheritDoc} */
+ public OutputStream create_output_stream()
+ {
+ cdrBufOutput stream = new cdrBufOutput();
+ stream.setOrb(this);
+ return stream;
+ }
+
+ /** {@inheritDoc} */
+ public TypeCode create_sequence_tc(int bound, TypeCode element_type)
+ {
+ primitiveArrayTypeCode p =
+ new primitiveArrayTypeCode(TCKind.tk_sequence, element_type);
+ p.setLength(bound);
+ return p;
+ }
+
+ /** {@inheritDoc} */
+ public TypeCode create_string_tc(int bound)
+ {
+ stringTypeCode p = new stringTypeCode(TCKind.tk_string);
+ p.setLength(bound);
+ return p;
+ }
+
+ /** {@inheritDoc} */
+ public TypeCode create_struct_tc(String id, String name,
+ StructMember[] members
+ )
+ {
+ recordTypeCode r = new recordTypeCode(TCKind.tk_struct);
+ r.setId(id);
+ r.setName(name);
+
+ for (int i = 0; i < members.length; i++)
+ {
+ r.add(members [ i ]);
+ }
+
+ return r;
+ }
+
+ /** {@inheritDoc} */
+ public TypeCode create_union_tc(String id, String name, TypeCode type,
+ UnionMember[] members
+ )
+ {
+ recordTypeCode r = new recordTypeCode(TCKind.tk_union);
+ r.setId(id);
+ r.setName(name);
+
+ for (int i = 0; i < members.length; i++)
+ {
+ r.add(members [ i ]);
+ }
+
+ return r;
+ }
+
+ /** {@inheritDoc} */
+ public TypeCode create_wstring_tc(int bound)
+ {
+ stringTypeCode p = new stringTypeCode(TCKind.tk_wstring);
+ p.setLength(bound);
+ return p;
+ }
+
+ /** {@inheritDoc} */
+ public TypeCode get_primitive_tc(TCKind tcKind)
+ {
+ try
+ {
+ return typeNamer.getPrimitveTC(tcKind);
+ }
+ catch (BadKind ex)
+ {
+ throw new BAD_PARAM("This is not a primitive type code: " +
+ tcKind.value()
+ );
+ }
+ }
+
+ /**
+ * This method is not allowed for a RestrictedORB.
+ *
+ * @throws NO_IMPLEMENT, always.
+ */
+ public String[] list_initial_services()
+ {
+ no();
+ throw new InternalError();
+ }
+
+ /**
+ * This method is not allowed for a RestrictedORB.
+ *
+ * @throws NO_IMPLEMENT, always.
+ */
+ public String object_to_string(org.omg.CORBA.Object forObject)
+ {
+ no();
+ throw new InternalError();
+ }
+
+ /**
+ * This method is not allowed for a RestrictedORB.
+ *
+ * @throws InvalidName never in this class, but it is thrown
+ * in the derived classes.
+ *
+ * @throws NO_IMPLEMENT, always.
+ */
+ public org.omg.CORBA.Object resolve_initial_references(String name)
+ throws InvalidName
+ {
+ no();
+ throw new InternalError();
+ }
+
+ /**
+ * Shutdown the ORB server.
+ *
+ * For RestrictedORB, returns witout action.
+ */
+ public void run()
+ {
+ }
+
+ /**
+ * Shutdown the ORB server.
+ *
+ * For RestrictedORB, returns witout action.
+ */
+ public void shutdown(boolean wait_for_completion)
+ {
+ }
+
+ /**
+ * This method is not allowed for a RestrictedORB.
+ *
+ * @throws NO_IMPLEMENT, always.
+ */
+ public org.omg.CORBA.Object string_to_object(String IOR)
+ {
+ no();
+ throw new InternalError();
+ }
+
+ /**
+ * This method is not allowed for a RestrictedORB.
+ *
+ * @throws NO_IMPLEMENT, always.
+ */
+ protected void set_parameters(Applet app, Properties props)
+ {
+ no();
+ }
+
+ /**
+ * This method is not allowed for a RestrictedORB.
+ *
+ * @throws NO_IMPLEMENT, always.
+ */
+ protected void set_parameters(String[] args, Properties props)
+ {
+ no();
+ }
+
+ /**
+ * Throws an exception, stating that the given method is not supported
+ * by the Restricted ORB.
+ */
+ private final void no()
+ {
+ // Apart the programming errors, this can only happen if the
+ // malicious code is trying to do that it is not allowed.
+ throw new NO_IMPLEMENT("Use init(args, props) for the functional version.");
+ }
+}
diff --git a/gnu/CORBA/Simple_delegate.java b/gnu/CORBA/Simple_delegate.java
new file mode 100644
index 000000000..9d6aab060
--- /dev/null
+++ b/gnu/CORBA/Simple_delegate.java
@@ -0,0 +1,250 @@
+/* Local_delegate.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import org.omg.CORBA.Context;
+import org.omg.CORBA.ContextList;
+import org.omg.CORBA.ExceptionList;
+import org.omg.CORBA.NO_IMPLEMENT;
+import org.omg.CORBA.NVList;
+import org.omg.CORBA.NamedValue;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Request;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.CORBA.portable.ObjectImpl;
+
+/**
+ * The delegate, implementing the basic functionality only. This delegate
+ * is set in {@link ORG.connect(org.omg.CORBA.Object)} if ORB
+ * determines that the object is an instance of the
+ * {@link org.omg.CORBA.portable.ObjectImpl} and no other delegate is set.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class Simple_delegate
+ extends Delegate
+{
+ /**
+ * The orb.
+ */
+ protected final ORB orb;
+
+ /**
+ * The ior.
+ */
+ protected IOR ior;
+
+ public Simple_delegate(ORB an_orb, IOR an_ior)
+ {
+ orb = an_orb;
+ ior = an_ior;
+ }
+
+ /**
+ * Set the IOR of this object. The IOR must be newly set if
+ * the server reports that the object has permanently moved to a new
+ * location.
+ *
+ * @param an_ior the new IOR.
+ */
+ public void setIor(IOR an_ior)
+ {
+ this.ior = an_ior;
+ }
+
+ /**
+ * Get the IOR of this object.
+ */
+ public IOR getIor()
+ {
+ return ior;
+ }
+
+ /**
+ * Not implemented.
+ *
+ * @throws NO_IMPLEMENT, always.
+ */
+ public Request create_request(org.omg.CORBA.Object target, Context context,
+ String operation, NVList parameters,
+ NamedValue returns
+ )
+ {
+ throw new NO_IMPLEMENT();
+ }
+
+ /**
+ * Not implemented.
+ *
+ * @throws NO_IMPLEMENT, always.
+ */
+ public Request create_request(org.omg.CORBA.Object target, Context context,
+ String operation, NVList parameters,
+ NamedValue returns, ExceptionList exceptions,
+ ContextList ctx_list
+ )
+ {
+ throw new NO_IMPLEMENT();
+ }
+
+ /**
+ * Not implemented.
+ *
+ * @throws NO_IMPLEMENT, always.
+ */
+ public org.omg.CORBA.Object duplicate(org.omg.CORBA.Object target)
+ {
+ throw new NO_IMPLEMENT();
+ }
+
+ /**
+ * Performs direct comparison ('==').
+ */
+ public boolean equals(org.omg.CORBA.Object self, org.omg.CORBA.Object other)
+ {
+ return self == other;
+ }
+
+ /**
+ * Not implemented.
+ *
+ * @throws NO_IMPLEMENT, always.
+ */
+ public org.omg.CORBA.Object get_interface_def(org.omg.CORBA.Object target)
+ {
+ throw new NO_IMPLEMENT();
+ }
+
+ /**
+ * Return the hashcode (0 <= hashcode < maximum).
+ */
+ public int hash(org.omg.CORBA.Object target, int maximum)
+ {
+ return target == null ? 0 : target.hashCode() % maximum;
+ }
+
+ /**
+ * Delegates functionality to java.lang.Object.hashCode();
+ */
+ public int hashCode(org.omg.CORBA.Object target)
+ {
+ return target == null ? 0 : target.hashCode();
+ }
+
+ /**
+ * Check if this object can be referenced by the given repository id.
+ *
+ * @param target the CORBA object, must be an instance of
+ * {@link org.omg.CORBA.portable.ObjectImpl}.
+ *
+ * @param repositoryIdentifer the repository id.
+ *
+ * @return true if the passed parameter is a repository id of this
+ * CORBA object.
+ */
+ public boolean is_a(org.omg.CORBA.Object target, String repositoryIdentifer)
+ {
+ if (!(target instanceof ObjectImpl))
+ throw new NO_IMPLEMENT("Supported only for org.omg.CORBA.portable.ObjectImpl");
+
+ ObjectImpl imp = (ObjectImpl) target;
+ String[] ids = imp._ids();
+
+ for (int i = 0; i < ids.length; i++)
+ {
+ if (ids [ i ].equals(repositoryIdentifer))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Only returns true if the objects are equal ('==').
+ */
+ public boolean is_equivalent(org.omg.CORBA.Object target,
+ org.omg.CORBA.Object other
+ )
+ {
+ return target == other;
+ }
+
+ /**
+ * Returns true by default.
+ */
+ public boolean is_local(org.omg.CORBA.Object self)
+ {
+ return true;
+ }
+
+ /**
+ * Returns true if the target is null.
+ */
+ public boolean non_existent(org.omg.CORBA.Object target)
+ {
+ return target == null;
+ }
+
+ /**
+ * Returns the ORB, passed in constructor,
+ * regardless of the argument. This class requires a single instance
+ * per each object.
+ */
+ public ORB orb(org.omg.CORBA.Object target)
+ {
+ return orb;
+ }
+
+ /**
+ * Returns without action.
+ */
+ public void release(org.omg.CORBA.Object target)
+ {
+ }
+
+ /**
+ * Not implemented for this delegate.
+ *
+ * @throws NO_IMPLEMENT, always.
+ */
+ public Request request(org.omg.CORBA.Object target, String operation)
+ {
+ /**@todo Implement this org.omg.CORBA.portable.Delegate abstract method*/
+ throw new java.lang.UnsupportedOperationException("Method request() not yet implemented.");
+ }
+}
diff --git a/gnu/CORBA/TypeCodeHelper.java b/gnu/CORBA/TypeCodeHelper.java
new file mode 100644
index 000000000..163ebbeb9
--- /dev/null
+++ b/gnu/CORBA/TypeCodeHelper.java
@@ -0,0 +1,297 @@
+/* TypeCodeHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+import org.omg.CORBA.TypeCodePackage.Bounds;
+
+/**
+ * Reads and writes the TypeCodes usind common data representation.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class TypeCodeHelper
+{
+ /**
+ * Read the CORBA {@link TypeCode}. First, the TypeCode kind
+ * is read as four byte long. Then, if needed, the additional
+ * parameters are loaded following CORBA specification.
+ *
+ * @param in a stream to read from.
+ */
+ public static TypeCode read(org.omg.CORBA.portable.InputStream in)
+ throws BadKind, Bounds
+ {
+ TCKind kind = TCKind.from_int(in.read_long());
+ TypeCode rt;
+ generalTypeCode g;
+ recordTypeCode r;
+ recordTypeCode.Field f;
+ stringTypeCode s;
+ int n;
+
+ switch (kind.value())
+ {
+ case TCKind._tk_sequence :
+ case TCKind._tk_array :
+
+ primitiveArrayTypeCode p = new primitiveArrayTypeCode(kind);
+ p.setLength(in.read_long());
+ rt = p;
+ break;
+
+ case TCKind._tk_string :
+ case TCKind._tk_wstring :
+ s = new stringTypeCode(kind);
+ s.setLength(in.read_long());
+ rt = s;
+ break;
+
+ case TCKind._tk_fixed :
+
+ fixedTypeCode fx = new fixedTypeCode();
+ fx.setDigits(in.read_short());
+ fx.setScale(in.read_short());
+ rt = fx;
+ break;
+
+ case TCKind._tk_objref :
+ case TCKind._tk_native :
+ case TCKind._tk_abstract_interface :
+ g = new generalTypeCode(kind);
+ g.setId(in.read_string());
+ g.setName(in.read_string());
+ rt = g;
+ break;
+
+ case TCKind._tk_alias :
+ case TCKind._tk_value_box :
+ g = new generalTypeCode(kind);
+ g.setId(in.read_string());
+ g.setName(in.read_string());
+ g.setContentType(in.read_TypeCode());
+ rt = g;
+ break;
+
+ case TCKind._tk_struct :
+ case TCKind._tk_except :
+ r = new recordTypeCode(kind);
+ r.setId(in.read_string());
+ r.setName(in.read_string());
+
+ n = in.read_long();
+
+ for (int i = 0; i < n; i++)
+ {
+ f = r.field();
+ f.name = in.read_string();
+ f.type = in.read_TypeCode();
+ }
+ rt = r;
+ break;
+
+ case TCKind._tk_enum :
+ r = new recordTypeCode(kind);
+ r.setId(in.read_string());
+ r.setName(in.read_string());
+
+ n = in.read_long();
+
+ for (int i = 0; i < n; i++)
+ {
+ f = r.field();
+ f.name = in.read_string();
+ }
+ rt = r;
+ break;
+
+ case TCKind._tk_union :
+ r = new recordTypeCode(kind);
+ r.setId(in.read_string());
+ r.setName(in.read_string());
+ r.setDiscriminator_type(in.read_TypeCode());
+ r.setDefaultIndex(in.read_long());
+
+ n = in.read_long();
+
+ for (int i = 0; i < n; i++)
+ {
+ f = r.field();
+ f.label = in.read_any();
+ f.name = in.read_string();
+ f.type = in.read_TypeCode();
+ }
+ rt = r;
+
+ break;
+
+ case TCKind._tk_value :
+ r = new recordTypeCode(kind);
+ r.setId(in.read_string());
+ r.setName(in.read_string());
+ r.setTypeModifier(in.read_short());
+ r.setConcreteBase_type(in.read_TypeCode());
+
+ n = in.read_long();
+
+ for (int i = 0; i < n; i++)
+ {
+ f = r.field();
+ f.name = in.read_string();
+ f.type = in.read_TypeCode();
+ f.visibility = in.read_short();
+ }
+ rt = r;
+ break;
+
+ default :
+ rt = new primitiveTypeCode(kind);
+ }
+ return rt;
+ }
+
+ /**
+ * Write the CORBA {@link TypeCode}. First, the TypeCode kind
+ * is written as four byte long. Then, if needed, the additional
+ * parameters are stored following CORBA specification.
+ *
+ * @param out a stream to write into.
+ * @param x a {@link TypeCode} to write.
+ */
+ public static void write(org.omg.CORBA.portable.OutputStream out, TypeCode x)
+ throws BadKind, Bounds
+ {
+ out.write_long(x.kind().value());
+
+ switch (x.kind().value())
+ {
+ case TCKind._tk_string :
+ case TCKind._tk_wstring :
+ out.write_long(x.length());
+ break;
+
+ case TCKind._tk_sequence :
+ case TCKind._tk_array :
+ write(out, x.content_type());
+ out.write_long(x.length());
+ break;
+
+ case TCKind._tk_fixed :
+ out.write_short(x.fixed_digits());
+ out.write_short(x.fixed_scale());
+ break;
+
+ case TCKind._tk_objref :
+ case TCKind._tk_native :
+ case TCKind._tk_abstract_interface :
+ out.write_string(x.id());
+ out.write_string(x.name());
+ break;
+
+ case TCKind._tk_alias :
+ case TCKind._tk_value_box :
+ out.write_string(x.id());
+ out.write_string(x.name());
+ write(out, x.content_type());
+ break;
+
+ case TCKind._tk_struct :
+ case TCKind._tk_except :
+ out.write_string(x.id());
+ out.write_string(x.name());
+
+ out.write_long(x.member_count());
+
+ for (int i = 0; i < x.member_count(); i++)
+ {
+ out.write_string(x.member_name(i));
+ write(out, x.member_type(i));
+ }
+ break;
+
+ case TCKind._tk_enum :
+ out.write_string(x.id());
+ out.write_string(x.name());
+
+ out.write_long(x.member_count());
+
+ for (int i = 0; i < x.member_count(); i++)
+ {
+ out.write_string(x.member_name(i));
+ }
+ break;
+
+ case TCKind._tk_union :
+ out.write_string(x.id());
+ out.write_string(x.name());
+
+ write(out, x.discriminator_type());
+ out.write_long(x.default_index());
+
+ out.write_long(x.member_count());
+
+ for (int i = 0; i < x.member_count(); i++)
+ {
+ out.write_any(x.member_label(i));
+ out.write_string(x.member_name(i));
+ write(out, x.member_type(i));
+ }
+ break;
+
+ case TCKind._tk_value :
+ out.write_string(x.id());
+ out.write_string(x.name());
+ out.write_short(x.type_modifier());
+ write(out, x.concrete_base_type());
+
+ out.write_long(x.member_count());
+
+ for (int i = 0; i < x.member_count(); i++)
+ {
+ out.write_string(x.member_name(i));
+ write(out, x.member_type(i));
+ out.write_short(x.member_visibility(i));
+ }
+ break;
+
+ default :}
+ }
+}
diff --git a/gnu/CORBA/Unexpected.java b/gnu/CORBA/Unexpected.java
new file mode 100644
index 000000000..f030d4dfc
--- /dev/null
+++ b/gnu/CORBA/Unexpected.java
@@ -0,0 +1,128 @@
+/* DNW.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+
+/**
+ * Contains the static method to throw an error in the case
+ * when the execution should never get into the current point.
+ *
+ * The error message contains the text, suggesting to check
+ * the user code first and then report a bug.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class Unexpected
+ extends InternalError
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The default message for the CORBA assertion error.
+ */
+ public static final String SHARED_MESSAGE =
+ "CORBA assertion error. Please check your code. " +
+ "If you think it is Classpath problem, please report " +
+ "this bug providing as much information as possible.";
+
+ /**
+ * Create an instance with explaining message and enclosing
+ * exception.
+ */
+ public Unexpected(String msg, Exception why)
+ {
+ super(msg + ". " + SHARED_MESSAGE);
+ if (why != null)
+ initCause(why);
+ }
+
+ /**
+ * Create an instance with enclosing exception.
+ */
+ public Unexpected(Exception why)
+ {
+ super(SHARED_MESSAGE);
+ if (why != null)
+ initCause(why);
+ }
+
+ /**
+ * Create an instance.
+ */
+ public Unexpected()
+ {
+ super(SHARED_MESSAGE);
+ }
+
+ /**
+ * Throws an error with the custom explaining message and
+ * the appended share message.
+ *
+ * @param msg the error message
+ * @param why the enclosing exception.
+ */
+ public static void error(String msg, Exception why)
+ {
+ throw new Unexpected(msg, why);
+ }
+
+ /**
+ * Throws an error with the shared explaining message.
+ *
+ * @param why the enclosing exception.
+ * @throws Error, always.
+ */
+ public static void error(Exception why)
+ {
+ throw new Unexpected(why);
+ }
+
+ /**
+ * Throws an error with the shared explaining message.
+ *
+ * @throws Error, always.
+ */
+ public static void error()
+ {
+ throw new Unexpected();
+ }
+}
diff --git a/gnu/CORBA/Version.java b/gnu/CORBA/Version.java
new file mode 100644
index 000000000..64ef01853
--- /dev/null
+++ b/gnu/CORBA/Version.java
@@ -0,0 +1,206 @@
+/* Version.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import java.io.IOException;
+import java.io.Serializable;
+
+import org.omg.CORBA.MARSHAL;
+
+/**
+ * A version number, represented by the major version number
+ * and the minor version number.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class Version
+ implements Serializable
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * Major number (0..256, so the byte cannot be used).
+ */
+ public final int major;
+
+ /**
+ * Minor number.
+ */
+ public final int minor;
+
+ /**
+ * Create the version with the given version numbers.
+ *
+ * @param major major number (0..255)
+ * @param minor minor number (0..255)
+ */
+ public Version(int _major, int _minor)
+ {
+ major = (byte) _major;
+ minor = (byte) _minor;
+ }
+
+ /**
+ * Returns true if the versions are equal.
+ * @param other the other version to compare.
+ *
+ * @return true if the versions are equal
+ */
+ public boolean equals(java.lang.Object other)
+ {
+ if (other == this)
+ {
+ return true;
+ }
+ if (!(other instanceof Version))
+ {
+ return false;
+ }
+
+ Version that = (Version) other;
+ return same(that);
+ }
+
+ /**
+ * Read from the input stream, major number first.
+ * @param in a stream to read from.
+ */
+ public static Version read_version(java.io.InputStream in)
+ {
+ try
+ {
+ int major = in.read() & 0xFF;
+ int minor = in.read() & 0xFF;
+ return new Version(major, minor);
+ }
+ catch (IOException ex)
+ {
+ throw new MARSHAL("IOException while reading message header");
+ }
+ }
+
+ /**
+ * Returns true if the versions are the same.
+ *
+ * @param that the other version to compare.
+ *
+ * @return true if the versions are the same.
+ */
+ public boolean same(Version that)
+ {
+ return major == that.major && minor == that.minor;
+ }
+
+ /**
+ * Returns true if the given version is higher than
+ * or equals to the version, supplied as parameter
+ * in the form of two integers.
+ *
+ * @param a_major major number of the version to compare.
+ * @param a_minor minor number of the version to compare.
+ *
+ * @return true if this version is higher than or equals to
+ * the version v.
+ */
+ public boolean since_inclusive(int a_major, int a_minor)
+ {
+ if (major > a_major)
+ return true;
+ else if (major < a_major)
+ return false;
+ else
+
+ // Major numbers are equal.
+ return minor >= a_minor;
+ }
+
+ /**
+ * Return the string representation, in the form
+ * major.minor.
+ */
+ public String toString()
+ {
+ return major + "." + minor;
+ }
+
+ /**
+ * Returs true if the given version is lower or equal to the
+ * version, specified by the provided minor and major version
+ * number. This means, the version, specified by these two numbers,
+ * should be supported by teh current version.
+ *
+ * @param a_major a major version number.
+ * @param a_minor a minor version number.
+ *
+ * @return true if the current version should be supported by the
+ * version, specified by the two passed numbers.
+ */
+ public boolean until_inclusive(int a_major, int a_minor)
+ {
+ if (major < a_major)
+ return true;
+ else if (major > a_major)
+ return false;
+ else
+
+ // Major numbers are equal.
+ return minor <= a_minor;
+ }
+
+ /**
+ * Write into the output stream, major number first.
+ *
+ * @param out a stream to write into.
+ */
+ public void write(java.io.OutputStream out)
+ {
+ try
+ {
+ out.write(major & 0xFF);
+ out.write(minor & 0xFF);
+ }
+ catch (IOException ex)
+ {
+ throw new MARSHAL("IOException while writing message header");
+ }
+ }
+}
diff --git a/gnu/CORBA/WCharHolder.java b/gnu/CORBA/WCharHolder.java
new file mode 100644
index 000000000..baa768fdf
--- /dev/null
+++ b/gnu/CORBA/WCharHolder.java
@@ -0,0 +1,126 @@
+/* WCharHolder.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+
+/**
+ * A holder for CORBA <code>char</code> that is mapped into
+ * java <code>char</code>.
+ *
+ * The holders have several application areas. The end user usually
+ * sees them implementing CORBA methods where the primitive type
+ * is passed by reference. While CORBA (or, for example, C) supports
+ * this, the java does not and a wrapper class is required.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public final class WCharHolder
+ implements Streamable
+{
+ /**
+ * The default type code for this holder.
+ */
+ private static final TypeCode t_char = new primitiveTypeCode(TCKind.tk_wchar);
+
+ /**
+ * The <code>char</code> (CORBA <code>wchar</code>) value,
+ * held by this WCharHolder.
+ */
+ public char value;
+
+ /**
+ * Constructs an instance of WCharHolder,
+ * initializing {@link #value} to <code>0 </code>.
+ */
+ public WCharHolder()
+ {
+ }
+
+ /**
+ * Constructs an instance of WCharHolder,
+ * initializing {@link #value} to the given <code>char</code>.
+ *
+ * @param initial_value a value that will be assigned to the
+ * {@link #value} field.
+ */
+ public WCharHolder(char initial_value)
+ {
+ value = initial_value;
+ }
+
+ /**
+ * Fill in the {@link value } field by reading the required data
+ * from the given stream. For <code>char</code>, the functionality
+ * is delegated to
+ * {@link org.omg.CORBA.portable.InputStream#read_wchar}.
+ *
+ * @param input the input stream to read from.
+ */
+ public void _read(InputStream input)
+ {
+ value = input.read_wchar();
+ }
+
+ /**
+ * Returns the TypeCode, corresponding the CORBA type that is stored
+ * using this holder.
+ */
+ public TypeCode _type()
+ {
+ return t_char;
+ }
+
+ /**
+ * Write the {@link value } field to the given stream.
+ * For <code>char</code>, the functionality
+ * is delegated to
+ * {@link org.omg.CORBA.portable.OutputStream#write_wchar(char) }.
+ *
+ * @param output the output stream to write into.
+ */
+ public void _write(OutputStream output)
+ {
+ output.write_wchar(value);
+ }
+}
diff --git a/gnu/CORBA/WStringHolder.java b/gnu/CORBA/WStringHolder.java
new file mode 100644
index 000000000..84ffcae96
--- /dev/null
+++ b/gnu/CORBA/WStringHolder.java
@@ -0,0 +1,129 @@
+/* WStringHolder.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+
+/**
+ * A holder for CORBA <code>wstring</code> that is mapped into
+ * java <code>String</code>. This holder writes and reads differently
+ * from the StringHolder.
+ *
+ * The holders have several application areas. The end user usually
+ * sees them implementing CORBA methods where the primitive type
+ * is passed by reference. While CORBA (or, for example, C) supports
+ * this, the java does not and a wrapper class is required.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class WStringHolder
+ implements Streamable
+{
+ /**
+ * The default type code for this holder.
+ */
+ private static final stringTypeCode t_string =
+ new stringTypeCode(TCKind.tk_wstring);
+
+ /**
+ * The <code>String</code> (CORBA <code>string</code>) value,
+ * held by this WStringHolder.
+ */
+ public String value;
+
+ /**
+ * Constructs an instance of WStringHolder,
+ * initializing {@link #value} to <code>null</code>.
+ */
+ public WStringHolder()
+ {
+ }
+
+ /**
+ * Constructs an instance of WStringHolder,
+ * initializing {@link #value} to the given <code>String</code>.
+ *
+ * @param initial_value a value that will be assigned to the
+ * {@link #value} field.
+ */
+ public WStringHolder(String initial_value)
+ {
+ value = initial_value;
+ }
+
+ /**
+ * Fill in the {@link #value } field by reading the required data
+ * from the given stream. For <code>string</code>, the functionality
+ * is delegated to
+ * {@link org.omg.CORBA.portable.InputStream#read_wstring}.
+ *
+ * @param input the input stream to read from.
+ */
+ public void _read(InputStream input)
+ {
+ value = input.read_wstring();
+ }
+
+ /**
+ * Returns the TypeCode, corresponding the CORBA type that is stored
+ * using this holder. The {@link TypeCode#length()} method of the
+ * returned typecode always returns 0.
+ */
+ public TypeCode _type()
+ {
+ return t_string;
+ }
+
+ /**
+ * Write the {@link #value } field to the given stream.
+ * For <code>string</code>, the functionality
+ * is delegated to
+ * {@link org.omg.CORBA.portable.OutputStream#write_wstring(String) }.
+ *
+ * @param output the output stream to write into.
+ */
+ public void _write(OutputStream output)
+ {
+ output.write_wstring(value);
+ }
+}
diff --git a/gnu/CORBA/aliasTypeCode.java b/gnu/CORBA/aliasTypeCode.java
new file mode 100644
index 000000000..a211b641f
--- /dev/null
+++ b/gnu/CORBA/aliasTypeCode.java
@@ -0,0 +1,142 @@
+/* aliasTypeCode.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+
+/**
+ * The type code that is an alias of another type code.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class aliasTypeCode
+ extends primitiveTypeCode
+{
+ /**
+ * The typecode repository id.
+ */
+ protected final String id;
+
+ /**
+ * The typecode name.
+ */
+ protected final String name;
+
+ /**
+ * The type code for that this typecode is an alias.
+ */
+ protected final TypeCode aliasFor;
+
+ /**
+ * Create the typecode, specifying for that typecode it is an
+ * alias and the id and name of the newly created typecode.
+ *
+ * @param an_aliasFor the typecode, for that this typecode is an
+ * alias.
+ *
+ * @param an_id the repository id fo the newly created typecode.
+ *
+ * @param a_name the name of the newly created typecode.
+ */
+ public aliasTypeCode(TypeCode an_aliasFor, String an_id, String a_name)
+ {
+ super(TCKind.tk_alias);
+ aliasFor = an_aliasFor;
+ id = an_id;
+ name = a_name;
+ }
+
+ /**
+ * Get the typecode, for that this typecode is an alias.
+ */
+ public TypeCode content_type()
+ {
+ return aliasFor;
+ }
+
+ /**
+ * The objects are assumed to be equal if they repository
+ * ids are both equal or both unavailable and the
+ * kind values are equal.
+ *
+ * @param other the other typecode to compare.
+ */
+ public boolean equal(TypeCode other)
+ {
+ if (super.equal(other))
+ return true;
+ try
+ {
+ return id.equals(other.id());
+ }
+ catch (BadKind ex)
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Return true if the given typecode is equal for
+ * either this typecode of the alias typecode.
+ *
+ * @param other the typecode to compare.
+ */
+ public boolean equivalent(TypeCode other)
+ {
+ return other.equal(this) || other.equal(aliasFor);
+ }
+
+ /**
+ * Get the repository id of this typecode.
+ */
+ public String id()
+ {
+ return id;
+ }
+
+ /**
+ * Get the name of this typecode.
+ */
+ public String name()
+ {
+ return name;
+ }
+}
diff --git a/gnu/CORBA/binaryReply.java b/gnu/CORBA/binaryReply.java
new file mode 100644
index 000000000..44d9e8dc8
--- /dev/null
+++ b/gnu/CORBA/binaryReply.java
@@ -0,0 +1,94 @@
+/* binaryReply.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.CORBA;
+
+import gnu.CORBA.CDR.cdrBufInput;
+import gnu.CORBA.GIOP.MessageHeader;
+
+import org.omg.CORBA.ORB;
+
+/**
+ * The remote object reply in the binary form, holding
+ * the message header and the following binary data.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+class binaryReply
+{
+ /**
+ * The message header.
+ */
+ final MessageHeader header;
+
+ /**
+ * The associated orb.
+ */
+ final ORB orb;
+
+ /**
+ * The message data.
+ */
+ final byte[] data;
+
+ /**
+ * Create the binary reply.
+ *
+ * @param an_header the message header
+ * @param a_data the message data.
+ */
+ binaryReply(ORB an_orb, MessageHeader an_header, byte[] a_data)
+ {
+ orb = an_orb;
+ header = an_header;
+ data = a_data;
+ }
+
+ /**
+ * Get the CDR input stream with the correctly set alignment.
+ *
+ * @return the CDR stream to read the message data.
+ */
+ cdrBufInput getStream()
+ {
+ cdrBufInput in = new cdrBufInput(data);
+ in.setOffset(header.getHeaderSize());
+ in.setVersion(header.version);
+ in.setOrb(orb);
+ return in;
+ }
+}
diff --git a/gnu/CORBA/bufferedResponseHandler.java b/gnu/CORBA/bufferedResponseHandler.java
new file mode 100644
index 000000000..b7d51e711
--- /dev/null
+++ b/gnu/CORBA/bufferedResponseHandler.java
@@ -0,0 +1,187 @@
+/* bufferedResponseHandler.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.GIOP.MessageHeader;
+import gnu.CORBA.GIOP.ReplyHeader;
+import gnu.CORBA.GIOP.cxCodeSet;
+
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.ResponseHandler;
+
+/**
+ * Provides the CDR output streams for writing the response to the given
+ * buffer.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+class bufferedResponseHandler
+ implements ResponseHandler
+{
+ /**
+ * The message header.
+ * This field is used to compute the size and alignments.
+ * It is, however, never directly written to the buffer stream.
+ */
+ final MessageHeader message_header;
+
+ /**
+ * The associated orb.
+ */
+ final ORB orb;
+
+ /**
+ * The reply header. This field is used to compute the size and alignments.
+ * It is, however, never directly written to the buffer stream.
+ */
+ final ReplyHeader reply_header;
+
+ /**
+ * True if the stream was obtained by invoking {@link #createExceptionReply()},
+ * false otherwise.
+ */
+ private boolean exceptionReply;
+
+ /**
+ * The buffer to write into.
+ */
+ private cdrBufOutput buffer;
+
+ /**
+ * Create a new buffered response handler that uses the given message
+ * headers. The headers are used to compute sizes and check the versions.
+ * They are not written into a stream inside this class.
+ *
+ * @param m_header a message header.
+ * @param r_header a reply header.
+ */
+ bufferedResponseHandler(ORB an_orb, MessageHeader m_header,
+ ReplyHeader r_header
+ )
+ {
+ message_header = m_header;
+ reply_header = r_header;
+ orb = an_orb;
+ prepareStream();
+ }
+
+ /**
+ * Get an output stream for providing details about the exception.
+ * Before returning the stream, the handler automatically writes
+ * the message header and the reply about exception header,
+ * but not the message header.
+ *
+ * @return the stream to write exception details into.
+ */
+ public OutputStream createExceptionReply()
+ {
+ exceptionReply = true;
+ prepareStream();
+ return buffer;
+ }
+
+ /**
+ * Get an output stream for writing a regular reply (not an exception).
+ *
+ * Before returning the stream, the handler automatically writes
+ * the regular reply header, but not the message header.
+ *
+ * @return the output stream for writing a regular reply.
+ */
+ public OutputStream createReply()
+ {
+ exceptionReply = false;
+ prepareStream();
+ reply_header.reply_status = reply_header.NO_EXCEPTION;
+ return buffer;
+ }
+
+ /**
+ * Get the buffer, normally containing the written reply.
+ * The reply includes the reply header (or the exception header)
+ * but does not include the message header.
+ *
+ * The stream buffer can also be empty if no data have been written
+ * into streams, returned by {@link #createReply()} or
+ * {@link #createExceptionReply()}.
+ *
+ * @return the CDR output stream, containing the written output.
+ */
+ cdrBufOutput getBuffer()
+ {
+ return buffer;
+ }
+
+ /**
+ * True if the stream was obtained by invoking
+ * {@link #createExceptionReply()}, false otherwise
+ * (usually no-exception reply).
+ */
+ boolean isExceptionReply()
+ {
+ return exceptionReply;
+ }
+
+ /**
+ * Compute the header offset, set the correct version number and codeset.
+ */
+ private void prepareStream()
+ {
+ buffer = new cdrBufOutput();
+ buffer.setOrb(orb);
+ buffer.setOffset(message_header.getHeaderSize());
+
+ // Get the position after the reply header would be written.
+ reply_header.write(buffer);
+
+ int new_offset = message_header.getHeaderSize() + buffer.buffer.size();
+
+ buffer.buffer.reset();
+ buffer.setOffset(new_offset);
+
+ if (message_header.version.since_inclusive(1, 2))
+ buffer.align(8);
+
+ buffer.setVersion(message_header.version);
+
+ buffer.setCodeSet(cxCodeSet.find(reply_header.service_context));
+ }
+}
diff --git a/gnu/CORBA/corbaArrayList.java b/gnu/CORBA/corbaArrayList.java
new file mode 100644
index 000000000..7d531c092
--- /dev/null
+++ b/gnu/CORBA/corbaArrayList.java
@@ -0,0 +1,115 @@
+/* corbaArrayList.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import java.io.Serializable;
+
+import java.util.ArrayList;
+
+import org.omg.CORBA.Bounds;
+
+/**
+ * This class is used to store array lists. Differently from
+ * the java.util lists,
+ * it throws {@link org.omg.CORBA.Bounds} rather than
+ * {@link IndexOutOfBoundsException}.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class corbaArrayList
+ extends ArrayList
+ implements Serializable
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * Creates the list with the given initial size.
+ */
+ public corbaArrayList(int initial_size)
+ {
+ super(initial_size);
+ }
+
+ /**
+ * Creates the list with the default size.
+ */
+ public corbaArrayList()
+ {
+ }
+
+ /**
+ * Remove the item at the given index.
+ * @param at the index
+ * @throws org.omg.CORBA.Bounds if the index is out of bounds.
+ */
+ public void drop(int at)
+ throws Bounds
+ {
+ try
+ {
+ super.remove(at);
+ }
+ catch (IndexOutOfBoundsException ex)
+ {
+ throw new Bounds("[" + at + "], valid [0.." + size() + "]");
+ }
+ }
+
+ /**
+ * Get the item at the given index.
+ * @param at the index
+ * @return the item at the index
+ * @throws org.omg.CORBA.Bounds if the index is out of bounds.
+ */
+ public Object item(int at)
+ throws Bounds
+ {
+ try
+ {
+ return super.get(at);
+ }
+ catch (IndexOutOfBoundsException ex)
+ {
+ throw new Bounds("[" + at + "], valid [0.." + size() + "]");
+ }
+ }
+}
diff --git a/gnu/CORBA/fixedTypeCode.java b/gnu/CORBA/fixedTypeCode.java
new file mode 100644
index 000000000..4d09e043d
--- /dev/null
+++ b/gnu/CORBA/fixedTypeCode.java
@@ -0,0 +1,149 @@
+/* fixedTypeCode.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import java.math.BigDecimal;
+
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+
+/**
+ * A typecode for CORBA <code>fixed</code>
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class fixedTypeCode
+ extends primitiveTypeCode
+{
+ /**
+ * The number of the used digits.
+ */
+ private short digits;
+
+ /**
+ * The number of the digits after the decimal point.
+ */
+ private short scale;
+
+ /**
+ * Creates the instance of the fixed type code.
+ */
+ public fixedTypeCode()
+ {
+ super(TCKind.tk_fixed);
+ }
+
+ /**
+ * Creates the instance of the fixed type code,
+ * setting the digits and scale by example.
+ */
+ public fixedTypeCode(BigDecimal example)
+ {
+ super(TCKind.tk_fixed);
+ if (example != null)
+ {
+ setScale(example.scale());
+ setDigits(countDigits(example));
+ }
+ }
+
+ /**
+ * Set the number of digits.
+ */
+ public void setDigits(int a_digits)
+ {
+ this.digits = (short) a_digits;
+ }
+
+ /**
+ * Set the number of digits after the decimal point.
+ */
+ public void setScale(int a_scale)
+ {
+ this.scale = (short) a_scale;
+ }
+
+ /**
+ * Get the number of digits in thid BigDecimal
+ *
+ * @param x a BigDecimal to check.
+ */
+ public static int countDigits(BigDecimal number)
+ {
+ return number.unscaledValue().abs().toString().length();
+ }
+
+ public boolean equals(Object other)
+ {
+ if (other == this)
+ {
+ return true;
+ }
+ if (!(other instanceof TypeCode))
+ {
+ return false;
+ }
+ try
+ {
+ TypeCode that = (TypeCode) other;
+ return kind() == that.kind() && digits == that.fixed_digits() &&
+ scale == that.fixed_scale();
+ }
+ catch (BadKind ex)
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Get the number of digits.
+ */
+ public short fixed_digits()
+ {
+ return digits;
+ }
+
+ /**
+ * Get the number of digits after the decimal point.
+ */
+ public short fixed_scale()
+ {
+ return scale;
+ }
+}
diff --git a/gnu/CORBA/generalTypeCode.java b/gnu/CORBA/generalTypeCode.java
new file mode 100644
index 000000000..222e7afb3
--- /dev/null
+++ b/gnu/CORBA/generalTypeCode.java
@@ -0,0 +1,243 @@
+/* generalTypeCode.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import gnu.CORBA.CDR.cdrBufOutput;
+
+import java.util.Arrays;
+import java.util.BitSet;
+
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+
+/**
+ * A typecode for types, requiring to provide various additional
+ * properties but still not requiring to store the
+ * members of the structure. The property can be retrieved
+ * by the corresponding method if it has been previously assigned.
+ * Otherwise, a {@link BadKind} is thrown.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class generalTypeCode
+ extends primitiveTypeCode
+{
+ /**
+ * Indicates that the field value has not been previously set.
+ */
+ protected static int UNSET = -Integer.MIN_VALUE;
+
+ /**
+ * The kinds for that the length() must return 0 even if it
+ * has not been previously set.
+ */
+ private static final BitSet lengthAllowed = new BitSet();
+
+ static
+ {
+ lengthAllowed.set(TCKind._tk_array);
+ lengthAllowed.set(TCKind._tk_sequence);
+ lengthAllowed.set(TCKind._tk_string);
+ lengthAllowed.set(TCKind._tk_wstring);
+ }
+
+ private String id;
+ private String name;
+ private TypeCode concrete_base_type;
+ private TypeCode content_type;
+ private int len;
+ private int type_modifier = UNSET;
+
+ /**
+ * Create a new instance, setting kind to the given kind.
+ * @param kind
+ */
+ public generalTypeCode(TCKind kind)
+ {
+ super(kind);
+ if (!lengthAllowed.get(kind.value()))
+ len = UNSET;
+ }
+
+ /**
+ * Set this property.
+ */
+ public void setConcreteBase_type(TypeCode concrete_base_type)
+ {
+ this.concrete_base_type = concrete_base_type;
+ }
+
+ /**
+ * Set the component content type.
+ */
+ public void setContentType(TypeCode a_content_type)
+ {
+ this.content_type = a_content_type;
+ }
+
+ /**
+ * Set this property.
+ */
+ public void setId(String id)
+ {
+ this.id = id;
+ }
+
+ /**
+ * Set the length property.
+ * @param l
+ */
+ public void setLength(int l)
+ {
+ len = l;
+ }
+
+ /**
+ * Set this property.
+ */
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * Set the type modifier.
+ */
+ public void setTypeModifier(int a_type_modifier)
+ {
+ this.type_modifier = a_type_modifier;
+ }
+
+ /** {@inheritDoc} */
+ public TypeCode concrete_base_type()
+ throws BadKind
+ {
+ if (concrete_base_type != null)
+ return concrete_base_type;
+ throw new BadKind("concrete_base_type");
+ }
+
+ /**
+ * Returns the content type that must be explicitly set
+ * for this class.
+ *
+ * @throws BadKind if the content type has not been set.
+ */
+ public TypeCode content_type()
+ throws BadKind
+ {
+ if (content_type != null)
+ return content_type;
+ throw new BadKind("content_type");
+ }
+
+ /**
+ * Returns true if both typecodes, if written into CDR
+ * stream, would result the same stream content.
+ */
+ public boolean equal(TypeCode other)
+ {
+ if (this == other)
+ return true;
+ if (kind() != other.kind())
+ return false;
+
+ cdrBufOutput a = new cdrBufOutput(16);
+ cdrBufOutput b = new cdrBufOutput(16);
+
+ a.write_TypeCode(this);
+ b.write_TypeCode(other);
+
+ return Arrays.equals(a.buffer.toByteArray(), b.buffer.toByteArray());
+ }
+
+ /**
+ * Delegates functionality to {@link #equal}.
+ */
+ public boolean equivalent(TypeCode other)
+ {
+ return equal(other);
+ }
+
+ /** {@inheritDoc} */
+ public String id()
+ throws BadKind
+ {
+ if (id != null)
+ return id;
+ throw new BadKind("id");
+ }
+
+ /**
+ * Get the length. For sequences, arrays, strings and wstrings
+ * this method returns 0 rather than throwing a BadKind even
+ * if {@link setLength(int)} has not been previously called.
+ *
+ * @return the length of string, array or sequence.
+ *
+ * @throws BadKind if the method cannot be invoked for the
+ * given kind of typecode.
+ */
+ public int length()
+ throws BadKind
+ {
+ if (len != UNSET)
+ return len;
+ throw new BadKind("length");
+ }
+
+ /** {@inheritDoc} */
+ public String name()
+ throws BadKind
+ {
+ if (name != null)
+ return name;
+ throw new BadKind("name");
+ }
+
+ /** {@inheritDoc} */
+ public short type_modifier()
+ throws BadKind
+ {
+ if (type_modifier != UNSET)
+ return (short) type_modifier;
+ throw new BadKind("type_modifier");
+ }
+}
diff --git a/gnu/CORBA/gnuAny.java b/gnu/CORBA/gnuAny.java
new file mode 100644
index 000000000..c5da988de
--- /dev/null
+++ b/gnu/CORBA/gnuAny.java
@@ -0,0 +1,788 @@
+/* gnuAny.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import gnu.CORBA.CDR.cdrBufInput;
+import gnu.CORBA.CDR.cdrBufOutput;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.AnyHolder;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.BooleanHolder;
+import org.omg.CORBA.CharHolder;
+import org.omg.CORBA.DoubleHolder;
+import org.omg.CORBA.FixedHolder;
+import org.omg.CORBA.FloatHolder;
+import org.omg.CORBA.IntHolder;
+import org.omg.CORBA.LongHolder;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.NO_IMPLEMENT;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.ObjectHolder;
+import org.omg.CORBA.Principal;
+import org.omg.CORBA.PrincipalHolder;
+import org.omg.CORBA.ShortHolder;
+import org.omg.CORBA.StringHolder;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodeHolder;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+import org.omg.CORBA.portable.Streamable;
+
+import java.io.IOException;
+import java.io.Serializable;
+
+import java.math.BigDecimal;
+
+import java.util.Arrays;
+
+/**
+ * The implementation of {@link Any}.
+ *
+ * For performance reasonse, the inserted values are not cloned.
+ * If the value object allows modifications (like {@link Streamable}),
+ * these subsequent alterations are reflected by the instance of
+ * this gnuAny, and the gnuAny alterations are reflected by the
+ * returned value. If it is required to have the uncoupled value,
+ * it must be requested from the copy of the current instance.
+ * The {@link gnuAny} can be simply cloned by the provided
+ * {@link Clone()} method.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class gnuAny
+ extends Any
+{
+ /**
+ * The value, returned by {@link #type()} if the value has been
+ * not intialized.
+ */
+ protected static final TypeCode nullType =
+ new primitiveTypeCode(TCKind.tk_null);
+
+ /**
+ * The Streamable, representing the value, held by this gnuAny.
+ */
+ protected Streamable has;
+
+ /**
+ * The complete typecode of the Streamable, if explicitly set.
+ */
+ protected TypeCode typecode;
+
+ /**
+ * The typecode kind of the Streamable, if explicitly set.
+ */
+ protected int xKind = -1;
+
+ /**
+ * The associated ORB.
+ */
+ private ORB orb;
+
+ /**
+ * Set the associated orb.
+ */
+ public void setOrb(ORB an_orb)
+ {
+ orb = an_orb;
+ }
+
+ /**
+ * Creates a deep copy of this gnuAny, writing to and subsequently
+ * reading from from the byte buffer.
+ *
+ * @return the uncoupled gnuAny with all fields set to identical
+ * values.
+ */
+ public gnuAny Clone()
+ {
+ cdrBufOutput out = new cdrBufOutput();
+ out.setOrb(orb);
+ out.write_any(this);
+
+ cdrBufInput in = new cdrBufInput(out.buffer.toByteArray());
+ in.setOrb(orb);
+ return (gnuAny) in.read_any();
+ }
+
+ /**
+ * Create the buffered CDR input stream, containing the
+ * value, stored inside of this {@link Any}.
+ */
+ public org.omg.CORBA.portable.InputStream create_input_stream()
+ {
+ cdrBufOutput out = new cdrBufOutput();
+ out.setOrb(orb);
+ write_value(out);
+ cdrBufInput in = new cdrBufInput(out.buffer.toByteArray());
+ in.setOrb(orb);
+ return in;
+ }
+
+ /**
+ * Create the buffered CDR output stream (empty).
+ */
+ public org.omg.CORBA.portable.OutputStream create_output_stream()
+ {
+ cdrBufOutput stream = new cdrBufOutput();
+ stream.setOrb(orb);
+ return stream;
+ }
+
+ /**
+ * Compare two Any's for equality.
+ * @param other the other Any to compare.
+ */
+ public boolean equal(Any other)
+ {
+ if (other == this)
+ return true;
+ if (type().kind() != other.type().kind())
+ return false;
+
+ if (has != null && other instanceof gnuAny)
+ if (has.equals(((gnuAny) other).has))
+ return true;
+
+ cdrBufOutput a = new cdrBufOutput();
+ a.setOrb(orb);
+ write_value(a);
+
+ cdrBufOutput b = new cdrBufOutput();
+ b.setOrb(orb);
+ other.write_value(b);
+
+ byte[] ba = a.buffer.toByteArray();
+ byte[] bb = b.buffer.toByteArray();
+
+ return Arrays.equals(ba, bb);
+ }
+
+ /**
+ * Delegates functionality to {@link #equal(Any)}.
+ */
+ public boolean equals(java.lang.Object other)
+ {
+ if (other == this)
+ return true;
+ if (!(other instanceof Any))
+ return false;
+
+ return equal((Any) other);
+ }
+
+ /**
+ * Extract the previously stored object.
+ */
+ public org.omg.CORBA.Object extract_Object()
+ {
+ try
+ {
+ return ((ObjectHolder) has).value;
+ }
+ catch (ClassCastException ex)
+ {
+ throw new BAD_OPERATION();
+ }
+ }
+
+ /**
+ * Extract the previously inserted CORBA <code>Principal</code>/
+ * @return the previously inserted value.
+ *
+ * @throws org.omg.CORBA.BAD_OPERATION if the holder contains something
+ * else than Principal.
+ *
+ * @deprecated by CORBA 2.2.
+ */
+ public Principal extract_Principal()
+ {
+ check(TCKind._tk_Principal);
+ return ((PrincipalHolder) has).value;
+ }
+
+ /**
+ * Return the value, encapsulated in a suitable holder.
+ * This implementation returns the direct reference,
+ * so the alterations on the returned streamable are
+ * directly reflected to the content of this {@link Any}.
+ */
+ public Streamable extract_Streamable()
+ {
+ return has;
+ }
+
+ public TypeCode extract_TypeCode()
+ throws BAD_OPERATION
+ {
+ check(TCKind._tk_TypeCode);
+ return ((TypeCodeHolder) has).value;
+ }
+
+ public Serializable extract_Value()
+ throws BAD_OPERATION
+ {
+ /**@todo Implement this org.omg.CORBA.Any abstract method*/
+ throw new java.lang.UnsupportedOperationException("Method extract_Value() not yet implemented.");
+ }
+
+ /** {@inheritDoc} */
+ public Any extract_any()
+ throws BAD_OPERATION
+ {
+ check(TCKind._tk_any);
+ return ((AnyHolder) has).value;
+ }
+
+ /** {@inheritDoc} */
+ public boolean extract_boolean()
+ throws BAD_OPERATION
+ {
+ check(TCKind._tk_boolean);
+ return ((BooleanHolder) has).value;
+ }
+
+ /** {@inheritDoc} */
+ public char extract_char()
+ throws BAD_OPERATION
+ {
+ check(TCKind._tk_char);
+ return ((CharHolder) has).value;
+ }
+
+ /** {@inheritDoc} */
+ public double extract_double()
+ throws BAD_OPERATION
+ {
+ check(TCKind._tk_double);
+ return ((DoubleHolder) has).value;
+ }
+
+ /**
+ * Extract the previously inserted CORBA <code>fixed</code>/
+ * @return the previously inserted value.
+ *
+ * @throws org.omg.CORBA.BAD_OPERATION if the holder contains something
+ * else than BigDecimal.
+ */
+ public BigDecimal extract_fixed()
+ throws org.omg.CORBA.BAD_OPERATION
+ {
+ check(TCKind._tk_fixed);
+ return ((FixedHolder) has).value;
+ }
+
+ /** {@inheritDoc} */
+ public float extract_float()
+ throws BAD_OPERATION
+ {
+ check(TCKind._tk_float);
+ return ((FloatHolder) has).value;
+ }
+
+ /** {@inheritDoc} */
+ public int extract_long()
+ throws BAD_OPERATION
+ {
+ // CORBA long = java int.
+ check(TCKind._tk_long);
+ return ((IntHolder) has).value;
+ }
+
+ /** {@inheritDoc} */
+ public long extract_longlong()
+ throws BAD_OPERATION
+ {
+ check(TCKind._tk_longlong);
+ return ((LongHolder) has).value;
+ }
+
+ /** {@inheritDoc} */
+ public byte extract_octet()
+ throws BAD_OPERATION
+ {
+ // ShortHolder holds also octets.
+ check(TCKind._tk_octet);
+ return (byte) ((OctetHolder) has).value;
+ }
+
+ /** {@inheritDoc} */
+ public short extract_short()
+ throws BAD_OPERATION
+ {
+ check(TCKind._tk_short);
+ return ((ShortHolder) has).value;
+ }
+
+ /** {@inheritDoc} */
+ public String extract_string()
+ throws BAD_OPERATION
+ {
+ check(TCKind._tk_string);
+ return ((StringHolder) has).value;
+ }
+
+ /** {@inheritDoc} */
+ public int extract_ulong()
+ throws BAD_OPERATION
+ {
+ // IntHolder also holds ulongs.
+ check(TCKind._tk_ulong);
+ return ((IntHolder) has).value;
+ }
+
+ /** {@inheritDoc} */
+ public long extract_ulonglong()
+ throws BAD_OPERATION
+ {
+ // LongHolder also holds ulonglong
+ check(TCKind._tk_ulonglong);
+ return ((LongHolder) has).value;
+ }
+
+ /** {@inheritDoc} */
+ public short extract_ushort()
+ throws BAD_OPERATION
+ {
+ // ShortHolder also holds ushorts.
+ check(TCKind._tk_ushort);
+ return ((ShortHolder) has).value;
+ }
+
+ /** {@inheritDoc} */
+ public char extract_wchar()
+ throws BAD_OPERATION
+ {
+ check(TCKind._tk_wchar);
+ return ((WCharHolder) has).value;
+ }
+
+ /** {@inheritDoc} */
+ public String extract_wstring()
+ throws BAD_OPERATION
+ {
+ // StringHolder also holds wstrings.
+ check(TCKind._tk_wstring);
+ return ((WStringHolder) has).value;
+ }
+
+ /**
+ * Inserts the CORBA object and sets the typecode to the given type.
+ */
+ public void insert_Object(org.omg.CORBA.Object x, TypeCode typecode)
+ {
+ has = new ObjectHolder(x);
+ type(typecode);
+ }
+
+ /**
+ * Inserts the CORBA object.
+ */
+ public void insert_Object(org.omg.CORBA.Object x)
+ {
+ has = new ObjectHolder(x);
+ }
+
+ /**
+ * Insert the CORBA Principal.
+ * This implementation uses direct assignment, so the later
+ * alterations of that BigDecimal are reflected on the
+ * content of this {@link Any}.
+ *
+ * @deprecated by CORBA 2.2.
+ */
+ public void insert_Principal(Principal x)
+ {
+ resetTypes();
+ if (has instanceof PrincipalHolder)
+ ((PrincipalHolder) has).value = x;
+ else
+ has = new PrincipalHolder(x);
+ }
+
+ /**
+ * Sets the value to the value, encapsulated in this holder.
+ * This implementation uses direct assignment, so the later
+ * alterations of that streamable are reflected on the
+ * content of this {@link Any}.
+ */
+ public void insert_Streamable(Streamable x)
+ {
+ resetTypes();
+ has = x;
+ }
+
+ /**
+ * Insert the typecode into this Any
+ * @param typecode the typecode to insert.
+ */
+ public void insert_TypeCode(TypeCode typecode)
+ {
+ resetTypes();
+ if (has instanceof TypeCodeHolder)
+ ((TypeCodeHolder) has).value = typecode;
+ else
+ has = new TypeCodeHolder(typecode);
+ }
+
+ /** {@inheritDoc} */
+ public void insert_Value(Serializable x, TypeCode typecode)
+ {
+ resetTypes();
+
+ /**@todo Implement this org.omg.CORBA.Any abstract method*/
+ }
+
+ /** {@inheritDoc} */
+ public void insert_Value(Serializable x)
+ {
+ resetTypes();
+
+ /**@todo Implement this org.omg.CORBA.Any abstract method*/
+ }
+
+ /**
+ * Insert another {@link Any} into this {@link Any}.
+ * This implementation uses direct assignment, so the later
+ * alterations of that {@link Any} are reflected on the
+ * content of this {@link Any}.
+ */
+ public void insert_any(Any an_any)
+ {
+ resetTypes();
+ if (has instanceof AnyHolder)
+ ((AnyHolder) has).value = an_any;
+ else
+ has = new AnyHolder(an_any);
+ }
+
+ /** {@inheritDoc} */
+ public void insert_boolean(boolean x)
+ {
+ resetTypes();
+ if (has instanceof BooleanHolder)
+ ((BooleanHolder) has).value = x;
+ else
+ has = new BooleanHolder(x);
+ }
+
+ /** {@inheritDoc} */
+ public void insert_char(char x)
+ {
+ resetTypes();
+ if (has instanceof CharHolder)
+ ((CharHolder) has).value = x;
+ else
+ has = new CharHolder(x);
+ }
+
+ /** {@inheritDoc} */
+ public void insert_double(double x)
+ {
+ resetTypes();
+ if (has instanceof DoubleHolder)
+ ((DoubleHolder) has).value = x;
+ else
+ has = new DoubleHolder(x);
+ }
+
+ /**
+ * Inserts the CORBA <code>fixed</code>, setting the typecode
+ * explicitly.
+ * This implementation uses direct assignment, so the later
+ * alterations of that BigDecimal are reflected on the
+ * content of this {@link Any}.
+ */
+ public void insert_fixed(BigDecimal x, TypeCode x_typecode)
+ {
+ resetTypes();
+ insert_fixed(x);
+ typecode = x_typecode;
+ }
+
+ /**
+ * Inserts the CORBA <code>fixed</code>, setting the typecode
+ * by example of the currently passed value.
+ * This implementation uses direct assignment, so the later
+ * alterations of that BigDecimal are reflected on the
+ * content of this {@link Any}, including the typecode.
+ */
+ public void insert_fixed(BigDecimal x)
+ {
+ resetTypes();
+ if (has instanceof FixedHolder)
+ ((FixedHolder) has).value = x;
+ else
+ has = new FixedHolder(x);
+ }
+
+ /** {@inheritDoc} */
+ public void insert_float(float x)
+ {
+ resetTypes();
+ if (has instanceof FloatHolder)
+ ((FloatHolder) has).value = x;
+ else
+ has = new FloatHolder(x);
+ }
+
+ /** {@inheritDoc} */
+ public void insert_long(int x)
+ {
+ resetTypes();
+ if (has instanceof IntHolder)
+ ((IntHolder) has).value = x;
+ else
+ has = new IntHolder(x);
+ }
+
+ /** {@inheritDoc} */
+ public void insert_longlong(long x)
+ {
+ resetTypes();
+ if (has instanceof LongHolder)
+ ((LongHolder) has).value = x;
+ else
+ has = new LongHolder(x);
+ }
+
+ /** {@inheritDoc} */
+ public void insert_octet(byte x)
+ {
+ resetTypes();
+ if (has instanceof OctetHolder)
+ ((OctetHolder) has).value = x;
+ else
+ has = new OctetHolder(x);
+ }
+
+ /** {@inheritDoc} */
+ public void insert_short(short x)
+ {
+ resetTypes();
+ if (has instanceof ShortHolder)
+ ((ShortHolder) has).value = x;
+ else
+ has = new ShortHolder(x);
+ }
+
+ /** {@inheritDoc} */
+ public void insert_string(String x)
+ {
+ resetTypes();
+ if (has instanceof StringHolder)
+ ((StringHolder) has).value = x;
+ else
+ has = new StringHolder(x);
+
+ typecode = new stringTypeCode(TCKind.tk_string);
+ }
+
+ /** {@inheritDoc} */
+ public void insert_ulong(int x)
+ {
+ resetTypes();
+ if (has instanceof IntHolder)
+ ((IntHolder) has).value = x;
+ else
+ has = new IntHolder(x);
+ xKind = TCKind._tk_ulong;
+ }
+
+ /** {@inheritDoc} */
+ public void insert_ulonglong(long x)
+ {
+ resetTypes();
+ if (has instanceof LongHolder)
+ ((LongHolder) has).value = x;
+ else
+ has = new LongHolder(x);
+ xKind = TCKind._tk_ulonglong;
+ }
+
+ /** {@inheritDoc} */
+ public void insert_ushort(short x)
+ {
+ resetTypes();
+ if (has instanceof ShortHolder)
+ ((ShortHolder) has).value = x;
+ else
+ has = new ShortHolder(x);
+ xKind = TCKind._tk_ushort;
+ }
+
+ /** {@inheritDoc} */
+ public void insert_wchar(char x)
+ {
+ resetTypes();
+ if (has instanceof WCharHolder)
+ ((WCharHolder) has).value = x;
+ else
+ has = new WCharHolder(x);
+ }
+
+ /** {@inheritDoc} */
+ public void insert_wstring(String x)
+ {
+ resetTypes();
+ if (has instanceof WStringHolder)
+ ((WStringHolder) has).value = x;
+ else
+ has = new WStringHolder(x);
+ }
+
+ /**
+ * Return the associated orb.
+ */
+ public ORB orb()
+ {
+ return orb;
+ }
+
+ /**
+ * Read the value of the given type from the given stream.
+ *
+ * @param input a stream to read from.
+ * @param a_type a typecode of the value to read.
+ */
+ public void read_value(org.omg.CORBA.portable.InputStream input,
+ TypeCode a_type
+ )
+ throws MARSHAL
+ {
+ try
+ {
+ int kind = a_type.kind().value();
+
+ // Fixed needs special handling.
+ if (kind == TCKind._tk_fixed)
+ {
+ BigDecimal dec = BigDecimalHelper.read(input, a_type.fixed_scale());
+ has = new FixedHolder(dec);
+ }
+ else
+ {
+ has = holderFactory.createHolder(a_type);
+ if (has == null)
+ throw new NO_IMPLEMENT("Not implemented for " +
+ typeNamer.nameIt(a_type)
+ );
+ }
+ type(a_type);
+ has._read(input);
+ }
+ catch (BadKind ex)
+ {
+ throw new MARSHAL("Bad kind: " + ex.getMessage());
+ }
+ catch (IOException ex)
+ {
+ throw new MARSHAL("IO exception: " + ex.getMessage());
+ }
+ }
+
+ /** {@inheritDoc} */
+ public TypeCode type()
+ {
+ if (typecode != null)
+ return typecode;
+ else if (xKind >= 0)
+ {
+ typecode = new primitiveTypeCode(TCKind.from_int(xKind));
+ return typecode;
+ }
+ else
+ return has != null ? has._type() : nullType;
+ }
+
+ /**
+ * Explicitly set the typecode of the value to the given type.
+ *
+ * @param valueTypeCode the typecode of the value.
+ */
+ public void type(TypeCode valueTypeCode)
+ {
+ xKind = valueTypeCode.kind().value();
+ typecode = valueTypeCode;
+ }
+
+ /** {@inheritDoc} */
+ public void write_value(org.omg.CORBA.portable.OutputStream output)
+ {
+ if (has != null)
+ has._write(output);
+ }
+
+ /**
+ * Check if the current value if the value of the given kind.
+ * @param kind a kind to check.
+ * @throws BAD_OPERATION if the value is not set of is different kind.
+ */
+ protected void check(int kind)
+ throws BAD_OPERATION
+ {
+ if (has == null)
+ throw new BAD_OPERATION("value not set");
+
+ if (xKind >= 0)
+ {
+ if (xKind != kind)
+ throw new BAD_OPERATION("Extracting " + typeNamer.nameIt(kind) +
+ " when stored " + typeNamer.nameIt(xKind)
+ );
+ }
+ else
+ {
+ if (type().kind().value() != kind)
+ throw new BAD_OPERATION("Extracting " + typeNamer.nameIt(kind) +
+ " stored " + typeNamer.nameIt(type())
+ );
+ }
+ }
+
+ /**
+ * Clear the additional type information before reusing this instance.
+ */
+ private final void resetTypes()
+ {
+ typecode = null;
+ xKind = -1;
+ }
+}
diff --git a/gnu/CORBA/gnuContext.java b/gnu/CORBA/gnuContext.java
new file mode 100644
index 000000000..533d7026b
--- /dev/null
+++ b/gnu/CORBA/gnuContext.java
@@ -0,0 +1,202 @@
+/* gnuContext.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.Bounds;
+import org.omg.CORBA.CTX_RESTRICT_SCOPE;
+import org.omg.CORBA.Context;
+import org.omg.CORBA.NVList;
+
+/**
+ * The working implementation of the {@link org.omg.CORBA.Context}.
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class gnuContext
+ extends Context
+{
+ /**
+ * The parent context.
+ */
+ Context parent;
+
+ /**
+ * The collection to store the context properties.
+ */
+ Map properties = new Hashtable();
+
+ /**
+ * The name of this context.
+ */
+ String name;
+
+ /**
+ * Creates the new context with the given name and parent.
+ *
+ * @param a_name a name of the new context.
+ * @param a_parent a parent, used to resolve the missing references.
+ */
+ public gnuContext(String a_name, Context a_parent)
+ {
+ name = a_name;
+ parent = a_parent;
+ }
+
+ /** {@inheritDoc} */
+ public String context_name()
+ {
+ return name;
+ }
+
+ /** {@inheritDoc} */
+ public Context create_child(String child)
+ {
+ return new gnuContext(child, this);
+ }
+
+ /** {@inheritDoc} */
+ public void delete_values(String property)
+ {
+ boolean starts = false;
+ if (property.endsWith("*"))
+ {
+ starts = true;
+ property = property.substring(0, property.length() - 1);
+ }
+
+ Set keys = properties.keySet();
+
+ Iterator iter = keys.iterator();
+ while (iter.hasNext())
+ {
+ String key = (String) iter.next();
+ if ((starts && key.startsWith(property)) ||
+ (!starts && key.equals(property))
+ )
+ iter.remove();
+ }
+ }
+
+ /** {@inheritDoc} */
+ public NVList get_values(String start_scope, int flags, String pattern)
+ {
+ if (start_scope != null)
+ {
+ Context c = this;
+ while (c != null && !c.context_name().equals(start_scope))
+ c = c.parent();
+ if (c == null)
+ return new gnuNVList();
+ }
+
+ try
+ {
+ gnuNVList rt = new gnuNVList();
+
+ boolean starts = false;
+ if (pattern.endsWith("*"))
+ {
+ starts = true;
+ pattern = pattern.substring(0, pattern.length() - 1);
+ }
+
+ Set keys = properties.keySet();
+
+ Iterator iter = keys.iterator();
+ while (iter.hasNext())
+ {
+ String key = (String) iter.next();
+ if ((starts && key.startsWith(pattern)) ||
+ (!starts && key.equals(pattern))
+ )
+ {
+ rt.add_value(key, (Any) properties.get(key), 0);
+ }
+ }
+
+ if ((flags & CTX_RESTRICT_SCOPE.value) == 0 && parent != null)
+ {
+ NVList par = parent.get_values(start_scope, flags, pattern);
+ for (int i = 0; i < par.count(); i++)
+ {
+ rt.list.add(par.item(i));
+ }
+ }
+
+ return rt;
+ }
+ catch (Bounds ex)
+ {
+ throw new Error("Report this bug.");
+ }
+ }
+
+ /** {@inheritDoc} */
+ public Context parent()
+ {
+ return parent;
+ }
+
+ /** {@inheritDoc} */
+ public void set_one_value(String name, Any value)
+ {
+ properties.put(name, value);
+ }
+
+ /** {@inheritDoc} */
+ public void set_values(NVList values)
+ {
+ try
+ {
+ for (int i = 0; i < values.count(); i++)
+ {
+ properties.put(values.item(i).name(), values.item(i).value());
+ }
+ }
+ catch (Bounds ex)
+ {
+ throw new Error("Please report this bug.");
+ }
+ }
+}
diff --git a/gnu/CORBA/gnuContextList.java b/gnu/CORBA/gnuContextList.java
new file mode 100644
index 000000000..5375e8b59
--- /dev/null
+++ b/gnu/CORBA/gnuContextList.java
@@ -0,0 +1,83 @@
+/* gnuContextList.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import java.util.ArrayList;
+
+import org.omg.CORBA.Bounds;
+import org.omg.CORBA.ContextList;
+
+/**
+ * The working implementation of the {@link org.omg.CORBA.ContextList}.
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class gnuContextList
+ extends ContextList
+{
+ /**
+ * The collection, holding the actual list of strings.
+ */
+ corbaArrayList strings = new corbaArrayList();
+
+ /** {@inheritDoc} */
+ public void add(String name)
+ {
+ strings.add(name);
+ }
+
+ /** {@inheritDoc} */
+ public int count()
+ {
+ return strings.size();
+ }
+
+ /** {@inheritDoc} */
+ public String item(int at)
+ throws Bounds
+ {
+ return (String) strings.item(at);
+ }
+
+ /** {@inheritDoc} */
+ public void remove(int at)
+ throws Bounds
+ {
+ strings.drop(at);
+ }
+}
diff --git a/gnu/CORBA/gnuEnvironment.java b/gnu/CORBA/gnuEnvironment.java
new file mode 100644
index 000000000..f470c95c0
--- /dev/null
+++ b/gnu/CORBA/gnuEnvironment.java
@@ -0,0 +1,72 @@
+/* gnuEnvironment.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import org.omg.CORBA.Environment;
+
+/**
+ * The implementation of the exception container ("Environment").
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class gnuEnvironment
+ extends Environment
+{
+ /**
+ * The stored exception.
+ */
+ protected Exception exception;
+
+ /** {@inheritDoc} */
+ public void clear()
+ {
+ exception = null;
+ }
+
+ /** {@inheritDoc} */
+ public void exception(Exception except)
+ {
+ exception = except;
+ }
+
+ /** {@inheritDoc} */
+ public Exception exception()
+ {
+ return exception;
+ }
+}
diff --git a/gnu/CORBA/gnuExceptionList.java b/gnu/CORBA/gnuExceptionList.java
new file mode 100644
index 000000000..55a9cc19e
--- /dev/null
+++ b/gnu/CORBA/gnuExceptionList.java
@@ -0,0 +1,84 @@
+/* gnuExceptionList.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import java.util.ArrayList;
+
+import org.omg.CORBA.Bounds;
+import org.omg.CORBA.ExceptionList;
+import org.omg.CORBA.TypeCode;
+
+/**
+ * The implementation of the list of type codes for exceptions.
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org).
+ */
+public class gnuExceptionList
+ extends ExceptionList
+{
+ /**
+ * A list to store the objects.
+ */
+ protected corbaArrayList list = new corbaArrayList();
+
+ /** {@inheritDoc} */
+ public void add(TypeCode an_exception)
+ {
+ list.add(an_exception);
+ }
+
+ /** {@inheritDoc} */
+ public int count()
+ {
+ return list.size();
+ }
+
+ /** {@inheritDoc} */
+ public TypeCode item(int at)
+ throws Bounds
+ {
+ return (TypeCode) list.item(at);
+ }
+
+ /** {@inheritDoc} */
+ public void remove(int at)
+ throws Bounds
+ {
+ list.drop(at);
+ }
+}
diff --git a/gnu/CORBA/gnuNVList.java b/gnu/CORBA/gnuNVList.java
new file mode 100644
index 000000000..f61afd7a6
--- /dev/null
+++ b/gnu/CORBA/gnuNVList.java
@@ -0,0 +1,127 @@
+/* gnuNVList.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.Bounds;
+import org.omg.CORBA.NVList;
+import org.omg.CORBA.NamedValue;
+
+/**
+ * The implementation of {@link NVList}.
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class gnuNVList
+ extends NVList
+{
+ /**
+ * The list of the named values.
+ */
+ protected corbaArrayList list;
+
+ /**
+ * Creates the list with the default initial size.
+ */
+ public gnuNVList()
+ {
+ list = new corbaArrayList();
+ }
+
+ /**
+ * Creates the list with the given initial size.
+ */
+ public gnuNVList(int initial_size)
+ {
+ list = new corbaArrayList(initial_size);
+ }
+
+ /** {@inheritDoc} */
+ public NamedValue add(int a_flags)
+ {
+ return add_value(null, null, a_flags);
+ }
+
+ /** {@inheritDoc} */
+ public NamedValue add_item(String a_name, int a_flags)
+ {
+ return add_value(a_name, null, a_flags);
+ }
+
+ /** {@inheritDoc} */
+ public NamedValue add_value(String a_name, Any a_value, int a_flags)
+ {
+ gnuNamedValue n = new gnuNamedValue();
+ n.setName(a_name);
+ n.setValue(a_value);
+ n.setFlags(a_flags);
+ list.add(n);
+ return n;
+ }
+
+ /**
+ * Add the given named value to the list directly.
+ *
+ * @param value the named vaue to add.
+ */
+ public void add(NamedValue value)
+ {
+ list.add(value);
+ }
+
+
+ /** {@inheritDoc} */
+ public int count()
+ {
+ return list.size();
+ }
+
+ /** {@inheritDoc} */
+ public NamedValue item(int at)
+ throws Bounds
+ {
+ return (NamedValue) list.item(at);
+ }
+
+ /** {@inheritDoc} */
+ public void remove(int at)
+ throws Bounds
+ {
+ list.drop(at);
+ }
+}
diff --git a/gnu/CORBA/gnuNamedValue.java b/gnu/CORBA/gnuNamedValue.java
new file mode 100644
index 000000000..eda91df2c
--- /dev/null
+++ b/gnu/CORBA/gnuNamedValue.java
@@ -0,0 +1,112 @@
+/* gnuNamedValue.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.NamedValue;
+
+/**
+ * The implementation of the named value.
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class gnuNamedValue
+ extends NamedValue
+{
+ /**
+ * The named value value.
+ */
+ private Any m_value = new gnuAny();
+
+ /**
+ * The named value name.
+ */
+ private String m_name;
+
+ /**
+ * The named value flags.
+ */
+ private int m_flags;
+
+ /**
+ * Set the flags, the normally expected values are
+ * {@link org.omg.CORBA.ARG_IN#value},
+ * {@link org.omg.CORBA.ARG_OUT#value} and
+ * {@link org.omg.CORBA.ARG_INOUT#value}.
+ */
+ public void setFlags(int flags)
+ {
+ m_flags = flags;
+ }
+
+ /**
+ * Set the name of the value.
+ * @param name the name of this value
+ */
+ public void setName(String name)
+ {
+ m_name = name;
+ }
+
+ /**
+ * Set the value of the value.
+ * @param value the value of this object.
+ */
+ public void setValue(Any value)
+ {
+ m_value = value;
+ }
+
+ /** {@inheritDoc} */
+ public int flags()
+ {
+ return m_flags;
+ }
+
+ /** {@inheritDoc} */
+ public String name()
+ {
+ return m_name;
+ }
+
+ /** {@inheritDoc} */
+ public Any value()
+ {
+ return m_value;
+ }
+}
diff --git a/gnu/CORBA/gnuRequest.java b/gnu/CORBA/gnuRequest.java
new file mode 100644
index 000000000..ace2bc09e
--- /dev/null
+++ b/gnu/CORBA/gnuRequest.java
@@ -0,0 +1,893 @@
+/* gnuRequest.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import gnu.CORBA.CDR.cdrBufInput;
+import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.GIOP.MessageHeader;
+import gnu.CORBA.GIOP.ReplyHeader;
+import gnu.CORBA.GIOP.RequestHeader;
+import gnu.CORBA.GIOP.cxCodeSet;
+
+import org.omg.CORBA.ARG_IN;
+import org.omg.CORBA.ARG_INOUT;
+import org.omg.CORBA.ARG_OUT;
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_INV_ORDER;
+import org.omg.CORBA.Bounds;
+import org.omg.CORBA.Context;
+import org.omg.CORBA.ContextList;
+import org.omg.CORBA.Environment;
+import org.omg.CORBA.ExceptionList;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.NVList;
+import org.omg.CORBA.NamedValue;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Request;
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.UserException;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import java.net.Socket;
+
+/**
+ * The implementation of the CORBA request.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class gnuRequest
+ extends Request
+ implements Cloneable
+{
+ /**
+ * The maximal supported GIOP version.
+ */
+ public static Version MAX_SUPPORTED = new Version(1, 2);
+
+ /**
+ * The request reading buffer size.
+ */
+ public static final int READ_BUFFER_SIZE = 2048;
+
+ /**
+ * The empty byte array.
+ */
+ private static final binaryReply EMPTY =
+ new binaryReply(null, new MessageHeader(), new byte[ 0 ]);
+
+ /**
+ * The context holder for methods ctx(Context) and ctx().
+ */
+ protected Context m_context;
+
+ /**
+ * The context list for method contexts().
+ */
+ protected ContextList m_context_list;
+
+ /**
+ * The request environment for holding the exception
+ * the has possibly been thrown by the method being invoked.
+ */
+ protected Environment m_environment = new gnuEnvironment();
+
+ /**
+ * The list of all exceptions that can be thrown by the
+ * method being invoked.
+ */
+ protected ExceptionList m_exceptions = new gnuExceptionList();
+
+ /**
+ * The result, returned by the invoked method (function).
+ */
+ protected NamedValue m_result = new gnuNamedValue();
+
+ /**
+ * The invocation target.
+ */
+ protected org.omg.CORBA.Object m_target;
+
+ /**
+ * The name of the method being invoked.
+ */
+ protected String m_operation;
+
+ /**
+ * The flag, indicating that the request has been sent
+ * and the result is already received.
+ */
+ protected boolean complete;
+
+ /**
+ * The flag, indicating that the response to this request must be
+ * ignored (used with {@link #send_oneway()}).
+ */
+ protected boolean oneWay;
+
+ /**
+ * The flag, indicating that the request has been sent
+ * and no result is yet received.
+ */
+ protected boolean running;
+
+ /**
+ * The request arguments.
+ */
+ protected gnuNVList m_args = new gnuNVList();
+
+ /**
+ * The request arguments in the case when they are directly written into
+ * the parameter buffer.
+ */
+ protected streamRequest m_parameter_buffer;
+
+ /**
+ * The IOR of the target.
+ */
+ private IOR ior;
+
+ /**
+ * The ORB of the target.
+ */
+ private ORB orb;
+
+ /**
+ * Set the IOR data, sufficient to find the invocation target.
+ *
+ * @see IOR.parse(String)
+ */
+ public void setIor(IOR an_ior)
+ {
+ ior = an_ior;
+ }
+
+ /**
+ * Get the IOR data, sufficient to find the invocation target.
+ *
+ * @return the IOR data.
+ */
+ public IOR getIor()
+ {
+ return ior;
+ }
+
+ /**
+ * Set the ORB, related to the invocation target.
+ */
+ public void setORB(ORB an_orb)
+ {
+ orb = an_orb;
+ }
+
+ /**
+ * The the method name to invoke.
+ *
+ * @param operation the method name.
+ */
+ public void setOperation(String operation)
+ {
+ m_operation = operation;
+ }
+
+ /**
+ * Get the parameter stream, where the invocation arguments should
+ * be written if they are written into the stream directly.
+ */
+ public streamRequest getParameterStream()
+ {
+ m_parameter_buffer = new streamRequest();
+ m_parameter_buffer.request = this;
+ m_parameter_buffer.setVersion(ior.Internet.version);
+ m_parameter_buffer.setCodeSet(cxCodeSet.negotiate(ior.CodeSets));
+ m_parameter_buffer.setOrb(orb);
+ return m_parameter_buffer;
+ }
+
+ /**
+ * Creates a shallow copy of this request.
+ */
+ public gnuRequest Clone()
+ {
+ try
+ {
+ return (gnuRequest) clone();
+ }
+ catch (CloneNotSupportedException ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+
+ /** {@inheritDoc} */
+ public Any add_in_arg()
+ {
+ gnuNamedValue v = new gnuNamedValue();
+ v.setFlags(ARG_IN.value);
+ m_args.add(v);
+ return v.value();
+ }
+
+ /** {@inheritDoc} */
+ public Any add_inout_arg()
+ {
+ gnuNamedValue v = new gnuNamedValue();
+ v.setFlags(ARG_INOUT.value);
+ m_args.add(v);
+ return v.value();
+ }
+
+ /** {@inheritDoc} */
+ public Any add_named_in_arg(String name)
+ {
+ gnuNamedValue v = new gnuNamedValue();
+ v.setFlags(ARG_IN.value);
+ v.setName(name);
+ m_args.add(v);
+ return v.value();
+ }
+
+ /** {@inheritDoc} */
+ public Any add_named_inout_arg(String name)
+ {
+ gnuNamedValue v = new gnuNamedValue();
+ v.setFlags(ARG_INOUT.value);
+ v.setName(name);
+ m_args.add(v);
+ return v.value();
+ }
+
+ /** {@inheritDoc} */
+ public Any add_named_out_arg(String name)
+ {
+ gnuNamedValue v = new gnuNamedValue();
+ v.setFlags(ARG_OUT.value);
+ v.setName(name);
+ m_args.add(v);
+ return v.value();
+ }
+
+ /** {@inheritDoc} */
+ public Any add_out_arg()
+ {
+ gnuNamedValue v = new gnuNamedValue();
+ v.setFlags(ARG_OUT.value);
+ m_args.add(v);
+ return v.value();
+ }
+
+ /** {@inheritDoc} */
+ public NVList arguments()
+ {
+ return m_args;
+ }
+
+ /** {@inheritDoc} */
+ public ContextList contexts()
+ {
+ return m_context_list;
+ }
+
+ /** {@inheritDoc} */
+ public Context ctx()
+ {
+ return m_context;
+ }
+
+ /** {@inheritDoc} */
+ public void ctx(Context a_context)
+ {
+ m_context = a_context;
+ }
+
+ /** {@inheritDoc} */
+ public Environment env()
+ {
+ return m_environment;
+ }
+
+ /** {@inheritDoc} */
+ public ExceptionList exceptions()
+ {
+ return m_exceptions;
+ }
+
+ /** {@inheritDoc} */
+ public void get_response()
+ throws org.omg.CORBA.WrongTransaction
+ {
+ /**
+ * The response is ready after it is received.
+ * FIXME implement context checks and any other functionality,
+ * if required.
+ */
+ }
+
+ /**
+ * Submit the request, suspending the current thread until the
+ * answer is received.
+ *
+ * This implementation requires to set the IOR property
+ * ({@link #setIOR(IOR)} before calling this method.
+ *
+ * @throws BAD_INV_ORDER, minor code 0, if the IOR has not been
+ * previously set.
+ *
+ * @throws SystemException if this exception has been thrown on
+ * remote side. The exact exception type and the minor code are
+ * the same as they have been for the exception, thrown on remoted
+ * side.
+ */
+ public synchronized void invoke()
+ throws BAD_INV_ORDER
+ {
+ waitWhileBusy();
+ complete = false;
+ running = true;
+
+ if (ior == null)
+ throw new BAD_INV_ORDER("Set IOR property first");
+
+ try
+ {
+ p_invoke();
+ }
+ finally
+ {
+ running = false;
+ complete = true;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public String operation()
+ {
+ return m_operation;
+ }
+
+ /**
+ * Get the orb, related to the invocation target.
+ */
+ public ORB orb()
+ {
+ return orb;
+ }
+
+ /** {@inheritDoc} */
+ public boolean poll_response()
+ {
+ return complete && !running;
+ }
+
+ /** {@inheritDoc} */
+ public NamedValue result()
+ {
+ return m_result;
+ }
+
+ /** {@inheritDoc}
+ *
+ */
+ public Any return_value()
+ {
+ return m_result.value();
+ }
+
+ /** {@inheritDoc} */
+ public synchronized void send_deferred()
+ {
+ waitWhileBusy();
+ new Thread()
+ {
+ public void run()
+ {
+ invoke();
+ }
+ }.run();
+ }
+
+ /**
+ * Send a request and forget about it, not waiting for a response.
+ * This can be done also for methods that normally are expected
+ * to return some values.
+ *
+ * TODO It is generally recommended to reuse the threads. Reuse?
+ */
+ public void send_oneway()
+ {
+ final gnuRequest cloned = Clone();
+ cloned.oneWay = true;
+
+ new Thread()
+ {
+ public void run()
+ {
+ cloned.invoke();
+ }
+ }.run();
+ }
+
+ /**
+ * Set the argument list.
+ * This field is initialised as empty non null instance by default,
+ * so the method is only used in cases when the direct replacement
+ * is desired.
+ *
+ * @param a_args the argument list.
+ */
+ public void set_args(NVList a_args)
+ {
+ if (a_args instanceof gnuNVList)
+ m_args = (gnuNVList) a_args;
+ else
+ {
+ try
+ {
+ // In case if this is another implementation of the NVList.
+ m_args.list.clear();
+ for (int i = 0; i < a_args.count(); i++)
+ {
+ m_args.add(a_args.item(i));
+ }
+ }
+ catch (Bounds ex)
+ {
+ Unexpected.error(ex);
+ }
+ }
+ }
+
+ /**
+ * Set the context list that is later returned by the
+ * method {@link #contexts()}.
+ *
+ * @param a_context_list a new context list.
+ */
+ public void set_context_list(ContextList a_context_list)
+ {
+ m_context_list = a_context_list;
+ }
+
+ /**
+ * Set the exception container.
+ * This field is initialised as empty non null instance by default,
+ * so the method is only used in cases when the direct replacement
+ * is desired.
+ *
+ * @param a_environment the new exception container.
+ */
+ public void set_environment(Environment a_environment)
+ {
+ m_environment = a_environment;
+ }
+
+ /**
+ * Set the list of exceptions.
+ * This field is initialised as empty non null instance by default,
+ * so the method is only used in cases when the direct replacement
+ * is desired.
+ *
+ * @param a_exceptions a list of exceptions.
+ */
+ public void set_exceptions(ExceptionList a_exceptions)
+ {
+ m_exceptions = a_exceptions;
+ }
+
+ /**
+ * Set the operation name.
+ *
+ * @param a_operation the operation name.
+ */
+ public void set_operation(String a_operation)
+ {
+ m_operation = a_operation;
+ }
+
+ /**
+ * Set the named value, returned as result.
+ * This field is initialised as empty non null instance by default,
+ * so the method is only used in cases when the direct replacement
+ * is desired.
+ *
+ * @param a_result the result keeper.
+ */
+ public void set_result(NamedValue a_result)
+ {
+ m_result = a_result;
+ }
+
+ /**
+ * Set the type of the named value, returned as a result.
+ * Instantiates a new instance of the result value.
+ */
+ public void set_return_type(TypeCode returns)
+ {
+ if (m_result == null || !returns.equal(m_result.value().type()))
+ {
+ m_result = new gnuNamedValue();
+ m_result.value().type(returns);
+ }
+ }
+
+ /**
+ * Set the invocation target.
+ *
+ * @param a_target the CORBA object for that the method will be invoked.
+ */
+ public void set_target(org.omg.CORBA.Object a_target)
+ {
+ m_target = a_target;
+ }
+
+ /**
+ * Do the actual invocation.
+ * This implementation requires to set the IOR property
+ * ({@link #setIOR(IOR)} before calling this method.
+ *
+ * @throws BAD_INV_ORDER, minor code 0, if the IOR has not been
+ * previously set or if the direct argument addition is mixed with
+ * the direct argument writing into the output stream.
+ *
+ * @return the server response in binary form.
+ */
+ public synchronized binaryReply submit()
+ {
+ gnu.CORBA.GIOP.MessageHeader header = new gnu.CORBA.GIOP.MessageHeader();
+
+ // The byte order will be Big Endian by default.
+ header.message_type = gnu.CORBA.GIOP.MessageHeader.REQUEST;
+ header.version = useVersion(ior.Internet.version);
+
+ RequestHeader rh = header.create_request_header();
+
+ rh.object_key = ior.key;
+ rh.operation = m_operation;
+
+ // Prepare the submission.
+ cdrBufOutput request_part = new cdrBufOutput();
+
+ request_part.setOffset(header.getHeaderSize());
+ request_part.setVersion(header.version);
+ request_part.setCodeSet(cxCodeSet.negotiate(ior.CodeSets));
+ request_part.setOrb(orb);
+
+ // This also sets the stream encoding to the encoding, specified
+ // in the header.
+ rh.write(request_part);
+
+ if (m_args != null && m_args.count() > 0)
+ {
+ write_parameters(header, request_part);
+
+ if (m_parameter_buffer != null)
+ throw new BAD_INV_ORDER("Please either add parameters or " +
+ "write them into stream, but not both " +
+ "at once."
+ );
+ }
+
+ if (m_parameter_buffer != null)
+ {
+ write_parameter_buffer(header, request_part);
+ }
+
+ // Now the message size is available.
+ header.message_size = request_part.buffer.size();
+
+ try
+ {
+ Socket socket = new Socket(ior.Internet.host, ior.Internet.port);
+
+ OutputStream socketOutput = socket.getOutputStream();
+
+ // Write the message header.
+ header.write(socketOutput);
+
+ // Write the request header and parameters (if present).
+ request_part.buffer.writeTo(socketOutput);
+
+ socketOutput.flush();
+ if (!socket.isClosed())
+ {
+ MessageHeader response_header = new MessageHeader();
+ InputStream socketInput = socket.getInputStream();
+ response_header.read(socketInput);
+
+ byte[] r = new byte[ response_header.message_size ];
+ int n = 0;
+ reading:
+ while (n < r.length)
+ {
+ n = socketInput.read(r, n, r.length - n);
+ }
+ socketInput.close();
+ return new binaryReply(orb, response_header, r);
+ }
+ else
+ return EMPTY;
+ }
+ catch (IOException ex1)
+ {
+ ex1.printStackTrace();
+ return null;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public org.omg.CORBA.Object target()
+ {
+ return m_target;
+ }
+
+ /**
+ * Get the used version. Normally, it is better to respond using the
+ * same version as it is specified in IOR, but not above the maximal
+ * supported version.
+ */
+ public Version useVersion(Version desired)
+ {
+ if (desired.until_inclusive(MAX_SUPPORTED.major, MAX_SUPPORTED.minor))
+ return desired;
+ else
+ return MAX_SUPPORTED;
+ }
+
+ /**
+ * Wait while the response to request, submitted using
+ * {@link #send_deferred()} or {@link #invoke()} (from other thread)
+ * is returned.
+ *
+ * FIXME It is possible to rewrite this using
+ * Object.wait() and Object.notify(), but be sure to prepare the test
+ * as well.
+ */
+ public synchronized void waitWhileBusy()
+ {
+ // Waiting constants.
+ long wait = 10;
+ long increment = 2;
+ long max = 5000;
+
+ while (running)
+ {
+ try
+ {
+ Thread.sleep(wait);
+ if (wait < max)
+ wait = wait * increment;
+ }
+ catch (InterruptedException ex)
+ {
+ }
+ }
+ }
+
+ /**
+ * Do actual invocation. This method recursively calls itself if
+ * the redirection is detected.
+ */
+ private void p_invoke()
+ throws SystemException
+ {
+ binaryReply response = submit();
+
+ ReplyHeader rh = response.header.create_reply_header();
+ cdrBufInput input = response.getStream();
+ input.setOrb(orb);
+
+ rh.read(input);
+
+ // The stream must be aligned sinve v1.2, but only once.
+ boolean align = response.header.version.since_inclusive(1, 2);
+
+ boolean moved_permanently = false;
+
+ switch (rh.reply_status)
+ {
+ case ReplyHeader.NO_EXCEPTION :
+
+ NamedValue arg;
+
+ // Read return value, if set.
+ if (m_result != null)
+ {
+ if (align)
+ {
+ input.align(8);
+ align = false;
+ }
+ m_result.value().read_value(input, m_result.value().type());
+ }
+
+ // Read returned parameters, if set.
+ if (m_args != null)
+ for (int i = 0; i < m_args.count(); i++)
+ {
+ try
+ {
+ arg = m_args.item(i);
+
+ // Both ARG_INOUT and ARG_OUT have this binary flag set.
+ if ((arg.flags() & ARG_OUT.value) != 0)
+ {
+ if (align)
+ {
+ input.align(8);
+ align = false;
+ }
+
+ arg.value().read_value(input, arg.value().type());
+ }
+ }
+ catch (Bounds ex)
+ {
+ Unexpected.error(ex);
+ }
+ }
+
+ break;
+
+ case ReplyHeader.SYSTEM_EXCEPTION :
+ if (align)
+ {
+ input.align(8);
+ align = false;
+ }
+
+ SystemException exception = ObjectCreator.readSystemException(input);
+
+ m_environment.exception(exception);
+
+ throw exception;
+
+ case ReplyHeader.USER_EXCEPTION :
+ if (align)
+ {
+ input.align(8);
+ align = false;
+ }
+ input.mark(2000);
+
+ String uxId = input.read_string();
+ input.reset();
+
+ UserException uex = ObjectCreator.readUserException(uxId, input);
+
+ if (uex == null)
+ m_environment.exception(new UserException(uxId));
+ else
+ m_environment.exception(uex);
+ break;
+
+ case ReplyHeader.LOCATION_FORWARD_PERM :
+ case ReplyHeader.LOCATION_FORWARD :
+ if (response.header.version.since_inclusive(1, 2))
+ input.align(8);
+
+ IOR forwarded = new IOR();
+ try
+ {
+ forwarded._read_no_endian(input);
+ }
+ catch (IOException ex)
+ {
+ throw new MARSHAL(ex + " while reading the forwarding info");
+ }
+
+ setIor(forwarded);
+ // Repeat with the forwarded information.
+ p_invoke();
+ return;
+
+ default :
+ throw new MARSHAL("Unknow reply status: " + rh.reply_status);
+ }
+ }
+
+ /**
+ * Write the operation parameters.
+ *
+ * @param header the message header
+ * @param request_part the stream to write parameters into
+ *
+ * @throws MARSHAL if the attempt to write the parameters has failde.
+ */
+ private void write_parameter_buffer(MessageHeader header,
+ cdrBufOutput request_part
+ )
+ throws MARSHAL
+ {
+ try
+ {
+ if (header.version.since_inclusive(1, 2))
+ {
+ request_part.align(8);
+ }
+ m_parameter_buffer.buffer.writeTo(request_part);
+ }
+ catch (IOException ex)
+ {
+ throw new MARSHAL("Unable to write method arguments to CDR output.");
+ }
+ }
+
+ /**
+ * Write the operation parameters.
+ *
+ * @param header the message header
+ * @param request_part the stream to write parameters into
+ *
+ * @throws MARSHAL if the attempt to write the parameters has failde.
+ */
+ private void write_parameters(MessageHeader header, cdrBufOutput request_part)
+ throws MARSHAL
+ {
+ // Align after 1.2, but only once.
+ boolean align = header.version.since_inclusive(1, 2);
+ NamedValue para;
+
+ try
+ {
+ // Write parameters now.
+ for (int i = 0; i < m_args.count(); i++)
+ {
+ para = m_args.item(i);
+
+ //This bit is set both for ARG_IN and ARG_INOUT
+ if ((para.flags() & ARG_IN.value) != 0)
+ {
+ if (align)
+ {
+ request_part.align(8);
+ align = false;
+ }
+ para.value().write_value(request_part);
+ }
+ }
+ }
+ catch (Bounds ex)
+ {
+ throw new MARSHAL("Unable to write method arguments to CDR output.");
+ }
+ }
+}
diff --git a/gnu/CORBA/holderFactory.java b/gnu/CORBA/holderFactory.java
new file mode 100644
index 000000000..17e0a68e5
--- /dev/null
+++ b/gnu/CORBA/holderFactory.java
@@ -0,0 +1,184 @@
+/* holderFactory.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import org.omg.CORBA.AnyHolder;
+import org.omg.CORBA.AnySeqHolder;
+import org.omg.CORBA.BooleanHolder;
+import org.omg.CORBA.BooleanSeqHolder;
+import org.omg.CORBA.CharHolder;
+import org.omg.CORBA.CharSeqHolder;
+import org.omg.CORBA.DoubleHolder;
+import org.omg.CORBA.DoubleSeqHolder;
+import org.omg.CORBA.FixedHolder;
+import org.omg.CORBA.FloatHolder;
+import org.omg.CORBA.FloatSeqHolder;
+import org.omg.CORBA.IntHolder;
+import org.omg.CORBA.LongHolder;
+import org.omg.CORBA.LongLongSeqHolder;
+import org.omg.CORBA.LongSeqHolder;
+import org.omg.CORBA.OctetSeqHolder;
+import org.omg.CORBA.PrincipalHolder;
+import org.omg.CORBA.ShortHolder;
+import org.omg.CORBA.ShortSeqHolder;
+import org.omg.CORBA.StringHolder;
+import org.omg.CORBA.StringSeqHolder;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodeHolder;
+import org.omg.CORBA.ULongLongSeqHolder;
+import org.omg.CORBA.ULongSeqHolder;
+import org.omg.CORBA.UShortSeqHolder;
+import org.omg.CORBA.WCharSeqHolder;
+import org.omg.CORBA.WStringSeqHolder;
+import org.omg.CORBA.portable.Streamable;
+
+/**
+ * Creates the suitable holder for storing the value of the given
+ * type.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class holderFactory
+{
+ /**
+ * The array, sufficiently large to use any {@link TCKind}._tk* constant
+ * as an index.
+ */
+ private static final Class[] holders;
+ private static final Class[] seqHolders;
+
+ static
+ {
+ holders = new Class[ 32 ];
+ holders [ TCKind._tk_Principal ] = PrincipalHolder.class;
+ holders [ TCKind._tk_TypeCode ] = TypeCodeHolder.class;
+ holders [ TCKind._tk_any ] = AnyHolder.class;
+ holders [ TCKind._tk_boolean ] = BooleanHolder.class;
+ holders [ TCKind._tk_char ] = CharHolder.class;
+ holders [ TCKind._tk_double ] = DoubleHolder.class;
+ holders [ TCKind._tk_float ] = FloatHolder.class;
+ holders [ TCKind._tk_fixed ] = FixedHolder.class;
+ holders [ TCKind._tk_long ] = IntHolder.class;
+ holders [ TCKind._tk_longdouble ] = DoubleHolder.class;
+ holders [ TCKind._tk_longlong ] = LongHolder.class;
+ holders [ TCKind._tk_octet ] = OctetHolder.class;
+ holders [ TCKind._tk_short ] = ShortHolder.class;
+ holders [ TCKind._tk_string ] = StringHolder.class;
+ holders [ TCKind._tk_ulong ] = IntHolder.class;
+ holders [ TCKind._tk_ulonglong ] = LongHolder.class;
+ holders [ TCKind._tk_ushort ] = ShortHolder.class;
+ holders [ TCKind._tk_wchar ] = WCharHolder.class;
+ holders [ TCKind._tk_wstring ] = WStringHolder.class;
+
+ seqHolders = new Class[ 32 ];
+
+ seqHolders [ TCKind._tk_ulonglong ] = ULongLongSeqHolder.class;
+ seqHolders [ TCKind._tk_short ] = ShortSeqHolder.class;
+ seqHolders [ TCKind._tk_octet ] = OctetSeqHolder.class;
+ seqHolders [ TCKind._tk_any ] = AnySeqHolder.class;
+ seqHolders [ TCKind._tk_long ] = LongSeqHolder.class;
+ seqHolders [ TCKind._tk_longlong ] = LongLongSeqHolder.class;
+ seqHolders [ TCKind._tk_float ] = FloatSeqHolder.class;
+ seqHolders [ TCKind._tk_double ] = DoubleSeqHolder.class;
+ seqHolders [ TCKind._tk_char ] = CharSeqHolder.class;
+ seqHolders [ TCKind._tk_boolean ] = BooleanSeqHolder.class;
+ seqHolders [ TCKind._tk_wchar ] = WCharSeqHolder.class;
+ seqHolders [ TCKind._tk_ushort ] = UShortSeqHolder.class;
+ seqHolders [ TCKind._tk_ulong ] = ULongSeqHolder.class;
+ seqHolders [ TCKind._tk_string ] = StringSeqHolder.class;
+ seqHolders [ TCKind._tk_wstring ] = WStringSeqHolder.class;
+ }
+
+ /**
+ * Create a holder for storing the value of the given built-in type.
+ * This function returns the defined holders for the built-in primitive
+ * types and they sequences.
+ *
+ * @param t the typecode
+ *
+ * @return an instance of the corresponding built-in holder of null
+ * if no such is defined for this type. The holder is created with a
+ * parameterless constructor.
+ */
+ public static Streamable createHolder(TypeCode t)
+ {
+ try
+ {
+ int kind = t.kind().value();
+ int componentKind;
+
+ Streamable holder = null;
+ Streamable component;
+
+ if (kind < holders.length && holders [ kind ] != null)
+ holder = (Streamable) holders [ kind ].newInstance();
+
+ if (holder != null)
+ return holder;
+
+ switch (kind)
+ {
+ case TCKind._tk_sequence :
+ componentKind = t.content_type().kind().value();
+ if (componentKind < seqHolders.length)
+ return (Streamable) seqHolders [ componentKind ].newInstance();
+ break;
+
+ default :
+ break;
+ }
+ }
+ catch (Exception ex)
+ {
+ throw new Unexpected(ex);
+ }
+
+ try
+ {
+ Object ox = ObjectCreator.createObject(t.id(), "Holder");
+ return (Streamable) ox;
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ return null;
+ }
+ }
+}
diff --git a/gnu/CORBA/primitiveArrayTypeCode.java b/gnu/CORBA/primitiveArrayTypeCode.java
index b028073da..6a4864033 100644
--- a/gnu/CORBA/primitiveArrayTypeCode.java
+++ b/gnu/CORBA/primitiveArrayTypeCode.java
@@ -60,6 +60,13 @@ public class primitiveArrayTypeCode
*/
private int length;
+ /**
+ * Create a primitive array type code, defining the sequence
+ * {@link TCKind.tk_sequence)} with
+ * the given member type.
+ *
+ * @param array_of the sequence member type.
+ */
public primitiveArrayTypeCode(TCKind array_of)
{
super(TCKind.tk_sequence);
@@ -67,6 +74,20 @@ public class primitiveArrayTypeCode
}
/**
+ * Create a primitive array type code, defining the array, sequence
+ * or other type with the given member type.
+ *
+ * @param this_type the type of this type (normally either
+ * sequence of array).
+ * @param array_of the sequence member type.
+ */
+ public primitiveArrayTypeCode(TCKind this_type, TypeCode array_of)
+ {
+ super(this_type);
+ of = array_of;
+ }
+
+ /**
* Return the array component type.
* @return the array component type
* @throws org.omg.CORBA.TypeCodePackage.BadKind
diff --git a/gnu/CORBA/primitiveTypeCode.java b/gnu/CORBA/primitiveTypeCode.java
index e9ad67192..d240c9aee 100644
--- a/gnu/CORBA/primitiveTypeCode.java
+++ b/gnu/CORBA/primitiveTypeCode.java
@@ -38,14 +38,15 @@
package gnu.CORBA;
+import java.io.Serializable;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.IDLEntity;
import org.omg.CORBA.NO_IMPLEMENT;
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
-
-import java.io.Serializable;
+import org.omg.CORBA.TypeCodePackage.Bounds;
/**
* An information about a primitive CORBA data type
@@ -73,25 +74,25 @@ public class primitiveTypeCode
}
public TypeCode concrete_base_type()
- throws org.omg.CORBA.TypeCodePackage.BadKind
+ throws BadKind
{
throw new BadKind();
}
public TypeCode content_type()
- throws org.omg.CORBA.TypeCodePackage.BadKind
+ throws BadKind
{
throw new BadKind();
}
public int default_index()
- throws org.omg.CORBA.TypeCodePackage.BadKind
+ throws BadKind
{
throw new BadKind();
}
public TypeCode discriminator_type()
- throws org.omg.CORBA.TypeCodePackage.BadKind
+ throws BadKind
{
throw new BadKind();
}
@@ -113,15 +114,15 @@ public class primitiveTypeCode
}
public short fixed_digits()
- throws org.omg.CORBA.TypeCodePackage.BadKind
+ throws BadKind
{
- throw new BadKind();
+ throw new BadKind("fixed_digits");
}
public short fixed_scale()
- throws org.omg.CORBA.TypeCodePackage.BadKind
+ throws BadKind
{
- throw new BadKind();
+ throw new BadKind("fixed_scale");
}
public TypeCode get_compact_typecode()
@@ -130,9 +131,9 @@ public class primitiveTypeCode
}
public String id()
- throws org.omg.CORBA.TypeCodePackage.BadKind
+ throws BadKind
{
- throw new BadKind();
+ throw new BadKind("id");
}
/**
@@ -145,53 +146,50 @@ public class primitiveTypeCode
}
public int length()
- throws org.omg.CORBA.TypeCodePackage.BadKind
+ throws BadKind
{
- throw new BadKind();
+ throw new BadKind("length");
}
public int member_count()
- throws org.omg.CORBA.TypeCodePackage.BadKind
+ throws BadKind
{
- throw new BadKind();
+ throw new BadKind("member_count");
}
public Any member_label(int index)
- throws org.omg.CORBA.TypeCodePackage.BadKind,
- org.omg.CORBA.TypeCodePackage.Bounds
+ throws BadKind, Bounds
{
- throw new BadKind();
+ throw new BadKind("member_label");
}
public String member_name(int index)
- throws BadKind
+ throws BadKind, Bounds
{
- throw new BadKind();
+ throw new BadKind("member_name");
}
public TypeCode member_type(int index)
- throws org.omg.CORBA.TypeCodePackage.BadKind,
- org.omg.CORBA.TypeCodePackage.Bounds
+ throws BadKind, Bounds
{
- throw new BadKind();
+ throw new BadKind("member_type");
}
public short member_visibility(int index)
- throws org.omg.CORBA.TypeCodePackage.BadKind,
- org.omg.CORBA.TypeCodePackage.Bounds
+ throws BadKind, Bounds
{
- throw new BadKind();
+ throw new BadKind("member_visibility");
}
public String name()
- throws org.omg.CORBA.TypeCodePackage.BadKind
+ throws BadKind
{
- throw new BadKind();
+ throw new BadKind("name");
}
public short type_modifier()
- throws org.omg.CORBA.TypeCodePackage.BadKind
+ throws BadKind
{
- throw new BadKind();
+ throw new BadKind("type_modifier");
}
}
diff --git a/gnu/CORBA/recordTypeCode.java b/gnu/CORBA/recordTypeCode.java
new file mode 100644
index 000000000..1e34b9aa3
--- /dev/null
+++ b/gnu/CORBA/recordTypeCode.java
@@ -0,0 +1,245 @@
+/* recordTypeCode.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.StructMember;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+import org.omg.CORBA.TypeCodePackage.Bounds;
+import org.omg.CORBA.UnionMember;
+import org.omg.CORBA.ValueMember;
+
+/**
+ * The type code that also has the member property getters
+ * supported.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class recordTypeCode
+ extends generalTypeCode
+{
+ /**
+ * The individual field of the record.
+ */
+ public static class Field
+ {
+ /**
+ * The record label.
+ */
+ public Any label;
+
+ /**
+ * The record name.
+ */
+ public String name;
+
+ /**
+ * The record type.
+ */
+ public TypeCode type;
+
+ /**
+ * The record visibility.
+ */
+ public int visibility = UNSET;
+ }
+
+ /**
+ * The members of this data structure.
+ */
+ protected corbaArrayList members = new corbaArrayList();
+ private TypeCode discriminator_type;
+ private int default_index = UNSET;
+
+ /**
+ * Creates the type code of the given kind.
+ */
+ public recordTypeCode(TCKind kind)
+ {
+ super(kind);
+ }
+
+ /**
+ * Set the default index.
+ */
+ public void setDefaultIndex(int a_default_index)
+ {
+ this.default_index = a_default_index;
+ }
+
+ /**
+ * Set the discriminator type.
+ */
+ public void setDiscriminator_type(TypeCode a_discriminator_type)
+ {
+ this.discriminator_type = a_discriminator_type;
+ }
+
+ public Field getField(int p)
+ {
+ return (Field) members.get(p);
+ }
+
+ public void add(Field field)
+ {
+ members.add(field);
+ }
+
+ /**
+ * Adds a new field, taking values from the passed
+ * {@link StructMember}.
+ */
+ public void add(StructMember m)
+ {
+ Field f = field();
+ f.name = m.name;
+ f.type = m.type;
+ }
+
+ /**
+ * Adds a new field, taking values from the passed
+ * {@link ValueMember}.
+ */
+ public void add(ValueMember m)
+ {
+ Field f = field();
+ f.name = m.name;
+ f.type = m.type;
+ f.visibility = m.access;
+
+ }
+
+ /**
+ * Adds a new field, taking values from the passed
+ * {@link UnionMember}.
+ */
+ public void add(UnionMember m)
+ {
+ Field f = field();
+ f.name = m.name;
+ f.type = m.type;
+ f.label = m.label;
+ }
+
+ public int default_index()
+ throws BadKind
+ {
+ if (default_index != UNSET)
+ return default_index;
+ throw new BadKind();
+ }
+
+ public TypeCode discriminator_type()
+ throws BadKind
+ {
+ if (discriminator_type != null)
+ return discriminator_type;
+ throw new BadKind();
+ }
+
+ /**
+ * Creates, adds and returns new field.
+ */
+ public Field field()
+ {
+ Field f = new Field();
+ members.add(f);
+ return f;
+ }
+
+ /** {@inheritDoc} */
+ public int member_count()
+ {
+ return members.size();
+ }
+
+ /** {@inheritDoc} */
+ public Any member_label(int index)
+ throws BadKind, Bounds
+ {
+ Field f = getField(index);
+ if (f.label != null)
+ {
+ return f.label;
+ }
+ else
+ throw new BadKind();
+ }
+
+ /** {@inheritDoc} */
+ public String member_name(int index)
+ throws BadKind
+ {
+ Field f = getField(index);
+ if (f.name != null)
+ {
+ return f.name;
+ }
+ else
+ throw new BadKind();
+ }
+
+ /** {@inheritDoc} */
+ public TypeCode member_type(int index)
+ throws BadKind, Bounds
+ {
+ Field f = getField(index);
+ if (f.type != null)
+ {
+ return f.type;
+ }
+ else
+ throw new BadKind();
+ }
+
+ /** {@inheritDoc} */
+ public short member_visibility(int index)
+ throws BadKind, Bounds
+ {
+ Field f = getField(index);
+ if (f.visibility != UNSET)
+ {
+ return (short) f.visibility;
+ }
+ else
+ throw new BadKind();
+ }
+}
diff --git a/gnu/CORBA/recursiveTypeCode.java b/gnu/CORBA/recursiveTypeCode.java
new file mode 100644
index 000000000..1fbae2401
--- /dev/null
+++ b/gnu/CORBA/recursiveTypeCode.java
@@ -0,0 +1,78 @@
+/* recursiveTypeCode.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import org.omg.CORBA.TCKind;
+
+/**
+ * The typecode, serving as a placeholder in defining
+ * typecodes, containing recursion.
+ */
+public class recursiveTypeCode
+ extends primitiveTypeCode
+{
+ /**
+ * The id of the type for that this type serves as a
+ * placeholder.
+ */
+ private final String the_id;
+
+ /**
+ * Create a typecode that serves as a placeholder for
+ * the typecode with the given id.
+ *
+ * @param id the Id of the type for that this type serves as a
+ * placeholder.
+ */
+ public recursiveTypeCode(String an_id)
+ {
+ super(TCKind.tk_null);
+ the_id = an_id;
+ }
+
+ /**
+ * Get the id of the type for that this type serves as a
+ * placeholder.
+ */
+ public String id()
+ throws org.omg.CORBA.TypeCodePackage.BadKind
+ {
+ return the_id;
+ }
+}
diff --git a/gnu/CORBA/streamRequest.java b/gnu/CORBA/streamRequest.java
new file mode 100644
index 000000000..5b63ca88e
--- /dev/null
+++ b/gnu/CORBA/streamRequest.java
@@ -0,0 +1,60 @@
+/* gnuStreamRequest.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import gnu.CORBA.CDR.cdrBufOutput;
+
+/**
+ * A stream, additionally holding the gnu request.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class streamRequest
+ extends cdrBufOutput
+{
+ /**
+ * The enclosed request.
+ */
+ public gnuRequest request;
+
+ /**
+ * True if the response is expected.
+ */
+ public boolean response_expected = true;
+}
diff --git a/gnu/CORBA/stringTypeCode.java b/gnu/CORBA/stringTypeCode.java
new file mode 100644
index 000000000..40adffaff
--- /dev/null
+++ b/gnu/CORBA/stringTypeCode.java
@@ -0,0 +1,83 @@
+/* stringTypeCode.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import org.omg.CORBA.TCKind;
+
+/**
+ * The typecode for string and wide string.
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class stringTypeCode
+ extends primitiveTypeCode
+{
+ private int len = 0;
+
+ /**
+ * Create a new instance of the string type code.
+ *
+ * @param a_kind a kind of this typecode, normally
+ * either tk_string or tk_wstring.
+ */
+ public stringTypeCode(TCKind a_kind)
+ {
+ super(a_kind);
+ }
+
+ /**
+ * Set the length property.
+ *
+ * @param a_length a length.
+ */
+ public void setLength(int a_length)
+ {
+ len = a_length;
+ }
+
+ /**
+ * Get the length of the string. This method returns 0
+ * (unbounded) if the property has not been set.
+ *
+ * @return the length (bound) of the string.
+ */
+ public int length()
+ {
+ return len;
+ }
+}
diff --git a/gnu/CORBA/stubFinder.java b/gnu/CORBA/stubFinder.java
new file mode 100644
index 000000000..3aff84133
--- /dev/null
+++ b/gnu/CORBA/stubFinder.java
@@ -0,0 +1,110 @@
+/* stubFinder.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.portable.ObjectImpl;
+
+/**
+ * Finds a stub class like "_HelloStub" that can be instantiated
+ * from IOR reference. The returned object can be casted to the
+ * used type like "Hello" without using the helper .narrow method,
+ * and the object is not unnsecessarily re - instantiated if
+ * the .narrow method is used anyway. If no stub, matching the naming
+ * conventions, is available, the returned stub replacement can still be used
+ * to get the valid request, add parameter and invoke the method by name.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class stubFinder
+{
+ /**
+ * Search for the possibly available default stub.
+ *
+ * @param orb the current ORB. It is not required to find the binding
+ * classes, but is needed to instantiate the default implementation
+ * if no binding classes are found.
+ *
+ * @param ior the IOR, possibly containing the information about the
+ * correct implementation class.
+ */
+ public static ObjectImpl search(ORB orb, IOR ior)
+ {
+ try
+ {
+ int a = ior.Id.indexOf(':');
+ int b = ior.Id.lastIndexOf(':');
+
+ String s = ior.Id.substring(a + 1, b).replace('/', '.');
+
+ String path;
+
+ b = s.lastIndexOf('.');
+ if (b > 0)
+ path = s.substring(0, b + 1);
+ else
+ path = "";
+
+ String stub = "_" + s.substring(b + 1) + "Stub";
+
+ Class stubClass = Class.forName(path + stub);
+
+ return (ObjectImpl) stubClass.newInstance();
+ }
+ catch (Exception failed)
+ {
+ // Various exceptions can be thrown if the Id cannot be parsed,
+ // the class is missing, cannot be instantiated or is not an
+ // instance of the ObjectImpl.
+ return createDefaultStub(orb, ior);
+ }
+ }
+
+ /**
+ * Return the default stub for the case when the client binding classes
+ * are not locally available. The returned stub can still be used
+ * to get the valid request, add parameter and invoke the method by name.
+ *
+ * @return the default implementation.
+ */
+ protected static ObjectImpl createDefaultStub(ORB orb, IOR ior)
+ {
+ return new IOR_contructed_object(orb, ior);
+ }
+}
diff --git a/gnu/CORBA/typeNamer.java b/gnu/CORBA/typeNamer.java
new file mode 100644
index 000000000..ec3cf6e97
--- /dev/null
+++ b/gnu/CORBA/typeNamer.java
@@ -0,0 +1,171 @@
+/* primitiveTypes.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+
+/**
+ * A conveniency method for naming the built-in types.
+ * This is used in error reporting that is part of the user interface.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class typeNamer
+{
+ /**
+ * Names of the primitve types.
+ */
+ protected static final String[] tk =
+ new String[]
+ {
+ "null", "void", "short", "long", "ushort", "ulong", "float", "double",
+ "boolean", "char", "octet", "any", "TypeCode", "Principal", "objref",
+ "struct", "union", "enum", "string", "sequence", "array", "alias",
+ "exception", "longlong", "ulonglong", "longdouble", "wchar", "wstring",
+ "fixed", "value", "value_box", "native", "abstract_interface"
+ };
+
+ /**
+ * Primitve TypeCodes.
+ */
+ protected static final TypeCode[] primitveCodes =
+ new TypeCode[]
+ {
+ new primitiveTypeCode(TCKind.tk_null),
+ new primitiveTypeCode(TCKind.tk_void),
+ new primitiveTypeCode(TCKind.tk_short),
+ new primitiveTypeCode(TCKind.tk_long),
+ new primitiveTypeCode(TCKind.tk_ushort),
+ new primitiveTypeCode(TCKind.tk_ulong),
+ new primitiveTypeCode(TCKind.tk_float),
+ new primitiveTypeCode(TCKind.tk_double),
+ new primitiveTypeCode(TCKind.tk_boolean),
+ new primitiveTypeCode(TCKind.tk_char),
+ new primitiveTypeCode(TCKind.tk_octet),
+ new primitiveTypeCode(TCKind.tk_any),
+ new primitiveTypeCode(TCKind.tk_TypeCode),
+ new primitiveTypeCode(TCKind.tk_Principal),
+ new primitiveTypeCode(TCKind.tk_objref),
+ new primitiveTypeCode(TCKind.tk_struct),
+ new primitiveTypeCode(TCKind.tk_union),
+ new primitiveTypeCode(TCKind.tk_enum),
+ new primitiveTypeCode(TCKind.tk_string),
+ new primitiveTypeCode(TCKind.tk_sequence),
+ new primitiveTypeCode(TCKind.tk_array),
+ new primitiveTypeCode(TCKind.tk_alias),
+ new primitiveTypeCode(TCKind.tk_except),
+ new primitiveTypeCode(TCKind.tk_longlong),
+ new primitiveTypeCode(TCKind.tk_ulonglong),
+ new primitiveTypeCode(TCKind.tk_longdouble),
+ new primitiveTypeCode(TCKind.tk_wchar),
+ new primitiveTypeCode(TCKind.tk_wstring),
+ new primitiveTypeCode(TCKind.tk_fixed),
+ new primitiveTypeCode(TCKind.tk_value),
+ new primitiveTypeCode(TCKind.tk_value_box),
+ new primitiveTypeCode(TCKind.tk_native),
+ new primitiveTypeCode(TCKind.tk_abstract_interface)
+ };
+
+ /**
+ * Get the primitive type code.
+ *
+ * @return the primitve type code, corresponding the passed value.
+ *
+ * @throws BadKind if this is not a primitive type code.
+ */
+ public static TypeCode getPrimitveTC(TCKind tc)
+ throws BadKind
+ {
+ try
+ {
+ return primitveCodes [ tc.value() ];
+ }
+ catch (ArrayIndexOutOfBoundsException ex)
+ {
+ throw new BadKind(tc.value() + " is not a primitve type.");
+ }
+ }
+
+ /**
+ * Get the string name of the passed primitive type.
+ *
+ * @param kind the kind of the primitive type the must be defined
+ * in {@link omg.org.CORBA.TCKind}.
+ *
+ * @return the short string name, used in error reporting, etc.
+ */
+ public static String nameIt(int kind)
+ {
+ try
+ {
+ return tk [ kind ];
+ }
+ catch (ArrayIndexOutOfBoundsException ex)
+ {
+ return "type of kind '" + kind + "'";
+ }
+ }
+
+ /**
+ * Get the string name of the passed primitive type.
+ *
+ * @param kind the kind of the primitive type the must be defined
+ * in {@link omg.org.CORBA.TCKind}.
+ *
+ * @return the short string name, used in error reporting, etc.
+ */
+ public static String nameIt(TypeCode type)
+ {
+ try
+ {
+ if (type.kind().value() == TCKind._tk_array)
+ return "array of " + nameIt(type.content_type());
+ else if (type.kind().value() == TCKind._tk_sequence)
+ return "sequence of " + nameIt(type.content_type());
+ else
+ return nameIt(type.kind().value());
+ }
+ catch (Exception ex)
+ {
+ return "type of kind '" + type.kind().value() + "'";
+ }
+ }
+}
diff --git a/org/omg/CORBA/Any.java b/org/omg/CORBA/Any.java
index 7187ae4ed..107da0407 100644
--- a/org/omg/CORBA/Any.java
+++ b/org/omg/CORBA/Any.java
@@ -40,6 +40,8 @@ package org.omg.CORBA;
import java.io.Serializable;
+import org.omg.CORBA.portable.IDLEntity;
+
/**
* A container that can store a value of either user defined or
* primitive IDL type.
@@ -47,7 +49,13 @@ import java.io.Serializable;
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public abstract class Any
+ implements Serializable, IDLEntity
{
+ /**
+ * Using v 1.4 serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1217179597823814463L;
+
/**
* Creates an input stream from that this Any object's value can be
* read (unmarshalled).
diff --git a/org/omg/CORBA/DomainManager.java b/org/omg/CORBA/DomainManager.java
new file mode 100644
index 000000000..c677dd4d0
--- /dev/null
+++ b/org/omg/CORBA/DomainManager.java
@@ -0,0 +1,57 @@
+/* DomainManager.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CORBA;
+
+import java.io.Serializable;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * Establishes and navigates relationships to superior and subordinate domains,
+ * and also creates and access policies.
+ *
+ * The DomainManager has associated with it the policy objects for a
+ * particular domain.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public interface DomainManager
+ extends IDLEntity, Object, Serializable, DomainManagerOperations
+{
+}
diff --git a/org/omg/CORBA/DomainManagerOperations.java b/org/omg/CORBA/DomainManagerOperations.java
new file mode 100644
index 000000000..dc1cb7163
--- /dev/null
+++ b/org/omg/CORBA/DomainManagerOperations.java
@@ -0,0 +1,59 @@
+/* DomainManagerOperations.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CORBA;
+
+
+/**
+ * Provides the means to access the policies of the domain, with that
+ * the implementing {@link DomainManage} is associated.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public interface DomainManagerOperations
+{
+ /**
+ * Get the policy of the specified type for the objects, belonging
+ * to this domain. The policy types are domain specific.
+ *
+ * @param policy_type the policy type
+ *
+ * @return the policy
+ */
+ Policy get_domain_policy(int policy_type);
+}
diff --git a/org/omg/CORBA/FixedHolder.java b/org/omg/CORBA/FixedHolder.java
index 6fbc4716f..6c26c4b2d 100644
--- a/org/omg/CORBA/FixedHolder.java
+++ b/org/omg/CORBA/FixedHolder.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
+import gnu.CORBA.fixedTypeCode;
import gnu.CORBA.primitiveTypeCode;
import java.math.BigDecimal;
@@ -61,12 +62,6 @@ public final class FixedHolder
implements Streamable
{
/**
- * The default type code for this holder.
- */
- private static final TypeCode t_fixed =
- new primitiveTypeCode(TCKind.tk_fixed);
-
- /**
* The <code>BigDecimal</code> (CORBA <code>fixed</code>) value,
* held by this FixedHolder.
*/
@@ -107,11 +102,13 @@ public final class FixedHolder
/**
* Returns the TypeCode, corresponding the CORBA type that is stored
- * using this holder.
+ * using this holder. The scale and digits are set corresponding
+ * the scale and used digits of the value that is currently stored
+ * or left with default value 0 if the value is not set.
*/
public TypeCode _type()
{
- return t_fixed;
+ return new fixedTypeCode(value);
}
/**
diff --git a/org/omg/CORBA/ORB.java b/org/omg/CORBA/ORB.java
index f1f3e70b4..90bfe32aa 100644
--- a/org/omg/CORBA/ORB.java
+++ b/org/omg/CORBA/ORB.java
@@ -38,13 +38,698 @@ exception statement from your version. */
package org.omg.CORBA;
+import gnu.CORBA.Restricted_ORB;
+import gnu.CORBA.fixedTypeCode;
+import gnu.CORBA.generalTypeCode;
+import gnu.CORBA.gnuContext;
+import gnu.CORBA.recordTypeCode;
+import gnu.CORBA.recursiveTypeCode;
+
+import java.applet.Applet;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+import java.util.Properties;
+
/**
- * FIXME
- * Not implemented yet, defined here to keep the package code compilable.
+ * When creating an ORB instance is being created, the class name
+ * is searched in the following locations:
+ * <p>
+ * 1. Applet parameter or application string array, if any.<br>
+ * 2. The properties parameter, if any.<br>
+ * 3. The System properties.<br>
+ * 4. The orb.properties file located in the user.home directory (if any).<br>
+ * 5. The orb.properties file located in the java.home/lib directory (if any).
+ * </p>
+ *
+ * The supported properties are:
+ * <table border="1">
+ * <tr><td> org.omg.CORBA.ORBClass</td><td>The class,
+ * implementing the functional ORB, returned by
+ * {@link #init(Applet, Properties)} or
+ * {@link #init(String[], Properties)} </td></tr>
+ * <tr><td>org.omg.CORBA.ORBSingletonClass</td><td>The class,
+ * implementing the restricted ORB, returned by
+ * {@link #init()}.
+ * </td></tr>
+ * <tr><td>org.omg.CORBA.ORBInitRef</td><td>Specifies the
+ * initial reference, accessible by name with the method
+ * {@link resolve_initial_references(String)}.
+ * </table>
+ * The command line accepts the same properties as a keys. When specifying
+ * in the command line, the prefix org.omg.CORBA can be omitted,
+ * for instance<code> -ORBInitRef NameService=IOR:aabbccdd....</code>
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class ORB
+public abstract class ORB
{
- public ORB()
+ /**
+ * By default, {@link init(String[], Properties)} and
+ * {@link init(Applet, Properties} return
+ * the built-in fully functional ORB is returned. If the
+ * <code>props</code> contains the property org.omg.CORBA.ORBClass,
+ * the value of this property is used as a class name to instantiate
+ * a user-defined ORB.
+ */
+ private static final String FUNCTIONAL_ORB = "org.omg.CORBA.ORBClass";
+
+ /**
+ * The name of the restricted ORB property.
+ */
+ private static final String RESTRICTED_ORB =
+ "org.omg.CORBA.ORBSingletonClass";
+
+ /**
+ * The class, implementing the default fully functional ORB.
+ */
+ private static final String DEFAULT_FUNCTIONAL_ORB = "gnu.CORBA.Functional_ORB";
+
+ /**
+ * The class, implementing the default restricted ORB.
+ */
+ private static final String DEFAULT_RESTRICTED_ORB = "gnu.CORBA.Restricted_ORB";
+
+
+ /**
+ * Connect the given CORBA object to this ORB. After the object is
+ * connected, it starts receiving remote invocations via this ORB.
+ *
+ * The OMG group recommends to use Portable Object Adapter (POA) instead
+ * of calling this method.
+ *
+ * This method is implemented in the derived Gnu Classpah classes,
+ * returned by ORB.init(..). In this abstract class, the implementation
+ * just throws {@link NO_IMPLEMENT}.
+ *
+ * @param object the org.omg.CORBA.Object to connect.
+ */
+ public void connect(org.omg.CORBA.Object object)
+ {
+ throw new NO_IMPLEMENT();
+ }
+
+ /**
+ * Disconnect the given CORBA object from this ORB. The object will be
+ * no longer receiving the remote invocations. In response to the
+ * remote invocation on this object, the ORB will send the
+ * exception {@link OBJECT_NOT_EXIST}. The object, however, is not
+ * destroyed and can receive the local invocations.
+ *
+ * This method is implemented in the derived Gnu Classpah classes,
+ * returned by ORB.init(..). In this abstract class, the implementation
+ * just throws {@link NO_IMPLEMENT}.
+ *
+ * @param object the object to disconnect.
+ */
+ public void disconnect(org.omg.CORBA.Object object)
+ {
+ throw new NO_IMPLEMENT();
+ }
+
+
+ /**
+ * Create alias typecode for the given typecode.
+ */
+ public abstract TypeCode create_alias_tc(String id, String name,
+ TypeCode typecode
+ );
+
+ /**
+ * Create an instance of the CORBA {@link Any} with the type, intialised
+ * to {@link TCKind#tc_null}
+ */
+ public abstract Any create_any();
+
+ /**
+ * Create a typecode, defining an array of the given elements.
+ *
+ * @param length the size of array
+ * @param element_type the array component type.
+ *
+ * @return the corresponding typecode.
+ */
+ public abstract TypeCode create_array_tc(int length, TypeCode element_type);
+
+ /**
+ * Creates an empty CORBA <code>ContextList</code>.
+ *
+ * @return the newly created context list.
+ */
+ public abstract ContextList create_context_list();
+
+ /**
+ * Create a typecode, defining the given enumeration.
+ *
+ * @param id the id.
+ * @param name the name.
+ * @param members the memebers
+ * @return the created enumeration.
+ */
+ public abstract TypeCode create_enum_tc(String id, String name,
+ String[] members
+ );
+
+ /**
+ * Create an environment (container for exceptions).
+ *
+ * @return the created container.
+ */
+ public abstract Environment create_environment();
+
+ /**
+ * Creates an empty exception list.
+ *
+ * @return the newly created list.
+ */
+ public abstract ExceptionList create_exception_list();
+
+ /**
+ * Create the exception typecode.
+ *
+ * @param id the id of exception.
+ * @param name the name of exception.
+ * @param members the members of exception.
+ */
+ public abstract TypeCode create_exception_tc(String id, String name,
+ StructMember[] members
+ );
+
+ /**
+ * Creates a TypeCode object for CORBA <code>fixed</code> that is
+ * mapped to java {@link java.math.BigDecimal}.
+ *
+ * @param digits the number of digits in that <code>fixed</code>.
+ * @param scale the number of digits after the decimal point.
+ *
+ * @return the corresponding TypeCode.
+ */
+ public TypeCode create_fixed_tc(short digits, short scale)
+ {
+ fixedTypeCode r = new fixedTypeCode();
+ r.setDigits(digits);
+ r.setScale(scale);
+ return r;
+ }
+
+ /**
+ * Creates a typecode, representing the IDL interface.
+ *
+ * @param id the interface repository id.
+ * @param name the interface name.
+ *
+ * @return the created typecode.
+ */
+ public abstract TypeCode create_interface_tc(String id, String name);
+
+ /**
+ * Create an instance of a new {@link NVList}.
+ *
+ * @param count the initial size of the list. If more elements are added,
+ * the list automatically expands.
+ *
+ * @return the created list.
+ */
+ public abstract NVList create_list(int count);
+
+ /**
+ * Create a new named value.
+ *
+ * @param name the name of the named value
+ * @param any the content of the named value.
+ * @param flags the flags of the named value
+ *
+ * @return the named value.
+ */
+ public abstract NamedValue create_named_value(String s, Any any, int flags);
+
+ /**
+ * Create a new CDR output stream, where the parameter values can be written
+ * during the method invocation.
+ *
+ * @return a stream to write values into.
+ */
+ public abstract org.omg.CORBA.portable.OutputStream create_output_stream();
+
+ /**
+ * Create typecode, defining the sequence of the elements, having
+ * the given type.
+ *
+ * @param bound the maximal length of the sequence, 0 if not restricted.
+ *
+ * @param element_type the sequence element type.
+ *
+ * @return the typecode.
+ */
+ public abstract TypeCode create_sequence_tc(int bound, TypeCode element_type);
+
+ /**
+ * Create a TypeCode, representing the CORBA <code>string</code>.
+ *
+ * @param bound the maximal length of the string, 0 is unlimited.
+ *
+ * @return the corresponding string typecode.
+ */
+ public abstract TypeCode create_string_tc(int bound);
+
+ /**
+ * Create the typecode, defining the given IDL structure.
+ *
+ * The TypeCode object is initialized with the given id, name, and members.
+ * @param id the Id of this type.
+ * @param the name of this type.
+ * @param members the member list.
+ *
+ * @return the typecode.
+ */
+ public abstract TypeCode create_struct_tc(String id, String name,
+ StructMember[] members
+ );
+
+ /**
+ * Create the typecode, defining the given IDL union.
+ *
+ * The TypeCode object is initialized with the given id, name, discriminator
+ * and members.
+ *
+ * @param id the Id of this type.
+ * @param the name of this type.
+ * @param discriminator the union discriminator.
+ * @param members the member list.
+ *
+ * @return the typecode.
+ */
+ public abstract TypeCode create_union_tc(String id, String name,
+ TypeCode discriminator,
+ UnionMember[] members
+ );
+
+ /**
+ * Create a TypeCode, representing the CORBA <code>wstring</code>.
+ *
+ * @param bound the maximal length of the string, 0 is unlimited.
+ *
+ * @return the corresponding string typecode.
+ */
+ public abstract TypeCode create_wstring_tc(int bound);
+
+ /**
+ * Create a typecode which serves as a placeholder for typcode, containing
+ * recursion.
+ *
+ * @param id the id of the recursive typecode, for that this typecode
+ * serves as a placeholder.
+ */
+ public TypeCode create_recursive_tc(String id)
+ {
+ return new recursiveTypeCode(id);
+ }
+
+ /**
+ * Create value box typecode.
+ */
+ public TypeCode create_value_box_tc(String id, String name,
+ TypeCode boxed_type
+ )
+ {
+ generalTypeCode t = new generalTypeCode(TCKind.tk_value_box);
+ t.setName(name);
+ t.setId(id);
+ t.setContentType(boxed_type);
+ return t;
+ }
+
+ /**
+ * Create IDL value type code.
+ */
+ public TypeCode create_value_tc(String id, String name, short type_modifier,
+ TypeCode concrete_base, ValueMember[] members
+ )
+ {
+ recordTypeCode r = new recordTypeCode(TCKind.tk_value);
+ r.setId(id);
+ r.setName(name);
+ r.setTypeModifier(type_modifier);
+ r.setConcreteBase_type(concrete_base);
+
+ for (int i = 0; i < members.length; i++)
+ {
+ r.add(members [ i ]);
+ }
+
+ return r;
+ }
+
+ /**
+ * Get the default context of this ORB. This is an initial root of all
+ * contexts.
+ *
+ * The default method returns a new context with the empty name and
+ * no parent context.
+ *
+ * @return the default context of this ORB.
+ *
+ * @throws NO_IMPLEMENT for the Singleton ORB, returned by
+ * the parameterless {@link init()}.
+ */
+ public Context get_default_context()
+ {
+ return new gnuContext("", null);
+ }
+
+ /**
+ * Return thg typecode, representing the given primitive object type.
+ *
+ * @param the kind of the primitive typecode.
+ *
+ * @return the typecode of the primitve typecode.
+ */
+ public abstract TypeCode get_primitive_tc(TCKind tcKind);
+
+ /**
+ * Returns so-called Singleton ORB, a highly restricted version
+ * that cannot communicate over network. This ORB is provided
+ * for the potentially malicious applets with heavy security restrictions.
+ *
+ * The returned Singleton ORB can only create typecodes,
+ * {@link Any}, {@link ContextList}, {@link NVList} and
+ * {@link org.omg.CORBA.portable.OutputStream} that writes to an
+ * internal buffer.
+ *
+ * All other methods throw the {@link NO_IMPLEMENT} exception, additionally
+ * printing the error message about the potential attempt to violate
+ * the security rules.
+ *
+ * The implementing ORB class, used in this method, is found as described
+ * in the header.
+ *
+ * @return the working derivative of ORB, implementing the methods
+ * of this abstract class.
+ */
+ public static ORB init()
+ {
+ String orb_cn = getORBName(null, RESTRICTED_ORB);
+ if (orb_cn == null)
+ return Restricted_ORB.Singleton;
+ else
+ return createORB(null, orb_cn);
+ }
+
+ /**
+ * Creates the working instance of ORB for an applet.
+ *
+ * By default the built-in fully functional ORB is returned. The ORB class
+ * is found as described in the header of this class.
+ *
+ * @param applet the applet. The property org.omg.CORBA.ORBClass,
+ * if present, defines the used ORB implementation class. If this
+ * property is not present, the ORB class is found as described in the
+ * class header.
+ *
+ * @param props the properties, may be <code>null</code>.
+ *
+ * @return a newly created functional derivative of this abstract class.
+ */
+ public static ORB init(Applet applet, Properties props)
+ {
+ String ocn = applet.getParameter(FUNCTIONAL_ORB);
+ ORB orb = createORB(props, ocn);
+ orb.set_parameters(applet, props);
+
+ return orb;
+ }
+
+ /**
+ * Creates the working instance of ORB for a
+ * standalone application.
+ *
+ * By default the built-in fully functional ORB is returned. The ORB class
+ * is found as described in the header of this class.
+ *
+ * @param the parameters, passed to the applications
+ * <code>main(String[] args)</code> method, may be <code>null</code>.
+ * The parameter -org.omg.CORBA.ORBClass <class name>
+ * if present, defines the used ORB implementation class. If this
+ * property is not present, the ORB class is found as described in the
+ * class header.
+
+ *
+ * @param props application specific properties, may be <code>null</code>.
+ *
+ * @return a newly created functional derivative of this abstract class.
+ */
+ public static ORB init(String[] args, Properties props)
+ {
+ String ocn = null;
+
+ String orbKey = "-" + FUNCTIONAL_ORB;
+
+ if (args != null)
+ if (args.length >= 2)
+ {
+ for (int i = 0; i < args.length - 1; i++)
+ {
+ if (args [ i ].equals(orbKey))
+ ocn = args [ i + 1 ];
+ }
+ }
+
+ ORB orb = createORB(props, ocn);
+
+ orb.set_parameters(args, props);
+ return orb;
+ }
+
+ /**
+ * List the initially available CORBA objects (services).
+ *
+ * @return a list of services.
+ *
+ * @see resolve_initial_references(String)
+ */
+ public abstract String[] list_initial_services();
+
+ /**
+ * Find and return the easily accessible CORBA object, addressed
+ * by name. The returned object is typically casted to the more
+ * specific reference using the <code>narrow(Object)</code> method
+ * of its helper.
+ *
+ * @param name the object name.
+ * @return the object
+ * @throws org.omg.CORBA.ORBPackage.InvalidName if the given name
+ * is not associated with the known object.
+ */
+ public abstract Object resolve_initial_references(String name)
+ throws org.omg.CORBA.ORBPackage.InvalidName;
+
+ /**
+ * Get the IOR reference string for the given object.
+ * IOR can be compared with the Internet address for a web page,
+ * it provides means to locate the CORBA service on the web.
+ * IOR contains the host address, port number, the object identifier
+ * (key) inside the server, the communication protocol version,
+ * supported charsets and so on.
+ *
+ * @param the CORBA object
+ * @return the object IOR representation.
+ * @see string_to_object(String)
+ */
+ public abstract String object_to_string(Object forObject);
+
+ /**
+ * Find and return the CORBA object, addressed by the given
+ * IOR string representation. The object can (an usually is)
+ * located on a remote computer, possibly running a different
+ * (not necessary java) CORBA implementation. The returned
+ * object is typically casted to the more specific reference
+ * using the <code>narrow(Object)</code> method of its helper.
+ *
+ * @param IOR the object IOR representation string.
+ *
+ * @return the found CORBA object.
+ * @see object_to_string(org.omg.CORBA.Object)
+ */
+ public abstract Object string_to_object(String IOR);
+
+ /**
+ * Start listening on the input socket. This method
+ * blocks the current thread until {@link #shutdown(boolean)}
+ * is called and shutdown process is completed.
+ */
+ public void run()
+ {
+ }
+
+ /**
+ * Shutdown the ORB server.
+ *
+ * @param wait_for_completion if true, the current thread is
+ * suspended untile the shutdown process is complete.
+ */
+ public void shutdown(boolean wait_for_completion)
+ {
+ }
+
+ /**
+ * Destroy this server, releasing the occupied resources.
+ * The default method returns without action.
+ */
+ public void destroy()
+ {
+ }
+
+ /**
+ * Set the ORB parameters. This method is normally called from
+ * {@link #init(String[], Properties)}.
+ *
+ * @param para the parameters, that were passed as the parameters
+ * to the <code>main(String[] args)</code> method of the current standalone
+ * application.
+ *
+ * @param props application specific properties that were passed
+ * as a second parameter in {@link init(String[], Properties)}).
+ * Can be <code>null</code>.
+ */
+ protected abstract void set_parameters(String[] para, Properties props);
+
+ /**
+ * Set the ORB parameters. This method is normally called from
+ * {@link #init(Applet, Properties)}.
+ *
+ * @param app the current applet.
+ *
+ * @param props application specific properties, passed as the second
+ * parameter in {@link #init(Applet, Properties)}.
+ * Can be <code>null</code>.
+ */
+ protected abstract void set_parameters(Applet app, Properties props);
+
+ /**
+ * Checks if the communication over network is allowed.
+ * @throws java.lang.SecurityException
+ */
+ private static final void checkNetworkingPermission(String host, int port)
+ throws SecurityException
+ {
+ SecurityManager security = System.getSecurityManager();
+ if (security != null)
+ {
+ security.checkConnect(host, port);
+ }
+ }
+
+ /**
+ * Get the ORB class name.
+ */
+ private static String getORBName(Properties props, String property)
+ {
+ String orb_cn = null;
+
+ if (props != null)
+ orb_cn = props.getProperty(property, null);
+
+ if (orb_cn == null)
+ orb_cn = System.getProperty(property, null);
+
+ if (orb_cn == null)
+ orb_cn = checkFile(property, "user.home", null);
+
+ if (orb_cn == null)
+ orb_cn = checkFile(property, "java.home", "lib");
+
+ return orb_cn;
+ }
+
+ /**
+ * Check if the property is defined in the existsting file orb.properties.
+ *
+ * @param property the property
+ * @param dir the system property, defining the folder where the
+ * file could be expected.
+ * @param subdir subfolder where to look for the file.
+ *
+ * @return the property value, null if not found or file does not exist.
+ */
+ private static String checkFile(String property, String dir, String subdir)
+ {
+ try
+ {
+ File f = new File(dir);
+ if (!f.exists())
+ return null;
+
+ if (subdir != null)
+ f = new File(f, subdir);
+
+ f = new File(f, "orb.properties");
+
+ if (!f.exists())
+ return null;
+
+ Properties p = new Properties();
+ p.load(new BufferedInputStream(new FileInputStream(f)));
+
+ return p.getProperty(property, null);
+ }
+ catch (IOException ex)
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Create ORB when its name is possibly known.
+ *
+ * @param props properties, possibly containing the ORB name.
+ * @param orbClassName the direct ORB class name, overriding
+ * other possible locations, or null if not specified.
+ */
+ private static ORB createORB(Properties props, String orbClassName)
+ {
+ ORB orb = null;
+
+ if (orbClassName == null)
+ {
+ orbClassName = getORBName(props, FUNCTIONAL_ORB);
+
+ if (orbClassName == null)
+ orbClassName = DEFAULT_FUNCTIONAL_ORB;
+ }
+
+ try
+ {
+ orb = (ORB) Class.forName(orbClassName).newInstance();
+ }
+ catch (ClassNotFoundException ex)
+ {
+ noORB(orbClassName, ex);
+ }
+ catch (IllegalAccessException ex)
+ {
+ noORB(orbClassName, ex);
+ }
+ catch (InstantiationException ex)
+ {
+ noORB(orbClassName, ex);
+ }
+
+ return orb;
+ }
+
+ /**
+ * Throw the runtime exception.
+ *
+ * @param orb_c the ORB class name.
+ * @param why the explaining chained exception.
+ */
+ private static void noORB(String orb_c, Throwable why)
{
+ throw new RuntimeException("The ORB " + orb_c + " cannot be instantiated.",
+ why
+ );
}
}
diff --git a/org/omg/CORBA/Object.java b/org/omg/CORBA/Object.java
index e50da51c0..2e73a9373 100644
--- a/org/omg/CORBA/Object.java
+++ b/org/omg/CORBA/Object.java
@@ -38,11 +38,154 @@ exception statement from your version. */
package org.omg.CORBA;
-
/**
- * FIXME
- * Not implemented, defined to keep the code compilable.
+ * The CORBA object reference. The object can be either local or remote.
+ * For the local object, the methods of the derived object are called
+ * like on any other java object. For the remote object, the reference
+ * points to the stup (proxy), responsible for the remote invocation.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class Object
+public interface Object
{
+ /**
+ * Create a request to invoke the method of this object.
+ *
+ * @param context a list of additional properties.
+ * @param operation the name of method to be invoked.
+ * @param parameters the method parameters.
+ * @param returns the container for tge method returned value.
+ *
+ * @return the created reaquest.
+ */
+ Request _create_request(Context context, String operation, NVList parameters,
+ NamedValue returns
+ );
+
+ /**
+ * Create a request to invoke the method of this object, specifying
+ * context list and the list of the expected exception.
+ *
+ * @param context a list of additional properties.
+ * @param operation the name of method to be invoked.
+ * @param parameters the method parameters.
+ * @param returns the container for tge method returned value.
+ * @param exceptions the list of the possible exceptions that the method
+ * can throw.
+ * @param ctx_list the list of the context strings that need to be
+ * resolved and send as a context instance.
+ *
+ * @return the created reaquest.
+ */
+ Request _create_request(Context context, String operation, NVList parameters,
+ NamedValue returns, ExceptionList exceptions,
+ ContextList ctx_list
+ );
+
+ /**
+ * Duplicate the object reference. This does not make much sense for
+ * java platform and is just included for the sake of compliance with
+ * CORBA APIs.
+ *
+ * The method may return the object reference itself.
+ *
+ * @return as a rule, <code>this</code>.
+ */
+ org.omg.CORBA.Object _duplicate();
+
+ /**
+ * Retrieve the domain managers for this object.
+ *
+ * @return the domain managers.
+ */
+ DomainManager[] _get_domain_managers();
+
+ /**
+ * Get the <code>InterfaceDef</code> for this Object.
+ */
+ org.omg.CORBA.Object _get_interface_def();
+
+ /**
+ * Returns the {@link Policy}, applying to this object.
+ *
+ * @param a_policy_type a type of policy to be obtained.
+ * @return a corresponding Policy object.
+ *
+ * @throws BAD_PARAM if the policy of the given type is not
+ * associated with this object, or if it is not supported by this ORB.
+ */
+ Policy _get_policy(int a_policy_type)
+ throws BAD_PARAM;
+
+ /**
+ * Get the hashcode this object reference. The same hashcode still
+ * does not means that the references are the same. From the other
+ * side, two different references may still refer to the same CORBA
+ * object. The returned value must not change during the object
+ * lifetime.
+ *
+ * @param maximum the maximal value to return.
+ *
+ * @return the hashcode.
+ */
+ int _hash(int maximum);
+
+ /**
+ * Check if this object can be referenced by the given repository id.
+ *
+ * @param repositoryIdentifer the repository id.
+ *
+ * @return true if the passed parameter is a repository id of this
+ * CORBA object.
+ */
+ boolean _is_a(String repositoryIdentifer);
+
+ /**
+ * Return true if the other object references are equivalent, so far as
+ * it is possible to determine this easily.
+ *
+ * @param other the other object reference.
+ *
+ * @return true if both references refer the same object, false
+ * if they probably can refer different objects.
+ */
+ boolean _is_equivalent(org.omg.CORBA.Object other);
+
+ /**
+ * Determines if the server object for this reference has already
+ * been destroyed.
+ *
+ * @return true if the object has been destroyed, false otherwise.
+ */
+ boolean _non_existent();
+
+ /**
+ * Free resoureces, occupied by this reference. The object implementation
+ * is not notified, and the other references to the same object are not
+ * affected.
+ */
+ void _release();
+
+ /**
+ * Create a request to invoke the method of this CORBA object.
+ *
+ * @param operation the name of the method to invoke.
+ *
+ * @return the request.
+ */
+ Request _request(String operation);
+
+ /**
+ * Returns a new object with the new policies either replacing or
+ * extending the current policies, depending on the second parameter.
+ *
+ * @param policies the policy additions or replacements.
+ *
+ * @param how either {@link SetOverrideType#SET_OVERRIDE} to override the
+ * current policies of {@link SetOverrideType#ADD_OVERRIDE} to replace
+ * them.
+ *
+ * @return the new reference with the changed policies.
+ */
+ Object _set_policy_override(Policy[] policies, SetOverrideType how);
}
diff --git a/org/omg/CORBA/ObjectHelper.java b/org/omg/CORBA/ObjectHelper.java
new file mode 100644
index 000000000..96545c483
--- /dev/null
+++ b/org/omg/CORBA/ObjectHelper.java
@@ -0,0 +1,113 @@
+/* ObjectHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CORBA;
+
+import gnu.CORBA.primitiveTypeCode;
+
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * The helper operations for the binding list.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class ObjectHelper
+{
+ /**
+ * The cached binding list type code.
+ */
+ private static TypeCode typeCode = new primitiveTypeCode(TCKind.tk_objref);
+
+ /**
+ * Extract the array of object from the given {@link Any}.
+ */
+ public static org.omg.CORBA.Object extract(Any a)
+ {
+ try
+ {
+ return ((ObjectHolder) a.extract_Streamable()).value;
+ }
+ catch (ClassCastException ex)
+ {
+ throw new BAD_OPERATION("CORBA object expected");
+ }
+ }
+
+ /**
+ * Get the object repository id.
+ * @return the empty string.
+ */
+ public static String id()
+ {
+ return "";
+ }
+
+ /**
+ * Insert the object into the given {@link Any}.
+ */
+ public static void insert(Any a, org.omg.CORBA.Object object)
+ {
+ a.insert_Streamable(new ObjectHolder(object));
+ }
+
+ /**
+ * Read the object from the given CDR input stream.
+ */
+ public static org.omg.CORBA.Object read(InputStream istream)
+ {
+ return istream.read_Object();
+ }
+
+ /**
+ * Return the object type code.
+ */
+ public static TypeCode type()
+ {
+ return typeCode;
+ }
+
+ /**
+ * Write the object into the given CDR output stream.
+ */
+ public static void write(OutputStream ostream, org.omg.CORBA.Object value)
+ {
+ ostream.write_Object(value);
+ }
+}
diff --git a/org/omg/CORBA/ObjectHolder.java b/org/omg/CORBA/ObjectHolder.java
new file mode 100644
index 000000000..050da870c
--- /dev/null
+++ b/org/omg/CORBA/ObjectHolder.java
@@ -0,0 +1,127 @@
+/* ObjectHolder.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CORBA;
+
+import gnu.CORBA.primitiveTypeCode;
+
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+
+/**
+ * A holder for CORBA <code>Object</code> that is mapped into
+ * java <code>org.omg.CORBA.Object</code>.
+ *
+ * The holders have several application areas. The end user usually
+ * sees them implementing CORBA methods where the primitive type
+ * is passed by reference. While CORBA (or, for example, C) supports
+ * this, the java does not and a wrapper class is required.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public final class ObjectHolder
+ implements Streamable
+{
+ /**
+ * The default type code for this holder.
+ */
+ private static final TypeCode t_object =
+ new primitiveTypeCode(TCKind.tk_objref);
+
+ /**
+ * The <code>org.omg.CORBA.Object</code> (CORBA <code>Object</code>) value,
+ * held by this ObjectHolder.
+ */
+ public org.omg.CORBA.Object value;
+
+ /**
+ * Constructs an instance of ObjectHolder,
+ * initializing {@link #value} to <code>0</code>.
+ */
+ public ObjectHolder()
+ {
+ }
+
+ /**
+ * Constructs an instance of ObjectHolder,
+ * initializing {@link #value} to the given <code>org.omg.CORBA.Object</code>.
+ *
+ * @param initial_value a value that will be assigned to the
+ * {@link #value} field.
+ */
+ public ObjectHolder(org.omg.CORBA.Object initial_value)
+ {
+ value = initial_value;
+ }
+
+ /**
+ * Fill in the {@link value } field by reading the required data
+ * from the given stream. For <code>org.omg.CORBA.Object</code>, the
+ * functionality is delegated to
+ * {@link org.omg.CORBA.portable.InputStream#read_Object}.
+ *
+ * @param input the input stream to read from.
+ */
+ public void _read(InputStream input)
+ {
+ value = input.read_Object();
+ }
+
+ /**
+ * Returns the TypeCode, corresponding the CORBA type that is stored
+ * using this holder.
+ */
+ public TypeCode _type()
+ {
+ return t_object;
+ }
+
+ /**
+ * Write the {@link value } field to the given stream.
+ * For <code>Object</code>, the functionality
+ * is delegated to
+ * {@link org.omg.CORBA.portable.OutputStream#write_Object(Object) }.
+ *
+ * @param output the output stream to write into.
+ */
+ public void _write(OutputStream output)
+ {
+ output.write_Object(value);
+ }
+}
diff --git a/org/omg/CORBA/Policy.java b/org/omg/CORBA/Policy.java
new file mode 100644
index 000000000..035c78fca
--- /dev/null
+++ b/org/omg/CORBA/Policy.java
@@ -0,0 +1,55 @@
+/* Policy.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CORBA;
+
+import java.io.Serializable;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * The interfaces derived from the class allow an ORB or CORBA service
+ * access to certain choices (id assignment, threading model and so on)
+ * that affect they operation.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public interface Policy
+ extends IDLEntity, Object, Serializable, PolicyOperations
+{
+}
diff --git a/org/omg/CORBA/PolicyOperations.java b/org/omg/CORBA/PolicyOperations.java
new file mode 100644
index 000000000..8a4595d47
--- /dev/null
+++ b/org/omg/CORBA/PolicyOperations.java
@@ -0,0 +1,70 @@
+/* PolicyOperation.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CORBA;
+
+/**
+ * Defines the operations that can be applied to the {@link Policy}
+ * object.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public interface PolicyOperations
+{
+ /**
+ * Return a copy of this Policy.
+ *
+ * @return a copy of theis Policy, without any retained relationships
+ * to the previous domain or object.
+ */
+ Policy copy();
+
+ /**
+ * Destroy the policy object.
+ */
+ void destroy();
+
+ /**
+ * Return an integer number, corresponding the type of this policy.
+ * The values, defining the different policy types, are allocated
+ * by OMG (request AT omg DOT org).
+ *
+ * @return the integer policy code.
+ */
+ int policy_type();
+}
diff --git a/org/omg/CORBA/SetOverrideType.java b/org/omg/CORBA/SetOverrideType.java
new file mode 100644
index 000000000..76bb030d5
--- /dev/null
+++ b/org/omg/CORBA/SetOverrideType.java
@@ -0,0 +1,136 @@
+/* SetOverrideType.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CORBA;
+
+import java.io.Serializable;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * Defines the instruction, how the newly specified policies can be
+ * taken into consideration. The policies can be either
+ * added to the current policies or replace them.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class SetOverrideType
+ implements Serializable, IDLEntity
+{
+ /**
+ * Use v 1.4 serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = -2761857189425106972L;
+
+ /**
+ * Add the new policies to the existing policies.
+ */
+ static final int _ADD_OVERRIDE = 1;
+
+ /**
+ * Replace the new existing policies by the new policies.
+ */
+ static final int _SET_OVERRIDE = 0;
+
+ /**
+ * Add the new policies to the existing policies.
+ * An instance of SetOverrideType, initialized to _ADD_OVERRIDE.
+ */
+ public static final SetOverrideType ADD_OVERRIDE =
+ new SetOverrideType(_ADD_OVERRIDE);
+
+ /**
+ * Replace the new existing policies by the new policies.
+ * An instance of SetOverrideType, initialized to _SET_OVERRIDE.
+ */
+ public static final SetOverrideType SET_OVERRIDE =
+ new SetOverrideType(_SET_OVERRIDE);
+
+ private final int _value;
+
+ /**
+ * No other instances can be created.
+ */
+ private SetOverrideType(int a_value)
+ {
+ _value = a_value;
+ }
+
+ /**
+ * Returns the SetOverrideType, matching the given integer constant
+ * @param kind one of _ADD_OVERRIDE or _SET_OVERRIDE.
+ *
+ * @return one of ADD_OVERRIDE or SET_OVERRIDE.
+ *
+ * @throws BAD_PARAM if the parameter is not one of these two values.
+ */
+ public static SetOverrideType from_int(int kind)
+ {
+ switch (kind)
+ {
+ case _ADD_OVERRIDE :
+ return ADD_OVERRIDE;
+
+ case _SET_OVERRIDE :
+ return SET_OVERRIDE;
+
+ default :
+ throw new BAD_PARAM("invalid add/override type " + kind);
+ }
+ }
+
+ /**
+ * Returns a short string representation.
+ *
+ * @return either "add" or "replace".
+ */
+ public String toString()
+ {
+ return (_value == _ADD_OVERRIDE) ? "add" : "replace";
+ }
+
+ /**
+ * Returns the value, representing stored instruction.
+ *
+ * @return one of ADD_OVERRIDE or SET_OVERRIDE
+ */
+ public int value()
+ {
+ return _value;
+ }
+}
diff --git a/org/omg/CORBA/StringHolder.java b/org/omg/CORBA/StringHolder.java
index f15a6e32e..9a428101a 100644
--- a/org/omg/CORBA/StringHolder.java
+++ b/org/omg/CORBA/StringHolder.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveTypeCode;
+import gnu.CORBA.stringTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -61,8 +61,8 @@ public final class StringHolder
/**
* The default type code for this holder.
*/
- private static final TypeCode t_string =
- new primitiveTypeCode(TCKind.tk_string);
+ private static final stringTypeCode t_string =
+ new stringTypeCode(TCKind.tk_string);
/**
* The <code>String</code> (CORBA <code>string</code>) value,
@@ -91,7 +91,7 @@ public final class StringHolder
}
/**
- * Fill in the {@link value } field by reading the required data
+ * Fill in the {@link #value } field by reading the required data
* from the given stream. For <code>string</code>, the functionality
* is delegated to
* {@link org.omg.CORBA.portable.InputStream#read_string}.
@@ -105,7 +105,8 @@ public final class StringHolder
/**
* Returns the TypeCode, corresponding the CORBA type that is stored
- * using this holder.
+ * using this holder. The {@link TypeCode#length()} method of the
+ * returned typecode always returns 0.
*/
public TypeCode _type()
{
@@ -113,7 +114,7 @@ public final class StringHolder
}
/**
- * Write the {@link value } field to the given stream.
+ * Write the {@link #value } field to the given stream.
* For <code>string</code>, the functionality
* is delegated to
* {@link org.omg.CORBA.portable.OutputStream#write_string(String) }.
diff --git a/org/omg/CORBA/StringSeqHelper.java b/org/omg/CORBA/StringSeqHelper.java
index 0b6365a3b..dc4122d5b 100644
--- a/org/omg/CORBA/StringSeqHelper.java
+++ b/org/omg/CORBA/StringSeqHelper.java
@@ -113,7 +113,7 @@ public abstract class StringSeqHelper
{
String[] value = new String[ input.read_long() ];
for (int i = 0; i < value.length; i++)
- value [ i ] = input.read_wstring();
+ value [ i ] = input.read_string();
return value;
}
@@ -139,6 +139,6 @@ public abstract class StringSeqHelper
output.write_long(value.length);
for (int i = 0; i < value.length; i++)
- output.write_wstring(value [ i ]);
+ output.write_string(value [ i ]);
}
}
diff --git a/org/omg/CORBA/StringSeqHolder.java b/org/omg/CORBA/StringSeqHolder.java
index 22514207c..a697e2493 100755
--- a/org/omg/CORBA/StringSeqHolder.java
+++ b/org/omg/CORBA/StringSeqHolder.java
@@ -98,7 +98,7 @@ public final class StringSeqHolder
value = new String[ input.read_long() ];
for (int i = 0; i < value.length; i++)
{
- value [ i ] = input.read_wstring();
+ value [ i ] = input.read_string();
}
typecode.setLength(value.length);
}
@@ -125,7 +125,7 @@ public final class StringSeqHolder
for (int i = 0; i < value.length; i++)
{
- output.write_wstring(value [ i ]);
+ output.write_string(value [ i ]);
}
}
}
diff --git a/org/omg/CORBA/TestContextList.java b/org/omg/CORBA/TestContextList.java
new file mode 100644
index 000000000..60fcf4cae
--- /dev/null
+++ b/org/omg/CORBA/TestContextList.java
@@ -0,0 +1,50 @@
+
+
+package org.omg.CORBA;
+
+import junit.framework.TestCase;
+
+public class TestContextList
+ extends TestCase
+{
+ ORB orb = ORB.init();
+
+ public void testCollections()
+ throws Exception
+ {
+ ContextList c = orb.create_context_list();
+
+ c.add("a");
+ c.add("b");
+ c.add("c");
+ c.add("d");
+ c.remove(1);
+
+ StringBuffer b = new StringBuffer();
+
+ for (int i = 0; i < c.count(); i++)
+ {
+ b.append(c.item(i));
+ }
+
+ assertEquals(b.toString(), "acd");
+ }
+
+ public void testExceptionList()
+ throws Exception
+ {
+ ExceptionList c = orb.create_exception_list();
+
+ c.add(orb.create_exception_tc("a","b", new StructMember[0]));
+
+ assertEquals(c.count(), 1);
+
+ assertEquals(c.item(0).id(), "a");
+ assertEquals(c.item(0).name(), "b");
+
+ c.remove(0);
+
+ assertEquals(c.count(), 0);
+ }
+
+}
diff --git a/org/omg/CORBA/UNKNOWN.java b/org/omg/CORBA/UNKNOWN.java
index 5f1d37e8c..e1456b70b 100644
--- a/org/omg/CORBA/UNKNOWN.java
+++ b/org/omg/CORBA/UNKNOWN.java
@@ -48,8 +48,8 @@ public class UNKNOWN
extends SystemException
implements Serializable
{
- /**
- * Use serialVersionUID for interoperability.
+ /**
+ * Use serialVersionUID for interoperability.
*/
private static final long serialVersionUID = -3556426185741898205L;
@@ -77,7 +77,7 @@ public class UNKNOWN
* @param minor additional error code.
* @param completed the method completion status.
*/
- UNKNOWN(int minor, CompletionStatus completed)
+ public UNKNOWN(int minor, CompletionStatus completed)
{
super("", minor, completed);
}
@@ -88,7 +88,7 @@ public class UNKNOWN
* @param minor additional error code (the "minor").
* @param completed the method completion status.
*/
- UNKNOWN(String reason, int minor, CompletionStatus completed)
+ public UNKNOWN(String reason, int minor, CompletionStatus completed)
{
super(reason, minor, completed);
}
diff --git a/org/omg/CORBA/UserException.java b/org/omg/CORBA/UserException.java
index c003516db..e305fdea7 100644
--- a/org/omg/CORBA/UserException.java
+++ b/org/omg/CORBA/UserException.java
@@ -40,6 +40,8 @@ package org.omg.CORBA;
import java.io.Serializable;
+import org.omg.CORBA.portable.IDLEntity;
+
/**
* The root class for CORBA IDL-defined user exceptions.
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
@@ -48,12 +50,12 @@ public class UserException
extends Exception
implements IDLEntity, Serializable
{
- /**
- * Use serialVersionUID for interoperability.
+ /**
+ * Use serialVersionUID for interoperability.
* Using the version 1.4 UID.
*/
- private static final long serialVersionUID =-6594940734566091244L;
-
+ private static final long serialVersionUID = -6594940734566091244L;
+
/**
* Constructs a the exception.
*/
diff --git a/org/omg/CORBA/package.html b/org/omg/CORBA/package.html
new file mode 100644
index 000000000..cda65d0ed
--- /dev/null
+++ b/org/omg/CORBA/package.html
@@ -0,0 +1,61 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - org.omg.CORBA</title></head>
+
+<body>
+This package will provide the support of <a href="www.omg.org">OMG</a> <a href="www.CORBA.org">CORBA</a>; see <a href="#overview">overview</a> of the implemented functionality. CORBA is an open, vendor independent system that applications use to work together over networks. Thie purpose of this package is to provide CORBA APIs to java programming language, including the fully functional Object Request Broker ({@link org.omg.CORBA.ORB}).
+
+<a name="overview">
+<h4>Overview of the currently <u>implemented</u> CORBA classes (all packages)</h4>
+<ol>
+<li>The <b>holder</b> classes are containers to store and pass values both to and from the method being executed. In java, the primitive types (int, boolean, etc) are passed by value (one way) only. While Objects are passed by reference, some of them (like String or Integer) are unmodifyable and the arrays cannot be resized. To work around this, such values are passed wrapped into a holder class, where the object instance can be modified and, if needed, replaced. The holders for the most of the types are located in the org.omg.CORBA package, having the suffix *Holder and implementing {@link org.omg.CORBA.portable.Streamable}.
+</li><li>
+The <b>helper</b> classes, having suffix *Helper, provide several convenience methods to manipulate the particular type of holder.
+</li><li>
+The <b>typecode</b> classes provide means to define all large variety of the CORBA types, from strings and arrays till structures, unions and enumerations. The typecodes (instances of the {@link org.omg.CORBA.TypeCode}) are created by invoking the methods of the ORB class. The instance of the restricted ORB (no networking) can be obtained by invoking {@link org.omg.CORBA.ORB#init()}. The typecodes can be used everywhere where the means to define data structures are required.
+</li><li>
+The {@link org.omg.CORBA.Any} class is be used as a container to store the arbitray data type and has the numerous methods for inserting and extracting all primitive types, supported by CORBA. The {@link org.omg.CORBA.Any} is a convienient structure for storing, and passing and returning the values of the arbitrary type.
+</li><li>
+The <b>CDR</b> (Commond Data Representation) streams, {@link org.omg.CORBA.portable.InputStream} and {@link org.omg.CORBA.portable.OutputStream}) are very much like DataInputStream and DataOutputStream in java.io. They read and write data in the binary form, standard for the CORBA messages. The working instances of these abstract classes can be obtained by calling methods on {@link org.omg.CORBA.ORB} or {@link org.omg.CORBA.Any}.
+</li>
+</ol>
+</body>
+</html>
+
diff --git a/org/omg/CORBA/portable/ApplicationException.java b/org/omg/CORBA/portable/ApplicationException.java
new file mode 100644
index 000000000..0604557cd
--- /dev/null
+++ b/org/omg/CORBA/portable/ApplicationException.java
@@ -0,0 +1,91 @@
+/* ApplicationException.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CORBA.portable;
+
+
+/**
+ * This expection is thrown if the application throws an exception,
+ * defined as a part of its remote method definition.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class ApplicationException
+ extends Exception
+ implements java.io.Serializable
+{
+ /**
+ * The input from where the exception parameters can be read.
+ */
+ private final org.omg.CORBA.portable.InputStream m_input;
+
+ /**
+ * The CORBA repository Id of the exception.
+ */
+ private final String m_id;
+
+ /**
+ * Creates an exception.
+ *
+ * @param id the CORBA repository Id of the exception.
+ * @param input the input from where the exception parameters can be read.
+ */
+ public ApplicationException(String id,
+ org.omg.CORBA.portable.InputStream input
+ )
+ {
+ m_id = id;
+ m_input = input;
+ }
+
+ /**
+ * Get the CORBA repository Id of the exception.
+ */
+ public String getId()
+ {
+ return m_id;
+ }
+
+ /**
+ * Get the input stream from where the exception parameters can be read.
+ */
+ public org.omg.CORBA.portable.InputStream getInputStream()
+ {
+ return m_input;
+ }
+}
diff --git a/org/omg/CORBA/portable/ApplicationException.jbx b/org/omg/CORBA/portable/ApplicationException.jbx
new file mode 100644
index 000000000..0113ff3e0
--- /dev/null
+++ b/org/omg/CORBA/portable/ApplicationException.jbx
@@ -0,0 +1,6 @@
+[PropertyInfo]
+[IconNames]
+
+
+
+
diff --git a/org/omg/CORBA/portable/Delegate.java b/org/omg/CORBA/portable/Delegate.java
new file mode 100644
index 000000000..a2ace02b7
--- /dev/null
+++ b/org/omg/CORBA/portable/Delegate.java
@@ -0,0 +1,433 @@
+/* Delegate.java --
+Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CORBA.portable;
+
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.Context;
+import org.omg.CORBA.ContextList;
+import org.omg.CORBA.DomainManager;
+import org.omg.CORBA.ExceptionList;
+import org.omg.CORBA.NO_IMPLEMENT;
+import org.omg.CORBA.NVList;
+import org.omg.CORBA.NamedValue;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Policy;
+import org.omg.CORBA.Request;
+import org.omg.CORBA.SetOverrideType;
+
+/**
+ * Specifies a vendor specific implementation of the
+ * {@link org.omg.CORBA.Object} methods. The calls to these
+ * methods are forwarded to the object delegate that can be
+ * replaced, if needed. The first parameter is the actual
+ * CORBA object to that the operation must be applied.
+ *
+ * Some methods in this class are not abstract, but no implemented,
+ * thowing the {@link NO_IMPLEMENT}. This, however, does not mean that
+ * they are not implemented in the derived classes as well.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public abstract class Delegate
+{
+ /**
+ * Explains the reason of throwing the NO_IMPLEMENT.
+ */
+ private static final String WHY =
+ "Following 1.4 API, this Delegate method must not be implemented. Override.";
+
+ /**
+ * Create a request to invoke the method of this object.
+ *
+ * @param target the CORBA object, to that this operation must be applied.
+ * @param context a list of additional properties.
+ * @param operation the name of method to be invoked.
+ * @param parameters the method parameters.
+ * @param returns the container for tge method returned value.
+ *
+ * @return the created reaquest.
+ */
+ public abstract Request create_request(org.omg.CORBA.Object target,
+ Context context, String operation,
+ NVList parameters, NamedValue returns
+ );
+
+ /**
+ * Create a request to invoke the method of this object, specifying
+ * context list and the list of the expected exception.
+ *
+ * @param target the CORBA object, to that this operation must be applied.
+ * @param context a list of additional properties.
+ * @param operation the name of method to be invoked.
+ * @param parameters the method parameters.
+ * @param returns the container for tge method returned value.
+ * @param exceptions the list of the possible exceptions that the method
+ * can throw.
+ * @param ctx_list the list of the context strings that need to be
+ * resolved and send as a context instance.
+ *
+ * @return the created reaquest.
+ */
+ public abstract Request create_request(org.omg.CORBA.Object target,
+ Context context, String operation,
+ NVList parameters, NamedValue returns,
+ ExceptionList exceptions,
+ ContextList ctx_list
+ );
+
+ /**
+ * Duplicate the object reference. This does not make much sense for
+ * java platform and is just included for the sake of compliance with
+ * CORBA APIs.
+ *
+ * @param target the CORBA object, to that this operation must be applied.
+ *
+ * The method may return the object reference itself.
+ *
+ * @return as a rule, <code>this</code>.
+ */
+ public abstract org.omg.CORBA.Object duplicate(org.omg.CORBA.Object target);
+
+ /**
+ * Retrieve the domain managers for this object.
+ *
+ * @param target the CORBA object, to that this operation must be applied.
+ *
+ * @return the domain managers.
+ *
+ * @throws NO_IMPLEMENT, always (following the 1.4 specification).
+ */
+ public DomainManager[] get_domain_managers(org.omg.CORBA.Object target)
+ {
+ throw new NO_IMPLEMENT(WHY);
+ }
+
+ /**
+ *
+ * @param target the CORBA object, to that this operation must be applied.
+ *
+ * Get the <code>InterfaceDef</code> for this Object.
+ */
+ public abstract org.omg.CORBA.Object get_interface_def(org.omg.CORBA.Object target);
+
+ /**
+ * Returns the {@link Policy}, applying to this object.
+ *
+ * @param target the CORBA object, to that this operation must be applied.
+ * @param a_policy_type a type of policy to be obtained.
+ * @return a corresponding Policy object.
+ *
+ * @throws NO_IMPLEMENT, always (following the 1.4 specification).
+ */
+ public Policy get_policy(org.omg.CORBA.Object target, int a_policy_type)
+ throws BAD_PARAM
+ {
+ throw new NO_IMPLEMENT(WHY);
+ }
+
+ /**
+ * Get the hashcode this object reference. The same hashcode still
+ * does not means that the references are the same. From the other
+ * side, two different references may still refer to the same CORBA
+ * object. The returned value must not change during the object
+ * lifetime.
+ *
+ * @param target the CORBA object, to that this operation must be applied.
+ * @param maximum the maximal value to return.
+ *
+ * @return the hashcode.
+ */
+ public abstract int hash(org.omg.CORBA.Object target, int maximum);
+
+ /**
+ * Check if this object can be referenced by the given repository id.
+ *
+ * @param target the CORBA object, to that this operation must be applied.
+ * @param repositoryIdentifer the repository id.
+ *
+ * @return true if the passed parameter is a repository id of this
+ * CORBA object.
+ */
+ public abstract boolean is_a(org.omg.CORBA.Object target,
+ String repositoryIdentifer
+ );
+
+ /**
+ * Return true if the other object references are equivalent, so far as
+ * it is possible to determine this easily.
+ *
+ * @param target the CORBA object, to that this operation must be applied.
+ * @param other the other object reference.
+ *
+ * @return true if both references refer the same object, false
+ * if they probably can refer different objects.
+ *
+ */
+ public abstract boolean is_equivalent(org.omg.CORBA.Object target,
+ org.omg.CORBA.Object other
+ );
+
+ /**
+ * Returns true if the object is local.
+ *
+ * @param self the object to check.
+ *
+ * @return false, always (following 1.4 specs). Override to get
+ * functionality.
+ */
+ public boolean is_local(org.omg.CORBA.Object self)
+ {
+ return false;
+ }
+
+ /**
+ * Determines if the server object for this reference has already
+ * been destroyed.
+ *
+ * @param target the CORBA object, to that this operation must be applied.
+ *
+ * @return true if the object has been destroyed, false otherwise.
+ */
+ public abstract boolean non_existent(org.omg.CORBA.Object target);
+
+ /**
+ * Compares two objects for equality. The default implementations
+ * delegated call to {@link java.lang.Object#equals(java.lang.Object)}.
+ *
+ * @param self this CORBA object.
+ * @param other the other CORBA object.
+ *
+ * @return true if the objects are equal.
+ */
+ public boolean equals(org.omg.CORBA.Object self, java.lang.Object other)
+ {
+ return super.equals(other);
+ }
+
+ /**
+ * Return the hashcode for this CORBA object. The default implementation
+ * delegates call to {@link #hash(int)}, passing Integer.MAX_VALUE as an
+ * argument.
+ *
+ * @param target the object, for that the hash code must be computed.
+ *
+ * @return the hashcode.
+ */
+ public int hashCode(org.omg.CORBA.Object target)
+ {
+ return hash(target, Integer.MAX_VALUE);
+ }
+
+ /**
+ * Invoke the operation.
+ *
+ * @param target the invocation target.
+ * @param output the stream, containing the written arguments.
+ *
+ * @return the stream, from where the input parameters could be read.
+ *
+ * @throws ApplicationException if the application throws an exception,
+ * defined as a part of its remote method definition.
+ *
+ * @throws RemarshalException if reading(remarshalling) fails.
+ *
+ * @throws NO_IMPLEMENT, always (following the 1.4 specification).
+ */
+ public InputStream invoke(org.omg.CORBA.Object target,
+ org.omg.CORBA.portable.OutputStream output
+ )
+ throws ApplicationException, RemarshalException
+ {
+ throw new NO_IMPLEMENT(WHY);
+ }
+
+ /**
+ * Provides the reference to ORB.
+ *
+ * @param target the object reference.
+ *
+ * @return the associated ORB.
+ *
+ * @throws NO_IMPLEMENT, always (following the 1.4 specification).
+ */
+ public ORB orb(org.omg.CORBA.Object target)
+ {
+ throw new NO_IMPLEMENT(WHY);
+ }
+
+ /**
+ * Free resoureces, occupied by this reference. The object implementation
+ * is not notified, and the other references to the same object are not
+ * affected.
+ *
+ * @param target the CORBA object, to that this operation must be applied.
+ */
+ public abstract void release(org.omg.CORBA.Object target);
+
+ /**
+ * Release the reply stream back to ORB after finishing reading the data
+ * from it.
+ *
+ * @param target the CORBA object, to that this operation must be applied.
+ * @param input the stream, normally returned by {@link #invoke} or
+ * {@link ApplicationException#getInputStream()}, can be null.
+ *
+ * The default method returns without action.
+ */
+ public void releaseReply(org.omg.CORBA.Object target,
+ org.omg.CORBA.portable.InputStream input
+ )
+ {
+ }
+
+ /**
+ * Create a request to invoke the method of this CORBA object.
+ *
+ * @param target the CORBA object, to that this operation must be applied.
+ * @param operation the name of the method to invoke.
+ *
+ * @return the request.
+ */
+ public abstract Request request(org.omg.CORBA.Object target, String operation);
+
+ /**
+ * Create a request to invoke the method of this CORBA object.
+ *
+ * @param target the CORBA object, to that this operation must be applied.
+ * @param operation the name of the method to invoke.
+ * @param response_expected specifies if this is one way message or the
+ * response to the message is expected.
+ *
+ * @return the stream where the method arguments should be written.
+ */
+ public org.omg.CORBA.portable.OutputStream request(org.omg.CORBA.Object target,
+ String operation,
+ boolean response_expected
+ )
+ {
+ throw new NO_IMPLEMENT(WHY);
+ }
+
+ /**
+ * This method is always called after invoking the operation on the
+ * local servant.
+ *
+ * The default method returns without action.
+ *
+ * @param self the object.
+ * @param servant the servant.
+ */
+ public void servant_postinvoke(org.omg.CORBA.Object self,
+ ServantObject servant
+ )
+ {
+ }
+
+ /**
+ * Returns a servant that should be used for this request.
+ * The servant can also be casted to the expected type, calling the
+ * required method directly.
+ *
+ * @param self the object
+ * @param operation the operation
+ * @param expectedType the expected type of the servant.
+ *
+ * This implementation always returns null; override for different
+ * behavior.
+ *
+ * @return the servant or null if the servant is not an expected type
+ * of the method is not supported, for example, due security reasons.
+ */
+ public ServantObject servant_preinvoke(org.omg.CORBA.Object self,
+ String operation, Class expectedType
+ )
+ {
+ return null;
+ }
+
+ /**
+ * Returns a new object with the new policies either replacing or
+ * extending the current policies, depending on the second parameter.
+ *
+ * @param target the CORBA object, to that this operation must be applied.
+ * @param policies the policy additions or replacements.
+ * @param how either {@link SetOverrideType#SET_OVERRIDE} to override the
+ * current policies of {@link SetOverrideType#ADD_OVERRIDE} to replace
+ * them.
+ *
+ * @throws NO_IMPLEMENT, always (following the 1.4 specification).
+ *
+ * @return the new reference with the changed policies.
+ */
+ public org.omg.CORBA.Object set_policy_override(org.omg.CORBA.Object target,
+ Policy[] policies,
+ SetOverrideType how
+ )
+ {
+ throw new NO_IMPLEMENT(WHY);
+ }
+
+ /**
+ * Return a string representation of the passed object.
+ *
+ * @param self the CORBA object, to that the string representation must be
+ * returned. By default, the call is delegated to
+ * {@link java.lang.Object.toString()}.
+ *
+ * @return the string representation.
+ */
+ public String toString(org.omg.CORBA.Object self)
+ {
+ if (self instanceof ObjectImpl)
+ {
+ ObjectImpl x = (ObjectImpl) self;
+ StringBuffer b = new StringBuffer(x.getClass().getName());
+ b.append(": [");
+ for (int i = 0; i < x._ids().length; i++)
+ {
+ b.append(x._ids() [ i ]);
+ b.append(" ");
+ }
+ b.append("]");
+ return b.toString();
+ }
+ else
+ return self.getClass().getName();
+ }
+}
diff --git a/org/omg/CORBA/portable/IndirectionException.java b/org/omg/CORBA/portable/IndirectionException.java
new file mode 100644
index 000000000..9bcaa6c52
--- /dev/null
+++ b/org/omg/CORBA/portable/IndirectionException.java
@@ -0,0 +1,77 @@
+/* IndirectionException.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CORBA.portable;
+
+import java.io.Serializable;
+
+import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.SystemException;
+
+/**
+ * This exception is thrown when reading from the ORBs input streams
+ * certain specific data layouts (object recursive references to itself).
+ * These layouts are not supported by this CORBA implementation.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class IndirectionException
+ extends SystemException
+ implements Serializable
+{
+ /**
+ * Use v 1.4 serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = -1923858944380721643L;
+
+ /**
+ * The stream offset, indicating, where the error has occured.
+ */
+ public int offset;
+
+ /**
+ * Create the indirection exception.
+ *
+ * @param an_offset the stream offset, indicating the error position.
+ */
+ public IndirectionException(int an_offset)
+ {
+ super("Indirection exception", 0, CompletionStatus.COMPLETED_NO);
+ offset = an_offset;
+ }
+}
diff --git a/org/omg/CORBA/portable/InvokeHandler.java b/org/omg/CORBA/portable/InvokeHandler.java
new file mode 100644
index 000000000..e63354fb7
--- /dev/null
+++ b/org/omg/CORBA/portable/InvokeHandler.java
@@ -0,0 +1,66 @@
+/* InvokeHandler.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CORBA.portable;
+
+import org.omg.CORBA.SystemException;
+
+/**
+ * Provides the dispatching mechanism for incoming call.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public interface InvokeHandler
+{
+ /**
+ * Invoke the object method.
+ *
+ * @param method the name of the method to invoke.
+ * @param input the input stream to read parameters from.
+ * @param handler the response handler, used for creating the reply.
+ *
+ * @return the output stream, returned by {@link ResponseHandler}.
+ * The response values are already written to that stream.
+ *
+ * @throws SystemException if invocation has failed due CORBA system exception.
+ */
+ OutputStream _invoke(String method, org.omg.CORBA.portable.InputStream input,
+ ResponseHandler handler
+ )
+ throws SystemException;
+}
diff --git a/org/omg/CORBA/portable/ObjectImpl.java b/org/omg/CORBA/portable/ObjectImpl.java
new file mode 100644
index 000000000..d501e38b9
--- /dev/null
+++ b/org/omg/CORBA/portable/ObjectImpl.java
@@ -0,0 +1,414 @@
+/* ObjectImpl.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CORBA.portable;
+
+import org.omg.CORBA.Context;
+import org.omg.CORBA.ContextList;
+import org.omg.CORBA.DomainManager;
+import org.omg.CORBA.ExceptionList;
+import org.omg.CORBA.NVList;
+import org.omg.CORBA.NamedValue;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Policy;
+import org.omg.CORBA.Request;
+import org.omg.CORBA.SetOverrideType;
+
+/**
+ * The basic implementation of the CORBA Object. The most of the methods
+ * delegate the functionality to the {@link Delegate} that can be replaced
+ * by {@link #_set_delegate(Delegate)}.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public abstract class ObjectImpl
+ implements org.omg.CORBA.Object
+{
+ /**
+ * The vendor - dependent delegate, responsible for the method implementations.
+ */
+ private Delegate delegate;
+
+ /**
+ * Create a request to invoke the method of this object, specifying
+ * context list and the list of the expected exception.
+ *
+ * @param context a list of additional properties.
+ * @param operation the name of method to be invoked.
+ * @param parameters the method parameters.
+ * @param returns the container for tge method returned value.
+ * @param exceptions the list of the possible exceptions that the method
+ * can throw.
+ * @param ctx_list the list of the context strings that need to be
+ * resolved and send as a context instance.
+ *
+ * @return the created reaquest.
+ */
+ public Request _create_request(Context context, String operation,
+ NVList parameters, NamedValue returns,
+ ExceptionList exceptions, ContextList ctx_list
+ )
+ {
+ return delegate.create_request(this, context, operation, parameters,
+ returns, exceptions, ctx_list
+ );
+ }
+
+ /**
+ * Create a request to invoke the method of this object.
+ *
+ * @param context a list of additional properties.
+ * @param operation the name of method to be invoked.
+ * @param parameters the method parameters.
+ * @param returns the container for tge method returned value.
+ *
+ * @return the created reaquest.
+ */
+ public Request _create_request(Context context, String operation,
+ NVList parameters, NamedValue returns
+ )
+ {
+ return delegate.create_request(this, context, operation, parameters, returns);
+ }
+
+ /**
+ * Duplicate the object reference. This does not make much sense for
+ * java platform and is just included for the sake of compliance with
+ * CORBA APIs.
+ *
+ * The method may return the object reference itself.
+ *
+ * @return as a rule, <code>this</code>.
+ */
+ public org.omg.CORBA.Object _duplicate()
+ {
+ return delegate.duplicate(this);
+ }
+
+ /**
+ * Get vendor specific delegate, responsible for the implemented
+ * functionality.
+ */
+ public Delegate _get_delegate()
+ {
+ return delegate;
+ }
+
+ /**
+ * Retrieve the domain managers for this object.
+ *
+ * @return the domain managers.
+ */
+ public DomainManager[] _get_domain_managers()
+ {
+ return delegate.get_domain_managers(this);
+ }
+
+ /**
+ * Get the <code>InterfaceDef</code> for this Object.
+ */
+ public org.omg.CORBA.Object _get_interface_def()
+ {
+ return delegate.get_interface_def(this);
+ }
+
+ /**
+ * Returns the {@link Policy}, applying to this object.
+ *
+ * @param a_policy_type a type of policy to be obtained.
+ * @return a corresponding Policy object.
+ *
+ * @throws BAD_PARAM if the policy of the given type is not
+ * associated with this object, or if it is not supported by this ORB.
+ */
+ public Policy _get_policy(int type)
+ {
+ return delegate.get_policy(this, type);
+ }
+
+ /**
+ * Get the array of interface repository ids, defining this object.
+ */
+ public abstract String[] _ids();
+
+ /**
+ * Get the hashcode this object reference. The same hashcode still
+ * does not means that the references are the same. From the other
+ * side, two different references may still refer to the same CORBA
+ * object. The returned value must not change during the object
+ * lifetime.
+ *
+ * @param maximum the maximal value to return.
+ *
+ * @return the hashcode.
+ */
+ public int _hash(int max)
+ {
+ return delegate.hash(this, max);
+ }
+
+ /**
+ * Invoke the operation.
+ *
+ * @param target the invocation target.
+ * @param output the stream, containing the written arguments.
+ *
+ * @return the stream, from where the input parameters could be read.
+ *
+ * @throws ApplicationException if the application throws an exception,
+ * defined as a part of its remote method definition.
+ *
+ * @throws RemarshalException if reading(remarshalling) fails.
+ */
+ public InputStream _invoke(OutputStream output)
+ throws org.omg.CORBA.portable.ApplicationException,
+ org.omg.CORBA.portable.RemarshalException
+ {
+ return delegate.invoke(this, output);
+ }
+
+ /**
+ * Check if this object can be referenced by the given repository id.
+ *
+ * @param repositoryIdentifer the repository id.
+ *
+ * @return true if the passed parameter is a repository id of this
+ * CORBA object.
+ */
+ public boolean _is_a(String idl_id)
+ {
+ return delegate.is_a(this, idl_id);
+ }
+
+ /**
+ * Return true if the other object references are equivalent, so far as
+ * it is possible to determine this easily.
+ *
+ * @param other the other object reference.
+ *
+ * @return true if both references refer the same object, false
+ * if they probably can refer different objects. Uses direct
+ * comparison if the delegate has not been set.
+ */
+ public boolean _is_equivalent(org.omg.CORBA.Object other)
+ {
+ return (delegate == null) ? this == other
+ : delegate.is_equivalent(this, other);
+ }
+
+ /**
+ * Returns true if the object is local.
+ *
+ * @param self the object to check.
+ *
+ * @return false, always (following 1.4 specs). Override to get
+ * functionality.
+ */
+ public boolean _is_local()
+ {
+ return delegate.is_local(this);
+ }
+
+ /**
+ * Determines if the server object for this reference has already
+ * been destroyed.
+ *
+ * @return true if the object has been destroyed, false otherwise.
+ */
+ public boolean _non_existent()
+ {
+ return delegate.non_existent(this);
+ }
+
+ /**
+ * Provides the reference to ORB.
+ *
+ * @return the associated ORB.
+ */
+ public ORB _orb()
+ {
+ return delegate.orb(this);
+ }
+
+ /**
+ * Free resoureces, occupied by this reference. The object implementation
+ * is not notified, and the other references to the same object are not
+ * affected.
+ */
+ public void _release()
+ {
+ delegate.release(this);
+ }
+
+ /**
+ * Release the reply stream back to ORB after finishing reading the data
+ * from it.
+ *
+ * @param input the stream, normally returned by {@link #invoke} or
+ * {@link ApplicationException#getInputStream()}, can be null.
+ *
+ * @throws NO_IMPLEMENT, always (following the 1.4 specification).
+ */
+ public void _releaseReply(InputStream stream)
+ {
+ delegate.releaseReply(this, stream);
+ }
+
+ /**
+ * Create a request to invoke the method of this CORBA object.
+ *
+ * @param operation the name of the method to invoke.
+ *
+ * @return the request.
+ */
+ public Request _request(String method)
+ {
+ return delegate.request(this, method);
+ }
+
+ /**
+ * Create a request to invoke the method of this CORBA object.
+ *
+ * @param operation the name of the method to invoke.
+ * @param response_expected specifies if this is one way message or the
+ * response to the message is expected.
+ *
+ * @return the stream where the method arguments should be written.
+ */
+ public org.omg.CORBA.portable.OutputStream _request(String method,
+ boolean response_expected
+ )
+ {
+ return delegate.request(this, method, response_expected);
+ }
+
+ /**
+ * This method is always called after invoking the operation on the
+ * local servant.
+ *
+ * The default method returns without action.
+ *
+ * @param self the object.
+ * @param servant the servant.
+ */
+ public void _servant_postinvoke(ServantObject servant)
+ {
+ delegate.servant_postinvoke(this, servant);
+ }
+
+ /**
+ * Returns a servant that should be used for this request.
+ * The servant can also be casted to the expected type, calling the
+ * required method directly.
+ *
+ * @param self the object
+ * @param operation the operation
+ * @param expectedType the expected type of the servant.
+ *
+ * This implementation always returns null; override for different
+ * behavior.
+ *
+ * @return the servant or null if the servant is not an expected type
+ * of the method is not supported, for example, due security reasons.
+ */
+ public ServantObject _servant_preinvoke(String method, Class expected_type)
+ {
+ return delegate.servant_preinvoke(this, method, expected_type);
+ }
+
+ /**
+ * Set the delegate, responsible for the implemented functionality.
+ *
+ * @param a_delegate a delegate, responsible for the implemented
+ * functionality.
+ */
+ public void _set_delegate(Delegate a_delegate)
+ {
+ delegate = a_delegate;
+ }
+
+ /**
+ * Returns a new object with the new policies either replacing or
+ * extending the current policies, depending on the second parameter.
+ *
+ * @param policies the policy additions or replacements.
+ * @param how either {@link SetOverrideType#SET_OVERRIDE} to override the
+ * current policies of {@link SetOverrideType#ADD_OVERRIDE} to replace
+ * them.
+ */
+ public org.omg.CORBA.Object _set_policy_override(Policy[] policies,
+ SetOverrideType set_add
+ )
+ {
+ return delegate.set_policy_override(this, policies, set_add);
+ }
+
+ /**
+ * Check if this object is equal to another object.
+ *
+ * @param other the other object to compare.
+ *
+ * @return true if the objects are equal.
+ */
+ public boolean equals(java.lang.Object other)
+ {
+ return delegate.equals(this, other);
+ }
+
+ /**
+ * Return the hashcode for this CORBA object. The default implementation
+ * delegates call to {@link #_hash(int)}, passing Integer.MAX_VALUE as an
+ * argument.
+ *
+ * @return the hashcode.
+ */
+ public int hashCode()
+ {
+ return _hash(Integer.MAX_VALUE);
+ }
+
+ /**
+ * Return the string representation of the passed object.
+ *
+ * @return the string representation.
+ */
+ public String toString()
+ {
+ return delegate.toString(this);
+ }
+}
diff --git a/org/omg/CORBA/portable/RemarshalException.java b/org/omg/CORBA/portable/RemarshalException.java
new file mode 100644
index 000000000..3898e3528
--- /dev/null
+++ b/org/omg/CORBA/portable/RemarshalException.java
@@ -0,0 +1,54 @@
+/* RemarshalException.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CORBA.portable;
+
+
+/**
+ * This is exception is potentially thrown by the _invoke()
+ * method of the object implementation, requiring to write the method
+ * parameters repeatedly. The parameters must be re-written as long as this
+ * exception is thrown.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class RemarshalException
+ extends Exception
+ implements java.io.Serializable
+{
+}
diff --git a/org/omg/CORBA/portable/ResponseHandler.java b/org/omg/CORBA/portable/ResponseHandler.java
new file mode 100644
index 000000000..9c2bca745
--- /dev/null
+++ b/org/omg/CORBA/portable/ResponseHandler.java
@@ -0,0 +1,58 @@
+/* ResponseHandler.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CORBA.portable;
+
+/**
+ * The interface, able to return streams, where the reply data can be
+ * marshalled.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public interface ResponseHandler
+{
+ /**
+ * Create a stream, suitable for writing a user exception.
+ */
+ org.omg.CORBA.portable.OutputStream createExceptionReply();
+
+ /**
+ * Create a stream for writing an ordinary reply (not an exception).
+ */
+ org.omg.CORBA.portable.OutputStream createReply();
+}
diff --git a/org/omg/CORBA/portable/ServantObject.java b/org/omg/CORBA/portable/ServantObject.java
new file mode 100644
index 000000000..3ecf38d5b
--- /dev/null
+++ b/org/omg/CORBA/portable/ServantObject.java
@@ -0,0 +1,61 @@
+/* ServantObject.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CORBA.portable;
+
+
+/**
+ * Together with supporting methods in {@link ObjectImpl} and {@link Delegate},
+ * provides mechanism for direct calls of clients, running on the same
+ * virtual machine (collocated).
+ *
+ * @see ObjectImpl#_servant_preinvoke(String, Class)
+ * @see ObjectImpl#_servant_postinvoke(ServantObject)
+ * @see Delegate#servant_preinvoke(org.omg.CORBA.Object, String operation, Class)
+ * @see Delegate#servant_postinvoke(org.omg.CORBA.Object, ServantObject)
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class ServantObject
+{
+ /**
+ * The real servant, that can be casted to the expected type, later
+ * invoking the methods directly.
+ */
+ public java.lang.Object Servant;
+}
diff --git a/org/omg/CORBA/portable/UnknownException.java b/org/omg/CORBA/portable/UnknownException.java
new file mode 100644
index 000000000..717ee2d48
--- /dev/null
+++ b/org/omg/CORBA/portable/UnknownException.java
@@ -0,0 +1,76 @@
+/* UnknownException.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CORBA.portable;
+
+import java.io.Serializable;
+
+import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.SystemException;
+
+/**
+ * The wrapper of the arbitrary exception into the System exception.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class UnknownException
+ extends SystemException
+ implements Serializable
+{
+ /**
+ * Use serialVersionUID (1.4) for interoperability.
+ */
+ private static final long serialVersionUID = 1725238280802233450L;
+
+ /**
+ * The original exception.
+ */
+ public Throwable originalEx;
+
+ /**
+ * Create a new unknown exception, wrapping a reason.
+ *
+ * @param reason an exception that has caused this unknown exception.
+ */
+ public UnknownException(Throwable reason)
+ {
+ super("" + reason, 0, CompletionStatus.COMPLETED_MAYBE);
+
+ originalEx = reason;
+ }
+}
diff --git a/org/omg/CORBA/portable/package.html b/org/omg/CORBA/portable/package.html
new file mode 100644
index 000000000..ee1b792a1
--- /dev/null
+++ b/org/omg/CORBA/portable/package.html
@@ -0,0 +1,50 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in org.omg.CORBA.portable package
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - org.omg.CORBA.portable</title></head>
+
+<body>
+<p>This package defines CDR streams,
+used for communications between orbs, normally via network.
+It also declares mechanisms, enabling the code, provided by one vendor, to run on the
+{@link org.omg.CORBA.ORB}, implemented by another vendor.</p>
+
+@author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+</body>
+</html>
diff --git a/org/omg/CosNaming/Binding.java b/org/omg/CosNaming/Binding.java
new file mode 100644
index 000000000..4d08a5967
--- /dev/null
+++ b/org/omg/CosNaming/Binding.java
@@ -0,0 +1,81 @@
+/* Binding.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * Defines the binding with the given name and type.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public final class Binding
+ implements IDLEntity
+{
+ /**
+ * The binding type holds value ncontext for bindings,
+ * created with operations bind_context, rebind_context or
+ * bind_new_context. It holds value nobject of all other
+ * possible bindings.
+ */
+ public BindingType binding_type;
+
+ /**
+ * The binding name, consisting of the number of the name components.
+ */
+ public NameComponent[] binding_name;
+
+ /**
+ * Create an empty binding.
+ */
+ public Binding()
+ {
+ }
+
+ /**
+ * Create the binding, initialised to the given values.
+ * @param a_name the binding name.
+ * @param a_type the binding type.
+ */
+ public Binding(NameComponent[] a_name, BindingType a_type)
+ {
+ binding_name = a_name;
+ binding_type = a_type;
+ }
+}
diff --git a/org/omg/CosNaming/BindingHelper.java b/org/omg/CosNaming/BindingHelper.java
new file mode 100644
index 000000000..e8da9740b
--- /dev/null
+++ b/org/omg/CosNaming/BindingHelper.java
@@ -0,0 +1,138 @@
+/* BindingHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.StructMember;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * The helper operations for {@link Binding}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class BindingHelper
+{
+ /**
+ * The {@link Binding} repository id.
+ */
+ private static String _id = "IDL:omg.org/CosNaming/Binding:1.0";
+
+ /**
+ * The cached type code value.
+ */
+ private static TypeCode typeCode;
+
+ /**
+ * Extract the binding from the given {@link Any}.
+ */
+ public static Binding extract(Any a)
+ {
+ try
+ {
+ return ((BindingHolder) a.extract_Streamable()).value;
+ }
+ catch (ClassCastException ex)
+ {
+ throw new BAD_OPERATION("Binding expected");
+ }
+ }
+
+ /**
+ * Return the binding repository id.
+ */
+ public static String id()
+ {
+ return _id;
+ }
+
+ /**
+ * Insert the binding into the given {@link Any}.
+ */
+ public static void insert(Any a, Binding that)
+ {
+ a.insert_Streamable(new BindingHolder(that));
+ }
+
+ /**
+ * Read the binding from the given CDR stream.
+ */
+ public static Binding read(InputStream istream)
+ {
+ Binding value = new Binding();
+ value.binding_name = NameHelper.read(istream);
+ value.binding_type = BindingTypeHelper.read(istream);
+ return value;
+ }
+
+ /**
+ * Create the type code for this exception.
+ */
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ ORB orb = ORB.init();
+
+ StructMember[] members = new StructMember[ 2 ];
+ TypeCode member;
+ member = NameComponentHelper.type();
+ member = orb.create_sequence_tc(0, member);
+ member = orb.create_alias_tc(NameHelper.id(), "Name", member);
+ members [ 0 ] = new StructMember("binding_name", member, null);
+ member = BindingTypeHelper.type();
+ members [ 1 ] = new StructMember("binding_type", member, null);
+ typeCode = orb.create_struct_tc(id(), "Binding", members);
+ }
+ return typeCode;
+ }
+
+ /**
+ * Write the exception to the CDR output stream.
+ */
+ public static void write(OutputStream ostream, Binding value)
+ {
+ NameHelper.write(ostream, value.binding_name);
+ BindingTypeHelper.write(ostream, value.binding_type);
+ }
+}
diff --git a/org/omg/CosNaming/BindingHolder.java b/org/omg/CosNaming/BindingHolder.java
new file mode 100644
index 000000000..3ec683f6d
--- /dev/null
+++ b/org/omg/CosNaming/BindingHolder.java
@@ -0,0 +1,94 @@
+/* BindingHolder.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming;
+
+import org.omg.CORBA.portable.Streamable;
+
+/**
+ * A holder for the binding type.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public final class BindingHolder
+ implements Streamable
+{
+ /**
+ * The stored binding type.
+ */
+ public Binding value;
+
+ /**
+ * Create an empty instance.
+ */
+ public BindingHolder()
+ {
+ }
+
+ /**
+ * Create the intialised holder.
+ */
+ public BindingHolder(Binding initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * Read the holder value from the CDR stream.
+ */
+ public void _read(org.omg.CORBA.portable.InputStream i)
+ {
+ value = BindingHelper.read(i);
+ }
+
+ /**
+ * Return the binding type code.
+ */
+ public org.omg.CORBA.TypeCode _type()
+ {
+ return BindingHelper.type();
+ }
+
+ /**
+ * Write the holder value to the CDR stream.
+ */
+ public void _write(org.omg.CORBA.portable.OutputStream o)
+ {
+ BindingHelper.write(o, value);
+ }
+}
diff --git a/org/omg/CosNaming/BindingIterator.java b/org/omg/CosNaming/BindingIterator.java
new file mode 100644
index 000000000..c1a688955
--- /dev/null
+++ b/org/omg/CosNaming/BindingIterator.java
@@ -0,0 +1,76 @@
+/* BindingIterator.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming;
+
+
+/**
+ * The iterator for seing the available bindings.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface BindingIterator
+{
+ /**
+ * Destroy the iterator on the server side. This must always be
+ * called, as otherwise the iterator will remain on the server even
+ * after the client application terminates.
+ */
+ void destroy();
+
+ /**
+ * Return the desired amount of bindings.
+ *
+ * @param amount the maximal number of bindings to return.
+ * @param a_list a holder to store the returned bindings.
+ *
+ * @return false if there are no more bindings available,
+ * true otherwise.
+ */
+ boolean next_n(int amount, BindingListHolder a_list);
+
+ /**
+ * Return the next binding.
+ *
+ * @param a_binding a holder, where the next binding will be stored.
+ *
+ * @return false if there are no more bindings available, true
+ * otherwise.
+ */
+ boolean next_one(BindingHolder a_binding);
+}
diff --git a/org/omg/CosNaming/BindingIteratorHelper.java b/org/omg/CosNaming/BindingIteratorHelper.java
new file mode 100644
index 000000000..4519fdd17
--- /dev/null
+++ b/org/omg/CosNaming/BindingIteratorHelper.java
@@ -0,0 +1,148 @@
+/* BindingIteratorHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * The helper operations for {@link BindingIterator}
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class BindingIteratorHelper
+{
+ /**
+ * The {@link BindingIterator} repository id.
+ */
+ private static String _id = "IDL:omg.org/CosNaming/BindingIterator:1.0";
+
+ /**
+ * The cached type code value.
+ */
+ private static TypeCode typeCode = null;
+
+ /**
+ * Extract the binding iterator from the given {@link Any}.
+ */
+ public static BindingIterator extract(Any a)
+ {
+ try
+ {
+ return ((BindingIteratorHolder) a.extract_Streamable()).value;
+ }
+ catch (ClassCastException ex)
+ {
+ throw new BAD_OPERATION("Binding iterator expected");
+ }
+ }
+
+ /**
+ * Return the binding iterator repository id.
+ */
+ public static String id()
+ {
+ return _id;
+ }
+
+ /**
+ * Insert the binding iterator into the given {@link Any}.
+ */
+ public static void insert(Any a, BindingIterator that)
+ {
+ a.insert_Streamable(new BindingIteratorHolder(that));
+ }
+
+ /**
+ * Narrow the given object to the BindingIterator. The narrowing
+ * means either direct casting or re-instantiating with the same
+ * delegate.
+ *
+ * @param obj the object to cast.
+ *
+ * @return the casted binding iterator.
+ */
+ public static BindingIterator narrow(org.omg.CORBA.Object obj)
+ {
+ if (obj == null)
+ return null;
+ else if (obj instanceof BindingIterator)
+ return (BindingIterator) obj;
+ else if (!obj._is_a(id()))
+ throw new BAD_PARAM();
+ else
+ {
+ Delegate delegate = ((ObjectImpl) obj)._get_delegate();
+ return new _BindingIteratorStub(delegate);
+ }
+ }
+
+ /**
+ * Read the exception from the given CDR stream.
+ */
+ public static BindingIterator read(InputStream istream)
+ {
+ return narrow(istream.read_Object(_BindingIteratorStub.class));
+ }
+
+ /**
+ * Create the type code for the BindingIterator.
+ */
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ typeCode = ORB.init().create_interface_tc(id(), "BindingIterator");
+ return typeCode;
+ }
+
+ /**
+ * Write the exception to the CDR output stream.
+ */
+ public static void write(OutputStream ostream, BindingIterator value)
+ {
+ ostream.write_Object((org.omg.CORBA.Object) value);
+ }
+}
diff --git a/org/omg/CosNaming/BindingIteratorHolder.java b/org/omg/CosNaming/BindingIteratorHolder.java
new file mode 100644
index 000000000..d6b53c2fd
--- /dev/null
+++ b/org/omg/CosNaming/BindingIteratorHolder.java
@@ -0,0 +1,97 @@
+/* BindingIteratorHolder.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming;
+
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+
+/**
+ * The holder to store the binding iterator.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public final class BindingIteratorHolder
+ implements Streamable
+{
+ /**
+ * The stored binding iterator.
+ */
+ public BindingIterator value;
+
+ /**
+ * Create an empty instance of this holder.
+ */
+ public BindingIteratorHolder()
+ {
+ }
+
+ /**
+ * Create the intialised instance.
+ */
+ public BindingIteratorHolder(BindingIterator initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * Read the holder value from the CDR stream.
+ */
+ public void _read(InputStream in)
+ {
+ value = BindingIteratorHelper.read(in);
+ }
+
+ /**
+ * Returen the type code of the binding iterator.
+ */
+ public TypeCode _type()
+ {
+ return BindingIteratorHelper.type();
+ }
+
+ /**
+ * Write the intialised value to the CDR stream.
+ */
+ public void _write(OutputStream out)
+ {
+ BindingIteratorHelper.write(out, value);
+ }
+}
diff --git a/org/omg/CosNaming/BindingListHelper.java b/org/omg/CosNaming/BindingListHelper.java
new file mode 100644
index 000000000..a49090f30
--- /dev/null
+++ b/org/omg/CosNaming/BindingListHelper.java
@@ -0,0 +1,132 @@
+/* BindingListHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * The helper operations for the binding list.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class BindingListHelper
+{
+ /**
+ * The binding list repository id.
+ */
+ private static String _id = "IDL:omg.org/CosNaming/BindingList:1.0";
+
+ /**
+ * The cached binding list type code.
+ */
+ private static TypeCode typeCode;
+
+ /**
+ * Extract the array of bindings from the given {@link Any}.
+ */
+ public static Binding[] extract(Any a)
+ {
+ try
+ {
+ return ((BindingListHolder) a.extract_Streamable()).value;
+ }
+ catch (ClassCastException ex)
+ {
+ throw new BAD_OPERATION("Binding list expected");
+ }
+ }
+
+ /**
+ * Get the binding list repository id.
+ */
+ public static String id()
+ {
+ return _id;
+ }
+
+ /**
+ * Insert the array of bindings into the given {@link Any}.
+ */
+ public static void insert(Any a, Binding[] bindings)
+ {
+ a.insert_Streamable(new BindingListHolder(bindings));
+ }
+
+ /**
+ * Read the array of bindings from the given CDR input stream.
+ */
+ public static Binding[] read(InputStream istream)
+ {
+ Binding[] value = new Binding[ istream.read_long() ];
+
+ for (int i = 0; i < value.length; i++)
+ value [ i ] = BindingHelper.read(istream);
+ return value;
+ }
+
+ /**
+ * Return the binding array type code.
+ */
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ ORB orb = ORB.init();
+ typeCode = BindingHelper.type();
+ typeCode = orb.create_sequence_tc(0, typeCode);
+ typeCode = orb.create_alias_tc(id(), "BindingList", typeCode);
+ }
+ return typeCode;
+ }
+
+ /**
+ * Write the array of bindings into the given CDR output stream.
+ */
+ public static void write(OutputStream ostream, Binding[] value)
+ {
+ ostream.write_long(value.length);
+ for (int i = 0; i < value.length; i++)
+ org.omg.CosNaming.BindingHelper.write(ostream, value [ i ]);
+ }
+}
diff --git a/org/omg/CosNaming/BindingListHolder.java b/org/omg/CosNaming/BindingListHolder.java
new file mode 100644
index 000000000..5e58584dc
--- /dev/null
+++ b/org/omg/CosNaming/BindingListHolder.java
@@ -0,0 +1,97 @@
+/* BindingListHolder.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming;
+
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+
+/**
+ * A class to hold the binding list.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public final class BindingListHolder
+ implements Streamable
+{
+ /**
+ * The wrapped binding list.
+ */
+ public Binding[] value = null;
+
+ /**
+ * Create the unitialised holder.
+ */
+ public BindingListHolder()
+ {
+ }
+
+ /**
+ * Create the holder, intialised to the given value.
+ */
+ public BindingListHolder(Binding[] initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * Read the binding list from the given CDR stream.
+ */
+ public void _read(InputStream in)
+ {
+ value = BindingListHelper.read(in);
+ }
+
+ /**
+ * Get the type code of the binding.
+ */
+ public TypeCode _type()
+ {
+ return BindingListHelper.type();
+ }
+
+ /**
+ * Write the binding list into the given CDR stream.
+ */
+ public void _write(OutputStream out)
+ {
+ BindingListHelper.write(out, value);
+ }
+}
diff --git a/org/omg/CosNaming/BindingType.java b/org/omg/CosNaming/BindingType.java
new file mode 100644
index 000000000..5e0e5466e
--- /dev/null
+++ b/org/omg/CosNaming/BindingType.java
@@ -0,0 +1,124 @@
+/* BindingType.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming;
+
+import org.omg.CORBA.BAD_PARAM;
+
+/**
+ * Specifies the binding type (how the binding has been created).
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class BindingType
+ implements org.omg.CORBA.portable.IDLEntity
+{
+ /**
+ * This constant means that the binding has been created
+ * with operations bind_context, rebind_context or
+ * bind_new_context.
+ */
+ public static final int _ncontext = 1;
+
+ /**
+ * This constant means that the binding has been created by the
+ * means, different from the listed in {@link _ncontext} description.
+ */
+ public static final int _nobject = 0;
+
+ /**
+ * This constant means that the binding has been created
+ * with operations bind_context, rebind_context or
+ * bind_new_context.
+ */
+ public static final BindingType ncontext = new BindingType(_ncontext);
+
+ /**
+ * This constant means that the binding has been created by the
+ * means, different from the listed in {@link _ncontext} description.
+ */
+ public static final BindingType nobject = new BindingType(_nobject);
+
+ /**
+ * The binding type, defined by this instance.
+ */
+ private final int type;
+
+ /**
+ * Create the new binding type definition.
+ *
+ * @param value the binding type, normally either _nobject or
+ * _ncontext.
+ */
+ protected BindingType(int value)
+ {
+ type = value;
+ }
+
+ /**
+ * Get the binding type instance, matching its integer code.
+ *
+ * @param value the binding type code.
+ * @return the matching binding type instance.
+ *
+ * @throws BAD_KIND if there is no matching binding type for
+ * the passed value.
+ */
+ public static BindingType from_int(int value)
+ {
+ switch (value)
+ {
+ case _nobject :
+ return nobject;
+
+ case _ncontext :
+ return ncontext;
+
+ default :
+ throw new BAD_PARAM("Unsupported binding type code " + value);
+ }
+ }
+
+ /**
+ * Return the integer code for this binding.
+ */
+ public int value()
+ {
+ return type;
+ }
+}
diff --git a/org/omg/CosNaming/BindingTypeHelper.java b/org/omg/CosNaming/BindingTypeHelper.java
new file mode 100644
index 000000000..f2a455246
--- /dev/null
+++ b/org/omg/CosNaming/BindingTypeHelper.java
@@ -0,0 +1,122 @@
+/* BindingTypeHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * A helper operations of the {@link BindingType}
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class BindingTypeHelper
+{
+ /**
+ * The binding type repository id.
+ */
+ private static String id = "IDL:omg.org/CosNaming/BindingType:1.0";
+ private static TypeCode typeCode = null;
+
+ /**
+ * Extract the binding type from the given {@link Any}.
+ */
+ public static BindingType extract(Any any)
+ {
+ try
+ {
+ return ((BindingTypeHolder) any.extract_Streamable()).value;
+ }
+ catch (ClassCastException ex)
+ {
+ throw new BAD_OPERATION("Binding type expected");
+ }
+ }
+
+ /**
+ * Return the binding type repository id.
+ */
+ public static String id()
+ {
+ return id;
+ }
+
+ /**
+ * Insert the binding type into the given {@link Any}.
+ */
+ public static void insert(Any any, BindingType that)
+ {
+ any.insert_Streamable(new BindingTypeHolder(that));
+ }
+
+ /**
+ * Read the binding type from the CDR input stream.
+ */
+ public static BindingType read(InputStream istream)
+ {
+ return BindingType.from_int(istream.read_long());
+ }
+
+ /**
+ * Get the type code of this enumeration.
+ */
+ public static synchronized TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ typeCode =
+ ORB.init().create_enum_tc(id(), "BindingType",
+ new String[] { "nobject", "ncontext" }
+ );
+ }
+ return typeCode;
+ }
+
+ /**
+ * Write the binding type to the CDR output stream.
+ */
+ public static void write(OutputStream ostream, BindingType value)
+ {
+ ostream.write_long(value.value());
+ }
+}
diff --git a/org/omg/CosNaming/BindingTypeHolder.java b/org/omg/CosNaming/BindingTypeHolder.java
new file mode 100644
index 000000000..80931e57e
--- /dev/null
+++ b/org/omg/CosNaming/BindingTypeHolder.java
@@ -0,0 +1,93 @@
+/* BindingTypeHolder.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming;
+
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+
+/**
+ * Holds the binding type.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public final class BindingTypeHolder
+ implements Streamable
+{
+ /**
+ * The stored binding type value.
+ */
+ public BindingType value;
+
+ /**
+ * Create the unitialised holder.
+ */
+ public BindingTypeHolder()
+ {
+ }
+
+ /**
+ * Create the holder, intialised to the given value.
+ */
+ public BindingTypeHolder(BindingType initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * Read the holder value from the CDR input stream.
+ */
+ public void _read(InputStream in)
+ {
+ value = BindingTypeHelper.read(in);
+ }
+
+ public org.omg.CORBA.TypeCode _type()
+ {
+ return BindingTypeHelper.type();
+ }
+
+ /**
+ * Write the stored value to the CDR output stream.
+ */
+ public void _write(OutputStream out)
+ {
+ BindingTypeHelper.write(out, value);
+ }
+}
diff --git a/org/omg/CosNaming/NameComponent.java b/org/omg/CosNaming/NameComponent.java
new file mode 100644
index 000000000..5ec003a50
--- /dev/null
+++ b/org/omg/CosNaming/NameComponent.java
@@ -0,0 +1,113 @@
+/* NameComponent.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * The name component, a node in the multi-comonent name.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public final class NameComponent
+ implements IDLEntity
+{
+ /**
+ * The name component identifier.
+ */
+ public String id;
+
+ /**
+ * The name component kind (this conception is similar to
+ * the file type conception.
+ */
+ public String kind;
+
+ /**
+ * Create the empty name component.
+ */
+ public NameComponent()
+ {
+ }
+
+ /**
+ * Create the initialised name component.
+ */
+ public NameComponent(String _id, String _kind)
+ {
+ id = _id;
+ kind = _kind;
+ }
+
+ /**
+ * Returns true if both name and kind are equal.
+ */
+ public boolean equals(Object other)
+ {
+ if (other instanceof NameComponent)
+ {
+ NameComponent n = (NameComponent) other;
+
+ boolean ieq;
+ boolean keq;
+
+ if (id == null || n.id == null)
+ ieq = id == n.id;
+ else
+ ieq = id.equals(n.id);
+
+ if (kind == null || n.kind == null)
+ keq = kind == n.kind;
+ else
+ keq = kind.equals(n.kind);
+
+ return keq && ieq;
+ }
+ else
+ return false;
+ }
+
+ /**
+ * Get a string representation (id.kind).
+ */
+ public String toString()
+ {
+ return id + "." + kind;
+ }
+}
diff --git a/org/omg/CosNaming/NameComponentHelper.java b/org/omg/CosNaming/NameComponentHelper.java
new file mode 100644
index 000000000..71286e50f
--- /dev/null
+++ b/org/omg/CosNaming/NameComponentHelper.java
@@ -0,0 +1,140 @@
+/* NameComponentHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.StructMember;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * A helper classes for the name component.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class NameComponentHelper
+{
+ /**
+ * A {@link NameComponent} repository id.
+ */
+ private static String _id = "IDL:omg.org/CosNaming/NameComponent:1.0";
+
+ /**
+ * The cached type code.
+ */
+ private static TypeCode typeCode = null;
+
+ /**
+ * Extract the name component from this {@link Any}
+ */
+ public static NameComponent extract(Any a)
+ {
+ try
+ {
+ return ((NameComponentHolder) a.extract_Streamable()).value;
+ }
+ catch (ClassCastException ex)
+ {
+ throw new BAD_OPERATION("Name component expected");
+ }
+ }
+
+ /**
+ * Get the repository Id of the {@link NameComponent}.
+ * @return
+ */
+ public static String id()
+ {
+ return _id;
+ }
+
+ /**
+ * Insert the name compnent into the given {@link Any}.
+ */
+ public static void insert(Any a, NameComponent that)
+ {
+ a.insert_Streamable(new NameComponentHolder(that));
+ }
+
+ /**
+ * Read the name component from the given CDR input stream.
+ */
+ public static NameComponent read(InputStream istream)
+ {
+ NameComponent value = new NameComponent();
+ value.id = istream.read_string();
+ value.kind = istream.read_string();
+ return value;
+ }
+
+ /**
+ * Get the type code of the named component.
+ */
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ ORB orb = ORB.init();
+
+ StructMember[] members = new StructMember[ 2 ];
+ TypeCode member;
+ member = orb.create_string_tc(0);
+ members [ 0 ] = new StructMember("id", member, null);
+ member = orb.create_string_tc(0);
+ members [ 1 ] = new StructMember("kind", member, null);
+ typeCode =
+ orb.create_struct_tc(NameComponentHelper.id(), "NameComponent",
+ members
+ );
+ }
+ return typeCode;
+ }
+
+ /**
+ * Write the named component into the CDR output stream.
+ */
+ public static void write(OutputStream ostream, NameComponent value)
+ {
+ ostream.write_string(value.id);
+ ostream.write_string(value.kind);
+ }
+}
diff --git a/org/omg/CosNaming/NameComponentHolder.java b/org/omg/CosNaming/NameComponentHolder.java
new file mode 100644
index 000000000..4d49c4d02
--- /dev/null
+++ b/org/omg/CosNaming/NameComponentHolder.java
@@ -0,0 +1,97 @@
+/* NameComponentHolder.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming;
+
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+
+/**
+ * The name component holder.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public final class NameComponentHolder
+ implements Streamable
+{
+ /**
+ * The stored value.
+ */
+ public NameComponent value;
+
+ /**
+ * Create the unitialised holder.
+ */
+ public NameComponentHolder()
+ {
+ }
+
+ /**
+ * Create the initialised holder.
+ */
+ public NameComponentHolder(NameComponent initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * Fill in the value field by reading it from the CDR input stream.
+ */
+ public void _read(InputStream in)
+ {
+ value = NameComponentHelper.read(in);
+ }
+
+ /**
+ * Get the type code of the {@link NameComponent}.
+ */
+ public TypeCode _type()
+ {
+ return NameComponentHelper.type();
+ }
+
+ /**
+ * Write the stored value into the given CDR output stream.
+ */
+ public void _write(OutputStream out)
+ {
+ NameComponentHelper.write(out, value);
+ }
+}
diff --git a/org/omg/CosNaming/NameHelper.java b/org/omg/CosNaming/NameHelper.java
new file mode 100644
index 000000000..f0dbe9d4f
--- /dev/null
+++ b/org/omg/CosNaming/NameHelper.java
@@ -0,0 +1,135 @@
+/* NameHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * The helper operations for the name that is defined as an array
+ * of the name components. There is no java class, directly matching
+ * the 'Name' IDL type.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class NameHelper
+{
+ /**
+ * The repository id of the Name.
+ */
+ private static String _id = "IDL:omg.org/CosNaming/Name:1.0";
+
+ /**
+ * The cached typecode of the Name.
+ */
+ private static TypeCode typeCode;
+
+ /**
+ * Extract the Name the given {@link Any}.
+ */
+ public static NameComponent[] extract(Any a)
+ {
+ try
+ {
+ return ((NameHolder) a.extract_Streamable()).value;
+ }
+ catch (ClassCastException ex)
+ {
+ throw new BAD_OPERATION("Name expected");
+ }
+ }
+
+ /**
+ * Get the Name repository Id.
+ */
+ public static String id()
+ {
+ return _id;
+ }
+
+ /**
+ * Extract the Name from the given {@link Any}.
+ */
+ public static void insert(Any a, NameComponent[] that)
+ {
+ a.insert_Streamable(new NameHolder(that));
+ }
+
+ /**
+ * Read the Name from the given CDR input stream.
+ */
+ public static NameComponent[] read(InputStream istream)
+ {
+ NameComponent[] value = null;
+ int l = istream.read_long();
+ value = new NameComponent[ l ];
+ for (int i = 0; i < value.length; ++i)
+ value [ i ] = NameComponentHelper.read(istream);
+ return value;
+ }
+
+ /**
+ * Get the type code of the Name.
+ */
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ typeCode = NameComponentHelper.type();
+ typeCode = ORB.init().create_sequence_tc(0, typeCode);
+ typeCode =
+ ORB.init().create_alias_tc(NameHelper.id(), "Name", typeCode);
+ }
+ return typeCode;
+ }
+
+ /**
+ * Write the Name into the CDR output stream.
+ */
+ public static void write(OutputStream ostream, NameComponent[] value)
+ {
+ ostream.write_long(value.length);
+ for (int i = 0; i < value.length; ++i)
+ NameComponentHelper.write(ostream, value [ i ]);
+ }
+}
diff --git a/org/omg/CosNaming/NameHolder.java b/org/omg/CosNaming/NameHolder.java
new file mode 100644
index 000000000..fb067c029
--- /dev/null
+++ b/org/omg/CosNaming/NameHolder.java
@@ -0,0 +1,99 @@
+/* NameHolder.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming;
+
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+
+/**
+ * The holder for the name that is defined as an array
+ * of the name components. There is no java class, directly matching
+ * the 'Name' IDL type.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public final class NameHolder
+ implements Streamable
+{
+ /**
+ * The stored Name (array of the name components).
+ */
+ public NameComponent[] value;
+
+ /**
+ * Create the empty holder.
+ */
+ public NameHolder()
+ {
+ }
+
+ /**
+ * Create the intialised holder.
+ */
+ public NameHolder(NameComponent[] initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * Fill in the holder value by reading it from the CDR input stream.
+ */
+ public void _read(InputStream in)
+ {
+ value = NameHelper.read(in);
+ }
+
+ /**
+ * Get the Name type code.
+ */
+ public TypeCode _type()
+ {
+ return NameHelper.type();
+ }
+
+ /**
+ * Write the stored value into CDR output stream.
+ */
+ public void _write(OutputStream out)
+ {
+ NameHelper.write(out, value);
+ }
+}
diff --git a/org/omg/CosNaming/NamingContext.java b/org/omg/CosNaming/NamingContext.java
new file mode 100644
index 000000000..c921cdef1
--- /dev/null
+++ b/org/omg/CosNaming/NamingContext.java
@@ -0,0 +1,177 @@
+/* NamingContext.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming;
+
+import org.omg.CORBA.portable.IDLEntity;
+import org.omg.CosNaming.NamingContextPackage.AlreadyBound;
+import org.omg.CosNaming.NamingContextPackage.CannotProceed;
+import org.omg.CosNaming.NamingContextPackage.InvalidName;
+import org.omg.CosNaming.NamingContextPackage.NotEmpty;
+import org.omg.CosNaming.NamingContextPackage.NotFound;
+
+/**
+ * The interface for the naming context. The naming context can
+ * store (bound) and retrieve (resolve) the named objects or
+ * named child contexts. These operations are defined in a separate
+ * interface.
+ *
+ * @see NamingContextExt
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface NamingContext
+ extends org.omg.CORBA.Object, IDLEntity
+{
+ /**
+ * Gives the object a name, valid in this context.
+ *
+ * @param a_name the name, being given to the object.
+ * @param an_object the object, being named.
+ *
+ * @throws AlreadyBound if the object is already named in this context.
+ * @throws InvalidName if the name has zero length or otherwise invalid.
+ */
+ void bind(NameComponent[] a_name, org.omg.CORBA.Object an_object)
+ throws NotFound, CannotProceed, InvalidName, AlreadyBound;
+
+ /**
+ * Gives a child context name, valid in this context.
+ *
+ * @param a_name the name, being given to the child context.
+ * @param a_context the child context being named.
+ *
+ * @throws AlreadyBound if the child context is already named in
+ * the current context.
+ */
+ void bind_context(NameComponent[] a_name, NamingContext a_context)
+ throws NotFound, CannotProceed, InvalidName, AlreadyBound;
+
+ /**
+ * Create a new context and give it a given name (bound it)
+ * in the current context.
+ *
+ * @param a_name the name being given to the new context.
+ *
+ * @return the newly created context.
+ *
+ * @throws AlreadyBound if the name is already in use.
+ * @throws InvalidName if the name has zero length or otherwise invalid.
+ */
+ NamingContext bind_new_context(NameComponent[] a_name)
+ throws NotFound, AlreadyBound, CannotProceed,
+ InvalidName;
+
+ /**
+ * Destroy this context (must be empty).
+ * @throws NotEmpty if the context being destroyed is not empty.
+ */
+ void destroy()
+ throws NotEmpty;
+
+ /**
+ * Iterate over all bindings, defined in this namind context.
+ *
+ * @param amount the maximal number of context to return in the
+ * holder a_list. The remaining bindings are accessible via iterator
+ * an_iter. If the parameter amount is zero, all bindings are accessed only
+ * via this iterator.
+ *
+ * @param a_list the holder, where the returned bindigs are stored.
+ * @param an_iter the iterator that can be used to access the remaining
+ * bindings.
+ */
+ void list(int amount, BindingListHolder a_list, BindingIteratorHolder an_iter);
+
+ /**
+ * Creates a new naming context, not bound to any name.
+ */
+ NamingContext new_context();
+
+ /**
+ * Names or renames the object.
+ *
+ * @param a_name the new name, being given to the object. If
+ * the object is already named in this context, it is renamed.
+ *
+ * @param an_object the object, being named.
+ *
+ * @throws InvalidName if the name has zero length or otherwise invalid.
+ */
+ void rebind(NameComponent[] a_name, org.omg.CORBA.Object an_object)
+ throws NotFound, CannotProceed, InvalidName;
+
+ /**
+ * Names or renames the child context.
+ * If the child context is already named in
+ * the current context, it is renamed.
+ *
+ * @param a_name the name, being given to the child context.
+ * @param a_context the child context being named.
+ *
+ * @throws InvalidName if the name has zero length or otherwise invalid.
+ */
+ void rebind_context(NameComponent[] a_name, NamingContext a_context)
+ throws NotFound, CannotProceed, InvalidName;
+
+ /**
+ * Get the object, bound to the specified name in this
+ * context.
+ *
+ * @param a_name the object name.
+ *
+ * @return the object, matching this name. The client
+ * usually casts or narrows (using the helper) the returned value
+ * to the more specific type.
+ *
+ * @throws NotFound
+ * @throws InvalidName if the name has zero length or otherwise invalid.
+ */
+ org.omg.CORBA.Object resolve(NameComponent[] a_name)
+ throws NotFound, CannotProceed, InvalidName;
+
+ /**
+ * Removes the name from the binding context.
+ *
+ * @param a_name a name to remove.
+ *
+ * @throws InvalidName if the name has zero length or otherwise invalid.
+ */
+ void unbind(NameComponent[] a_name)
+ throws NotFound, CannotProceed, InvalidName;
+}
diff --git a/org/omg/CosNaming/NamingContextExt.java b/org/omg/CosNaming/NamingContextExt.java
new file mode 100644
index 000000000..77bd896c2
--- /dev/null
+++ b/org/omg/CosNaming/NamingContextExt.java
@@ -0,0 +1,55 @@
+/* NamingContextExt.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * The extended naming context interface, defined since 1.4. The context
+ * operations are defined separately from the context interface.
+ *
+ * This interface is derived from the previous NamingContex version,
+ * requiring to implement all previously available functionality.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface NamingContextExt
+ extends NamingContextExtOperations, NamingContext, IDLEntity
+{
+}
diff --git a/org/omg/CosNaming/NamingContextExtHelper.java b/org/omg/CosNaming/NamingContextExtHelper.java
new file mode 100644
index 000000000..890c6db14
--- /dev/null
+++ b/org/omg/CosNaming/NamingContextExtHelper.java
@@ -0,0 +1,152 @@
+/* NamingContextExtHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * The helper operations for the extended naming context.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class NamingContextExtHelper
+{
+ /**
+ * The naming context repository id.
+ */
+ private static String _id = "IDL:omg.org/CosNaming/NamingContextExt:1.0";
+
+ /**
+ * The cached {@link NamingContextExt} typecode.
+ */
+ private static TypeCode typeCode = null;
+
+ /**
+ * Extract the naming context from the given {@link Any}.
+ */
+ public static NamingContextExt extract(Any a)
+ {
+ try
+ {
+ return ((NamingContextExtHolder) a.extract_Streamable()).value;
+ }
+ catch (ClassCastException ex)
+ {
+ throw new BAD_OPERATION("NamingContextExt expected");
+ }
+ }
+
+ /**
+ * Get the {@link NamingContextExt} repository id.
+ */
+ public static String id()
+ {
+ return _id;
+ }
+
+ /**
+ * Insert the naming context into the given {@link Any}
+ */
+ public static void insert(Any a, NamingContextExt that)
+ {
+ a.insert_Streamable(new NamingContextExtHolder(that));
+ }
+
+ /**
+ * Cast the passed object into the NamingContextExt. If the
+ * object has a different java type, create an instance
+ * of the NamingContextExt, using the same delegate, as for
+ * the passed parameter. Hence this method may return
+ * a different object, than has been passed.
+ *
+ * @param obj the object to cast.
+ * @return casted instance.
+ */
+ public static NamingContextExt narrow(org.omg.CORBA.Object obj)
+ {
+ if (obj == null)
+ return null;
+ else if (obj instanceof NamingContextExt)
+ return (NamingContextExt) obj;
+ else if (!obj._is_a(id()))
+ throw new BAD_PARAM();
+ else
+ {
+ Delegate delegate = ((ObjectImpl) obj)._get_delegate();
+ return new _NamingContextExtStub(delegate);
+ }
+ }
+
+ /**
+ * Read the extended naming context from the given CDR input stream.
+ */
+ public static NamingContextExt read(InputStream istream)
+ {
+ return narrow(istream.read_Object(_NamingContextExtStub.class));
+ }
+
+ /**
+ * Get the type code of the {@link NamingContextExt}.
+ */
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ typeCode =
+ ORB.init().create_interface_tc(NamingContextExtHelper.id(),
+ "NamingContextExt"
+ );
+ return typeCode;
+ }
+
+ /**
+ * Write the given extended naming context into the given CDR output stream.
+ */
+ public static void write(OutputStream ostream, NamingContextExt value)
+ {
+ ostream.write_Object(value);
+ }
+}
diff --git a/org/omg/CosNaming/NamingContextExtHolder.java b/org/omg/CosNaming/NamingContextExtHolder.java
new file mode 100644
index 000000000..a2527c316
--- /dev/null
+++ b/org/omg/CosNaming/NamingContextExtHolder.java
@@ -0,0 +1,97 @@
+/* NamingContextExtHolder.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming;
+
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+
+/**
+ * A holder for the extended naming context, added since 1.4.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public final class NamingContextExtHolder
+ implements Streamable
+{
+ /**
+ * A stored value.
+ */
+ public NamingContextExt value;
+
+ /**
+ * Create the unitialised naming context holder.
+ */
+ public NamingContextExtHolder()
+ {
+ }
+
+ /**
+ * Create the naming context holder, intialised to the given value.
+ */
+ public NamingContextExtHolder(NamingContextExt initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * Read the naming context from the given CDR input stream.
+ */
+ public void _read(InputStream i)
+ {
+ value = NamingContextExtHelper.read(i);
+ }
+
+ /**
+ * Get the typecode of the naming context.
+ */
+ public TypeCode _type()
+ {
+ return NamingContextExtHelper.type();
+ }
+
+ /**
+ * Write the naming context to the given CDR output stream.
+ */
+ public void _write(OutputStream o)
+ {
+ NamingContextExtHelper.write(o, value);
+ }
+}
diff --git a/org/omg/CosNaming/NamingContextExtOperations.java b/org/omg/CosNaming/NamingContextExtOperations.java
new file mode 100644
index 000000000..6e6474ec0
--- /dev/null
+++ b/org/omg/CosNaming/NamingContextExtOperations.java
@@ -0,0 +1,97 @@
+/* NamingContextExtOperations.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming;
+
+import org.omg.CosNaming.NamingContextExtPackage.InvalidAddress;
+import org.omg.CosNaming.NamingContextPackage.CannotProceed;
+import org.omg.CosNaming.NamingContextPackage.InvalidName;
+import org.omg.CosNaming.NamingContextPackage.NotFound;
+
+/**
+ * The extended naming context operations, defined since 1.4.
+ * The extensions are focused on providing the simplier way
+ * to use naming service with the string-based names and
+ * addresses.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface NamingContextExtOperations
+ extends NamingContextOperations
+{
+ /**
+ * Resolve the name, represented in the form of the string.
+ * The components of the composite name are separated by
+ * slash ('/').
+ *
+ * @param a_name_string the name to resolve.
+ * @return the object, referenced by the name.
+ */
+ org.omg.CORBA.Object resolve_str(String a_name_string)
+ throws NotFound, CannotProceed, InvalidName;
+
+ /**
+ * Converts the name, represented in the form of the string,
+ * into the older name representation (array of the name
+ * components).
+ *
+ * @param a_name_string the stringified form of the name.
+ *
+ * @return the component array form of the name.
+ *
+ * @throws InvalidName if the name is invalid.
+ */
+ NameComponent[] to_name(String a_name_string)
+ throws InvalidName;
+
+ /**
+ * Converts the older representation for the name (array
+ * of the name components) into the string form of the name.
+ *
+ * @param a_name the name, as an array of components.
+ *
+ * @return the same name as a string.
+ *
+ * @throws InvalidName if the name is invalid.
+ */
+ String to_string(NameComponent[] a_name)
+ throws InvalidName;
+
+ String to_url(String an_address, String a_name_string)
+ throws InvalidAddress, InvalidName;
+}
diff --git a/org/omg/CosNaming/NamingContextExtPackage/AddressHelper.java b/org/omg/CosNaming/NamingContextExtPackage/AddressHelper.java
new file mode 100644
index 000000000..3aa42d1d3
--- /dev/null
+++ b/org/omg/CosNaming/NamingContextExtPackage/AddressHelper.java
@@ -0,0 +1,119 @@
+/* AddressHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming.NamingContextExtPackage;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+
+/**
+ * Helper operations for address. Address is directly mapped into
+ * java String. There is no separate Address class in the implementation.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class AddressHelper
+{
+ /**
+ * The address repository id.
+ */
+ private static String _id =
+ "IDL:omg.org/CosNaming/NamingContextExt/Address:1.0";
+
+ /**
+ * The cached type code (string alias).
+ */
+ private static TypeCode typeCode = null;
+
+ /**
+ * Just extracts string from this {@link Any}.
+ */
+ public static String extract(Any a)
+ {
+ return a.extract_string();
+ }
+
+ /**
+ * Get repository id.
+ */
+ public static String id()
+ {
+ return _id;
+ }
+
+ /**
+ * Just inserts string into this {@link Any}.
+ */
+ public static void insert(Any a, String that)
+ {
+ a.insert_string(that);
+ }
+
+ /**
+ * Delegates functionality to {@link InputStream#read_string()}.
+ */
+ public static String read(InputStream istream)
+ {
+ return istream.read_string();
+ }
+
+ /**
+ * Return the "Address", alias of String, typecode.
+ */
+ public static synchronized TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ typeCode = ORB.init().create_string_tc(0);
+ typeCode = ORB.init().create_alias_tc(id(), "Address", typeCode);
+ }
+ return typeCode;
+ }
+
+ /**
+ * Delegates functionality to {@link OutputStream#write_string}.
+ */
+ public static void write(OutputStream ostream, String value)
+ {
+ ostream.write_string(value);
+ }
+}
diff --git a/org/omg/CosNaming/NamingContextExtPackage/InvalidAddress.java b/org/omg/CosNaming/NamingContextExtPackage/InvalidAddress.java
new file mode 100644
index 000000000..0431daf65
--- /dev/null
+++ b/org/omg/CosNaming/NamingContextExtPackage/InvalidAddress.java
@@ -0,0 +1,53 @@
+/* InvalidAddress.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming.NamingContextExtPackage;
+
+import org.omg.CORBA.UserException;
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * The exception is thrown if the passed address is empty or otherwise invalid.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public final class InvalidAddress
+ extends UserException
+ implements IDLEntity
+{
+}
diff --git a/org/omg/CosNaming/NamingContextExtPackage/InvalidAddressHelper.java b/org/omg/CosNaming/NamingContextExtPackage/InvalidAddressHelper.java
new file mode 100644
index 000000000..25f8e2cac
--- /dev/null
+++ b/org/omg/CosNaming/NamingContextExtPackage/InvalidAddressHelper.java
@@ -0,0 +1,122 @@
+/* InvalidAddressHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming.NamingContextExtPackage;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.StructMember;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+* The holder for exception {@link InvalidAddress}.
+*
+* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+*/
+public abstract class InvalidAddressHelper
+{
+ /**
+ * The {@link InvalidAddress} repository id.
+ */
+ private static String _id =
+ "IDL:omg.org/CosNaming/NamingContextExt/InvalidAddress:1.0";
+
+ /**
+ * The cached type code value.
+ */
+ private static TypeCode typeCode;
+
+ /**
+ * Extract the exception from the given {@link Any}.
+ */
+ public static InvalidAddress extract(Any a)
+ {
+ return read(a.create_input_stream());
+ }
+
+ /**
+ * Return the exception repository id.
+ */
+ public static String id()
+ {
+ return _id;
+ }
+
+ /**
+ * Insert the exception into the given {@link Any}.
+ */
+ public static void insert(Any a, InvalidAddress that)
+ {
+ a.insert_Streamable(new InvalidAddressHolder(that));
+ }
+
+ /**
+ * Read the exception from the given CDR stream.
+ */
+ public static InvalidAddress read(InputStream istream)
+ {
+ InvalidAddress value = new InvalidAddress();
+
+ // Read and discard the repository ID.
+ istream.read_string();
+ return value;
+ }
+
+ /**
+ * Create the type code for this exception.
+ */
+ public static synchronized TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ typeCode =
+ ORB.init().create_struct_tc(InvalidAddressHelper.id(),
+ "InvalidAddress", new StructMember[ 0 ]
+ );
+ }
+ return typeCode;
+ }
+
+ public static void write(OutputStream ostream, InvalidAddress value)
+ {
+ // Write the repository ID.
+ ostream.write_string(id());
+ }
+}
diff --git a/org/omg/CosNaming/NamingContextExtPackage/InvalidAddressHolder.java b/org/omg/CosNaming/NamingContextExtPackage/InvalidAddressHolder.java
new file mode 100644
index 000000000..08bfbb388
--- /dev/null
+++ b/org/omg/CosNaming/NamingContextExtPackage/InvalidAddressHolder.java
@@ -0,0 +1,97 @@
+/* InvalidAddressHolder.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming.NamingContextExtPackage;
+
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+
+/**
+ * The holder for the exception {@link InvalidAddress}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public final class InvalidAddressHolder
+ implements Streamable
+{
+ /**
+ * The stored value.
+ */
+ public InvalidAddress value;
+
+ /**
+ * Create the holder with unitialised value.
+ */
+ public InvalidAddressHolder()
+ {
+ }
+
+ /**
+ * Create the holder, storing the given value.
+ */
+ public InvalidAddressHolder(InvalidAddress initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * Fill in the stored value, reading it from the given CDR stream.
+ */
+ public void _read(InputStream in)
+ {
+ value = InvalidAddressHelper.read(in);
+ }
+
+ /**
+ * Get the type code of the {@link NotEmpty} exception.
+ */
+ public TypeCode _type()
+ {
+ return InvalidAddressHelper.type();
+ }
+
+ /**
+ * Write the stored value to the given CDR stream.
+ */
+ public void _write(OutputStream out)
+ {
+ InvalidAddressHelper.write(out, value);
+ }
+}
diff --git a/org/omg/CosNaming/NamingContextExtPackage/StringNameHelper.java b/org/omg/CosNaming/NamingContextExtPackage/StringNameHelper.java
new file mode 100644
index 000000000..12903d963
--- /dev/null
+++ b/org/omg/CosNaming/NamingContextExtPackage/StringNameHelper.java
@@ -0,0 +1,120 @@
+/* StringNameHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming.NamingContextExtPackage;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+
+/**
+ * Helper operations for the string name.
+ * The string name is directly mapped into java String.
+ * There is no separate "String name" class in the implementation.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class StringNameHelper
+{
+ /**
+ * The string name repository id.
+ */
+ private static String _id =
+ "IDL:omg.org/CosNaming/NamingContextExt/StringName:1.0";
+
+ /**
+ * The cached type code (string alias).
+ */
+ private static TypeCode typeCode;
+
+ /**
+ * Just extracts string from this {@link Any}.
+ */
+ public static String extract(Any a)
+ {
+ return a.extract_string();
+ }
+
+ /**
+ * Get repository id.
+ */
+ public static String id()
+ {
+ return _id;
+ }
+
+ /**
+ * Just inserts string into this {@link Any}.
+ */
+ public static void insert(Any a, String that)
+ {
+ a.insert_string(that);
+ }
+
+ /**
+ * Delegates functionality to {@link InputStream#read_string()}.
+ */
+ public static String read(InputStream istream)
+ {
+ return istream.read_string();
+ }
+
+ /**
+ * Return the "StringName", alias of String, typecode.
+ */
+ public static synchronized TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ typeCode = ORB.init().create_string_tc(0);
+ typeCode = ORB.init().create_alias_tc(id(), "StringName", typeCode);
+ }
+ return typeCode;
+ }
+
+ /**
+ * Delegates functionality to {@link OutputStream#write_string}.
+ */
+ public static void write(OutputStream ostream, String value)
+ {
+ ostream.write_string(value);
+ }
+}
diff --git a/org/omg/CosNaming/NamingContextExtPackage/URLStringHelper.java b/org/omg/CosNaming/NamingContextExtPackage/URLStringHelper.java
new file mode 100644
index 000000000..2c67a3894
--- /dev/null
+++ b/org/omg/CosNaming/NamingContextExtPackage/URLStringHelper.java
@@ -0,0 +1,119 @@
+/* URLStringHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming.NamingContextExtPackage;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * Helper operations for the URL string name.
+ * The URL string is directly mapped into java String.
+ * There is no separate "URL string" class in the implementation.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class URLStringHelper
+{
+ /**
+ * The URL string repository id.
+ */
+ private static String _id =
+ "IDL:omg.org/CosNaming/NamingContextExt/URLString:1.0";
+
+ /**
+ * The cached type code (string alias).
+ */
+ private static TypeCode typeCode;
+
+ /**
+ * Just extracts string from this {@link Any}.
+ */
+ public static String extract(Any a)
+ {
+ return a.extract_string();
+ }
+
+ /**
+ * Get repository id.
+ */
+ public static String id()
+ {
+ return _id;
+ }
+
+ /**
+ * Just inserts string into this {@link Any}.
+ */
+ public static void insert(Any a, String that)
+ {
+ a.insert_string(that);
+ }
+
+ /**
+ * Delegates functionality to {@link InputStream#read_string()}.
+ */
+ public static String read(InputStream istream)
+ {
+ return istream.read_string();
+ }
+
+ /**
+ * Return the "URLString", alias of String, typecode.
+ */
+ public static synchronized TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ typeCode = ORB.init().create_string_tc(0);
+ typeCode = ORB.init().create_alias_tc(id(), "URLString", typeCode);
+ }
+ return typeCode;
+ }
+
+ /**
+ * Delegates functionality to {@link OutputStream#write_string}.
+ */
+ public static void write(OutputStream ostream, String value)
+ {
+ ostream.write_string(value);
+ }
+}
diff --git a/org/omg/CosNaming/NamingContextExtPackage/package.html b/org/omg/CosNaming/NamingContextExtPackage/package.html
new file mode 100644
index 000000000..fb8aea5f5
--- /dev/null
+++ b/org/omg/CosNaming/NamingContextExtPackage/package.html
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in org.omg.CosNaming.NamingContextExtPackage
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - org.omg.CosNaming.NamingContextExtPackage</title></head>
+
+<body>
+<p>Provides several satelitte classes, needed by the naming service
+extensions, added from the version 1.4</p>
+
+</body>
+</html>
diff --git a/org/omg/CosNaming/NamingContextHelper.java b/org/omg/CosNaming/NamingContextHelper.java
new file mode 100644
index 000000000..140c63657
--- /dev/null
+++ b/org/omg/CosNaming/NamingContextHelper.java
@@ -0,0 +1,157 @@
+/* NamingContextHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * The helper operations for the naming context.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class NamingContextHelper
+{
+ /**
+ * The naming context repository id.
+ */
+ private static String _id = "IDL:omg.org/CosNaming/NamingContext:1.0";
+
+ /**
+ * The cached {@link NamingContext} typecode.
+ */
+ private static TypeCode typeCode;
+
+ /**
+ * Extract the naming context from the given {@link Any}.
+ */
+ public static NamingContext extract(Any a)
+ {
+ try
+ {
+ return ((NamingContextHolder) a.extract_Streamable()).value;
+ }
+ catch (ClassCastException ex)
+ {
+ throw new BAD_OPERATION("Naming context expected");
+ }
+ }
+
+ /**
+ * Get the {@link NamingContext} repository id.
+ */
+ public static String id()
+ {
+ return _id;
+ }
+
+ /**
+ * Insert the naming context into the given {@link Any}
+ */
+ public static void insert(Any a, NamingContext that)
+ {
+ a.insert_Streamable(new NamingContextHolder(that));
+ }
+
+ /**
+ * Cast the passed object into the NamingContext. If the
+ * object has a different java type, create an instance
+ * of the NamingContext, using the same delegate, as for
+ * the passed parameter.
+ *
+ * If the object repository Id indicates that it is an instance of
+ * {@link NamingContextExt} that is a subclass of the NamingContext,
+ * the functionality is delegated to {@link NamingContextHelper#narrow}.
+ *
+ * @param obj the object to cast.
+ * @return casted instance.
+ *
+ * @throws BAD_PARAM if the passed object is not an instance of
+ * {@link NamingContext} or {@link NamingContextExt}.
+ */
+ public static NamingContext narrow(org.omg.CORBA.Object obj)
+ {
+ if (obj == null)
+ return null;
+ else if (obj instanceof NamingContext)
+ return (NamingContext) obj;
+ else if (obj._is_a(id()))
+ {
+ Delegate delegate = ((ObjectImpl) obj)._get_delegate();
+ return new _NamingContextStub(delegate);
+ }
+ else if (obj._is_a(NamingContextExtHelper.id()))
+ return NamingContextExtHelper.narrow(obj);
+ else
+ throw new BAD_PARAM();
+ }
+
+ /**
+ * Read the naming context from the given CDR input stream.
+ */
+ public static NamingContext read(InputStream istream)
+ {
+ return narrow(istream.read_Object(_NamingContextStub.class));
+ }
+
+ /**
+ * Get the type code of the {@link NamingContext}.
+ */
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ typeCode = ORB.init().create_interface_tc(id(), "NamingContext");
+ return typeCode;
+ }
+
+ /**
+ * Write the given naming context into the given CDR output stream.
+ */
+ public static void write(OutputStream ostream, NamingContext value)
+ {
+ ostream.write_Object(value);
+ }
+}
diff --git a/org/omg/CosNaming/NamingContextHolder.java b/org/omg/CosNaming/NamingContextHolder.java
new file mode 100644
index 000000000..a212baa37
--- /dev/null
+++ b/org/omg/CosNaming/NamingContextHolder.java
@@ -0,0 +1,97 @@
+/* NamingContextHolder.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming;
+
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+
+/**
+ * A holder for the naming context.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public final class NamingContextHolder
+ implements Streamable
+{
+ /**
+ * A stored value.
+ */
+ public NamingContext value;
+
+ /**
+ * Create the unitialised naming context holder.
+ */
+ public NamingContextHolder()
+ {
+ }
+
+ /**
+ * Create the naming context holder, intialised to the given value.
+ */
+ public NamingContextHolder(NamingContext initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * Read the naming context from the given CDR input stream.
+ */
+ public void _read(InputStream in)
+ {
+ value = NamingContextHelper.read(in);
+ }
+
+ /**
+ * Get the typecode of the naming context.
+ */
+ public TypeCode _type()
+ {
+ return NamingContextHelper.type();
+ }
+
+ /**
+ * Write the naming context to the given CDR output stream.
+ */
+ public void _write(OutputStream out)
+ {
+ NamingContextHelper.write(out, value);
+ }
+}
diff --git a/org/omg/CosNaming/NamingContextOperations.java b/org/omg/CosNaming/NamingContextOperations.java
new file mode 100644
index 000000000..d58f153b1
--- /dev/null
+++ b/org/omg/CosNaming/NamingContextOperations.java
@@ -0,0 +1,176 @@
+/* NamingContext.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming;
+
+import org.omg.CORBA.portable.IDLEntity;
+import org.omg.CosNaming.NamingContextPackage.AlreadyBound;
+import org.omg.CosNaming.NamingContextPackage.CannotProceed;
+import org.omg.CosNaming.NamingContextPackage.InvalidName;
+import org.omg.CosNaming.NamingContextPackage.NotEmpty;
+import org.omg.CosNaming.NamingContextPackage.NotFound;
+
+/**
+ * The naming context operations. The naming context can
+ * store (bound) and retrieve (resolve) the named objects or
+ * named child contexts.
+ *
+ * @see NamingContextExtOperations
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface NamingContextOperations
+ extends org.omg.CORBA.Object, IDLEntity
+{
+ /**
+ * Gives the object a name, valid in this context.
+ *
+ * @param a_name the name, being given to the object.
+ * @param an_object the object, being named.
+ *
+ * @throws AlreadyBound if the object is already named in this context.
+ * @throws InvalidName if the name has zero length or otherwise invalid.
+ */
+ void bind(NameComponent[] a_name, org.omg.CORBA.Object an_object)
+ throws NotFound, CannotProceed, InvalidName, AlreadyBound;
+
+ /**
+ * Gives a child context name, valid in this context.
+ *
+ * @param a_name the name, being given to the child context.
+ * @param a_context the child context being named.
+ *
+ * @throws AlreadyBound if the child context is already named in
+ * the current context.
+ */
+ void bind_context(NameComponent[] a_name, NamingContext a_context)
+ throws NotFound, CannotProceed, InvalidName, AlreadyBound;
+
+ /**
+ * Create a new context and give it a given name (bound it)
+ * in the current context.
+ *
+ * @param a_name the name being given to the new context.
+ *
+ * @return the newly created context.
+ *
+ * @throws AlreadyBound if the name is already in use.
+ * @throws InvalidName if the name has zero length or otherwise invalid.
+ */
+ NamingContext bind_new_context(NameComponent[] a_name)
+ throws NotFound, AlreadyBound, CannotProceed,
+ InvalidName;
+
+ /**
+ * Destroy this context (must be empty).
+ * @throws NotEmpty if the context being destroyed is not empty.
+ */
+ void destroy()
+ throws NotEmpty;
+
+ /**
+ * Iterate over all bindings, defined in this namind context.
+ *
+ * @param amount the maximal number of context to return in the
+ * holder a_list. The remaining bindings are accessible via iterator
+ * an_iter. If the parameter amount is zero, all bindings are accessed only
+ * via this iterator.
+ *
+ * @param a_list the holder, where the returned bindigs are stored.
+ * @param an_iter the iterator that can be used to access the remaining
+ * bindings.
+ */
+ void list(int amount, BindingListHolder a_list, BindingIteratorHolder an_iter);
+
+ /**
+ * Creates a new naming context, not bound to any name.
+ */
+ NamingContext new_context();
+
+ /**
+ * Names or renames the object.
+ *
+ * @param a_name the new name, being given to the object. If
+ * the object is already named in this context, it is renamed.
+ *
+ * @param an_object the object, being named.
+ *
+ * @throws InvalidName if the name has zero length or otherwise invalid.
+ */
+ void rebind(NameComponent[] a_name, org.omg.CORBA.Object an_object)
+ throws NotFound, CannotProceed, InvalidName;
+
+ /**
+ * Names or renames the child context.
+ * If the child context is already named in
+ * the current context, it is renamed.
+ *
+ * @param a_name the name, being given to the child context.
+ * @param a_context the child context being named.
+ *
+ * @throws InvalidName if the name has zero length or otherwise invalid.
+ */
+ void rebind_context(NameComponent[] a_name, NamingContext a_context)
+ throws NotFound, CannotProceed, InvalidName;
+
+ /**
+ * Get the object, bound to the specified name in this
+ * context.
+ *
+ * @param a_name the object name.
+ *
+ * @return the object, matching this name. The client
+ * usually casts or narrows (using the helper) the returned value
+ * to the more specific type.
+ *
+ * @throws NotFound
+ * @throws InvalidName if the name has zero length or otherwise invalid.
+ */
+ org.omg.CORBA.Object resolve(NameComponent[] a_name)
+ throws NotFound, CannotProceed, InvalidName;
+
+ /**
+ * Removes the name from the binding context.
+ *
+ * @param a_name a name to remove.
+ *
+ * @throws InvalidName if the name has zero length or otherwise invalid.
+ */
+ void unbind(NameComponent[] a_name)
+ throws NotFound, CannotProceed, InvalidName;
+}
diff --git a/org/omg/CosNaming/NamingContextPackage/AlreadyBound.java b/org/omg/CosNaming/NamingContextPackage/AlreadyBound.java
new file mode 100644
index 000000000..cf0792162
--- /dev/null
+++ b/org/omg/CosNaming/NamingContextPackage/AlreadyBound.java
@@ -0,0 +1,70 @@
+/* AlreadyBound.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming.NamingContextPackage;
+
+import org.omg.CORBA.UserException;
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * The exception is thrown in response to bind the same object
+ * into the same context repeatedly under the different name.
+ * The object can have only one name in the context.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public final class AlreadyBound
+ extends UserException
+ implements IDLEntity
+{
+ /**
+ * Creates the expection with no details.
+ */
+ public AlreadyBound()
+ {
+ }
+
+ /**
+ * Creates the exception, explaining the reason.
+ * @param why
+ */
+ public AlreadyBound(String why)
+ {
+ super(why);
+ }
+}
diff --git a/org/omg/CosNaming/NamingContextPackage/AlreadyBoundHelper.java b/org/omg/CosNaming/NamingContextPackage/AlreadyBoundHelper.java
new file mode 100644
index 000000000..d4e99f996
--- /dev/null
+++ b/org/omg/CosNaming/NamingContextPackage/AlreadyBoundHelper.java
@@ -0,0 +1,128 @@
+/* AlreadyBoundHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming.NamingContextPackage;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.StructMember;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * The helper operations for the {@link AlreadyBound} user exception.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class AlreadyBoundHelper
+{
+ /**
+ * The {@link AlreadyBound} repository id.
+ */
+ private static String _id =
+ "IDL:omg.org/CosNaming/NamingContext/AlreadyBound:1.0";
+
+ /**
+ * The cached type code value.
+ */
+ private static TypeCode typeCode;
+
+ /**
+ * Extract the exception from the given {@link Any}.
+ */
+ public static AlreadyBound extract(Any a)
+ {
+ try
+ {
+ return ((AlreadyBoundHolder) a.extract_Streamable()).value;
+ }
+ catch (ClassCastException ex)
+ {
+ throw new BAD_OPERATION();
+ }
+ }
+
+ /**
+ * Return the exception repository id.
+ */
+ public static String id()
+ {
+ return _id;
+ }
+
+ /**
+ * Insert the exception into the given {@link Any}.
+ */
+ public static void insert(Any a, AlreadyBound that)
+ {
+ a.insert_Streamable(new AlreadyBoundHolder(that));
+ }
+
+ /**
+ * Read the exception from the given CDR stream.
+ */
+ public static AlreadyBound read(InputStream istream)
+ {
+ AlreadyBound value = new AlreadyBound();
+
+ // Read and discard the repository ID.
+ istream.read_string();
+ return value;
+ }
+
+ /**
+ * Create the type code for this exception.
+ */
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ typeCode =
+ ORB.init().create_struct_tc(id(), "AlreadyBound", new StructMember[ 0 ]);
+ return typeCode;
+ }
+
+ /**
+ * Write the exception to the CDR output stream.
+ */
+ public static void write(OutputStream ostream, AlreadyBound value)
+ {
+ ostream.write_string(id());
+ }
+}
diff --git a/org/omg/CosNaming/NamingContextPackage/AlreadyBoundHolder.java b/org/omg/CosNaming/NamingContextPackage/AlreadyBoundHolder.java
new file mode 100644
index 000000000..f46e8a1fd
--- /dev/null
+++ b/org/omg/CosNaming/NamingContextPackage/AlreadyBoundHolder.java
@@ -0,0 +1,97 @@
+/* AlreadyBoundHolder.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming.NamingContextPackage;
+
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+
+/**
+ * The holder for class {@link AlreadyBound} exception.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public final class AlreadyBoundHolder
+ implements Streamable
+{
+ /**
+ * The stored value.
+ */
+ public AlreadyBound value;
+
+ /**
+ * Create the holder with unitialised value.
+ */
+ public AlreadyBoundHolder()
+ {
+ }
+
+ /**
+ * Create the holder, storing the given value.
+ */
+ public AlreadyBoundHolder(AlreadyBound initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * Fill in the stored value, reading it from the given CDR stream.
+ */
+ public void _read(InputStream in)
+ {
+ value = AlreadyBoundHelper.read(in);
+ }
+
+ /**
+ * Get the type code of the {@link NotEmpty} exception.
+ */
+ public TypeCode _type()
+ {
+ return AlreadyBoundHelper.type();
+ }
+
+ /**
+ * Write the stored value to the given CDR stream.
+ */
+ public void _write(OutputStream out)
+ {
+ AlreadyBoundHelper.write(out, value);
+ }
+}
diff --git a/org/omg/CosNaming/NamingContextPackage/CannotProceed.java b/org/omg/CosNaming/NamingContextPackage/CannotProceed.java
new file mode 100644
index 000000000..8b53cc3a6
--- /dev/null
+++ b/org/omg/CosNaming/NamingContextPackage/CannotProceed.java
@@ -0,0 +1,82 @@
+/* CannotProceed.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming.NamingContextPackage;
+
+import org.omg.CORBA.UserException;
+import org.omg.CORBA.portable.IDLEntity;
+import org.omg.CosNaming.NameComponent;
+import org.omg.CosNaming.NamingContext;
+
+/**
+ * The exception is raised when the naming service has
+ * given up for some reason.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public final class CannotProceed
+ extends UserException
+ implements IDLEntity
+{
+ /**
+ * The relevant naming contex.
+ */
+ public NamingContext cxt;
+
+ /**
+ * Contains the remainder of the non working name.
+ */
+ public NameComponent[] rest_of_name;
+
+ /**
+ * Creates the unitialised exception.
+ */
+ public CannotProceed()
+ {
+ }
+
+ /**
+ * Creates an exception with the fields, intialised to the
+ * given values.
+ */
+ public CannotProceed(NamingContext _cxt, NameComponent[] _rest_of_name)
+ {
+ cxt = _cxt;
+ rest_of_name = _rest_of_name;
+ }
+}
diff --git a/org/omg/CosNaming/NamingContextPackage/CannotProceedHelper.java b/org/omg/CosNaming/NamingContextPackage/CannotProceedHelper.java
new file mode 100644
index 000000000..5297628e9
--- /dev/null
+++ b/org/omg/CosNaming/NamingContextPackage/CannotProceedHelper.java
@@ -0,0 +1,147 @@
+/* CannotProceedHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming.NamingContextPackage;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.StructMember;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CosNaming.NameComponentHelper;
+import org.omg.CosNaming.NameHelper;
+import org.omg.CosNaming.NamingContextHelper;
+
+/**
+ * The helper operations for {@link CannotProceed}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class CannotProceedHelper
+{
+ /**
+ * The {@link CannotProceed} repository id.
+ */
+ private static String _id =
+ "IDL:omg.org/CosNaming/NamingContext/CannotProceed:1.0";
+
+ /**
+ * The cached type code value.
+ */
+ private static TypeCode typeCode;
+
+ /**
+ * Extract the exception from the given {@link Any}.
+ */
+ public static CannotProceed extract(Any a)
+ {
+ try
+ {
+ return ((CannotProceedHolder) a.extract_Streamable()).value;
+ }
+ catch (ClassCastException ex)
+ {
+ throw new BAD_OPERATION();
+ }
+ }
+
+ /**
+ * Return the exception repository id.
+ */
+ public static String id()
+ {
+ return _id;
+ }
+
+ /**
+ * Insert the exception into the given {@link Any}.
+ */
+ public static void insert(Any a, CannotProceed that)
+ {
+ a.insert_Streamable(new CannotProceedHolder(that));
+ }
+
+ /**
+ * Read the exception from the given CDR stream.
+ */
+ public static CannotProceed read(InputStream istream)
+ {
+ CannotProceed value = new CannotProceed();
+
+ // read and discard the repository ID
+ istream.read_string();
+ value.cxt = NamingContextHelper.read(istream);
+ value.rest_of_name = NameHelper.read(istream);
+ return value;
+ }
+
+ /**
+ * Create the type code for this exception.
+ */
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ ORB orb = ORB.init();
+
+ StructMember[] members = new StructMember[ 2 ];
+ TypeCode member;
+ member = NamingContextHelper.type();
+ members [ 0 ] = new StructMember("cxt", member, null);
+ member = NameComponentHelper.type();
+ member = orb.create_sequence_tc(0, member);
+ member = orb.create_alias_tc(NameHelper.id(), "Name", member);
+ members [ 1 ] = new StructMember("rest_of_name", member, null);
+ typeCode = orb.create_struct_tc(id(), "CannotProceed", members);
+ }
+ return typeCode;
+ }
+
+ /**
+ * Write the exception to the CDR output stream.
+ */
+ public static void write(OutputStream ostream, CannotProceed value)
+ {
+ // write the repository ID
+ ostream.write_string(id());
+ NamingContextHelper.write(ostream, value.cxt);
+ NameHelper.write(ostream, value.rest_of_name);
+ }
+}
diff --git a/org/omg/CosNaming/NamingContextPackage/CannotProceedHolder.java b/org/omg/CosNaming/NamingContextPackage/CannotProceedHolder.java
new file mode 100644
index 000000000..bb5615a0e
--- /dev/null
+++ b/org/omg/CosNaming/NamingContextPackage/CannotProceedHolder.java
@@ -0,0 +1,97 @@
+/* CannotProceedHolder.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming.NamingContextPackage;
+
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+
+/**
+ * The holder for exception {@link CannotProceed}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public final class CannotProceedHolder
+ implements Streamable
+{
+ /**
+ * The stored value.
+ */
+ public CannotProceed value;
+
+ /**
+ * Create the holder with unitialised value.
+ */
+ public CannotProceedHolder()
+ {
+ }
+
+ /**
+ * Create the holder, storing the given value.
+ */
+ public CannotProceedHolder(CannotProceed initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * Fill in the stored value, reading it from the given CDR stream.
+ */
+ public void _read(InputStream i)
+ {
+ value = CannotProceedHelper.read(i);
+ }
+
+ /**
+ * Get the type code of the {@link NotEmpty} exception.
+ */
+ public TypeCode _type()
+ {
+ return CannotProceedHelper.type();
+ }
+
+ /**
+ * Write the stored value to the given CDR stream.
+ */
+ public void _write(OutputStream o)
+ {
+ CannotProceedHelper.write(o, value);
+ }
+}
diff --git a/org/omg/CosNaming/NamingContextPackage/InvalidName.java b/org/omg/CosNaming/NamingContextPackage/InvalidName.java
new file mode 100644
index 000000000..3e953b005
--- /dev/null
+++ b/org/omg/CosNaming/NamingContextPackage/InvalidName.java
@@ -0,0 +1,71 @@
+/* InvalidName.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming.NamingContextPackage;
+
+import org.omg.CORBA.UserException;
+import org.omg.CORBA.portable.IDLEntity;
+import org.omg.CosNaming.NameComponent;
+
+/**
+ * The exception is thrown if the name has the zero length or is otherwise
+ * invalid.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public final class InvalidName
+ extends UserException
+ implements IDLEntity
+{
+ /**
+ * The default constructor.
+ */
+ public InvalidName()
+ {
+ }
+
+ /**
+ * Creates an exception with explanation, why the name is invalid.
+ *
+ * @param why the string, explaining why the name is invalid.
+ */
+ public InvalidName(String why)
+ {
+ super(why);
+ }
+}
diff --git a/org/omg/CosNaming/NamingContextPackage/InvalidNameHelper.java b/org/omg/CosNaming/NamingContextPackage/InvalidNameHelper.java
new file mode 100644
index 000000000..fd3d094f9
--- /dev/null
+++ b/org/omg/CosNaming/NamingContextPackage/InvalidNameHelper.java
@@ -0,0 +1,133 @@
+/* InvalidNameHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming.NamingContextPackage;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.StructMember;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * The helper operations for the {@link InvalidName}
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class InvalidNameHelper
+{
+ /**
+ * The {@link InvalidName} repository id.
+ */
+ private static String _id =
+ "IDL:omg.org/CosNaming/NamingContext/InvalidName:1.0";
+
+ /**
+ * The cached type code value.
+ */
+ private static TypeCode typeCode;
+
+ /**
+ * Extract the exception from the given {@link Any}.
+ */
+ public static InvalidName extract(Any a)
+ {
+ try
+ {
+ return ((InvalidNameHolder) a.extract_Streamable()).value;
+ }
+ catch (ClassCastException ex)
+ {
+ throw new BAD_OPERATION();
+ }
+ }
+
+ /**
+ * Return the exception repository id.
+ */
+ public static String id()
+ {
+ return _id;
+ }
+
+ /**
+ * Insert the exception into the given {@link Any}.
+ */
+ public static void insert(Any a, InvalidName that)
+ {
+ a.insert_Streamable(new InvalidNameHolder(that));
+ }
+
+ /**
+ * Read the exception from the given CDR stream.
+ */
+ public static InvalidName read(InputStream istream)
+ {
+ InvalidName value = new InvalidName();
+
+ // Read and discard the repository ID.
+ istream.read_string();
+ return value;
+ }
+
+ /**
+ * Create the type code for this exception.
+ */
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ if (typeCode == null)
+ typeCode =
+ ORB.init().create_struct_tc(id(), "InvalidName",
+ new StructMember[ 0 ]
+ );
+ }
+ return typeCode;
+ }
+
+ /**
+ * Write the exception to the CDR output stream.
+ */
+ public static void write(OutputStream ostream, InvalidName value)
+ {
+ ostream.write_string(id());
+ }
+}
diff --git a/org/omg/CosNaming/NamingContextPackage/InvalidNameHolder.java b/org/omg/CosNaming/NamingContextPackage/InvalidNameHolder.java
new file mode 100644
index 000000000..8ae721b75
--- /dev/null
+++ b/org/omg/CosNaming/NamingContextPackage/InvalidNameHolder.java
@@ -0,0 +1,97 @@
+/* InvalidNameHolder.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming.NamingContextPackage;
+
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+
+/**
+ * The holder for exception {@link InvalidName}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public final class InvalidNameHolder
+ implements Streamable
+{
+ /**
+ * The stored value.
+ */
+ public InvalidName value;
+
+ /**
+ * Create the holder with unitialised value.
+ */
+ public InvalidNameHolder()
+ {
+ }
+
+ /**
+ * Create the holder, storing the given value.
+ */
+ public InvalidNameHolder(InvalidName initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * Fill in the stored value, reading it from the given CDR stream.
+ */
+ public void _read(InputStream in)
+ {
+ value = InvalidNameHelper.read(in);
+ }
+
+ /**
+ * Get the type code of the {@link NotEmpty} exception.
+ */
+ public TypeCode _type()
+ {
+ return InvalidNameHelper.type();
+ }
+
+ /**
+ * Write the stored value to the given CDR stream.
+ */
+ public void _write(OutputStream out)
+ {
+ InvalidNameHelper.write(out, value);
+ }
+}
diff --git a/org/omg/CosNaming/NamingContextPackage/NotEmpty.java b/org/omg/CosNaming/NamingContextPackage/NotEmpty.java
new file mode 100644
index 000000000..5915f89ac
--- /dev/null
+++ b/org/omg/CosNaming/NamingContextPackage/NotEmpty.java
@@ -0,0 +1,53 @@
+/* NotEmpty.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming.NamingContextPackage;
+
+import org.omg.CORBA.UserException;
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * This exception is thrown in response to the attemt to destroy
+ * the non tempty context. Only the empty context can be destroyed.
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public final class NotEmpty
+ extends UserException
+ implements IDLEntity
+{
+}
diff --git a/org/omg/CosNaming/NamingContextPackage/NotEmptyHelper.java b/org/omg/CosNaming/NamingContextPackage/NotEmptyHelper.java
new file mode 100644
index 000000000..fa0e165b3
--- /dev/null
+++ b/org/omg/CosNaming/NamingContextPackage/NotEmptyHelper.java
@@ -0,0 +1,128 @@
+/* NotEmptyHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming.NamingContextPackage;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.StructMember;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * The helper operations for the {@link NotEmpty}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class NotEmptyHelper
+{
+ /**
+ * The {@link NotEmpty} repository id.
+ */
+ private static String _id =
+ "IDL:omg.org/CosNaming/NamingContext/NotEmpty:1.0";
+
+ /**
+ * The cached type code value.
+ */
+ private static TypeCode typeCode;
+
+ /**
+ * Extract the exception from the given {@link Any}.
+ */
+ public static NotEmpty extract(Any a)
+ {
+ try
+ {
+ return ((NotEmptyHolder) a.extract_Streamable()).value;
+ }
+ catch (ClassCastException ex)
+ {
+ throw new BAD_OPERATION();
+ }
+ }
+
+ /**
+ * Return the exception repository id.
+ */
+ public static String id()
+ {
+ return _id;
+ }
+
+ /**
+ * Insert the exception into the given {@link Any}.
+ */
+ public static void insert(Any a, NotEmpty that)
+ {
+ a.insert_Streamable(new NotEmptyHolder(that));
+ }
+
+ /**
+ * Read the exception from the given CDR stream.
+ */
+ public static NotEmpty read(InputStream istream)
+ {
+ NotEmpty value = new NotEmpty();
+
+ // Read and discard the repository ID.
+ istream.read_string();
+ return value;
+ }
+
+ /**
+ * Create the type code for this exception.
+ */
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ typeCode =
+ ORB.init().create_struct_tc(id(), "NotEmpty", new StructMember[ 0 ]);
+ return typeCode;
+ }
+
+ /**
+ * Write the exception to the CDR output stream.
+ */
+ public static void write(OutputStream ostream, NotEmpty value)
+ {
+ ostream.write_string(id());
+ }
+}
diff --git a/org/omg/CosNaming/NamingContextPackage/NotEmptyHolder.java b/org/omg/CosNaming/NamingContextPackage/NotEmptyHolder.java
new file mode 100644
index 000000000..bace2c29c
--- /dev/null
+++ b/org/omg/CosNaming/NamingContextPackage/NotEmptyHolder.java
@@ -0,0 +1,97 @@
+/* NotEmptyHolder.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming.NamingContextPackage;
+
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+
+/**
+ * The holder for exception {@link NotEmpty}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public final class NotEmptyHolder
+ implements Streamable
+{
+ /**
+ * The stored value.
+ */
+ public NotEmpty value;
+
+ /**
+ * Create the holder with unitialised value.
+ */
+ public NotEmptyHolder()
+ {
+ }
+
+ /**
+ * Create the holder, storing the given value.
+ */
+ public NotEmptyHolder(NotEmpty initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * Fill in the stored value, reading it from the given CDR stream.
+ */
+ public void _read(InputStream i)
+ {
+ value = NotEmptyHelper.read(i);
+ }
+
+ /**
+ * Get the type code of the {@link NotEmpty} exception.
+ */
+ public TypeCode _type()
+ {
+ return NotEmptyHelper.type();
+ }
+
+ /**
+ * Write the stored value to the given CDR stream.
+ */
+ public void _write(OutputStream o)
+ {
+ NotEmptyHelper.write(o, value);
+ }
+}
diff --git a/org/omg/CosNaming/NamingContextPackage/NotFound.java b/org/omg/CosNaming/NamingContextPackage/NotFound.java
new file mode 100644
index 000000000..69a6ecdda
--- /dev/null
+++ b/org/omg/CosNaming/NamingContextPackage/NotFound.java
@@ -0,0 +1,81 @@
+/* NotFound.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming.NamingContextPackage;
+
+import org.omg.CORBA.UserException;
+import org.omg.CORBA.portable.IDLEntity;
+import org.omg.CosNaming.NameComponent;
+
+/**
+* The exception is thrown when the binding being searched does not exist
+* or has the wrong type
+*
+* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+*/
+public final class NotFound
+ extends UserException
+ implements IDLEntity
+{
+ /**
+ * The reason, explaining, why the binding cannot be found.
+ * This might be either the missing node or the wrong binding type.
+ */
+ public NotFoundReason why;
+
+ /**
+ * Contains the remainder of the non working name.
+ */
+ public NameComponent[] rest_of_name;
+
+ /**
+ * Creates the exception with unitialised fields.
+ */
+ public NotFound()
+ {
+ }
+
+ /**
+ * Creates the exception, intialising the fields to the given values.
+ */
+ public NotFound(NotFoundReason _why, NameComponent[] _rest_of_name)
+ {
+ why = _why;
+ rest_of_name = _rest_of_name;
+ }
+}
diff --git a/org/omg/CosNaming/NamingContextPackage/NotFoundHelper.java b/org/omg/CosNaming/NamingContextPackage/NotFoundHelper.java
new file mode 100644
index 000000000..a4d69a243
--- /dev/null
+++ b/org/omg/CosNaming/NamingContextPackage/NotFoundHelper.java
@@ -0,0 +1,145 @@
+/* NotFoundHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming.NamingContextPackage;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.StructMember;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CosNaming.NameComponentHelper;
+import org.omg.CosNaming.NameHelper;
+
+/**
+ * The helper operations for {@link NotFound}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class NotFoundHelper
+{
+ /**
+ * The {@link NotFound} repository id.
+ */
+ private static String _id =
+ "IDL:omg.org/CosNaming/NamingContext/NotFound:1.0";
+
+ /**
+ * The cached type code value.
+ */
+ private static TypeCode typeCode = null;
+
+ /**
+ * Extract the exception from the given {@link Any}.
+ */
+ public static NotFound extract(Any a)
+ {
+ try
+ {
+ return ((NotFoundHolder) a.extract_Streamable()).value;
+ }
+ catch (ClassCastException ex)
+ {
+ throw new BAD_OPERATION();
+ }
+ }
+
+ /**
+ * Return the exception repository id.
+ */
+ public static String id()
+ {
+ return _id;
+ }
+
+ /**
+ * Insert the exception into the given {@link Any}.
+ */
+ public static void insert(Any a, NotFound that)
+ {
+ a.insert_Streamable(new NotFoundHolder(that));
+ }
+
+ /**
+ * Read the exception from the given CDR stream.
+ */
+ public static NotFound read(InputStream istream)
+ {
+ NotFound value = new NotFound();
+
+ // Read and discard the repository ID.
+ istream.read_string();
+ value.why = NotFoundReasonHelper.read(istream);
+ value.rest_of_name = NameHelper.read(istream);
+ return value;
+ }
+
+ /**
+ * Create the type code for this exception.
+ */
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ ORB orb = ORB.init();
+
+ StructMember[] members = new StructMember[ 2 ];
+ TypeCode member = null;
+ member = NotFoundReasonHelper.type();
+ members [ 0 ] = new StructMember("why", member, null);
+ member = NameComponentHelper.type();
+ member = orb.create_sequence_tc(0, member);
+ member = orb.create_alias_tc(NameHelper.id(), "Name", member);
+ members [ 1 ] = new StructMember("rest_of_name", member, null);
+ typeCode = orb.create_struct_tc(id(), "NotFound", members);
+ }
+ return typeCode;
+ }
+
+ /**
+ * Write the exception to the CDR output stream.
+ */
+ public static void write(OutputStream ostream, NotFound value)
+ {
+ ostream.write_string(id());
+ NotFoundReasonHelper.write(ostream, value.why);
+ NameHelper.write(ostream, value.rest_of_name);
+ }
+}
diff --git a/org/omg/CosNaming/NamingContextPackage/NotFoundHolder.java b/org/omg/CosNaming/NamingContextPackage/NotFoundHolder.java
new file mode 100644
index 000000000..2b86c91bd
--- /dev/null
+++ b/org/omg/CosNaming/NamingContextPackage/NotFoundHolder.java
@@ -0,0 +1,97 @@
+/* NotFoundHolder.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming.NamingContextPackage;
+
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+
+/**
+ * The holder for the {@link NotFound} exception.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public final class NotFoundHolder
+ implements Streamable
+{
+ /**
+ * The stored value.
+ */
+ public NotFound value;
+
+ /**
+ * Create the holder with unitialised value.
+ */
+ public NotFoundHolder()
+ {
+ }
+
+ /**
+ * Create the holder, storing the given value.
+ */
+ public NotFoundHolder(NotFound initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * Fill in the stored value, reading it from the given CDR stream.
+ */
+ public void _read(InputStream in)
+ {
+ value = NotFoundHelper.read(in);
+ }
+
+ /**
+ * Get the type code of the {@link NotFound} exception.
+ */
+ public TypeCode _type()
+ {
+ return NotFoundHelper.type();
+ }
+
+ /**
+ * Write the stored value to the given CDR stream.
+ */
+ public void _write(OutputStream out)
+ {
+ NotFoundHelper.write(out, value);
+ }
+}
diff --git a/org/omg/CosNaming/NamingContextPackage/NotFoundReason.java b/org/omg/CosNaming/NamingContextPackage/NotFoundReason.java
new file mode 100644
index 000000000..f7ba14521
--- /dev/null
+++ b/org/omg/CosNaming/NamingContextPackage/NotFoundReason.java
@@ -0,0 +1,129 @@
+/* NotFoundReason.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming.NamingContextPackage;
+
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * Represents the reason (explanation), why the binding cannot be found.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class NotFoundReason
+ implements IDLEntity
+{
+ /**
+ * The code for reason, when the node is missing.
+ */
+ public static final int _missing_node = 0;
+
+ /**
+ * The code for reason, when the binding type is object when
+ * it should be a context.
+ */
+ public static final int _not_context = 1;
+
+ /**
+ * The code for reason, when the binding type is context when
+ * it should be an object.
+ */
+ public static final int _not_object = 2;
+
+ /**
+ * The reason, when the node is missing.
+ */
+ public static final NotFoundReason missing_node =
+ new NotFoundReason(_missing_node);
+
+ /**
+ * The reason, when the binding type is object when it should be
+ * a context.
+ */
+ public static final NotFoundReason not_context =
+ new NotFoundReason(_not_context);
+
+ /**
+ * The reason, when the binding type is context when it should be
+ * and object.
+ */
+ public static final NotFoundReason not_object =
+ new NotFoundReason(_not_object);
+
+ /**
+ * The reason code for this instance.
+ */
+ private int value;
+
+ protected NotFoundReason(int a_value)
+ {
+ value = a_value;
+ }
+
+ /**
+ * Get the reason object from the reason code.
+ *
+ * @throws BAD_PARAM for unsupported code.
+ */
+ public static NotFoundReason from_int(int value)
+ {
+ switch (value)
+ {
+ case _missing_node :
+ return missing_node;
+
+ case _not_context :
+ return not_context;
+
+ case _not_object :
+ return not_object;
+
+ default :
+ throw new BAD_PARAM("Unsupported not found reason: " + value);
+ }
+ }
+
+ /**
+ * Get the reason code for this reason of not finding.
+ */
+ public int value()
+ {
+ return value;
+ }
+}
diff --git a/org/omg/CosNaming/NamingContextPackage/NotFoundReasonHelper.java b/org/omg/CosNaming/NamingContextPackage/NotFoundReasonHelper.java
new file mode 100644
index 000000000..60065fa71
--- /dev/null
+++ b/org/omg/CosNaming/NamingContextPackage/NotFoundReasonHelper.java
@@ -0,0 +1,128 @@
+/* NotFoundReasonHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming.NamingContextPackage;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * The helper operations for {@link NotFoundReason}
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class NotFoundReasonHelper
+{
+ /**
+ * The {@link AlreadyBound} repository id.
+ */
+ private static String _id =
+ "IDL:omg.org/CosNaming/NamingContext/NotFoundReason:1.0";
+
+ /**
+ * The cached type code value.
+ */
+ private static TypeCode typeCode;
+
+ /**
+ * Extract the exception from the given {@link Any}.
+ */
+ public static NotFoundReason extract(Any a)
+ {
+ try
+ {
+ return ((NotFoundReasonHolder) a.extract_Streamable()).value;
+ }
+ catch (ClassCastException ex)
+ {
+ throw new BAD_OPERATION();
+ }
+ }
+
+ /**
+ * Return the exception repository id.
+ */
+ public static String id()
+ {
+ return _id;
+ }
+
+ /**
+ * Insert the exception into the given {@link Any}.
+ */
+ public static void insert(Any a, NotFoundReason that)
+ {
+ a.insert_Streamable(new NotFoundReasonHolder(that));
+ }
+
+ /**
+ * Read the exception from the given CDR stream.
+ */
+ public static NotFoundReason read(InputStream istream)
+ {
+ return NotFoundReason.from_int(istream.read_long());
+ }
+
+ /**
+ * Create the type code for this exception.
+ */
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ typeCode =
+ ORB.init().create_enum_tc(id(), "NotFoundReason",
+ new String[]
+ {
+ "missing_node", "not_context", "not_object"
+ }
+ );
+ return typeCode;
+ }
+
+ /**
+ * Write the exception to the CDR output stream.
+ */
+ public static void write(OutputStream ostream, NotFoundReason value)
+ {
+ ostream.write_long(value.value());
+ }
+}
diff --git a/org/omg/CosNaming/NamingContextPackage/NotFoundReasonHolder.java b/org/omg/CosNaming/NamingContextPackage/NotFoundReasonHolder.java
new file mode 100644
index 000000000..954a3fc62
--- /dev/null
+++ b/org/omg/CosNaming/NamingContextPackage/NotFoundReasonHolder.java
@@ -0,0 +1,98 @@
+/* NotFoundReasonHolder.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming.NamingContextPackage;
+
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+
+/**
+* The holder for class {@link NotFoundReason}.
+*
+* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+*/
+public final class NotFoundReasonHolder
+ implements Streamable
+{
+ /**
+ * The stored value.
+ */
+ public NotFoundReason value;
+
+ /**
+ * Create the holder with unitialized value.
+ */
+ public NotFoundReasonHolder()
+ {
+ }
+
+ /**
+ * Create the holder, storing the given intial value.
+ */
+ public NotFoundReasonHolder(NotFoundReason initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * Read the holder from the CDR input stream.
+ */
+ public void _read(InputStream in)
+ {
+ value = NotFoundReasonHelper.read(in);
+ }
+
+ /**
+ * Get the type code of {@link NotFoundReason}.
+ * @return
+ */
+ public TypeCode _type()
+ {
+ return NotFoundReasonHelper.type();
+ }
+
+ /**
+ * Write the holder to the CDR output stream.
+ */
+ public void _write(OutputStream out)
+ {
+ NotFoundReasonHelper.write(out, value);
+ }
+}
diff --git a/org/omg/CosNaming/NamingContextPackage/package.html b/org/omg/CosNaming/NamingContextPackage/package.html
new file mode 100644
index 000000000..f30394adb
--- /dev/null
+++ b/org/omg/CosNaming/NamingContextPackage/package.html
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in org.omg.CosNaming.NamingContextPackage
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - org.omg.CosNaming.NamingContextExtPackage</title></head>
+
+<body>
+<p>Provides exceptions and several other satelitte classes, needed by the naming service.</p>
+
+</body>
+</html>
diff --git a/org/omg/CosNaming/_BindingIteratorImplBase.java b/org/omg/CosNaming/_BindingIteratorImplBase.java
new file mode 100644
index 000000000..585fcaeff
--- /dev/null
+++ b/org/omg/CosNaming/_BindingIteratorImplBase.java
@@ -0,0 +1,113 @@
+/* _BindingIteratorImplBase.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming;
+
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.InvokeHandler;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.ResponseHandler;
+
+/**
+ * The binding iterator implementation base.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class _BindingIteratorImplBase
+ extends ObjectImpl
+ implements BindingIterator, InvokeHandler
+{
+ /**
+ * The binding interator repository id.
+ */
+ private static String[] ids = { BindingIteratorHelper.id() };
+
+ /**
+ * Return the list of repository ids.
+ */
+ public String[] _ids()
+ {
+ return ids;
+ }
+
+ /**
+ * Call the required method.
+ */
+ public OutputStream _invoke(String method, InputStream in, ResponseHandler rh)
+ {
+ OutputStream out = null;
+
+ // We suppose that the next_n should be the most popular.
+ if (method.equals("next_n"))
+ {
+ // The next_n has been invoked.
+ int amount = in.read_ulong();
+ BindingListHolder a_list = new BindingListHolder();
+
+ boolean result = next_n(amount, a_list);
+
+ out = rh.createReply();
+ out.write_boolean(result);
+ BindingListHelper.write(out, a_list.value);
+ }
+ else if (method.equals("next_one"))
+ {
+ // The next_one has been invoked.
+ BindingHolder a_binding = new BindingHolder();
+
+ boolean result = next_one(a_binding);
+
+ out = rh.createReply();
+ out.write_boolean(result);
+ BindingHelper.write(out, a_binding.value);
+ }
+ else if (method.equals("destroy"))
+ {
+ // The destroy has been invoked.
+ destroy();
+ out = rh.createReply();
+ }
+ else
+ throw new BAD_OPERATION(method, 0, CompletionStatus.COMPLETED_MAYBE);
+
+ return out;
+ }
+}
diff --git a/org/omg/CosNaming/_BindingIteratorStub.java b/org/omg/CosNaming/_BindingIteratorStub.java
new file mode 100644
index 000000000..3bb71b6b6
--- /dev/null
+++ b/org/omg/CosNaming/_BindingIteratorStub.java
@@ -0,0 +1,198 @@
+/* _BindingIteratorStub.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming;
+
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.portable.ApplicationException;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.RemarshalException;
+
+/**
+ * The binding interator stub (proxy), used on the client side.
+ * The BindingIterator methods contains the code for remote invocaton.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class _BindingIteratorStub
+ extends ObjectImpl
+ implements BindingIterator
+{
+ /**
+ * The object can be destroyed only once.
+ */
+ private boolean destroyed;
+
+ /**
+ * Create the stub.
+ */
+ public _BindingIteratorStub()
+ {
+ super();
+ }
+
+ /**
+ * Create the stub that used the given delegate.
+ */
+ public _BindingIteratorStub(Delegate delegate)
+ {
+ super();
+ _set_delegate(delegate);
+ }
+
+ /**
+ * Get an array of repository ids for this object.
+ */
+ public String[] _ids()
+ {
+ return new String[] { BindingIteratorHelper.id() };
+ }
+
+ /**
+ * Returns true if the object has been destroyed.
+ */
+ public boolean _non_existent()
+ {
+ return destroyed;
+ }
+
+ /**
+ * Destroys the object on the server side.
+ * The destruction message is sent only once, even if the method is
+ * called repeatedly.
+ */
+ public void destroy()
+ {
+ if (destroyed)
+ return;
+
+ InputStream _in = null;
+ try
+ {
+ OutputStream _out = _request("destroy", true);
+ _in = _invoke(_out);
+ destroyed = true;
+ }
+ catch (ApplicationException _ex)
+ {
+ _in = _ex.getInputStream();
+ throw new MARSHAL(_ex.getId());
+ }
+ catch (RemarshalException _rm)
+ {
+ destroy();
+ }
+ finally
+ {
+ _releaseReply(_in);
+ }
+ }
+
+ /** {@inheritDoc} */
+ public boolean next_n(int amount, BindingListHolder a_list)
+ {
+ InputStream _in = null;
+ try
+ {
+ OutputStream _out = _request("next_n", true);
+ _out.write_ulong(amount);
+ _in = _invoke(_out);
+
+ boolean result = _in.read_boolean();
+ a_list.value = BindingListHelper.read(_in);
+ return result;
+ }
+ catch (ApplicationException _ex)
+ {
+ _in = _ex.getInputStream();
+ throw new MARSHAL(_ex.getId());
+ }
+ catch (RemarshalException _rm)
+ {
+ return next_n(amount, a_list);
+ }
+ finally
+ {
+ _releaseReply(_in);
+ }
+ }
+
+ /** {@inheritDoc} */
+ public boolean next_one(BindingHolder a_binding)
+ {
+ InputStream _in = null;
+ try
+ {
+ OutputStream _out = _request("next_one", true);
+ _in = _invoke(_out);
+
+ boolean result = _in.read_boolean();
+ a_binding.value = BindingHelper.read(_in);
+ return result;
+ }
+ catch (ApplicationException _ex)
+ {
+ _in = _ex.getInputStream();
+ throw new MARSHAL(_ex.getId());
+ }
+ catch (RemarshalException _rm)
+ {
+ return next_one(a_binding);
+ }
+ finally
+ {
+ _releaseReply(_in);
+ }
+ }
+
+ /**
+ * Destroys the iterator instance on the server side, calling
+ * {@link #destroy()}.
+ *
+ * @throws java.lang.Throwable
+ */
+ protected void finalize()
+ throws java.lang.Throwable
+ {
+ destroy();
+ super.finalize();
+ }
+}
diff --git a/org/omg/CosNaming/_NamingContextExtImplBase.java b/org/omg/CosNaming/_NamingContextExtImplBase.java
new file mode 100644
index 000000000..80bea5a08
--- /dev/null
+++ b/org/omg/CosNaming/_NamingContextExtImplBase.java
@@ -0,0 +1,195 @@
+/* _NamingContextExtImplBase.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming;
+
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.InvokeHandler;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.ResponseHandler;
+import org.omg.CosNaming.NamingContextExtPackage.AddressHelper;
+import org.omg.CosNaming.NamingContextExtPackage.InvalidAddress;
+import org.omg.CosNaming.NamingContextExtPackage.InvalidAddressHelper;
+import org.omg.CosNaming.NamingContextExtPackage.StringNameHelper;
+import org.omg.CosNaming.NamingContextPackage.CannotProceed;
+import org.omg.CosNaming.NamingContextPackage.CannotProceedHelper;
+import org.omg.CosNaming.NamingContextPackage.InvalidName;
+import org.omg.CosNaming.NamingContextPackage.InvalidNameHelper;
+import org.omg.CosNaming.NamingContextPackage.NotFound;
+import org.omg.CosNaming.NamingContextPackage.NotFoundHelper;
+
+import java.util.Hashtable;
+
+/**
+ * The extended naming context implementation base.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class _NamingContextExtImplBase
+ extends _NamingContextImplBase
+ implements NamingContextExt, InvokeHandler
+{
+ private static Hashtable _methods = new Hashtable();
+
+ static
+ {
+ _methods.put("to_string", new java.lang.Integer(0));
+ _methods.put("to_name", new java.lang.Integer(1));
+ _methods.put("to_url", new java.lang.Integer(2));
+ _methods.put("resolve_str", new java.lang.Integer(3));
+ }
+
+ /**
+ * This stub can be the base of the two CORBA objects, so it
+ * has two repository ids.
+ */
+ private static String[] __ids =
+ { NamingContextExtHelper.id(), NamingContextHelper.id() };
+
+ /**
+ * Return the array of repository ids for this object.
+ * This stub can be the base of the two CORBA objects, so it
+ * has two repository ids, for {@link NamingContext} and
+ * for {@link NamingContextExt}.
+ */
+ public String[] _ids()
+ {
+ return __ids;
+ }
+
+ public OutputStream _invoke(String method, InputStream in, ResponseHandler rh)
+ {
+ Integer call_method = (Integer) _methods.get(method);
+
+ if (call_method == null)
+
+ // The older methods are handled by the parent class.
+ return super._invoke(method, in, rh);
+
+ OutputStream out = null;
+
+ switch (call_method.intValue())
+ {
+ case 0 : // to_string
+ {
+ try
+ {
+ NameComponent[] a_name = NameHelper.read(in);
+ String result = null;
+ result = this.to_string(a_name);
+ out = rh.createReply();
+ out.write_string(result);
+ }
+ catch (InvalidName ex)
+ {
+ out = rh.createExceptionReply();
+ InvalidNameHelper.write(out, ex);
+ }
+ break;
+ }
+
+ case 1 : // to_name
+ {
+ try
+ {
+ String a_name_string = in.read_string();
+ NameComponent[] result = to_name(a_name_string);
+ out = rh.createReply();
+ NameHelper.write(out, result);
+ }
+ catch (InvalidName ex)
+ {
+ out = rh.createExceptionReply();
+ InvalidNameHelper.write(out, ex);
+ }
+ break;
+ }
+
+ case 2 : // to_url
+ {
+ try
+ {
+ String an_address = in.read_string();
+ String a_name_string = in.read_string();
+ String result = to_url(an_address, a_name_string);
+ out = rh.createReply();
+ out.write_string(result);
+ }
+ catch (InvalidAddress ex)
+ {
+ out = rh.createExceptionReply();
+ InvalidAddressHelper.write(out, ex);
+ }
+ catch (InvalidName ex)
+ {
+ out = rh.createExceptionReply();
+ InvalidNameHelper.write(out, ex);
+ }
+ break;
+ }
+
+ case 3 : // resolve_str
+ {
+ try
+ {
+ String a_name_string = in.read_string();
+ org.omg.CORBA.Object result = resolve_str(a_name_string);
+ out = rh.createReply();
+ org.omg.CORBA.ObjectHelper.write(out, result);
+ }
+ catch (NotFound ex)
+ {
+ out = rh.createExceptionReply();
+ NotFoundHelper.write(out, ex);
+ }
+ catch (CannotProceed ex)
+ {
+ out = rh.createExceptionReply();
+ CannotProceedHelper.write(out, ex);
+ }
+ catch (InvalidName ex)
+ {
+ out = rh.createExceptionReply();
+ InvalidNameHelper.write(out, ex);
+ }
+ break;
+ }
+ }
+ return out;
+ }
+}
diff --git a/org/omg/CosNaming/_NamingContextExtStub.java b/org/omg/CosNaming/_NamingContextExtStub.java
new file mode 100644
index 000000000..b6939a746
--- /dev/null
+++ b/org/omg/CosNaming/_NamingContextExtStub.java
@@ -0,0 +1,205 @@
+/* _NamingContextExtStub.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming;
+
+import gnu.CORBA.NamingService.snConverter;
+
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.ObjectHelper;
+import org.omg.CORBA.portable.ApplicationException;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.RemarshalException;
+import org.omg.CosNaming.NamingContextExtPackage.AddressHelper;
+import org.omg.CosNaming.NamingContextExtPackage.InvalidAddress;
+import org.omg.CosNaming.NamingContextExtPackage.InvalidAddressHelper;
+import org.omg.CosNaming.NamingContextExtPackage.StringNameHelper;
+import org.omg.CosNaming.NamingContextExtPackage.URLStringHelper;
+import org.omg.CosNaming.NamingContextPackage.CannotProceed;
+import org.omg.CosNaming.NamingContextPackage.InvalidName;
+import org.omg.CosNaming.NamingContextPackage.InvalidNameHelper;
+import org.omg.CosNaming.NamingContextPackage.NotFound;
+
+/**
+ * The extended naming context stub (proxy), used on the client side.
+ * The most of the {@link NamingContextExt} methods contain the code
+ * for remote invocaton. However as remote invocation is potencially an
+ * expensive step, some trivial methods, not requiring access to the
+ * naming database, are handled locally (see the method descriptions for
+ * details).
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class _NamingContextExtStub
+ extends _NamingContextStub
+ implements NamingContextExt
+{
+ /**
+ * This stub can be the base of the two CORBA objects, so it
+ * has two repository ids.
+ */
+ private static String[] __ids =
+ { NamingContextExtHelper.id(), NamingContextHelper.id() };
+
+ /**
+ * The local name form converter.
+ */
+ private snConverter converter = new snConverter();
+
+ /**
+ * Create the naming context stub.
+ */
+ public _NamingContextExtStub()
+ {
+ super();
+ }
+
+ /**
+ * Create the naming context stub with the given delegate.
+ */
+ public _NamingContextExtStub(Delegate delegate)
+ {
+ super(delegate);
+ }
+
+ /**
+ * Return the array of repository ids for this object.
+ * This stub can be the base of the two CORBA objects, so it
+ * has two repository ids, for {@link NamingContext} and
+ * for {@link NamingContextExt}.
+ */
+ public String[] _ids()
+ {
+ return (String[]) __ids.clone();
+ }
+
+ /** {@inheritDoc} */
+ public org.omg.CORBA.Object resolve_str(String a_name_string)
+ throws NotFound, CannotProceed, InvalidName
+ {
+ InputStream in = null;
+ try
+ {
+ OutputStream _out = _request("resolve_str", true);
+ StringNameHelper.write(_out, a_name_string);
+ in = _invoke(_out);
+
+ return ObjectHelper.read(in);
+ }
+ catch (ApplicationException ex)
+ {
+ in = ex.getInputStream();
+
+ String id = ex.getId();
+ throw4(in, id);
+
+ // Should never happen.
+ throw new InternalError();
+ }
+ catch (RemarshalException _rm)
+ {
+ return resolve_str(a_name_string);
+ }
+ finally
+ {
+ _releaseReply(in);
+ }
+ }
+
+ /**
+ * Converts the string name representation into the array
+ * name representation.
+ *
+ * This method is handled locally.
+ */
+ public NameComponent[] to_name(String a_name_string)
+ throws InvalidName
+ {
+ return converter.toName(a_name_string);
+ }
+
+ /**
+ * Convert the name array representation to the name string
+ * representation.
+ *
+ * This method is handled locally.
+ */
+ public String to_string(NameComponent[] a_name)
+ throws InvalidName
+ {
+ return converter.toString(a_name);
+ }
+
+ /** {@inheritDoc} */
+ public String to_url(String an_address, String a_name_string)
+ throws InvalidAddress, InvalidName
+ {
+ InputStream in = null;
+ try
+ {
+ OutputStream _out = _request("to_url", true);
+ AddressHelper.write(_out, an_address);
+ StringNameHelper.write(_out, a_name_string);
+ in = _invoke(_out);
+
+ return URLStringHelper.read(in);
+ }
+ catch (ApplicationException ex)
+ {
+ in = ex.getInputStream();
+
+ String id = ex.getId();
+ if (id.equals(InvalidAddressHelper.id()))
+ throw InvalidAddressHelper.read(in);
+ else if (id.equals(InvalidNameHelper.id()))
+ throw InvalidNameHelper.read(in);
+ else
+ throw new MARSHAL(id);
+ }
+ catch (RemarshalException _rm)
+ {
+ return to_url(an_address, a_name_string);
+ }
+ finally
+ {
+ _releaseReply(in);
+ }
+ }
+}
diff --git a/org/omg/CosNaming/_NamingContextImplBase.java b/org/omg/CosNaming/_NamingContextImplBase.java
new file mode 100644
index 000000000..dd43c7dbb
--- /dev/null
+++ b/org/omg/CosNaming/_NamingContextImplBase.java
@@ -0,0 +1,368 @@
+/* _NamingContextImplBase.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming;
+
+import java.util.Hashtable;
+
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.ObjectHelper;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.InvokeHandler;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.ResponseHandler;
+import org.omg.CosNaming.NamingContextPackage.AlreadyBound;
+import org.omg.CosNaming.NamingContextPackage.AlreadyBoundHelper;
+import org.omg.CosNaming.NamingContextPackage.CannotProceed;
+import org.omg.CosNaming.NamingContextPackage.CannotProceedHelper;
+import org.omg.CosNaming.NamingContextPackage.InvalidName;
+import org.omg.CosNaming.NamingContextPackage.InvalidNameHelper;
+import org.omg.CosNaming.NamingContextPackage.NotEmpty;
+import org.omg.CosNaming.NamingContextPackage.NotEmptyHelper;
+import org.omg.CosNaming.NamingContextPackage.NotFound;
+import org.omg.CosNaming.NamingContextPackage.NotFoundHelper;
+
+/**
+ * The naming context implementation base.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class _NamingContextImplBase
+ extends ObjectImpl
+ implements NamingContext, InvokeHandler
+{
+ /**
+ * As there are quite many methods, it may be sensible to use the hashtable.
+ */
+ private static Hashtable methods = new Hashtable();
+
+ /**
+ * Put all methods into the table.
+ */
+ static
+ {
+ methods.put("bind", new Integer(0));
+ methods.put("rebind", new Integer(1));
+ methods.put("bind_context", new Integer(2));
+ methods.put("rebind_context", new Integer(3));
+ methods.put("resolve", new Integer(4));
+ methods.put("unbind", new Integer(5));
+ methods.put("new_context", new Integer(6));
+ methods.put("bind_new_context", new Integer(7));
+ methods.put("destroy", new Integer(8));
+ methods.put("list", new Integer(9));
+ }
+
+ /**
+ * Return the array of repository ids.
+ */
+ public String[] _ids()
+ {
+ return new String[] { NamingContextHelper.id() };
+ }
+
+ /**
+ * The server calls this method after receiving the request message
+ * from client. The implementation base calls one of its abstract
+ * methods to perform the requested operation.
+ *
+ * @param method the method being invoked.
+ * @param in the stream to read parameters from.
+ * @param rh the handler to get a stream for writing a response.
+ *
+ * @return the stream, returned by the handler.
+ */
+ public OutputStream _invoke(String method, InputStream in, ResponseHandler rh)
+ {
+ OutputStream out = null;
+ Integer call_method = (Integer) methods.get(method);
+ if (call_method == null)
+ throw new BAD_OPERATION(0, CompletionStatus.COMPLETED_MAYBE);
+
+ switch (call_method.intValue())
+ {
+ case 0 : // bind
+ {
+ try
+ {
+ NameComponent[] a_name = NameHelper.read(in);
+ org.omg.CORBA.Object an_object = ObjectHelper.read(in);
+ bind(a_name, an_object);
+ out = rh.createReply();
+ }
+ catch (NotFound ex)
+ {
+ out = rh.createExceptionReply();
+ NotFoundHelper.write(out, ex);
+ }
+ catch (CannotProceed ex)
+ {
+ out = rh.createExceptionReply();
+ CannotProceedHelper.write(out, ex);
+ }
+ catch (InvalidName ex)
+ {
+ out = rh.createExceptionReply();
+ InvalidNameHelper.write(out, ex);
+ }
+ catch (AlreadyBound ex)
+ {
+ out = rh.createExceptionReply();
+ AlreadyBoundHelper.write(out, ex);
+ }
+ break;
+ }
+
+ case 1 : // rebind
+ {
+ try
+ {
+ NameComponent[] a_name = NameHelper.read(in);
+ org.omg.CORBA.Object an_object = ObjectHelper.read(in);
+ rebind(a_name, an_object);
+ out = rh.createReply();
+ }
+ catch (NotFound ex)
+ {
+ out = rh.createExceptionReply();
+ NotFoundHelper.write(out, ex);
+ }
+ catch (CannotProceed ex)
+ {
+ out = rh.createExceptionReply();
+ CannotProceedHelper.write(out, ex);
+ }
+ catch (InvalidName ex)
+ {
+ out = rh.createExceptionReply();
+ InvalidNameHelper.write(out, ex);
+ }
+ break;
+ }
+
+ case 2 : // bind_context
+ {
+ try
+ {
+ NameComponent[] a_name = NameHelper.read(in);
+ NamingContext a_context = NamingContextHelper.read(in);
+ bind_context(a_name, a_context);
+ out = rh.createReply();
+ }
+ catch (NotFound ex)
+ {
+ out = rh.createExceptionReply();
+ NotFoundHelper.write(out, ex);
+ }
+ catch (CannotProceed ex)
+ {
+ out = rh.createExceptionReply();
+ CannotProceedHelper.write(out, ex);
+ }
+ catch (InvalidName ex)
+ {
+ out = rh.createExceptionReply();
+ InvalidNameHelper.write(out, ex);
+ }
+ catch (AlreadyBound ex)
+ {
+ out = rh.createExceptionReply();
+ AlreadyBoundHelper.write(out, ex);
+ }
+ break;
+ }
+
+ case 3 : // rebind_context
+ {
+ try
+ {
+ NameComponent[] a_name = NameHelper.read(in);
+ NamingContext a_context = NamingContextHelper.read(in);
+ rebind_context(a_name, a_context);
+ out = rh.createReply();
+ }
+ catch (NotFound ex)
+ {
+ out = rh.createExceptionReply();
+ NotFoundHelper.write(out, ex);
+ }
+ catch (CannotProceed ex)
+ {
+ out = rh.createExceptionReply();
+ CannotProceedHelper.write(out, ex);
+ }
+ catch (InvalidName ex)
+ {
+ out = rh.createExceptionReply();
+ InvalidNameHelper.write(out, ex);
+ }
+ break;
+ }
+
+ case 4 : // resolve
+ {
+ try
+ {
+ NameComponent[] a_name = NameHelper.read(in);
+ org.omg.CORBA.Object __result = null;
+ __result = resolve(a_name);
+ out = rh.createReply();
+ ObjectHelper.write(out, __result);
+ }
+ catch (NotFound ex)
+ {
+ out = rh.createExceptionReply();
+ NotFoundHelper.write(out, ex);
+ }
+ catch (CannotProceed ex)
+ {
+ out = rh.createExceptionReply();
+ CannotProceedHelper.write(out, ex);
+ }
+ catch (InvalidName ex)
+ {
+ out = rh.createExceptionReply();
+ InvalidNameHelper.write(out, ex);
+ }
+ break;
+ }
+
+ case 5 : // unbind
+ {
+ try
+ {
+ NameComponent[] a_name = NameHelper.read(in);
+ unbind(a_name);
+ out = rh.createReply();
+ }
+ catch (NotFound ex)
+ {
+ out = rh.createExceptionReply();
+ NotFoundHelper.write(out, ex);
+ }
+ catch (CannotProceed ex)
+ {
+ out = rh.createExceptionReply();
+ CannotProceedHelper.write(out, ex);
+ }
+ catch (InvalidName ex)
+ {
+ out = rh.createExceptionReply();
+ InvalidNameHelper.write(out, ex);
+ }
+ break;
+ }
+
+ case 6 : // new_context
+ {
+ NamingContext __result = null;
+ __result = new_context();
+ out = rh.createReply();
+ NamingContextHelper.write(out, __result);
+ break;
+ }
+
+ case 7 : // bind_new_context
+ {
+ try
+ {
+ NameComponent[] a_name = NameHelper.read(in);
+ NamingContext __result = null;
+ __result = bind_new_context(a_name);
+ out = rh.createReply();
+ NamingContextHelper.write(out, __result);
+ }
+ catch (NotFound ex)
+ {
+ out = rh.createExceptionReply();
+ NotFoundHelper.write(out, ex);
+ }
+ catch (AlreadyBound ex)
+ {
+ out = rh.createExceptionReply();
+ AlreadyBoundHelper.write(out, ex);
+ }
+ catch (CannotProceed ex)
+ {
+ out = rh.createExceptionReply();
+ CannotProceedHelper.write(out, ex);
+ }
+ catch (InvalidName ex)
+ {
+ out = rh.createExceptionReply();
+ InvalidNameHelper.write(out, ex);
+ }
+ break;
+ }
+
+ case 8 : // destroy
+ {
+ try
+ {
+ destroy();
+ out = rh.createReply();
+ }
+ catch (NotEmpty ex)
+ {
+ out = rh.createExceptionReply();
+ NotEmptyHelper.write(out, ex);
+ }
+ break;
+ }
+
+ case 9 : // list
+ {
+ int amount = in.read_ulong();
+ BindingListHolder a_list = new BindingListHolder();
+ BindingIteratorHolder an_iter = new BindingIteratorHolder();
+ list(amount, a_list, an_iter);
+ out = rh.createReply();
+ BindingListHelper.write(out, a_list.value);
+ BindingIteratorHelper.write(out, an_iter.value);
+ break;
+ }
+
+ default :
+ throw new BAD_OPERATION(0, CompletionStatus.COMPLETED_MAYBE);
+ }
+
+ return out;
+ }
+}
diff --git a/org/omg/CosNaming/_NamingContextStub.java b/org/omg/CosNaming/_NamingContextStub.java
new file mode 100644
index 000000000..0f921f012
--- /dev/null
+++ b/org/omg/CosNaming/_NamingContextStub.java
@@ -0,0 +1,446 @@
+/* _NamingContextStub.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CosNaming;
+
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.ObjectHelper;
+import org.omg.CORBA.portable.ApplicationException;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.RemarshalException;
+import org.omg.CosNaming.NamingContextPackage.AlreadyBound;
+import org.omg.CosNaming.NamingContextPackage.AlreadyBoundHelper;
+import org.omg.CosNaming.NamingContextPackage.CannotProceed;
+import org.omg.CosNaming.NamingContextPackage.CannotProceedHelper;
+import org.omg.CosNaming.NamingContextPackage.InvalidName;
+import org.omg.CosNaming.NamingContextPackage.InvalidNameHelper;
+import org.omg.CosNaming.NamingContextPackage.NotEmpty;
+import org.omg.CosNaming.NamingContextPackage.NotEmptyHelper;
+import org.omg.CosNaming.NamingContextPackage.NotFound;
+import org.omg.CosNaming.NamingContextPackage.NotFoundHelper;
+
+/**
+ * The naming context stub (proxy), used on the client side.
+ * The {@link NamingContext} methods contain the code for remote
+ * invocaton.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class _NamingContextStub
+ extends ObjectImpl
+ implements NamingContext
+{
+ /**
+ * Create the naming context stub.
+ */
+ public _NamingContextStub()
+ {
+ super();
+ }
+
+ /**
+ * Create the naming context stub with the given delegate.
+ */
+ public _NamingContextStub(Delegate delegate)
+ {
+ super();
+ _set_delegate(delegate);
+ }
+
+ /**
+ * Return the array of repository ids for this object.
+ */
+ public String[] _ids()
+ {
+ return new String[] { NamingContextHelper.id() };
+ }
+
+ /** {@inheritDoc} */
+ public void bind(NameComponent[] a_name, org.omg.CORBA.Object an_object)
+ throws NotFound, CannotProceed, InvalidName, AlreadyBound
+ {
+ InputStream in = null;
+ try
+ {
+ OutputStream out = _request("bind", true);
+ NameHelper.write(out, a_name);
+ ObjectHelper.write(out, an_object);
+ in = _invoke(out);
+ }
+ catch (ApplicationException ex)
+ {
+ in = ex.getInputStream();
+ String id = ex.getId();
+ throw5(in, id);
+ }
+ catch (RemarshalException remarsh)
+ {
+ bind(a_name, an_object);
+ }
+ finally
+ {
+ _releaseReply(in);
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void bind_context(NameComponent[] a_name, NamingContext a_context)
+ throws NotFound, CannotProceed, InvalidName, AlreadyBound
+ {
+ InputStream in = null;
+ try
+ {
+ OutputStream out = _request("bind_context", true);
+ NameHelper.write(out, a_name);
+ NamingContextHelper.write(out, a_context);
+ in = _invoke(out);
+ }
+ catch (ApplicationException ex)
+ {
+ in = ex.getInputStream();
+
+ String id = ex.getId();
+ throw5(in, id);
+ }
+ catch (RemarshalException remarsh)
+ {
+ bind_context(a_name, a_context);
+ }
+ finally
+ {
+ _releaseReply(in);
+ }
+ }
+
+ /** {@inheritDoc} */
+ public NamingContext bind_new_context(NameComponent[] a_name)
+ throws NotFound, AlreadyBound, CannotProceed,
+ InvalidName
+ {
+ InputStream in = null;
+ try
+ {
+ OutputStream out = _request("bind_new_context", true);
+ NameHelper.write(out, a_name);
+ in = _invoke(out);
+
+ NamingContext __result = NamingContextHelper.read(in);
+ return __result;
+ }
+ catch (ApplicationException ex)
+ {
+ in = ex.getInputStream();
+ String id = ex.getId();
+ throw5(in, id);
+ throw new InternalError();
+ }
+ catch (RemarshalException remarsh)
+ {
+ return bind_new_context(a_name);
+ }
+ finally
+ {
+ _releaseReply(in);
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void destroy()
+ throws NotEmpty
+ {
+ InputStream in = null;
+ try
+ {
+ OutputStream out = _request("destroy", true);
+ in = _invoke(out);
+ }
+ catch (ApplicationException ex)
+ {
+ in = ex.getInputStream();
+
+ String id = ex.getId();
+ if (id.equals(NotEmptyHelper.id()))
+ throw NotEmptyHelper.read(in);
+ else
+ throw new MARSHAL(id);
+ }
+ catch (RemarshalException remarsh)
+ {
+ destroy();
+ }
+ finally
+ {
+ _releaseReply(in);
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void list(int amount, BindingListHolder a_list,
+ BindingIteratorHolder an_iter
+ )
+ {
+ InputStream in = null;
+ try
+ {
+ OutputStream out = _request("list", true);
+ out.write_ulong(amount);
+ in = _invoke(out);
+ a_list.value = BindingListHelper.read(in);
+ an_iter.value = BindingIteratorHelper.read(in);
+ }
+ catch (ApplicationException ex)
+ {
+ in = ex.getInputStream();
+ throw new MARSHAL(ex.getId());
+ }
+ catch (RemarshalException remarsh)
+ {
+ list(amount, a_list, an_iter);
+ }
+ finally
+ {
+ _releaseReply(in);
+ }
+ }
+
+ /** {@inheritDoc} */
+ public NamingContext new_context()
+ {
+ InputStream in = null;
+ try
+ {
+ OutputStream out = _request("new_context", true);
+ in = _invoke(out);
+
+ NamingContext __result = NamingContextHelper.read(in);
+ return __result;
+ }
+ catch (ApplicationException ex)
+ {
+ in = ex.getInputStream();
+ throw new MARSHAL(ex.getId());
+ }
+ catch (RemarshalException remarsh)
+ {
+ return new_context();
+ }
+ finally
+ {
+ _releaseReply(in);
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void rebind(NameComponent[] a_name, org.omg.CORBA.Object an_object)
+ throws NotFound, CannotProceed, InvalidName
+ {
+ InputStream in = null;
+ try
+ {
+ OutputStream out = _request("rebind", true);
+ NameHelper.write(out, a_name);
+ ObjectHelper.write(out, an_object);
+ in = _invoke(out);
+ }
+ catch (ApplicationException ex)
+ {
+ in = ex.getInputStream();
+ String id = ex.getId();
+ throw4(in, id);
+ }
+ catch (RemarshalException remarsh)
+ {
+ rebind(a_name, an_object);
+ }
+ finally
+ {
+ _releaseReply(in);
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void rebind_context(NameComponent[] a_name, NamingContext a_context)
+ throws NotFound, CannotProceed, InvalidName
+ {
+ InputStream in = null;
+ try
+ {
+ OutputStream out = _request("rebind_context", true);
+ NameHelper.write(out, a_name);
+ NamingContextHelper.write(out, a_context);
+ in = _invoke(out);
+ }
+ catch (ApplicationException ex)
+ {
+ in = ex.getInputStream();
+ String id = ex.getId();
+ throw4(in, id);
+ }
+ catch (RemarshalException remarsh)
+ {
+ rebind_context(a_name, a_context);
+ }
+ finally
+ {
+ _releaseReply(in);
+ }
+ }
+
+ /** {@inheritDoc} */
+ public org.omg.CORBA.Object resolve(NameComponent[] a_name)
+ throws NotFound, CannotProceed, InvalidName
+ {
+ InputStream in = null;
+ try
+ {
+ OutputStream out = _request("resolve", true);
+ NameHelper.write(out, a_name);
+ in = _invoke(out);
+
+ org.omg.CORBA.Object __result = ObjectHelper.read(in);
+ return __result;
+ }
+ catch (ApplicationException ex)
+ {
+ in = ex.getInputStream();
+ String id = ex.getId();
+ throw4(in, id);
+ throw new InternalError();
+ }
+ catch (RemarshalException remarsh)
+ {
+ return resolve(a_name);
+ }
+ finally
+ {
+ _releaseReply(in);
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void unbind(NameComponent[] a_name)
+ throws NotFound, CannotProceed, InvalidName
+ {
+ InputStream in = null;
+ try
+ {
+ OutputStream out = _request("unbind", true);
+ NameHelper.write(out, a_name);
+ in = _invoke(out);
+ }
+ catch (ApplicationException ex)
+ {
+ in = ex.getInputStream();
+
+ String id = ex.getId();
+ if (id.equals(NotFoundHelper.id()))
+ throw NotFoundHelper.read(in);
+ else if (id.equals(CannotProceedHelper.id()))
+ throw CannotProceedHelper.read(in);
+ else if (id.equals(InvalidNameHelper.id()))
+ throw InvalidNameHelper.read(in);
+ else
+ throw new MARSHAL(id);
+ }
+ catch (RemarshalException remarsh)
+ {
+ unbind(a_name);
+ }
+ finally
+ {
+ _releaseReply(in);
+ }
+ }
+
+ /**
+ * Throw one of the three possible exceptions, as specified in
+ * the passed exception repository id.
+ *
+ * This method should never return normally.
+ *
+ * @param in the stream to read the exception from.
+ * @param id the exception id.
+ *
+ * @throws InvalidName if the id matches.
+ * @throws CannotProceed if the id matches.
+ * @throws NotFound if the id matches.
+ * @throws MARSHAL if the id does not match any of the previous 4 exceptions.
+ */
+ protected void throw4(InputStream in, String id)
+ throws MARSHAL, InvalidName, CannotProceed,
+ NotFound
+ {
+ if (id.equals(NotFoundHelper.id()))
+ throw NotFoundHelper.read(in);
+ else if (id.equals(CannotProceedHelper.id()))
+ throw CannotProceedHelper.read(in);
+ else if (id.equals(InvalidNameHelper.id()))
+ throw InvalidNameHelper.read(in);
+ else
+ throw new MARSHAL(id);
+ }
+
+ /**
+ * Throw one of the five possible exceptions, as specified in
+ * the passed exception repository id.
+ *
+ * This method should never return normally.
+ *
+ * @param in the stream to read the exception from.
+ * @param id the exception id.
+ *
+ * @throws AlreadyBound if the id matches.
+ * @throws InvalidName if the id matches.
+ * @throws CannotProceed if the id matches.
+ * @throws NotFound if the id matches.
+ * @throws MARSHAL if the id does not match any of the previous 4 exceptions.
+ */
+ protected void throw5(InputStream in, String id)
+ throws MARSHAL, AlreadyBound, InvalidName, CannotProceed,
+ NotFound
+ {
+ if (id.equals(AlreadyBoundHelper.id()))
+ throw AlreadyBoundHelper.read(in);
+ else
+ throw4(in, id);
+ }
+}
diff --git a/org/omg/CosNaming/package.html b/org/omg/CosNaming/package.html
new file mode 100644
index 000000000..25f427f2d
--- /dev/null
+++ b/org/omg/CosNaming/package.html
@@ -0,0 +1,50 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - the naming service description.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - javax.swing.text.html.parser</title></head>
+
+<body>
+<p>
+The COS (Common Object Service) Naming Service allows an object to be found from its symbolic name. The client obtains the object reference invoking the naming service as any other CORBA service. The naming service itself can be located from the stringified object reference (see {@link org.omg.CORBA.ORB#string_to_object(String)} or from the ORB pre-configured data by passing &quot;NameService&quot; to {@link org.omg.CORBA.ORB.Object#resolve_initial_references(String)}. The returned object is casted to the NamingContextExt using {@link org.omg.CosNaming.NamingContextExtHelper#narrow}. The Naming Service can reside on any host accessible within the network.
+</p><p>
+The default pre-configured location method uses two parameters (properties, applet parameters or command line parameters): org.omg.CORBA.ORBInitialHost and org.omg.CORBA.ORBInitialPort. If these parameters are missing, the naming service is supposed to be running at port 900 on the local host.
+</p>
+@author Audrius Meskauskas, Lithuania
+</body>
+</html>