From 0a0baee45ebcff44635907d457c4ff6810b09c87 Mon Sep 17 00:00:00 2001 From: Alex Rudyy Date: Wed, 15 Apr 2015 09:47:28 +0000 Subject: QPID-6481: Move java source tree to top level git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1673693 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/common/src/main/grammar/SelectorParser.jj | 612 ---------- qpid/java/common/src/main/java/common.bnd | 25 - .../org/apache/qpid/AMQChannelClosedException.java | 34 - .../java/org/apache/qpid/AMQChannelException.java | 65 - .../apache/qpid/AMQConnectionClosedException.java | 37 - .../org/apache/qpid/AMQConnectionException.java | 65 - .../apache/qpid/AMQConnectionFailureException.java | 55 - .../org/apache/qpid/AMQDisconnectedException.java | 32 - .../main/java/org/apache/qpid/AMQException.java | 134 -- .../java/org/apache/qpid/AMQInternalException.java | 49 - .../apache/qpid/AMQInvalidArgumentException.java | 40 - .../apache/qpid/AMQInvalidRoutingKeyException.java | 34 - .../org/apache/qpid/AMQPInvalidClassException.java | 37 - .../java/org/apache/qpid/AMQProtocolException.java | 39 - .../java/org/apache/qpid/AMQSecurityException.java | 54 - .../java/org/apache/qpid/AMQTimeoutException.java | 34 - .../org/apache/qpid/AMQUndeliveredException.java | 49 - .../apache/qpid/AMQUnresolvedAddressException.java | 45 - .../src/main/java/org/apache/qpid/api/Message.java | 128 -- .../java/org/apache/qpid/codec/AMQDecoder.java | 425 ------- .../java/org/apache/qpid/codec/ClientDecoder.java | 273 ----- .../org/apache/qpid/codec/MarkableDataInput.java | 41 - .../java/org/apache/qpid/codec/ServerDecoder.java | 244 ---- .../org/apache/qpid/common/AMQPFilterTypes.java | 64 - .../org/apache/qpid/common/QpidProperties.java | 147 --- .../apache/qpid/common/ServerPropertyNames.java | 60 - .../org/apache/qpid/configuration/Accessor.java | 170 --- .../qpid/configuration/ClientProperties.java | 354 ------ .../qpid/configuration/CommonProperties.java | 98 -- .../org/apache/qpid/configuration/Configured.java | 44 - .../qpid/configuration/PropertyException.java | 38 - .../apache/qpid/configuration/PropertyUtils.java | 164 --- .../apache/qpid/configuration/QpidProperty.java | 210 ---- .../org/apache/qpid/configuration/Validator.java | 31 - .../src/main/java/org/apache/qpid/dtx/XidImpl.java | 261 ---- .../org/apache/qpid/exchange/ExchangeDefaults.java | 63 - .../apache/qpid/filter/ArithmeticExpression.java | 263 ---- .../org/apache/qpid/filter/BinaryExpression.java | 90 -- .../org/apache/qpid/filter/BooleanExpression.java | 36 - .../apache/qpid/filter/ComparisonExpression.java | 589 --------- .../org/apache/qpid/filter/ConstantExpression.java | 207 ---- .../java/org/apache/qpid/filter/Expression.java | 35 - .../org/apache/qpid/filter/FilterableMessage.java | 41 - .../org/apache/qpid/filter/LogicExpression.java | 114 -- .../org/apache/qpid/filter/PropertyExpression.java | 234 ---- .../qpid/filter/SelectorParsingException.java | 36 - .../org/apache/qpid/filter/UnaryExpression.java | 340 ------ .../qpid/filter/selector/ParseException.java | 208 ---- .../qpid/filter/selector/SelectorParser.java | 1224 ------------------- .../filter/selector/SelectorParserConstants.java | 125 -- .../selector/SelectorParserTokenManager.java | 1066 ---------------- .../qpid/filter/selector/SimpleCharStream.java | 492 -------- .../org/apache/qpid/filter/selector/Token.java | 152 --- .../apache/qpid/filter/selector/TokenMgrError.java | 168 --- .../main/java/org/apache/qpid/framing/AMQBody.java | 45 - .../java/org/apache/qpid/framing/AMQDataBlock.java | 51 - .../java/org/apache/qpid/framing/AMQFrame.java | 143 --- .../qpid/framing/AMQFrameDecodingException.java | 42 - .../org/apache/qpid/framing/AMQMethodBody.java | 74 -- .../org/apache/qpid/framing/AMQMethodBodyImpl.java | 212 ---- .../qpid/framing/AMQProtocolClassException.java | 34 - .../qpid/framing/AMQProtocolHeaderException.java | 31 - .../qpid/framing/AMQProtocolInstanceException.java | 34 - .../qpid/framing/AMQProtocolVersionException.java | 34 - .../org/apache/qpid/framing/AMQShortString.java | 797 ------------ .../qpid/framing/AMQShortStringTokenizer.java | 32 - .../main/java/org/apache/qpid/framing/AMQType.java | 844 ------------- .../java/org/apache/qpid/framing/AMQTypeMap.java | 52 - .../org/apache/qpid/framing/AMQTypedValue.java | 322 ----- .../org/apache/qpid/framing/AccessRequestBody.java | 183 --- .../apache/qpid/framing/AccessRequestOkBody.java | 108 -- .../java/org/apache/qpid/framing/BasicAckBody.java | 126 -- .../org/apache/qpid/framing/BasicCancelBody.java | 127 -- .../org/apache/qpid/framing/BasicCancelOkBody.java | 109 -- .../org/apache/qpid/framing/BasicConsumeBody.java | 214 ---- .../apache/qpid/framing/BasicConsumeOkBody.java | 109 -- .../qpid/framing/BasicContentHeaderProperties.java | 799 ------------ .../org/apache/qpid/framing/BasicDeliverBody.java | 169 --- .../java/org/apache/qpid/framing/BasicGetBody.java | 141 --- .../org/apache/qpid/framing/BasicGetEmptyBody.java | 108 -- .../org/apache/qpid/framing/BasicGetOkBody.java | 167 --- .../org/apache/qpid/framing/BasicNackBody.java | 143 --- .../org/apache/qpid/framing/BasicPublishBody.java | 170 --- .../java/org/apache/qpid/framing/BasicQosBody.java | 139 --- .../org/apache/qpid/framing/BasicQosOkBody.java | 87 -- .../org/apache/qpid/framing/BasicRecoverBody.java | 115 -- .../apache/qpid/framing/BasicRecoverSyncBody.java | 115 -- .../qpid/framing/BasicRecoverSyncOkBody.java | 87 -- .../org/apache/qpid/framing/BasicRejectBody.java | 126 -- .../org/apache/qpid/framing/BasicReturnBody.java | 150 --- .../apache/qpid/framing/ByteArrayDataInput.java | 192 --- .../org/apache/qpid/framing/ChannelAlertBody.java | 137 --- .../org/apache/qpid/framing/ChannelCloseBody.java | 148 --- .../apache/qpid/framing/ChannelCloseOkBody.java | 85 -- .../org/apache/qpid/framing/ChannelFlowBody.java | 104 -- .../org/apache/qpid/framing/ChannelFlowOkBody.java | 106 -- .../qpid/framing/ChannelMethodProcessor.java | 42 - .../org/apache/qpid/framing/ChannelOpenBody.java | 95 -- .../org/apache/qpid/framing/ChannelOpenOkBody.java | 113 -- .../qpid/framing/ClientChannelMethodProcessor.java | 79 -- .../qpid/framing/ClientMethodDispatcher.java | 77 -- .../apache/qpid/framing/ClientMethodProcessor.java | 39 - .../apache/qpid/framing/CompositeAMQDataBlock.java | 92 -- .../org/apache/qpid/framing/ConfirmSelectBody.java | 105 -- .../apache/qpid/framing/ConfirmSelectOkBody.java | 77 -- .../apache/qpid/framing/ConnectionCloseBody.java | 145 --- .../apache/qpid/framing/ConnectionCloseOkBody.java | 82 -- .../apache/qpid/framing/ConnectionOpenBody.java | 135 --- .../apache/qpid/framing/ConnectionOpenOkBody.java | 108 -- .../qpid/framing/ConnectionRedirectBody.java | 120 -- .../apache/qpid/framing/ConnectionSecureBody.java | 109 -- .../qpid/framing/ConnectionSecureOkBody.java | 107 -- .../apache/qpid/framing/ConnectionStartBody.java | 153 --- .../apache/qpid/framing/ConnectionStartOkBody.java | 142 --- .../apache/qpid/framing/ConnectionTuneBody.java | 133 -- .../apache/qpid/framing/ConnectionTuneOkBody.java | 133 -- .../java/org/apache/qpid/framing/ContentBody.java | 184 --- .../org/apache/qpid/framing/ContentHeaderBody.java | 198 --- .../framing/ContentHeaderPropertiesFactory.java | 58 - .../apache/qpid/framing/EncodableAMQDataBlock.java | 35 - .../org/apache/qpid/framing/EncodingUtils.java | 1013 ---------------- .../org/apache/qpid/framing/ExchangeBoundBody.java | 138 --- .../apache/qpid/framing/ExchangeBoundOkBody.java | 130 -- .../apache/qpid/framing/ExchangeDeclareBody.java | 233 ---- .../apache/qpid/framing/ExchangeDeclareOkBody.java | 87 -- .../apache/qpid/framing/ExchangeDeleteBody.java | 156 --- .../apache/qpid/framing/ExchangeDeleteOkBody.java | 87 -- .../org/apache/qpid/framing/ExtendedDataInput.java | 34 - .../java/org/apache/qpid/framing/FieldArray.java | 130 -- .../java/org/apache/qpid/framing/FieldTable.java | 1181 ------------------ .../org/apache/qpid/framing/FieldTableFactory.java | 43 - .../qpid/framing/FrameCreatingMethodProcessor.java | 629 ---------- .../org/apache/qpid/framing/HeartbeatBody.java | 103 -- .../apache/qpid/framing/MessagePublishInfo.java | 83 -- .../org/apache/qpid/framing/MethodDispatcher.java | 37 - .../org/apache/qpid/framing/MethodProcessor.java | 40 - .../org/apache/qpid/framing/MethodRegistry.java | 557 --------- .../apache/qpid/framing/ProtocolInitiation.java | 252 ---- .../org/apache/qpid/framing/ProtocolVersion.java | 188 --- .../org/apache/qpid/framing/QueueBindBody.java | 183 --- .../org/apache/qpid/framing/QueueBindOkBody.java | 87 -- .../org/apache/qpid/framing/QueueDeclareBody.java | 213 ---- .../apache/qpid/framing/QueueDeclareOkBody.java | 134 -- .../org/apache/qpid/framing/QueueDeleteBody.java | 170 --- .../org/apache/qpid/framing/QueueDeleteOkBody.java | 107 -- .../org/apache/qpid/framing/QueuePurgeBody.java | 140 --- .../org/apache/qpid/framing/QueuePurgeOkBody.java | 107 -- .../org/apache/qpid/framing/QueueUnbindBody.java | 164 --- .../org/apache/qpid/framing/QueueUnbindOkBody.java | 87 -- .../qpid/framing/ServerChannelMethodProcessor.java | 93 -- .../qpid/framing/ServerMethodDispatcher.java | 73 -- .../apache/qpid/framing/ServerMethodProcessor.java | 39 - .../java/org/apache/qpid/framing/TxCommitBody.java | 80 -- .../org/apache/qpid/framing/TxCommitOkBody.java | 78 -- .../org/apache/qpid/framing/TxRollbackBody.java | 78 -- .../org/apache/qpid/framing/TxRollbackOkBody.java | 79 -- .../java/org/apache/qpid/framing/TxSelectBody.java | 81 -- .../org/apache/qpid/framing/TxSelectOkBody.java | 77 -- .../java/org/apache/qpid/messaging/Address.java | 79 -- .../apache/qpid/messaging/util/AddressParser.java | 422 ------- .../java/org/apache/qpid/messaging/util/JAddr.java | 97 -- .../org/apache/qpid/messaging/util/LexError.java | 37 - .../java/org/apache/qpid/messaging/util/Lexer.java | 82 -- .../org/apache/qpid/messaging/util/Lexicon.java | 103 -- .../org/apache/qpid/messaging/util/LineInfo.java | 93 -- .../org/apache/qpid/messaging/util/ParseError.java | 58 - .../org/apache/qpid/messaging/util/Parser.java | 97 -- .../org/apache/qpid/messaging/util/PyPrint.java | 149 --- .../java/org/apache/qpid/messaging/util/Token.java | 106 -- .../pool/ReferenceCountingExecutorService.java | 187 --- ...InheritedAccessControlContextThreadFactory.java | 50 - .../qpid/properties/ConnectionStartProperties.java | 102 -- .../java/org/apache/qpid/protocol/AMQConstant.java | 227 ---- .../org/apache/qpid/protocol/AMQMethodEvent.java | 90 -- .../apache/qpid/protocol/AMQMethodListener.java | 64 - .../apache/qpid/protocol/AMQProtocolWriter.java | 38 - .../protocol/AMQVersionAwareProtocolSession.java | 59 - .../org/apache/qpid/protocol/ProtocolEngine.java | 62 - .../qpid/protocol/ProtocolEngineFactory.java | 31 - .../apache/qpid/protocol/ProtocolVersionAware.java | 48 - .../org/apache/qpid/ssl/SSLContextFactory.java | 135 --- .../apache/qpid/thread/DefaultThreadFactory.java | 45 - .../thread/LoggingUncaughtExceptionHandler.java | 60 - .../org/apache/qpid/thread/QpidThreadExecutor.java | 40 - .../apache/qpid/thread/RealtimeThreadFactory.java | 72 -- .../java/org/apache/qpid/thread/ThreadFactory.java | 28 - .../java/org/apache/qpid/thread/Threading.java | 51 - .../java/org/apache/qpid/transport/Acquired.java | 141 --- .../java/org/apache/qpid/transport/Binary.java | 154 --- .../java/org/apache/qpid/transport/Binding.java | 36 - .../apache/qpid/transport/ByteBufferReceiver.java | 32 - .../apache/qpid/transport/ByteBufferSender.java | 32 - .../org/apache/qpid/transport/ClientDelegate.java | 228 ---- .../java/org/apache/qpid/transport/Connection.java | 881 -------------- .../org/apache/qpid/transport/ConnectionClose.java | 196 --- .../apache/qpid/transport/ConnectionCloseCode.java | 54 - .../apache/qpid/transport/ConnectionCloseOk.java | 111 -- .../apache/qpid/transport/ConnectionDelegate.java | 113 -- .../apache/qpid/transport/ConnectionException.java | 70 -- .../apache/qpid/transport/ConnectionHeartbeat.java | 111 -- .../apache/qpid/transport/ConnectionInvoker.java | 78 -- .../apache/qpid/transport/ConnectionListener.java | 41 - .../org/apache/qpid/transport/ConnectionOpen.java | 235 ---- .../apache/qpid/transport/ConnectionOpenOk.java | 154 --- .../apache/qpid/transport/ConnectionRedirect.java | 196 --- .../apache/qpid/transport/ConnectionSecure.java | 154 --- .../apache/qpid/transport/ConnectionSecureOk.java | 154 --- .../apache/qpid/transport/ConnectionSettings.java | 431 ------- .../org/apache/qpid/transport/ConnectionStart.java | 238 ---- .../apache/qpid/transport/ConnectionStartOk.java | 280 ----- .../org/apache/qpid/transport/ConnectionTune.java | 272 ----- .../apache/qpid/transport/ConnectionTuneOk.java | 232 ---- .../java/org/apache/qpid/transport/Constant.java | 29 - .../apache/qpid/transport/DeliveryProperties.java | 593 --------- .../java/org/apache/qpid/transport/DtxCommit.java | 193 --- .../java/org/apache/qpid/transport/DtxEnd.java | 232 ---- .../java/org/apache/qpid/transport/DtxForget.java | 154 --- .../org/apache/qpid/transport/DtxGetTimeout.java | 154 --- .../java/org/apache/qpid/transport/DtxPrepare.java | 154 --- .../java/org/apache/qpid/transport/DtxRecover.java | 111 -- .../org/apache/qpid/transport/DtxRollback.java | 154 --- .../java/org/apache/qpid/transport/DtxSelect.java | 111 -- .../org/apache/qpid/transport/DtxSetTimeout.java | 194 --- .../java/org/apache/qpid/transport/DtxStart.java | 232 ---- .../org/apache/qpid/transport/DtxXaStatus.java | 62 - .../org/apache/qpid/transport/ExchangeBind.java | 280 ----- .../org/apache/qpid/transport/ExchangeBound.java | 280 ----- .../apache/qpid/transport/ExchangeBoundResult.java | 301 ----- .../org/apache/qpid/transport/ExchangeDeclare.java | 397 ------ .../org/apache/qpid/transport/ExchangeDelete.java | 193 --- .../org/apache/qpid/transport/ExchangeQuery.java | 154 --- .../apache/qpid/transport/ExchangeQueryResult.java | 268 ---- .../org/apache/qpid/transport/ExchangeUnbind.java | 238 ---- .../apache/qpid/transport/ExecutionErrorCode.java | 72 -- .../apache/qpid/transport/ExecutionException.java | 398 ------ .../org/apache/qpid/transport/ExecutionResult.java | 194 --- .../org/apache/qpid/transport/ExecutionSync.java | 111 -- .../main/java/org/apache/qpid/transport/Field.java | 83 -- .../org/apache/qpid/transport/FileReturnCode.java | 52 - .../apache/qpid/transport/FragmentProperties.java | 224 ---- .../apache/qpid/transport/FrameSizeObserver.java | 26 - .../java/org/apache/qpid/transport/Future.java | 37 - .../apache/qpid/transport/GetTimeoutResult.java | 139 --- .../java/org/apache/qpid/transport/Header.java | 143 --- .../org/apache/qpid/transport/MessageAccept.java | 154 --- .../apache/qpid/transport/MessageAcceptMode.java | 50 - .../org/apache/qpid/transport/MessageAcquire.java | 154 --- .../apache/qpid/transport/MessageAcquireMode.java | 50 - .../org/apache/qpid/transport/MessageCancel.java | 154 --- .../apache/qpid/transport/MessageCreditUnit.java | 50 - .../apache/qpid/transport/MessageDeliveryMode.java | 50 - .../qpid/transport/MessageDeliveryPriority.java | 66 - .../org/apache/qpid/transport/MessageFlow.java | 236 ---- .../org/apache/qpid/transport/MessageFlowMode.java | 50 - .../org/apache/qpid/transport/MessageFlush.java | 154 --- .../apache/qpid/transport/MessageProperties.java | 475 -------- .../org/apache/qpid/transport/MessageReject.java | 238 ---- .../apache/qpid/transport/MessageRejectCode.java | 52 - .../org/apache/qpid/transport/MessageRelease.java | 193 --- .../org/apache/qpid/transport/MessageResume.java | 196 --- .../apache/qpid/transport/MessageResumeResult.java | 139 --- .../apache/qpid/transport/MessageSetFlowMode.java | 196 --- .../org/apache/qpid/transport/MessageStop.java | 154 --- .../apache/qpid/transport/MessageSubscribe.java | 443 ------- .../org/apache/qpid/transport/MessageTransfer.java | 302 ----- .../java/org/apache/qpid/transport/Method.java | 236 ---- .../org/apache/qpid/transport/MethodDelegate.java | 217 ---- .../qpid/transport/NetworkEventReceiver.java | 32 - .../transport/NetworkTransportConfiguration.java | 51 - .../java/org/apache/qpid/transport/Option.java | 60 - .../apache/qpid/transport/ProtocolDelegate.java | 40 - .../org/apache/qpid/transport/ProtocolError.java | 88 -- .../org/apache/qpid/transport/ProtocolEvent.java | 41 - .../qpid/transport/ProtocolEventReceiver.java | 30 - .../apache/qpid/transport/ProtocolEventSender.java | 30 - .../org/apache/qpid/transport/ProtocolHeader.java | 123 -- .../qpid/transport/ProtocolVersionException.java | 62 - .../org/apache/qpid/transport/QueueDeclare.java | 394 ------ .../org/apache/qpid/transport/QueueDelete.java | 232 ---- .../java/org/apache/qpid/transport/QueuePurge.java | 154 --- .../java/org/apache/qpid/transport/QueueQuery.java | 154 --- .../apache/qpid/transport/QueueQueryResult.java | 429 ------- .../main/java/org/apache/qpid/transport/Range.java | 306 ----- .../java/org/apache/qpid/transport/RangeSet.java | 58 - .../org/apache/qpid/transport/RangeSetFactory.java | 38 - .../org/apache/qpid/transport/RangeSetImpl.java | 240 ---- .../org/apache/qpid/transport/RecoverResult.java | 141 --- .../java/org/apache/qpid/transport/ReplyTo.java | 200 --- .../org/apache/qpid/transport/SegmentType.java | 54 - .../qpid/transport/SenderClosedException.java | 52 - .../org/apache/qpid/transport/SenderException.java | 52 - .../org/apache/qpid/transport/ServerDelegate.java | 214 ---- .../java/org/apache/qpid/transport/Session.java | 1215 ------------------- .../org/apache/qpid/transport/SessionAttach.java | 193 --- .../org/apache/qpid/transport/SessionAttached.java | 154 --- .../qpid/transport/SessionClosedException.java | 46 - .../qpid/transport/SessionCommandFragment.java | 138 --- .../apache/qpid/transport/SessionCommandPoint.java | 192 --- .../apache/qpid/transport/SessionCompleted.java | 193 --- .../apache/qpid/transport/SessionConfirmed.java | 196 --- .../org/apache/qpid/transport/SessionDelegate.java | 246 ---- .../org/apache/qpid/transport/SessionDetach.java | 154 --- .../apache/qpid/transport/SessionDetachCode.java | 56 - .../org/apache/qpid/transport/SessionDetached.java | 196 --- .../apache/qpid/transport/SessionException.java | 59 - .../org/apache/qpid/transport/SessionExpected.java | 196 --- .../org/apache/qpid/transport/SessionFlush.java | 229 ---- .../java/org/apache/qpid/transport/SessionGap.java | 154 --- .../org/apache/qpid/transport/SessionHeader.java | 145 --- .../org/apache/qpid/transport/SessionInvoker.java | 236 ---- .../qpid/transport/SessionKnownCompleted.java | 154 --- .../org/apache/qpid/transport/SessionListener.java | 42 - .../qpid/transport/SessionRequestTimeout.java | 152 --- .../org/apache/qpid/transport/SessionTimeout.java | 152 --- .../apache/qpid/transport/StreamReturnCode.java | 52 - .../java/org/apache/qpid/transport/Struct.java | 156 --- .../org/apache/qpid/transport/StructFactory.java | 200 --- .../main/java/org/apache/qpid/transport/Track.java | 50 - .../apache/qpid/transport/TransportException.java | 51 - .../java/org/apache/qpid/transport/TxCommit.java | 111 -- .../java/org/apache/qpid/transport/TxRollback.java | 111 -- .../java/org/apache/qpid/transport/TxSelect.java | 111 -- .../main/java/org/apache/qpid/transport/Type.java | 148 --- .../java/org/apache/qpid/transport/XaResult.java | 141 --- .../main/java/org/apache/qpid/transport/Xid.java | 223 ---- .../qpid/transport/codec/AbstractDecoder.java | 478 -------- .../qpid/transport/codec/AbstractEncoder.java | 620 ---------- .../org/apache/qpid/transport/codec/BBDecoder.java | 149 --- .../org/apache/qpid/transport/codec/BBEncoder.java | 363 ------ .../org/apache/qpid/transport/codec/Decoder.java | 283 ----- .../org/apache/qpid/transport/codec/Encodable.java | 44 - .../org/apache/qpid/transport/codec/Encoder.java | 284 ----- .../apache/qpid/transport/network/Assembler.java | 280 ----- .../qpid/transport/network/ConnectionBinding.java | 105 -- .../qpid/transport/network/Disassembler.java | 266 ---- .../org/apache/qpid/transport/network/Frame.java | 146 --- .../network/IncomingNetworkTransport.java | 38 - .../qpid/transport/network/InputHandler.java | 218 ---- .../qpid/transport/network/NetworkConnection.java | 55 - .../qpid/transport/network/NetworkDelegate.java | 42 - .../qpid/transport/network/NetworkEvent.java | 34 - .../qpid/transport/network/NetworkTransport.java | 30 - .../network/OutgoingNetworkTransport.java | 33 - .../org/apache/qpid/transport/network/Ticker.java | 29 - .../apache/qpid/transport/network/Transport.java | 138 --- .../qpid/transport/network/TransportActivity.java | 33 - .../transport/network/TransportEncryption.java | 26 - .../network/io/AbstractNetworkTransport.java | 342 ------ .../transport/network/io/IdleTimeoutTicker.java | 87 -- .../transport/network/io/IoNetworkConnection.java | 146 --- .../transport/network/io/IoNetworkTransport.java | 43 - .../qpid/transport/network/io/IoReceiver.java | 265 ---- .../apache/qpid/transport/network/io/IoSender.java | 373 ------ .../qpid/transport/network/security/SSLStatus.java | 49 - .../transport/network/security/SecurityLayer.java | 34 - .../network/security/SecurityLayerFactory.java | 190 --- .../network/security/sasl/SASLEncryptor.java | 87 -- .../network/security/sasl/SASLReceiver.java | 85 -- .../network/security/sasl/SASLSender.java | 114 -- .../security/ssl/QpidClientX509KeyManager.java | 106 -- .../security/ssl/QpidMultipleTrustManager.java | 103 -- .../security/ssl/QpidPeersOnlyTrustManager.java | 81 -- .../network/security/ssl/SSLBufferingSender.java | 0 .../network/security/ssl/SSLReceiver.java | 213 ---- .../transport/network/security/ssl/SSLSender.java | 268 ---- .../transport/network/security/ssl/SSLUtil.java | 371 ------ .../org/apache/qpid/transport/util/Functions.java | 125 -- .../org/apache/qpid/transport/util/Logger.java | 130 -- .../org/apache/qpid/transport/util/Waiter.java | 63 - .../apache/qpid/typedmessage/TypedBytesCodes.java | 46 - .../qpid/typedmessage/TypedBytesContentReader.java | 670 ---------- .../qpid/typedmessage/TypedBytesContentWriter.java | 366 ------ .../typedmessage/TypedBytesFormatException.java | 29 - .../java/org/apache/qpid/url/AMQBindingURL.java | 246 ---- .../main/java/org/apache/qpid/url/BindingURL.java | 91 -- .../java/org/apache/qpid/url/BindingURLParser.java | 460 ------- .../main/java/org/apache/qpid/url/URLHelper.java | 173 --- .../org/apache/qpid/url/URLSyntaxException.java | 97 -- .../apache/qpid/util/ByteBufferInputStream.java | 100 -- .../java/org/apache/qpid/util/BytesDataOutput.java | 178 --- .../org/apache/qpid/util/CommandLineParser.java | 680 ----------- .../java/org/apache/qpid/util/DataUrlUtils.java | 32 - .../main/java/org/apache/qpid/util/FileUtils.java | 396 ------ .../main/java/org/apache/qpid/util/GZIPUtils.java | 119 -- .../java/org/apache/qpid/util/NameUUIDGen.java | 59 - .../java/org/apache/qpid/util/RandomUUIDGen.java | 39 - .../src/main/java/org/apache/qpid/util/Serial.java | 109 -- .../main/java/org/apache/qpid/util/Strings.java | 406 ------- .../java/org/apache/qpid/util/SystemUtils.java | 127 -- .../main/java/org/apache/qpid/util/UUIDGen.java | 36 - .../src/main/java/org/apache/qpid/util/UUIDs.java | 62 - .../src/main/resources/qpidversion.properties | 23 - .../java/org/apache/qpid/AMQExceptionTest.java | 120 -- .../java/org/apache/qpid/codec/AMQDecoderTest.java | 205 ---- .../qpid/configuration/QpidPropertyTest.java | 185 --- .../apache/qpid/framing/AMQShortStringTest.java | 349 ------ .../framing/BasicContentHeaderPropertiesTest.java | 194 --- .../org/apache/qpid/framing/FieldTableTest.java | 949 --------------- .../abstraction/MessagePublishInfoImplTest.java | 100 -- .../pool/ReferenceCountingExecutorServiceTest.java | 159 --- ...ritedAccessControlContextThreadFactoryTest.java | 95 -- .../org/apache/qpid/ssl/SSLContextFactoryTest.java | 70 -- .../java/org/apache/qpid/ssl/TrustManagerTest.java | 344 ------ .../org/apache/qpid/thread/ThreadFactoryTest.java | 104 -- .../qpid/transport/ConnectionSettingsTest.java | 211 ---- .../org/apache/qpid/transport/ConnectionTest.java | 473 -------- .../java/org/apache/qpid/transport/GenTest.java | 44 - .../org/apache/qpid/transport/RangeSetTest.java | 353 ------ .../apache/qpid/transport/SessionTimeoutTest.java | 81 -- .../apache/qpid/transport/codec/BBEncoderTest.java | 47 - .../qpid/transport/network/TransportTest.java | 166 --- .../network/io/IdleTimeoutTickerTest.java | 250 ---- .../qpid/transport/network/io/IoAcceptor.java | 122 -- .../qpid/transport/network/io/IoTransport.java | 90 -- .../network/security/ssl/SSLUtilTest.java | 1274 -------------------- .../qpid/util/ByteBufferInputStreamTest.java | 111 -- .../apache/qpid/util/CommandLineParserTest.java | 555 --------- .../java/org/apache/qpid/util/FileUtilsTest.java | 694 ----------- .../java/org/apache/qpid/util/GZIPUtilsTest.java | 102 -- .../org/apache/qpid/util/PropertyUtilsTest.java | 43 - .../test/java/org/apache/qpid/util/SerialTest.java | 78 -- .../java/org/apache/qpid/util/StringsTest.java | 48 - .../java/org/apache/qpid/util/default.properties | 21 - .../org/apache/qpid/util/mydefaults.properties | 21 - 424 files changed, 72044 deletions(-) delete mode 100644 qpid/java/common/src/main/grammar/SelectorParser.jj delete mode 100755 qpid/java/common/src/main/java/common.bnd delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/AMQChannelClosedException.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/AMQChannelException.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/AMQConnectionClosedException.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/AMQConnectionException.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/AMQConnectionFailureException.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/AMQDisconnectedException.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/AMQException.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/AMQInternalException.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/AMQInvalidArgumentException.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/AMQInvalidRoutingKeyException.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/AMQPInvalidClassException.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/AMQProtocolException.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/AMQSecurityException.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/AMQTimeoutException.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/AMQUndeliveredException.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/AMQUnresolvedAddressException.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/api/Message.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/codec/AMQDecoder.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/codec/ClientDecoder.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/codec/MarkableDataInput.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/codec/ServerDecoder.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/common/AMQPFilterTypes.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/common/QpidProperties.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/common/ServerPropertyNames.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/configuration/Accessor.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/configuration/CommonProperties.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/configuration/Configured.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/configuration/PropertyException.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/configuration/PropertyUtils.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/configuration/QpidProperty.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/configuration/Validator.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/dtx/XidImpl.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/exchange/ExchangeDefaults.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/filter/ArithmeticExpression.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/filter/BinaryExpression.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/filter/BooleanExpression.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/filter/ComparisonExpression.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/filter/ConstantExpression.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/filter/Expression.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/filter/FilterableMessage.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/filter/LogicExpression.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/filter/PropertyExpression.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/filter/SelectorParsingException.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/filter/UnaryExpression.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/filter/selector/ParseException.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/filter/selector/SelectorParser.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/filter/selector/SelectorParserConstants.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/filter/selector/SelectorParserTokenManager.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/filter/selector/SimpleCharStream.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/filter/selector/Token.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/filter/selector/TokenMgrError.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/AMQBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlock.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/AMQFrame.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/AMQFrameDecodingException.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/AMQMethodBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/AMQMethodBodyImpl.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/AMQProtocolClassException.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/AMQProtocolHeaderException.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/AMQProtocolInstanceException.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/AMQProtocolVersionException.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/AMQShortString.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/AMQShortStringTokenizer.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/AMQType.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/AMQTypeMap.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/AMQTypedValue.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/AccessRequestBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/AccessRequestOkBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/BasicAckBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/BasicCancelBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/BasicCancelOkBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/BasicConsumeBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/BasicConsumeOkBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/BasicDeliverBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/BasicGetBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/BasicGetEmptyBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/BasicGetOkBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/BasicNackBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/BasicPublishBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/BasicQosBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/BasicQosOkBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/BasicRecoverBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/BasicRecoverSyncBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/BasicRecoverSyncOkBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/BasicRejectBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/BasicReturnBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ByteArrayDataInput.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ChannelAlertBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ChannelCloseBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ChannelCloseOkBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ChannelFlowBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ChannelFlowOkBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ChannelMethodProcessor.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ChannelOpenBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ChannelOpenOkBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ClientChannelMethodProcessor.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ClientMethodDispatcher.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ClientMethodProcessor.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/CompositeAMQDataBlock.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ConfirmSelectBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ConfirmSelectOkBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionCloseBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionCloseOkBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionOpenBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionOpenOkBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionRedirectBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionSecureBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionSecureOkBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionStartBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionStartOkBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionTuneBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionTuneOkBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ContentBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/EncodableAMQDataBlock.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ExchangeBoundBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ExchangeBoundOkBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ExchangeDeclareBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ExchangeDeclareOkBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ExchangeDeleteBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ExchangeDeleteOkBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ExtendedDataInput.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/FieldArray.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTableFactory.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/FrameCreatingMethodProcessor.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/HeartbeatBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/MessagePublishInfo.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/MethodDispatcher.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/MethodProcessor.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/MethodRegistry.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ProtocolInitiation.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ProtocolVersion.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/QueueBindBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/QueueBindOkBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/QueueDeclareBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/QueueDeclareOkBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/QueueDeleteBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/QueueDeleteOkBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/QueuePurgeBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/QueuePurgeOkBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/QueueUnbindBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/QueueUnbindOkBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ServerChannelMethodProcessor.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ServerMethodDispatcher.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/ServerMethodProcessor.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/TxCommitBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/TxCommitOkBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/TxRollbackBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/TxRollbackOkBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/TxSelectBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/framing/TxSelectOkBody.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/messaging/Address.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/messaging/util/AddressParser.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/messaging/util/JAddr.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/messaging/util/LexError.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/messaging/util/Lexer.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/messaging/util/Lexicon.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/messaging/util/LineInfo.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/messaging/util/ParseError.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/messaging/util/Parser.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/messaging/util/PyPrint.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/messaging/util/Token.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/pool/ReferenceCountingExecutorService.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/pool/SuppressingInheritedAccessControlContextThreadFactory.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQConstant.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQMethodEvent.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQMethodListener.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQProtocolWriter.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQVersionAwareProtocolSession.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/protocol/ProtocolEngine.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/protocol/ProtocolEngineFactory.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/protocol/ProtocolVersionAware.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/ssl/SSLContextFactory.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/thread/DefaultThreadFactory.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/thread/LoggingUncaughtExceptionHandler.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/thread/QpidThreadExecutor.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/thread/RealtimeThreadFactory.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/thread/ThreadFactory.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/thread/Threading.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/Acquired.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/Binary.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/Binding.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ByteBufferReceiver.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ByteBufferSender.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionClose.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionCloseCode.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionCloseOk.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionDelegate.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionException.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionHeartbeat.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionInvoker.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionListener.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionOpen.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionOpenOk.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionRedirect.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionSecure.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionSecureOk.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionSettings.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionStart.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionStartOk.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionTune.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionTuneOk.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/Constant.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/DeliveryProperties.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/DtxCommit.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/DtxEnd.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/DtxForget.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/DtxGetTimeout.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/DtxPrepare.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/DtxRecover.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/DtxRollback.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/DtxSelect.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/DtxSetTimeout.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/DtxStart.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/DtxXaStatus.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ExchangeBind.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ExchangeBound.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ExchangeBoundResult.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ExchangeDeclare.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ExchangeDelete.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ExchangeQuery.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ExchangeQueryResult.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ExchangeUnbind.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ExecutionErrorCode.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ExecutionException.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ExecutionResult.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ExecutionSync.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/Field.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/FileReturnCode.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/FragmentProperties.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/FrameSizeObserver.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/Future.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/GetTimeoutResult.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/Header.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/MessageAccept.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/MessageAcceptMode.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/MessageAcquire.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/MessageAcquireMode.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/MessageCancel.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/MessageCreditUnit.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/MessageDeliveryMode.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/MessageDeliveryPriority.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/MessageFlow.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/MessageFlowMode.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/MessageFlush.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/MessageProperties.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/MessageReject.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/MessageRejectCode.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/MessageRelease.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/MessageResume.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/MessageResumeResult.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/MessageSetFlowMode.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/MessageStop.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/MessageSubscribe.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/MessageTransfer.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/Method.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/MethodDelegate.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/NetworkEventReceiver.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/NetworkTransportConfiguration.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/Option.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolDelegate.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolError.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolEvent.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolEventReceiver.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolEventSender.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolHeader.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolVersionException.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/QueueDeclare.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/QueueDelete.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/QueuePurge.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/QueueQuery.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/QueueQueryResult.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/Range.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/RangeSet.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/RangeSetFactory.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/RangeSetImpl.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/RecoverResult.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ReplyTo.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/SegmentType.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/SenderClosedException.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/SenderException.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/ServerDelegate.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/Session.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/SessionAttach.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/SessionAttached.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/SessionClosedException.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/SessionCommandFragment.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/SessionCommandPoint.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/SessionCompleted.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/SessionConfirmed.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/SessionDelegate.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/SessionDetach.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/SessionDetachCode.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/SessionDetached.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/SessionException.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/SessionExpected.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/SessionFlush.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/SessionGap.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/SessionHeader.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/SessionInvoker.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/SessionKnownCompleted.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/SessionListener.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/SessionRequestTimeout.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/SessionTimeout.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/StreamReturnCode.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/Struct.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/StructFactory.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/Track.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/TransportException.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/TxCommit.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/TxRollback.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/TxSelect.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/Type.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/XaResult.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/Xid.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/codec/AbstractDecoder.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/codec/AbstractEncoder.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/codec/BBDecoder.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/codec/BBEncoder.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/codec/Decoder.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/codec/Encodable.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/codec/Encoder.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/network/Assembler.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/network/ConnectionBinding.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/network/Disassembler.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/network/Frame.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/network/IncomingNetworkTransport.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/network/InputHandler.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/network/NetworkConnection.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/network/NetworkDelegate.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/network/NetworkEvent.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/network/NetworkTransport.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/network/OutgoingNetworkTransport.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/network/Ticker.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/network/Transport.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/network/TransportActivity.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/network/TransportEncryption.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/AbstractNetworkTransport.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IdleTimeoutTicker.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoNetworkConnection.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoNetworkTransport.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoReceiver.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoSender.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/SSLStatus.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/SecurityLayer.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/SecurityLayerFactory.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLEncryptor.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLReceiver.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLSender.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/QpidClientX509KeyManager.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/QpidMultipleTrustManager.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/QpidPeersOnlyTrustManager.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLBufferingSender.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLReceiver.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLSender.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLUtil.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/util/Functions.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/util/Logger.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/transport/util/Waiter.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/typedmessage/TypedBytesCodes.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/typedmessage/TypedBytesContentReader.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/typedmessage/TypedBytesContentWriter.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/typedmessage/TypedBytesFormatException.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/url/AMQBindingURL.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/url/BindingURL.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/url/BindingURLParser.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/url/URLHelper.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/url/URLSyntaxException.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/util/ByteBufferInputStream.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/util/BytesDataOutput.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/util/CommandLineParser.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/util/DataUrlUtils.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/util/GZIPUtils.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/util/NameUUIDGen.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/util/RandomUUIDGen.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/util/Serial.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/util/Strings.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/util/SystemUtils.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/util/UUIDGen.java delete mode 100644 qpid/java/common/src/main/java/org/apache/qpid/util/UUIDs.java delete mode 100644 qpid/java/common/src/main/resources/qpidversion.properties delete mode 100644 qpid/java/common/src/test/java/org/apache/qpid/AMQExceptionTest.java delete mode 100644 qpid/java/common/src/test/java/org/apache/qpid/codec/AMQDecoderTest.java delete mode 100644 qpid/java/common/src/test/java/org/apache/qpid/configuration/QpidPropertyTest.java delete mode 100644 qpid/java/common/src/test/java/org/apache/qpid/framing/AMQShortStringTest.java delete mode 100644 qpid/java/common/src/test/java/org/apache/qpid/framing/BasicContentHeaderPropertiesTest.java delete mode 100644 qpid/java/common/src/test/java/org/apache/qpid/framing/FieldTableTest.java delete mode 100644 qpid/java/common/src/test/java/org/apache/qpid/framing/abstraction/MessagePublishInfoImplTest.java delete mode 100644 qpid/java/common/src/test/java/org/apache/qpid/pool/ReferenceCountingExecutorServiceTest.java delete mode 100644 qpid/java/common/src/test/java/org/apache/qpid/pool/SuppressingInheritedAccessControlContextThreadFactoryTest.java delete mode 100644 qpid/java/common/src/test/java/org/apache/qpid/ssl/SSLContextFactoryTest.java delete mode 100644 qpid/java/common/src/test/java/org/apache/qpid/ssl/TrustManagerTest.java delete mode 100644 qpid/java/common/src/test/java/org/apache/qpid/thread/ThreadFactoryTest.java delete mode 100644 qpid/java/common/src/test/java/org/apache/qpid/transport/ConnectionSettingsTest.java delete mode 100644 qpid/java/common/src/test/java/org/apache/qpid/transport/ConnectionTest.java delete mode 100644 qpid/java/common/src/test/java/org/apache/qpid/transport/GenTest.java delete mode 100644 qpid/java/common/src/test/java/org/apache/qpid/transport/RangeSetTest.java delete mode 100644 qpid/java/common/src/test/java/org/apache/qpid/transport/SessionTimeoutTest.java delete mode 100644 qpid/java/common/src/test/java/org/apache/qpid/transport/codec/BBEncoderTest.java delete mode 100644 qpid/java/common/src/test/java/org/apache/qpid/transport/network/TransportTest.java delete mode 100644 qpid/java/common/src/test/java/org/apache/qpid/transport/network/io/IdleTimeoutTickerTest.java delete mode 100644 qpid/java/common/src/test/java/org/apache/qpid/transport/network/io/IoAcceptor.java delete mode 100644 qpid/java/common/src/test/java/org/apache/qpid/transport/network/io/IoTransport.java delete mode 100644 qpid/java/common/src/test/java/org/apache/qpid/transport/network/security/ssl/SSLUtilTest.java delete mode 100644 qpid/java/common/src/test/java/org/apache/qpid/util/ByteBufferInputStreamTest.java delete mode 100644 qpid/java/common/src/test/java/org/apache/qpid/util/CommandLineParserTest.java delete mode 100644 qpid/java/common/src/test/java/org/apache/qpid/util/FileUtilsTest.java delete mode 100644 qpid/java/common/src/test/java/org/apache/qpid/util/GZIPUtilsTest.java delete mode 100644 qpid/java/common/src/test/java/org/apache/qpid/util/PropertyUtilsTest.java delete mode 100644 qpid/java/common/src/test/java/org/apache/qpid/util/SerialTest.java delete mode 100644 qpid/java/common/src/test/java/org/apache/qpid/util/StringsTest.java delete mode 100644 qpid/java/common/src/test/java/org/apache/qpid/util/default.properties delete mode 100644 qpid/java/common/src/test/java/org/apache/qpid/util/mydefaults.properties (limited to 'qpid/java/common/src') diff --git a/qpid/java/common/src/main/grammar/SelectorParser.jj b/qpid/java/common/src/main/grammar/SelectorParser.jj deleted file mode 100644 index ec3a27142f..0000000000 --- a/qpid/java/common/src/main/grammar/SelectorParser.jj +++ /dev/null @@ -1,612 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - // - // Original File from r450141 of the Apache ActiveMQ project - // - -// ---------------------------------------------------------------------------- -// OPTIONS -// ---------------------------------------------------------------------------- -options { - STATIC = false; - UNICODE_INPUT = true; - - // some performance optimizations - ERROR_REPORTING = false; -} - -// ---------------------------------------------------------------------------- -// PARSER -// ---------------------------------------------------------------------------- - -PARSER_BEGIN(SelectorParser) -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.qpid.filter.selector; - -import java.io.StringReader; -import java.util.ArrayList; - -import org.apache.qpid.filter.ArithmeticExpression; -import org.apache.qpid.filter.BooleanExpression; -import org.apache.qpid.filter.ComparisonExpression; -import org.apache.qpid.filter.ConstantExpression; -import org.apache.qpid.filter.Expression; -import org.apache.qpid.filter.LogicExpression; -import org.apache.qpid.filter.PropertyExpression; -import org.apache.qpid.filter.UnaryExpression; - -/** - * JMS Selector Parser generated by JavaCC - * - * Do not edit this .java file directly - it is autogenerated from SelectorParser.jj - */ -public class SelectorParser -{ - - public SelectorParser() - { - this(new StringReader("")); - } - - public BooleanExpression parse(String sql) throws ParseException - { - this.ReInit(new StringReader(sql)); - - return this.JmsSelector(); - - } - - private BooleanExpression asBooleanExpression(Expression value) throws ParseException - { - if (value instanceof BooleanExpression) - { - return (BooleanExpression) value; - } - if (value instanceof PropertyExpression) - { - return UnaryExpression.createBooleanCast( value ); - } - throw new ParseException("Expression will not result in a boolean value: " + value); - } - - -} - -PARSER_END(SelectorParser) - -// ---------------------------------------------------------------------------- -// Tokens -// ---------------------------------------------------------------------------- - -/* White Space */ -SPECIAL_TOKEN : -{ - " " | "\t" | "\n" | "\r" | "\f" -} - -/* Comments */ -SKIP: -{ - -} - -SKIP: -{ - -} - -/* Reserved Words */ -TOKEN [IGNORE_CASE] : -{ - < NOT : "NOT"> - | < AND : "AND"> - | < OR : "OR"> - | < BETWEEN : "BETWEEN"> - | < LIKE : "LIKE"> - | < ESCAPE : "ESCAPE"> - | < IN : "IN"> - | < IS : "IS"> - | < TRUE : "TRUE" > - | < FALSE : "FALSE" > - | < NULL : "NULL" > -} - -/* Literals */ -TOKEN [IGNORE_CASE] : -{ - - < DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* (["l","L"])? > - | < HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ > - | < OCTAL_LITERAL: "0" (["0"-"7"])* > - | < FLOATING_POINT_LITERAL: - (["0"-"9"])+ "." (["0"-"9"])* ()? // matches: 5.5 or 5. or 5.5E10 or 5.E10 - | "." (["0"-"9"])+ ()? // matches: .5 or .5E10 - | (["0"-"9"])+ // matches: 5E10 - > - | < #EXPONENT: "E" (["+","-"])? (["0"-"9"])+ > - | < STRING_LITERAL: "'" ( ("''") | ~["'"] )* "'" > -} - -TOKEN [IGNORE_CASE] : -{ - < ID : ["a"-"z", "_", "$"] (["a"-"z","0"-"9","_", "$"])* > - | < QUOTED_ID : "\"" ( ("\"\"") | ~["\""] )* "\"" > -} - -// ---------------------------------------------------------------------------- -// Grammer -// ---------------------------------------------------------------------------- -BooleanExpression JmsSelector() : -{ - Expression left=null; -} -{ - ( - left = orExpression() - ) - { - return asBooleanExpression(left); - } - -} - -Expression orExpression() : -{ - Expression left; - Expression right; -} -{ - ( - left = andExpression() - ( - right = andExpression() - { - left = LogicExpression.createOR(asBooleanExpression(left), asBooleanExpression(right)); - } - )* - ) - { - return left; - } - -} - - -Expression andExpression() : -{ - Expression left; - Expression right; -} -{ - ( - left = equalityExpression() - ( - right = equalityExpression() - { - left = LogicExpression.createAND(asBooleanExpression(left), asBooleanExpression(right)); - } - )* - ) - { - return left; - } -} - -Expression equalityExpression() : -{ - Expression left; - Expression right; -} -{ - ( - left = comparisonExpression() - ( - - "=" right = comparisonExpression() - { - left = ComparisonExpression.createEqual(left, right); - } - | - "<>" right = comparisonExpression() - { - left = ComparisonExpression.createNotEqual(left, right); - } - | - LOOKAHEAD(2) - - { - left = ComparisonExpression.createIsNull(left); - } - | - - { - left = ComparisonExpression.createIsNotNull(left); - } - )* - ) - { - return left; - } -} - -Expression comparisonExpression() : -{ - Expression left; - Expression right; - Expression low; - Expression high; - String t, u; - boolean not; - ArrayList list; -} -{ - ( - left = addExpression() - ( - - ">" right = addExpression() - { - left = ComparisonExpression.createGreaterThan(left, right); - } - | - ">=" right = addExpression() - { - left = ComparisonExpression.createGreaterThanEqual(left, right); - } - | - "<" right = addExpression() - { - left = ComparisonExpression.createLessThan(left, right); - } - | - "<=" right = addExpression() - { - left = ComparisonExpression.createLessThanEqual(left, right); - } - | - { - u=null; - } - t = stringLiteral() - [ u = stringLiteral() ] - { - left = ComparisonExpression.createLike(left, t, u); - } - | - LOOKAHEAD(2) - { - u=null; - } - t = stringLiteral() [ u = stringLiteral() ] - { - left = ComparisonExpression.createNotLike(left, t, u); - } - | - low = addExpression() high = addExpression() - { - left = ComparisonExpression.createBetween(left, low, high); - } - | - LOOKAHEAD(2) - low = addExpression() high = addExpression() - { - left = ComparisonExpression.createNotBetween(left, low, high); - } - | - - "(" - t = stringLiteral() - { - list = new ArrayList(); - list.add( t ); - } - ( - "," - t = stringLiteral() - { - list.add( t ); - } - - )* - ")" - { - left = ComparisonExpression.createInFilter(left, list); - } - | - LOOKAHEAD(2) - - "(" - t = stringLiteral() - { - list = new ArrayList(); - list.add( t ); - } - ( - "," - t = stringLiteral() - { - list.add( t ); - } - - )* - ")" - { - left = ComparisonExpression.createNotInFilter(left, list); - } - - )* - ) - { - return left; - } -} - -Expression addExpression() : -{ - Expression left; - Expression right; -} -{ - left = multExpr() - ( - LOOKAHEAD( ("+"|"-") multExpr()) - ( - "+" right = multExpr() - { - left = ArithmeticExpression.createPlus(left, right); - } - | - "-" right = multExpr() - { - left = ArithmeticExpression.createMinus(left, right); - } - ) - - )* - { - return left; - } -} - -Expression multExpr() : -{ - Expression left; - Expression right; -} -{ - left = unaryExpr() - ( - "*" right = unaryExpr() - { - left = ArithmeticExpression.createMultiply(left, right); - } - | - "/" right = unaryExpr() - { - left = ArithmeticExpression.createDivide(left, right); - } - | - "%" right = unaryExpr() - { - left = ArithmeticExpression.createMod(left, right); - } - - )* - { - return left; - } -} - - -Expression unaryExpr() : -{ - String s=null; - Expression left=null; -} -{ - ( - LOOKAHEAD( "+" unaryExpr() ) - "+" left=unaryExpr() - | - "-" left=unaryExpr() - { - left = UnaryExpression.createNegate(left); - } - | - left=unaryExpr() - { - left = UnaryExpression.createNOT( asBooleanExpression(left) ); - } - | - left = primaryExpr() - ) - { - return left; - } - -} - -Expression primaryExpr() : -{ - Expression left=null; -} -{ - ( - left = literal() - | - left = variable() - | - "(" left = orExpression() ")" - ) - { - return left; - } -} - - - -ConstantExpression literal() : -{ - Token t; - String s; - ConstantExpression left=null; -} -{ - ( - ( - s = stringLiteral() - { - left = new ConstantExpression(s); - } - ) - | - ( - t = - { - left = ConstantExpression.createFromDecimal(t.image); - } - ) - | - ( - t = - { - left = ConstantExpression.createFromHex(t.image); - } - ) - | - ( - t = - { - left = ConstantExpression.createFromOctal(t.image); - } - ) - | - ( - t = - { - left = ConstantExpression.createFloat(t.image); - } - ) - | - ( - - { - left = ConstantExpression.TRUE; - } - ) - | - ( - - { - left = ConstantExpression.FALSE; - } - ) - | - ( - - { - left = ConstantExpression.NULL; - } - ) - ) - { - return left; - } -} - -String stringLiteral() : -{ - Token t; - StringBuffer rc = new StringBuffer(); - boolean first=true; -} -{ - t = - { - // Decode the sting value. - String image = t.image; - for( int i=1; i < image.length()-1; i++ ) { - char c = image.charAt(i); - if( c == (char) 0x27 )//single quote - { - i++; - } - rc.append(c); - } - return rc.toString(); - } -} - -PropertyExpression variable() : -{ - Token t; - StringBuffer rc = new StringBuffer(); - PropertyExpression left=null; -} -{ - ( - t = - { - left = new PropertyExpression(t.image); - } - | - t = - { - // Decode the sting value. - String image = t.image; - for( int i=1; i < image.length()-1; i++ ) { - char c = image.charAt(i); - if( c == '"' ) - { - i++; - } - rc.append(c); - } - return new PropertyExpression(rc.toString()); - } - - - ) - { - return left; - } -} diff --git a/qpid/java/common/src/main/java/common.bnd b/qpid/java/common/src/main/java/common.bnd deleted file mode 100755 index cf06218370..0000000000 --- a/qpid/java/common/src/main/java/common.bnd +++ /dev/null @@ -1,25 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -ver: 0.31.0 - -Bundle-SymbolicName: qpid-common -Bundle-Version: ${ver} -Export-Package: *;version=${ver} -Bundle-RequiredExecutionEnvironment: J2SE-1.5 diff --git a/qpid/java/common/src/main/java/org/apache/qpid/AMQChannelClosedException.java b/qpid/java/common/src/main/java/org/apache/qpid/AMQChannelClosedException.java deleted file mode 100644 index 73a906b81c..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/AMQChannelClosedException.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid; - -import org.apache.qpid.protocol.AMQConstant; - -/** - * AMQChannelClosedException indicates that an operation cannot be performed becauase a channel has been closed. - */ -public class AMQChannelClosedException extends AMQException -{ - public AMQChannelClosedException(AMQConstant errorCode, String msg, Throwable cause) - { - super(errorCode, msg, cause); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/AMQChannelException.java b/qpid/java/common/src/main/java/org/apache/qpid/AMQChannelException.java deleted file mode 100644 index 7ab422eb4f..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/AMQChannelException.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid; - -import org.apache.qpid.framing.MethodRegistry; -import org.apache.qpid.protocol.AMQConstant; - -/** - * AMQChannelException indicates that an error that requires the channel to be closed has occurred. - */ -public class AMQChannelException extends AMQException -{ - private final int _classId; - private final int _methodId; - /* AMQP version for which exception ocurred */ - private final MethodRegistry _methodRegistry; - - - public AMQChannelException(AMQConstant errorCode, - String msg, - int classId, - int methodId, - MethodRegistry methodRegistry) - { - super(errorCode, msg); - _classId = classId; - _methodId = methodId; - _methodRegistry = methodRegistry; - - } - - public int getClassId() - { - return _classId; - } - - public int getMethodId() - { - return _methodId; - } - - public MethodRegistry getMethodRegistry() - { - return _methodRegistry; - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/AMQConnectionClosedException.java b/qpid/java/common/src/main/java/org/apache/qpid/AMQConnectionClosedException.java deleted file mode 100644 index 4417c0a141..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/AMQConnectionClosedException.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid; - -import org.apache.qpid.protocol.AMQConstant; - -/** - * AMQConnectionClosedException indicates that a connection has been closed. - * - *

This exception is really used as an event, in order that the method handler that raises it creates an event - * which is propagated to the io handler, in order to notify it of the connection closure. - */ -public class AMQConnectionClosedException extends AMQException -{ - public AMQConnectionClosedException(AMQConstant errorCode, String msg, Throwable cause) - { - super(errorCode, msg, cause); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/AMQConnectionException.java b/qpid/java/common/src/main/java/org/apache/qpid/AMQConnectionException.java deleted file mode 100644 index ca70d19420..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/AMQConnectionException.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.qpid; - -import org.apache.qpid.framing.AMQFrame; -import org.apache.qpid.framing.AMQMethodBody; -import org.apache.qpid.framing.AMQShortString; -import org.apache.qpid.framing.MethodRegistry; -import org.apache.qpid.protocol.AMQConstant; - -/** - * AMQConnectionException indicates that an error that requires the channel to be closed has occurred. - */ -public class AMQConnectionException extends AMQException -{ - private final int _classId; - private final int _methodId; - - private final MethodRegistry _methodRegistry; - - public AMQConnectionException(AMQConstant errorCode, String msg, AMQMethodBody body, MethodRegistry methodRegistry) - { - this(errorCode, msg, body.getClazz(), body.getMethod(), methodRegistry, null); - } - - public AMQConnectionException(AMQConstant errorCode, String msg, int classId, int methodId, MethodRegistry methodRegistry, - Throwable cause) - { - super(errorCode, msg, cause); - _classId = classId; - _methodId = methodId; - _methodRegistry = methodRegistry; - - } - - public AMQFrame getCloseFrame() - { - return new AMQFrame(0, - _methodRegistry.createConnectionCloseBody(getErrorCode().getCode(), - AMQShortString.validValueOf(getMessage()), - _classId, - _methodId)); - - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/AMQConnectionFailureException.java b/qpid/java/common/src/main/java/org/apache/qpid/AMQConnectionFailureException.java deleted file mode 100644 index efadaae611..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/AMQConnectionFailureException.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid; - -import org.apache.qpid.protocol.AMQConstant; - -import java.util.Collection; - -/** - * AMQConnectionFailureException indicates that a connection to a broker could not be formed. - */ -public class AMQConnectionFailureException extends AMQException -{ - private Collection _exceptions; - - public AMQConnectionFailureException(String message, Throwable cause) - { - super(cause instanceof AMQException ? ((AMQException) cause).getErrorCode() : null, message, cause); - } - - public AMQConnectionFailureException(AMQConstant errorCode, String message, Throwable cause) - { - super(errorCode, message, cause); - } - - public AMQConnectionFailureException(String message, Collection exceptions) - { - // Blah, I hate ? but java won't let super() be anything other than the first thing, sorry... - super (null, message, exceptions.isEmpty() ? null : exceptions.iterator().next()); - this._exceptions = exceptions; - } - - public Collection getLinkedExceptions() - { - return _exceptions; - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/AMQDisconnectedException.java b/qpid/java/common/src/main/java/org/apache/qpid/AMQDisconnectedException.java deleted file mode 100644 index 38fbc8fc57..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/AMQDisconnectedException.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid; - -/** - * AMQDisconnectedException indicates that a broker disconnected without failover. - */ -public class AMQDisconnectedException extends AMQException -{ - public AMQDisconnectedException(String msg, Throwable cause) - { - super(null, msg, cause); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/AMQException.java b/qpid/java/common/src/main/java/org/apache/qpid/AMQException.java deleted file mode 100644 index 7d2521a057..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/AMQException.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid; - -import org.apache.qpid.protocol.AMQConstant; - -/** - * AMQException forms the root exception of all exceptions relating to the AMQ protocol. It provides space to associate - * a required AMQ error code with the exception, which is a numeric value, with a meaning defined by the protocol. - */ -public class AMQException extends Exception -{ - /** Holds the AMQ error code constant associated with this exception. */ - private AMQConstant _errorCode; - - private boolean _isHardError; - - /** - * Creates an exception with an optional error code, optional message and optional underlying cause. - * - * @param errorCode The error code. May be null if not to be set. - * @param msg The exception message. May be null if not to be set. - * @param cause The underlying cause of the exception. May be null if not to be set. - */ - public AMQException(AMQConstant errorCode, String msg, Throwable cause) - { - // isHardError is defaulted to true to avoid unnessacery modification to - // existing code. - this(errorCode,true,msg,cause); - } - - /** - * Creates an exception with an optional error code, optional message and optional underlying cause. - * - * @param errorCode The error code. May be null if not to be set. - * @param isHardError Denotes if the underlying error is considered a hard error. - * @param msg The exception message. May be null if not to be set. - * @param cause The underlying cause of the exception. May be null if not to be set. - */ - public AMQException(AMQConstant errorCode, boolean isHardError, String msg, Throwable cause) - { - super(((msg == null) ? "" : msg), cause); - _errorCode = errorCode; - _isHardError = isHardError; - } - - /* - * Deprecated constructors brought from M2.1 - */ - @Deprecated - public AMQException(String msg) - { - this(null, (msg == null) ? "" : msg); - } - - public AMQException(AMQConstant errorCode, String msg) - { - this(errorCode, (msg == null) ? "" : msg, null); - } - - @Deprecated - public AMQException(String msg, Throwable cause) - { - this(null, msg, cause); - } - - @Override - public String toString() - { - return getClass().getName() + ": " + getMessage() + (_errorCode == null ? "" : " [error code " + _errorCode + "]"); - } - - /** - * Gets the AMQ protocol exception code associated with this exception. - * - * @return The AMQ protocol exception code associated with this exception. - */ - public AMQConstant getErrorCode() - { - return _errorCode; - } - - public boolean isHardError() - { - return _isHardError; - } - - /** - * Rethrown this exception as a new exception. - * - * Attempt to create a new exception of the same class if they have the default constructor of: - * {AMQConstant.class, String.class, Throwable.class}. - * - * @return cloned exception - */ - public AMQException cloneForCurrentThread() - { - Class amqeClass = this.getClass(); - Class[] paramClasses = {AMQConstant.class, String.class, Throwable.class}; - Object[] params = {getErrorCode(), getMessage(), this}; - - AMQException newAMQE; - - try - { - newAMQE = (AMQException) amqeClass.getConstructor(paramClasses).newInstance(params); - } - catch (Exception creationException) - { - newAMQE = new AMQException(getErrorCode(), getMessage(), this); - } - - return newAMQE; - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/AMQInternalException.java b/qpid/java/common/src/main/java/org/apache/qpid/AMQInternalException.java deleted file mode 100644 index 59dc800c0e..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/AMQInternalException.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid; - -import org.apache.qpid.protocol.AMQConstant; - -/** - * InternalException encapsulates error code 541, or {@link AMQConstant#INTERNAL_ERROR} exceptions relating to the - * AMQ protocol. It is used to report internal failures and errors that occur within the broker. - */ -public class AMQInternalException extends AMQException -{ - /** serialVersionUID */ - private static final long serialVersionUID = 2544449432843381112L; - - /** - * Creates an exception with an optional message and optional underlying cause. - * - * @param msg The exception message. May be null if not to be set. - * @param cause The underlying cause of the exception. May be null if not to be set. - */ - public AMQInternalException(String msg, Throwable cause) - { - super(AMQConstant.INTERNAL_ERROR, ((msg == null) ? "Internal error" : msg), cause); - } - - public AMQInternalException(String msg) - { - this(msg, null); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/AMQInvalidArgumentException.java b/qpid/java/common/src/main/java/org/apache/qpid/AMQInvalidArgumentException.java deleted file mode 100644 index 2592ab7662..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/AMQInvalidArgumentException.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - * - */ -package org.apache.qpid; - -import org.apache.qpid.protocol.AMQConstant; - -/** - * AMQInvalidArgumentException indicates that an invalid argument has been passed to an AMQP method. - */ -public class AMQInvalidArgumentException extends AMQException -{ - public AMQInvalidArgumentException(String message, Throwable cause) - { - super(AMQConstant.ARGUMENT_INVALID, message, cause); - } - - public boolean isHardError() - { - return false; - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/AMQInvalidRoutingKeyException.java b/qpid/java/common/src/main/java/org/apache/qpid/AMQInvalidRoutingKeyException.java deleted file mode 100644 index d0a61cfeeb..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/AMQInvalidRoutingKeyException.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - * - */ -package org.apache.qpid; - -import org.apache.qpid.protocol.AMQConstant; - -/** - * AMQInvalidRoutingKeyException indicates an error with a routing key having an invalid format. - */ -public class AMQInvalidRoutingKeyException extends AMQException -{ - public AMQInvalidRoutingKeyException(String message, Throwable cause) - { - super(AMQConstant.INVALID_ROUTING_KEY, message, cause); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/AMQPInvalidClassException.java b/qpid/java/common/src/main/java/org/apache/qpid/AMQPInvalidClassException.java deleted file mode 100644 index 533a704a80..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/AMQPInvalidClassException.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - * - */ -package org.apache.qpid; - -/** - * AMQPInvalidClassException indicates an error when trying to store an illegally typed argument in a field table. - * - *

TODO Could just re-use an exising exception like IllegalArgumentException or ClassCastException. - */ -public class AMQPInvalidClassException extends RuntimeException -{ - /** Error message text when trying to store an unsupported class or null object */ - public static final String INVALID_OBJECT_MSG = "Only Primitive objects allowed. Object is: "; - - public AMQPInvalidClassException(String s) - { - super(s); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/AMQProtocolException.java b/qpid/java/common/src/main/java/org/apache/qpid/AMQProtocolException.java deleted file mode 100644 index 7744b128ce..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/AMQProtocolException.java +++ /dev/null @@ -1,39 +0,0 @@ -/* -* Licensed to the Apache Software Foundation (ASF) under one -* or more contributor license agreements. See the NOTICE file -* distributed with this work for additional information -* regarding copyright ownership. The ASF licenses this file -* to you under the Apache License, Version 2.0 (the -* "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ -package org.apache.qpid; - -import org.apache.qpid.protocol.AMQConstant; - - -public class AMQProtocolException extends AMQException -{ - /** - * Constructor for a Protocol Exception - *

This is the only provided constructor and the parameters have to be - * set to null when they are unknown. - * - * @param msg A description of the reason of this exception . - * @param errorCode A string specifyin the error code of this exception. - * @param cause The linked Execption. - */ - public AMQProtocolException(AMQConstant errorCode, String msg, Throwable cause) - { - super(errorCode, msg, cause); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/AMQSecurityException.java b/qpid/java/common/src/main/java/org/apache/qpid/AMQSecurityException.java deleted file mode 100644 index d145d2c21d..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/AMQSecurityException.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid; - -import org.apache.qpid.protocol.AMQConstant; - -/** - * SecurityException encapsulates error code 403, or {@link AMQConstant#ACCESS_REFUSED} exceptions relating to the - * AMQ protocol. It is used to report authorisation failures and security errors. - */ -public class AMQSecurityException extends AMQException -{ - /** serialVersionUID */ - private static final long serialVersionUID = 8862069852716968394L; - - /** - * Creates an exception with an optional message and optional underlying cause. - * - * @param msg The exception message. May be null if not to be set. - * @param cause The underlying cause of the exception. May be null if not to be set. - */ - public AMQSecurityException(String msg, Throwable cause) - { - super(AMQConstant.ACCESS_REFUSED, ((msg == null) ? "Permission denied" : msg), cause); - } - - public AMQSecurityException(String msg) - { - this(msg, null); - } - - public AMQSecurityException() - { - this(null); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/AMQTimeoutException.java b/qpid/java/common/src/main/java/org/apache/qpid/AMQTimeoutException.java deleted file mode 100644 index c36d2c5907..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/AMQTimeoutException.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - * - */ -package org.apache.qpid; - -import org.apache.qpid.protocol.AMQConstant; - -/** - * AMQTimeoutException indicates that an expected response from a broker took too long. - */ -public class AMQTimeoutException extends AMQException -{ - public AMQTimeoutException(String message, Throwable cause) - { - super(AMQConstant.REQUEST_TIMEOUT, message, cause); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/AMQUndeliveredException.java b/qpid/java/common/src/main/java/org/apache/qpid/AMQUndeliveredException.java deleted file mode 100644 index 68cbc57216..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/AMQUndeliveredException.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid; - -import org.apache.qpid.protocol.AMQConstant; - -/** - * AMQUndeliveredException indicates that a message, marked immediate or mandatory, could not be delivered. - */ -public class AMQUndeliveredException extends AMQException -{ - private Object _bounced; - - public AMQUndeliveredException(AMQConstant errorCode, String msg, Object bounced, Throwable cause) - { - super(errorCode, msg, cause); - - _bounced = bounced; - } - - public Object getUndeliveredMessage() - { - return _bounced; - } - - public boolean isHardError() - { - return false; - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/AMQUnresolvedAddressException.java b/qpid/java/common/src/main/java/org/apache/qpid/AMQUnresolvedAddressException.java deleted file mode 100644 index 902b12300f..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/AMQUnresolvedAddressException.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid; - -/** - * AMQUnresolvedAddressException indicates failure to resolve a socket address. - *

- * TODO Not an AMQP exception as no status code. - *

- * TODO Why replace java.nio.UnresolvedAddressException with this? This is checked, which may explain why, but it - * doesn't wrap the underlying exception. - */ -public class AMQUnresolvedAddressException extends AMQException -{ - private String _broker; - - public AMQUnresolvedAddressException(String message, String broker, Throwable cause) - { - super(null, message, cause); - _broker = broker; - } - - public String toString() - { - return super.toString() + " Broker, \"" + _broker + "\""; - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/api/Message.java b/qpid/java/common/src/main/java/org/apache/qpid/api/Message.java deleted file mode 100644 index fff62424ca..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/api/Message.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.qpid.api; - -import org.apache.qpid.transport.DeliveryProperties; -import org.apache.qpid.transport.Header; -import org.apache.qpid.transport.MessageProperties; - -import java.io.IOException; -import java.nio.ByteBuffer; - -public interface Message -{ - public Header getHeader(); - - public void setHeader(Header header); - - public MessageProperties getMessageProperties(); - - public DeliveryProperties getDeliveryProperties(); - - /** - * This will abstract the underlying message data. - * The Message implementation may not hold all message - * data in memory (especially in the case of large messages) - * - * The appendData function might write data to - *

    - *
  • Memory (Ex: ByteBuffer) - *
  • To Disk - *
  • To Socket (Stream) - *
- * @param src - the data to append - * @throws IOException if there is an issue appending the data - */ - public void appendData(byte[] src) throws IOException; - - - /** - * This will abstract the underlying message data. - * The Message implementation may not hold all message - * data in memory (especially in the case of large messages) - * - * The appendData function might write data to - *
    - *
  • Memory (Ex: ByteBuffer) - *
  • To Disk - *
  • To Socket (Stream) - *
- * @param src - the data to append - * @throws IOException if there is an issue appending the data - */ - public void appendData(ByteBuffer src) throws IOException; - - /** - * This will abstract the underlying message data. - * The Message implementation may not hold all message - * data in memory (especially in the case of large messages) - * - * The read function might copy data from - *
    - *
  • From memory (Ex: ByteBuffer) - *
  • From Disk - *
  • From Socket as and when it gets streamed - *
- * @param target The target byte[] which the data gets copied to - * @throws IOException if there is an issue reading the data - */ - public void readData(byte[] target) throws IOException; - - /** - * * This will abstract the underlying message data. - * The Message implementation may not hold all message - * data in memory (especially in the case of large messages) - * - * The read function might copy data from - *
    - *
  • From memory (Ex: ByteBuffer) - *
  • From Disk - *
  • From Socket as and when it gets streamed - *
- * - * @return A ByteBuffer containing data - * @throws IOException if there is an issue reading the data - */ - public ByteBuffer readData() throws IOException; - - /** - * This should clear the body of the message. - */ - public void clearData(); - - /** - * The provides access to the command Id assigned to the - * message transfer. - * This id is useful when you do - *
    - *
  • For message acquiring - If the transfer happend in no-acquire mode - * you could use this id to accquire it. - *
  • For releasing a message. You can use this id to release an acquired - * message - *
  • For Acknowledging a message - You need to pass this ID, in order to - * acknowledge the message - *
  • For Rejecting a message - You need to pass this ID, in order to reject - * the message. - *
- * - * @return the message transfer id. - */ - public int getMessageTransferId(); - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/codec/AMQDecoder.java b/qpid/java/common/src/main/java/org/apache/qpid/codec/AMQDecoder.java deleted file mode 100644 index 9bafc30ebc..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/codec/AMQDecoder.java +++ /dev/null @@ -1,425 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.codec; - -import java.io.ByteArrayInputStream; -import java.io.DataInput; -import java.io.DataInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; -import java.util.ListIterator; - -import org.apache.qpid.framing.*; -import org.apache.qpid.protocol.AMQConstant; - -/** - * AMQDecoder delegates the decoding of AMQP either to a data block decoder, or in the case of new connections, to a - * protocol initiation decoder. It is a cumulative decoder, which means that it can accumulate data to decode in the - * buffer until there is enough data to decode. - * - *

One instance of this class is created per session, so any changes or configuration done at run time to the - * decoder will only affect decoding of the protocol session data to which is it bound. - * - *

- * TODO If protocol initiation decoder not needed, then don't create it. Probably not a big deal, but it adds to the - * per-session overhead. - */ -public abstract class AMQDecoder -{ - private static final int MAX_BUFFERS_LIMIT = 10; - private final T _methodProcessor; - - /** Holds the protocol initiation decoder. */ - private ProtocolInitiation.Decoder _piDecoder = new ProtocolInitiation.Decoder(); - - /** Flag to indicate whether this decoder needs to handle protocol initiation. */ - private boolean _expectProtocolInitiation; - - - private boolean _firstRead = true; - - private int _maxFrameSize = AMQConstant.FRAME_MIN_SIZE.getCode(); - - private List _remainingBufs = new ArrayList(); - - /** - * Creates a new AMQP decoder. - * - * @param expectProtocolInitiation true if this decoder needs to handle protocol initiation. - * @param methodProcessor method processor - */ - protected AMQDecoder(boolean expectProtocolInitiation, T methodProcessor) - { - _expectProtocolInitiation = expectProtocolInitiation; - _methodProcessor = methodProcessor; - } - - - /** - * Sets the protocol initation flag, that determines whether decoding is handled by the data decoder of the protocol - * initation decoder. This method is expected to be called with false once protocol initation completes. - * - * @param expectProtocolInitiation true to use the protocol initiation decoder, false to use the - * data decoder. - */ - public void setExpectProtocolInitiation(boolean expectProtocolInitiation) - { - _expectProtocolInitiation = expectProtocolInitiation; - } - - public void setMaxFrameSize(final int frameMax) - { - _maxFrameSize = frameMax; - } - - public T getMethodProcessor() - { - return _methodProcessor; - } - - private class RemainingByteArrayInputStream extends InputStream - { - private int _currentListPos; - private int _markPos; - - - @Override - public int read() throws IOException - { - ByteArrayInputStream currentStream = _remainingBufs.get(_currentListPos); - if(currentStream.available() > 0) - { - return currentStream.read(); - } - else if((_currentListPos == _remainingBufs.size()) - || (++_currentListPos == _remainingBufs.size())) - { - return -1; - } - else - { - - ByteArrayInputStream stream = _remainingBufs.get(_currentListPos); - stream.mark(0); - return stream.read(); - } - } - - @Override - public int read(final byte[] b, final int off, final int len) throws IOException - { - - if(_currentListPos == _remainingBufs.size()) - { - return -1; - } - else - { - ByteArrayInputStream currentStream = _remainingBufs.get(_currentListPos); - final int available = currentStream.available(); - int read = currentStream.read(b, off, len > available ? available : len); - if(read < len) - { - if(_currentListPos++ != _remainingBufs.size()) - { - _remainingBufs.get(_currentListPos).mark(0); - } - int correctRead = read == -1 ? 0 : read; - int subRead = read(b, off+correctRead, len-correctRead); - if(subRead == -1) - { - return read; - } - else - { - return correctRead+subRead; - } - } - else - { - return len; - } - } - } - - @Override - public int available() throws IOException - { - int total = 0; - for(int i = _currentListPos; i < _remainingBufs.size(); i++) - { - total += _remainingBufs.get(i).available(); - } - return total; - } - - @Override - public void mark(final int readlimit) - { - _markPos = _currentListPos; - final ByteArrayInputStream stream = _remainingBufs.get(_currentListPos); - if(stream != null) - { - stream.mark(readlimit); - } - } - - @Override - public void reset() throws IOException - { - _currentListPos = _markPos; - final int size = _remainingBufs.size(); - if(_currentListPos < size) - { - _remainingBufs.get(_currentListPos).reset(); - } - for(int i = _currentListPos+1; i 8) - { - _expectProtocolInitiation = true; - } - } - - boolean enoughData = true; - while (enoughData) - { - if(!_expectProtocolInitiation) - { - enoughData = decodable(msg); - if (enoughData) - { - processInput(msg); - } - } - else - { - enoughData = _piDecoder.decodable(msg); - if (enoughData) - { - _methodProcessor.receiveProtocolHeader(new ProtocolInitiation(msg)); - } - - } - - if(!enoughData) - { - if(!_remainingBufs.isEmpty()) - { - _remainingBufs.remove(_remainingBufs.size()-1); - ListIterator iterator = _remainingBufs.listIterator(); - while(iterator.hasNext() && iterator.next().available() == 0) - { - iterator.remove(); - } - } - - if(bais == null) - { - if(msg.available()!=0) - { - byte[] remaining = new byte[msg.available()]; - msg.read(remaining); - _remainingBufs.add(new ByteArrayInputStream(remaining)); - } - } - else - { - if(bais.available()!=0) - { - byte[] remaining = new byte[bais.available()]; - bais.read(remaining); - _remainingBufs.add(new ByteArrayInputStream(remaining)); - } - } - - if(_remainingBufs.size() > MAX_BUFFERS_LIMIT) - { - int totalSize = 0; - for(ByteArrayInputStream stream : _remainingBufs) - { - totalSize += stream.available(); - } - - byte[] completeBuffer = new byte[totalSize]; - int pos = 0; - for(ByteArrayInputStream stream : _remainingBufs) - { - pos += stream.read(completeBuffer, pos, stream.available()); - } - - _remainingBufs.clear(); - _remainingBufs.add(new ByteArrayInputStream(completeBuffer)); - } - } - } - } - - private boolean decodable(final MarkableDataInput in) throws AMQFrameDecodingException, IOException - { - final int remainingAfterAttributes = in.available() - (1 + 2 + 4 + 1); - // type, channel, body length and end byte - if (remainingAfterAttributes < 0) - { - return false; - } - - in.mark(8); - in.skip(1 + 2); - - - // Get an unsigned int, lifted from MINA ByteBuffer getUnsignedInt() - final long bodySize = in.readInt() & 0xffffffffL; - if (bodySize > _maxFrameSize) - { - throw new AMQFrameDecodingException(AMQConstant.FRAME_ERROR, - "Incoming frame size of " - + bodySize - + " is larger than negotiated maximum of " - + _maxFrameSize); - } - in.reset(); - - return (remainingAfterAttributes >= bodySize); - - } - - private void processInput(final MarkableDataInput in) - throws AMQFrameDecodingException, AMQProtocolVersionException, IOException - { - final byte type = in.readByte(); - - final int channel = in.readUnsignedShort(); - final long bodySize = EncodingUtils.readUnsignedInteger(in); - - // bodySize can be zero - if ((channel < 0) || (bodySize < 0)) - { - throw new AMQFrameDecodingException(AMQConstant.FRAME_ERROR, - "Undecodable frame: type = " + type + " channel = " + channel - + " bodySize = " + bodySize); - } - - processFrame(channel, type, bodySize, in); - - byte marker = in.readByte(); - if ((marker & 0xFF) != 0xCE) - { - throw new AMQFrameDecodingException(AMQConstant.FRAME_ERROR, - "End of frame marker not found. Read " + marker + " length=" + bodySize - + " type=" + type); - } - - } - - protected void processFrame(final int channel, final byte type, final long bodySize, final MarkableDataInput in) - throws AMQFrameDecodingException, IOException - { - switch (type) - { - case 1: - processMethod(channel, in); - break; - case 2: - ContentHeaderBody.process(in, _methodProcessor.getChannelMethodProcessor(channel), bodySize); - break; - case 3: - ContentBody.process(in, _methodProcessor.getChannelMethodProcessor(channel), bodySize); - break; - case 8: - HeartbeatBody.process(channel, in, _methodProcessor, bodySize); - break; - default: - throw new AMQFrameDecodingException(AMQConstant.FRAME_ERROR, "Unsupported frame type: " + type); - } - } - - - abstract void processMethod(int channelId, - MarkableDataInput in) - throws AMQFrameDecodingException, IOException; - - AMQFrameDecodingException newUnknownMethodException(final int classId, - final int methodId, - ProtocolVersion protocolVersion) - { - return new AMQFrameDecodingException(AMQConstant.COMMAND_INVALID, - "Method " - + methodId - + " unknown in AMQP version " - + protocolVersion - + " (while trying to decode class " - + classId - + " method " - + methodId - + "."); - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/codec/ClientDecoder.java b/qpid/java/common/src/main/java/org/apache/qpid/codec/ClientDecoder.java deleted file mode 100644 index 9bdc1dd889..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/codec/ClientDecoder.java +++ /dev/null @@ -1,273 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.codec; - -import java.io.IOException; - -import org.apache.qpid.framing.*; - -public class ClientDecoder extends AMQDecoder> -{ - - /** - * Creates a new AMQP decoder. - * - * @param methodProcessor method processor - */ - public ClientDecoder(final ClientMethodProcessor methodProcessor) - { - super(false, methodProcessor); - } - - - void processMethod(int channelId, - MarkableDataInput in) - throws AMQFrameDecodingException, IOException - { - ClientMethodProcessor methodProcessor = getMethodProcessor(); - ClientChannelMethodProcessor channelMethodProcessor = methodProcessor.getChannelMethodProcessor(channelId); - final int classAndMethod = in.readInt(); - int classId = classAndMethod >> 16; - int methodId = classAndMethod & 0xFFFF; - methodProcessor.setCurrentMethod(classId, methodId); - try - { - switch (classAndMethod) - { - //CONNECTION_CLASS: - case 0x000a000a: - ConnectionStartBody.process(in, methodProcessor); - break; - case 0x000a0014: - ConnectionSecureBody.process(in, methodProcessor); - break; - case 0x000a001e: - ConnectionTuneBody.process(in, methodProcessor); - break; - case 0x000a0029: - ConnectionOpenOkBody.process(in, methodProcessor); - break; - case 0x000a002a: - ConnectionRedirectBody.process(in, methodProcessor); - break; - case 0x000a0032: - if (methodProcessor.getProtocolVersion().equals(ProtocolVersion.v8_0)) - { - ConnectionRedirectBody.process(in, methodProcessor); - } - else - { - ConnectionCloseBody.process(in, methodProcessor); - } - break; - case 0x000a0033: - if (methodProcessor.getProtocolVersion().equals(ProtocolVersion.v8_0)) - { - throw newUnknownMethodException(classId, methodId, - methodProcessor.getProtocolVersion()); - } - else - { - methodProcessor.receiveConnectionCloseOk(); - } - break; - case 0x000a003c: - if (methodProcessor.getProtocolVersion().equals(ProtocolVersion.v8_0)) - { - ConnectionCloseBody.process(in, methodProcessor); - } - else - { - throw newUnknownMethodException(classId, methodId, - methodProcessor.getProtocolVersion()); - } - break; - case 0x000a003d: - if (methodProcessor.getProtocolVersion().equals(ProtocolVersion.v8_0)) - { - methodProcessor.receiveConnectionCloseOk(); - } - else - { - throw newUnknownMethodException(classId, methodId, - methodProcessor.getProtocolVersion()); - } - break; - - // CHANNEL_CLASS: - - case 0x0014000b: - ChannelOpenOkBody.process(in, methodProcessor.getProtocolVersion(), channelMethodProcessor); - break; - case 0x00140014: - ChannelFlowBody.process(in, channelMethodProcessor); - break; - case 0x00140015: - ChannelFlowOkBody.process(in, channelMethodProcessor); - break; - case 0x0014001e: - ChannelAlertBody.process(in, channelMethodProcessor); - break; - case 0x00140028: - ChannelCloseBody.process(in, channelMethodProcessor); - break; - case 0x00140029: - channelMethodProcessor.receiveChannelCloseOk(); - break; - - // ACCESS_CLASS: - - case 0x001e000b: - AccessRequestOkBody.process(in, channelMethodProcessor); - break; - - // EXCHANGE_CLASS: - - case 0x0028000b: - if(!channelMethodProcessor.ignoreAllButCloseOk()) - { - channelMethodProcessor.receiveExchangeDeclareOk(); - } - break; - case 0x00280015: - if(!channelMethodProcessor.ignoreAllButCloseOk()) - { - channelMethodProcessor.receiveExchangeDeleteOk(); - } - break; - case 0x00280017: - ExchangeBoundOkBody.process(in, channelMethodProcessor); - break; - - - // QUEUE_CLASS: - - case 0x0032000b: - QueueDeclareOkBody.process(in, channelMethodProcessor); - break; - case 0x00320015: - if(!channelMethodProcessor.ignoreAllButCloseOk()) - { - channelMethodProcessor.receiveQueueBindOk(); - } - break; - case 0x0032001f: - QueuePurgeOkBody.process(in, channelMethodProcessor); - break; - case 0x00320029: - QueueDeleteOkBody.process(in, channelMethodProcessor); - break; - case 0x00320033: - if(!channelMethodProcessor.ignoreAllButCloseOk()) - { - channelMethodProcessor.receiveQueueUnbindOk(); - } - break; - - - // BASIC_CLASS: - - case 0x003c000b: - if(!channelMethodProcessor.ignoreAllButCloseOk()) - { - channelMethodProcessor.receiveBasicQosOk(); - } - break; - case 0x003c0015: - BasicConsumeOkBody.process(in, channelMethodProcessor); - break; - case 0x003c001f: - BasicCancelOkBody.process(in, channelMethodProcessor); - break; - case 0x003c0032: - BasicReturnBody.process(in, channelMethodProcessor); - break; - case 0x003c003c: - BasicDeliverBody.process(in, channelMethodProcessor); - break; - case 0x003c0047: - BasicGetOkBody.process(in, channelMethodProcessor); - break; - case 0x003c0048: - BasicGetEmptyBody.process(in, channelMethodProcessor); - break; - case 0x003c0050: - BasicAckBody.process(in, channelMethodProcessor); - break; - case 0x003c0065: - if(!channelMethodProcessor.ignoreAllButCloseOk()) - { - channelMethodProcessor.receiveBasicRecoverSyncOk(); - } - break; - case 0x003c006f: - if(!channelMethodProcessor.ignoreAllButCloseOk()) - { - channelMethodProcessor.receiveBasicRecoverSyncOk(); - } - break; - case 0x003c0078: - BasicNackBody.process(in, channelMethodProcessor); - break; - - // CONFIRM CLASS: - - case 0x0055000b: - if(!channelMethodProcessor.ignoreAllButCloseOk()) - { - channelMethodProcessor.receiveConfirmSelectOk(); - } - break; - - // TX_CLASS: - - case 0x005a000b: - if(!channelMethodProcessor.ignoreAllButCloseOk()) - { - channelMethodProcessor.receiveTxSelectOk(); - } - break; - case 0x005a0015: - if(!channelMethodProcessor.ignoreAllButCloseOk()) - { - channelMethodProcessor.receiveTxCommitOk(); - } - break; - case 0x005a001f: - if(!channelMethodProcessor.ignoreAllButCloseOk()) - { - channelMethodProcessor.receiveTxRollbackOk(); - } - break; - - default: - throw newUnknownMethodException(classId, methodId, - methodProcessor.getProtocolVersion()); - - } - } - finally - { - methodProcessor.setCurrentMethod(0, 0); - } - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/codec/MarkableDataInput.java b/qpid/java/common/src/main/java/org/apache/qpid/codec/MarkableDataInput.java deleted file mode 100644 index a1513135a3..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/codec/MarkableDataInput.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.codec; - -import org.apache.qpid.framing.AMQShortString; - -import java.io.DataInput; -import java.io.IOException; - -public interface MarkableDataInput extends DataInput -{ - public void mark(int pos); - public void reset() throws IOException; - - int available() throws IOException; - - long skip(long i) throws IOException; - - int read(byte[] b) throws IOException; - - public AMQShortString readAMQShortString() throws IOException; - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/codec/ServerDecoder.java b/qpid/java/common/src/main/java/org/apache/qpid/codec/ServerDecoder.java deleted file mode 100644 index deed32346f..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/codec/ServerDecoder.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.codec; - -import java.io.IOException; - -import org.apache.qpid.framing.*; - -public class ServerDecoder extends AMQDecoder> -{ - - /** - * Creates a new AMQP decoder. - * - * @param methodProcessor method processor - */ - public ServerDecoder(final ServerMethodProcessor methodProcessor) - { - super(true, methodProcessor); - } - - void processMethod(int channelId, - MarkableDataInput in) - throws AMQFrameDecodingException, IOException - { - ServerMethodProcessor methodProcessor = getMethodProcessor(); - final int classAndMethod = in.readInt(); - int classId = classAndMethod >> 16; - int methodId = classAndMethod & 0xFFFF; - methodProcessor.setCurrentMethod(classId, methodId); - try - { - switch (classAndMethod) - { - //CONNECTION_CLASS: - case 0x000a000b: - ConnectionStartOkBody.process(in, methodProcessor); - break; - case 0x000a0015: - ConnectionSecureOkBody.process(in, methodProcessor); - break; - case 0x000a001f: - ConnectionTuneOkBody.process(in, methodProcessor); - break; - case 0x000a0028: - ConnectionOpenBody.process(in, methodProcessor); - break; - case 0x000a0032: - if (methodProcessor.getProtocolVersion().equals(ProtocolVersion.v8_0)) - { - throw newUnknownMethodException(classId, methodId, - methodProcessor.getProtocolVersion()); - } - else - { - ConnectionCloseBody.process(in, methodProcessor); - } - break; - case 0x000a0033: - if (methodProcessor.getProtocolVersion().equals(ProtocolVersion.v8_0)) - { - throw newUnknownMethodException(classId, methodId, - methodProcessor.getProtocolVersion()); - } - else - { - methodProcessor.receiveConnectionCloseOk(); - } - break; - case 0x000a003c: - if (methodProcessor.getProtocolVersion().equals(ProtocolVersion.v8_0)) - { - ConnectionCloseBody.process(in, methodProcessor); - } - else - { - throw newUnknownMethodException(classId, methodId, - methodProcessor.getProtocolVersion()); - } - break; - case 0x000a003d: - if (methodProcessor.getProtocolVersion().equals(ProtocolVersion.v8_0)) - { - methodProcessor.receiveConnectionCloseOk(); - } - else - { - throw newUnknownMethodException(classId, methodId, - methodProcessor.getProtocolVersion()); - } - break; - - // CHANNEL_CLASS: - - case 0x0014000a: - ChannelOpenBody.process(channelId, in, methodProcessor); - break; - case 0x00140014: - ChannelFlowBody.process(in, methodProcessor.getChannelMethodProcessor(channelId)); - break; - case 0x00140015: - ChannelFlowOkBody.process(in, methodProcessor.getChannelMethodProcessor(channelId)); - break; - case 0x00140028: - ChannelCloseBody.process(in, methodProcessor.getChannelMethodProcessor(channelId)); - break; - case 0x00140029: - methodProcessor.getChannelMethodProcessor(channelId).receiveChannelCloseOk(); - break; - - // ACCESS_CLASS: - - case 0x001e000a: - AccessRequestBody.process(in, methodProcessor.getChannelMethodProcessor(channelId)); - break; - - // EXCHANGE_CLASS: - - case 0x0028000a: - ExchangeDeclareBody.process(in, methodProcessor.getChannelMethodProcessor(channelId)); - break; - case 0x00280014: - ExchangeDeleteBody.process(in, methodProcessor.getChannelMethodProcessor(channelId)); - break; - case 0x00280016: - ExchangeBoundBody.process(in, methodProcessor.getChannelMethodProcessor(channelId)); - break; - - - // QUEUE_CLASS: - - case 0x0032000a: - QueueDeclareBody.process(in, methodProcessor.getChannelMethodProcessor(channelId)); - break; - case 0x00320014: - QueueBindBody.process(in, methodProcessor.getChannelMethodProcessor(channelId)); - break; - case 0x0032001e: - QueuePurgeBody.process(in, methodProcessor.getChannelMethodProcessor(channelId)); - break; - case 0x00320028: - QueueDeleteBody.process(in, methodProcessor.getChannelMethodProcessor(channelId)); - break; - case 0x00320032: - QueueUnbindBody.process(in, methodProcessor.getChannelMethodProcessor(channelId)); - break; - - - // BASIC_CLASS: - - case 0x003c000a: - BasicQosBody.process(in, methodProcessor.getChannelMethodProcessor(channelId)); - break; - case 0x003c0014: - BasicConsumeBody.process(in, methodProcessor.getChannelMethodProcessor(channelId)); - break; - case 0x003c001e: - BasicCancelBody.process(in, methodProcessor.getChannelMethodProcessor(channelId)); - break; - case 0x003c0028: - BasicPublishBody.process(in, methodProcessor.getChannelMethodProcessor(channelId)); - break; - case 0x003c0046: - BasicGetBody.process(in, methodProcessor.getChannelMethodProcessor(channelId)); - break; - case 0x003c0050: - BasicAckBody.process(in, methodProcessor.getChannelMethodProcessor(channelId)); - break; - case 0x003c005a: - BasicRejectBody.process(in, methodProcessor.getChannelMethodProcessor(channelId)); - break; - case 0x003c0064: - BasicRecoverBody.process(in, methodProcessor.getProtocolVersion(), - methodProcessor.getChannelMethodProcessor(channelId)); - break; - case 0x003c0066: - BasicRecoverSyncBody.process(in, methodProcessor.getChannelMethodProcessor(channelId)); - break; - case 0x003c006e: - BasicRecoverSyncBody.process(in, methodProcessor.getChannelMethodProcessor(channelId)); - break; - case 0x003c0078: - BasicNackBody.process(in, methodProcessor.getChannelMethodProcessor(channelId)); - break; - - // CONFIRM CLASS: - - case 0x0055000a: - ConfirmSelectBody.process(in, methodProcessor.getChannelMethodProcessor(channelId)); - break; - - // TX_CLASS: - - case 0x005a000a: - if(!methodProcessor.getChannelMethodProcessor(channelId).ignoreAllButCloseOk()) - { - methodProcessor.getChannelMethodProcessor(channelId).receiveTxSelect(); - } - break; - case 0x005a0014: - if(!methodProcessor.getChannelMethodProcessor(channelId).ignoreAllButCloseOk()) - { - methodProcessor.getChannelMethodProcessor(channelId).receiveTxCommit(); - } - break; - case 0x005a001e: - if(!methodProcessor.getChannelMethodProcessor(channelId).ignoreAllButCloseOk()) - { - methodProcessor.getChannelMethodProcessor(channelId).receiveTxRollback(); - } - break; - - - default: - throw newUnknownMethodException(classId, methodId, - methodProcessor.getProtocolVersion()); - - } - } - finally - { - methodProcessor.setCurrentMethod(0, 0); - } - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/common/AMQPFilterTypes.java b/qpid/java/common/src/main/java/org/apache/qpid/common/AMQPFilterTypes.java deleted file mode 100644 index d033bf86c2..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/common/AMQPFilterTypes.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - * - */ -package org.apache.qpid.common; - -import org.apache.qpid.framing.AMQShortString; - -/** - * Specifies the different filter types for consumers that filter their messages. - */ -public enum AMQPFilterTypes -{ - JMS_SELECTOR("x-filter-jms-selector"), - NO_CONSUME("x-filter-no-consume"), - AUTO_CLOSE("x-filter-auto-close"), - NO_LOCAL("x-qpid-no-local"), - REPLAY_PERIOD("x-qpid-replay-period"); - - /** The identifying string for the filter type. */ - private final AMQShortString _value; - - /** - * Creates a new filter type from its identifying string. - * - * @param value The identifying string. - */ - AMQPFilterTypes(String value) - { - _value = new AMQShortString(value); - } - - /** - * Gets the identifying string of the filter type. - * - * @return The identifying string of the filter type. - */ - public AMQShortString getValue() - { - return _value; - } - - @Override - public String toString() - { - return _value.asString(); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/common/QpidProperties.java b/qpid/java/common/src/main/java/org/apache/qpid/common/QpidProperties.java deleted file mode 100644 index d077cc9717..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/common/QpidProperties.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - * - */ -package org.apache.qpid.common; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; - -/** - * QpidProperties captures the project name, version number, and source code repository revision number from a properties - * file which is generated as part of the build process. Normally, the name and version number are pulled from the module - * name and version number of the Maven build POM, but could come from other sources if the build system is changed. The - * idea behind this, is that every build has these values incorporated directly into its jar file, so that code in the - * wild can be identified, should its origination be forgotten. - * - *

To get the build version of any Qpid code call the {@link #main} method. This version string is usually also - * printed to the console on broker start up. - */ -public class QpidProperties -{ - /** The name of the version properties file to load from the class path. */ - public static final String VERSION_RESOURCE = "qpidversion.properties"; - - /** Defines the name of the product property. */ - public static final String PRODUCT_NAME_PROPERTY = "qpid.name"; - - /** Defines the name of the version property. */ - public static final String RELEASE_VERSION_PROPERTY = "qpid.version"; - - /** Defines the name of the version suffix property. */ - public static final String RELEASE_VERSION_SUFFIX = "qpid.version.suffix"; - - /** Defines the name of the source code revision property. */ - public static final String BUILD_VERSION_PROPERTY = "qpid.svnversion"; - - /** Defines the default value for all properties that cannot be loaded. */ - private static final String DEFAULT = "unknown"; - - /** Holds the product name. */ - private static final String productName; - - /** Holds the product version. */ - private static final String releaseVersion; - - /** Holds the source code revision. */ - private static final String buildVersion; - - private static final Properties properties = new Properties(); - - // Loads the values from the version properties file. - static - { - - try(InputStream propertyStream = QpidProperties.class.getClassLoader().getResourceAsStream(VERSION_RESOURCE)) - { - if (propertyStream != null) - { - properties.load(propertyStream); - } - } - catch (IOException e) - { - // Ignore, most likely running within an IDE, values will have the DEFAULT text - } - - String versionSuffix = properties.getProperty(RELEASE_VERSION_SUFFIX); - String version = properties.getProperty(RELEASE_VERSION_PROPERTY, DEFAULT); - - productName = properties.getProperty(PRODUCT_NAME_PROPERTY, DEFAULT); - releaseVersion = versionSuffix == null || "".equals(versionSuffix) ? version : version + ";" + versionSuffix; - buildVersion = properties.getProperty(BUILD_VERSION_PROPERTY, DEFAULT); - } - - public static Properties asProperties() - { - return new Properties(properties); - } - - /** - * Gets the product name. - * - * @return The product name. - */ - public static String getProductName() - { - return productName; - } - - /** - * Gets the product version. - * - * @return The product version. - */ - public static String getReleaseVersion() - { - return releaseVersion; - } - - /** - * Gets the source code revision. - * - * @return The source code revision. - */ - public static String getBuildVersion() - { - return buildVersion; - } - - /** - * Extracts all of the version information as a printable string. - * - * @return All of the version information as a printable string. - */ - public static String getVersionString() - { - return getProductName() + " - " + getReleaseVersion() + " build: " + getBuildVersion(); - } - - /** - * Prints the versioning information to the console. This is extremely usefull for identifying Qpid code in the - * wild, where the origination of the code has been forgotten. - * - * @param args Does not require any arguments. - */ - public static void main(String[] args) - { - System.out.println(getVersionString()); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/common/ServerPropertyNames.java b/qpid/java/common/src/main/java/org/apache/qpid/common/ServerPropertyNames.java deleted file mode 100644 index 3d792459a9..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/common/ServerPropertyNames.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.common; - -/** - * Keys names used within the serverProperties argument of the ConnectionStart - * method. Property names which start with "qpid." are Qpid specific. - */ -public final class ServerPropertyNames -{ - private ServerPropertyNames() - { - } - - /** - * Server property: federation tag UUID - */ - public static final String FEDERATION_TAG = "qpid.federation_tag"; - - /** - * Server property: array of features supported by the server. - */ - public static final String QPID_FEATURES = "qpid.features"; - - /** - * Feature: Signifies that a server supports JMS selectors. - */ - public static final String FEATURE_QPID_JMS_SELECTOR = "qpid.jms-selector"; - - /** - * Server property: 'name' attribute of the server instance. - */ - public static final String QPID_INSTANCE_NAME = "qpid.instance_name"; - - /** - * Server property: build number. - */ - public static final String QPID_BUILD = "qpid.build"; - - public static final String PRODUCT = "product"; - public static final String VERSION = "version"; -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/configuration/Accessor.java b/qpid/java/common/src/main/java/org/apache/qpid/configuration/Accessor.java deleted file mode 100644 index b73f08f824..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/configuration/Accessor.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.configuration; - -import java.util.Map; - -public interface Accessor -{ - public Boolean getBoolean(String name); - public Integer getInt(String name); - public Long getLong(String name); - public String getString(String name); - public Float getFloat(String name); - - static class SystemPropertyAccessor implements Accessor - { - public Boolean getBoolean(String name) - { - return System.getProperty(name) == null ? null : Boolean.getBoolean(name); - } - - public Integer getInt(String name) - { - return Integer.getInteger(name); - } - - public Long getLong(String name) - { - return Long.getLong(name); - } - - public String getString(String name) - { - return System.getProperty(name); - } - - public Float getFloat(String name) - { - return System.getProperty(name) == null ? null : Float.parseFloat(System.getProperty(name)); - } - } - - static class MapAccessor implements Accessor - { - private Map source; - - public MapAccessor(Map map) - { - source = map; - } - - protected void setSource(Map source) - { - this.source = source; - } - - public Boolean getBoolean(String name) - { - if (source != null && source.containsKey(name)) - { - if (source.get(name) instanceof Boolean) - { - return (Boolean)source.get(name); - } - else - { - return Boolean.parseBoolean((String)source.get(name)); - } - } - else - { - return null; - } - } - - public Integer getInt(String name) - { - if (source != null && source.containsKey(name)) - { - if (source.get(name) instanceof Integer) - { - return (Integer)source.get(name); - } - else - { - return Integer.parseInt((String)source.get(name)); - } - } - else - { - return null; - } - } - - public Long getLong(String name) - { - if (source != null && source.containsKey(name)) - { - if (source.get(name) instanceof Long) - { - return (Long)source.get(name); - } - else - { - return Long.parseLong((String)source.get(name)); - } - } - else - { - return null; - } - } - - public String getString(String name) - { - if (source != null && source.containsKey(name)) - { - if (source.get(name) instanceof String) - { - return (String)source.get(name); - } - else - { - return String.valueOf(source.get(name)); - } - } - else - { - return null; - } - } - - public Float getFloat(String name) - { - if (source != null && source.containsKey(name)) - { - if (source.get(name) instanceof Float) - { - return (Float)source.get(name); - } - else - { - return Float.parseFloat((String)source.get(name)); - } - } - else - { - return null; - } - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java b/qpid/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java deleted file mode 100644 index 89e4c3ccdd..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java +++ /dev/null @@ -1,354 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.qpid.configuration; - -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.HashSet; -import java.util.Properties; -import java.util.Set; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * This class centralized the Qpid client properties. - * - * @see CommonProperties - */ -public class ClientProperties -{ - private static final Logger LOGGER = LoggerFactory.getLogger(ClientProperties.class); - - /** - * Currently with Qpid it is not possible to change the client ID. - * If one is not specified upon connection construction, an id is generated automatically. - * Therefore an exception is always thrown unless this property is set to true. - * type: boolean - */ - public static final String IGNORE_SET_CLIENTID_PROP_NAME = "ignore_setclientID"; - - /** - * This property is currently used within the 0.10 code path only - * The maximum number of pre-fetched messages per destination - * This property is used for all the connection unless it is overwritten by the connectionURL - * type: long - */ - public static final String MAX_PREFETCH_PROP_NAME = "max_prefetch"; - public static final String MAX_PREFETCH_DEFAULT = "500"; - - /** - * When true a sync command is sent after every persistent messages. - * type: boolean - */ - public static final String SYNC_PERSISTENT_PROP_NAME = "sync_persistence"; - - /** - * When true a sync command is sent after sending a message ack. - * type: boolean - */ - public static final String SYNC_ACK_PROP_NAME = "sync_ack"; - - /** - * sync_publish property - {persistent|all} - * If set to 'persistent',then persistent messages will be publish synchronously - * If set to 'all', then all messages regardless of the delivery mode will be - * published synchronously. - */ - public static final String SYNC_PUBLISH_PROP_NAME = "sync_publish"; - - /** - * Frequency of heartbeat messages (in milliseconds) - * @see #QPID_HEARTBEAT_INTERVAL - */ - @Deprecated - public static final String IDLE_TIMEOUT_PROP_NAME = "idle_timeout"; - - /** - * Frequency of heartbeat messages (in seconds) - * @see #QPID_HEARTBEAT_INTERVAL - */ - @Deprecated - public static final String AMQJ_HEARTBEAT_DELAY = "amqj.heartbeat.delay"; - - /** - * Frequency of heartbeat messages (in seconds) - */ - public static final String QPID_HEARTBEAT_INTERVAL = "qpid.heartbeat"; - - /** - * Default heartbeat interval (used by 0-10 protocol). - */ - public static final int QPID_HEARTBEAT_INTERVAL_010_DEFAULT = 120; - - /** - * @see #QPID_HEARTBEAT_TIMEOUT_FACTOR - */ - @Deprecated - public static final String AMQJ_HEARTBEAT_TIMEOUT_FACTOR = "amqj.heartbeat.timeoutFactor"; - - /** - * The factor applied to {@link #QPID_HEARTBEAT_INTERVAL} that determines the maximum - * length of time that may elapse before the peer is deemed to have failed. - * - * @see #QPID_HEARTBEAT_TIMEOUT_FACTOR_DEFAULT - */ - public static final String QPID_HEARTBEAT_TIMEOUT_FACTOR = "qpid.heartbeat_timeout_factor"; - - /** - * Default heartbeat timeout factor. - */ - public static final float QPID_HEARTBEAT_TIMEOUT_FACTOR_DEFAULT = 2.0f; - - /** - * This value will be used to determine the default destination syntax type. - * Currently the two types are Binding URL (java only) and the Addressing format (used by - * all clients). - */ - public static final String DEST_SYNTAX = "qpid.dest_syntax"; - - public static final String USE_LEGACY_MAP_MESSAGE_FORMAT = "qpid.use_legacy_map_message"; - - public static final String USE_LEGACY_STREAM_MESSAGE_FORMAT = "qpid.use_legacy_stream_message"; - - public static final String AMQP_VERSION = "qpid.amqp.version"; - - public static final String QPID_VERIFY_CLIENT_ID = "qpid.verify_client_id"; - - /** - * System properties to change the default timeout used during - * synchronous operations. - */ - public static final String QPID_SYNC_OP_TIMEOUT = "qpid.sync_op_timeout"; - @Deprecated - public static final String AMQJ_DEFAULT_SYNCWRITE_TIMEOUT = "amqj.default_syncwrite_timeout"; - - /** - * A default timeout value for synchronous operations - */ - public static final int DEFAULT_SYNC_OPERATION_TIMEOUT = 60000; - - /** - * System properties to change the default timeout used whilst closing connections - * and underlying sessions. - */ - public static final String QPID_CLOSE_TIMEOUT = "qpid.close_timeout"; - - /** - * A default timeout value for close operations - */ - public static final int DEFAULT_CLOSE_TIMEOUT = 2000; - - - /** - * System properties to change the default value used for TCP_NODELAY - */ - public static final String QPID_TCP_NODELAY_PROP_NAME = "qpid.tcp_nodelay"; - @Deprecated - public static final String AMQJ_TCP_NODELAY_PROP_NAME = "amqj.tcp_nodelay"; - - /** - * System property to set the reject behaviour. default value will be 'normal' but can be - * changed to 'server' in which case the server decides whether a message should be requeued - * or dead lettered. - * This can be overridden by the more specific settings at connection or binding URL level. - */ - public static final String REJECT_BEHAVIOUR_PROP_NAME = "qpid.reject.behaviour"; - - /** - * System property used to set the key manager factory algorithm. - * - * Historically, Qpid referred to this as {@value #QPID_SSL_KEY_STORE_CERT_TYPE_PROP_NAME}. - */ - public static final String QPID_SSL_KEY_MANAGER_FACTORY_ALGORITHM_PROP_NAME = "qpid.ssl.KeyManagerFactory.algorithm"; - @Deprecated - public static final String QPID_SSL_KEY_STORE_CERT_TYPE_PROP_NAME = "qpid.ssl.keyStoreCertType"; - - /** - * System property used to set the trust manager factory algorithm. - * - * Historically, Qpid referred to this as {@value #QPID_SSL_TRUST_STORE_CERT_TYPE_PROP_NAME}. - */ - public static final String QPID_SSL_TRUST_MANAGER_FACTORY_ALGORITHM_PROP_NAME = "qpid.ssl.TrustManagerFactory.algorithm"; - @Deprecated - public static final String QPID_SSL_TRUST_STORE_CERT_TYPE_PROP_NAME = "qpid.ssl.trustStoreCertType"; - - /** - * System property to enable allow dispatcher thread to be run as a daemon thread - */ - public static final String DAEMON_DISPATCHER = "qpid.jms.daemon.dispatcher"; - - /** - * Used to name the process utilising the Qpid client, to override the default - * value is used in the ConnectionStartOk reply to the broker. - */ - public static final String PROCESS_NAME = "qpid.client_process"; - - /** - * System property used to set the socket receive buffer size. - * - * Historically, Qpid referred to this as {@value #LEGACY_RECEIVE_BUFFER_SIZE_PROP_NAME}. - */ - public static final String RECEIVE_BUFFER_SIZE_PROP_NAME = "qpid.receive_buffer_size"; - @Deprecated - public static final String LEGACY_RECEIVE_BUFFER_SIZE_PROP_NAME = "amqj.receiveBufferSize"; - - /** - * System property used to set the socket send buffer size. - * - * Historically, Qpid referred to this as {@value #LEGACY_SEND_BUFFER_SIZE_PROP_NAME}. - */ - public static final String SEND_BUFFER_SIZE_PROP_NAME = "qpid.send_buffer_size"; - @Deprecated - public static final String LEGACY_SEND_BUFFER_SIZE_PROP_NAME = "amqj.sendBufferSize"; - - /** - * System property to set the time (in millis) to wait before failing when sending and - * the client has been flow controlled by the broker. - */ - public static final String QPID_FLOW_CONTROL_WAIT_FAILURE = "qpid.flow_control_wait_failure"; - - /** - * Default time (in millis) to wait before failing when sending and the client has been - * flow controlled by the broker. - */ - public static final long DEFAULT_FLOW_CONTROL_WAIT_FAILURE = 60000L; - - /** - * System property to set the time (in millis) between log notifications that a - * send is waiting because the client was flow controlled by the broker. - */ - public static final String QPID_FLOW_CONTROL_WAIT_NOTIFY_PERIOD = "qpid.flow_control_wait_notify_period"; - - /** - * Default time (in millis) between log notifications that a send is - * waiting because the client was flow controlled by the broker. - */ - public static final long DEFAULT_FLOW_CONTROL_WAIT_NOTIFY_PERIOD = 5000L; - - /** - * System property to control whether the client will declare queues during - * consumer creation when using BindingURLs. - */ - public static final String QPID_DECLARE_QUEUES_PROP_NAME = "qpid.declare_queues"; - - /** - * System property to control whether the client will declare exchanges during - * producer/consumer creation when using BindingURLs. - */ - public static final String QPID_DECLARE_EXCHANGES_PROP_NAME = "qpid.declare_exchanges"; - /** - * System property to control whether the client will bind queues during - * consumer creation when using BindingURLs. - */ - public static final String QPID_BIND_QUEUES_PROP_NAME = "qpid.bind_queues"; - - public static final String VERIFY_QUEUE_ON_SEND = "qpid.verify_queue_on_send"; - - public static final String QPID_MAX_CACHED_ADDR_OPTION_STRINGS = "qpid.max_cached_address_option_strings"; - public static final int DEFAULT_MAX_CACHED_ADDR_OPTION_STRINGS = 10; - - /** - * System property to control whether the 0-8/0-9/0-9-1 client will set the message - * 'expiration' header using the computed expiration value (default, when false) or instead set - * it to the raw TTL (when true). May be necessary for interop with other vendors. - */ - public static final String SET_EXPIRATION_AS_TTL = "qpid.set_expiration_as_ttl"; - - /** - * System property to set a default value for a connection option 'ssl_verify_hostname' - */ - public static final String CONNECTION_OPTION_SSL_VERIFY_HOST_NAME = "qpid.connection_ssl_verify_hostname"; - public static final boolean DEFAULT_CONNECTION_OPTION_SSL_VERIFY_HOST_NAME = true; - - /** - * System property to set a default value for a connection option 'compress_messages' - */ - public static final String CONNECTION_OPTION_COMPRESS_MESSAGES = "qpid.connection_compress_messages"; - public static final boolean DEFAULT_CONNECTION_OPTION_COMPRESS_MESSAGES = false; - - - /** - * System property to set a default value for a connection option 'message_compression_threshold_size' - */ - public static final String CONNECTION_OPTION_MESSAGE_COMPRESSION_THRESHOLD_SIZE = "qpid.message_compression_threshold_size"; - public static final int DEFAULT_MESSAGE_COMPRESSION_THRESHOLD_SIZE = 102400; - - public static final String ADDR_SYNTAX_SUPPORTED_IN_0_8 = "qpid.addr_syntax_supported"; - public static final boolean DEFAULT_ADDR_SYNTAX_0_8_SUPPORT = true; - - /** - * Before 0.30, when using AMQP 0-8..0-9-1 requesting queue depth (AMQSession#getQueueDepth) for a queue that - * did not exist resulted in AMQChannelException. From 0.30 forward, 0 is returned in common with 0-10 - * behaviour. - * - * Setting this system property true restores the old behaviour. It also avoids the isBound with a null exchange - * that causes an error in the Java Broker (0.28 and earlier). - */ - public static final String QPID_USE_LEGACY_GETQUEUEDEPTH_BEHAVIOUR = "qpid.use_legacy_getqueuedepth_behavior"; - - static - { - // force load of common properties - Class commonPropertiesClass = CommonProperties.class; - - Properties props = new Properties(); - String initialProperties = System.getProperty("qpid.client_properties_file"); - URL initialPropertiesLocation = null; - try - { - if (initialProperties == null) - { - initialPropertiesLocation = ClientProperties.class.getClassLoader().getResource("qpid-client.properties"); - } - else - { - initialPropertiesLocation = (new File(initialProperties)).toURI().toURL(); - } - - if (initialPropertiesLocation != null) - { - props.load(initialPropertiesLocation.openStream()); - } - } - catch (MalformedURLException e) - { - LOGGER.warn("Could not open client properties file '"+initialProperties+"'.", e); - } - catch (IOException e) - { - LOGGER.warn("Could not open client properties file '" + initialPropertiesLocation + "'.", e); - } - - Set propertyNames = new HashSet<>(props.stringPropertyNames()); - propertyNames.removeAll(System.getProperties().stringPropertyNames()); - for (String propName : propertyNames) - { - System.setProperty(propName, props.getProperty(propName)); - } - - } - - private ClientProperties() - { - //No instances - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/configuration/CommonProperties.java b/qpid/java/common/src/main/java/org/apache/qpid/configuration/CommonProperties.java deleted file mode 100644 index a052a02748..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/configuration/CommonProperties.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.configuration; - -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.HashSet; -import java.util.Properties; -import java.util.Set; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.apache.qpid.common.QpidProperties; - -/** - * Centralised record of Qpid common properties. - * - * @see ClientProperties - */ -public class CommonProperties -{ - private static final Logger LOGGER = LoggerFactory.getLogger(CommonProperties.class); - - /** - * The timeout used by the IO layer for timeouts such as send timeout in IoSender, and the close timeout for IoSender and IoReceiver - */ - public static final String IO_NETWORK_TRANSPORT_TIMEOUT_PROP_NAME = "qpid.io_network_transport_timeout"; - public static final int IO_NETWORK_TRANSPORT_TIMEOUT_DEFAULT = 60000; - - public static final String HANDSHAKE_TIMEOUT_PROP_NAME = "qpid.handshake_timeout"; - public static final int HANDSHAKE_TIMEOUT_DEFAULT = 2; - - static - { - - Properties props = new Properties(QpidProperties.asProperties()); - String initialProperties = System.getProperty("qpid.common_properties_file"); - URL initialPropertiesLocation = null; - try - { - if (initialProperties == null) - { - initialPropertiesLocation = CommonProperties.class.getClassLoader().getResource("qpid-common.properties"); - } - else - { - initialPropertiesLocation = (new File(initialProperties)).toURI().toURL(); - } - - if (initialPropertiesLocation != null) - { - props.load(initialPropertiesLocation.openStream()); - } - } - catch (MalformedURLException e) - { - LOGGER.warn("Could not open common properties file '"+initialProperties+"'.", e); - } - catch (IOException e) - { - LOGGER.warn("Could not open common properties file '" + initialPropertiesLocation + "'.", e); - } - - Set propertyNames = new HashSet<>(props.stringPropertyNames()); - propertyNames.removeAll(System.getProperties().stringPropertyNames()); - for (String propName : propertyNames) - { - System.setProperty(propName, props.getProperty(propName)); - } - - } - - private CommonProperties() - { - //no instances - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/configuration/Configured.java b/qpid/java/common/src/main/java/org/apache/qpid/configuration/Configured.java deleted file mode 100644 index 22903888fe..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/configuration/Configured.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.configuration; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Marks a field as having a "configured" value injected into it by a configurator. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface Configured -{ - /** - * The Commons Configuration path to the configuration element - */ - String path(); - - /** - * The default value to use should the path not be found in the configuration source - */ - String defaultValue(); -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/configuration/PropertyException.java b/qpid/java/common/src/main/java/org/apache/qpid/configuration/PropertyException.java deleted file mode 100644 index cf08dafb49..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/configuration/PropertyException.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.configuration; - -import org.apache.qpid.AMQException; - -/** - * Indicates a failure to parse a property expansion. See {@link PropertyUtils} for the code that does property - * expansions. - * - *

- * TODO Not an AMQP exception as no status code. - */ -public class PropertyException extends AMQException -{ - public PropertyException(String message, Throwable cause) - { - super(null, message, cause); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/configuration/PropertyUtils.java b/qpid/java/common/src/main/java/org/apache/qpid/configuration/PropertyUtils.java deleted file mode 100644 index da366ffd0f..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/configuration/PropertyUtils.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.configuration; - -import java.util.ArrayList; -import java.util.Iterator; - -/** - * PropertyUtils provides helper methods for dealing with Java properties. - * - *

- * TODO Make the lookup method generic by passing in the properties to use for the expansion, rather than hard coding - * as system properties. The expansion code has greater potential for re-use that way. - *

- * TODO Some more property related code could be added to this utils class, which might more appropriately reside under - * org.apache.qpid.util. For example standardised code to load properties from a resource name, currently found in - * QpidProperties and possibly other places could be moved here. - */ -public class PropertyUtils -{ - private PropertyUtils() - { - } - - /** - * Given a string that contains substrings of the form ${xxx}, looks up the valuea of 'xxx' as a - * system properties and substitutes tham back into the original string, to provide a property value expanded - * string. - * - * @param value The string to be scanned for property references. May be null, in which case this - * method returns immediately with no effect. - * - * @return The original string with the properties replaced, or null if the original string is - * null. - * - * @throws PropertyException If the string contains an opening ${ without a balancing }, - * or if the property to expand does not exist as a system property. - */ - public static String replaceProperties(String value) throws PropertyException - { - if (value == null) - { - return null; - } - - ArrayList fragments = new ArrayList(); - ArrayList propertyRefs = new ArrayList(); - parsePropertyString(value, fragments, propertyRefs); - - StringBuffer sb = new StringBuffer(); - Iterator j = propertyRefs.iterator(); - - for (String fragment : fragments) - { - if (fragment == null) - { - String propertyName = j.next(); - - // try to get it from the project or keys - // Backward compatibility - String replacement = System.getProperty(propertyName); - - if (replacement == null) - { - throw new PropertyException("Property ${" + propertyName + "} has not been set", null); - } - - fragment = replacement; - } - - sb.append(fragment); - } - - return sb.toString(); - } - - /** - * Parses the supplied value for properties which are specified using ${foo} syntax. $X is left as is, and $$ - * specifies a single $. - * - * @param value The property string to parse. - * @param fragments Is populated with the string fragments. A null means "insert a property value here. The number - * of nulls in the list when populated is equal to the size of the propertyRefs list. - * @param propertyRefs Populated with the property names to be added into the final string. - */ - private static void parsePropertyString(String value, ArrayList fragments, ArrayList propertyRefs) - throws PropertyException - { - int prev = 0; - int pos; - // search for the next instance of $ from the 'prev' position - while ((pos = value.indexOf("$", prev)) >= 0) - { - - // if there was any text before this, add it as a fragment - if (pos > 0) - { - fragments.add(value.substring(prev, pos)); - } - // if we are at the end of the string, we tack on a $ - // then move past it - if (pos == (value.length() - 1)) - { - fragments.add("$"); - prev = pos + 1; - } - else if (value.charAt(pos + 1) != '{') - { - // peek ahead to see if the next char is a property or not - // not a property: insert the char as a literal - if (value.charAt(pos + 1) == '$') - { - // two $ map to one $ - fragments.add("$"); - prev = pos + 2; - } - else - { - // $X maps to $X for all values of X!='$' - fragments.add(value.substring(pos, pos + 2)); - prev = pos + 2; - } - } - else - { - // property found, extract its name or bail on a typo - int endName = value.indexOf('}', pos); - if (endName < 0) - { - throw new PropertyException("Syntax error in property: " + value, null); - } - - String propertyName = value.substring(pos + 2, endName); - fragments.add(null); - propertyRefs.add(propertyName); - prev = endName + 1; - } - } - // no more $ signs found - // if there is any tail to the file, append it - if (prev < value.length()) - { - fragments.add(value.substring(prev)); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/configuration/QpidProperty.java b/qpid/java/common/src/main/java/org/apache/qpid/configuration/QpidProperty.java deleted file mode 100644 index 3ed32a604a..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/configuration/QpidProperty.java +++ /dev/null @@ -1,210 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.qpid.configuration; - -import org.apache.qpid.configuration.Accessor.SystemPropertyAccessor; - -public abstract class QpidProperty -{ - private T defValue; - private String[] names; - private Accessor accessor; - - QpidProperty(T defValue, String... names) - { - this(new SystemPropertyAccessor(),defValue,names); - } - - QpidProperty(Accessor accessor,T defValue, String... names) - { - this.accessor = accessor; - this.defValue = defValue; - this.names = names; - } - - public T get() - { - for (String name : names) - { - T obj = getByName(name); - if (obj != null) - { - return obj; - } - } - - return defValue; - } - - protected abstract T getByName(String name); - - public static QpidProperty booleanProperty(Boolean defaultValue, - String... names) - { - return new QpidBooleanProperty(defaultValue, names); - } - - public static QpidProperty booleanProperty(Accessor accessor, - Boolean defaultValue,String... names) - { - return new QpidBooleanProperty(accessor,defaultValue, names); - } - - public static QpidProperty intProperty(Integer defaultValue, - String... names) - { - return new QpidIntProperty(defaultValue, names); - } - - public static QpidProperty intProperty(Accessor accessor, - Integer defaultValue, String... names) - { - return new QpidIntProperty(accessor,defaultValue, names); - } - - public static QpidProperty longProperty(Long defaultValue, - String... names) - { - return new QpidLongProperty(defaultValue, names); - } - - public static QpidProperty longProperty(Accessor accessor, - Long defaultValue, String... names) - { - return new QpidLongProperty(accessor,defaultValue, names); - } - - public static QpidProperty stringProperty(String defaultValue, - String... names) - { - return new QpidStringProperty(defaultValue, names); - } - - public static QpidProperty stringProperty(Accessor accessor, - String defaultValue,String... names) - { - return new QpidStringProperty(accessor,defaultValue, names); - } - - public static QpidProperty floatProperty(Float defaultValue, String... names) - { - return new QpidFloatProperty(defaultValue, names); - } - - protected Accessor getAccessor() - { - return accessor; - } - - static class QpidBooleanProperty extends QpidProperty - { - QpidBooleanProperty(Boolean defValue, String... names) - { - super(defValue, names); - } - - QpidBooleanProperty(Accessor accessor,Boolean defValue, String... names) - { - super(accessor,defValue, names); - } - - @Override - protected Boolean getByName(String name) - { - return getAccessor().getBoolean(name); - } - } - - static class QpidIntProperty extends QpidProperty - { - QpidIntProperty(Integer defValue, String... names) - { - super(defValue, names); - } - - QpidIntProperty(Accessor accessor,Integer defValue, String... names) - { - super(accessor,defValue, names); - } - - @Override - protected Integer getByName(String name) - { - return getAccessor().getInt(name); - } - } - - static class QpidLongProperty extends QpidProperty - { - QpidLongProperty(Long defValue, String... names) - { - super(defValue, names); - } - - QpidLongProperty(Accessor accessor,Long defValue, String... names) - { - super(accessor,defValue, names); - } - - @Override - protected Long getByName(String name) - { - return getAccessor().getLong(name); - } - } - - static class QpidStringProperty extends QpidProperty - { - QpidStringProperty(String defValue, String... names) - { - super(defValue, names); - } - - QpidStringProperty(Accessor accessor,String defValue, String... names) - { - super(accessor,defValue, names); - } - - @Override - protected String getByName(String name) - { - return getAccessor().getString(name); - } - } - - static class QpidFloatProperty extends QpidProperty - { - QpidFloatProperty(Float defValue, String... names) - { - super(defValue, names); - } - - QpidFloatProperty(Accessor accessor,Float defValue, String... names) - { - super(accessor,defValue, names); - } - - @Override - protected Float getByName(String name) - { - return getAccessor().getFloat(name); - } - } - -} \ No newline at end of file diff --git a/qpid/java/common/src/main/java/org/apache/qpid/configuration/Validator.java b/qpid/java/common/src/main/java/org/apache/qpid/configuration/Validator.java deleted file mode 100644 index e65bddf10b..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/configuration/Validator.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.configuration; - - -public interface Validator -{ - public void validate(Integer value); - - public void validate(Long value); - - public void validate(String value); -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/dtx/XidImpl.java b/qpid/java/common/src/main/java/org/apache/qpid/dtx/XidImpl.java deleted file mode 100644 index 2d017b1cd4..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/dtx/XidImpl.java +++ /dev/null @@ -1,261 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.qpid.dtx; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.apache.qpid.AMQInvalidArgumentException; - -import javax.transaction.xa.Xid; -import java.io.ByteArrayInputStream; -import java.io.DataInputStream; -import java.io.IOException; -import java.util.Arrays; - -/** - * Implements javax.transaction.dtx.Xid - */ -public class XidImpl implements Xid -{ - /** - * this session's logger - */ - private static final Logger _logger = LoggerFactory.getLogger(XidImpl.class); - - /** - * the transaction branch identifier part of XID as an array of bytes - */ - private byte[] _branchQualifier; - - /** - * the format identifier part of the XID. - */ - private int _formatID; - - /** - * the global transaction identifier part of XID as an array of bytes. - */ - private byte[] _globalTransactionID; - - //--- Constructors - - /** - * Create new Xid. - * this is an empty constructor. - */ - public XidImpl() - { - - } - - /** - * Create a new XidImpl from an existing Xid. - *

Usefull for casting external Xids - * - * @param xid Foreign Xid. - */ - public XidImpl(Xid xid) - { - _branchQualifier = xid.getBranchQualifier(); - _formatID = xid.getFormatId(); - _globalTransactionID = xid.getGlobalTransactionId(); - } - - /** - * Create a new Xid. - * - * @param branchQualifier The transaction branch identifier part of XID as an array of bytes. - * @param format The format identifier part of the XID. - * @param globalTransactionID The global transaction identifier part of XID as an array of bytes. - */ - public XidImpl(byte[] branchQualifier, int format, byte[] globalTransactionID) - { - _branchQualifier = branchQualifier; - _formatID = format; - _globalTransactionID = globalTransactionID; - } - - /** - * Create a new Xid form its String form - * 4 1 1 g b - * +---+---+---+---+---+---+---+- -+---+---+- -+---+ - * | format_id | g | b | txn-id | br-id | - * +---+---+---+---+---+---+---+- -+---+---+- -+---+ - * 0 4 5 6 6+g 6+g+b - * format_id: an implementation specific format identifier - *

- * gtrid_length: how many bytes of this form the transaction id - *

- * bqual_length: how many bytes of this form the branch id - *

- * data: a sequence of octets of at most 128 bytes containing the txn id and the - * branch id - *

- * Note - The sum of the two lengths must equal the length of the data field. - * - * @param xid an XID STring Form - * @throws AMQInvalidArgumentException If the string does not represent a valid Xid - */ - public XidImpl(String xid) throws AMQInvalidArgumentException - { - if (_logger.isDebugEnabled()) - { - _logger.debug("converting string " + xid + " into XidImpl"); - } - try - { - DataInputStream input = new DataInputStream(new ByteArrayInputStream(xid.getBytes())); - _formatID = (int) input.readLong(); - int g = input.readByte(); - int b = input.readByte(); - _globalTransactionID = new byte[g]; - _branchQualifier = new byte[b]; - if (input.read(_globalTransactionID, 0, g) != g) - { - throw new AMQInvalidArgumentException("Cannot convert the string " + xid + " into an Xid", null); - } - if (input.read(_branchQualifier, 0, b) != b) - { - throw new AMQInvalidArgumentException("Cannot convert the string " + xid + " into an Xid", null); - } - } - catch (IOException e) - { - throw new AMQInvalidArgumentException("cannot convert the string " + xid + " into an Xid", e); - } - } - - //--- Xid interface implementation - - /** - * Format identifier. O means the OSI CCR format. - * - * @return Global transaction identifier. - */ - public byte[] getGlobalTransactionId() - { - return _globalTransactionID; - } - - /** - * Obtain the transaction branch identifier part of XID as an array of bytes. - * - * @return Branch identifier part of XID. - */ - public byte[] getBranchQualifier() - { - return _branchQualifier; - } - - /** - * Obtain the format identifier part of the XID. - * - * @return Format identifier. O means the OSI CCR format. - */ - public int getFormatId() - { - return _formatID; - } - - //--- Object operations - - /** - * Indicates whether some other Xid is "equal to" this one. - *

Two Xids are equal if and only if their three elementary parts are equal - * - * @param o the object to compare this XidImpl against. - * @return true if the XidImpl are equal, false otherwise. - */ - public boolean equals(Object o) - { - if (this == o) - { - return true; - } - if (o instanceof XidImpl) - { - XidImpl other = (XidImpl) o; - if (_formatID == other.getFormatId()) - { - if (_branchQualifier.length == other.getBranchQualifier().length) - { - for (int i = 0; i < _branchQualifier.length; i++) - { - if (_branchQualifier[i] != other.getBranchQualifier()[i]) - { - return false; - } - } - if (_globalTransactionID.length == other.getGlobalTransactionId().length) - { - for (int i = 0; i < _globalTransactionID.length; i++) - { - if (_globalTransactionID[i] != other.getGlobalTransactionId()[i]) - { - return false; - } - } - // everithing is equal - return true; - } - } - } - } - return false; - } - - @Override - public int hashCode() - { - int result = _branchQualifier != null ? Arrays.hashCode(_branchQualifier) : 0; - result = 31 * result + _formatID; - result = 31 * result + (_globalTransactionID != null ? Arrays.hashCode(_globalTransactionID) : 0); - return result; - } - - //-- Static helper method - /** - * Convert an Xid into the AMQP String format. - * - * 4 1 1 g b - * +---+---+---+---+---+---+---+- -+---+---+- -+---+ - * | format_id | g | b | txn-id | br-id | - * +---+---+---+---+---+---+---+- -+---+---+- -+---+ - * 0 4 5 6 6+g 6+g+b - * format_id: an implementation specific format identifier - *

- * gtrid_length: how many bytes of this form the transaction id - *

- * bqual_length: how many bytes of this form the branch id - *

- * data: a sequence of octets of at most 128 bytes containing the txn id and the - * branch id - *

- * Note - The sum of the two lengths must equal the length of the data field. - * - * @param xid an Xid to convert. - * @return The String representation of this Xid - */ - public static org.apache.qpid.transport.Xid convert(Xid xid) - { - return new org.apache.qpid.transport.Xid(xid.getFormatId(), - xid.getGlobalTransactionId(), - xid.getBranchQualifier()); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/exchange/ExchangeDefaults.java b/qpid/java/common/src/main/java/org/apache/qpid/exchange/ExchangeDefaults.java deleted file mode 100644 index 9384002a72..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/exchange/ExchangeDefaults.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.exchange; - -/** - * Defines the names of the standard AMQP exchanges that every AMQP broker should provide. These exchange names - * and type are given in the specification. - * - *

- * TODO A type safe enum, might be more appropriate for the exchange types. - */ -public class ExchangeDefaults -{ - private ExchangeDefaults() - { - } - - /** The default direct exchange, which is a special internal exchange that cannot be explicitly bound to. */ - public static final String DEFAULT_EXCHANGE_NAME = ""; - - /** The pre-defined topic exchange, the broker SHOULD provide this. */ - public static final String TOPIC_EXCHANGE_NAME = "amq.topic"; - - /** Defines the identifying type name of topic exchanges. */ - public static final String TOPIC_EXCHANGE_CLASS = "topic"; - - /** The pre-defined direct exchange, the broker MUST provide this. */ - public static final String DIRECT_EXCHANGE_NAME = "amq.direct"; - - /** Defines the identifying type name of direct exchanges. */ - public static final String DIRECT_EXCHANGE_CLASS = "direct"; - - /** The pre-defined headers exchange, the specification does not say this needs to be provided. */ - public static final String HEADERS_EXCHANGE_NAME = "amq.match"; - - /** Defines the identifying type name of headers exchanges. */ - public static final String HEADERS_EXCHANGE_CLASS = "headers"; - - /** The pre-defined fanout exchange, the boker MUST provide this. */ - public static final String FANOUT_EXCHANGE_NAME = "amq.fanout"; - - /** Defines the identifying type name of fanout exchanges. */ - public static final String FANOUT_EXCHANGE_CLASS = "fanout"; - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/filter/ArithmeticExpression.java b/qpid/java/common/src/main/java/org/apache/qpid/filter/ArithmeticExpression.java deleted file mode 100644 index 35a7c93043..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/filter/ArithmeticExpression.java +++ /dev/null @@ -1,263 +0,0 @@ -/** - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.qpid.filter; -// -// Based on like named file from r450141 of the Apache ActiveMQ project -// - -/** - * An expression which performs an operation on two expression values - */ -public abstract class ArithmeticExpression extends BinaryExpression -{ - - protected static final int INTEGER = 1; - protected static final int LONG = 2; - protected static final int DOUBLE = 3; - - public ArithmeticExpression(Expression left, Expression right) - { - super(left, right); - } - - public static Expression createPlus(Expression left, Expression right) - { - return new ArithmeticExpression(left, right) - { - protected Object evaluate(Object lvalue, Object rvalue) - { - if (lvalue instanceof String) - { - String text = (String) lvalue; - String answer = text + rvalue; - - return answer; - } - else if (lvalue instanceof Number) - { - return plus((Number) lvalue, asNumber(rvalue)); - } - - throw new SelectorParsingException("Cannot call plus operation on: " + lvalue + " and: " + rvalue); - } - - public String getExpressionSymbol() - { - return "+"; - } - }; - } - - public static Expression createMinus(Expression left, Expression right) - { - return new ArithmeticExpression(left, right) - { - protected Object evaluate(Object lvalue, Object rvalue) - { - if (lvalue instanceof Number) - { - return minus((Number) lvalue, asNumber(rvalue)); - } - - throw new SelectorParsingException("Cannot call minus operation on: " + lvalue + " and: " + rvalue); - } - - public String getExpressionSymbol() - { - return "-"; - } - }; - } - - public static Expression createMultiply(Expression left, Expression right) - { - return new ArithmeticExpression(left, right) - { - - protected Object evaluate(Object lvalue, Object rvalue) - { - if (lvalue instanceof Number) - { - return multiply((Number) lvalue, asNumber(rvalue)); - } - - throw new SelectorParsingException("Cannot call multiply operation on: " + lvalue + " and: " + rvalue); - } - - public String getExpressionSymbol() - { - return "*"; - } - }; - } - - public static Expression createDivide(Expression left, Expression right) - { - return new ArithmeticExpression(left, right) - { - - protected Object evaluate(Object lvalue, Object rvalue) - { - if (lvalue instanceof Number) - { - return divide((Number) lvalue, asNumber(rvalue)); - } - - throw new SelectorParsingException("Cannot call divide operation on: " + lvalue + " and: " + rvalue); - } - - public String getExpressionSymbol() - { - return "/"; - } - }; - } - - public static Expression createMod(Expression left, Expression right) - { - return new ArithmeticExpression(left, right) - { - - protected Object evaluate(Object lvalue, Object rvalue) - { - if (lvalue instanceof Number) - { - return mod((Number) lvalue, asNumber(rvalue)); - } - - throw new SelectorParsingException("Cannot call mod operation on: " + lvalue + " and: " + rvalue); - } - - public String getExpressionSymbol() - { - return "%"; - } - }; - } - - protected Number plus(Number left, Number right) - { - switch (numberType(left, right)) - { - - case INTEGER: - return Integer.valueOf(left.intValue() + right.intValue()); - - case LONG: - return Long.valueOf(left.longValue() + right.longValue()); - - default: - return Double.valueOf(left.doubleValue() + right.doubleValue()); - } - } - - protected Number minus(Number left, Number right) - { - switch (numberType(left, right)) - { - - case INTEGER: - return Integer.valueOf(left.intValue() - right.intValue()); - - case LONG: - return Long.valueOf(left.longValue() - right.longValue()); - - default: - return Double.valueOf(left.doubleValue() - right.doubleValue()); - } - } - - protected Number multiply(Number left, Number right) - { - switch (numberType(left, right)) - { - - case INTEGER: - return Integer.valueOf(left.intValue() * right.intValue()); - - case LONG: - return Long.valueOf(left.longValue() * right.longValue()); - - default: - return Double.valueOf(left.doubleValue() * right.doubleValue()); - } - } - - protected Number divide(Number left, Number right) - { - return Double.valueOf(left.doubleValue() / right.doubleValue()); - } - - protected Number mod(Number left, Number right) - { - return Double.valueOf(left.doubleValue() % right.doubleValue()); - } - - private int numberType(Number left, Number right) - { - if (isDouble(left) || isDouble(right)) - { - return DOUBLE; - } - else if ((left instanceof Long) || (right instanceof Long)) - { - return LONG; - } - else - { - return INTEGER; - } - } - - private boolean isDouble(Number n) - { - return (n instanceof Float) || (n instanceof Double); - } - - protected Number asNumber(Object value) - { - if (value instanceof Number) - { - return (Number) value; - } - else - { - throw new SelectorParsingException("Cannot convert value: " + value + " into a number"); - } - } - - public Object evaluate(FilterableMessage message) - { - Object lvalue = getLeft().evaluate(message); - if (lvalue == null) - { - return null; - } - - Object rvalue = getRight().evaluate(message); - if (rvalue == null) - { - return null; - } - - return evaluate(lvalue, rvalue); - } - - protected abstract Object evaluate(Object lvalue, Object rvalue); - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/filter/BinaryExpression.java b/qpid/java/common/src/main/java/org/apache/qpid/filter/BinaryExpression.java deleted file mode 100644 index 47f97ea908..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/filter/BinaryExpression.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.qpid.filter; -// -// Based on like named file from r450141 of the Apache ActiveMQ project -// - -/** - * An expression which performs an operation on two expression values. - */ -public abstract class BinaryExpression implements Expression -{ - private final Expression left; - private final Expression right; - - public BinaryExpression(Expression left, Expression right) - { - this.left = left; - this.right = right; - } - - public Expression getLeft() - { - return left; - } - - public Expression getRight() - { - return right; - } - - /** - * @see java.lang.Object#toString() - */ - public String toString() - { - return "(" + left.toString() + " " + getExpressionSymbol() + " " + right.toString() + ")"; - } - - /** - * TODO: more efficient hashCode() - * - * @see java.lang.Object#hashCode() - */ - public int hashCode() - { - return toString().hashCode(); - } - - /** - * TODO: more efficient hashCode() - * - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(Object o) - { - - if ((o == null) || !this.getClass().equals(o.getClass())) - { - return false; - } - - return toString().equals(o.toString()); - - } - - /** - * Returns the symbol that represents this binary expression. For example, addition is - * represented by "+" - * - * @return the expression symbol - */ - public abstract String getExpressionSymbol(); - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/filter/BooleanExpression.java b/qpid/java/common/src/main/java/org/apache/qpid/filter/BooleanExpression.java deleted file mode 100644 index 5b1cf54680..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/filter/BooleanExpression.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.qpid.filter; -// -// Based on like named file from r450141 of the Apache ActiveMQ project -// - -/** - * A BooleanExpression is an expression that always - * produces a Boolean result. - */ -public interface BooleanExpression extends Expression -{ - - /** - * @param message message to match - * @return true if the expression evaluates to Boolean.TRUE. - */ - public boolean matches(FilterableMessage message); - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/filter/ComparisonExpression.java b/qpid/java/common/src/main/java/org/apache/qpid/filter/ComparisonExpression.java deleted file mode 100644 index 76f743000b..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/filter/ComparisonExpression.java +++ /dev/null @@ -1,589 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.filter; -// -// Based on like named file from r450141 of the Apache ActiveMQ project -// - -import java.util.HashSet; -import java.util.List; -import java.util.regex.Pattern; - -/** - * A filter performing a comparison of two objects - */ -public abstract class ComparisonExpression extends BinaryExpression implements BooleanExpression -{ - - public static BooleanExpression createBetween(Expression value, Expression left, Expression right) - { - return LogicExpression.createAND(createGreaterThanEqual(value, left), createLessThanEqual(value, right)); - } - - public static BooleanExpression createNotBetween(Expression value, Expression left, Expression right) - { - return LogicExpression.createOR(createLessThan(value, left), createGreaterThan(value, right)); - } - - private static final HashSet REGEXP_CONTROL_CHARS = new HashSet(); - - static - { - REGEXP_CONTROL_CHARS.add('.'); - REGEXP_CONTROL_CHARS.add('\\'); - REGEXP_CONTROL_CHARS.add('['); - REGEXP_CONTROL_CHARS.add(']'); - REGEXP_CONTROL_CHARS.add('^'); - REGEXP_CONTROL_CHARS.add('$'); - REGEXP_CONTROL_CHARS.add('?'); - REGEXP_CONTROL_CHARS.add('*'); - REGEXP_CONTROL_CHARS.add('+'); - REGEXP_CONTROL_CHARS.add('{'); - REGEXP_CONTROL_CHARS.add('}'); - REGEXP_CONTROL_CHARS.add('|'); - REGEXP_CONTROL_CHARS.add('('); - REGEXP_CONTROL_CHARS.add(')'); - REGEXP_CONTROL_CHARS.add(':'); - REGEXP_CONTROL_CHARS.add('&'); - REGEXP_CONTROL_CHARS.add('<'); - REGEXP_CONTROL_CHARS.add('>'); - REGEXP_CONTROL_CHARS.add('='); - REGEXP_CONTROL_CHARS.add('!'); - } - - static class LikeExpression extends UnaryExpression implements BooleanExpression - { - - private Pattern likePattern; - - public LikeExpression(Expression right, String like, int escape) - { - super(right); - - StringBuffer regexp = new StringBuffer(like.length() * 2); - regexp.append("\\A"); // The beginning of the input - for (int i = 0; i < like.length(); i++) - { - char c = like.charAt(i); - if (escape == (0xFFFF & c)) - { - i++; - if (i >= like.length()) - { - // nothing left to escape... - break; - } - - char t = like.charAt(i); - regexp.append("\\x"); - regexp.append(Integer.toHexString(0xFFFF & t)); - } - else if (c == '%') - { - regexp.append(".*?"); // Do a non-greedy match - } - else if (c == '_') - { - regexp.append("."); // match one - } - else if (REGEXP_CONTROL_CHARS.contains(c)) - { - regexp.append("\\x"); - regexp.append(Integer.toHexString(0xFFFF & c)); - } - else - { - regexp.append(c); - } - } - - regexp.append("\\z"); // The end of the input - - likePattern = Pattern.compile(regexp.toString(), Pattern.DOTALL); - } - - /** - * org.apache.activemq.filter.UnaryExpression#getExpressionSymbol() - */ - public String getExpressionSymbol() - { - return "LIKE"; - } - - /** - * org.apache.activemq.filter.Expression#evaluate(MessageEvaluationContext) - */ - public Object evaluate(FilterableMessage message) - { - - Object rv = this.getRight().evaluate(message); - - if (rv == null) - { - return null; - } - - if (!(rv instanceof String)) - { - return - Boolean.FALSE; - } - - return likePattern.matcher((String) rv).matches() ? Boolean.TRUE : Boolean.FALSE; - } - - public boolean matches(FilterableMessage message) - { - Object object = evaluate(message); - - return (object != null) && (object == Boolean.TRUE); - } - } - - public static BooleanExpression createLike(Expression left, String right, String escape) - { - if ((escape != null) && (escape.length() != 1)) - { - throw new SelectorParsingException( - "The ESCAPE string literal is invalid. It can only be one character. Litteral used: " + escape); - } - - int c = -1; - if (escape != null) - { - c = 0xFFFF & escape.charAt(0); - } - - return new LikeExpression(left, right, c); - } - - public static BooleanExpression createNotLike(Expression left, String right, String escape) - { - return UnaryExpression.createNOT(createLike(left, right, escape)); - } - - public static BooleanExpression createInFilter(Expression left, List elements) - { - - if (!(left instanceof PropertyExpression)) - { - throw new SelectorParsingException("Expected a property for In expression, got: " + left); - } - - return UnaryExpression.createInExpression((PropertyExpression) left, elements, false); - - } - - public static BooleanExpression createNotInFilter(Expression left, List elements) - { - - if (!(left instanceof PropertyExpression)) - { - throw new SelectorParsingException("Expected a property for In expression, got: " + left); - } - - return UnaryExpression.createInExpression((PropertyExpression) left, elements, true); - - } - - public static BooleanExpression createIsNull(Expression left) - { - return doCreateEqual(left, ConstantExpression.NULL); - } - - public static BooleanExpression createIsNotNull(Expression left) - { - return UnaryExpression.createNOT(doCreateEqual(left, ConstantExpression.NULL)); - } - - public static BooleanExpression createNotEqual(Expression left, Expression right) - { - return UnaryExpression.createNOT(createEqual(left, right)); - } - - public static BooleanExpression createEqual(Expression left, Expression right) - { - checkEqualOperand(left); - checkEqualOperand(right); - checkEqualOperandCompatability(left, right); - - return doCreateEqual(left, right); - } - - private static BooleanExpression doCreateEqual(Expression left, Expression right) - { - return new EqualExpression(left, right); - } - - public static BooleanExpression createGreaterThan(final Expression left, final Expression right) - { - checkLessThanOperand(left); - checkLessThanOperand(right); - - return new ComparisonExpression(left, right) - { - protected boolean asBoolean(int answer) - { - return answer > 0; - } - - public String getExpressionSymbol() - { - return ">"; - } - }; - } - - public static BooleanExpression createGreaterThanEqual(final Expression left, final Expression right) - { - checkLessThanOperand(left); - checkLessThanOperand(right); - - return new ComparisonExpression(left, right) - { - protected boolean asBoolean(int answer) - { - return answer >= 0; - } - - public String getExpressionSymbol() - { - return ">="; - } - }; - } - - public static BooleanExpression createLessThan(final Expression left, final Expression right) - { - checkLessThanOperand(left); - checkLessThanOperand(right); - - return new ComparisonExpression(left, right) - { - - protected boolean asBoolean(int answer) - { - return answer < 0; - } - - public String getExpressionSymbol() - { - return "<"; - } - - }; - } - - public static BooleanExpression createLessThanEqual(final Expression left, final Expression right) - { - checkLessThanOperand(left); - checkLessThanOperand(right); - - return new ComparisonExpression(left, right) - { - - protected boolean asBoolean(int answer) - { - return answer <= 0; - } - - public String getExpressionSymbol() - { - return "<="; - } - }; - } - - /** - * Only Numeric expressions can be used in {@literal >, >=, < or <=} expressions. - * - * @param expr expression to check - */ - public static void checkLessThanOperand(Expression expr) - { - if (expr instanceof ConstantExpression) - { - Object value = ((ConstantExpression) expr).getValue(); - if (value instanceof Number) - { - return; - } - - // Else it's boolean or a String.. - throw new SelectorParsingException("Value '" + expr + "' cannot be compared."); - } - - if (expr instanceof BooleanExpression) - { - throw new SelectorParsingException("Value '" + expr + "' cannot be compared."); - } - } - - /** - * Validates that the expression can be used in {@literal == or <>} expression. - * Cannot not be NULL TRUE or FALSE literals. - * - * @param expr expression to check - */ - public static void checkEqualOperand(Expression expr) - { - if (expr instanceof ConstantExpression) - { - Object value = ((ConstantExpression) expr).getValue(); - if (value == null) - { - throw new SelectorParsingException("'" + expr + "' cannot be compared."); - } - } - } - - /** - * - * @param left - * @param right - */ - private static void checkEqualOperandCompatability(Expression left, Expression right) - { - if ((left instanceof ConstantExpression) && (right instanceof ConstantExpression)) - { - if ((left instanceof BooleanExpression) && !(right instanceof BooleanExpression)) - { - throw new SelectorParsingException("'" + left + "' cannot be compared with '" + right + "'"); - } - } - } - - public ComparisonExpression(Expression left, Expression right) - { - super(left, right); - } - - public Object evaluate(FilterableMessage message) - { - Comparable lv = (Comparable) getLeft().evaluate(message); - if (lv == null) - { - return null; - } - - Comparable rv = (Comparable) getRight().evaluate(message); - if (rv == null) - { - return null; - } - - return compare(lv, rv); - } - - protected Boolean compare(Comparable lv, Comparable rv) - { - Class lc = lv.getClass(); - Class rc = rv.getClass(); - // If the the objects are not of the same type, - // try to convert up to allow the comparison. - if (lc != rc) - { - if (lc == Byte.class) - { - if (rc == Short.class) - { - lv = ((Number) lv).shortValue(); - } - else if (rc == Integer.class) - { - lv = ((Number) lv).intValue(); - } - else if (rc == Long.class) - { - lv = ((Number) lv).longValue(); - } - else if (rc == Float.class) - { - lv = ((Number) lv).floatValue(); - } - else if (rc == Double.class) - { - lv = ((Number) lv).doubleValue(); - } - else - { - return Boolean.FALSE; - } - } - else if (lc == Short.class) - { - if (rc == Integer.class) - { - lv = ((Number) lv).intValue(); - } - else if (rc == Long.class) - { - lv = ((Number) lv).longValue(); - } - else if (rc == Float.class) - { - lv = ((Number) lv).floatValue(); - } - else if (rc == Double.class) - { - lv = ((Number) lv).doubleValue(); - } - else - { - return Boolean.FALSE; - } - } - else if (lc == Integer.class) - { - if (rc == Long.class) - { - lv = ((Number) lv).longValue(); - } - else if (rc == Float.class) - { - lv = ((Number) lv).floatValue(); - } - else if (rc == Double.class) - { - lv = ((Number) lv).doubleValue(); - } - else - { - return Boolean.FALSE; - } - } - else if (lc == Long.class) - { - if (rc == Integer.class) - { - rv = ((Number) rv).longValue(); - } - else if (rc == Float.class) - { - lv = ((Number) lv).floatValue(); - } - else if (rc == Double.class) - { - lv = ((Number) lv).doubleValue(); - } - else - { - return Boolean.FALSE; - } - } - else if (lc == Float.class) - { - if (rc == Integer.class) - { - rv = ((Number) rv).floatValue(); - } - else if (rc == Long.class) - { - rv = ((Number) rv).floatValue(); - } - else if (rc == Double.class) - { - lv = ((Number) lv).doubleValue(); - } - else - { - return Boolean.FALSE; - } - } - else if (lc == Double.class) - { - if (rc == Integer.class) - { - rv = ((Number) rv).doubleValue(); - } - else if (rc == Long.class) - { - rv = ((Number) rv).doubleValue(); - } - else if (rc == Float.class) - { - rv = ((Number) rv).doubleValue(); - } - else - { - return Boolean.FALSE; - } - } - else - { - return Boolean.FALSE; - } - } - - return asBoolean(lv.compareTo(rv)) ? Boolean.TRUE : Boolean.FALSE; - } - - protected abstract boolean asBoolean(int answer); - - public boolean matches(FilterableMessage message) - { - Object object = evaluate(message); - - return (object != null) && (object == Boolean.TRUE); - } - - private static class EqualExpression extends ComparisonExpression - { - public EqualExpression(final Expression left, final Expression right) - { - super(left, right); - } - - public Object evaluate(FilterableMessage message) - { - Object lv = getLeft().evaluate(message); - Object rv = getRight().evaluate(message); - - // Iff one of the values is null - if ((lv == null) ^ (rv == null)) - { - return Boolean.FALSE; - } - - if ((lv == rv) || lv.equals(rv)) - { - return Boolean.TRUE; - } - - if ((lv instanceof Comparable) && (rv instanceof Comparable)) - { - return compare((Comparable) lv, (Comparable) rv); - } - - return Boolean.FALSE; - } - - protected boolean asBoolean(int answer) - { - return answer == 0; - } - - public String getExpressionSymbol() - { - return "="; - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/filter/ConstantExpression.java b/qpid/java/common/src/main/java/org/apache/qpid/filter/ConstantExpression.java deleted file mode 100644 index 9d8509b303..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/filter/ConstantExpression.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.filter; -// -// Based on like named file from r450141 of the Apache ActiveMQ project -// - -import java.math.BigDecimal; - -/** - * Represents a constant expression - */ -public class ConstantExpression implements Expression -{ - - static class BooleanConstantExpression extends ConstantExpression implements BooleanExpression - { - public BooleanConstantExpression(Object value) - { - super(value); - } - - public boolean matches(FilterableMessage message) - { - Object object = evaluate(message); - - return (object != null) && (object == Boolean.TRUE); - } - } - - public static final BooleanConstantExpression NULL = new BooleanConstantExpression(null); - public static final BooleanConstantExpression TRUE = new BooleanConstantExpression(Boolean.TRUE); - public static final BooleanConstantExpression FALSE = new BooleanConstantExpression(Boolean.FALSE); - - private Object _value; - - public static ConstantExpression createFromDecimal(String text) - { - - // Strip off the 'l' or 'L' if needed. - if (text.endsWith("l") || text.endsWith("L")) - { - text = text.substring(0, text.length() - 1); - } - - Number value; - try - { - value = Long.valueOf(text); - } - catch (NumberFormatException e) - { - // The number may be too big to fit in a long. - value = new BigDecimal(text); - } - - long l = value.longValue(); - if ((Integer.MIN_VALUE <= l) && (l <= Integer.MAX_VALUE)) - { - value = value.intValue(); - } - - return new ConstantExpression(value); - } - - public static ConstantExpression createFromHex(String text) - { - Number value = Long.parseLong(text.substring(2), 16); - long l = value.longValue(); - if ((Integer.MIN_VALUE <= l) && (l <= Integer.MAX_VALUE)) - { - value = value.intValue(); - } - - return new ConstantExpression(value); - } - - public static ConstantExpression createFromOctal(String text) - { - Number value = Long.parseLong(text, 8); - long l = value.longValue(); - if ((Integer.MIN_VALUE <= l) && (l <= Integer.MAX_VALUE)) - { - value = value.intValue(); - } - - return new ConstantExpression(value); - } - - public static ConstantExpression createFloat(String text) - { - Number value = new Double(text); - - return new ConstantExpression(value); - } - - public ConstantExpression(Object value) - { - this._value = value; - } - - public Object evaluate(FilterableMessage message) - { - return _value; - } - - public Object getValue() - { - return _value; - } - - /** - * @see java.lang.Object#toString() - */ - public String toString() - { - if (_value == null) - { - return "NULL"; - } - - if (_value instanceof Boolean) - { - return ((Boolean) _value) ? "TRUE" : "FALSE"; - } - - if (_value instanceof String) - { - return encodeString((String) _value); - } - - return _value.toString(); - } - - /** - * TODO: more efficient hashCode() - * - * @see java.lang.Object#hashCode() - */ - public int hashCode() - { - return toString().hashCode(); - } - - /** - * TODO: more efficient hashCode() - * - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(Object o) - { - - if ((o == null) || !this.getClass().equals(o.getClass())) - { - return false; - } - - return toString().equals(o.toString()); - - } - - /** - * Encodes the value of string so that it looks like it would look like - * when it was provided in a selector. - * - * @param s string to encode - * @return encoded string - */ - public static String encodeString(String s) - { - StringBuilder b = new StringBuilder(); - b.append('\''); - for (int i = 0; i < s.length(); i++) - { - char c = s.charAt(i); - if (c == '\'') - { - b.append(c); - } - - b.append(c); - } - - b.append('\''); - - return b.toString(); - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/filter/Expression.java b/qpid/java/common/src/main/java/org/apache/qpid/filter/Expression.java deleted file mode 100644 index 64630c142e..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/filter/Expression.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.qpid.filter; -// -// Based on like named file from r450141 of the Apache ActiveMQ project -// - -/** - * Represents an expression - */ -public interface Expression -{ - - /** - * @param message message to evaluate - * @return the value of this expression - */ - public Object evaluate(FilterableMessage message); - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/filter/FilterableMessage.java b/qpid/java/common/src/main/java/org/apache/qpid/filter/FilterableMessage.java deleted file mode 100644 index 98c34bafd2..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/filter/FilterableMessage.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.qpid.filter; - -public interface FilterableMessage -{ - - boolean isPersistent(); - - boolean isRedelivered(); - - Object getHeader(String name); - - String getReplyTo(); - - String getType(); - - byte getPriority(); - - String getMessageId(); - - long getTimestamp(); - - String getCorrelationId(); - - long getExpiration(); -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/filter/LogicExpression.java b/qpid/java/common/src/main/java/org/apache/qpid/filter/LogicExpression.java deleted file mode 100644 index 6de3a03ee0..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/filter/LogicExpression.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.qpid.filter; -// -// Based on like named file from r450141 of the Apache ActiveMQ project -// - -/** - * A filter performing a comparison of two objects - */ -public abstract class LogicExpression extends BinaryExpression implements BooleanExpression -{ - - public static BooleanExpression createOR(BooleanExpression lvalue, BooleanExpression rvalue) - { - return new OrExpression(lvalue, rvalue); - } - - public static BooleanExpression createAND(BooleanExpression lvalue, BooleanExpression rvalue) - { - return new AndExpression(lvalue, rvalue); - } - - public LogicExpression(BooleanExpression left, BooleanExpression right) - { - super(left, right); - } - - public abstract Object evaluate(FilterableMessage message); - - public boolean matches(FilterableMessage message) - { - Object object = evaluate(message); - - return (object != null) && (object == Boolean.TRUE); - } - - private static class OrExpression extends LogicExpression - { - public OrExpression(final BooleanExpression lvalue, final BooleanExpression rvalue) - { - super(lvalue, rvalue); - } - - public Object evaluate(FilterableMessage message) - { - - Boolean lv = (Boolean) getLeft().evaluate(message); - // Can we do an OR shortcut?? - if ((lv != null) && lv.booleanValue()) - { - return Boolean.TRUE; - } - - Boolean rv = (Boolean) getRight().evaluate(message); - - return (rv == null) ? null : rv; - } - - public String getExpressionSymbol() - { - return "OR"; - } - } - - private static class AndExpression extends LogicExpression - { - public AndExpression(final BooleanExpression lvalue, final BooleanExpression rvalue) - { - super(lvalue, rvalue); - } - - public Object evaluate(FilterableMessage message) - { - - Boolean lv = (Boolean) getLeft().evaluate(message); - - // Can we do an AND shortcut?? - if (lv == null) - { - return null; - } - - if (!lv.booleanValue()) - { - return Boolean.FALSE; - } - - Boolean rv = (Boolean) getRight().evaluate(message); - - return (rv == null) ? null : rv; - } - - public String getExpressionSymbol() - { - return "AND"; - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/filter/PropertyExpression.java b/qpid/java/common/src/main/java/org/apache/qpid/filter/PropertyExpression.java deleted file mode 100644 index 4fb9c0e62f..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/filter/PropertyExpression.java +++ /dev/null @@ -1,234 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.filter; -// -// Based on like named file from r450141 of the Apache ActiveMQ project -// - - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.HashMap; - -/** - * Represents a property expression - */ -public class PropertyExpression implements Expression -{ - // Constants - defined the same as JMS - private static enum JMSDeliveryMode { NON_PERSISTENT, PERSISTENT } - - private static final int DEFAULT_PRIORITY = 4; - - private static final Logger _logger = LoggerFactory.getLogger(PropertyExpression.class); - - private static final HashMap JMS_PROPERTY_EXPRESSIONS = new HashMap(); - - { - JMS_PROPERTY_EXPRESSIONS.put("JMSDestination", new Expression() - { - public Object evaluate(FilterableMessage message) - { - //TODO - return null; - } - }); - JMS_PROPERTY_EXPRESSIONS.put("JMSReplyTo", new ReplyToExpression()); - - JMS_PROPERTY_EXPRESSIONS.put("JMSType", new TypeExpression()); - - JMS_PROPERTY_EXPRESSIONS.put("JMSDeliveryMode", new DeliveryModeExpression()); - - JMS_PROPERTY_EXPRESSIONS.put("JMSPriority", new PriorityExpression()); - - JMS_PROPERTY_EXPRESSIONS.put("JMSMessageID", new MessageIDExpression()); - - JMS_PROPERTY_EXPRESSIONS.put("AMQMessageID", new MessageIDExpression()); - - JMS_PROPERTY_EXPRESSIONS.put("JMSTimestamp", new TimestampExpression()); - - JMS_PROPERTY_EXPRESSIONS.put("JMSCorrelationID", new CorrelationIdExpression()); - - JMS_PROPERTY_EXPRESSIONS.put("JMSExpiration", new ExpirationExpression()); - - JMS_PROPERTY_EXPRESSIONS.put("JMSRedelivered", new Expression() - { - public Object evaluate(FilterableMessage message) - { - return message.isRedelivered(); - } - }); - } - - private final String name; - private final Expression jmsPropertyExpression; - - public boolean outerTest() - { - return false; - } - - public PropertyExpression(String name) - { - this.name = name; - - - - jmsPropertyExpression = JMS_PROPERTY_EXPRESSIONS.get(name); - } - - public Object evaluate(FilterableMessage message) - { - - if (jmsPropertyExpression != null) - { - return jmsPropertyExpression.evaluate(message); - } - else - { - return message.getHeader(name); - } - } - - public String getName() - { - return name; - } - - /** - * @see java.lang.Object#toString() - */ - public String toString() - { - return name; - } - - /** - * @see java.lang.Object#hashCode() - */ - public int hashCode() - { - return name.hashCode(); - } - - /** - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(Object o) - { - - if ((o == null) || !this.getClass().equals(o.getClass())) - { - return false; - } - - return name.equals(((PropertyExpression) o).name); - - } - - private static class ReplyToExpression implements Expression - { - public Object evaluate(FilterableMessage message) - { - String replyTo = message.getReplyTo(); - return replyTo; - } - - } - - private static class TypeExpression implements Expression - { - public Object evaluate(FilterableMessage message) - { - - String type = message.getType(); - return type; - - } - } - - private static class DeliveryModeExpression implements Expression - { - public Object evaluate(FilterableMessage message) - { - JMSDeliveryMode mode = message.isPersistent() ? JMSDeliveryMode.PERSISTENT : - JMSDeliveryMode.NON_PERSISTENT; - if (_logger.isDebugEnabled()) - { - _logger.debug("JMSDeliveryMode is :" + mode); - } - - return mode.toString(); - } - } - - private static class PriorityExpression implements Expression - { - public Object evaluate(FilterableMessage message) - { - byte priority = message.getPriority(); - return (int) priority; - } - } - - private static class MessageIDExpression implements Expression - { - public Object evaluate(FilterableMessage message) - { - - String messageId = message.getMessageId(); - - return messageId; - - } - } - - private static class TimestampExpression implements Expression - { - public Object evaluate(FilterableMessage message) - { - long timestamp = message.getTimestamp(); - return timestamp; - } - } - - private static class CorrelationIdExpression implements Expression - { - public Object evaluate(FilterableMessage message) - { - - String correlationId = message.getCorrelationId(); - - return correlationId; - } - } - - private static class ExpirationExpression implements Expression - { - public Object evaluate(FilterableMessage message) - { - long expiration = message.getExpiration(); - return expiration; - - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/filter/SelectorParsingException.java b/qpid/java/common/src/main/java/org/apache/qpid/filter/SelectorParsingException.java deleted file mode 100644 index 53909a0009..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/filter/SelectorParsingException.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.qpid.filter; - -public class SelectorParsingException extends RuntimeException -{ - public SelectorParsingException(String s) - { - super(s); - } - - public SelectorParsingException(String message, Throwable cause) - { - super(message, cause); - } - - public SelectorParsingException(Throwable cause) - { - super(cause); - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/filter/UnaryExpression.java b/qpid/java/common/src/main/java/org/apache/qpid/filter/UnaryExpression.java deleted file mode 100644 index b80b89840c..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/filter/UnaryExpression.java +++ /dev/null @@ -1,340 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.filter; -// -// Based on like named file from r450141 of the Apache ActiveMQ project -// - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; - -/** - * An expression which performs an operation on two expression values - */ -public abstract class UnaryExpression implements Expression -{ - - private static final BigDecimal BD_LONG_MIN_VALUE = BigDecimal.valueOf(Long.MIN_VALUE); - private Expression right; - - public static Expression createNegate(Expression left) - { - return new NegativeExpression(left); - } - - public static BooleanExpression createInExpression(PropertyExpression right, List elements, final boolean not) - { - - // Use a HashSet if there are many elements. - Collection t; - if (elements.size() == 0) - { - t = null; - } - else if (elements.size() < 5) - { - t = elements; - } - else - { - t = new HashSet(elements); - } - - final Collection inList = t; - - return new InExpression(right, inList, not); - } - - abstract static class BooleanUnaryExpression extends UnaryExpression implements BooleanExpression - { - public BooleanUnaryExpression(Expression left) - { - super(left); - } - - public boolean matches(FilterableMessage message) - { - Object object = evaluate(message); - - return (object != null) && (object == Boolean.TRUE); - } - } - - public static BooleanExpression createNOT(BooleanExpression left) - { - return new NotExpression(left); - } - - public static BooleanExpression createBooleanCast(Expression left) - { - return new BooleanCastExpression(left); - } - - private static Number negate(Number left) - { - Class clazz = left.getClass(); - if (clazz == Integer.class) - { - return -left.intValue(); - } - else if (clazz == Long.class) - { - return -left.longValue(); - } - else if (clazz == Float.class) - { - return -left.floatValue(); - } - else if (clazz == Double.class) - { - return -left.doubleValue(); - } - else if (clazz == BigDecimal.class) - { - // We ussually get a big deciamal when we have Long.MIN_VALUE constant in the - // Selector. Long.MIN_VALUE is too big to store in a Long as a positive so we store it - // as a Big decimal. But it gets Negated right away.. to here we try to covert it back - // to a Long. - BigDecimal bd = (BigDecimal) left; - bd = bd.negate(); - - if (BD_LONG_MIN_VALUE.compareTo(bd) == 0) - { - return Long.MIN_VALUE; - } - - return bd; - } - else - { - throw new SelectorParsingException("Don't know how to negate: " + left); - } - } - - public UnaryExpression(Expression left) - { - this.right = left; - } - - public Expression getRight() - { - return right; - } - - /** - * @see java.lang.Object#toString() - */ - public String toString() - { - return "(" + getExpressionSymbol() + " " + right.toString() + ")"; - } - - /** - * TODO: more efficient hashCode() - * - * @see java.lang.Object#hashCode() - */ - public int hashCode() - { - return toString().hashCode(); - } - - /** - * TODO: more efficient hashCode() - * - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(Object o) - { - return ((o != null) && this.getClass().equals(o.getClass())) && toString().equals(o.toString()); - } - - /** - * Returns the symbol that represents this binary expression. For example, addition is - * represented by "+" - * - * @return symbol - */ - public abstract String getExpressionSymbol(); - - private static class NegativeExpression extends UnaryExpression - { - public NegativeExpression(final Expression left) - { - super(left); - } - - public Object evaluate(FilterableMessage message) - { - Object rvalue = getRight().evaluate(message); - if (rvalue == null) - { - return null; - } - - if (rvalue instanceof Number) - { - return negate((Number) rvalue); - } - - return null; - } - - public String getExpressionSymbol() - { - return "-"; - } - } - - private static class InExpression extends BooleanUnaryExpression - { - private final Collection _inList; - private final boolean _not; - - public InExpression(final PropertyExpression right, final Collection inList, final boolean not) - { - super(right); - _inList = inList; - _not = not; - } - - public Object evaluate(FilterableMessage message) - { - - Object rvalue = getRight().evaluate(message); - if (rvalue == null) - { - return null; - } - - if (rvalue.getClass() != String.class) - { - return null; - } - - if (((_inList != null) && _inList.contains(rvalue)) ^ _not) - { - return Boolean.TRUE; - } - else - { - return Boolean.FALSE; - } - - } - - public String toString() - { - StringBuilder answer = new StringBuilder(String.valueOf(getRight())); - answer.append(" "); - answer.append(getExpressionSymbol()); - answer.append(" ( "); - - int count = 0; - for (Object o : _inList) - { - if (count != 0) - { - answer.append(", "); - } - - answer.append(o); - count++; - } - - answer.append(" )"); - - return answer.toString(); - } - - public String getExpressionSymbol() - { - if (_not) - { - return "NOT IN"; - } - else - { - return "IN"; - } - } - } - - private static class NotExpression extends BooleanUnaryExpression - { - public NotExpression(final BooleanExpression left) - { - super(left); - } - - public Object evaluate(FilterableMessage message) - { - Boolean lvalue = (Boolean) getRight().evaluate(message); - if (lvalue == null) - { - return null; - } - - return lvalue ? Boolean.FALSE : Boolean.TRUE; - } - - public String getExpressionSymbol() - { - return "NOT"; - } - } - - private static class BooleanCastExpression extends BooleanUnaryExpression - { - public BooleanCastExpression(final Expression left) - { - super(left); - } - - public Object evaluate(FilterableMessage message) - { - Object rvalue = getRight().evaluate(message); - if (rvalue == null) - { - return null; - } - - if (!rvalue.getClass().equals(Boolean.class)) - { - return Boolean.FALSE; - } - - return ((Boolean) rvalue) ? Boolean.TRUE : Boolean.FALSE; - } - - public String toString() - { - return getRight().toString(); - } - - public String getExpressionSymbol() - { - return ""; - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/filter/selector/ParseException.java b/qpid/java/common/src/main/java/org/apache/qpid/filter/selector/ParseException.java deleted file mode 100644 index bf28ada12b..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/filter/selector/ParseException.java +++ /dev/null @@ -1,208 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 5.0 */ -/* JavaCCOptions:KEEP_LINE_COL=null */ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.qpid.filter.selector; - -/** - * This exception is thrown when parse errors are encountered. - * You can explicitly create objects of this exception type by - * calling the method generateParseException in the generated - * parser. - * - * You can modify this class to customize your error reporting - * mechanisms so long as you retain the public fields. - */ -public class ParseException extends Exception { - - /** - * The version identifier for this Serializable class. - * Increment only if the serialized form of the - * class changes. - */ - private static final long serialVersionUID = 1L; - - /** - * This constructor is used by the method "generateParseException" - * in the generated parser. Calling this constructor generates - * a new object of this type with the fields "currentToken", - * "expectedTokenSequences", and "tokenImage" set. - */ - public ParseException(Token currentTokenVal, - int[][] expectedTokenSequencesVal, - String[] tokenImageVal - ) - { - super(initialise(currentTokenVal, expectedTokenSequencesVal, tokenImageVal)); - currentToken = currentTokenVal; - expectedTokenSequences = expectedTokenSequencesVal; - tokenImage = tokenImageVal; - } - - /** - * The following constructors are for use by you for whatever - * purpose you can think of. Constructing the exception in this - * manner makes the exception behave in the normal way - i.e., as - * documented in the class "Throwable". The fields "errorToken", - * "expectedTokenSequences", and "tokenImage" do not contain - * relevant information. The JavaCC generated code does not use - * these constructors. - */ - - public ParseException() { - super(); - } - - /** Constructor with message. */ - public ParseException(String message) { - super(message); - } - - - /** - * This is the last token that has been consumed successfully. If - * this object has been created due to a parse error, the token - * followng this token will (therefore) be the first error token. - */ - public Token currentToken; - - /** - * Each entry in this array is an array of integers. Each array - * of integers represents a sequence of tokens (by their ordinal - * values) that is expected at this point of the parse. - */ - public int[][] expectedTokenSequences; - - /** - * This is a reference to the "tokenImage" array of the generated - * parser within which the parse error occurred. This array is - * defined in the generated ...Constants interface. - */ - public String[] tokenImage; - - /** - * It uses "currentToken" and "expectedTokenSequences" to generate a parse - * error message and returns it. If this object has been created - * due to a parse error, and you do not catch it (it gets thrown - * from the parser) the correct error message - * gets displayed. - */ - private static String initialise(Token currentToken, - int[][] expectedTokenSequences, - String[] tokenImage) { - String eol = System.getProperty("line.separator", "\n"); - StringBuffer expected = new StringBuffer(); - int maxSize = 0; - for (int i = 0; i < expectedTokenSequences.length; i++) { - if (maxSize < expectedTokenSequences[i].length) { - maxSize = expectedTokenSequences[i].length; - } - for (int j = 0; j < expectedTokenSequences[i].length; j++) { - expected.append(tokenImage[expectedTokenSequences[i][j]]).append(' '); - } - if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) { - expected.append("..."); - } - expected.append(eol).append(" "); - } - String retval = "Encountered \""; - Token tok = currentToken.next; - for (int i = 0; i < maxSize; i++) { - if (i != 0) retval += " "; - if (tok.kind == 0) { - retval += tokenImage[0]; - break; - } - retval += " " + tokenImage[tok.kind]; - retval += " \""; - retval += add_escapes(tok.image); - retval += " \""; - tok = tok.next; - } - retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn; - retval += "." + eol; - if (expectedTokenSequences.length == 1) { - retval += "Was expecting:" + eol + " "; - } else { - retval += "Was expecting one of:" + eol + " "; - } - retval += expected.toString(); - return retval; - } - - /** - * The end of line string for this machine. - */ - protected String eol = System.getProperty("line.separator", "\n"); - - /** - * Used to convert raw characters to their escaped version - * when these raw version cannot be used as part of an ASCII - * string literal. - */ - static String add_escapes(String str) { - StringBuffer retval = new StringBuffer(); - char ch; - for (int i = 0; i < str.length(); i++) { - switch (str.charAt(i)) - { - case 0 : - continue; - case '\b': - retval.append("\\b"); - continue; - case '\t': - retval.append("\\t"); - continue; - case '\n': - retval.append("\\n"); - continue; - case '\f': - retval.append("\\f"); - continue; - case '\r': - retval.append("\\r"); - continue; - case '\"': - retval.append("\\\""); - continue; - case '\'': - retval.append("\\\'"); - continue; - case '\\': - retval.append("\\\\"); - continue; - default: - if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { - String s = "0000" + Integer.toString(ch, 16); - retval.append("\\u" + s.substring(s.length() - 4, s.length())); - } else { - retval.append(ch); - } - continue; - } - } - return retval.toString(); - } - -} -/* JavaCC - OriginalChecksum=d315306e736475f86f69c53861799960 (do not edit this line) */ diff --git a/qpid/java/common/src/main/java/org/apache/qpid/filter/selector/SelectorParser.java b/qpid/java/common/src/main/java/org/apache/qpid/filter/selector/SelectorParser.java deleted file mode 100644 index ed85de9d8e..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/filter/selector/SelectorParser.java +++ /dev/null @@ -1,1224 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. SelectorParser.java */ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.qpid.filter.selector; - -import java.io.StringReader; -import java.util.ArrayList; - -import org.apache.qpid.filter.ArithmeticExpression; -import org.apache.qpid.filter.BooleanExpression; -import org.apache.qpid.filter.ComparisonExpression; -import org.apache.qpid.filter.ConstantExpression; -import org.apache.qpid.filter.Expression; -import org.apache.qpid.filter.LogicExpression; -import org.apache.qpid.filter.PropertyExpression; -import org.apache.qpid.filter.UnaryExpression; - -/** - * JMS Selector Parser generated by JavaCC - * - * Do not edit this .java file directly - it is autogenerated from SelectorParser.jj - */ -public class SelectorParser implements SelectorParserConstants { - - public SelectorParser() - { - this(new StringReader("")); - } - - public BooleanExpression parse(String sql) throws ParseException - { - this.ReInit(new StringReader(sql)); - - return this.JmsSelector(); - - } - - private BooleanExpression asBooleanExpression(Expression value) throws ParseException - { - if (value instanceof BooleanExpression) - { - return (BooleanExpression) value; - } - if (value instanceof PropertyExpression) - { - return UnaryExpression.createBooleanCast( value ); - } - throw new ParseException("Expression will not result in a boolean value: " + value); - } - -// ---------------------------------------------------------------------------- -// Grammer -// ---------------------------------------------------------------------------- - final public BooleanExpression JmsSelector() throws ParseException { - Expression left=null; - left = orExpression(); - {if (true) return asBooleanExpression(left);} - throw new Error("Missing return statement in function"); - } - - final public Expression orExpression() throws ParseException { - Expression left; - Expression right; - left = andExpression(); - label_1: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case OR: - ; - break; - default: - break label_1; - } - jj_consume_token(OR); - right = andExpression(); - left = LogicExpression.createOR(asBooleanExpression(left), asBooleanExpression(right)); - } - {if (true) return left;} - throw new Error("Missing return statement in function"); - } - - final public Expression andExpression() throws ParseException { - Expression left; - Expression right; - left = equalityExpression(); - label_2: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case AND: - ; - break; - default: - break label_2; - } - jj_consume_token(AND); - right = equalityExpression(); - left = LogicExpression.createAND(asBooleanExpression(left), asBooleanExpression(right)); - } - {if (true) return left;} - throw new Error("Missing return statement in function"); - } - - final public Expression equalityExpression() throws ParseException { - Expression left; - Expression right; - left = comparisonExpression(); - label_3: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case IS: - case 27: - case 28: - ; - break; - default: - break label_3; - } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case 27: - jj_consume_token(27); - right = comparisonExpression(); - left = ComparisonExpression.createEqual(left, right); - break; - case 28: - jj_consume_token(28); - right = comparisonExpression(); - left = ComparisonExpression.createNotEqual(left, right); - break; - default: - if (jj_2_1(2)) { - jj_consume_token(IS); - jj_consume_token(NULL); - left = ComparisonExpression.createIsNull(left); - } else { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case IS: - jj_consume_token(IS); - jj_consume_token(NOT); - jj_consume_token(NULL); - left = ComparisonExpression.createIsNotNull(left); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } - } - } - {if (true) return left;} - throw new Error("Missing return statement in function"); - } - - final public Expression comparisonExpression() throws ParseException { - Expression left; - Expression right; - Expression low; - Expression high; - String t, u; - boolean not; - ArrayList list; - left = addExpression(); - label_4: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case NOT: - case BETWEEN: - case LIKE: - case IN: - case 29: - case 30: - case 31: - case 32: - ; - break; - default: - break label_4; - } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case 29: - jj_consume_token(29); - right = addExpression(); - left = ComparisonExpression.createGreaterThan(left, right); - break; - case 30: - jj_consume_token(30); - right = addExpression(); - left = ComparisonExpression.createGreaterThanEqual(left, right); - break; - case 31: - jj_consume_token(31); - right = addExpression(); - left = ComparisonExpression.createLessThan(left, right); - break; - case 32: - jj_consume_token(32); - right = addExpression(); - left = ComparisonExpression.createLessThanEqual(left, right); - break; - case LIKE: - u=null; - jj_consume_token(LIKE); - t = stringLiteral(); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case ESCAPE: - jj_consume_token(ESCAPE); - u = stringLiteral(); - break; - default: - ; - } - left = ComparisonExpression.createLike(left, t, u); - break; - default: - if (jj_2_2(2)) { - u=null; - jj_consume_token(NOT); - jj_consume_token(LIKE); - t = stringLiteral(); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case ESCAPE: - jj_consume_token(ESCAPE); - u = stringLiteral(); - break; - default: - ; - } - left = ComparisonExpression.createNotLike(left, t, u); - } else { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case BETWEEN: - jj_consume_token(BETWEEN); - low = addExpression(); - jj_consume_token(AND); - high = addExpression(); - left = ComparisonExpression.createBetween(left, low, high); - break; - default: - if (jj_2_3(2)) { - jj_consume_token(NOT); - jj_consume_token(BETWEEN); - low = addExpression(); - jj_consume_token(AND); - high = addExpression(); - left = ComparisonExpression.createNotBetween(left, low, high); - } else { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case IN: - jj_consume_token(IN); - jj_consume_token(33); - t = stringLiteral(); - list = new ArrayList(); - list.add( t ); - label_5: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case 34: - ; - break; - default: - break label_5; - } - jj_consume_token(34); - t = stringLiteral(); - list.add( t ); - } - jj_consume_token(35); - left = ComparisonExpression.createInFilter(left, list); - break; - default: - if (jj_2_4(2)) { - jj_consume_token(NOT); - jj_consume_token(IN); - jj_consume_token(33); - t = stringLiteral(); - list = new ArrayList(); - list.add( t ); - label_6: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case 34: - ; - break; - default: - break label_6; - } - jj_consume_token(34); - t = stringLiteral(); - list.add( t ); - } - jj_consume_token(35); - left = ComparisonExpression.createNotInFilter(left, list); - } else { - jj_consume_token(-1); - throw new ParseException(); - } - } - } - } - } - } - } - {if (true) return left;} - throw new Error("Missing return statement in function"); - } - - final public Expression addExpression() throws ParseException { - Expression left; - Expression right; - left = multExpr(); - label_7: - while (true) { - if (jj_2_5(2147483647)) { - ; - } else { - break label_7; - } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case 36: - jj_consume_token(36); - right = multExpr(); - left = ArithmeticExpression.createPlus(left, right); - break; - case 37: - jj_consume_token(37); - right = multExpr(); - left = ArithmeticExpression.createMinus(left, right); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } - {if (true) return left;} - throw new Error("Missing return statement in function"); - } - - final public Expression multExpr() throws ParseException { - Expression left; - Expression right; - left = unaryExpr(); - label_8: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case 38: - case 39: - case 40: - ; - break; - default: - break label_8; - } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case 38: - jj_consume_token(38); - right = unaryExpr(); - left = ArithmeticExpression.createMultiply(left, right); - break; - case 39: - jj_consume_token(39); - right = unaryExpr(); - left = ArithmeticExpression.createDivide(left, right); - break; - case 40: - jj_consume_token(40); - right = unaryExpr(); - left = ArithmeticExpression.createMod(left, right); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } - {if (true) return left;} - throw new Error("Missing return statement in function"); - } - - final public Expression unaryExpr() throws ParseException { - String s=null; - Expression left=null; - if (jj_2_6(2147483647)) { - jj_consume_token(36); - left = unaryExpr(); - } else { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case 37: - jj_consume_token(37); - left = unaryExpr(); - left = UnaryExpression.createNegate(left); - break; - case NOT: - jj_consume_token(NOT); - left = unaryExpr(); - left = UnaryExpression.createNOT( asBooleanExpression(left) ); - break; - case TRUE: - case FALSE: - case NULL: - case DECIMAL_LITERAL: - case HEX_LITERAL: - case OCTAL_LITERAL: - case FLOATING_POINT_LITERAL: - case STRING_LITERAL: - case ID: - case QUOTED_ID: - case 33: - left = primaryExpr(); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - } - {if (true) return left;} - throw new Error("Missing return statement in function"); - } - - final public Expression primaryExpr() throws ParseException { - Expression left=null; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case TRUE: - case FALSE: - case NULL: - case DECIMAL_LITERAL: - case HEX_LITERAL: - case OCTAL_LITERAL: - case FLOATING_POINT_LITERAL: - case STRING_LITERAL: - left = literal(); - break; - case ID: - case QUOTED_ID: - left = variable(); - break; - case 33: - jj_consume_token(33); - left = orExpression(); - jj_consume_token(35); - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - {if (true) return left;} - throw new Error("Missing return statement in function"); - } - - final public ConstantExpression literal() throws ParseException { - Token t; - String s; - ConstantExpression left=null; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case STRING_LITERAL: - s = stringLiteral(); - left = new ConstantExpression(s); - break; - case DECIMAL_LITERAL: - t = jj_consume_token(DECIMAL_LITERAL); - left = ConstantExpression.createFromDecimal(t.image); - break; - case HEX_LITERAL: - t = jj_consume_token(HEX_LITERAL); - left = ConstantExpression.createFromHex(t.image); - break; - case OCTAL_LITERAL: - t = jj_consume_token(OCTAL_LITERAL); - left = ConstantExpression.createFromOctal(t.image); - break; - case FLOATING_POINT_LITERAL: - t = jj_consume_token(FLOATING_POINT_LITERAL); - left = ConstantExpression.createFloat(t.image); - break; - case TRUE: - jj_consume_token(TRUE); - left = ConstantExpression.TRUE; - break; - case FALSE: - jj_consume_token(FALSE); - left = ConstantExpression.FALSE; - break; - case NULL: - jj_consume_token(NULL); - left = ConstantExpression.NULL; - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - {if (true) return left;} - throw new Error("Missing return statement in function"); - } - - final public String stringLiteral() throws ParseException { - Token t; - StringBuffer rc = new StringBuffer(); - boolean first=true; - t = jj_consume_token(STRING_LITERAL); - // Decode the sting value. - String image = t.image; - for( int i=1; i < image.length()-1; i++ ) { - char c = image.charAt(i); - if( c == (char) 0x27 )//single quote - { - i++; - } - rc.append(c); - } - {if (true) return rc.toString();} - throw new Error("Missing return statement in function"); - } - - final public PropertyExpression variable() throws ParseException { - Token t; - StringBuffer rc = new StringBuffer(); - PropertyExpression left=null; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case ID: - t = jj_consume_token(ID); - left = new PropertyExpression(t.image); - break; - case QUOTED_ID: - t = jj_consume_token(QUOTED_ID); - // Decode the sting value. - String image = t.image; - for( int i=1; i < image.length()-1; i++ ) { - char c = image.charAt(i); - if( c == '"' ) - { - i++; - } - rc.append(c); - } - {if (true) return new PropertyExpression(rc.toString());} - break; - default: - jj_consume_token(-1); - throw new ParseException(); - } - {if (true) return left;} - throw new Error("Missing return statement in function"); - } - - private boolean jj_2_1(int xla) { - jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return !jj_3_1(); } - catch(LookaheadSuccess ls) { return true; } - } - - private boolean jj_2_2(int xla) { - jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return !jj_3_2(); } - catch(LookaheadSuccess ls) { return true; } - } - - private boolean jj_2_3(int xla) { - jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return !jj_3_3(); } - catch(LookaheadSuccess ls) { return true; } - } - - private boolean jj_2_4(int xla) { - jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return !jj_3_4(); } - catch(LookaheadSuccess ls) { return true; } - } - - private boolean jj_2_5(int xla) { - jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return !jj_3_5(); } - catch(LookaheadSuccess ls) { return true; } - } - - private boolean jj_2_6(int xla) { - jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return !jj_3_6(); } - catch(LookaheadSuccess ls) { return true; } - } - - private boolean jj_3R_59() { - if (jj_scan_token(ESCAPE)) return true; - if (jj_3R_38()) return true; - return false; - } - - private boolean jj_3R_38() { - if (jj_scan_token(STRING_LITERAL)) return true; - return false; - } - - private boolean jj_3R_15() { - if (jj_3R_19()) return true; - return false; - } - - private boolean jj_3R_14() { - if (jj_scan_token(NOT)) return true; - if (jj_3R_10()) return true; - return false; - } - - private boolean jj_3R_12() { - if (jj_scan_token(36)) return true; - if (jj_3R_10()) return true; - return false; - } - - private boolean jj_3R_55() { - if (jj_scan_token(IN)) return true; - if (jj_scan_token(33)) return true; - if (jj_3R_38()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_60()) { jj_scanpos = xsp; break; } - } - if (jj_scan_token(35)) return true; - return false; - } - - private boolean jj_3R_47() { - if (jj_scan_token(IS)) return true; - if (jj_scan_token(NOT)) return true; - if (jj_scan_token(NULL)) return true; - return false; - } - - private boolean jj_3R_13() { - if (jj_scan_token(37)) return true; - if (jj_3R_10()) return true; - return false; - } - - private boolean jj_3R_33() { - if (jj_scan_token(NULL)) return true; - return false; - } - - private boolean jj_3_1() { - if (jj_scan_token(IS)) return true; - if (jj_scan_token(NULL)) return true; - return false; - } - - private boolean jj_3R_10() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_12()) { - jj_scanpos = xsp; - if (jj_3R_13()) { - jj_scanpos = xsp; - if (jj_3R_14()) { - jj_scanpos = xsp; - if (jj_3R_15()) return true; - } - } - } - return false; - } - - private boolean jj_3R_46() { - if (jj_scan_token(28)) return true; - if (jj_3R_41()) return true; - return false; - } - - private boolean jj_3R_32() { - if (jj_scan_token(FALSE)) return true; - return false; - } - - private boolean jj_3_3() { - if (jj_scan_token(NOT)) return true; - if (jj_scan_token(BETWEEN)) return true; - if (jj_3R_43()) return true; - if (jj_scan_token(AND)) return true; - if (jj_3R_43()) return true; - return false; - } - - private boolean jj_3R_45() { - if (jj_scan_token(27)) return true; - if (jj_3R_41()) return true; - return false; - } - - private boolean jj_3R_42() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_45()) { - jj_scanpos = xsp; - if (jj_3R_46()) { - jj_scanpos = xsp; - if (jj_3_1()) { - jj_scanpos = xsp; - if (jj_3R_47()) return true; - } - } - } - return false; - } - - private boolean jj_3R_54() { - if (jj_scan_token(BETWEEN)) return true; - if (jj_3R_43()) return true; - if (jj_scan_token(AND)) return true; - if (jj_3R_43()) return true; - return false; - } - - private boolean jj_3R_31() { - if (jj_scan_token(TRUE)) return true; - return false; - } - - private boolean jj_3R_58() { - if (jj_scan_token(ESCAPE)) return true; - if (jj_3R_38()) return true; - return false; - } - - private boolean jj_3R_18() { - if (jj_scan_token(40)) return true; - if (jj_3R_10()) return true; - return false; - } - - private boolean jj_3R_30() { - if (jj_scan_token(FLOATING_POINT_LITERAL)) return true; - return false; - } - - private boolean jj_3R_39() { - if (jj_3R_41()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_42()) { jj_scanpos = xsp; break; } - } - return false; - } - - private boolean jj_3_2() { - if (jj_scan_token(NOT)) return true; - if (jj_scan_token(LIKE)) return true; - if (jj_3R_38()) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_59()) jj_scanpos = xsp; - return false; - } - - private boolean jj_3R_53() { - if (jj_scan_token(LIKE)) return true; - if (jj_3R_38()) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_58()) jj_scanpos = xsp; - return false; - } - - private boolean jj_3R_17() { - if (jj_scan_token(39)) return true; - if (jj_3R_10()) return true; - return false; - } - - private boolean jj_3R_29() { - if (jj_scan_token(OCTAL_LITERAL)) return true; - return false; - } - - private boolean jj_3R_16() { - if (jj_scan_token(38)) return true; - if (jj_3R_10()) return true; - return false; - } - - private boolean jj_3R_11() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_16()) { - jj_scanpos = xsp; - if (jj_3R_17()) { - jj_scanpos = xsp; - if (jj_3R_18()) return true; - } - } - return false; - } - - private boolean jj_3R_40() { - if (jj_scan_token(AND)) return true; - if (jj_3R_39()) return true; - return false; - } - - private boolean jj_3R_28() { - if (jj_scan_token(HEX_LITERAL)) return true; - return false; - } - - private boolean jj_3R_9() { - if (jj_3R_10()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_11()) { jj_scanpos = xsp; break; } - } - return false; - } - - private boolean jj_3R_27() { - if (jj_scan_token(DECIMAL_LITERAL)) return true; - return false; - } - - private boolean jj_3R_57() { - if (jj_scan_token(37)) return true; - if (jj_3R_9()) return true; - return false; - } - - private boolean jj_3R_36() { - if (jj_3R_39()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_40()) { jj_scanpos = xsp; break; } - } - return false; - } - - private boolean jj_3_5() { - Token xsp; - xsp = jj_scanpos; - if (jj_scan_token(36)) { - jj_scanpos = xsp; - if (jj_scan_token(37)) return true; - } - if (jj_3R_9()) return true; - return false; - } - - private boolean jj_3R_52() { - if (jj_scan_token(32)) return true; - if (jj_3R_43()) return true; - return false; - } - - private boolean jj_3R_35() { - if (jj_scan_token(QUOTED_ID)) return true; - return false; - } - - private boolean jj_3R_56() { - if (jj_scan_token(36)) return true; - if (jj_3R_9()) return true; - return false; - } - - private boolean jj_3R_26() { - if (jj_3R_38()) return true; - return false; - } - - private boolean jj_3R_51() { - if (jj_scan_token(31)) return true; - if (jj_3R_43()) return true; - return false; - } - - private boolean jj_3R_34() { - if (jj_scan_token(ID)) return true; - return false; - } - - private boolean jj_3R_61() { - if (jj_scan_token(34)) return true; - if (jj_3R_38()) return true; - return false; - } - - private boolean jj_3R_48() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_56()) { - jj_scanpos = xsp; - if (jj_3R_57()) return true; - } - return false; - } - - private boolean jj_3R_37() { - if (jj_scan_token(OR)) return true; - if (jj_3R_36()) return true; - return false; - } - - private boolean jj_3R_23() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_26()) { - jj_scanpos = xsp; - if (jj_3R_27()) { - jj_scanpos = xsp; - if (jj_3R_28()) { - jj_scanpos = xsp; - if (jj_3R_29()) { - jj_scanpos = xsp; - if (jj_3R_30()) { - jj_scanpos = xsp; - if (jj_3R_31()) { - jj_scanpos = xsp; - if (jj_3R_32()) { - jj_scanpos = xsp; - if (jj_3R_33()) return true; - } - } - } - } - } - } - } - return false; - } - - private boolean jj_3R_50() { - if (jj_scan_token(30)) return true; - if (jj_3R_43()) return true; - return false; - } - - private boolean jj_3R_24() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_34()) { - jj_scanpos = xsp; - if (jj_3R_35()) return true; - } - return false; - } - - private boolean jj_3R_49() { - if (jj_scan_token(29)) return true; - if (jj_3R_43()) return true; - return false; - } - - private boolean jj_3R_44() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_49()) { - jj_scanpos = xsp; - if (jj_3R_50()) { - jj_scanpos = xsp; - if (jj_3R_51()) { - jj_scanpos = xsp; - if (jj_3R_52()) { - jj_scanpos = xsp; - if (jj_3R_53()) { - jj_scanpos = xsp; - if (jj_3_2()) { - jj_scanpos = xsp; - if (jj_3R_54()) { - jj_scanpos = xsp; - if (jj_3_3()) { - jj_scanpos = xsp; - if (jj_3R_55()) { - jj_scanpos = xsp; - if (jj_3_4()) return true; - } - } - } - } - } - } - } - } - } - return false; - } - - private boolean jj_3R_43() { - if (jj_3R_9()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_48()) { jj_scanpos = xsp; break; } - } - return false; - } - - private boolean jj_3R_25() { - if (jj_3R_36()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_37()) { jj_scanpos = xsp; break; } - } - return false; - } - - private boolean jj_3R_22() { - if (jj_scan_token(33)) return true; - if (jj_3R_25()) return true; - if (jj_scan_token(35)) return true; - return false; - } - - private boolean jj_3R_21() { - if (jj_3R_24()) return true; - return false; - } - - private boolean jj_3R_20() { - if (jj_3R_23()) return true; - return false; - } - - private boolean jj_3R_60() { - if (jj_scan_token(34)) return true; - if (jj_3R_38()) return true; - return false; - } - - private boolean jj_3R_19() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_20()) { - jj_scanpos = xsp; - if (jj_3R_21()) { - jj_scanpos = xsp; - if (jj_3R_22()) return true; - } - } - return false; - } - - private boolean jj_3R_41() { - if (jj_3R_43()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_44()) { jj_scanpos = xsp; break; } - } - return false; - } - - private boolean jj_3_4() { - if (jj_scan_token(NOT)) return true; - if (jj_scan_token(IN)) return true; - if (jj_scan_token(33)) return true; - if (jj_3R_38()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_61()) { jj_scanpos = xsp; break; } - } - if (jj_scan_token(35)) return true; - return false; - } - - private boolean jj_3_6() { - if (jj_scan_token(36)) return true; - if (jj_3R_10()) return true; - return false; - } - - /** Generated Token Manager. */ - public SelectorParserTokenManager token_source; - SimpleCharStream jj_input_stream; - /** Current token. */ - public Token token; - /** Next token. */ - public Token jj_nt; - private int jj_ntk; - private Token jj_scanpos, jj_lastpos; - private int jj_la; - - /** Constructor with InputStream. */ - public SelectorParser(java.io.InputStream stream) { - this(stream, null); - } - /** Constructor with InputStream and supplied encoding */ - public SelectorParser(java.io.InputStream stream, String encoding) { - try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } - token_source = new SelectorParserTokenManager(jj_input_stream); - token = new Token(); - jj_ntk = -1; - } - - /** Reinitialise. */ - public void ReInit(java.io.InputStream stream) { - ReInit(stream, null); - } - /** Reinitialise. */ - public void ReInit(java.io.InputStream stream, String encoding) { - try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } - token_source.ReInit(jj_input_stream); - token = new Token(); - jj_ntk = -1; - } - - /** Constructor. */ - public SelectorParser(java.io.Reader stream) { - jj_input_stream = new SimpleCharStream(stream, 1, 1); - token_source = new SelectorParserTokenManager(jj_input_stream); - token = new Token(); - jj_ntk = -1; - } - - /** Reinitialise. */ - public void ReInit(java.io.Reader stream) { - jj_input_stream.ReInit(stream, 1, 1); - token_source.ReInit(jj_input_stream); - token = new Token(); - jj_ntk = -1; - } - - /** Constructor with generated Token Manager. */ - public SelectorParser(SelectorParserTokenManager tm) { - token_source = tm; - token = new Token(); - jj_ntk = -1; - } - - /** Reinitialise. */ - public void ReInit(SelectorParserTokenManager tm) { - token_source = tm; - token = new Token(); - jj_ntk = -1; - } - - private Token jj_consume_token(int kind) throws ParseException { - Token oldToken; - if ((oldToken = token).next != null) token = token.next; - else token = token.next = token_source.getNextToken(); - jj_ntk = -1; - if (token.kind == kind) { - return token; - } - token = oldToken; - throw generateParseException(); - } - - static private final class LookaheadSuccess extends java.lang.Error { } - final private LookaheadSuccess jj_ls = new LookaheadSuccess(); - private boolean jj_scan_token(int kind) { - if (jj_scanpos == jj_lastpos) { - jj_la--; - if (jj_scanpos.next == null) { - jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken(); - } else { - jj_lastpos = jj_scanpos = jj_scanpos.next; - } - } else { - jj_scanpos = jj_scanpos.next; - } - if (jj_scanpos.kind != kind) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls; - return false; - } - - -/** Get the next Token. */ - final public Token getNextToken() { - if (token.next != null) token = token.next; - else token = token.next = token_source.getNextToken(); - jj_ntk = -1; - return token; - } - -/** Get the specific Token. */ - final public Token getToken(int index) { - Token t = token; - for (int i = 0; i < index; i++) { - if (t.next != null) t = t.next; - else t = t.next = token_source.getNextToken(); - } - return t; - } - - private int jj_ntk() { - if ((jj_nt=token.next) == null) - return (jj_ntk = (token.next=token_source.getNextToken()).kind); - else - return (jj_ntk = jj_nt.kind); - } - - /** Generate ParseException. */ - public ParseException generateParseException() { - Token errortok = token.next; - int line = errortok.beginLine, column = errortok.beginColumn; - String mess = (errortok.kind == 0) ? tokenImage[0] : errortok.image; - return new ParseException("Parse error at line " + line + ", column " + column + ". Encountered: " + mess); - } - - /** Enable tracing. */ - final public void enable_tracing() { - } - - /** Disable tracing. */ - final public void disable_tracing() { - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/filter/selector/SelectorParserConstants.java b/qpid/java/common/src/main/java/org/apache/qpid/filter/selector/SelectorParserConstants.java deleted file mode 100644 index 2ffdcddc6c..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/filter/selector/SelectorParserConstants.java +++ /dev/null @@ -1,125 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. SelectorParserConstants.java */ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.qpid.filter.selector; - - -/** - * Token literal values and constants. - * Generated by org.javacc.parser.OtherFilesGen#start() - */ -public interface SelectorParserConstants { - - /** End of File. */ - int EOF = 0; - /** RegularExpression Id. */ - int LINE_COMMENT = 6; - /** RegularExpression Id. */ - int BLOCK_COMMENT = 7; - /** RegularExpression Id. */ - int NOT = 8; - /** RegularExpression Id. */ - int AND = 9; - /** RegularExpression Id. */ - int OR = 10; - /** RegularExpression Id. */ - int BETWEEN = 11; - /** RegularExpression Id. */ - int LIKE = 12; - /** RegularExpression Id. */ - int ESCAPE = 13; - /** RegularExpression Id. */ - int IN = 14; - /** RegularExpression Id. */ - int IS = 15; - /** RegularExpression Id. */ - int TRUE = 16; - /** RegularExpression Id. */ - int FALSE = 17; - /** RegularExpression Id. */ - int NULL = 18; - /** RegularExpression Id. */ - int DECIMAL_LITERAL = 19; - /** RegularExpression Id. */ - int HEX_LITERAL = 20; - /** RegularExpression Id. */ - int OCTAL_LITERAL = 21; - /** RegularExpression Id. */ - int FLOATING_POINT_LITERAL = 22; - /** RegularExpression Id. */ - int EXPONENT = 23; - /** RegularExpression Id. */ - int STRING_LITERAL = 24; - /** RegularExpression Id. */ - int ID = 25; - /** RegularExpression Id. */ - int QUOTED_ID = 26; - - /** Lexical state. */ - int DEFAULT = 0; - - /** Literal token values. */ - String[] tokenImage = { - "", - "\" \"", - "\"\\t\"", - "\"\\n\"", - "\"\\r\"", - "\"\\f\"", - "", - "", - "\"NOT\"", - "\"AND\"", - "\"OR\"", - "\"BETWEEN\"", - "\"LIKE\"", - "\"ESCAPE\"", - "\"IN\"", - "\"IS\"", - "\"TRUE\"", - "\"FALSE\"", - "\"NULL\"", - "", - "", - "", - "", - "", - "", - "", - "", - "\"=\"", - "\"<>\"", - "\">\"", - "\">=\"", - "\"<\"", - "\"<=\"", - "\"(\"", - "\",\"", - "\")\"", - "\"+\"", - "\"-\"", - "\"*\"", - "\"/\"", - "\"%\"", - }; - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/filter/selector/SelectorParserTokenManager.java b/qpid/java/common/src/main/java/org/apache/qpid/filter/selector/SelectorParserTokenManager.java deleted file mode 100644 index 96781acf84..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/filter/selector/SelectorParserTokenManager.java +++ /dev/null @@ -1,1066 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. SelectorParserTokenManager.java */ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.qpid.filter.selector; -import java.io.StringReader; -import java.util.ArrayList; -import org.apache.qpid.filter.ArithmeticExpression; -import org.apache.qpid.filter.BooleanExpression; -import org.apache.qpid.filter.ComparisonExpression; -import org.apache.qpid.filter.ConstantExpression; -import org.apache.qpid.filter.Expression; -import org.apache.qpid.filter.LogicExpression; -import org.apache.qpid.filter.PropertyExpression; -import org.apache.qpid.filter.UnaryExpression; - -/** Token Manager. */ -public class SelectorParserTokenManager implements SelectorParserConstants -{ - - /** Debug output. */ - public java.io.PrintStream debugStream = System.out; - /** Set debug output. */ - public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; } -private int jjStopAtPos(int pos, int kind) -{ - jjmatchedKind = kind; - jjmatchedPos = pos; - return pos + 1; -} -private int jjMoveStringLiteralDfa0_0() -{ - switch(curChar) - { - case 9: - jjmatchedKind = 2; - return jjMoveNfa_0(5, 0); - case 10: - jjmatchedKind = 3; - return jjMoveNfa_0(5, 0); - case 12: - jjmatchedKind = 5; - return jjMoveNfa_0(5, 0); - case 13: - jjmatchedKind = 4; - return jjMoveNfa_0(5, 0); - case 32: - jjmatchedKind = 1; - return jjMoveNfa_0(5, 0); - case 37: - jjmatchedKind = 40; - return jjMoveNfa_0(5, 0); - case 40: - jjmatchedKind = 33; - return jjMoveNfa_0(5, 0); - case 41: - jjmatchedKind = 35; - return jjMoveNfa_0(5, 0); - case 42: - jjmatchedKind = 38; - return jjMoveNfa_0(5, 0); - case 43: - jjmatchedKind = 36; - return jjMoveNfa_0(5, 0); - case 44: - jjmatchedKind = 34; - return jjMoveNfa_0(5, 0); - case 45: - jjmatchedKind = 37; - return jjMoveNfa_0(5, 0); - case 47: - jjmatchedKind = 39; - return jjMoveNfa_0(5, 0); - case 60: - jjmatchedKind = 31; - return jjMoveStringLiteralDfa1_0(0x110000000L); - case 61: - jjmatchedKind = 27; - return jjMoveNfa_0(5, 0); - case 62: - jjmatchedKind = 29; - return jjMoveStringLiteralDfa1_0(0x40000000L); - case 65: - return jjMoveStringLiteralDfa1_0(0x200L); - case 66: - return jjMoveStringLiteralDfa1_0(0x800L); - case 69: - return jjMoveStringLiteralDfa1_0(0x2000L); - case 70: - return jjMoveStringLiteralDfa1_0(0x20000L); - case 73: - return jjMoveStringLiteralDfa1_0(0xc000L); - case 76: - return jjMoveStringLiteralDfa1_0(0x1000L); - case 78: - return jjMoveStringLiteralDfa1_0(0x40100L); - case 79: - return jjMoveStringLiteralDfa1_0(0x400L); - case 84: - return jjMoveStringLiteralDfa1_0(0x10000L); - case 97: - return jjMoveStringLiteralDfa1_0(0x200L); - case 98: - return jjMoveStringLiteralDfa1_0(0x800L); - case 101: - return jjMoveStringLiteralDfa1_0(0x2000L); - case 102: - return jjMoveStringLiteralDfa1_0(0x20000L); - case 105: - return jjMoveStringLiteralDfa1_0(0xc000L); - case 108: - return jjMoveStringLiteralDfa1_0(0x1000L); - case 110: - return jjMoveStringLiteralDfa1_0(0x40100L); - case 111: - return jjMoveStringLiteralDfa1_0(0x400L); - case 116: - return jjMoveStringLiteralDfa1_0(0x10000L); - default : - return jjMoveNfa_0(5, 0); - } -} -private int jjMoveStringLiteralDfa1_0(long active0) -{ - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - return jjMoveNfa_0(5, 0); - } - switch(curChar) - { - case 61: - if ((active0 & 0x40000000L) != 0L) - { - jjmatchedKind = 30; - jjmatchedPos = 1; - } - else if ((active0 & 0x100000000L) != 0L) - { - jjmatchedKind = 32; - jjmatchedPos = 1; - } - break; - case 62: - if ((active0 & 0x10000000L) != 0L) - { - jjmatchedKind = 28; - jjmatchedPos = 1; - } - break; - case 65: - return jjMoveStringLiteralDfa2_0(active0, 0x20000L); - case 69: - return jjMoveStringLiteralDfa2_0(active0, 0x800L); - case 73: - return jjMoveStringLiteralDfa2_0(active0, 0x1000L); - case 78: - if ((active0 & 0x4000L) != 0L) - { - jjmatchedKind = 14; - jjmatchedPos = 1; - } - return jjMoveStringLiteralDfa2_0(active0, 0x200L); - case 79: - return jjMoveStringLiteralDfa2_0(active0, 0x100L); - case 82: - if ((active0 & 0x400L) != 0L) - { - jjmatchedKind = 10; - jjmatchedPos = 1; - } - return jjMoveStringLiteralDfa2_0(active0, 0x10000L); - case 83: - if ((active0 & 0x8000L) != 0L) - { - jjmatchedKind = 15; - jjmatchedPos = 1; - } - return jjMoveStringLiteralDfa2_0(active0, 0x2000L); - case 85: - return jjMoveStringLiteralDfa2_0(active0, 0x40000L); - case 97: - return jjMoveStringLiteralDfa2_0(active0, 0x20000L); - case 101: - return jjMoveStringLiteralDfa2_0(active0, 0x800L); - case 105: - return jjMoveStringLiteralDfa2_0(active0, 0x1000L); - case 110: - if ((active0 & 0x4000L) != 0L) - { - jjmatchedKind = 14; - jjmatchedPos = 1; - } - return jjMoveStringLiteralDfa2_0(active0, 0x200L); - case 111: - return jjMoveStringLiteralDfa2_0(active0, 0x100L); - case 114: - if ((active0 & 0x400L) != 0L) - { - jjmatchedKind = 10; - jjmatchedPos = 1; - } - return jjMoveStringLiteralDfa2_0(active0, 0x10000L); - case 115: - if ((active0 & 0x8000L) != 0L) - { - jjmatchedKind = 15; - jjmatchedPos = 1; - } - return jjMoveStringLiteralDfa2_0(active0, 0x2000L); - case 117: - return jjMoveStringLiteralDfa2_0(active0, 0x40000L); - default : - break; - } - return jjMoveNfa_0(5, 1); -} -private int jjMoveStringLiteralDfa2_0(long old0, long active0) -{ - if (((active0 &= old0)) == 0L) - return jjMoveNfa_0(5, 1); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - return jjMoveNfa_0(5, 1); - } - switch(curChar) - { - case 67: - return jjMoveStringLiteralDfa3_0(active0, 0x2000L); - case 68: - if ((active0 & 0x200L) != 0L) - { - jjmatchedKind = 9; - jjmatchedPos = 2; - } - break; - case 75: - return jjMoveStringLiteralDfa3_0(active0, 0x1000L); - case 76: - return jjMoveStringLiteralDfa3_0(active0, 0x60000L); - case 84: - if ((active0 & 0x100L) != 0L) - { - jjmatchedKind = 8; - jjmatchedPos = 2; - } - return jjMoveStringLiteralDfa3_0(active0, 0x800L); - case 85: - return jjMoveStringLiteralDfa3_0(active0, 0x10000L); - case 99: - return jjMoveStringLiteralDfa3_0(active0, 0x2000L); - case 100: - if ((active0 & 0x200L) != 0L) - { - jjmatchedKind = 9; - jjmatchedPos = 2; - } - break; - case 107: - return jjMoveStringLiteralDfa3_0(active0, 0x1000L); - case 108: - return jjMoveStringLiteralDfa3_0(active0, 0x60000L); - case 116: - if ((active0 & 0x100L) != 0L) - { - jjmatchedKind = 8; - jjmatchedPos = 2; - } - return jjMoveStringLiteralDfa3_0(active0, 0x800L); - case 117: - return jjMoveStringLiteralDfa3_0(active0, 0x10000L); - default : - break; - } - return jjMoveNfa_0(5, 2); -} -private int jjMoveStringLiteralDfa3_0(long old0, long active0) -{ - if (((active0 &= old0)) == 0L) - return jjMoveNfa_0(5, 2); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - return jjMoveNfa_0(5, 2); - } - switch(curChar) - { - case 65: - return jjMoveStringLiteralDfa4_0(active0, 0x2000L); - case 69: - if ((active0 & 0x1000L) != 0L) - { - jjmatchedKind = 12; - jjmatchedPos = 3; - } - else if ((active0 & 0x10000L) != 0L) - { - jjmatchedKind = 16; - jjmatchedPos = 3; - } - break; - case 76: - if ((active0 & 0x40000L) != 0L) - { - jjmatchedKind = 18; - jjmatchedPos = 3; - } - break; - case 83: - return jjMoveStringLiteralDfa4_0(active0, 0x20000L); - case 87: - return jjMoveStringLiteralDfa4_0(active0, 0x800L); - case 97: - return jjMoveStringLiteralDfa4_0(active0, 0x2000L); - case 101: - if ((active0 & 0x1000L) != 0L) - { - jjmatchedKind = 12; - jjmatchedPos = 3; - } - else if ((active0 & 0x10000L) != 0L) - { - jjmatchedKind = 16; - jjmatchedPos = 3; - } - break; - case 108: - if ((active0 & 0x40000L) != 0L) - { - jjmatchedKind = 18; - jjmatchedPos = 3; - } - break; - case 115: - return jjMoveStringLiteralDfa4_0(active0, 0x20000L); - case 119: - return jjMoveStringLiteralDfa4_0(active0, 0x800L); - default : - break; - } - return jjMoveNfa_0(5, 3); -} -private int jjMoveStringLiteralDfa4_0(long old0, long active0) -{ - if (((active0 &= old0)) == 0L) - return jjMoveNfa_0(5, 3); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - return jjMoveNfa_0(5, 3); - } - switch(curChar) - { - case 69: - if ((active0 & 0x20000L) != 0L) - { - jjmatchedKind = 17; - jjmatchedPos = 4; - } - return jjMoveStringLiteralDfa5_0(active0, 0x800L); - case 80: - return jjMoveStringLiteralDfa5_0(active0, 0x2000L); - case 101: - if ((active0 & 0x20000L) != 0L) - { - jjmatchedKind = 17; - jjmatchedPos = 4; - } - return jjMoveStringLiteralDfa5_0(active0, 0x800L); - case 112: - return jjMoveStringLiteralDfa5_0(active0, 0x2000L); - default : - break; - } - return jjMoveNfa_0(5, 4); -} -private int jjMoveStringLiteralDfa5_0(long old0, long active0) -{ - if (((active0 &= old0)) == 0L) - return jjMoveNfa_0(5, 4); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - return jjMoveNfa_0(5, 4); - } - switch(curChar) - { - case 69: - if ((active0 & 0x2000L) != 0L) - { - jjmatchedKind = 13; - jjmatchedPos = 5; - } - return jjMoveStringLiteralDfa6_0(active0, 0x800L); - case 101: - if ((active0 & 0x2000L) != 0L) - { - jjmatchedKind = 13; - jjmatchedPos = 5; - } - return jjMoveStringLiteralDfa6_0(active0, 0x800L); - default : - break; - } - return jjMoveNfa_0(5, 5); -} -private int jjMoveStringLiteralDfa6_0(long old0, long active0) -{ - if (((active0 &= old0)) == 0L) - return jjMoveNfa_0(5, 5); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - return jjMoveNfa_0(5, 5); - } - switch(curChar) - { - case 78: - if ((active0 & 0x800L) != 0L) - { - jjmatchedKind = 11; - jjmatchedPos = 6; - } - break; - case 110: - if ((active0 & 0x800L) != 0L) - { - jjmatchedKind = 11; - jjmatchedPos = 6; - } - break; - default : - break; - } - return jjMoveNfa_0(5, 6); -} -static final long[] jjbitVec0 = { - 0xfffffffffffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL -}; -static final long[] jjbitVec2 = { - 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL -}; -private int jjMoveNfa_0(int startState, int curPos) -{ - int strKind = jjmatchedKind; - int strPos = jjmatchedPos; - int seenUpto; - input_stream.backup(seenUpto = curPos + 1); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { throw new Error("Internal Error"); } - curPos = 0; - int startsAt = 0; - jjnewStateCnt = 48; - int i = 1; - jjstateSet[0] = startState; - int kind = 0x7fffffff; - for (;;) - { - if (++jjround == 0x7fffffff) - ReInitRounds(); - if (curChar < 64) - { - long l = 1L << curChar; - do - { - switch(jjstateSet[--i]) - { - case 5: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(0, 3); - else if (curChar == 34) - jjCheckNAddStates(4, 6); - else if (curChar == 36) - { - if (kind > 25) - kind = 25; - jjCheckNAdd(27); - } - else if (curChar == 39) - jjCheckNAddStates(7, 9); - else if (curChar == 46) - jjCheckNAdd(17); - else if (curChar == 47) - jjstateSet[jjnewStateCnt++] = 6; - else if (curChar == 45) - jjstateSet[jjnewStateCnt++] = 0; - if ((0x3fe000000000000L & l) != 0L) - { - if (kind > 19) - kind = 19; - jjCheckNAddTwoStates(14, 15); - } - else if (curChar == 48) - { - if (kind > 21) - kind = 21; - jjCheckNAddTwoStates(45, 47); - } - break; - case 0: - if (curChar == 45) - jjCheckNAddStates(10, 12); - break; - case 1: - if ((0xffffffffffffdbffL & l) != 0L) - jjCheckNAddStates(10, 12); - break; - case 2: - if ((0x2400L & l) != 0L && kind > 6) - kind = 6; - break; - case 3: - if (curChar == 10 && kind > 6) - kind = 6; - break; - case 4: - if (curChar == 13) - jjstateSet[jjnewStateCnt++] = 3; - break; - case 6: - if (curChar == 42) - jjCheckNAddTwoStates(7, 8); - break; - case 7: - if ((0xfffffbffffffffffL & l) != 0L) - jjCheckNAddTwoStates(7, 8); - break; - case 8: - if (curChar == 42) - jjCheckNAddStates(13, 15); - break; - case 9: - if ((0xffff7bffffffffffL & l) != 0L) - jjCheckNAddTwoStates(10, 8); - break; - case 10: - if ((0xfffffbffffffffffL & l) != 0L) - jjCheckNAddTwoStates(10, 8); - break; - case 11: - if (curChar == 47 && kind > 7) - kind = 7; - break; - case 12: - if (curChar == 47) - jjstateSet[jjnewStateCnt++] = 6; - break; - case 13: - if ((0x3fe000000000000L & l) == 0L) - break; - if (kind > 19) - kind = 19; - jjCheckNAddTwoStates(14, 15); - break; - case 14: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 19) - kind = 19; - jjCheckNAddTwoStates(14, 15); - break; - case 16: - if (curChar == 46) - jjCheckNAdd(17); - break; - case 17: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 22) - kind = 22; - jjCheckNAddTwoStates(17, 18); - break; - case 19: - if ((0x280000000000L & l) != 0L) - jjCheckNAdd(20); - break; - case 20: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 22) - kind = 22; - jjCheckNAdd(20); - break; - case 21: - case 22: - if (curChar == 39) - jjCheckNAddStates(7, 9); - break; - case 23: - if (curChar == 39) - jjstateSet[jjnewStateCnt++] = 22; - break; - case 24: - if ((0xffffff7fffffffffL & l) != 0L) - jjCheckNAddStates(7, 9); - break; - case 25: - if (curChar == 39 && kind > 24) - kind = 24; - break; - case 26: - if (curChar != 36) - break; - if (kind > 25) - kind = 25; - jjCheckNAdd(27); - break; - case 27: - if ((0x3ff001000000000L & l) == 0L) - break; - if (kind > 25) - kind = 25; - jjCheckNAdd(27); - break; - case 28: - case 29: - if (curChar == 34) - jjCheckNAddStates(4, 6); - break; - case 30: - if (curChar == 34) - jjstateSet[jjnewStateCnt++] = 29; - break; - case 31: - if ((0xfffffffbffffffffL & l) != 0L) - jjCheckNAddStates(4, 6); - break; - case 32: - if (curChar == 34 && kind > 26) - kind = 26; - break; - case 33: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(0, 3); - break; - case 34: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(34, 35); - break; - case 35: - if (curChar != 46) - break; - if (kind > 22) - kind = 22; - jjCheckNAddTwoStates(36, 37); - break; - case 36: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 22) - kind = 22; - jjCheckNAddTwoStates(36, 37); - break; - case 38: - if ((0x280000000000L & l) != 0L) - jjCheckNAdd(39); - break; - case 39: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 22) - kind = 22; - jjCheckNAdd(39); - break; - case 40: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(40, 41); - break; - case 42: - if ((0x280000000000L & l) != 0L) - jjCheckNAdd(43); - break; - case 43: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 22) - kind = 22; - jjCheckNAdd(43); - break; - case 44: - if (curChar != 48) - break; - if (kind > 21) - kind = 21; - jjCheckNAddTwoStates(45, 47); - break; - case 46: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 20) - kind = 20; - jjstateSet[jjnewStateCnt++] = 46; - break; - case 47: - if ((0xff000000000000L & l) == 0L) - break; - if (kind > 21) - kind = 21; - jjCheckNAdd(47); - break; - default : break; - } - } while(i != startsAt); - } - else if (curChar < 128) - { - long l = 1L << (curChar & 077); - do - { - switch(jjstateSet[--i]) - { - case 5: - case 27: - if ((0x7fffffe87fffffeL & l) == 0L) - break; - if (kind > 25) - kind = 25; - jjCheckNAdd(27); - break; - case 1: - jjAddStates(10, 12); - break; - case 7: - jjCheckNAddTwoStates(7, 8); - break; - case 9: - case 10: - jjCheckNAddTwoStates(10, 8); - break; - case 15: - if ((0x100000001000L & l) != 0L && kind > 19) - kind = 19; - break; - case 18: - if ((0x2000000020L & l) != 0L) - jjAddStates(16, 17); - break; - case 24: - jjAddStates(7, 9); - break; - case 31: - jjAddStates(4, 6); - break; - case 37: - if ((0x2000000020L & l) != 0L) - jjAddStates(18, 19); - break; - case 41: - if ((0x2000000020L & l) != 0L) - jjAddStates(20, 21); - break; - case 45: - if ((0x100000001000000L & l) != 0L) - jjCheckNAdd(46); - break; - case 46: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 20) - kind = 20; - jjCheckNAdd(46); - break; - default : break; - } - } while(i != startsAt); - } - else - { - int hiByte = (int)(curChar >> 8); - int i1 = hiByte >> 6; - long l1 = 1L << (hiByte & 077); - int i2 = (curChar & 0xff) >> 6; - long l2 = 1L << (curChar & 077); - do - { - switch(jjstateSet[--i]) - { - case 1: - if (jjCanMove_0(hiByte, i1, i2, l1, l2)) - jjAddStates(10, 12); - break; - case 7: - if (jjCanMove_0(hiByte, i1, i2, l1, l2)) - jjCheckNAddTwoStates(7, 8); - break; - case 9: - case 10: - if (jjCanMove_0(hiByte, i1, i2, l1, l2)) - jjCheckNAddTwoStates(10, 8); - break; - case 24: - if (jjCanMove_0(hiByte, i1, i2, l1, l2)) - jjAddStates(7, 9); - break; - case 31: - if (jjCanMove_0(hiByte, i1, i2, l1, l2)) - jjAddStates(4, 6); - break; - default : break; - } - } while(i != startsAt); - } - if (kind != 0x7fffffff) - { - jjmatchedKind = kind; - jjmatchedPos = curPos; - kind = 0x7fffffff; - } - ++curPos; - if ((i = jjnewStateCnt) == (startsAt = 48 - (jjnewStateCnt = startsAt))) - break; - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { break; } - } - if (jjmatchedPos > strPos) - return curPos; - - int toRet = Math.max(curPos, seenUpto); - - if (curPos < toRet) - for (i = toRet - Math.min(curPos, seenUpto); i-- > 0; ) - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { throw new Error("Internal Error : Please send a bug report."); } - - if (jjmatchedPos < strPos) - { - jjmatchedKind = strKind; - jjmatchedPos = strPos; - } - else if (jjmatchedPos == strPos && jjmatchedKind > strKind) - jjmatchedKind = strKind; - - return toRet; -} -static final int[] jjnextStates = { - 34, 35, 40, 41, 30, 31, 32, 23, 24, 25, 1, 2, 4, 8, 9, 11, - 19, 20, 38, 39, 42, 43, -}; -private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2) -{ - switch(hiByte) - { - case 0: - return ((jjbitVec2[i2] & l2) != 0L); - default : - if ((jjbitVec0[i1] & l1) != 0L) - return true; - return false; - } -} - -/** Token literal values. */ -public static final String[] jjstrLiteralImages = { -"", null, null, null, null, null, null, null, null, null, null, null, null, -null, null, null, null, null, null, null, null, null, null, null, null, null, null, -"\75", "\74\76", "\76", "\76\75", "\74", "\74\75", "\50", "\54", "\51", "\53", "\55", -"\52", "\57", "\45", }; - -/** Lexer state names. */ -public static final String[] lexStateNames = { - "DEFAULT", -}; -static final long[] jjtoToken = { - 0x1ffff7fff01L, -}; -static final long[] jjtoSkip = { - 0xfeL, -}; -static final long[] jjtoSpecial = { - 0x3eL, -}; -protected SimpleCharStream input_stream; -private final int[] jjrounds = new int[48]; -private final int[] jjstateSet = new int[96]; -protected char curChar; -/** Constructor. */ -public SelectorParserTokenManager(SimpleCharStream stream){ - if (SimpleCharStream.staticFlag) - throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer."); - input_stream = stream; -} - -/** Constructor. */ -public SelectorParserTokenManager(SimpleCharStream stream, int lexState){ - this(stream); - SwitchTo(lexState); -} - -/** Reinitialise parser. */ -public void ReInit(SimpleCharStream stream) -{ - jjmatchedPos = jjnewStateCnt = 0; - curLexState = defaultLexState; - input_stream = stream; - ReInitRounds(); -} -private void ReInitRounds() -{ - int i; - jjround = 0x80000001; - for (i = 48; i-- > 0;) - jjrounds[i] = 0x80000000; -} - -/** Reinitialise parser. */ -public void ReInit(SimpleCharStream stream, int lexState) -{ - ReInit(stream); - SwitchTo(lexState); -} - -/** Switch to specified lex state. */ -public void SwitchTo(int lexState) -{ - if (lexState >= 1 || lexState < 0) - throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE); - else - curLexState = lexState; -} - -protected Token jjFillToken() -{ - final Token t; - final String curTokenImage; - final int beginLine; - final int endLine; - final int beginColumn; - final int endColumn; - String im = jjstrLiteralImages[jjmatchedKind]; - curTokenImage = (im == null) ? input_stream.GetImage() : im; - beginLine = input_stream.getBeginLine(); - beginColumn = input_stream.getBeginColumn(); - endLine = input_stream.getEndLine(); - endColumn = input_stream.getEndColumn(); - t = Token.newToken(jjmatchedKind, curTokenImage); - - t.beginLine = beginLine; - t.endLine = endLine; - t.beginColumn = beginColumn; - t.endColumn = endColumn; - - return t; -} - -int curLexState = 0; -int defaultLexState = 0; -int jjnewStateCnt; -int jjround; -int jjmatchedPos; -int jjmatchedKind; - -/** Get the next Token. */ -public Token getNextToken() -{ - Token specialToken = null; - Token matchedToken; - int curPos = 0; - - EOFLoop : - for (;;) - { - try - { - curChar = input_stream.BeginToken(); - } - catch(java.io.IOException e) - { - jjmatchedKind = 0; - matchedToken = jjFillToken(); - matchedToken.specialToken = specialToken; - return matchedToken; - } - - jjmatchedKind = 0x7fffffff; - jjmatchedPos = 0; - curPos = jjMoveStringLiteralDfa0_0(); - if (jjmatchedKind != 0x7fffffff) - { - if (jjmatchedPos + 1 < curPos) - input_stream.backup(curPos - jjmatchedPos - 1); - if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) - { - matchedToken = jjFillToken(); - matchedToken.specialToken = specialToken; - return matchedToken; - } - else - { - if ((jjtoSpecial[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) - { - matchedToken = jjFillToken(); - if (specialToken == null) - specialToken = matchedToken; - else - { - matchedToken.specialToken = specialToken; - specialToken = (specialToken.next = matchedToken); - } - } - continue EOFLoop; - } - } - int error_line = input_stream.getEndLine(); - int error_column = input_stream.getEndColumn(); - String error_after = null; - boolean EOFSeen = false; - try { input_stream.readChar(); input_stream.backup(1); } - catch (java.io.IOException e1) { - EOFSeen = true; - error_after = curPos <= 1 ? "" : input_stream.GetImage(); - if (curChar == '\n' || curChar == '\r') { - error_line++; - error_column = 0; - } - else - error_column++; - } - if (!EOFSeen) { - input_stream.backup(1); - error_after = curPos <= 1 ? "" : input_stream.GetImage(); - } - throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR); - } -} - -private void jjCheckNAdd(int state) -{ - if (jjrounds[state] != jjround) - { - jjstateSet[jjnewStateCnt++] = state; - jjrounds[state] = jjround; - } -} -private void jjAddStates(int start, int end) -{ - do { - jjstateSet[jjnewStateCnt++] = jjnextStates[start]; - } while (start++ != end); -} -private void jjCheckNAddTwoStates(int state1, int state2) -{ - jjCheckNAdd(state1); - jjCheckNAdd(state2); -} - -private void jjCheckNAddStates(int start, int end) -{ - do { - jjCheckNAdd(jjnextStates[start]); - } while (start++ != end); -} - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/filter/selector/SimpleCharStream.java b/qpid/java/common/src/main/java/org/apache/qpid/filter/selector/SimpleCharStream.java deleted file mode 100644 index c492e5cc23..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/filter/selector/SimpleCharStream.java +++ /dev/null @@ -1,492 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 5.0 */ -/* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.qpid.filter.selector; - -/** - * An implementation of interface CharStream, where the stream is assumed to - * contain only ASCII characters (without unicode processing). - */ - -public class SimpleCharStream -{ -/** Whether parser is static. */ - public static final boolean staticFlag = false; - int bufsize; - int available; - int tokenBegin; -/** Position in buffer. */ - public int bufpos = -1; - protected int bufline[]; - protected int bufcolumn[]; - - protected int column = 0; - protected int line = 1; - - protected boolean prevCharIsCR = false; - protected boolean prevCharIsLF = false; - - protected java.io.Reader inputStream; - - protected char[] buffer; - protected int maxNextCharInd = 0; - protected int inBuf = 0; - protected int tabSize = 8; - - protected void setTabSize(int i) { tabSize = i; } - protected int getTabSize(int i) { return tabSize; } - - - protected void ExpandBuff(boolean wrapAround) - { - char[] newbuffer = new char[bufsize + 2048]; - int newbufline[] = new int[bufsize + 2048]; - int newbufcolumn[] = new int[bufsize + 2048]; - - try - { - if (wrapAround) - { - System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); - System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos); - buffer = newbuffer; - - System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); - System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); - bufline = newbufline; - - System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); - System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); - bufcolumn = newbufcolumn; - - maxNextCharInd = (bufpos += (bufsize - tokenBegin)); - } - else - { - System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); - buffer = newbuffer; - - System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); - bufline = newbufline; - - System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); - bufcolumn = newbufcolumn; - - maxNextCharInd = (bufpos -= tokenBegin); - } - } - catch (Throwable t) - { - throw new Error(t.getMessage()); - } - - - bufsize += 2048; - available = bufsize; - tokenBegin = 0; - } - - protected void FillBuff() throws java.io.IOException - { - if (maxNextCharInd == available) - { - if (available == bufsize) - { - if (tokenBegin > 2048) - { - bufpos = maxNextCharInd = 0; - available = tokenBegin; - } - else if (tokenBegin < 0) - bufpos = maxNextCharInd = 0; - else - ExpandBuff(false); - } - else if (available > tokenBegin) - available = bufsize; - else if ((tokenBegin - available) < 2048) - ExpandBuff(true); - else - available = tokenBegin; - } - - int i; - try { - if ((i = inputStream.read(buffer, maxNextCharInd, available - maxNextCharInd)) == -1) - { - inputStream.close(); - throw new java.io.IOException(); - } - else - maxNextCharInd += i; - return; - } - catch(java.io.IOException e) { - --bufpos; - backup(0); - if (tokenBegin == -1) - tokenBegin = bufpos; - throw e; - } - } - -/** Start. */ - public char BeginToken() throws java.io.IOException - { - tokenBegin = -1; - char c = readChar(); - tokenBegin = bufpos; - - return c; - } - - protected void UpdateLineColumn(char c) - { - column++; - - if (prevCharIsLF) - { - prevCharIsLF = false; - line += (column = 1); - } - else if (prevCharIsCR) - { - prevCharIsCR = false; - if (c == '\n') - { - prevCharIsLF = true; - } - else - line += (column = 1); - } - - switch (c) - { - case '\r' : - prevCharIsCR = true; - break; - case '\n' : - prevCharIsLF = true; - break; - case '\t' : - column--; - column += (tabSize - (column % tabSize)); - break; - default : - break; - } - - bufline[bufpos] = line; - bufcolumn[bufpos] = column; - } - -/** Read a character. */ - public char readChar() throws java.io.IOException - { - if (inBuf > 0) - { - --inBuf; - - if (++bufpos == bufsize) - bufpos = 0; - - return buffer[bufpos]; - } - - if (++bufpos >= maxNextCharInd) - FillBuff(); - - char c = buffer[bufpos]; - - UpdateLineColumn(c); - return c; - } - - @Deprecated - /** - * @deprecated - * @see #getEndColumn - */ - - public int getColumn() { - return bufcolumn[bufpos]; - } - - @Deprecated - /** - * @deprecated - * @see #getEndLine - */ - - public int getLine() { - return bufline[bufpos]; - } - - /** Get token end column number. */ - public int getEndColumn() { - return bufcolumn[bufpos]; - } - - /** Get token end line number. */ - public int getEndLine() { - return bufline[bufpos]; - } - - /** Get token beginning column number. */ - public int getBeginColumn() { - return bufcolumn[tokenBegin]; - } - - /** Get token beginning line number. */ - public int getBeginLine() { - return bufline[tokenBegin]; - } - -/** Backup a number of characters. */ - public void backup(int amount) { - - inBuf += amount; - if ((bufpos -= amount) < 0) - bufpos += bufsize; - } - - /** Constructor. */ - public SimpleCharStream(java.io.Reader dstream, int startline, - int startcolumn, int buffersize) - { - inputStream = dstream; - line = startline; - column = startcolumn - 1; - - available = bufsize = buffersize; - buffer = new char[buffersize]; - bufline = new int[buffersize]; - bufcolumn = new int[buffersize]; - } - - /** Constructor. */ - public SimpleCharStream(java.io.Reader dstream, int startline, - int startcolumn) - { - this(dstream, startline, startcolumn, 4096); - } - - /** Constructor. */ - public SimpleCharStream(java.io.Reader dstream) - { - this(dstream, 1, 1, 4096); - } - - /** Reinitialise. */ - public void ReInit(java.io.Reader dstream, int startline, - int startcolumn, int buffersize) - { - inputStream = dstream; - line = startline; - column = startcolumn - 1; - - if (buffer == null || buffersize != buffer.length) - { - available = bufsize = buffersize; - buffer = new char[buffersize]; - bufline = new int[buffersize]; - bufcolumn = new int[buffersize]; - } - prevCharIsLF = prevCharIsCR = false; - tokenBegin = inBuf = maxNextCharInd = 0; - bufpos = -1; - } - - /** Reinitialise. */ - public void ReInit(java.io.Reader dstream, int startline, - int startcolumn) - { - ReInit(dstream, startline, startcolumn, 4096); - } - - /** Reinitialise. */ - public void ReInit(java.io.Reader dstream) - { - ReInit(dstream, 1, 1, 4096); - } - /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline, - int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException - { - this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); - } - - /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream, int startline, - int startcolumn, int buffersize) - { - this(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); - } - - /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline, - int startcolumn) throws java.io.UnsupportedEncodingException - { - this(dstream, encoding, startline, startcolumn, 4096); - } - - /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream, int startline, - int startcolumn) - { - this(dstream, startline, startcolumn, 4096); - } - - /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException - { - this(dstream, encoding, 1, 1, 4096); - } - - /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream) - { - this(dstream, 1, 1, 4096); - } - - /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream, String encoding, int startline, - int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException - { - ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); - } - - /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream, int startline, - int startcolumn, int buffersize) - { - ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); - } - - /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException - { - ReInit(dstream, encoding, 1, 1, 4096); - } - - /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream) - { - ReInit(dstream, 1, 1, 4096); - } - /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream, String encoding, int startline, - int startcolumn) throws java.io.UnsupportedEncodingException - { - ReInit(dstream, encoding, startline, startcolumn, 4096); - } - /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream, int startline, - int startcolumn) - { - ReInit(dstream, startline, startcolumn, 4096); - } - /** Get token literal value. */ - public String GetImage() - { - if (bufpos >= tokenBegin) - return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); - else - return new String(buffer, tokenBegin, bufsize - tokenBegin) + - new String(buffer, 0, bufpos + 1); - } - - /** Get the suffix. */ - public char[] GetSuffix(int len) - { - char[] ret = new char[len]; - - if ((bufpos + 1) >= len) - System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); - else - { - System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, - len - bufpos - 1); - System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); - } - - return ret; - } - - /** Reset buffer when finished. */ - public void Done() - { - buffer = null; - bufline = null; - bufcolumn = null; - } - - /** - * Method to adjust line and column numbers for the start of a token. - */ - public void adjustBeginLineColumn(int newLine, int newCol) - { - int start = tokenBegin; - int len; - - if (bufpos >= tokenBegin) - { - len = bufpos - tokenBegin + inBuf + 1; - } - else - { - len = bufsize - tokenBegin + bufpos + 1 + inBuf; - } - - int i = 0, j = 0, k = 0; - int nextColDiff = 0, columnDiff = 0; - - while (i < len && bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) - { - bufline[j] = newLine; - nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j]; - bufcolumn[j] = newCol + columnDiff; - columnDiff = nextColDiff; - i++; - } - - if (i < len) - { - bufline[j] = newLine++; - bufcolumn[j] = newCol + columnDiff; - - while (i++ < len) - { - if (bufline[j = start % bufsize] != bufline[++start % bufsize]) - bufline[j] = newLine++; - else - bufline[j] = newLine; - } - } - - line = bufline[j]; - column = bufcolumn[j]; - } - -} -/* JavaCC - OriginalChecksum=dcf3510e97e4ee9a841bdafac162a129 (do not edit this line) */ diff --git a/qpid/java/common/src/main/java/org/apache/qpid/filter/selector/Token.java b/qpid/java/common/src/main/java/org/apache/qpid/filter/selector/Token.java deleted file mode 100644 index aebd21dacc..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/filter/selector/Token.java +++ /dev/null @@ -1,152 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. Token.java Version 5.0 */ -/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.qpid.filter.selector; - -/** - * Describes the input token stream. - */ - -public class Token implements java.io.Serializable { - - /** - * The version identifier for this Serializable class. - * Increment only if the serialized form of the - * class changes. - */ - private static final long serialVersionUID = 1L; - - /** - * An integer that describes the kind of this token. This numbering - * system is determined by JavaCCParser, and a table of these numbers is - * stored in the file ...Constants.java. - */ - public int kind; - - /** The line number of the first character of this Token. */ - public int beginLine; - /** The column number of the first character of this Token. */ - public int beginColumn; - /** The line number of the last character of this Token. */ - public int endLine; - /** The column number of the last character of this Token. */ - public int endColumn; - - /** - * The string image of the token. - */ - public String image; - - /** - * A reference to the next regular (non-special) token from the input - * stream. If this is the last token from the input stream, or if the - * token manager has not read tokens beyond this one, this field is - * set to null. This is true only if this token is also a regular - * token. Otherwise, see below for a description of the contents of - * this field. - */ - public Token next; - - /** - * This field is used to access special tokens that occur prior to this - * token, but after the immediately preceding regular (non-special) token. - * If there are no such special tokens, this field is set to null. - * When there are more than one such special token, this field refers - * to the last of these special tokens, which in turn refers to the next - * previous special token through its specialToken field, and so on - * until the first special token (whose specialToken field is null). - * The next fields of special tokens refer to other special tokens that - * immediately follow it (without an intervening regular token). If there - * is no such token, this field is null. - */ - public Token specialToken; - - /** - * An optional attribute value of the Token. - * Tokens which are not used as syntactic sugar will often contain - * meaningful values that will be used later on by the compiler or - * interpreter. This attribute value is often different from the image. - * Any subclass of Token that actually wants to return a non-null value can - * override this method as appropriate. - */ - public Object getValue() { - return null; - } - - /** - * No-argument constructor - */ - public Token() {} - - /** - * Constructs a new token for the specified Image. - */ - public Token(int kind) - { - this(kind, null); - } - - /** - * Constructs a new token for the specified Image and Kind. - */ - public Token(int kind, String image) - { - this.kind = kind; - this.image = image; - } - - /** - * Returns the image. - */ - public String toString() - { - return image; - } - - /** - * Returns a new Token object, by default. However, if you want, you - * can create and return subclass objects based on the value of ofKind. - * Simply add the cases to the switch for all those special cases. - * For example, if you have a subclass of Token called IDToken that - * you want to create if ofKind is ID, simply add something like : - * - * case MyParserConstants.ID : return new IDToken(ofKind, image); - * - * to the following switch statement. Then you can cast matchedToken - * variable to the appropriate type and use sit in your lexical actions. - */ - public static Token newToken(int ofKind, String image) - { - switch(ofKind) - { - default : return new Token(ofKind, image); - } - } - - public static Token newToken(int ofKind) - { - return newToken(ofKind, null); - } - -} -/* JavaCC - OriginalChecksum=dfd1857bf2f000661cadfe9ef672245e (do not edit this line) */ diff --git a/qpid/java/common/src/main/java/org/apache/qpid/filter/selector/TokenMgrError.java b/qpid/java/common/src/main/java/org/apache/qpid/filter/selector/TokenMgrError.java deleted file mode 100644 index 835339dc53..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/filter/selector/TokenMgrError.java +++ /dev/null @@ -1,168 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 5.0 */ -/* JavaCCOptions: */ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.qpid.filter.selector; - -/** Token Manager Error. */ -public class TokenMgrError extends Error -{ - - /** - * The version identifier for this Serializable class. - * Increment only if the serialized form of the - * class changes. - */ - private static final long serialVersionUID = 1L; - - /* - * Ordinals for various reasons why an Error of this type can be thrown. - */ - - /** - * Lexical error occurred. - */ - static final int LEXICAL_ERROR = 0; - - /** - * An attempt was made to create a second instance of a static token manager. - */ - static final int STATIC_LEXER_ERROR = 1; - - /** - * Tried to change to an invalid lexical state. - */ - static final int INVALID_LEXICAL_STATE = 2; - - /** - * Detected (and bailed out of) an infinite loop in the token manager. - */ - static final int LOOP_DETECTED = 3; - - /** - * Indicates the reason why the exception is thrown. It will have - * one of the above 4 values. - */ - int errorCode; - - /** - * Replaces unprintable characters by their escaped (or unicode escaped) - * equivalents in the given string - */ - protected static final String addEscapes(String str) { - StringBuffer retval = new StringBuffer(); - char ch; - for (int i = 0; i < str.length(); i++) { - switch (str.charAt(i)) - { - case 0 : - continue; - case '\b': - retval.append("\\b"); - continue; - case '\t': - retval.append("\\t"); - continue; - case '\n': - retval.append("\\n"); - continue; - case '\f': - retval.append("\\f"); - continue; - case '\r': - retval.append("\\r"); - continue; - case '\"': - retval.append("\\\""); - continue; - case '\'': - retval.append("\\\'"); - continue; - case '\\': - retval.append("\\\\"); - continue; - default: - if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { - String s = "0000" + Integer.toString(ch, 16); - retval.append("\\u" + s.substring(s.length() - 4, s.length())); - } else { - retval.append(ch); - } - continue; - } - } - return retval.toString(); - } - - /** - * Returns a detailed message for the Error when it is thrown by the - * token manager to indicate a lexical error. - * Parameters : - * EOFSeen : indicates if EOF caused the lexical error - * curLexState : lexical state in which this error occurred - * errorLine : line number when the error occurred - * errorColumn : column number when the error occurred - * errorAfter : prefix that was seen before this error occurred - * curchar : the offending character - * Note: You can customize the lexical error message by modifying this method. - */ - protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { - return("Lexical error at line " + - errorLine + ", column " + - errorColumn + ". Encountered: " + - (EOFSeen ? " " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") + - "after : \"" + addEscapes(errorAfter) + "\""); - } - - /** - * You can also modify the body of this method to customize your error messages. - * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not - * of end-users concern, so you can return something like : - * - * "Internal Error : Please file a bug report .... " - * - * from this method for such cases in the release version of your parser. - */ - public String getMessage() { - return super.getMessage(); - } - - /* - * Constructors of various flavors follow. - */ - - /** No arg constructor. */ - public TokenMgrError() { - } - - /** Constructor with message and reason. */ - public TokenMgrError(String message, int reason) { - super(message); - errorCode = reason; - } - - /** Full Constructor. */ - public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { - this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); - } -} -/* JavaCC - OriginalChecksum=795daaee93a15e0081e60f73df35399f (do not edit this line) */ diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQBody.java deleted file mode 100644 index 6860b46546..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQBody.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.protocol.AMQVersionAwareProtocolSession; -import org.apache.qpid.transport.ByteBufferSender; - -public interface AMQBody -{ - public byte getFrameType(); - - /** - * Get the size of the body - * @return unsigned short - */ - public abstract int getSize(); - - public void writePayload(DataOutput buffer) throws IOException; - - void handle(final int channelId, final AMQVersionAwareProtocolSession amqProtocolSession) throws AMQException; - - long writePayload(ByteBufferSender sender) throws IOException; -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlock.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlock.java deleted file mode 100644 index 8f804bf2d6..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlock.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.transport.ByteBufferSender; - - -/** - * A data block represents something that has a size in bytes and the ability to write itself to a byte - * buffer (similar to a byte array). - */ -public abstract class AMQDataBlock implements EncodableAMQDataBlock -{ - /** - * Get the size of buffer needed to store the byte representation of this - * frame. - * @return unsigned integer - */ - public abstract long getSize(); - - /** - * Writes the datablock to the specified buffer. - * @param buffer the buffer to write to - * @throws IOException if there is a problem writing the output - */ - public abstract void writePayload(DataOutput buffer) throws IOException; - - public abstract long writePayload(ByteBufferSender sender) throws IOException; - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQFrame.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQFrame.java deleted file mode 100644 index 5fcdfb901a..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQFrame.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; -import java.nio.ByteBuffer; - -import org.apache.qpid.transport.ByteBufferSender; -import org.apache.qpid.util.BytesDataOutput; - -public class AMQFrame extends AMQDataBlock implements EncodableAMQDataBlock -{ - private final int _channel; - - private final AMQBody _bodyFrame; - public static final byte FRAME_END_BYTE = (byte) 0xCE; - - - public AMQFrame(final int channel, final AMQBody bodyFrame) - { - _channel = channel; - _bodyFrame = bodyFrame; - } - - public long getSize() - { - return 1 + 2 + 4 + _bodyFrame.getSize() + 1; - } - - public static final int getFrameOverhead() - { - return 1 + 2 + 4 + 1; - } - - - public void writePayload(DataOutput buffer) throws IOException - { - buffer.writeByte(_bodyFrame.getFrameType()); - EncodingUtils.writeUnsignedShort(buffer, _channel); - EncodingUtils.writeUnsignedInteger(buffer, _bodyFrame.getSize()); - _bodyFrame.writePayload(buffer); - buffer.writeByte(FRAME_END_BYTE); - } - - private static final byte[] FRAME_END_BYTE_ARRAY = new byte[] { FRAME_END_BYTE }; - - @Override - public long writePayload(final ByteBufferSender sender) throws IOException - { - byte[] frameHeader = new byte[7]; - BytesDataOutput buffer = new BytesDataOutput(frameHeader); - - buffer.writeByte(_bodyFrame.getFrameType()); - EncodingUtils.writeUnsignedShort(buffer, _channel); - EncodingUtils.writeUnsignedInteger(buffer, _bodyFrame.getSize()); - sender.send(ByteBuffer.wrap(frameHeader)); - - long size = 8 + _bodyFrame.writePayload(sender); - - sender.send(ByteBuffer.wrap(FRAME_END_BYTE_ARRAY)); - return size; - } - - public final int getChannel() - { - return _channel; - } - - public final AMQBody getBodyFrame() - { - return _bodyFrame; - } - - public String toString() - { - return "Frame channelId: " + _channel + ", bodyFrame: " + String.valueOf(_bodyFrame); - } - - public static void writeFrame(DataOutput buffer, final int channel, AMQBody body) throws IOException - { - buffer.writeByte(body.getFrameType()); - EncodingUtils.writeUnsignedShort(buffer, channel); - EncodingUtils.writeUnsignedInteger(buffer, body.getSize()); - body.writePayload(buffer); - buffer.writeByte(FRAME_END_BYTE); - - } - - public static void writeFrames(DataOutput buffer, final int channel, AMQBody body1, AMQBody body2) throws IOException - { - buffer.writeByte(body1.getFrameType()); - EncodingUtils.writeUnsignedShort(buffer, channel); - EncodingUtils.writeUnsignedInteger(buffer, body1.getSize()); - body1.writePayload(buffer); - buffer.writeByte(FRAME_END_BYTE); - buffer.writeByte(body2.getFrameType()); - EncodingUtils.writeUnsignedShort(buffer, channel); - EncodingUtils.writeUnsignedInteger(buffer, body2.getSize()); - body2.writePayload(buffer); - buffer.writeByte(FRAME_END_BYTE); - - } - - public static void writeFrames(DataOutput buffer, final int channel, AMQBody body1, AMQBody body2, AMQBody body3) throws IOException - { - buffer.writeByte(body1.getFrameType()); - EncodingUtils.writeUnsignedShort(buffer, channel); - EncodingUtils.writeUnsignedInteger(buffer, body1.getSize()); - body1.writePayload(buffer); - buffer.writeByte(FRAME_END_BYTE); - buffer.writeByte(body2.getFrameType()); - EncodingUtils.writeUnsignedShort(buffer, channel); - EncodingUtils.writeUnsignedInteger(buffer, body2.getSize()); - body2.writePayload(buffer); - buffer.writeByte(FRAME_END_BYTE); - buffer.writeByte(body3.getFrameType()); - EncodingUtils.writeUnsignedShort(buffer, channel); - EncodingUtils.writeUnsignedInteger(buffer, body3.getSize()); - body3.writePayload(buffer); - buffer.writeByte(FRAME_END_BYTE); - - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQFrameDecodingException.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQFrameDecodingException.java deleted file mode 100644 index 34e9211d1c..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQFrameDecodingException.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.framing; - -import org.apache.qpid.AMQException; -import org.apache.qpid.protocol.AMQConstant; - -/** - * AMQFrameDecodingException indicates that an AMQP frame cannot be decoded because it does not have the correct - * format as defined by the protocol. - */ -public class AMQFrameDecodingException extends AMQException -{ - public AMQFrameDecodingException(AMQConstant errorCode, String message, Throwable cause) - { - super(errorCode, message, cause); - } - - public AMQFrameDecodingException(AMQConstant errorCode, String message) - { - super(errorCode, message, null); - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQMethodBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQMethodBody.java deleted file mode 100644 index 23315d4787..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQMethodBody.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQChannelException; -import org.apache.qpid.AMQConnectionException; -import org.apache.qpid.AMQException; -import org.apache.qpid.protocol.AMQConstant; - -public interface AMQMethodBody extends AMQBody -{ - public static final byte TYPE = 1; - - /** @return unsigned short */ - public int getClazz(); - - /** @return unsigned short */ - public int getMethod(); - - public void writeMethodPayload(DataOutput buffer) throws IOException; - - - public int getSize(); - - public void writePayload(DataOutput buffer) throws IOException; - - public AMQFrame generateFrame(int channelId); - - public String toString(); - - - - /** - * Convenience Method to create a channel not found exception - * - * @param channelId The channel id that is not found - * - * @param methodRegistry - * @return new AMQChannelException - */ - public AMQChannelException getChannelNotFoundException(int channelId, final MethodRegistry methodRegistry); - - public AMQChannelException getChannelException(AMQConstant code, - String message, - final MethodRegistry methodRegistry); - - public AMQConnectionException getConnectionException(AMQConstant code, - String message, - final MethodRegistry methodRegistry); - - - public boolean execute(MethodDispatcher methodDispatcher, int channelId) throws AMQException; -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQMethodBodyImpl.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQMethodBodyImpl.java deleted file mode 100644 index 01deed67ed..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQMethodBodyImpl.java +++ /dev/null @@ -1,212 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.framing; - - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.nio.ByteBuffer; - -import org.apache.qpid.AMQChannelException; -import org.apache.qpid.AMQConnectionException; -import org.apache.qpid.AMQException; -import org.apache.qpid.protocol.AMQConstant; -import org.apache.qpid.protocol.AMQVersionAwareProtocolSession; -import org.apache.qpid.transport.ByteBufferSender; -import org.apache.qpid.util.BytesDataOutput; - -public abstract class AMQMethodBodyImpl implements AMQMethodBody -{ - public static final byte TYPE = 1; - - public AMQMethodBodyImpl() - { - } - - public byte getFrameType() - { - return TYPE; - } - - - /** unsigned short - * - * @return body size*/ - abstract protected int getBodySize(); - - - public AMQFrame generateFrame(int channelId) - { - return new AMQFrame(channelId, this); - } - - /** - * Creates an AMQChannelException for the corresponding body type (a channel exception should include the class and - * method ids of the body it resulted from). - */ - - /** - * Convenience Method to create a channel not found exception - * - * @param channelId The channel id that is not found - * - * @param methodRegistry - * @return new AMQChannelException - */ - public AMQChannelException getChannelNotFoundException(int channelId, final MethodRegistry methodRegistry) - { - return getChannelException(AMQConstant.NOT_FOUND, "Channel not found for id:" + channelId, methodRegistry); - } - - public AMQChannelException getChannelException(AMQConstant code, - String message, - final MethodRegistry methodRegistry) - { - return new AMQChannelException(code, message, getClazz(), getMethod(), methodRegistry); - } - - public AMQConnectionException getConnectionException(AMQConstant code, - String message, - final MethodRegistry methodRegistry) - { - return new AMQConnectionException(code, message, this, methodRegistry); - } - - public void handle(final int channelId, final AMQVersionAwareProtocolSession session) throws AMQException - { - session.methodFrameReceived(channelId, this); - } - - public int getSize() - { - return 2 + 2 + getBodySize(); - } - - public void writePayload(DataOutput buffer) throws IOException - { - EncodingUtils.writeUnsignedShort(buffer, getClazz()); - EncodingUtils.writeUnsignedShort(buffer, getMethod()); - writeMethodPayload(buffer); - } - - @Override - public long writePayload(final ByteBufferSender sender) throws IOException - { - final int size = getSize(); - byte[] bytes = new byte[size]; - BytesDataOutput buffer = new BytesDataOutput(bytes); - writePayload(buffer); - sender.send(ByteBuffer.wrap(bytes)); - return size; - } - - protected int getSizeOf(AMQShortString string) - { - return EncodingUtils.encodedShortStringLength(string); - } - - protected void writeByte(DataOutput buffer, byte b) throws IOException - { - buffer.writeByte(b); - } - - protected void writeAMQShortString(DataOutput buffer, AMQShortString string) throws IOException - { - EncodingUtils.writeShortStringBytes(buffer, string); - } - - protected int readInt(DataInput buffer) throws IOException - { - return buffer.readInt(); - } - - protected void writeInt(DataOutput buffer, int i) throws IOException - { - buffer.writeInt(i); - } - - protected int getSizeOf(FieldTable table) - { - return EncodingUtils.encodedFieldTableLength(table); //To change body of created methods use File | Settings | File Templates. - } - - protected void writeFieldTable(DataOutput buffer, FieldTable table) throws IOException - { - EncodingUtils.writeFieldTableBytes(buffer, table); - } - - protected void writeLong(DataOutput buffer, long l) throws IOException - { - buffer.writeLong(l); - } - - protected int getSizeOf(byte[] response) - { - return (response == null) ? 4 : response.length + 4; - } - - protected void writeBytes(DataOutput buffer, byte[] data) throws IOException - { - EncodingUtils.writeBytes(buffer,data); - } - - protected short readShort(DataInput buffer) throws IOException - { - return EncodingUtils.readShort(buffer); - } - - protected void writeShort(DataOutput buffer, short s) throws IOException - { - EncodingUtils.writeShort(buffer, s); - } - - protected void writeBitfield(DataOutput buffer, byte bitfield0) throws IOException - { - buffer.writeByte(bitfield0); - } - - protected void writeUnsignedShort(DataOutput buffer, int s) throws IOException - { - EncodingUtils.writeUnsignedShort(buffer, s); - } - - protected void writeUnsignedInteger(DataOutput buffer, long i) throws IOException - { - EncodingUtils.writeUnsignedInteger(buffer, i); - } - - - protected void writeUnsignedByte(DataOutput buffer, short unsignedByte) throws IOException - { - EncodingUtils.writeUnsignedByte(buffer, unsignedByte); - } - - protected long readTimestamp(DataInput buffer) throws IOException - { - return EncodingUtils.readTimestamp(buffer); - } - - protected void writeTimestamp(DataOutput buffer, long t) throws IOException - { - EncodingUtils.writeTimestamp(buffer, t); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQProtocolClassException.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQProtocolClassException.java deleted file mode 100644 index 0586a11619..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQProtocolClassException.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.framing; - -/** - * AMQProtocolInstanceException indicates that the protocol class is incorrect in a header. - *

- * TODO Not an AMQP exception as no status code. - */ -public class AMQProtocolClassException extends AMQProtocolHeaderException -{ - public AMQProtocolClassException(String message, Throwable cause) - { - super(message, cause); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQProtocolHeaderException.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQProtocolHeaderException.java deleted file mode 100644 index b55a48067d..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQProtocolHeaderException.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.framing; - -import org.apache.qpid.transport.TransportException; - -public class AMQProtocolHeaderException extends TransportException -{ - public AMQProtocolHeaderException(String message, Throwable cause) - { - super(message, cause); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQProtocolInstanceException.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQProtocolInstanceException.java deleted file mode 100644 index cbc9e724de..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQProtocolInstanceException.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.framing; - -/** - * AMQProtocolInstanceException indicates that the protocol instance is incorrect in a header. - *

- * TODO Not an AMQP exception as no status code. - */ -public class AMQProtocolInstanceException extends AMQProtocolHeaderException -{ - public AMQProtocolInstanceException(String message, Throwable cause) - { - super(message, cause); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQProtocolVersionException.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQProtocolVersionException.java deleted file mode 100644 index 37c384bfc9..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQProtocolVersionException.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.framing; - -/** - * AMQProtocolInstanceException indicates that the client and server differ on expected protocol version in a header. - *

- * TODO Not an AMQP exception as no status code. - */ -public class AMQProtocolVersionException extends AMQProtocolHeaderException -{ - public AMQProtocolVersionException(String message, Throwable cause) - { - super(message, cause); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQShortString.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQShortString.java deleted file mode 100644 index 765d742789..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQShortString.java +++ /dev/null @@ -1,797 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.qpid.framing; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.util.Arrays; -import java.util.Collection; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A short string is a representation of an AMQ Short String - * Short strings differ from the Java String class by being limited to on ASCII characters (0-127) - * and thus can be held more effectively in a byte buffer. - * - */ -public final class AMQShortString implements CharSequence, Comparable -{ - /** - * The maximum number of octets in AMQ short string as defined in AMQP specification - */ - public static final int MAX_LENGTH = 255; - private static final byte MINUS = (byte)'-'; - private static final byte ZERO = (byte) '0'; - - private final class TokenizerImpl implements AMQShortStringTokenizer - { - private final byte _delim; - private int _count = -1; - private int _pos = 0; - - public TokenizerImpl(final byte delim) - { - _delim = delim; - } - - public int countTokens() - { - if(_count == -1) - { - _count = 1 + AMQShortString.this.occurrences(_delim); - } - return _count; - } - - public AMQShortString nextToken() - { - if(_pos <= AMQShortString.this.length()) - { - int nextDelim = AMQShortString.this.indexOf(_delim, _pos); - if(nextDelim == -1) - { - nextDelim = AMQShortString.this.length(); - } - - AMQShortString nextToken = AMQShortString.this.substring(_pos, nextDelim++); - _pos = nextDelim; - return nextToken; - } - else - { - return null; - } - } - - public boolean hasMoreTokens() - { - return _pos <= AMQShortString.this.length(); - } - } - - private AMQShortString substring(final int from, final int to) - { - return new AMQShortString(_data, from+_offset, to-from); - } - - private static final ConcurrentMap _globalInternMap = - new ConcurrentHashMap(); - - private static final Logger _logger = LoggerFactory.getLogger(AMQShortString.class); - - private final byte[] _data; - private final int _offset; - private int _hashCode; - private String _asString = null; - - private final int _length; - private static final char[] EMPTY_CHAR_ARRAY = new char[0]; - - public static final AMQShortString EMPTY_STRING = new AMQShortString((String)null); - - public AMQShortString(byte[] data) - { - if (data == null) - { - throw new NullPointerException("Cannot create AMQShortString with null data[]"); - } - if (data.length > MAX_LENGTH) - { - throw new IllegalArgumentException("Cannot create AMQShortString with number of octets over 255!"); - } - _data = data.clone(); - _length = data.length; - _offset = 0; - } - - public AMQShortString(String data) - { - this((data == null) ? EMPTY_CHAR_ARRAY : data.toCharArray()); - _asString = data; - } - - public AMQShortString(char[] data) - { - if (data == null) - { - throw new NullPointerException("Cannot create AMQShortString with null char[]"); - } - // the current implementation of 0.8/0.9.x short string encoding - // supports only ASCII characters - if (data.length> MAX_LENGTH) - { - throw new IllegalArgumentException("Cannot create AMQShortString with number of octets over 255!"); - } - final int length = data.length; - final byte[] stringBytes = new byte[length]; - int hash = 0; - for (int i = 0; i < length; i++) - { - stringBytes[i] = (byte) (0xFF & data[i]); - hash = (31 * hash) + stringBytes[i]; - } - _hashCode = hash; - _data = stringBytes; - - _length = length; - _offset = 0; - - } - - public AMQShortString(CharSequence charSequence) - { - if (charSequence == null) - { - // it should be possible to create short string for null data - charSequence = ""; - } - // the current implementation of 0.8/0.9.x short string encoding - // supports only ASCII characters - if (charSequence.length() > MAX_LENGTH) - { - throw new IllegalArgumentException("Cannot create AMQShortString with number of octets over 255!"); - } - final int length = charSequence.length(); - final byte[] stringBytes = new byte[length]; - int hash = 0; - for (int i = 0; i < length; i++) - { - stringBytes[i] = ((byte) (0xFF & charSequence.charAt(i))); - hash = (31 * hash) + stringBytes[i]; - - } - - _data = stringBytes; - _hashCode = hash; - _length = length; - _offset = 0; - - } - - private AMQShortString(DataInput data, final int length) throws IOException - { - if (length > MAX_LENGTH) - { - throw new IllegalArgumentException("Cannot create AMQShortString with number of octets over 255!"); - } - byte[] dataBytes = new byte[length]; - data.readFully(dataBytes); - _data = dataBytes; - _offset = 0; - _length = length; - - } - - public AMQShortString(byte[] data, final int offset, final int length) - { - if (length > MAX_LENGTH) - { - throw new IllegalArgumentException("Cannot create AMQShortString with number of octets over 255!"); - } - if (data == null) - { - throw new NullPointerException("Cannot create AMQShortString with null data[]"); - } - - _offset = offset; - _length = length; - _data = data; - } - - public AMQShortString shrink() - { - if(_data.length != _length) - { - return copy(); - } - else - { - return this; - } - } - - /** - * Get the length of the short string - * @return length of the underlying byte array - */ - public int length() - { - return _length; - } - - public char charAt(int index) - { - - return (char) _data[_offset + index]; - - } - - public CharSequence subSequence(int start, int end) - { - return new CharSubSequence(start, end); - } - - public static AMQShortString readFromBuffer(DataInput buffer) throws IOException - { - final int length = buffer.readUnsignedByte(); - if (length == 0) - { - return null; - } - else - { - - return new AMQShortString(buffer, length); - } - } - - public byte[] getBytes() - { - if(_offset == 0 && _length == _data.length) - { - return _data.clone(); - } - else - { - byte[] data = new byte[_length]; - System.arraycopy(_data,_offset,data,0,_length); - return data; - } - } - - public void writeToBuffer(DataOutput buffer) throws IOException - { - - final int size = length(); - buffer.writeByte(size); - buffer.write(_data, _offset, size); - - } - - public boolean endsWith(String s) - { - return endsWith(new AMQShortString(s)); - } - - - public boolean endsWith(AMQShortString otherString) - { - - if (otherString.length() > length()) - { - return false; - } - - - int thisLength = length(); - int otherLength = otherString.length(); - - for (int i = 1; i <= otherLength; i++) - { - if (charAt(thisLength - i) != otherString.charAt(otherLength - i)) - { - return false; - } - } - return true; - } - - public boolean startsWith(String s) - { - return startsWith(new AMQShortString(s)); - } - - public boolean startsWith(AMQShortString otherString) - { - - if (otherString.length() > length()) - { - return false; - } - - for (int i = 0; i < otherString.length(); i++) - { - if (charAt(i) != otherString.charAt(i)) - { - return false; - } - } - - return true; - - } - - public boolean startsWith(CharSequence otherString) - { - if (otherString.length() > length()) - { - return false; - } - - for (int i = 0; i < otherString.length(); i++) - { - if (charAt(i) != otherString.charAt(i)) - { - return false; - } - } - - return true; - } - - - private final class CharSubSequence implements CharSequence - { - private final int _sequenceOffset; - private final int _end; - - public CharSubSequence(final int offset, final int end) - { - _sequenceOffset = offset; - _end = end; - } - - public int length() - { - return _end - _sequenceOffset; - } - - public char charAt(int index) - { - return AMQShortString.this.charAt(index + _sequenceOffset); - } - - public CharSequence subSequence(int start, int end) - { - return new CharSubSequence(start + _sequenceOffset, end + _sequenceOffset); - } - - @Override - public String toString() - { - char[] chars = new char[length()]; - for(int i = 0; i < length(); i++) - { - chars[i] = charAt(i); - } - return new String(chars); - } - } - - public char[] asChars() - { - final int size = length(); - final char[] chars = new char[size]; - - for (int i = 0; i < size; i++) - { - chars[i] = (char) _data[i + _offset]; - } - - return chars; - } - - - public String asString() - { - if (_asString == null) - { - AMQShortString intern = intern(false); - - if(intern == this) - { - _asString = new String(asChars()); - } - else - { - _asString = intern.asString(); - } - - } - return _asString; - } - - public boolean equals(Object o) - { - - if (o == this) - { - return true; - } - - if(o instanceof AMQShortString) - { - return equals((AMQShortString) o); - } - - return false; - - } - - public boolean equals(final AMQShortString otherString) - { - if (otherString == this) - { - return true; - } - - if (otherString == null) - { - return false; - } - - final int hashCode = _hashCode; - - final int otherHashCode = otherString._hashCode; - - if ((hashCode != 0) && (otherHashCode != 0) && (hashCode != otherHashCode)) - { - return false; - } - - final int length = _length; - - if(length != otherString._length) - { - return false; - } - - - final byte[] data = _data; - - final byte[] otherData = otherString._data; - - final int offset = _offset; - - final int otherOffset = otherString._offset; - - if(offset == 0 && otherOffset == 0 && length == data.length && length == otherData.length) - { - return Arrays.equals(data, otherData); - } - else - { - int thisIdx = offset; - int otherIdx = otherOffset; - for(int i = length; i-- != 0; ) - { - if(!(data[thisIdx++] == otherData[otherIdx++])) - { - return false; - } - } - } - - return true; - - } - - public boolean equalsCharSequence(CharSequence s) - { - if(s instanceof AMQShortString) - { - return equals((AMQShortString) s); - } - - if (s == null) - { - return false; - } - - if (s.length() != length()) - { - return false; - } - - for (int i = 0; i < length(); i++) - { - if (charAt(i) != s.charAt(i)) - { - return false; - } - } - - return true; - } - - public int hashCode() - { - int hash = _hashCode; - if (hash == 0) - { - final int size = length(); - - for (int i = 0; i < size; i++) - { - hash = (31 * hash) + _data[i+_offset]; - } - - _hashCode = hash; - } - - return hash; - } - - public void setDirty() - { - _hashCode = 0; - } - - public String toString() - { - return asString(); - } - - public int compareTo(AMQShortString name) - { - if(name == this) - { - return 0; - } - else if (name == null) - { - return 1; - } - else - { - - if (name.length() < length()) - { - return -name.compareTo(this); - } - - for (int i = 0; i < length(); i++) - { - final byte d = _data[i+_offset]; - final byte n = name._data[i+name._offset]; - if (d < n) - { - return -1; - } - - if (d > n) - { - return 1; - } - } - - return (length() == name.length()) ? 0 : -1; - } - } - - - public AMQShortStringTokenizer tokenize(byte delim) - { - return new TokenizerImpl(delim); - } - - - public AMQShortString intern() - { - return intern(true); - } - - public AMQShortString intern(boolean keep) - { - - AMQShortString internString = keep ? _globalInternMap.putIfAbsent(this,this) : _globalInternMap.get(this); - - return internString == null ? this : internString; - - } - - private AMQShortString copy() - { - byte[] dataBytes = new byte[_length]; - System.arraycopy(_data,_offset,dataBytes,0,_length); - return new AMQShortString(dataBytes,0,_length); - } - - private int occurrences(final byte delim) - { - int count = 0; - final int end = _offset + _length; - for(int i = _offset ; i < end ; i++ ) - { - if(_data[i] == delim) - { - count++; - } - } - return count; - } - - private int indexOf(final byte val, final int pos) - { - - for(int i = pos; i < length(); i++) - { - if(_data[_offset+i] == val) - { - return i; - } - } - return -1; - } - - - public static AMQShortString join(final Collection terms, - final AMQShortString delim) - { - if(terms.size() == 0) - { - return EMPTY_STRING; - } - - int size = delim.length() * (terms.size() - 1); - for(AMQShortString term : terms) - { - size += term.length(); - } - - if (size > MAX_LENGTH) - { - throw new IllegalArgumentException("Cannot create AMQShortString with number of octets over 255!"); - } - byte[] data = new byte[size]; - int pos = 0; - final byte[] delimData = delim._data; - final int delimOffset = delim._offset; - final int delimLength = delim._length; - - - for(AMQShortString term : terms) - { - - if(pos!=0) - { - System.arraycopy(delimData, delimOffset,data,pos, delimLength); - pos+=delimLength; - } - System.arraycopy(term._data,term._offset,data,pos,term._length); - pos+=term._length; - } - - - - return new AMQShortString(data,0,size); - } - - public int toIntValue() - { - int pos = _offset; - int val = 0; - - - boolean isNegative = (_data[pos] == MINUS); - if(isNegative) - { - pos++; - } - - final int end = _length + _offset; - - while(pos < end) - { - int digit = (int) (_data[pos++] - ZERO); - if((digit < 0) || (digit > 9)) - { - throw new NumberFormatException("\""+toString()+"\" is not a valid number"); - } - val = val * 10; - val += digit; - } - if(isNegative) - { - val = val * -1; - } - return val; - } - - public boolean contains(final byte b) - { - final int end = _length + _offset; - for(int i = _offset; i < end; i++) - { - if(_data[i] == b) - { - return true; - } - } - return false; //To change body of created methods use File | Settings | File Templates. - } - - public static AMQShortString validValueOf(Object obj) - { - return valueOf(obj,true,true); - } - - static AMQShortString valueOf(Object obj, boolean truncate, boolean nullAsEmptyString) - { - if (obj == null) - { - if (nullAsEmptyString) - { - return EMPTY_STRING; - } - return null; - } - else - { - String value = String.valueOf(obj); - if (truncate && value.length() > AMQShortString.MAX_LENGTH) - { - value = value.substring(0, AMQShortString.MAX_LENGTH - 3) + "..."; - } - return valueOf(value); - } - } - - public static AMQShortString valueOf(Object obj) - { - return valueOf(obj, false, false); - } - - public static AMQShortString valueOf(String obj) - { - if(obj == null) - { - return null; - } - else - { - return new AMQShortString(obj); - } - - } - - public static String toString(AMQShortString amqShortString) - { - return amqShortString == null ? null : amqShortString.asString(); - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQShortStringTokenizer.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQShortStringTokenizer.java deleted file mode 100644 index 25ab60327a..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQShortStringTokenizer.java +++ /dev/null @@ -1,32 +0,0 @@ -/* -* -* Licensed to the Apache Software Foundation (ASF) under one -* or more contributor license agreements. See the NOTICE file -* distributed with this work for additional information -* regarding copyright ownership. The ASF licenses this file -* to you under the Apache License, Version 2.0 (the -* "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -* -*/ -package org.apache.qpid.framing; - - -public interface AMQShortStringTokenizer -{ - - public int countTokens(); - - public AMQShortString nextToken(); - - boolean hasMoreTokens(); -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQType.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQType.java deleted file mode 100644 index 71b5c5a623..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQType.java +++ /dev/null @@ -1,844 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.framing; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.math.BigDecimal; -import java.util.Collection; - -/** - * AMQType is a type that represents the different possible AMQP field table types. It provides operations for each - * of the types to perform tasks such as calculating the size of an instance of the type, converting types between AMQP - * and Java native types, and reading and writing instances of AMQP types in binary formats to and from byte buffers. - */ -public enum AMQType -{ - LONG_STRING('S') - { - public int getEncodingSize(Object value) - { - return EncodingUtils.encodedLongStringLength((String) value); - } - - public String toNativeValue(Object value) - { - if (value != null) - { - return value.toString(); - } - else - { - throw new NullPointerException("Cannot convert: null to String."); - } - } - - public void writeValueImpl(Object value, DataOutput buffer) throws IOException - { - EncodingUtils.writeLongStringBytes(buffer, (String) value); - } - - public Object readValueFromBuffer(DataInput buffer) throws IOException - { - return EncodingUtils.readLongString(buffer); - } - }, - - INTEGER('i') - { - public int getEncodingSize(Object value) - { - return EncodingUtils.unsignedIntegerLength(); - } - - public Long toNativeValue(Object value) - { - if (value instanceof Long) - { - return (Long) value; - } - else if (value instanceof Integer) - { - return ((Integer) value).longValue(); - } - else if (value instanceof Short) - { - return ((Short) value).longValue(); - } - else if (value instanceof Byte) - { - return ((Byte) value).longValue(); - } - else if ((value instanceof String) || (value == null)) - { - return Long.valueOf((String) value); - } - else - { - throw new NumberFormatException("Cannot convert: " + value + "(" + value.getClass().getName() + ") to int."); - } - } - - public void writeValueImpl(Object value, DataOutput buffer) throws IOException - { - EncodingUtils.writeUnsignedInteger(buffer, (Long) value); - } - - public Object readValueFromBuffer(DataInput buffer) throws IOException - { - return EncodingUtils.readUnsignedInteger(buffer); - } - }, - - DECIMAL('D') - { - public int getEncodingSize(Object value) - { - return EncodingUtils.encodedByteLength() + EncodingUtils.encodedIntegerLength(); - } - - public Object toNativeValue(Object value) - { - if (value instanceof BigDecimal) - { - return (BigDecimal) value; - } - else - { - throw new NumberFormatException("Cannot convert: " + value + "(" + value.getClass().getName() - + ") to BigDecimal."); - } - } - - public void writeValueImpl(Object value, DataOutput buffer) throws IOException - { - BigDecimal bd = (BigDecimal) value; - - byte places = new Integer(bd.scale()).byteValue(); - - int unscaled = bd.intValue(); - - EncodingUtils.writeByte(buffer, places); - - EncodingUtils.writeInteger(buffer, unscaled); - } - - public Object readValueFromBuffer(DataInput buffer) throws IOException - { - byte places = EncodingUtils.readByte(buffer); - - int unscaled = EncodingUtils.readInteger(buffer); - - BigDecimal bd = new BigDecimal(unscaled); - - return bd.setScale(places); - } - }, - - TIMESTAMP('T') - { - public int getEncodingSize(Object value) - { - return EncodingUtils.encodedLongLength(); - } - - public Object toNativeValue(Object value) - { - if (value instanceof Long) - { - return (Long) value; - } - else - { - throw new NumberFormatException("Cannot convert: " + value + "(" + value.getClass().getName() - + ") to timestamp."); - } - } - - public void writeValueImpl(Object value, DataOutput buffer) throws IOException - { - EncodingUtils.writeLong(buffer, (Long) value); - } - - public Object readValueFromBuffer(DataInput buffer) throws IOException - { - return EncodingUtils.readLong(buffer); - } - }, - - /** - * Implements the field table type. The native value of a field table type will be an instance of - * {@link FieldTable}, which itself may contain name/value pairs encoded as {@link AMQTypedValue}s. - */ - FIELD_TABLE('F') - { - /** - * Calculates the size of an instance of the type in bytes. - * - * @param value An instance of the type. - * - * @return The size of the instance of the type in bytes. - */ - public int getEncodingSize(Object value) - { - // Ensure that the value is a FieldTable. - if (!(value instanceof FieldTable)) - { - throw new IllegalArgumentException("Value is not a FieldTable."); - } - - FieldTable ftValue = (FieldTable) value; - - // Loop over all name/value pairs adding up size of each. FieldTable itself keeps track of its encoded - // size as entries are added, so no need to loop over all explicitly. - // EncodingUtils calculation of the encoded field table lenth, will include 4 bytes for its 'size' field. - return EncodingUtils.encodedFieldTableLength(ftValue); - } - - /** - * Converts an instance of the type to an equivalent Java native representation. - * - * @param value An instance of the type. - * - * @return An equivalent Java native representation. - */ - public Object toNativeValue(Object value) - { - // Ensure that the value is a FieldTable. - if (!(value instanceof FieldTable)) - { - throw new IllegalArgumentException("Value is not a FieldTable."); - } - - return (FieldTable) value; - } - - /** - * Writes an instance of the type to a specified byte buffer. - * - * @param value An instance of the type. - * @param buffer The byte buffer to write it to. - */ - public void writeValueImpl(Object value, DataOutput buffer) throws IOException - { - // Ensure that the value is a FieldTable. - if (!(value instanceof FieldTable)) - { - throw new IllegalArgumentException("Value is not a FieldTable."); - } - - FieldTable ftValue = (FieldTable) value; - - // Loop over all name/values writing out into buffer. - ftValue.writeToBuffer(buffer); - } - - /** - * Reads an instance of the type from a specified byte buffer. - * - * @param buffer The byte buffer to write it to. - * - * @return An instance of the type. - */ - public Object readValueFromBuffer(DataInput buffer) throws IOException - { - try - { - // Read size of field table then all name/value pairs. - return EncodingUtils.readFieldTable(buffer); - } - catch (AMQFrameDecodingException e) - { - throw new IllegalArgumentException("Unable to read field table from buffer.", e); - } - } - }, - /** - * Implements the field table type. The native value of a field table type will be an instance of - * {@link FieldTable}, which itself may contain name/value pairs encoded as {@link AMQTypedValue}s. - */ - FIELD_ARRAY('A') - { - public int getEncodingSize(Object value) - { - if (!(value instanceof Collection)) - { - throw new IllegalArgumentException("Value is not a Collection."); - } - - FieldArray fieldArrayValue = FieldArray.asFieldArray((Collection)value); - - return 4 + fieldArrayValue.getEncodingSize(); - } - - public Object toNativeValue(Object value) - { - // Ensure that the value is a FieldTable. - if (!(value instanceof Collection)) - { - throw new IllegalArgumentException("Value cannot be converted to a FieldArray."); - } - - return FieldArray.asFieldArray((Collection)value); - } - - public void writeValueImpl(Object value, DataOutput buffer) throws IOException - { - - if (!(value instanceof FieldArray)) - { - throw new IllegalArgumentException("Value is not a FieldArray."); - } - - FieldArray fieldArrayValue = (FieldArray) value; - - // Loop over all name/values writing out into buffer. - fieldArrayValue.writeToBuffer(buffer); - } - - /** - * Reads an instance of the type from a specified byte buffer. - * - * @param buffer The byte buffer to write it to. - * - * @return An instance of the type. - */ - public Object readValueFromBuffer(DataInput buffer) throws IOException - { - // Read size of field table then all name/value pairs. - return FieldArray.readFromBuffer(buffer); - - } - }, - VOID('V') - { - public int getEncodingSize(Object value) - { - return 0; - } - - public Object toNativeValue(Object value) - { - if (value == null) - { - return null; - } - else - { - throw new NumberFormatException("Cannot convert: " + value + "(" + value.getClass().getName() - + ") to null String."); - } - } - - public void writeValueImpl(Object value, DataOutput buffer) - { } - - public Object readValueFromBuffer(DataInput buffer) - { - return null; - } - }, - - BINARY('x') - { - public int getEncodingSize(Object value) - { - return EncodingUtils.encodedLongstrLength((byte[]) value); - } - - public Object toNativeValue(Object value) - { - if ((value instanceof byte[]) || (value == null)) - { - return value; - } - else - { - throw new IllegalArgumentException("Value: " + value + " (" + value.getClass().getName() - + ") cannot be converted to byte[]"); - } - } - - public void writeValueImpl(Object value, DataOutput buffer) throws IOException - { - EncodingUtils.writeLongstr(buffer, (byte[]) value); - } - - public Object readValueFromBuffer(DataInput buffer) throws IOException - { - return EncodingUtils.readLongstr(buffer); - } - }, - - ASCII_STRING('c') - { - public int getEncodingSize(Object value) - { - return EncodingUtils.encodedLongStringLength((String) value); - } - - public String toNativeValue(Object value) - { - if (value != null) - { - return value.toString(); - } - else - { - throw new NullPointerException("Cannot convert: null to String."); - } - } - - public void writeValueImpl(Object value, DataOutput buffer) throws IOException - { - EncodingUtils.writeLongStringBytes(buffer, (String) value); - } - - public Object readValueFromBuffer(DataInput buffer) throws IOException - { - return EncodingUtils.readLongString(buffer); - } - }, - - WIDE_STRING('C') - { - public int getEncodingSize(Object value) - { - // FIXME: use proper charset encoder - return EncodingUtils.encodedLongStringLength((String) value); - } - - public String toNativeValue(Object value) - { - if (value != null) - { - return value.toString(); - } - else - { - throw new NullPointerException("Cannot convert: null to String."); - } - } - - public void writeValueImpl(Object value, DataOutput buffer) throws IOException - { - EncodingUtils.writeLongStringBytes(buffer, (String) value); - } - - public Object readValueFromBuffer(DataInput buffer) throws IOException - { - return EncodingUtils.readLongString(buffer); - } - }, - - BOOLEAN('t') - { - public int getEncodingSize(Object value) - { - return EncodingUtils.encodedBooleanLength(); - } - - public Object toNativeValue(Object value) - { - if (value instanceof Boolean) - { - return (Boolean) value; - } - else if ((value instanceof String) || (value == null)) - { - return Boolean.valueOf((String) value); - } - else - { - throw new NumberFormatException("Cannot convert: " + value + "(" + value.getClass().getName() - + ") to boolean."); - } - } - - public void writeValueImpl(Object value, DataOutput buffer) throws IOException - { - EncodingUtils.writeBoolean(buffer, (Boolean) value); - } - - public Object readValueFromBuffer(DataInput buffer) throws IOException - { - return EncodingUtils.readBoolean(buffer); - } - }, - - ASCII_CHARACTER('k') - { - public int getEncodingSize(Object value) - { - return EncodingUtils.encodedCharLength(); - } - - public Character toNativeValue(Object value) - { - if (value instanceof Character) - { - return (Character) value; - } - else if (value == null) - { - throw new NullPointerException("Cannot convert null into char"); - } - else - { - throw new NumberFormatException("Cannot convert: " + value + "(" + value.getClass().getName() - + ") to char."); - } - } - - public void writeValueImpl(Object value, DataOutput buffer) throws IOException - { - EncodingUtils.writeChar(buffer, (Character) value); - } - - public Object readValueFromBuffer(DataInput buffer) throws IOException - { - return EncodingUtils.readChar(buffer); - } - }, - - BYTE('b') - { - public int getEncodingSize(Object value) - { - return EncodingUtils.encodedByteLength(); - } - - public Byte toNativeValue(Object value) - { - if (value instanceof Byte) - { - return (Byte) value; - } - else if ((value instanceof String) || (value == null)) - { - return Byte.valueOf((String) value); - } - else - { - throw new NumberFormatException("Cannot convert: " + value + "(" + value.getClass().getName() - + ") to byte."); - } - } - - public void writeValueImpl(Object value, DataOutput buffer) throws IOException - { - EncodingUtils.writeByte(buffer, (Byte) value); - } - - public Object readValueFromBuffer(DataInput buffer) throws IOException - { - return EncodingUtils.readByte(buffer); - } - }, - - SHORT('s') - { - public int getEncodingSize(Object value) - { - return EncodingUtils.encodedShortLength(); - } - - public Short toNativeValue(Object value) - { - if (value instanceof Short) - { - return (Short) value; - } - else if (value instanceof Byte) - { - return ((Byte) value).shortValue(); - } - else if ((value instanceof String) || (value == null)) - { - return Short.valueOf((String) value); - } - else - { - throw new NumberFormatException("Cannot convert: " + value + "(" + value.getClass().getName() - + ") to short."); - } - } - - public void writeValueImpl(Object value, DataOutput buffer) throws IOException - { - EncodingUtils.writeShort(buffer, (Short) value); - } - - public Object readValueFromBuffer(DataInput buffer) throws IOException - { - return EncodingUtils.readShort(buffer); - } - }, - - INT('I') - { - public int getEncodingSize(Object value) - { - return EncodingUtils.encodedIntegerLength(); - } - - public Integer toNativeValue(Object value) - { - if (value instanceof Integer) - { - return (Integer) value; - } - else if (value instanceof Short) - { - return ((Short) value).intValue(); - } - else if (value instanceof Byte) - { - return ((Byte) value).intValue(); - } - else if ((value instanceof String) || (value == null)) - { - return Integer.valueOf((String) value); - } - else - { - throw new NumberFormatException("Cannot convert: " + value + "(" + value.getClass().getName() + ") to int."); - } - } - - public void writeValueImpl(Object value, DataOutput buffer) throws IOException - { - EncodingUtils.writeInteger(buffer, (Integer) value); - } - - public Object readValueFromBuffer(DataInput buffer) throws IOException - { - return EncodingUtils.readInteger(buffer); - } - }, - - LONG('l') - { - public int getEncodingSize(Object value) - { - return EncodingUtils.encodedLongLength(); - } - - public Object toNativeValue(Object value) - { - if (value instanceof Long) - { - return (Long) value; - } - else if (value instanceof Integer) - { - return ((Integer) value).longValue(); - } - else if (value instanceof Short) - { - return ((Short) value).longValue(); - } - else if (value instanceof Byte) - { - return ((Byte) value).longValue(); - } - else if ((value instanceof String) || (value == null)) - { - return Long.valueOf((String) value); - } - else - { - throw new NumberFormatException("Cannot convert: " + value + "(" + value.getClass().getName() - + ") to long."); - } - } - - public void writeValueImpl(Object value, DataOutput buffer) throws IOException - { - EncodingUtils.writeLong(buffer, (Long) value); - } - - public Object readValueFromBuffer(DataInput buffer) throws IOException - { - return EncodingUtils.readLong(buffer); - } - }, - - FLOAT('f') - { - public int getEncodingSize(Object value) - { - return EncodingUtils.encodedFloatLength(); - } - - public Float toNativeValue(Object value) - { - if (value instanceof Float) - { - return (Float) value; - } - else if ((value instanceof String) || (value == null)) - { - return Float.valueOf((String) value); - } - else - { - throw new NumberFormatException("Cannot convert: " + value + "(" + value.getClass().getName() - + ") to float."); - } - } - - public void writeValueImpl(Object value, DataOutput buffer) throws IOException - { - EncodingUtils.writeFloat(buffer, (Float) value); - } - - public Object readValueFromBuffer(DataInput buffer) throws IOException - { - return EncodingUtils.readFloat(buffer); - } - }, - - DOUBLE('d') - { - public int getEncodingSize(Object value) - { - return EncodingUtils.encodedDoubleLength(); - } - - public Double toNativeValue(Object value) - { - if (value instanceof Double) - { - return (Double) value; - } - else if (value instanceof Float) - { - return ((Float) value).doubleValue(); - } - else if ((value instanceof String) || (value == null)) - { - return Double.valueOf((String) value); - } - else - { - throw new NumberFormatException("Cannot convert: " + value + "(" + value.getClass().getName() - + ") to double."); - } - } - - public void writeValueImpl(Object value, DataOutput buffer) throws IOException - { - EncodingUtils.writeDouble(buffer, (Double) value); - } - - public Object readValueFromBuffer(DataInput buffer) throws IOException - { - return EncodingUtils.readDouble(buffer); - } - }; - - /** Holds the defined one byte identifier for the type. */ - private final byte _identifier; - - /** - * Creates an instance of an AMQP type from its defined one byte identifier. - * - * @param identifier The one byte identifier for the type. - */ - AMQType(char identifier) - { - _identifier = (byte) identifier; - } - - /** - * Extracts the byte identifier for the typ. - * - * @return The byte identifier for the typ. - */ - public final byte identifier() - { - return _identifier; - } - - /** - * Calculates the size of an instance of the type in bytes. - * - * @param value An instance of the type. - * - * @return The size of the instance of the type in bytes. - */ - public abstract int getEncodingSize(Object value); - - /** - * Converts an instance of the type to an equivalent Java native representation. - * - * @param value An instance of the type. - * - * @return An equivalent Java native representation. - */ - public abstract Object toNativeValue(Object value); - - /** - * Converts an instance of the type to an equivalent Java native representation, packaged as an - * {@link AMQTypedValue} tagged with its AMQP type. - * - * @param value An instance of the type. - * - * @return An equivalent Java native representation, tagged with its AMQP type. - */ - public AMQTypedValue asTypedValue(Object value) - { - return AMQTypedValue.createAMQTypedValue(this, toNativeValue(value)); - } - - /** - * Writes an instance of the type to a specified byte buffer, preceded by its one byte identifier. As the type and - * value are both written, this provides a fully encoded description of a parameters type and value. - * - * @param value An instance of the type. - * @param buffer The byte buffer to write it to. - * @throws IOException if there is a problem writing to the buffer - */ - public void writeToBuffer(Object value, DataOutput buffer) throws IOException - { - buffer.writeByte(identifier()); - writeValueImpl(value, buffer); - } - - /** - * Writes an instance of the type to a specified byte buffer. - * - * @param value An instance of the type. - * @param buffer The byte buffer to write it to. - */ - abstract void writeValueImpl(Object value, DataOutput buffer) throws IOException; - - /** - * Reads an instance of the type from a specified byte buffer. - * - * @param buffer The byte buffer to write it to. - * - * @return An instance of the type. - */ - abstract Object readValueFromBuffer(DataInput buffer) throws IOException; -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQTypeMap.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQTypeMap.java deleted file mode 100644 index 94a7d127b3..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQTypeMap.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.framing; - -import java.util.HashMap; -import java.util.Map; - -public class AMQTypeMap -{ - public static final Map _reverseTypeMap = new HashMap(); - - private AMQTypeMap() - { - } - - static - { - for(AMQType type : AMQType.values()) - { - _reverseTypeMap.put(type.identifier(), type); - } - } - - public static AMQType getType(Byte identifier) - { - AMQType result = _reverseTypeMap.get(identifier); - if (result == null) { - throw new IllegalArgumentException - ("no such type code: " + Integer.toHexString(identifier.intValue())); - } - return result; - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQTypedValue.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQTypedValue.java deleted file mode 100644 index e60ead7ad1..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQTypedValue.java +++ /dev/null @@ -1,322 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.framing; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Date; -import java.util.Map; - -/** - * AMQTypedValue combines together a native Java Object value, and an {@link AMQType}, as a fully typed AMQP parameter - * value. It provides the ability to read and write fully typed parameters to and from byte buffers. It also provides - * the ability to create such parameters from Java native value and a type tag or to extract the native value and type - * from one. - */ -public abstract class AMQTypedValue -{ - - public abstract AMQType getType(); - - public abstract Object getValue(); - - public abstract void writeToBuffer(DataOutput buffer) throws IOException; - - public abstract int getEncodingSize(); - - - private static final class GenericTypedValue extends AMQTypedValue - { - /** The type of the value. */ - private final AMQType _type; - - /** The Java native representation of the AMQP typed value. */ - private final Object _value; - - private GenericTypedValue(AMQType type, Object value) - { - if (type == null) - { - throw new NullPointerException("Cannot create a typed value with null type"); - } - - _type = type; - _value = type.toNativeValue(value); - } - - private GenericTypedValue(AMQType type, DataInput buffer) throws IOException - { - _type = type; - _value = type.readValueFromBuffer(buffer); - } - - - public AMQType getType() - { - return _type; - } - - public Object getValue() - { - return _value; - } - - public void writeToBuffer(DataOutput buffer) throws IOException - { - _type.writeToBuffer(_value, buffer); - } - - public int getEncodingSize() - { - return _type.getEncodingSize(_value); - } - - - public String toString() - { - return "[" + getType() + ": " + getValue() + "]"; - } - - - public boolean equals(Object o) - { - if(o instanceof GenericTypedValue) - { - GenericTypedValue other = (GenericTypedValue) o; - return _type == other._type && (_value == null ? other._value == null : _value.equals(other._value)); - } - else - { - return false; - } - } - - public int hashCode() - { - return _type.hashCode() ^ (_value == null ? 0 : _value.hashCode()); - } - - } - - private static final class LongTypedValue extends AMQTypedValue - { - - private final long _value; - - private LongTypedValue(long value) - { - _value = value; - } - - public LongTypedValue(DataInput buffer) throws IOException - { - _value = EncodingUtils.readLong(buffer); - } - - public AMQType getType() - { - return AMQType.LONG; - } - - - public Object getValue() - { - return _value; - } - - public void writeToBuffer(DataOutput buffer) throws IOException - { - EncodingUtils.writeByte(buffer,AMQType.LONG.identifier()); - EncodingUtils.writeLong(buffer,_value); - } - - - public int getEncodingSize() - { - return EncodingUtils.encodedLongLength(); - } - } - - private static final class IntTypedValue extends AMQTypedValue - { - @Override - public String toString() - { - return "[INT: " + String.valueOf(_value) + "]"; - } - - private final int _value; - - public IntTypedValue(int value) - { - _value = value; - } - - public AMQType getType() - { - return AMQType.INT; - } - - - public Object getValue() - { - return _value; - } - - public void writeToBuffer(DataOutput buffer) throws IOException - { - EncodingUtils.writeByte(buffer,AMQType.INT.identifier()); - EncodingUtils.writeInteger(buffer, _value); - } - - - public int getEncodingSize() - { - return EncodingUtils.encodedIntegerLength(); - } - } - - - public static AMQTypedValue readFromBuffer(DataInput buffer) throws IOException - { - AMQType type = AMQTypeMap.getType(buffer.readByte()); - - switch(type) - { - case LONG: - return new LongTypedValue(buffer); - - case INT: - int value = EncodingUtils.readInteger(buffer); - return createAMQTypedValue(value); - - default: - return new GenericTypedValue(type, buffer); - } - - } - - private static final AMQTypedValue[] INT_VALUES = new AMQTypedValue[16]; - static - { - for(int i = 0 ; i < 16; i ++) - { - INT_VALUES[i] = new IntTypedValue(i); - } - } - - public static AMQTypedValue createAMQTypedValue(int i) - { - return (i & 0x0f) == i ? INT_VALUES[i] : new IntTypedValue(i); - } - - - public static AMQTypedValue createAMQTypedValue(long value) - { - return new LongTypedValue(value); - } - - public static AMQTypedValue createAMQTypedValue(AMQType type, Object value) - { - switch(type) - { - case LONG: - return new LongTypedValue((Long) AMQType.LONG.toNativeValue(value)); - case INT: - return new IntTypedValue((Integer) AMQType.INT.toNativeValue(value)); - - default: - return new GenericTypedValue(type, value); - } - } - - - - public static AMQTypedValue toTypedValue(Object val) - { - if(val == null) - { - return AMQType.VOID.asTypedValue(null); - } - - Class klass = val.getClass(); - if(klass == String.class) - { - return AMQType.LONG_STRING.asTypedValue(val); - } - else if(klass == Character.class) - { - return AMQType.ASCII_CHARACTER.asTypedValue(val); - } - else if(klass == Integer.class) - { - return AMQType.INT.asTypedValue(val); - } - else if(klass == Long.class) - { - return AMQType.LONG.asTypedValue(val); - } - else if(klass == Float.class) - { - return AMQType.FLOAT.asTypedValue(val); - } - else if(klass == Double.class) - { - return AMQType.DOUBLE.asTypedValue(val); - } - else if(klass == Date.class) - { - return AMQType.TIMESTAMP.asTypedValue(val); - } - else if(klass == Byte.class) - { - return AMQType.BYTE.asTypedValue(val); - } - else if(klass == Boolean.class) - { - return AMQType.BOOLEAN.asTypedValue(val); - } - else if(klass == byte[].class) - { - return AMQType.BINARY.asTypedValue(val); - } - else if(klass == BigDecimal.class) - { - return AMQType.DECIMAL.asTypedValue(val); - } - else if(val instanceof Map) - { - return AMQType.FIELD_TABLE.asTypedValue(FieldTable.convertToFieldTable((Map)val)); - } - else if(klass == FieldTable.class) - { - return AMQType.FIELD_TABLE.asTypedValue(val); - } - else if(val instanceof Collection) - { - return AMQType.FIELD_ARRAY.asTypedValue(val); - } - throw new IllegalArgumentException("Cannot convert an object of class " + val.getClass().getName() + " to an AMQP typed value"); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/AccessRequestBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/AccessRequestBody.java deleted file mode 100644 index 8dec50c400..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/AccessRequestBody.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class AccessRequestBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 30; - public static final int METHOD_ID = 10; - - // Fields declared in specification - private final AMQShortString _realm; // [realm] - private final byte _bitfield0; // [exclusive, passive, active, write, read] - - // Constructor - public AccessRequestBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _realm = buffer.readAMQShortString(); - _bitfield0 = buffer.readByte(); - } - - public AccessRequestBody( - AMQShortString realm, - boolean exclusive, - boolean passive, - boolean active, - boolean write, - boolean read - ) - { - _realm = realm; - byte bitfield0 = (byte)0; - if( exclusive ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 0)); - } - - if( passive ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 1)); - } - - if( active ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 2)); - } - - if( write ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 3)); - } - - if( read ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 4)); - } - _bitfield0 = bitfield0; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final AMQShortString getRealm() - { - return _realm; - } - public final boolean getExclusive() - { - return (((int)(_bitfield0)) & ( 1 << 0)) != 0; - } - public final boolean getPassive() - { - return (((int)(_bitfield0)) & ( 1 << 1)) != 0; - } - public final boolean getActive() - { - return (((int)(_bitfield0)) & ( 1 << 2)) != 0; - } - public final boolean getWrite() - { - return (((int)(_bitfield0)) & ( 1 << 3)) != 0; - } - public final boolean getRead() - { - return (((int)(_bitfield0)) & ( 1 << 4)) != 0; - } - - protected int getBodySize() - { - int size = 1; - size += getSizeOf( _realm ); - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeAMQShortString( buffer, _realm ); - writeBitfield( buffer, _bitfield0 ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchAccessRequest(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[AccessRequestBodyImpl: "); - buf.append( "realm=" ); - buf.append( getRealm() ); - buf.append( ", " ); - buf.append( "exclusive=" ); - buf.append( getExclusive() ); - buf.append( ", " ); - buf.append( "passive=" ); - buf.append( getPassive() ); - buf.append( ", " ); - buf.append( "active=" ); - buf.append( getActive() ); - buf.append( ", " ); - buf.append( "write=" ); - buf.append( getWrite() ); - buf.append( ", " ); - buf.append( "read=" ); - buf.append( getRead() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, - final ServerChannelMethodProcessor dispatcher) throws IOException - { - AMQShortString realm = buffer.readAMQShortString(); - byte bitfield = buffer.readByte(); - boolean exclusive = (bitfield & 0x01) == 0x1 ; - boolean passive = (bitfield & 0x02) == 0x2 ; - boolean active = (bitfield & 0x04) == 0x4 ; - boolean write = (bitfield & 0x08) == 0x8 ; - boolean read = (bitfield & 0x10) == 0x10 ; - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveAccessRequest(realm, exclusive, passive, active, write, read); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/AccessRequestOkBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/AccessRequestOkBody.java deleted file mode 100644 index 7ed0b3602b..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/AccessRequestOkBody.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class AccessRequestOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 30; - public static final int METHOD_ID = 11; - - // Fields declared in specification - private final int _ticket; // [ticket] - - // Constructor - public AccessRequestOkBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _ticket = buffer.readUnsignedShort(); - } - - public AccessRequestOkBody( - int ticket - ) - { - _ticket = ticket; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final int getTicket() - { - return _ticket; - } - - protected int getBodySize() - { - int size = 2; - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeUnsignedShort( buffer, _ticket ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchAccessRequestOk(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[AccessRequestOkBodyImpl: "); - buf.append( "ticket=" ); - buf.append( getTicket() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, - final ClientChannelMethodProcessor dispatcher) - throws IOException - { - int ticket = buffer.readUnsignedShort(); - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveAccessRequestOk(ticket); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicAckBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicAckBody.java deleted file mode 100644 index 01ca6f95f1..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicAckBody.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class BasicAckBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 60; - public static final int METHOD_ID = 80; - - // Fields declared in specification - private final long _deliveryTag; // [deliveryTag] - private final byte _bitfield0; // [multiple] - - // Constructor - public BasicAckBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _deliveryTag = buffer.readLong(); - _bitfield0 = buffer.readByte(); - } - - public BasicAckBody( - long deliveryTag, - boolean multiple - ) - { - _deliveryTag = deliveryTag; - byte bitfield0 = (byte)0; - if( multiple ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 0)); - } - _bitfield0 = bitfield0; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final long getDeliveryTag() - { - return _deliveryTag; - } - public final boolean getMultiple() - { - return (((int)(_bitfield0)) & ( 1 << 0)) != 0; - } - - protected int getBodySize() - { - int size = 9; - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeLong( buffer, _deliveryTag ); - writeBitfield( buffer, _bitfield0 ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchBasicAck(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[BasicAckBodyImpl: "); - buf.append( "deliveryTag=" ); - buf.append( getDeliveryTag() ); - buf.append( ", " ); - buf.append( "multiple=" ); - buf.append( getMultiple() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, - final ChannelMethodProcessor dispatcher) throws IOException - { - - long deliveryTag = buffer.readLong(); - boolean multiple = (buffer.readByte() & 0x01) != 0; - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveBasicAck(deliveryTag, multiple); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicCancelBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicCancelBody.java deleted file mode 100644 index c9a870e2a5..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicCancelBody.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class BasicCancelBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 60; - public static final int METHOD_ID = 30; - - // Fields declared in specification - private final AMQShortString _consumerTag; // [consumerTag] - private final byte _bitfield0; // [nowait] - - // Constructor - public BasicCancelBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _consumerTag = buffer.readAMQShortString(); - _bitfield0 = buffer.readByte(); - } - - public BasicCancelBody( - AMQShortString consumerTag, - boolean nowait - ) - { - _consumerTag = consumerTag; - byte bitfield0 = (byte)0; - if( nowait ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 0)); - } - _bitfield0 = bitfield0; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final AMQShortString getConsumerTag() - { - return _consumerTag; - } - public final boolean getNowait() - { - return (((int)(_bitfield0)) & ( 1 << 0)) != 0; - } - - protected int getBodySize() - { - int size = 1; - size += getSizeOf( _consumerTag ); - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeAMQShortString( buffer, _consumerTag ); - writeBitfield( buffer, _bitfield0 ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchBasicCancel(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[BasicCancelBodyImpl: "); - buf.append( "consumerTag=" ); - buf.append( getConsumerTag() ); - buf.append( ", " ); - buf.append( "nowait=" ); - buf.append( getNowait() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, - final ServerChannelMethodProcessor dispatcher) throws IOException - { - - AMQShortString consumerTag = buffer.readAMQShortString(); - boolean noWait = (buffer.readByte() & 0x01) == 0x01; - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveBasicCancel(consumerTag, noWait); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicCancelOkBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicCancelOkBody.java deleted file mode 100644 index 8d16aa44ec..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicCancelOkBody.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class BasicCancelOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 60; - public static final int METHOD_ID = 31; - - // Fields declared in specification - private final AMQShortString _consumerTag; // [consumerTag] - - // Constructor - public BasicCancelOkBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _consumerTag = buffer.readAMQShortString(); - } - - public BasicCancelOkBody( - AMQShortString consumerTag - ) - { - _consumerTag = consumerTag; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final AMQShortString getConsumerTag() - { - return _consumerTag; - } - - protected int getBodySize() - { - int size = 0; - size += getSizeOf( _consumerTag ); - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeAMQShortString( buffer, _consumerTag ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchBasicCancelOk(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[BasicCancelOkBodyImpl: "); - buf.append( "consumerTag=" ); - buf.append( getConsumerTag() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput in, - final ClientChannelMethodProcessor dispatcher) - throws IOException - { - AMQShortString consumerTag = in.readAMQShortString(); - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveBasicCancelOk(consumerTag); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicConsumeBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicConsumeBody.java deleted file mode 100644 index 502fa07e78..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicConsumeBody.java +++ /dev/null @@ -1,214 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class BasicConsumeBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 60; - public static final int METHOD_ID = 20; - - // Fields declared in specification - private final int _ticket; // [ticket] - private final AMQShortString _queue; // [queue] - private final AMQShortString _consumerTag; // [consumerTag] - private final byte _bitfield0; // [noLocal, noAck, exclusive, nowait] - private final FieldTable _arguments; // [arguments] - - // Constructor - public BasicConsumeBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _ticket = buffer.readUnsignedShort(); - _queue = buffer.readAMQShortString(); - _consumerTag = buffer.readAMQShortString(); - _bitfield0 = buffer.readByte(); - _arguments = EncodingUtils.readFieldTable(buffer); - } - - public BasicConsumeBody( - int ticket, - AMQShortString queue, - AMQShortString consumerTag, - boolean noLocal, - boolean noAck, - boolean exclusive, - boolean nowait, - FieldTable arguments - ) - { - _ticket = ticket; - _queue = queue; - _consumerTag = consumerTag; - byte bitfield0 = (byte)0; - if( noLocal ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 0)); - } - - if( noAck ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 1)); - } - - if( exclusive ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 2)); - } - - if( nowait ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 3)); - } - - _bitfield0 = bitfield0; - _arguments = arguments; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final int getTicket() - { - return _ticket; - } - public final AMQShortString getQueue() - { - return _queue; - } - public final AMQShortString getConsumerTag() - { - return _consumerTag; - } - public final boolean getNoLocal() - { - return (((int)(_bitfield0)) & ( 1 << 0)) != 0; - } - public final boolean getNoAck() - { - return (((int)(_bitfield0)) & ( 1 << 1)) != 0; - } - public final boolean getExclusive() - { - return (((int)(_bitfield0)) & ( 1 << 2)) != 0; - } - public final boolean getNowait() - { - return (((int)(_bitfield0)) & ( 1 << 3)) != 0; - } - public final FieldTable getArguments() - { - return _arguments; - } - - protected int getBodySize() - { - int size = 3; - size += getSizeOf( _queue ); - size += getSizeOf( _consumerTag ); - size += getSizeOf( _arguments ); - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeUnsignedShort( buffer, _ticket ); - writeAMQShortString( buffer, _queue ); - writeAMQShortString( buffer, _consumerTag ); - writeBitfield( buffer, _bitfield0 ); - writeFieldTable( buffer, _arguments ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchBasicConsume(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[BasicConsumeBodyImpl: "); - buf.append( "ticket=" ); - buf.append( getTicket() ); - buf.append( ", " ); - buf.append( "queue=" ); - buf.append( getQueue() ); - buf.append( ", " ); - buf.append( "consumerTag=" ); - buf.append( getConsumerTag() ); - buf.append( ", " ); - buf.append( "noLocal=" ); - buf.append( getNoLocal() ); - buf.append( ", " ); - buf.append( "noAck=" ); - buf.append( getNoAck() ); - buf.append( ", " ); - buf.append( "exclusive=" ); - buf.append( getExclusive() ); - buf.append( ", " ); - buf.append( "nowait=" ); - buf.append( getNowait() ); - buf.append( ", " ); - buf.append( "arguments=" ); - buf.append( getArguments() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, - final ServerChannelMethodProcessor dispatcher) - throws IOException, AMQFrameDecodingException - { - - int ticket = buffer.readUnsignedShort(); - AMQShortString queue = buffer.readAMQShortString(); - AMQShortString consumerTag = buffer.readAMQShortString(); - byte bitfield = buffer.readByte(); - - boolean noLocal = (bitfield & 0x01) == 0x01; - boolean noAck = (bitfield & 0x02) == 0x02; - boolean exclusive = (bitfield & 0x04) == 0x04; - boolean nowait = (bitfield & 0x08) == 0x08; - FieldTable arguments = EncodingUtils.readFieldTable(buffer); - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveBasicConsume(queue, consumerTag, noLocal, noAck, exclusive, nowait, arguments); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicConsumeOkBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicConsumeOkBody.java deleted file mode 100644 index d3df7f222a..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicConsumeOkBody.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class BasicConsumeOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 60; - public static final int METHOD_ID = 21; - - // Fields declared in specification - private final AMQShortString _consumerTag; // [consumerTag] - - // Constructor - public BasicConsumeOkBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _consumerTag = buffer.readAMQShortString(); - } - - public BasicConsumeOkBody( - AMQShortString consumerTag - ) - { - _consumerTag = consumerTag; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final AMQShortString getConsumerTag() - { - return _consumerTag; - } - - protected int getBodySize() - { - int size = 0; - size += getSizeOf( _consumerTag ); - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeAMQShortString( buffer, _consumerTag ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchBasicConsumeOk(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[BasicConsumeOkBodyImpl: "); - buf.append( "consumerTag=" ); - buf.append( getConsumerTag() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, - final ClientChannelMethodProcessor dispatcher) - throws IOException - { - AMQShortString consumerTag = buffer.readAMQShortString(); - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveBasicConsumeOk(consumerTag); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java deleted file mode 100644 index 6481c6ebdb..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java +++ /dev/null @@ -1,799 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.framing; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.nio.ByteBuffer; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.apache.qpid.transport.ByteBufferSender; -import org.apache.qpid.util.BytesDataOutput; - -public class BasicContentHeaderProperties -{ - //persistent & non-persistent constants, values as per JMS DeliveryMode - public static final byte NON_PERSISTENT = 1; - public static final byte PERSISTENT = 2; - - private static final Logger _logger = LoggerFactory.getLogger(BasicContentHeaderProperties.class); - - private static final AMQShortString ZERO_STRING = null; - - private AMQShortString _contentType; - - private AMQShortString _encoding; - - private FieldTable _headers; - - private byte _deliveryMode; - - private byte _priority; - - private AMQShortString _correlationId; - - private AMQShortString _replyTo; - - private long _expiration; - - private AMQShortString _messageId; - - private long _timestamp; - - private AMQShortString _type; - - private AMQShortString _userId; - - private AMQShortString _appId; - - private AMQShortString _clusterId; - - private int _propertyFlags = 0; - private static final int CONTENT_TYPE_MASK = 1 << 15; - private static final int ENCODING_MASK = 1 << 14; - private static final int HEADERS_MASK = 1 << 13; - private static final int DELIVERY_MODE_MASK = 1 << 12; - private static final int PRIORITY_MASK = 1 << 11; - private static final int CORRELATION_ID_MASK = 1 << 10; - private static final int REPLY_TO_MASK = 1 << 9; - private static final int EXPIRATION_MASK = 1 << 8; - private static final int MESSAGE_ID_MASK = 1 << 7; - private static final int TIMESTAMP_MASK = 1 << 6; - private static final int TYPE_MASK = 1 << 5; - private static final int USER_ID_MASK = 1 << 4; - private static final int APPLICATION_ID_MASK = 1 << 3; - private static final int CLUSTER_ID_MASK = 1 << 2; - private byte[] _encodedForm; - - - public BasicContentHeaderProperties(BasicContentHeaderProperties other) - { - if(other._headers != null) - { - byte[] encodedHeaders = other._headers.getDataAsBytes(); - - _headers = new FieldTable(encodedHeaders,0,encodedHeaders.length); - - } - - _contentType = other._contentType; - - _encoding = other._encoding; - - _deliveryMode = other._deliveryMode; - - _priority = other._priority; - - _correlationId = other._correlationId; - - _replyTo = other._replyTo; - - _expiration = other._expiration; - - _messageId = other._messageId; - - _timestamp = other._timestamp; - - _type = other._type; - - _userId = other._userId; - - _appId = other._appId; - - _clusterId = other._clusterId; - - _propertyFlags = other._propertyFlags; - } - - public BasicContentHeaderProperties() - { - } - - public int getPropertyListSize() - { - if(useEncodedForm()) - { - return _encodedForm.length; - } - else - { - int size = 0; - - if ((_propertyFlags & (CONTENT_TYPE_MASK)) != 0) - { - size += EncodingUtils.encodedShortStringLength(_contentType); - } - - if ((_propertyFlags & ENCODING_MASK) != 0) - { - size += EncodingUtils.encodedShortStringLength(_encoding); - } - - if ((_propertyFlags & HEADERS_MASK) != 0) - { - size += EncodingUtils.encodedFieldTableLength(_headers); - } - - if ((_propertyFlags & DELIVERY_MODE_MASK) != 0) - { - size += 1; - } - - if ((_propertyFlags & PRIORITY_MASK) != 0) - { - size += 1; - } - - if ((_propertyFlags & CORRELATION_ID_MASK) != 0) - { - size += EncodingUtils.encodedShortStringLength(_correlationId); - } - - if ((_propertyFlags & REPLY_TO_MASK) != 0) - { - size += EncodingUtils.encodedShortStringLength(_replyTo); - } - - if ((_propertyFlags & EXPIRATION_MASK) != 0) - { - if (_expiration == 0L) - { - size += EncodingUtils.encodedShortStringLength(ZERO_STRING); - } - else - { - size += EncodingUtils.encodedShortStringLength(_expiration); - } - } - - if ((_propertyFlags & MESSAGE_ID_MASK) != 0) - { - size += EncodingUtils.encodedShortStringLength(_messageId); - } - - if ((_propertyFlags & TIMESTAMP_MASK) != 0) - { - size += 8; - } - - if ((_propertyFlags & TYPE_MASK) != 0) - { - size += EncodingUtils.encodedShortStringLength(_type); - } - - if ((_propertyFlags & USER_ID_MASK) != 0) - { - size += EncodingUtils.encodedShortStringLength(_userId); - } - - if ((_propertyFlags & APPLICATION_ID_MASK) != 0) - { - size += EncodingUtils.encodedShortStringLength(_appId); - } - - if ((_propertyFlags & CLUSTER_ID_MASK) != 0) - { - size += EncodingUtils.encodedShortStringLength(_clusterId); - } - - return size; - } - } - - public void setPropertyFlags(int propertyFlags) - { - _propertyFlags = propertyFlags; - } - - public int getPropertyFlags() - { - return _propertyFlags; - } - - public void writePropertyListPayload(DataOutput buffer) throws IOException - { - if(useEncodedForm()) - { - buffer.write(_encodedForm); - } - else - { - if ((_propertyFlags & (CONTENT_TYPE_MASK)) != 0) - { - EncodingUtils.writeShortStringBytes(buffer, _contentType); - } - - if ((_propertyFlags & ENCODING_MASK) != 0) - { - EncodingUtils.writeShortStringBytes(buffer, _encoding); - } - - if ((_propertyFlags & HEADERS_MASK) != 0) - { - EncodingUtils.writeFieldTableBytes(buffer, _headers); - } - - if ((_propertyFlags & DELIVERY_MODE_MASK) != 0) - { - buffer.writeByte(_deliveryMode); - } - - if ((_propertyFlags & PRIORITY_MASK) != 0) - { - buffer.writeByte(_priority); - } - - if ((_propertyFlags & CORRELATION_ID_MASK) != 0) - { - EncodingUtils.writeShortStringBytes(buffer, _correlationId); - } - - if ((_propertyFlags & REPLY_TO_MASK) != 0) - { - EncodingUtils.writeShortStringBytes(buffer, _replyTo); - } - - if ((_propertyFlags & EXPIRATION_MASK) != 0) - { - if (_expiration == 0L) - { - EncodingUtils.writeShortStringBytes(buffer, ZERO_STRING); - } - else - { - EncodingUtils.writeShortStringBytes(buffer, String.valueOf(_expiration)); - } - } - - if ((_propertyFlags & MESSAGE_ID_MASK) != 0) - { - EncodingUtils.writeShortStringBytes(buffer, _messageId); - } - - if ((_propertyFlags & TIMESTAMP_MASK) != 0) - { - EncodingUtils.writeTimestamp(buffer, _timestamp); - } - - if ((_propertyFlags & TYPE_MASK) != 0) - { - EncodingUtils.writeShortStringBytes(buffer, _type); - } - - if ((_propertyFlags & USER_ID_MASK) != 0) - { - EncodingUtils.writeShortStringBytes(buffer, _userId); - } - - if ((_propertyFlags & APPLICATION_ID_MASK) != 0) - { - EncodingUtils.writeShortStringBytes(buffer, _appId); - } - - if ((_propertyFlags & CLUSTER_ID_MASK) != 0) - { - EncodingUtils.writeShortStringBytes(buffer, _clusterId); - } - } - } - - - public long writePropertyListPayload(final ByteBufferSender sender) throws IOException - { - if(useEncodedForm()) - { - sender.send(ByteBuffer.wrap(_encodedForm)); - return _encodedForm.length; - } - else - { - int propertyListSize = getPropertyListSize(); - byte[] data = new byte[propertyListSize]; - BytesDataOutput out = new BytesDataOutput(data); - writePropertyListPayload(out); - sender.send(ByteBuffer.wrap(data)); - return propertyListSize; - } - - } - - public void populatePropertiesFromBuffer(DataInput buffer, int propertyFlags, int size) throws AMQFrameDecodingException, IOException - { - _propertyFlags = propertyFlags; - - if (_logger.isDebugEnabled()) - { - _logger.debug("Property flags: " + _propertyFlags); - } - - _encodedForm = new byte[size]; - buffer.readFully(_encodedForm); - - ByteArrayDataInput input = new ByteArrayDataInput(_encodedForm); - - decode(input); - - } - - private void decode(ByteArrayDataInput buffer) throws IOException, AMQFrameDecodingException - { - int headersOffset = 0; - - if ((_propertyFlags & (CONTENT_TYPE_MASK)) != 0) - { - _contentType = buffer.readAMQShortString(); - headersOffset += EncodingUtils.encodedShortStringLength(_contentType); - } - - if ((_propertyFlags & ENCODING_MASK) != 0) - { - _encoding = buffer.readAMQShortString(); - headersOffset += EncodingUtils.encodedShortStringLength(_encoding); - } - - if ((_propertyFlags & HEADERS_MASK) != 0) - { - long length = EncodingUtils.readUnsignedInteger(buffer); - - _headers = new FieldTable(_encodedForm, headersOffset+4, (int)length); - - buffer.skipBytes((int)length); - } - - if ((_propertyFlags & DELIVERY_MODE_MASK) != 0) - { - _deliveryMode = buffer.readByte(); - } - - if ((_propertyFlags & PRIORITY_MASK) != 0) - { - _priority = buffer.readByte(); - } - - if ((_propertyFlags & CORRELATION_ID_MASK) != 0) - { - _correlationId = buffer.readAMQShortString(); - } - - if ((_propertyFlags & REPLY_TO_MASK) != 0) - { - _replyTo = buffer.readAMQShortString(); - } - - if ((_propertyFlags & EXPIRATION_MASK) != 0) - { - _expiration = EncodingUtils.readLongAsShortString(buffer); - } - - if ((_propertyFlags & MESSAGE_ID_MASK) != 0) - { - _messageId = buffer.readAMQShortString(); - } - - if ((_propertyFlags & TIMESTAMP_MASK) != 0) - { - _timestamp = EncodingUtils.readTimestamp(buffer); - } - - if ((_propertyFlags & TYPE_MASK) != 0) - { - _type = buffer.readAMQShortString(); - } - - if ((_propertyFlags & USER_ID_MASK) != 0) - { - _userId = buffer.readAMQShortString(); - } - - if ((_propertyFlags & APPLICATION_ID_MASK) != 0) - { - _appId = buffer.readAMQShortString(); - } - - if ((_propertyFlags & CLUSTER_ID_MASK) != 0) - { - _clusterId = buffer.readAMQShortString(); - } - - - } - - - public AMQShortString getContentType() - { - return _contentType; - } - - public String getContentTypeAsString() - { - return (_contentType == null) ? null : _contentType.toString(); - } - - public void setContentType(AMQShortString contentType) - { - - if(contentType == null) - { - _propertyFlags &= (~CONTENT_TYPE_MASK); - } - else - { - _propertyFlags |= CONTENT_TYPE_MASK; - } - _contentType = contentType; - _encodedForm = null; - } - - public void setContentType(String contentType) - { - setContentType((contentType == null) ? null : AMQShortString.valueOf(contentType)); - } - - public String getEncodingAsString() - { - - return (getEncoding() == null) ? null : getEncoding().toString(); - } - - public AMQShortString getEncoding() - { - return _encoding; - } - - public void setEncoding(String encoding) - { - setEncoding(encoding == null ? null : AMQShortString.valueOf(encoding)); - } - - public void setEncoding(AMQShortString encoding) - { - if(encoding == null) - { - _propertyFlags &= (~ENCODING_MASK); - } - else - { - _propertyFlags |= ENCODING_MASK; - } - _encoding = encoding; - _encodedForm = null; - } - - public FieldTable getHeaders() - { - if (_headers == null) - { - setHeaders(FieldTableFactory.newFieldTable()); - } - - return _headers; - } - - public void setHeaders(FieldTable headers) - { - if(headers == null) - { - _propertyFlags &= (~HEADERS_MASK); - } - else - { - _propertyFlags |= HEADERS_MASK; - } - _headers = headers; - _encodedForm = null; - } - - public byte getDeliveryMode() - { - return _deliveryMode; - } - - public void setDeliveryMode(byte deliveryMode) - { - _propertyFlags |= DELIVERY_MODE_MASK; - _deliveryMode = deliveryMode; - _encodedForm = null; - } - - public byte getPriority() - { - return _priority; - } - - public void setPriority(byte priority) - { - _propertyFlags |= PRIORITY_MASK; - _priority = priority; - _encodedForm = null; - } - - public AMQShortString getCorrelationId() - { - return _correlationId; - } - - public String getCorrelationIdAsString() - { - return (_correlationId == null) ? null : _correlationId.toString(); - } - - public void setCorrelationId(String correlationId) - { - setCorrelationId((correlationId == null) ? null : AMQShortString.valueOf(correlationId)); - } - - public void setCorrelationId(AMQShortString correlationId) - { - if(correlationId == null) - { - _propertyFlags &= (~CORRELATION_ID_MASK); - } - else - { - _propertyFlags |= CORRELATION_ID_MASK; - } - _correlationId = correlationId; - _encodedForm = null; - } - - public String getReplyToAsString() - { - return (_replyTo == null) ? null : _replyTo.toString(); - } - - public AMQShortString getReplyTo() - { - return _replyTo; - } - - public void setReplyTo(String replyTo) - { - setReplyTo((replyTo == null) ? null : AMQShortString.valueOf(replyTo)); - } - - public void setReplyTo(AMQShortString replyTo) - { - if(replyTo == null) - { - _propertyFlags &= (~REPLY_TO_MASK); - } - else - { - _propertyFlags |= REPLY_TO_MASK; - } - _replyTo = replyTo; - _encodedForm = null; - } - - public long getExpiration() - { - return _expiration; - } - - public void setExpiration(long expiration) - { - if(expiration == 0l) - { - _propertyFlags &= (~EXPIRATION_MASK); - } - else - { - _propertyFlags |= EXPIRATION_MASK; - } - _expiration = expiration; - _encodedForm = null; - } - - public AMQShortString getMessageId() - { - return _messageId; - } - - public String getMessageIdAsString() - { - return (_messageId == null) ? null : _messageId.toString(); - } - - public void setMessageId(String messageId) - { - setMessageId(messageId == null ? null : new AMQShortString(messageId)); - } - - public void setMessageId(AMQShortString messageId) - { - if(messageId == null) - { - _propertyFlags &= (~MESSAGE_ID_MASK); - } - else - { - _propertyFlags |= MESSAGE_ID_MASK; - } - _messageId = messageId; - _encodedForm = null; - } - - public long getTimestamp() - { - return _timestamp; - } - - public void setTimestamp(long timestamp) - { - _propertyFlags |= TIMESTAMP_MASK; - _timestamp = timestamp; - _encodedForm = null; - } - - public String getTypeAsString() - { - return (_type == null) ? null : _type.toString(); - } - - public AMQShortString getType() - { - return _type; - } - - public void setType(String type) - { - setType((type == null) ? null : AMQShortString.valueOf(type)); - } - - public void setType(AMQShortString type) - { - if(type == null) - { - _propertyFlags &= (~TYPE_MASK); - } - else - { - _propertyFlags |= TYPE_MASK; - } - _type = type; - _encodedForm = null; - } - - public String getUserIdAsString() - { - return (_userId == null) ? null : _userId.toString(); - } - - public AMQShortString getUserId() - { - return _userId; - } - - public void setUserId(String userId) - { - setUserId((userId == null) ? null : AMQShortString.valueOf(userId)); - } - - public void setUserId(AMQShortString userId) - { - if(userId == null) - { - _propertyFlags &= (~USER_ID_MASK); - } - else - { - _propertyFlags |= USER_ID_MASK; - } - _userId = userId; - _encodedForm = null; - } - - public String getAppIdAsString() - { - return (_appId == null) ? null : _appId.toString(); - } - - public AMQShortString getAppId() - { - return _appId; - } - - public void setAppId(String appId) - { - setAppId((appId == null) ? null : AMQShortString.valueOf(appId)); - } - - public void setAppId(AMQShortString appId) - { - if(appId == null) - { - _propertyFlags &= (~APPLICATION_ID_MASK); - } - else - { - _propertyFlags |= APPLICATION_ID_MASK; - } - _appId = appId; - _encodedForm = null; - } - - public String getClusterIdAsString() - { - return (_clusterId == null) ? null : _clusterId.toString(); - } - - public AMQShortString getClusterId() - { - return _clusterId; - } - - public void setClusterId(String clusterId) - { - setClusterId((clusterId == null) ? null : AMQShortString.valueOf(clusterId)); - } - - public void setClusterId(AMQShortString clusterId) - { - if(clusterId == null) - { - _propertyFlags &= (~CLUSTER_ID_MASK); - } - else - { - _propertyFlags |= CLUSTER_ID_MASK; - } - _clusterId = clusterId; - _encodedForm = null; - } - - public String toString() - { - return "reply-to = " + _replyTo + ",propertyFlags = " + _propertyFlags + ",ApplicationID = " + _appId - + ",ClusterID = " + _clusterId + ",UserId = " + _userId + ",JMSMessageID = " + _messageId - + ",JMSCorrelationID = " + _correlationId + ",JMSDeliveryMode = " + _deliveryMode + ",JMSExpiration = " - + _expiration + ",JMSPriority = " + _priority + ",JMSTimestamp = " + _timestamp + ",JMSType = " + _type; - } - - private boolean useEncodedForm() - { - return _encodedForm != null && (_headers == null || _headers.isClean()); - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicDeliverBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicDeliverBody.java deleted file mode 100644 index f61ee2d55b..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicDeliverBody.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class BasicDeliverBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 60; - public static final int METHOD_ID = 60; - - // Fields declared in specification - private final AMQShortString _consumerTag; // [consumerTag] - private final long _deliveryTag; // [deliveryTag] - private final byte _bitfield0; // [redelivered] - private final AMQShortString _exchange; // [exchange] - private final AMQShortString _routingKey; // [routingKey] - - // Constructor - public BasicDeliverBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _consumerTag = buffer.readAMQShortString(); - _deliveryTag = buffer.readLong(); - _bitfield0 = buffer.readByte(); - _exchange = buffer.readAMQShortString(); - _routingKey = buffer.readAMQShortString(); - } - - public BasicDeliverBody( - AMQShortString consumerTag, - long deliveryTag, - boolean redelivered, - AMQShortString exchange, - AMQShortString routingKey - ) - { - _consumerTag = consumerTag; - _deliveryTag = deliveryTag; - byte bitfield0 = (byte)0; - if( redelivered ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 0)); - } - - _bitfield0 = bitfield0; - _exchange = exchange; - _routingKey = routingKey; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final AMQShortString getConsumerTag() - { - return _consumerTag; - } - public final long getDeliveryTag() - { - return _deliveryTag; - } - public final boolean getRedelivered() - { - return (((int)(_bitfield0)) & ( 1 << 0)) != 0; - } - public final AMQShortString getExchange() - { - return _exchange; - } - public final AMQShortString getRoutingKey() - { - return _routingKey; - } - - protected int getBodySize() - { - int size = 9; - size += getSizeOf( _consumerTag ); - size += getSizeOf( _exchange ); - size += getSizeOf( _routingKey ); - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeAMQShortString( buffer, _consumerTag ); - writeLong( buffer, _deliveryTag ); - writeBitfield( buffer, _bitfield0 ); - writeAMQShortString( buffer, _exchange ); - writeAMQShortString( buffer, _routingKey ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchBasicDeliver(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[BasicDeliverBodyImpl: "); - buf.append( "consumerTag=" ); - buf.append( getConsumerTag() ); - buf.append( ", " ); - buf.append( "deliveryTag=" ); - buf.append( getDeliveryTag() ); - buf.append( ", " ); - buf.append( "redelivered=" ); - buf.append( getRedelivered() ); - buf.append( ", " ); - buf.append( "exchange=" ); - buf.append( getExchange() ); - buf.append( ", " ); - buf.append( "routingKey=" ); - buf.append( getRoutingKey() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, - final ClientChannelMethodProcessor dispatcher) throws IOException - { - - AMQShortString consumerTag = buffer.readAMQShortString(); - long deliveryTag = buffer.readLong(); - boolean redelivered = (buffer.readByte() & 0x01) != 0; - AMQShortString exchange = buffer.readAMQShortString(); - AMQShortString routingKey = buffer.readAMQShortString(); - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveBasicDeliver(consumerTag, deliveryTag, redelivered, exchange, routingKey); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicGetBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicGetBody.java deleted file mode 100644 index 68a6f2980b..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicGetBody.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class BasicGetBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 60; - public static final int METHOD_ID = 70; - - // Fields declared in specification - private final int _ticket; // [ticket] - private final AMQShortString _queue; // [queue] - private final byte _bitfield0; // [noAck] - - // Constructor - public BasicGetBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _ticket = buffer.readUnsignedShort(); - _queue = buffer.readAMQShortString(); - _bitfield0 = buffer.readByte(); - } - - public BasicGetBody( - int ticket, - AMQShortString queue, - boolean noAck - ) - { - _ticket = ticket; - _queue = queue; - byte bitfield0 = (byte)0; - if( noAck ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 0)); - } - _bitfield0 = bitfield0; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final int getTicket() - { - return _ticket; - } - public final AMQShortString getQueue() - { - return _queue; - } - public final boolean getNoAck() - { - return (((int)(_bitfield0)) & ( 1 << 0)) != 0; - } - - protected int getBodySize() - { - int size = 3; - size += getSizeOf( _queue ); - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeUnsignedShort( buffer, _ticket ); - writeAMQShortString( buffer, _queue ); - writeBitfield( buffer, _bitfield0 ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchBasicGet(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[BasicGetBodyImpl: "); - buf.append( "ticket=" ); - buf.append( getTicket() ); - buf.append( ", " ); - buf.append( "queue=" ); - buf.append( getQueue() ); - buf.append( ", " ); - buf.append( "noAck=" ); - buf.append( getNoAck() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, - final ServerChannelMethodProcessor dispatcher) - throws IOException - { - - int ticket = buffer.readUnsignedShort(); - AMQShortString queue = buffer.readAMQShortString(); - boolean noAck = (buffer.readByte() & 0x01) != 0; - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveBasicGet(queue, noAck); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicGetEmptyBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicGetEmptyBody.java deleted file mode 100644 index f37fb632db..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicGetEmptyBody.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class BasicGetEmptyBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 60; - public static final int METHOD_ID = 72; - - // Fields declared in specification - private final AMQShortString _clusterId; // [clusterId] - - // Constructor - public BasicGetEmptyBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _clusterId = buffer.readAMQShortString(); - } - - public BasicGetEmptyBody( - AMQShortString clusterId - ) - { - _clusterId = clusterId; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final AMQShortString getClusterId() - { - return _clusterId; - } - - protected int getBodySize() - { - int size = 0; - size += getSizeOf( _clusterId ); - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeAMQShortString( buffer, _clusterId ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchBasicGetEmpty(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[BasicGetEmptyBody: "); - buf.append( "clusterId=" ); - buf.append( getClusterId() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, - final ClientChannelMethodProcessor dispatcher) throws IOException - { - AMQShortString clusterId = buffer.readAMQShortString(); - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveBasicGetEmpty(); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicGetOkBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicGetOkBody.java deleted file mode 100644 index 37e9bdae5a..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicGetOkBody.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class BasicGetOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 60; - public static final int METHOD_ID = 71; - - // Fields declared in specification - private final long _deliveryTag; // [deliveryTag] - private final byte _bitfield0; // [redelivered] - private final AMQShortString _exchange; // [exchange] - private final AMQShortString _routingKey; // [routingKey] - private final long _messageCount; // [messageCount] - - // Constructor - public BasicGetOkBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _deliveryTag = buffer.readLong(); - _bitfield0 = buffer.readByte(); - _exchange = buffer.readAMQShortString(); - _routingKey = buffer.readAMQShortString(); - _messageCount = EncodingUtils.readUnsignedInteger(buffer); - } - - public BasicGetOkBody( - long deliveryTag, - boolean redelivered, - AMQShortString exchange, - AMQShortString routingKey, - long messageCount - ) - { - _deliveryTag = deliveryTag; - byte bitfield0 = (byte)0; - if( redelivered ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 0)); - } - - _bitfield0 = bitfield0; - _exchange = exchange; - _routingKey = routingKey; - _messageCount = messageCount; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final long getDeliveryTag() - { - return _deliveryTag; - } - public final boolean getRedelivered() - { - return (((int)(_bitfield0)) & ( 1 << 0)) != 0; - } - public final AMQShortString getExchange() - { - return _exchange; - } - public final AMQShortString getRoutingKey() - { - return _routingKey; - } - public final long getMessageCount() - { - return _messageCount; - } - - protected int getBodySize() - { - int size = 13; - size += getSizeOf( _exchange ); - size += getSizeOf( _routingKey ); - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeLong( buffer, _deliveryTag ); - writeBitfield( buffer, _bitfield0 ); - writeAMQShortString( buffer, _exchange ); - writeAMQShortString( buffer, _routingKey ); - writeUnsignedInteger( buffer, _messageCount ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchBasicGetOk(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[BasicGetOkBodyImpl: "); - buf.append( "deliveryTag=" ); - buf.append( getDeliveryTag() ); - buf.append( ", " ); - buf.append( "redelivered=" ); - buf.append( getRedelivered() ); - buf.append( ", " ); - buf.append( "exchange=" ); - buf.append( getExchange() ); - buf.append( ", " ); - buf.append( "routingKey=" ); - buf.append( getRoutingKey() ); - buf.append( ", " ); - buf.append( "messageCount=" ); - buf.append( getMessageCount() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, - final ClientChannelMethodProcessor dispatcher) throws IOException - { - long deliveryTag = buffer.readLong(); - boolean redelivered = (buffer.readByte() & 0x01) != 0; - AMQShortString exchange = buffer.readAMQShortString(); - AMQShortString routingKey = buffer.readAMQShortString(); - long messageCount = EncodingUtils.readUnsignedInteger(buffer); - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveBasicGetOk(deliveryTag, redelivered, exchange, routingKey, messageCount); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicNackBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicNackBody.java deleted file mode 100644 index 33ccb10f39..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicNackBody.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class BasicNackBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 60; - public static final int METHOD_ID = 120; - - // Fields declared in specification - private final long _deliveryTag; // [deliveryTag] - private final byte _bitfield0; // [multiple] - - // Constructor - public BasicNackBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _deliveryTag = buffer.readLong(); - _bitfield0 = buffer.readByte(); - } - - public BasicNackBody( - long deliveryTag, - boolean multiple, - boolean requeue - ) - { - _deliveryTag = deliveryTag; - byte bitfield0 = (byte)0; - if( multiple ) - { - bitfield0 = (byte) (((int) bitfield0) | 1); - - } - if( requeue ) - { - bitfield0 = (byte) (((int) bitfield0) | 2); - } - _bitfield0 = bitfield0; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final long getDeliveryTag() - { - return _deliveryTag; - } - - public final boolean getMultiple() - { - return (((int)(_bitfield0)) & 1) != 0; - } - - public final boolean getRequeue() - { - return (((int)(_bitfield0)) & 2 ) != 0; - } - - protected int getBodySize() - { - int size = 9; - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeLong( buffer, _deliveryTag ); - writeBitfield( buffer, _bitfield0 ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchBasicNack(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[BasicNackBodyImpl: "); - buf.append( "deliveryTag=" ); - buf.append( getDeliveryTag() ); - buf.append( ", " ); - buf.append( "multiple=" ); - buf.append( getMultiple() ); - buf.append( ", " ); - buf.append( "requeue=" ); - buf.append( getRequeue() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, - final ChannelMethodProcessor dispatcher) throws IOException - { - - long deliveryTag = buffer.readLong(); - byte bitfield = buffer.readByte(); - boolean multiple = (bitfield & 0x01) != 0; - boolean requeue = (bitfield & 0x02) != 0; - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveBasicNack(deliveryTag, multiple, requeue); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicPublishBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicPublishBody.java deleted file mode 100644 index 8e5d71a804..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicPublishBody.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class BasicPublishBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 60; - public static final int METHOD_ID = 40; - - // Fields declared in specification - private final int _ticket; // [ticket] - private final AMQShortString _exchange; // [exchange] - private final AMQShortString _routingKey; // [routingKey] - private final byte _bitfield0; // [mandatory, immediate] - - // Constructor - public BasicPublishBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _ticket = buffer.readUnsignedShort(); - _exchange = buffer.readAMQShortString(); - _routingKey = buffer.readAMQShortString(); - _bitfield0 = buffer.readByte(); - } - - public BasicPublishBody( - int ticket, - AMQShortString exchange, - AMQShortString routingKey, - boolean mandatory, - boolean immediate - ) - { - _ticket = ticket; - _exchange = exchange; - _routingKey = routingKey; - byte bitfield0 = (byte)0; - if( mandatory ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 0)); - } - - if( immediate ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 1)); - } - _bitfield0 = bitfield0; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final int getTicket() - { - return _ticket; - } - public final AMQShortString getExchange() - { - return _exchange; - } - public final AMQShortString getRoutingKey() - { - return _routingKey; - } - public final boolean getMandatory() - { - return (((int)(_bitfield0)) & ( 1 << 0)) != 0; - } - public final boolean getImmediate() - { - return (((int)(_bitfield0)) & ( 1 << 1)) != 0; - } - - protected int getBodySize() - { - int size = 3; - size += getSizeOf( _exchange ); - size += getSizeOf( _routingKey ); - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeUnsignedShort( buffer, _ticket ); - writeAMQShortString( buffer, _exchange ); - writeAMQShortString( buffer, _routingKey ); - writeBitfield( buffer, _bitfield0 ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchBasicPublish(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[BasicPublishBodyImpl: "); - buf.append( "ticket=" ); - buf.append( getTicket() ); - buf.append( ", " ); - buf.append( "exchange=" ); - buf.append( getExchange() ); - buf.append( ", " ); - buf.append( "routingKey=" ); - buf.append( getRoutingKey() ); - buf.append( ", " ); - buf.append( "mandatory=" ); - buf.append( getMandatory() ); - buf.append( ", " ); - buf.append( "immediate=" ); - buf.append( getImmediate() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, - final ServerChannelMethodProcessor dispatcher) throws IOException - { - - int ticket = buffer.readUnsignedShort(); - AMQShortString exchange = buffer.readAMQShortString(); - AMQShortString routingKey = buffer.readAMQShortString(); - byte bitfield = buffer.readByte(); - - boolean mandatory = (bitfield & 0x01) != 0; - boolean immediate = (bitfield & 0x02) != 0; - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveBasicPublish(exchange, routingKey, mandatory, immediate); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicQosBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicQosBody.java deleted file mode 100644 index 6b7e90f41f..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicQosBody.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class BasicQosBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 60; - public static final int METHOD_ID = 10; - - // Fields declared in specification - private final long _prefetchSize; // [prefetchSize] - private final int _prefetchCount; // [prefetchCount] - private final byte _bitfield0; // [global] - - // Constructor - public BasicQosBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _prefetchSize = EncodingUtils.readUnsignedInteger(buffer); - _prefetchCount = buffer.readUnsignedShort(); - _bitfield0 = buffer.readByte(); - } - - public BasicQosBody( - long prefetchSize, - int prefetchCount, - boolean global - ) - { - _prefetchSize = prefetchSize; - _prefetchCount = prefetchCount; - byte bitfield0 = (byte)0; - if( global ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 0)); - } - _bitfield0 = bitfield0; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final long getPrefetchSize() - { - return _prefetchSize; - } - public final int getPrefetchCount() - { - return _prefetchCount; - } - public final boolean getGlobal() - { - return (((int)(_bitfield0)) & ( 1 << 0)) != 0; - } - - protected int getBodySize() - { - int size = 7; - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeUnsignedInteger( buffer, _prefetchSize ); - writeUnsignedShort( buffer, _prefetchCount ); - writeBitfield( buffer, _bitfield0 ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchBasicQos(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[BasicQosBodyImpl: "); - buf.append( "prefetchSize=" ); - buf.append( getPrefetchSize() ); - buf.append( ", " ); - buf.append( "prefetchCount=" ); - buf.append( getPrefetchCount() ); - buf.append( ", " ); - buf.append( "global=" ); - buf.append( getGlobal() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, - final ServerChannelMethodProcessor dispatcher) throws IOException - { - - long prefetchSize = EncodingUtils.readUnsignedInteger(buffer); - int prefetchCount = buffer.readUnsignedShort(); - boolean global = (buffer.readByte() & 0x01) == 0x01; - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveBasicQos(prefetchSize, prefetchCount, global); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicQosOkBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicQosOkBody.java deleted file mode 100644 index 4be10906c2..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicQosOkBody.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class BasicQosOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 60; - public static final int METHOD_ID = 11; - - // Fields declared in specification - - // Constructor - public BasicQosOkBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - } - - public BasicQosOkBody( - ) - { - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - - protected int getBodySize() - { - int size = 0; - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchBasicQosOk(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[BasicQosOkBodyImpl: "); - buf.append("]"); - return buf.toString(); - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicRecoverBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicRecoverBody.java deleted file mode 100644 index e5490c4827..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicRecoverBody.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class BasicRecoverBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 60; - public static final int METHOD_ID = 100; - - // Fields declared in specification - private final byte _bitfield0; // [requeue] - - // Constructor - public BasicRecoverBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _bitfield0 = buffer.readByte(); - } - - public BasicRecoverBody( - boolean requeue - ) - { - byte bitfield0 = (byte)0; - if( requeue ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 0)); - } - _bitfield0 = bitfield0; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final boolean getRequeue() - { - return (((int)(_bitfield0)) & ( 1 << 0)) != 0; - } - - protected int getBodySize() - { - int size = 1; - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeBitfield( buffer, _bitfield0 ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchBasicRecover(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[BasicRecoverBodyImpl: "); - buf.append( "requeue=" ); - buf.append( getRequeue() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput in, - final ProtocolVersion protocolVersion, - final ServerChannelMethodProcessor dispatcher) throws IOException - { - boolean requeue = (in.readByte() & 0x01) == 0x01; - boolean sync = (ProtocolVersion.v8_0.equals(protocolVersion)); - - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveBasicRecover(requeue, sync); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicRecoverSyncBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicRecoverSyncBody.java deleted file mode 100644 index f82ee78862..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicRecoverSyncBody.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 0-91 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class BasicRecoverSyncBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - private int _methodId; - - public static final int CLASS_ID = 60; - - // Fields declared in specification - private final byte _bitfield0; // [requeue] - - // Constructor - public BasicRecoverSyncBody(MarkableDataInput buffer, ProtocolVersion protocolVersion) throws AMQFrameDecodingException, IOException - { - _methodId = ProtocolVersion.v0_9.equals(protocolVersion) ? 102 : 110; - _bitfield0 = buffer.readByte(); - } - - public BasicRecoverSyncBody(ProtocolVersion protocolVersion, - boolean requeue - ) - { - _methodId = ProtocolVersion.v0_9.equals(protocolVersion) ? 102 : 110; - - byte bitfield0 = (byte)0; - if( requeue ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 0)); - } - _bitfield0 = bitfield0; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return _methodId; - } - - public final boolean getRequeue() - { - return (((int)(_bitfield0)) & ( 1 << 0)) != 0; - } - - protected int getBodySize() - { - int size = 1; - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeBitfield( buffer, _bitfield0 ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchBasicRecoverSync(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[BasicRecoverSyncBodyImpl: "); - buf.append( "requeue=" ); - buf.append( getRequeue() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput in, - final ServerChannelMethodProcessor dispatcher) throws IOException - { - boolean requeue = (in.readByte() & 0x01) == 0x01; - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveBasicRecover(requeue, true); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicRecoverSyncOkBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicRecoverSyncOkBody.java deleted file mode 100644 index dc60d53952..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicRecoverSyncOkBody.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 0-91 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; - -public class BasicRecoverSyncOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 60; - public final int _ownMethodId; - - // Fields declared in specification - - // Constructor - public BasicRecoverSyncOkBody(ProtocolVersion protocolVersion) - { - if(ProtocolVersion.v0_91.equals(protocolVersion)) - { - _ownMethodId = 111; - } - else - { - _ownMethodId = 101; - } - } - - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return _ownMethodId; - } - - - protected int getBodySize() - { - return 0; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchBasicRecoverSyncOk(this, channelId); - } - - public String toString() - { - return "[BasicRecoverSyncOkBody]"; - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicRejectBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicRejectBody.java deleted file mode 100644 index 8c8757f1d2..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicRejectBody.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class BasicRejectBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 60; - public static final int METHOD_ID = 90; - - // Fields declared in specification - private final long _deliveryTag; // [deliveryTag] - private final byte _bitfield0; // [requeue] - - // Constructor - public BasicRejectBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _deliveryTag = buffer.readLong(); - _bitfield0 = buffer.readByte(); - } - - public BasicRejectBody( - long deliveryTag, - boolean requeue - ) - { - _deliveryTag = deliveryTag; - byte bitfield0 = (byte)0; - if( requeue ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 0)); - } - _bitfield0 = bitfield0; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final long getDeliveryTag() - { - return _deliveryTag; - } - public final boolean getRequeue() - { - return (((int)(_bitfield0)) & ( 1 << 0)) != 0; - } - - protected int getBodySize() - { - int size = 9; - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeLong( buffer, _deliveryTag ); - writeBitfield( buffer, _bitfield0 ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchBasicReject(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[BasicRejectBodyImpl: "); - buf.append( "deliveryTag=" ); - buf.append( getDeliveryTag() ); - buf.append( ", " ); - buf.append( "requeue=" ); - buf.append( getRequeue() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, - final ServerChannelMethodProcessor dispatcher) throws IOException - { - - long deliveryTag = buffer.readLong(); - boolean requeue = (buffer.readByte() & 0x01) != 0; - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveBasicReject(deliveryTag, requeue); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicReturnBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicReturnBody.java deleted file mode 100644 index afdb343c9f..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicReturnBody.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class BasicReturnBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 60; - public static final int METHOD_ID = 50; - - // Fields declared in specification - private final int _replyCode; // [replyCode] - private final AMQShortString _replyText; // [replyText] - private final AMQShortString _exchange; // [exchange] - private final AMQShortString _routingKey; // [routingKey] - - // Constructor - public BasicReturnBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _replyCode = buffer.readUnsignedShort(); - _replyText = buffer.readAMQShortString(); - _exchange = buffer.readAMQShortString(); - _routingKey = buffer.readAMQShortString(); - } - - public BasicReturnBody( - int replyCode, - AMQShortString replyText, - AMQShortString exchange, - AMQShortString routingKey - ) - { - _replyCode = replyCode; - _replyText = replyText; - _exchange = exchange; - _routingKey = routingKey; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final int getReplyCode() - { - return _replyCode; - } - public final AMQShortString getReplyText() - { - return _replyText; - } - public final AMQShortString getExchange() - { - return _exchange; - } - public final AMQShortString getRoutingKey() - { - return _routingKey; - } - - protected int getBodySize() - { - int size = 2; - size += getSizeOf( _replyText ); - size += getSizeOf( _exchange ); - size += getSizeOf( _routingKey ); - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeUnsignedShort( buffer, _replyCode ); - writeAMQShortString( buffer, _replyText ); - writeAMQShortString( buffer, _exchange ); - writeAMQShortString( buffer, _routingKey ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchBasicReturn(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[BasicReturnBodyImpl: "); - buf.append( "replyCode=" ); - buf.append( getReplyCode() ); - buf.append( ", " ); - buf.append( "replyText=" ); - buf.append( getReplyText() ); - buf.append( ", " ); - buf.append( "exchange=" ); - buf.append( getExchange() ); - buf.append( ", " ); - buf.append( "routingKey=" ); - buf.append( getRoutingKey() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, - final ClientChannelMethodProcessor dispatcher) throws IOException - { - - int replyCode = buffer.readUnsignedShort(); - AMQShortString replyText = buffer.readAMQShortString(); - AMQShortString exchange = buffer.readAMQShortString(); - AMQShortString routingKey = buffer.readAMQShortString(); - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveBasicReturn(replyCode, replyText, exchange, routingKey); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ByteArrayDataInput.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ByteArrayDataInput.java deleted file mode 100644 index 854f77e135..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ByteArrayDataInput.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.framing; - -import org.apache.qpid.codec.MarkableDataInput; - -public class ByteArrayDataInput implements ExtendedDataInput, MarkableDataInput -{ - private byte[] _data; - private int _offset; - private int _length; - private int _origin; - private int _mark; - - public ByteArrayDataInput(byte[] data) - { - this(data,0, data.length); - } - - public ByteArrayDataInput(byte[] data, int offset, int length) - { - _data = data; - _offset = offset; - _length = length; - _origin = offset; - _mark = 0; - } - - public void readFully(byte[] b) - { - System.arraycopy(_data,_offset,b,0,b.length); - _offset+=b.length; - } - - public void readFully(byte[] b, int off, int len) - { - System.arraycopy(_data,_offset,b,off,len); - _offset+=len; - } - - public int skipBytes(int n) - { - return _offset+=n; - } - - public boolean readBoolean() - { - return _data[_offset++] != 0; - } - - public byte readByte() - { - return _data[_offset++]; - } - - public int readUnsignedByte() - { - return ((int)_data[_offset++]) & 0xFF; - } - - public short readShort() - { - return (short) (((((int)_data[_offset++]) << 8) & 0xFF00) | (((int)_data[_offset++]) & 0xFF)); - } - - public int readUnsignedShort() - { - return (((((int)_data[_offset++]) << 8) & 0xFF00) | (((int)_data[_offset++]) & 0xFF)); - } - - public char readChar() - { - return (char) (((((int)_data[_offset++]) << 8) & 0xFF00) | (((int)_data[_offset++]) & 0xFF)); - } - - public int readInt() - { - return ((((int)_data[_offset++]) << 24) & 0xFF000000) - | ((((int)_data[_offset++]) << 16) & 0xFF0000) - | ((((int)_data[_offset++]) << 8) & 0xFF00) - | (((int)_data[_offset++]) & 0xFF); - } - - public long readLong() - { - return ((((long)_data[_offset++]) << 56) & 0xFF00000000000000L) - | ((((long)_data[_offset++]) << 48) & 0xFF000000000000L) - | ((((long)_data[_offset++]) << 40) & 0xFF0000000000L) - | ((((long)_data[_offset++]) << 32) & 0xFF00000000L) - | ((((long)_data[_offset++]) << 24) & 0xFF000000L) - | ((((long)_data[_offset++]) << 16) & 0xFF0000L) - | ((((long)_data[_offset++]) << 8) & 0xFF00L) - | (((long)_data[_offset++]) & 0xFFL); - } - - public float readFloat() - { - return Float.intBitsToFloat(readInt()); - } - - public double readDouble() - { - return Double.longBitsToDouble(readLong()); - } - - public AMQShortString readAMQShortString() - { - int length = _data[_offset++] & 0xff; - if(length == 0) - { - return null; - } - else - { - final AMQShortString amqShortString = new AMQShortString(_data, _offset, length); - _offset+=length; - return amqShortString; - } - } - - public String readLine() - { - throw new UnsupportedOperationException(); - } - - public String readUTF() - { - throw new UnsupportedOperationException(); - } - - public int available() - { - return (_origin+_length)-_offset; - } - - - public long skip(long i) - { - _offset+=i; - return i; - } - - public int read(byte[] b) - { - readFully(b); - return b.length; - } - - public int position() - { - return _offset - _origin; - } - - public void position(int position) - { - _offset = position + _origin; - } - - public int length() - { - return _length; - } - - - public void mark(int readAhead) - { - _mark = _offset-_origin; - } - - public void reset() - { - _offset = _origin + _mark; - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ChannelAlertBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ChannelAlertBody.java deleted file mode 100644 index 289cf2cc10..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ChannelAlertBody.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class ChannelAlertBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 20; - public static final int METHOD_ID = 30; - - // Fields declared in specification - private final int _replyCode; // [replyCode] - private final AMQShortString _replyText; // [replyText] - private final FieldTable _details; // [details] - - // Constructor - public ChannelAlertBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _replyCode = buffer.readUnsignedShort(); - _replyText = buffer.readAMQShortString(); - _details = EncodingUtils.readFieldTable(buffer); - } - - public ChannelAlertBody( - int replyCode, - AMQShortString replyText, - FieldTable details - ) - { - _replyCode = replyCode; - _replyText = replyText; - _details = details; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final int getReplyCode() - { - return _replyCode; - } - public final AMQShortString getReplyText() - { - return _replyText; - } - public final FieldTable getDetails() - { - return _details; - } - - protected int getBodySize() - { - int size = 2; - size += getSizeOf( _replyText ); - size += getSizeOf( _details ); - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeUnsignedShort( buffer, _replyCode ); - writeAMQShortString( buffer, _replyText ); - writeFieldTable( buffer, _details ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchChannelAlert(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[ChannelAlertBodyImpl: "); - buf.append( "replyCode=" ); - buf.append( getReplyCode() ); - buf.append( ", " ); - buf.append( "replyText=" ); - buf.append( getReplyText() ); - buf.append( ", " ); - buf.append( "details=" ); - buf.append( getDetails() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, - final ClientChannelMethodProcessor dispatcher) - throws IOException, AMQFrameDecodingException - { - - int replyCode = buffer.readUnsignedShort(); - AMQShortString replyText = buffer.readAMQShortString(); - FieldTable details = EncodingUtils.readFieldTable(buffer); - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveChannelAlert(replyCode, replyText, details); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ChannelCloseBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ChannelCloseBody.java deleted file mode 100644 index a3b92a1fad..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ChannelCloseBody.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class ChannelCloseBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 20; - public static final int METHOD_ID = 40; - - // Fields declared in specification - private final int _replyCode; // [replyCode] - private final AMQShortString _replyText; // [replyText] - private final int _classId; // [classId] - private final int _methodId; // [methodId] - - // Constructor - public ChannelCloseBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _replyCode = buffer.readUnsignedShort(); - _replyText = buffer.readAMQShortString(); - _classId = buffer.readUnsignedShort(); - _methodId = buffer.readUnsignedShort(); - } - - public ChannelCloseBody( - int replyCode, - AMQShortString replyText, - int classId, - int methodId - ) - { - _replyCode = replyCode; - _replyText = replyText; - _classId = classId; - _methodId = methodId; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final int getReplyCode() - { - return _replyCode; - } - public final AMQShortString getReplyText() - { - return _replyText; - } - public final int getClassId() - { - return _classId; - } - public final int getMethodId() - { - return _methodId; - } - - protected int getBodySize() - { - int size = 6; - size += getSizeOf( _replyText ); - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeUnsignedShort( buffer, _replyCode ); - writeAMQShortString( buffer, _replyText ); - writeUnsignedShort( buffer, _classId ); - writeUnsignedShort( buffer, _methodId ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchChannelClose(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[ChannelCloseBodyImpl: "); - buf.append( "replyCode=" ); - buf.append( getReplyCode() ); - buf.append( ", " ); - buf.append( "replyText=" ); - buf.append( getReplyText() ); - buf.append( ", " ); - buf.append( "classId=" ); - buf.append( getClassId() ); - buf.append( ", " ); - buf.append( "methodId=" ); - buf.append( getMethodId() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, - final ChannelMethodProcessor dispatcher) throws IOException - { - - int replyCode = buffer.readUnsignedShort(); - AMQShortString replyText = buffer.readAMQShortString(); - int classId = buffer.readUnsignedShort(); - int methodId = buffer.readUnsignedShort(); - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveChannelClose(replyCode, replyText, classId, methodId); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ChannelCloseOkBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ChannelCloseOkBody.java deleted file mode 100644 index e9b1572eef..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ChannelCloseOkBody.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class ChannelCloseOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - public static final ChannelCloseOkBody INSTANCE = new ChannelCloseOkBody(); - - public static final int CLASS_ID = 20; - public static final int METHOD_ID = 41; - - // Fields declared in specification - - // Constructor - public ChannelCloseOkBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - } - - private ChannelCloseOkBody() - { - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - - protected int getBodySize() - { - return 0; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchChannelCloseOk(this, channelId); - } - - public String toString() - { - return "[ChannelCloseOkBody]"; - - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ChannelFlowBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ChannelFlowBody.java deleted file mode 100644 index 1c3cc47d4e..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ChannelFlowBody.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class ChannelFlowBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 20; - public static final int METHOD_ID = 20; - - // Fields declared in specification - private final boolean _active; // [active] - - // Constructor - public ChannelFlowBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _active = (buffer.readByte() & 0x01) == 0x01; - } - - public ChannelFlowBody(boolean active) - { - _active = active; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final boolean getActive() - { - return _active; - } - - protected int getBodySize() - { - return 1; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeBitfield( buffer, _active ? (byte)1 : (byte)0); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchChannelFlow(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[ChannelFlowBodyImpl: "); - buf.append( "active=" ); - buf.append( getActive() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, - final ChannelMethodProcessor dispatcher) throws IOException - { - boolean active = (buffer.readByte() & 0x01) == 0x01; - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveChannelFlow(active); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ChannelFlowOkBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ChannelFlowOkBody.java deleted file mode 100644 index 9d4a2b09a1..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ChannelFlowOkBody.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class ChannelFlowOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 20; - public static final int METHOD_ID = 21; - - // Fields declared in specification - private final boolean _active; // [active] - - // Constructor - public ChannelFlowOkBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _active = (buffer.readByte() & 0x01) == 0x01; - } - - public ChannelFlowOkBody(boolean active) - { - _active = active; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final boolean getActive() - { - return _active; - } - - protected int getBodySize() - { - int size = 1; - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeBitfield( buffer, _active ? (byte)1 : (byte)0 ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchChannelFlowOk(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[ChannelFlowOkBodyImpl: "); - buf.append( "active=" ); - buf.append( getActive() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, - final ChannelMethodProcessor dispatcher) - throws IOException - { - boolean active = (buffer.readByte() & 0x01) == 0x01; - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveChannelFlowOk(active); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ChannelMethodProcessor.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ChannelMethodProcessor.java deleted file mode 100644 index 75fbb15629..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ChannelMethodProcessor.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.framing; - -public interface ChannelMethodProcessor -{ - void receiveChannelFlow(boolean active); - - void receiveChannelFlowOk(boolean active); - - void receiveChannelClose(int replyCode, AMQShortString replyText, int classId, int methodId); - - void receiveChannelCloseOk(); - - void receiveMessageContent(byte[] data); - - void receiveMessageHeader(BasicContentHeaderProperties properties, long bodySize); - - boolean ignoreAllButCloseOk(); - - void receiveBasicNack(long deliveryTag, boolean multiple, boolean requeue); - - void receiveBasicAck(long deliveryTag, boolean multiple); -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ChannelOpenBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ChannelOpenBody.java deleted file mode 100644 index af583f5fda..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ChannelOpenBody.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class ChannelOpenBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 20; - public static final int METHOD_ID = 10; - - - // Constructor - public ChannelOpenBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - // ignore unused OOB string - buffer.readAMQShortString(); - } - - public ChannelOpenBody() - { - - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - protected int getBodySize() - { - return 1; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeAMQShortString( buffer, null ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchChannelOpen(this, channelId); - } - - public String toString() - { - return "[ChannelOpenBody] "; - } - - public static void process(final int channelId, - final MarkableDataInput buffer, - final ServerMethodProcessor dispatcher) throws IOException - { - buffer.readAMQShortString(); - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveChannelOpen(channelId); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ChannelOpenOkBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ChannelOpenOkBody.java deleted file mode 100644 index e3b4f38a8c..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ChannelOpenOkBody.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class ChannelOpenOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 20; - public static final int METHOD_ID = 11; - - public static final ChannelOpenOkBody INSTANCE_0_8 = new ChannelOpenOkBody(true); - public static final ChannelOpenOkBody INSTANCE_0_9 = new ChannelOpenOkBody(false); - - public static ChannelOpenOkBody getInstance(ProtocolVersion protocolVersion, MarkableDataInput input) - throws IOException - { - final boolean isAMQP08 = ProtocolVersion.v8_0.equals(protocolVersion); - ChannelOpenOkBody instance = isAMQP08 ? INSTANCE_0_8 : INSTANCE_0_9; - if(!isAMQP08) - { - EncodingUtils.readBytes(input); - } - return instance; - } - // Fields declared in specification - private final boolean _isAMQP08; - // Constructor - - private ChannelOpenOkBody(boolean isAMQP08) - { - _isAMQP08 = isAMQP08; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - - protected int getBodySize() - { - return _isAMQP08 ? 0 : 4; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - if(!_isAMQP08) - { - buffer.writeInt(0); - } - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchChannelOpenOk(this, channelId); - } - - public String toString() - { - return "[ChannelOpenOkBody]"; - } - - public static void process(final MarkableDataInput in, - final ProtocolVersion protocolVersion, - final ClientChannelMethodProcessor dispatcher) throws IOException - { - if(!ProtocolVersion.v8_0.equals(protocolVersion)) - { - EncodingUtils.readBytes(in); - } - - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveChannelOpenOk(); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ClientChannelMethodProcessor.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ClientChannelMethodProcessor.java deleted file mode 100644 index 289a284d6b..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ClientChannelMethodProcessor.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.framing; - -public interface ClientChannelMethodProcessor extends ChannelMethodProcessor -{ - void receiveChannelOpenOk(); - - void receiveChannelAlert(int replyCode, final AMQShortString replyText, FieldTable details); - - void receiveAccessRequestOk(int ticket); - - void receiveExchangeDeclareOk(); - - void receiveExchangeDeleteOk(); - - void receiveExchangeBoundOk(int replyCode, AMQShortString replyText); - - void receiveQueueBindOk(); - - void receiveQueueUnbindOk(); - - void receiveQueueDeclareOk(final AMQShortString queue, long messageCount, long consumerCount); - - void receiveQueuePurgeOk(long messageCount); - - void receiveQueueDeleteOk(long messageCount); - - void receiveBasicRecoverSyncOk(); - - void receiveBasicQosOk(); - - void receiveBasicConsumeOk(AMQShortString consumerTag); - - void receiveBasicCancelOk(AMQShortString consumerTag); - - void receiveBasicReturn(int replyCode, - AMQShortString replyText, - AMQShortString exchange, - AMQShortString routingKey); - - void receiveBasicDeliver(AMQShortString consumerTag, - long deliveryTag, - boolean redelivered, - AMQShortString exchange, AMQShortString routingKey); - - void receiveBasicGetOk(long deliveryTag, - boolean redelivered, - AMQShortString exchange, - AMQShortString routingKey, long messageCount); - - void receiveBasicGetEmpty(); - - void receiveTxSelectOk(); - - void receiveTxCommitOk(); - - void receiveTxRollbackOk(); - - void receiveConfirmSelectOk(); -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ClientMethodDispatcher.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ClientMethodDispatcher.java deleted file mode 100644 index 4f1b6b917e..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ClientMethodDispatcher.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 0-9 - * 0-91 - * 8-0 - */ - -package org.apache.qpid.framing; - -import org.apache.qpid.AMQException; - -public interface ClientMethodDispatcher -{ - - public boolean dispatchBasicCancelOk(BasicCancelOkBody body, int channelId) throws AMQException; - public boolean dispatchBasicConsumeOk(BasicConsumeOkBody body, int channelId) throws AMQException; - public boolean dispatchBasicDeliver(BasicDeliverBody body, int channelId) throws AMQException; - public boolean dispatchBasicGetEmpty(BasicGetEmptyBody body, int channelId) throws AMQException; - public boolean dispatchBasicGetOk(BasicGetOkBody body, int channelId) throws AMQException; - public boolean dispatchBasicQosOk(BasicQosOkBody body, int channelId) throws AMQException; - public boolean dispatchBasicReturn(BasicReturnBody body, int channelId) throws AMQException; - public boolean dispatchChannelClose(ChannelCloseBody body, int channelId) throws AMQException; - public boolean dispatchChannelCloseOk(ChannelCloseOkBody body, int channelId) throws AMQException; - public boolean dispatchChannelFlow(ChannelFlowBody body, int channelId) throws AMQException; - public boolean dispatchChannelFlowOk(ChannelFlowOkBody body, int channelId) throws AMQException; - public boolean dispatchChannelOpenOk(ChannelOpenOkBody body, int channelId) throws AMQException; - public boolean dispatchConnectionClose(ConnectionCloseBody body, int channelId) throws AMQException; - public boolean dispatchConnectionCloseOk(ConnectionCloseOkBody body, int channelId) throws AMQException; - public boolean dispatchConnectionOpenOk(ConnectionOpenOkBody body, int channelId) throws AMQException; - public boolean dispatchConnectionSecure(ConnectionSecureBody body, int channelId) throws AMQException; - public boolean dispatchConnectionStart(ConnectionStartBody body, int channelId) throws AMQException; - public boolean dispatchConnectionTune(ConnectionTuneBody body, int channelId) throws AMQException; - public boolean dispatchExchangeBoundOk(ExchangeBoundOkBody body, int channelId) throws AMQException; - public boolean dispatchExchangeDeclareOk(ExchangeDeclareOkBody body, int channelId) throws AMQException; - public boolean dispatchExchangeDeleteOk(ExchangeDeleteOkBody body, int channelId) throws AMQException; - public boolean dispatchQueueBindOk(QueueBindOkBody body, int channelId) throws AMQException; - public boolean dispatchQueueDeclareOk(QueueDeclareOkBody body, int channelId) throws AMQException; - public boolean dispatchQueueDeleteOk(QueueDeleteOkBody body, int channelId) throws AMQException; - public boolean dispatchQueuePurgeOk(QueuePurgeOkBody body, int channelId) throws AMQException; - public boolean dispatchTxCommitOk(TxCommitOkBody body, int channelId) throws AMQException; - public boolean dispatchTxRollbackOk(TxRollbackOkBody body, int channelId) throws AMQException; - public boolean dispatchTxSelectOk(TxSelectOkBody body, int channelId) throws AMQException; - - boolean dispatchConnectionRedirect(ConnectionRedirectBody connectionRedirectBody, int channelId) throws AMQException; - boolean dispatchAccessRequestOk(AccessRequestOkBody accessRequestOkBody, int channelId) throws AMQException; - - boolean dispatchQueueUnbindOk(QueueUnbindOkBody queueUnbindOkBody, int channelId) throws AMQException; - - boolean dispatchBasicRecoverSyncOk(BasicRecoverSyncOkBody basicRecoverSyncOkBody, int channelId) - throws AMQException; - - boolean dispatchChannelAlert(ChannelAlertBody channelAlertBody, int channelId) throws AMQException; - - boolean dispatchConfirmSelectOk(ConfirmSelectOkBody confirmSelectOkBody, int channelId) throws AMQException; -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ClientMethodProcessor.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ClientMethodProcessor.java deleted file mode 100644 index 0b599ee40a..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ClientMethodProcessor.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.framing; - -public interface ClientMethodProcessor extends MethodProcessor -{ - void receiveConnectionStart(short versionMajor, - short versionMinor, - FieldTable serverProperties, - byte[] mechanisms, - byte[] locales); - - void receiveConnectionSecure(byte[] challenge); - - void receiveConnectionRedirect(AMQShortString host, AMQShortString knownHosts); - - void receiveConnectionTune(int channelMax, long frameMax, int heartbeat); - - void receiveConnectionOpenOk(AMQShortString knownHosts); - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/CompositeAMQDataBlock.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/CompositeAMQDataBlock.java deleted file mode 100644 index 819446021e..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/CompositeAMQDataBlock.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.transport.ByteBufferSender; - -public class CompositeAMQDataBlock extends AMQDataBlock implements EncodableAMQDataBlock -{ - - private AMQDataBlock[] _blocks; - - public CompositeAMQDataBlock(AMQDataBlock[] blocks) - { - _blocks = blocks; - } - - - public AMQDataBlock[] getBlocks() - { - return _blocks; - } - - - public long getSize() - { - long frameSize = 0; - for (int i = 0; i < _blocks.length; i++) - { - frameSize += _blocks[i].getSize(); - } - return frameSize; - } - - public void writePayload(DataOutput buffer) throws IOException - { - for (int i = 0; i < _blocks.length; i++) - { - _blocks[i].writePayload(buffer); - } - } - - @Override - public long writePayload(final ByteBufferSender sender) throws IOException - { - long size = 0l; - for (int i = 0; i < _blocks.length; i++) - { - size += _blocks[i].writePayload(sender); - } - return size; - } - - public String toString() - { - if (_blocks == null) - { - return "No blocks contained in composite frame"; - } - else - { - StringBuilder buf = new StringBuilder(this.getClass().getName()); - buf.append("{"); - for (int i = 0 ; i < _blocks.length; i++) - { - buf.append(" ").append(i).append("=[").append(_blocks[i].toString()).append("]"); - } - buf.append("}"); - return buf.toString(); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ConfirmSelectBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ConfirmSelectBody.java deleted file mode 100644 index 7f9e56caa6..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ConfirmSelectBody.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class ConfirmSelectBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 85; - public static final int METHOD_ID = 10; - - // Fields declared in specification - private final boolean _nowait; // [active] - - // Constructor - public ConfirmSelectBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _nowait = (buffer.readByte() & 0x01) == 0x01; - } - - public ConfirmSelectBody(boolean nowait) - { - _nowait = nowait; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final boolean getNowait() - { - return _nowait; - } - - protected int getBodySize() - { - return 1; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeBitfield( buffer, _nowait ? (byte)1 : (byte)0 ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchConfirmSelect(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[ConfirmSelectBody: "); - buf.append( "active=" ); - buf.append( getNowait() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, - final ServerChannelMethodProcessor dispatcher) - throws IOException - { - boolean nowait = (buffer.readByte() & 0x01) == 0x01; - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveConfirmSelect(nowait); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ConfirmSelectOkBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ConfirmSelectOkBody.java deleted file mode 100644 index d0e3bd093d..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ConfirmSelectOkBody.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; - -public class ConfirmSelectOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 85; - public static final int METHOD_ID = 11; - - public static final ConfirmSelectOkBody INSTANCE = new ConfirmSelectOkBody(); - - private ConfirmSelectOkBody() - { - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - - protected int getBodySize() - { - return 0; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchConfirmSelectOk(this, channelId); - } - - public String toString() - { - return "[ConfirmSelectOkBody]"; - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionCloseBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionCloseBody.java deleted file mode 100644 index 546cf5fa0a..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionCloseBody.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 0-91 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class ConnectionCloseBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 10; - - private final int _ownMethodId; - // Fields declared in specification - private final int _replyCode; // [replyCode] - private final AMQShortString _replyText; // [replyText] - private final int _classId; // [classId] - private final int _methodId; // [methodId] - - // Constructor - public ConnectionCloseBody(MarkableDataInput buffer, ProtocolVersion protocolVersion) throws AMQFrameDecodingException, IOException - { - _ownMethodId = ProtocolVersion.v8_0.equals(protocolVersion) ? 60 : 50; - _replyCode = buffer.readUnsignedShort(); - _replyText = buffer.readAMQShortString(); - _classId = buffer.readUnsignedShort(); - _methodId = buffer.readUnsignedShort(); - } - - public ConnectionCloseBody(ProtocolVersion protocolVersion, - int replyCode, - AMQShortString replyText, - int classId, - int methodId - ) - { - _ownMethodId = ProtocolVersion.v8_0.equals(protocolVersion) ? 60 : 50; - _replyCode = replyCode; - _replyText = replyText; - _classId = classId; - _methodId = methodId; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return _ownMethodId; - } - - public final int getReplyCode() - { - return _replyCode; - } - public final AMQShortString getReplyText() - { - return _replyText; - } - public final int getClassId() - { - return _classId; - } - public final int getMethodId() - { - return _methodId; - } - - protected int getBodySize() - { - int size = 6; - size += getSizeOf( _replyText ); - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeUnsignedShort( buffer, _replyCode ); - writeAMQShortString( buffer, _replyText ); - writeUnsignedShort( buffer, _classId ); - writeUnsignedShort( buffer, _methodId ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchConnectionClose(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[ConnectionCloseBodyImpl: "); - buf.append( "replyCode=" ); - buf.append( getReplyCode() ); - buf.append( ", " ); - buf.append( "replyText=" ); - buf.append( getReplyText() ); - buf.append( ", " ); - buf.append( "classId=" ); - buf.append( getClassId() ); - buf.append( ", " ); - buf.append( "methodId=" ); - buf.append( getMethodId() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, final MethodProcessor dispatcher) throws IOException - { - int replyCode = buffer.readUnsignedShort(); - AMQShortString replyText = buffer.readAMQShortString(); - int classId = buffer.readUnsignedShort(); - int methodId = buffer.readUnsignedShort(); - dispatcher.receiveConnectionClose(replyCode, replyText, classId, methodId); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionCloseOkBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionCloseOkBody.java deleted file mode 100644 index 30e9f90b9a..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionCloseOkBody.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 0-91 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class ConnectionCloseOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - private final int _ownMethodId; - - public static final int CLASS_ID = 10; - - public static final ConnectionCloseOkBody CONNECTION_CLOSE_OK_0_8 = new ConnectionCloseOkBody(61); - public static final ConnectionCloseOkBody CONNECTION_CLOSE_OK_0_9 = new ConnectionCloseOkBody(51); - - // Constructor - private ConnectionCloseOkBody(int methodId) - { - _ownMethodId = methodId; - } - - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return _ownMethodId; - } - - - protected int getBodySize() - { - return 0; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchConnectionCloseOk(this, channelId); - } - - public String toString() - { - return "[ConnectionCloseOkBody]"; - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionOpenBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionOpenBody.java deleted file mode 100644 index 7fb815ae40..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionOpenBody.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class ConnectionOpenBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 10; - public static final int METHOD_ID = 40; - - // Fields declared in specification - private final AMQShortString _virtualHost; // [virtualHost] - private final AMQShortString _capabilities; // [capabilities] - private final boolean _insist; // [insist] - - // Constructor - public ConnectionOpenBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _virtualHost = buffer.readAMQShortString(); - _capabilities = buffer.readAMQShortString(); - _insist = (buffer.readByte() & 0x01) == 0x01; - } - - public ConnectionOpenBody( - AMQShortString virtualHost, - AMQShortString capabilities, - boolean insist - ) - { - _virtualHost = virtualHost; - _capabilities = capabilities; - _insist = insist; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final AMQShortString getVirtualHost() - { - return _virtualHost; - } - public final AMQShortString getCapabilities() - { - return _capabilities; - } - public final boolean getInsist() - { - return _insist; - } - - protected int getBodySize() - { - int size = 1; - size += getSizeOf( _virtualHost ); - size += getSizeOf( _capabilities ); - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeAMQShortString( buffer, _virtualHost ); - writeAMQShortString( buffer, _capabilities ); - writeBitfield( buffer, _insist ? (byte)1 : (byte)0); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchConnectionOpen(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[ConnectionOpenBodyImpl: "); - buf.append( "virtualHost=" ); - buf.append( getVirtualHost() ); - buf.append( ", " ); - buf.append( "capabilities=" ); - buf.append( getCapabilities() ); - buf.append( ", " ); - buf.append( "insist=" ); - buf.append( getInsist() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, final ServerMethodProcessor dispatcher) throws IOException - { - - AMQShortString virtualHost = buffer.readAMQShortString(); - AMQShortString capabilities = buffer.readAMQShortString(); - boolean insist = (buffer.readByte() & 0x01) == 0x01; - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveConnectionOpen(virtualHost, capabilities, insist); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionOpenOkBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionOpenOkBody.java deleted file mode 100644 index 95c48873f3..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionOpenOkBody.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class ConnectionOpenOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 10; - public static final int METHOD_ID = 41; - - // Fields declared in specification - private final AMQShortString _knownHosts; // [knownHosts] - - // Constructor - public ConnectionOpenOkBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _knownHosts = buffer.readAMQShortString(); - } - - public ConnectionOpenOkBody( - AMQShortString knownHosts - ) - { - _knownHosts = knownHosts; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final AMQShortString getKnownHosts() - { - return _knownHosts; - } - - protected int getBodySize() - { - int size = 0; - size += getSizeOf( _knownHosts ); - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeAMQShortString( buffer, _knownHosts ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchConnectionOpenOk(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[ConnectionOpenOkBodyImpl: "); - buf.append( "knownHosts=" ); - buf.append( getKnownHosts() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, final ClientMethodProcessor dispatcher) throws IOException - { - AMQShortString knownHosts = buffer.readAMQShortString(); - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveConnectionOpenOk(knownHosts); - } - - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionRedirectBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionRedirectBody.java deleted file mode 100644 index 491cc25125..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionRedirectBody.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class ConnectionRedirectBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - private final int _ownMethodId; - - public static final int CLASS_ID = 10; - - // Fields declared in specification - private final AMQShortString _host; // [host] - private final AMQShortString _knownHosts; // [knownHosts] - - // Constructor - public ConnectionRedirectBody(MarkableDataInput buffer, ProtocolVersion protocolVersion) throws AMQFrameDecodingException, IOException - { - _ownMethodId = ProtocolVersion.v8_0.equals(protocolVersion) ? 50 : 42; - _host = buffer.readAMQShortString(); - _knownHosts = buffer.readAMQShortString(); - } - - public ConnectionRedirectBody(ProtocolVersion protocolVersion, AMQShortString host, AMQShortString knownHosts) - { - _ownMethodId = ProtocolVersion.v8_0.equals(protocolVersion) ? 50 : 42; - _host = host; - _knownHosts = knownHosts; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return _ownMethodId; - } - - public final AMQShortString getHost() - { - return _host; - } - public final AMQShortString getKnownHosts() - { - return _knownHosts; - } - - protected int getBodySize() - { - int size = 0; - size += getSizeOf( _host ); - size += getSizeOf( _knownHosts ); - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeAMQShortString( buffer, _host ); - writeAMQShortString( buffer, _knownHosts ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchConnectionRedirect(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[ConnectionRedirectBodyImpl: "); - buf.append( "host=" ); - buf.append( getHost() ); - buf.append( ", " ); - buf.append( "knownHosts=" ); - buf.append( getKnownHosts() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, final ClientMethodProcessor dispatcher) throws IOException - { - AMQShortString host = buffer.readAMQShortString(); - AMQShortString knownHosts = buffer.readAMQShortString(); - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveConnectionRedirect(host, knownHosts); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionSecureBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionSecureBody.java deleted file mode 100644 index e10af3b4c1..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionSecureBody.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class ConnectionSecureBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 10; - public static final int METHOD_ID = 20; - - // Fields declared in specification - private final byte[] _challenge; // [challenge] - - // Constructor - public ConnectionSecureBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _challenge = EncodingUtils.readBytes(buffer); - } - - public ConnectionSecureBody( - byte[] challenge - ) - { - _challenge = challenge; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final byte[] getChallenge() - { - return _challenge; - } - - protected int getBodySize() - { - int size = 0; - size += getSizeOf( _challenge ); - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeBytes( buffer, _challenge ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchConnectionSecure(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[ConnectionSecureBodyImpl: "); - buf.append( "challenge=" ); - buf.append( getChallenge() == null ? "null" : java.util.Arrays.toString( getChallenge() ) ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput in, final ClientMethodProcessor dispatcher) - throws IOException, AMQFrameDecodingException - - { - byte[] challenge = EncodingUtils.readBytes(in); - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveConnectionSecure(challenge); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionSecureOkBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionSecureOkBody.java deleted file mode 100644 index 4c4a249bb6..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionSecureOkBody.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class ConnectionSecureOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 10; - public static final int METHOD_ID = 21; - - // Fields declared in specification - private final byte[] _response; // [response] - - // Constructor - public ConnectionSecureOkBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _response = EncodingUtils.readBytes(buffer); - } - - public ConnectionSecureOkBody( - byte[] response - ) - { - _response = response; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final byte[] getResponse() - { - return _response; - } - - protected int getBodySize() - { - int size = 0; - size += getSizeOf( _response ); - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeBytes( buffer, _response ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchConnectionSecureOk(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[ConnectionSecureOkBodyImpl: "); - buf.append( "response=" ); - buf.append( getResponse() == null ? "null" : java.util.Arrays.toString( getResponse() ) ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput in, final ServerMethodProcessor dispatcher) throws IOException - { - byte[] response = EncodingUtils.readBytes(in); - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveConnectionSecureOk(response); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionStartBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionStartBody.java deleted file mode 100644 index 3b94919d4e..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionStartBody.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class ConnectionStartBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 10; - public static final int METHOD_ID = 10; - - // Fields declared in specification - private final short _versionMajor; // [versionMajor] - private final short _versionMinor; // [versionMinor] - private final FieldTable _serverProperties; // [serverProperties] - private final byte[] _mechanisms; // [mechanisms] - private final byte[] _locales; // [locales] - - public ConnectionStartBody( - short versionMajor, - short versionMinor, - FieldTable serverProperties, - byte[] mechanisms, - byte[] locales - ) - { - _versionMajor = versionMajor; - _versionMinor = versionMinor; - _serverProperties = serverProperties; - _mechanisms = mechanisms; - _locales = locales; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final short getVersionMajor() - { - return _versionMajor; - } - public final short getVersionMinor() - { - return _versionMinor; - } - public final FieldTable getServerProperties() - { - return _serverProperties; - } - public final byte[] getMechanisms() - { - return _mechanisms; - } - public final byte[] getLocales() - { - return _locales; - } - - protected int getBodySize() - { - int size = 2; - size += getSizeOf( _serverProperties ); - size += getSizeOf( _mechanisms ); - size += getSizeOf( _locales ); - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeUnsignedByte( buffer, _versionMajor ); - writeUnsignedByte( buffer, _versionMinor ); - writeFieldTable( buffer, _serverProperties ); - writeBytes( buffer, _mechanisms ); - writeBytes( buffer, _locales ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchConnectionStart(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[ConnectionStartBodyImpl: "); - buf.append( "versionMajor=" ); - buf.append( getVersionMajor() ); - buf.append( ", " ); - buf.append( "versionMinor=" ); - buf.append( getVersionMinor() ); - buf.append( ", " ); - buf.append( "serverProperties=" ); - buf.append( getServerProperties() ); - buf.append( ", " ); - buf.append( "mechanisms=" ); - buf.append( getMechanisms() == null ? "null" : java.util.Arrays.toString( getMechanisms() ) ); - buf.append( ", " ); - buf.append( "locales=" ); - buf.append( getLocales() == null ? "null" : java.util.Arrays.toString( getLocales() ) ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput in, final ClientMethodProcessor dispatcher) - throws IOException, AMQFrameDecodingException - { - short versionMajor = (short) in.readUnsignedByte(); - short versionMinor = (short) in.readUnsignedByte(); - FieldTable serverProperties = EncodingUtils.readFieldTable(in); - byte[] mechanisms = EncodingUtils.readBytes(in); - byte[] locales = EncodingUtils.readBytes(in); - - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveConnectionStart(versionMajor, versionMinor, serverProperties, mechanisms, locales); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionStartOkBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionStartOkBody.java deleted file mode 100644 index 5b6a8e3ef7..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionStartOkBody.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class ConnectionStartOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 10; - public static final int METHOD_ID = 11; - - // Fields declared in specification - private final FieldTable _clientProperties; // [clientProperties] - private final AMQShortString _mechanism; // [mechanism] - private final byte[] _response; // [response] - private final AMQShortString _locale; // [locale] - - public ConnectionStartOkBody( - FieldTable clientProperties, - AMQShortString mechanism, - byte[] response, - AMQShortString locale - ) - { - _clientProperties = clientProperties; - _mechanism = mechanism; - _response = response; - _locale = locale; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final FieldTable getClientProperties() - { - return _clientProperties; - } - public final AMQShortString getMechanism() - { - return _mechanism; - } - public final byte[] getResponse() - { - return _response; - } - public final AMQShortString getLocale() - { - return _locale; - } - - protected int getBodySize() - { - int size = 0; - size += getSizeOf( _clientProperties ); - size += getSizeOf( _mechanism ); - size += getSizeOf( _response ); - size += getSizeOf( _locale ); - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeFieldTable( buffer, _clientProperties ); - writeAMQShortString( buffer, _mechanism ); - writeBytes( buffer, _response ); - writeAMQShortString( buffer, _locale ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchConnectionStartOk(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[ConnectionStartOkBodyImpl: "); - buf.append( "clientProperties=" ); - buf.append( getClientProperties() ); - buf.append( ", " ); - buf.append( "mechanism=" ); - buf.append( getMechanism() ); - buf.append( ", " ); - buf.append( "response=" ); - buf.append( getResponse() == null ? "null" : java.util.Arrays.toString( getResponse() ) ); - buf.append( ", " ); - buf.append( "locale=" ); - buf.append( getLocale() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput in, final ServerMethodProcessor dispatcher) - throws IOException, AMQFrameDecodingException - { - - FieldTable clientProperties = EncodingUtils.readFieldTable(in); - AMQShortString mechanism = in.readAMQShortString(); - byte[] response = EncodingUtils.readBytes(in); - AMQShortString locale = in.readAMQShortString(); - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveConnectionStartOk(clientProperties, mechanism, response, locale); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionTuneBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionTuneBody.java deleted file mode 100644 index 04def21d44..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionTuneBody.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class ConnectionTuneBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 10; - public static final int METHOD_ID = 30; - - // Fields declared in specification - private final int _channelMax; // [channelMax] - private final long _frameMax; // [frameMax] - private final int _heartbeat; // [heartbeat] - - // Constructor - public ConnectionTuneBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _channelMax = buffer.readUnsignedShort(); - _frameMax = EncodingUtils.readUnsignedInteger(buffer); - _heartbeat = buffer.readUnsignedShort(); - } - - public ConnectionTuneBody( - int channelMax, - long frameMax, - int heartbeat - ) - { - _channelMax = channelMax; - _frameMax = frameMax; - _heartbeat = heartbeat; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final int getChannelMax() - { - return _channelMax; - } - public final long getFrameMax() - { - return _frameMax; - } - public final int getHeartbeat() - { - return _heartbeat; - } - - protected int getBodySize() - { - int size = 8; - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeUnsignedShort( buffer, _channelMax ); - writeUnsignedInteger( buffer, _frameMax ); - writeUnsignedShort( buffer, _heartbeat ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchConnectionTune(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[ConnectionTuneBodyImpl: "); - buf.append( "channelMax=" ); - buf.append( getChannelMax() ); - buf.append( ", " ); - buf.append( "frameMax=" ); - buf.append( getFrameMax() ); - buf.append( ", " ); - buf.append( "heartbeat=" ); - buf.append( getHeartbeat() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, final ClientMethodProcessor dispatcher) throws IOException - { - - int channelMax = buffer.readUnsignedShort(); - long frameMax = EncodingUtils.readUnsignedInteger(buffer); - int heartbeat = buffer.readUnsignedShort(); - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveConnectionTune(channelMax, frameMax, heartbeat); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionTuneOkBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionTuneOkBody.java deleted file mode 100644 index 3141a85766..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ConnectionTuneOkBody.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class ConnectionTuneOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 10; - public static final int METHOD_ID = 31; - - // Fields declared in specification - private final int _channelMax; // [channelMax] - private final long _frameMax; // [frameMax] - private final int _heartbeat; // [heartbeat] - - // Constructor - public ConnectionTuneOkBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _channelMax = buffer.readUnsignedShort(); - _frameMax = EncodingUtils.readUnsignedInteger(buffer); - _heartbeat = buffer.readUnsignedShort(); - } - - public ConnectionTuneOkBody( - int channelMax, - long frameMax, - int heartbeat - ) - { - _channelMax = channelMax; - _frameMax = frameMax; - _heartbeat = heartbeat; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final int getChannelMax() - { - return _channelMax; - } - public final long getFrameMax() - { - return _frameMax; - } - public final int getHeartbeat() - { - return _heartbeat; - } - - protected int getBodySize() - { - int size = 8; - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeUnsignedShort( buffer, _channelMax ); - writeUnsignedInteger( buffer, _frameMax ); - writeUnsignedShort( buffer, _heartbeat ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchConnectionTuneOk(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[ConnectionTuneOkBodyImpl: "); - buf.append( "channelMax=" ); - buf.append( getChannelMax() ); - buf.append( ", " ); - buf.append( "frameMax=" ); - buf.append( getFrameMax() ); - buf.append( ", " ); - buf.append( "heartbeat=" ); - buf.append( getHeartbeat() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, final ServerMethodProcessor dispatcher) throws IOException - { - - int channelMax = buffer.readUnsignedShort(); - long frameMax = EncodingUtils.readUnsignedInteger(buffer); - int heartbeat = buffer.readUnsignedShort(); - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveConnectionTuneOk(channelMax, frameMax, heartbeat); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentBody.java deleted file mode 100644 index 0f4ba5209b..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentBody.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.framing; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.nio.ByteBuffer; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; -import org.apache.qpid.protocol.AMQVersionAwareProtocolSession; -import org.apache.qpid.transport.ByteBufferSender; - -public class ContentBody implements AMQBody -{ - public static final byte TYPE = 3; - - private byte[] _payload; - - public ContentBody() - { - } - - public ContentBody(DataInput buffer, long size) throws AMQFrameDecodingException, IOException - { - _payload = new byte[(int)size]; - buffer.readFully(getPayload()); - } - - - public ContentBody(byte[] payload) - { - _payload = payload; - } - - public byte getFrameType() - { - return TYPE; - } - - public int getSize() - { - return getPayload() == null ? 0 : getPayload().length; - } - - public void writePayload(DataOutput buffer) throws IOException - { - buffer.write(getPayload()); - } - - public void handle(final int channelId, final AMQVersionAwareProtocolSession session) - throws AMQException - { - session.contentBodyReceived(channelId, this); - } - - @Override - public long writePayload(final ByteBufferSender sender) throws IOException - { - if(_payload != null) - { - sender.send(ByteBuffer.wrap(_payload)); - return _payload.length; - } - else - { - return 0l; - } - } - - public byte[] getPayload() - { - return _payload; - } - - public static void process(final MarkableDataInput in, - final ChannelMethodProcessor methodProcessor, final long bodySize) - throws IOException - { - - byte[] payload = new byte[(int)bodySize]; - in.readFully(payload); - - if(!methodProcessor.ignoreAllButCloseOk()) - { - methodProcessor.receiveMessageContent(payload); - } - } - - private static class BufferContentBody implements AMQBody - { - private final int _length; - private final int _offset; - private final ByteBuffer _buf; - - private BufferContentBody( ByteBuffer buf, int offset, int length) - { - _length = length; - _offset = offset; - _buf = buf; - } - - public byte getFrameType() - { - return TYPE; - } - - - public int getSize() - { - return _length; - } - - public void writePayload(DataOutput buffer) throws IOException - { - if(_buf.hasArray()) - { - buffer.write(_buf.array(), _buf.arrayOffset() + _offset, _length); - } - else - { - byte[] data = new byte[_length]; - ByteBuffer buf = _buf.duplicate(); - - buf.position(_offset); - buf.limit(_offset+_length); - buf.get(data); - buffer.write(data); - } - } - - @Override - public long writePayload(final ByteBufferSender sender) throws IOException - { - if(_buf.hasArray()) - { - sender.send(ByteBuffer.wrap(_buf.array(), _buf.arrayOffset() + _offset, _length)); - } - else - { - ByteBuffer buf = _buf.duplicate(); - - buf.position(_offset); - buf.limit(_offset+_length); - sender.send(buf); - } - return _length; - } - - public void handle(int channelId, AMQVersionAwareProtocolSession amqProtocolSession) throws AMQException - { - throw new RuntimeException("Buffered Body only to be used for outgoing data"); - } - } - - public static AMQFrame createAMQFrame(int channelId, ByteBuffer buf, int offset, int length) - { - return new AMQFrame(channelId, new BufferContentBody(buf, offset, length)); - } - - public static AMQFrame createAMQFrame(int channelId, ContentBody body) - { - return new AMQFrame(channelId, body); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderBody.java deleted file mode 100644 index 21b8e6c8b6..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderBody.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.framing; - -import java.io.DataInput; -import java.io.DataInputStream; -import java.io.DataOutput; -import java.io.IOException; -import java.nio.ByteBuffer; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; -import org.apache.qpid.protocol.AMQVersionAwareProtocolSession; -import org.apache.qpid.transport.ByteBufferSender; -import org.apache.qpid.util.BytesDataOutput; - -public class ContentHeaderBody implements AMQBody -{ - public static final byte TYPE = 2; - public static final int CLASS_ID = 60; - - private long _bodySize; - - /** must never be null */ - private BasicContentHeaderProperties _properties; - - public ContentHeaderBody(DataInput buffer, long size) throws AMQFrameDecodingException, IOException - { - buffer.readUnsignedShort(); - buffer.readUnsignedShort(); - _bodySize = buffer.readLong(); - int propertyFlags = buffer.readUnsignedShort(); - ContentHeaderPropertiesFactory factory = ContentHeaderPropertiesFactory.getInstance(); - _properties = factory.createContentHeaderProperties(CLASS_ID, propertyFlags, buffer, (int)size - 14); - - } - - public ContentHeaderBody(BasicContentHeaderProperties props) - { - _properties = props; - } - - public ContentHeaderBody(BasicContentHeaderProperties props, long bodySize) - { - _properties = props; - _bodySize = bodySize; - } - - public byte getFrameType() - { - return TYPE; - } - - /** - * Helper method that is used currently by the persistence layer. - * @param buffer buffer to decode - * @param size size of the body - * - * @return the decoded header body - * @throws AMQFrameDecodingException if there is a decoding issue - * @throws AMQProtocolVersionException if there is a version issue - * @throws IOException if there is an IO issue - */ - public static ContentHeaderBody createFromBuffer(DataInputStream buffer, long size) - throws AMQFrameDecodingException, AMQProtocolVersionException, IOException - { - ContentHeaderBody body = new ContentHeaderBody(buffer, size); - - return body; - } - - public int getSize() - { - return 2 + 2 + 8 + 2 + _properties.getPropertyListSize(); - } - - public void writePayload(DataOutput buffer) throws IOException - { - EncodingUtils.writeUnsignedShort(buffer, CLASS_ID); - EncodingUtils.writeUnsignedShort(buffer, 0); - buffer.writeLong(_bodySize); - EncodingUtils.writeUnsignedShort(buffer, _properties.getPropertyFlags()); - _properties.writePropertyListPayload(buffer); - } - - @Override - public long writePayload(final ByteBufferSender sender) throws IOException - { - byte[] data = new byte[14]; - BytesDataOutput buffer = new BytesDataOutput(data); - EncodingUtils.writeUnsignedShort(buffer, CLASS_ID); - EncodingUtils.writeUnsignedShort(buffer, 0); - buffer.writeLong(_bodySize); - EncodingUtils.writeUnsignedShort(buffer, _properties.getPropertyFlags()); - sender.send(ByteBuffer.wrap(data)); - return 14 + _properties.writePropertyListPayload(sender); - } - - public void handle(final int channelId, final AMQVersionAwareProtocolSession session) - throws AMQException - { - session.contentHeaderReceived(channelId, this); - } - - public static AMQFrame createAMQFrame(int channelId, - BasicContentHeaderProperties properties, - long bodySize) - { - return new AMQFrame(channelId, new ContentHeaderBody(properties, bodySize)); - } - - public BasicContentHeaderProperties getProperties() - { - return _properties; - } - - public void setProperties(BasicContentHeaderProperties props) - { - _properties = props; - } - - @Override - public String toString() - { - return "ContentHeaderBody{" + - "classId=" + CLASS_ID + - ", weight=" + 0 + - ", bodySize=" + _bodySize + - ", properties=" + _properties + - '}'; - } - - public int getClassId() - { - return CLASS_ID; - } - - public int getWeight() - { - return 0; - } - - /** unsigned long but java can't handle that anyway when allocating byte array - * - * @return the body size */ - public long getBodySize() - { - return _bodySize; - } - - public void setBodySize(long bodySize) - { - _bodySize = bodySize; - } - - public static void process(final MarkableDataInput buffer, - final ChannelMethodProcessor methodProcessor, final long size) - throws IOException, AMQFrameDecodingException - { - - int classId = buffer.readUnsignedShort(); - buffer.readUnsignedShort(); - long bodySize = buffer.readLong(); - int propertyFlags = buffer.readUnsignedShort(); - - BasicContentHeaderProperties properties; - - if (classId != CLASS_ID) - { - throw new AMQFrameDecodingException(null, "Unsupported content header class id: " + classId, null); - } - properties = new BasicContentHeaderProperties(); - properties.populatePropertiesFromBuffer(buffer, propertyFlags, (int)(size-14)); - - if(!methodProcessor.ignoreAllButCloseOk()) - { - methodProcessor.receiveMessageHeader(properties, bodySize); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java deleted file mode 100644 index e8eb471284..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.framing; - -import java.io.DataInput; -import java.io.IOException; - -public class ContentHeaderPropertiesFactory -{ - private static final ContentHeaderPropertiesFactory _instance = new ContentHeaderPropertiesFactory(); - - public static ContentHeaderPropertiesFactory getInstance() - { - return _instance; - } - - private ContentHeaderPropertiesFactory() - { - } - - public BasicContentHeaderProperties createContentHeaderProperties(int classId, int propertyFlags, - DataInput buffer, int size) - throws AMQFrameDecodingException, IOException - { - BasicContentHeaderProperties properties; - // AMQP version change: "Hardwired" version to major=8, minor=0 - // TODO: Change so that the actual version is obtained from - // the ProtocolInitiation object for this session. - if (classId == BasicConsumeBody.CLASS_ID) - { - properties = new BasicContentHeaderProperties(); - } - else - { - throw new AMQFrameDecodingException(null, "Unsupport content header class id: " + classId, null); - } - properties.populatePropertiesFromBuffer(buffer, propertyFlags, size); - return properties; - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/EncodableAMQDataBlock.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/EncodableAMQDataBlock.java deleted file mode 100644 index 9cf96e698c..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/EncodableAMQDataBlock.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.framing; - -/** - * Marker interface to indicate to MINA that a data block should be encoded with the - * single encoder/decoder that we have defined. - * - * Note that due to a bug in MINA all classes must directly implement this interface, even if - * a superclass implements it. - * TODO: fix MINA so that this is not necessary - * - */ -public interface EncodableAMQDataBlock -{ - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java deleted file mode 100644 index a7fe4b01f3..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java +++ /dev/null @@ -1,1013 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.framing; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.charset.Charset; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class EncodingUtils -{ - private static final Logger _logger = LoggerFactory.getLogger(EncodingUtils.class); - - private static final String STRING_ENCODING = "iso8859-15"; - - private static final Charset _charset = Charset.forName("iso8859-15"); - - public static final int SIZEOF_UNSIGNED_SHORT = 2; - public static final int SIZEOF_UNSIGNED_INT = 4; - private static final boolean[] ALL_FALSE_ARRAY = new boolean[8]; - - private EncodingUtils() - { - } - - public static int encodedShortStringLength(String s) - { - if (s == null) - { - return 1; - } - else - { - return (short) (1 + s.length()); - } - } - - public static int encodedShortStringLength(short s) - { - if (s == 0) - { - return 1 + 1; - } - - int len = 0; - if (s < 0) - { - len = 1; - // sloppy - doesn't work of Integer.MIN_VALUE - s = (short) -s; - } - - if (s > 9999) - { - return 1 + 5; - } - else if (s > 999) - { - return 1 + 4; - } - else if (s > 99) - { - return 1 + 3; - } - else if (s > 9) - { - return 1 + 2; - } - else - { - return 1 + 1; - } - - } - - public static int encodedShortStringLength(int i) - { - if (i == 0) - { - return 1 + 1; - } - - int len = 0; - if (i < 0) - { - len = 1; - // sloppy - doesn't work of Integer.MIN_VALUE - i = -i; - } - - // range is now 1 - 2147483647 - if (i < Short.MAX_VALUE) - { - return len + encodedShortStringLength((short) i); - } - else if (i > 999999) - { - return len + 6 + encodedShortStringLength((short) (i / 1000000)); - } - else // if i > 99999 - { - return len + 5 + encodedShortStringLength((short) (i / 100000)); - } - - } - - public static int encodedShortStringLength(long l) - { - if (l == 0) - { - return 1 + 1; - } - - int len = 0; - if (l < 0) - { - len = 1; - // sloppy - doesn't work of Long.MIN_VALUE - l = -l; - } - - if (l < Integer.MAX_VALUE) - { - return len + encodedShortStringLength((int) l); - } - else if (l > 9999999999L) - { - return len + 10 + encodedShortStringLength((int) (l / 10000000000L)); - } - else - { - return len + 1 + encodedShortStringLength((int) (l / 10L)); - } - - } - - public static int encodedShortStringLength(AMQShortString s) - { - if (s == null) - { - return 1; - } - else - { - return (1 + s.length()); - } - } - - public static int encodedLongStringLength(String s) - { - if (s == null) - { - return 4; - } - else - { - return 4 + s.length(); - } - } - - public static int encodedLongStringLength(char[] s) - { - if (s == null) - { - return 4; - } - else - { - return 4 + s.length; - } - } - - public static int encodedLongstrLength(byte[] bytes) - { - if (bytes == null) - { - return 4; - } - else - { - return 4 + bytes.length; - } - } - - public static int encodedFieldTableLength(FieldTable table) - { - if (table == null) - { - // length is encoded as 4 octets - return 4; - } - else - { - // length of the table plus 4 octets for the length - return (int) table.getEncodedSize() + 4; - } - } - - public static void writeShortStringBytes(DataOutput buffer, String s) throws IOException - { - if (s != null) - { - byte[] encodedString = new byte[s.length()]; - char[] cha = s.toCharArray(); - for (int i = 0; i < cha.length; i++) - { - encodedString[i] = (byte) cha[i]; - } - - // TODO: check length fits in an unsigned byte - writeUnsignedByte(buffer, (short)encodedString.length); - buffer.write(encodedString); - - - } - else - { - // really writing out unsigned byte - buffer.write((byte) 0); - } - } - - public static void writeShortStringBytes(DataOutput buffer, AMQShortString s) throws IOException - { - if (s != null) - { - - s.writeToBuffer(buffer); - } - else - { - // really writing out unsigned byte - buffer.write((byte) 0); - } - } - - public static void writeLongStringBytes(DataOutput buffer, String s) throws IOException - { - if (s != null) - { - int len = s.length(); - writeUnsignedInteger(buffer, s.length()); - byte[] encodedString = new byte[len]; - char[] cha = s.toCharArray(); - for (int i = 0; i < cha.length; i++) - { - encodedString[i] = (byte) cha[i]; - } - - buffer.write(encodedString); - } - else - { - writeUnsignedInteger(buffer, 0); - } - } - - public static void writeLongStringBytes(DataOutput buffer, char[] s) throws IOException - { - if (s != null) - { - int len = s.length; - writeUnsignedInteger(buffer, s.length); - byte[] encodedString = new byte[len]; - for (int i = 0; i < s.length; i++) - { - encodedString[i] = (byte) s[i]; - } - - buffer.write(encodedString); - } - else - { - writeUnsignedInteger(buffer, 0); - } - } - - public static void writeLongStringBytes(DataOutput buffer, byte[] bytes) throws IOException - { - if (bytes != null) - { - writeUnsignedInteger(buffer, bytes.length); - buffer.write(bytes); - } - else - { - writeUnsignedInteger(buffer, 0); - } - } - - public static void writeUnsignedByte(DataOutput buffer, short b) throws IOException - { - byte bv = (byte) b; - buffer.write(bv); - } - - public static void writeUnsignedShort(DataOutput buffer, int s) throws IOException - { - // TODO: Is this comparison safe? Do I need to cast RHS to long? - if (s < Short.MAX_VALUE) - { - buffer.writeShort(s); - } - else - { - short sv = (short) s; - buffer.write((byte) (0xFF & (sv >> 8))); - buffer.write((byte) (0xFF & sv)); - } - } - - public static int unsignedIntegerLength() - { - return 4; - } - - public static void writeUnsignedInteger(DataOutput buffer, long l) throws IOException - { - // TODO: Is this comparison safe? Do I need to cast RHS to long? - if (l < Integer.MAX_VALUE) - { - buffer.writeInt((int) l); - } - else - { - int iv = (int) l; - - // FIXME: This *may* go faster if we build this into a local 4-byte array and then - // put the array in a single call. - buffer.write((byte) (0xFF & (iv >> 24))); - buffer.write((byte) (0xFF & (iv >> 16))); - buffer.write((byte) (0xFF & (iv >> 8))); - buffer.write((byte) (0xFF & iv)); - } - } - - public static void writeFieldTableBytes(DataOutput buffer, FieldTable table) throws IOException - { - if (table != null) - { - table.writeToBuffer(buffer); - } - else - { - EncodingUtils.writeUnsignedInteger(buffer, 0); - } - } - - public static void writeBooleans(DataOutput buffer, boolean[] values) throws IOException - { - byte packedValue = 0; - for (int i = 0; i < values.length; i++) - { - if (values[i]) - { - packedValue = (byte) (packedValue | (1 << i)); - } - } - - buffer.write(packedValue); - } - - public static void writeBooleans(DataOutput buffer, boolean value) throws IOException - { - - buffer.write(value ? (byte) 1 : (byte) 0); - } - - public static void writeBooleans(DataOutput buffer, boolean value0, boolean value1) throws IOException - { - byte packedValue = value0 ? (byte) 1 : (byte) 0; - - if (value1) - { - packedValue = (byte) (packedValue | (byte) (1 << 1)); - } - - buffer.write(packedValue); - } - - public static void writeBooleans(DataOutput buffer, boolean value0, boolean value1, boolean value2) throws IOException - { - byte packedValue = value0 ? (byte) 1 : (byte) 0; - - if (value1) - { - packedValue = (byte) (packedValue | (byte) (1 << 1)); - } - - if (value2) - { - packedValue = (byte) (packedValue | (byte) (1 << 2)); - } - - buffer.write(packedValue); - } - - public static void writeBooleans(DataOutput buffer, boolean value0, boolean value1, boolean value2, boolean value3) throws IOException - { - byte packedValue = value0 ? (byte) 1 : (byte) 0; - - if (value1) - { - packedValue = (byte) (packedValue | (byte) (1 << 1)); - } - - if (value2) - { - packedValue = (byte) (packedValue | (byte) (1 << 2)); - } - - if (value3) - { - packedValue = (byte) (packedValue | (byte) (1 << 3)); - } - - buffer.write(packedValue); - } - - public static void writeBooleans(DataOutput buffer, boolean value0, boolean value1, boolean value2, boolean value3, - boolean value4) throws IOException - { - byte packedValue = value0 ? (byte) 1 : (byte) 0; - - if (value1) - { - packedValue = (byte) (packedValue | (byte) (1 << 1)); - } - - if (value2) - { - packedValue = (byte) (packedValue | (byte) (1 << 2)); - } - - if (value3) - { - packedValue = (byte) (packedValue | (byte) (1 << 3)); - } - - if (value4) - { - packedValue = (byte) (packedValue | (byte) (1 << 4)); - } - - buffer.write(packedValue); - } - - public static void writeBooleans(DataOutput buffer, boolean value0, boolean value1, boolean value2, boolean value3, - boolean value4, boolean value5) throws IOException - { - byte packedValue = value0 ? (byte) 1 : (byte) 0; - - if (value1) - { - packedValue = (byte) (packedValue | (byte) (1 << 1)); - } - - if (value2) - { - packedValue = (byte) (packedValue | (byte) (1 << 2)); - } - - if (value3) - { - packedValue = (byte) (packedValue | (byte) (1 << 3)); - } - - if (value4) - { - packedValue = (byte) (packedValue | (byte) (1 << 4)); - } - - if (value5) - { - packedValue = (byte) (packedValue | (byte) (1 << 5)); - } - - buffer.write(packedValue); - } - - public static void writeBooleans(DataOutput buffer, boolean value0, boolean value1, boolean value2, boolean value3, - boolean value4, boolean value5, boolean value6) throws IOException - { - byte packedValue = value0 ? (byte) 1 : (byte) 0; - - if (value1) - { - packedValue = (byte) (packedValue | (byte) (1 << 1)); - } - - if (value2) - { - packedValue = (byte) (packedValue | (byte) (1 << 2)); - } - - if (value3) - { - packedValue = (byte) (packedValue | (byte) (1 << 3)); - } - - if (value4) - { - packedValue = (byte) (packedValue | (byte) (1 << 4)); - } - - if (value5) - { - packedValue = (byte) (packedValue | (byte) (1 << 5)); - } - - if (value6) - { - packedValue = (byte) (packedValue | (byte) (1 << 6)); - } - - buffer.write(packedValue); - } - - public static void writeBooleans(DataOutput buffer, boolean value0, boolean value1, boolean value2, boolean value3, - boolean value4, boolean value5, boolean value6, boolean value7) throws IOException - { - byte packedValue = value0 ? (byte) 1 : (byte) 0; - - if (value1) - { - packedValue = (byte) (packedValue | (byte) (1 << 1)); - } - - if (value2) - { - packedValue = (byte) (packedValue | (byte) (1 << 2)); - } - - if (value3) - { - packedValue = (byte) (packedValue | (byte) (1 << 3)); - } - - if (value4) - { - packedValue = (byte) (packedValue | (byte) (1 << 4)); - } - - if (value5) - { - packedValue = (byte) (packedValue | (byte) (1 << 5)); - } - - if (value6) - { - packedValue = (byte) (packedValue | (byte) (1 << 6)); - } - - if (value7) - { - packedValue = (byte) (packedValue | (byte) (1 << 7)); - } - - buffer.write(packedValue); - } - - /** - * This is used for writing longstrs. - * @param buffer buffer to write to - * @param data data to write - * @throws IOException if there is an issue writing the output - */ - public static void writeLongstr(DataOutput buffer, byte[] data) throws IOException - { - if (data != null) - { - writeUnsignedInteger(buffer, data.length); - buffer.write(data); - } - else - { - writeUnsignedInteger(buffer, 0); - } - } - - public static void writeTimestamp(DataOutput buffer, long timestamp) throws IOException - { - writeLong(buffer, timestamp); - } - - public static boolean[] readBooleans(DataInput buffer) throws IOException - { - final byte packedValue = buffer.readByte(); - if (packedValue == 0) - { - return ALL_FALSE_ARRAY; - } - - final boolean[] result = new boolean[8]; - - result[0] = ((packedValue & 1) != 0); - result[1] = ((packedValue & (1 << 1)) != 0); - result[2] = ((packedValue & (1 << 2)) != 0); - result[3] = ((packedValue & (1 << 3)) != 0); - if ((packedValue & 0xF0) == 0) - { - result[0] = ((packedValue & 1) != 0); - } - - result[4] = ((packedValue & (1 << 4)) != 0); - result[5] = ((packedValue & (1 << 5)) != 0); - result[6] = ((packedValue & (1 << 6)) != 0); - result[7] = ((packedValue & (1 << 7)) != 0); - - return result; - } - - public static FieldTable readFieldTable(DataInput buffer) throws AMQFrameDecodingException, IOException - { - long length = ((long)(buffer.readInt())) & 0xFFFFFFFFL; - if (length == 0) - { - return null; - } - else - { - return FieldTableFactory.newFieldTable(buffer, length); - } - } - - public static AMQShortString readAMQShortString(DataInput buffer) throws IOException - { - return AMQShortString.readFromBuffer(buffer); - - } - - public static String readShortString(DataInput buffer) throws IOException - { - short length = (short) (((short)buffer.readByte()) & 0xFF); - if (length == 0) - { - return null; - } - else - { - // this may seem rather odd to declare two array but testing has shown - // that constructing a string from a byte array is 5 (five) times slower - // than constructing one from a char array. - // this approach here is valid since we know that all the chars are - // ASCII (0-127) - byte[] stringBytes = new byte[length]; - buffer.readFully(stringBytes, 0, length); - char[] stringChars = new char[length]; - for (int i = 0; i < stringChars.length; i++) - { - stringChars[i] = (char) stringBytes[i]; - } - - return new String(stringChars); - } - } - - public static String readLongString(DataInput buffer) throws IOException - { - long length = ((long)(buffer.readInt())) & 0xFFFFFFFFL; - if (length == 0) - { - return ""; - } - else - { - // this may seem rather odd to declare two array but testing has shown - // that constructing a string from a byte array is 5 (five) times slower - // than constructing one from a char array. - // this approach here is valid since we know that all the chars are - // ASCII (0-127) - byte[] stringBytes = new byte[(int) length]; - buffer.readFully(stringBytes, 0, (int) length); - char[] stringChars = new char[(int) length]; - for (int i = 0; i < stringChars.length; i++) - { - stringChars[i] = (char) stringBytes[i]; - } - - return new String(stringChars); - } - } - - public static byte[] readLongstr(DataInput buffer) throws IOException - { - long length = ((long)(buffer.readInt())) & 0xFFFFFFFFL; - if (length == 0) - { - return null; - } - else - { - byte[] result = new byte[(int) length]; - buffer.readFully(result); - - return result; - } - } - - public static long readTimestamp(DataInput buffer) throws IOException - { - return buffer.readLong(); - } - - static byte[] hexToByteArray(String id) - { - // Should check param for null, long enough for this check, upper-case and trailing char - String s = (id.charAt(1) == 'x') ? id.substring(2) : id; // strip 0x - - int len = s.length(); - int byte_len = len / 2; - byte[] b = new byte[byte_len]; - - for (int i = 0; i < byte_len; i++) - { - // fixme: refine these repetitive subscript calcs. - int ch = i * 2; - - byte b1 = Byte.parseByte(s.substring(ch, ch + 1), 16); - byte b2 = Byte.parseByte(s.substring(ch + 1, ch + 2), 16); - - b[i] = (byte) ((b1 * 16) + b2); - } - - return (b); - } - - public static char[] convertToHexCharArray(byte[] from) - { - int length = from.length; - char[] result_buff = new char[(length * 2) + 2]; - - result_buff[0] = '0'; - result_buff[1] = 'x'; - - int bite; - int dest = 2; - - for (int i = 0; i < length; i++) - { - bite = from[i]; - - if (bite < 0) - { - bite += 256; - } - - result_buff[dest++] = hex_chars[bite >> 4]; - result_buff[dest++] = hex_chars[bite & 0x0f]; - } - - return (result_buff); - } - - public static String convertToHexString(byte[] from) - { - return (new String(convertToHexCharArray(from))); - } - - public static String convertToHexString(ByteBuffer bb) - { - int size = bb.limit(); - - byte[] from = new byte[size]; - - for (int i = 0; i < size; i++) - { - from[i] = bb.get(i); - } - - return (new String(convertToHexCharArray(from))); - } - - private static char[] hex_chars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; - - // **** new methods - - // AMQP_BOOLEAN_PROPERTY_PREFIX - - public static void writeBoolean(DataOutput buffer, boolean aBoolean) throws IOException - { - buffer.write(aBoolean ? 1 : 0); - } - - public static boolean readBoolean(DataInput buffer) throws IOException - { - byte packedValue = buffer.readByte(); - - return (packedValue == 1); - } - - public static int encodedBooleanLength() - { - return 1; - } - - // AMQP_BYTE_PROPERTY_PREFIX - public static void writeByte(DataOutput buffer, byte aByte) throws IOException - { - buffer.writeByte(aByte); - } - - public static byte readByte(DataInput buffer) throws IOException - { - return buffer.readByte(); - } - - public static int encodedByteLength() - { - return 1; - } - - // AMQP_SHORT_PROPERTY_PREFIX - public static void writeShort(DataOutput buffer, short aShort) throws IOException - { - buffer.writeShort(aShort); - } - - public static short readShort(DataInput buffer) throws IOException - { - return buffer.readShort(); - } - - public static int encodedShortLength() - { - return 2; - } - - // INTEGER_PROPERTY_PREFIX - public static void writeInteger(DataOutput buffer, int aInteger) throws IOException - { - buffer.writeInt(aInteger); - } - - public static int readInteger(DataInput buffer) throws IOException - { - return buffer.readInt(); - } - - public static int encodedIntegerLength() - { - return 4; - } - - // AMQP_LONG_PROPERTY_PREFIX - public static void writeLong(DataOutput buffer, long aLong) throws IOException - { - buffer.writeLong(aLong); - } - - public static long readLong(DataInput buffer) throws IOException - { - return buffer.readLong(); - } - - public static int encodedLongLength() - { - return 8; - } - - // Float_PROPERTY_PREFIX - public static void writeFloat(DataOutput buffer, float aFloat) throws IOException - { - buffer.writeFloat(aFloat); - } - - public static float readFloat(DataInput buffer) throws IOException - { - return buffer.readFloat(); - } - - public static int encodedFloatLength() - { - return 4; - } - - // Double_PROPERTY_PREFIX - public static void writeDouble(DataOutput buffer, Double aDouble) throws IOException - { - buffer.writeDouble(aDouble); - } - - public static double readDouble(DataInput buffer) throws IOException - { - return buffer.readDouble(); - } - - public static int encodedDoubleLength() - { - return 8; - } - - public static byte[] readBytes(DataInput buffer) throws IOException - { - long length = ((long)(buffer.readInt())) & 0xFFFFFFFFL; - if (length == 0) - { - return null; - } - else - { - byte[] dataBytes = new byte[(int)length]; - buffer.readFully(dataBytes, 0, (int) length); - - return dataBytes; - } - } - - public static void writeBytes(DataOutput buffer, byte[] data) throws IOException - { - if (data != null) - { - // TODO: check length fits in an unsigned byte - writeUnsignedInteger(buffer, (long)data.length); - buffer.write(data); - } - else - { - writeUnsignedInteger(buffer, 0L); - } - } - - // CHAR_PROPERTY - public static int encodedCharLength() - { - return encodedByteLength(); - } - - public static char readChar(DataInput buffer) throws IOException - { - // This is valid as we know that the Character is ASCII 0..127 - return (char) buffer.readByte(); - } - - public static void writeChar(DataOutput buffer, char character) throws IOException - { - // This is valid as we know that the Character is ASCII 0..127 - writeByte(buffer, (byte) character); - } - - public static long readLongAsShortString(DataInput buffer) throws IOException - { - short length = (short) buffer.readUnsignedByte(); - short pos = 0; - if (length == 0) - { - return 0L; - } - - byte digit = buffer.readByte(); - boolean isNegative; - long result = 0; - if (digit == (byte) '-') - { - isNegative = true; - pos++; - digit = buffer.readByte(); - } - else - { - isNegative = false; - } - - result = digit - (byte) '0'; - pos++; - - while (pos < length) - { - pos++; - digit = buffer.readByte(); - result = (result << 3) + (result << 1); - result += digit - (byte) '0'; - } - - return result; - } - - public static long readUnsignedInteger(DataInput buffer) throws IOException - { - long l = 0xFF & buffer.readByte(); - l <<= 8; - l = l | (0xFF & buffer.readByte()); - l <<= 8; - l = l | (0xFF & buffer.readByte()); - l <<= 8; - l = l | (0xFF & buffer.readByte()); - - return l; - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ExchangeBoundBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ExchangeBoundBody.java deleted file mode 100644 index e8dc2ae442..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ExchangeBoundBody.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class ExchangeBoundBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 40; - public static final int METHOD_ID = 22; - - // Fields declared in specification - private final AMQShortString _exchange; // [exchange] - private final AMQShortString _routingKey; // [routingKey] - private final AMQShortString _queue; // [queue] - - // Constructor - public ExchangeBoundBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _exchange = buffer.readAMQShortString(); - _routingKey = buffer.readAMQShortString(); - _queue = buffer.readAMQShortString(); - } - - public ExchangeBoundBody( - AMQShortString exchange, - AMQShortString routingKey, - AMQShortString queue - ) - { - _exchange = exchange; - _routingKey = routingKey; - _queue = queue; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final AMQShortString getExchange() - { - return _exchange; - } - public final AMQShortString getRoutingKey() - { - return _routingKey; - } - public final AMQShortString getQueue() - { - return _queue; - } - - protected int getBodySize() - { - int size = 0; - size += getSizeOf( _exchange ); - size += getSizeOf( _routingKey ); - size += getSizeOf( _queue ); - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeAMQShortString( buffer, _exchange ); - writeAMQShortString( buffer, _routingKey ); - writeAMQShortString( buffer, _queue ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchExchangeBound(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[ExchangeBoundBodyImpl: "); - buf.append( "exchange=" ); - buf.append( getExchange() ); - buf.append( ", " ); - buf.append( "routingKey=" ); - buf.append( getRoutingKey() ); - buf.append( ", " ); - buf.append( "queue=" ); - buf.append( getQueue() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, - final ServerChannelMethodProcessor dispatcher) - throws IOException - { - - AMQShortString exchange = buffer.readAMQShortString(); - AMQShortString routingKey = buffer.readAMQShortString(); - AMQShortString queue = buffer.readAMQShortString(); - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveExchangeBound(exchange, routingKey, queue); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ExchangeBoundOkBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ExchangeBoundOkBody.java deleted file mode 100644 index ef91c1d635..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ExchangeBoundOkBody.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class ExchangeBoundOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 40; - public static final int METHOD_ID = 23; - public static final int OK = 0; - public static final int EXCHANGE_NOT_FOUND = 1; - public static final int QUEUE_NOT_FOUND = 2; - public static final int NO_BINDINGS = 3; - public static final int QUEUE_NOT_BOUND = 4; - public static final int NO_QUEUE_BOUND_WITH_RK = 5; - public static final int SPECIFIC_QUEUE_NOT_BOUND_WITH_RK = 6; - - // Fields declared in specification - private final int _replyCode; // [replyCode] - private final AMQShortString _replyText; // [replyText] - - // Constructor - public ExchangeBoundOkBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _replyCode = buffer.readUnsignedShort(); - _replyText = buffer.readAMQShortString(); - } - - public ExchangeBoundOkBody( - int replyCode, - AMQShortString replyText - ) - { - _replyCode = replyCode; - _replyText = replyText; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final int getReplyCode() - { - return _replyCode; - } - public final AMQShortString getReplyText() - { - return _replyText; - } - - protected int getBodySize() - { - int size = 2; - size += getSizeOf( _replyText ); - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeUnsignedShort( buffer, _replyCode ); - writeAMQShortString( buffer, _replyText ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchExchangeBoundOk(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[ExchangeBoundOkBodyImpl: "); - buf.append( "replyCode=" ); - buf.append( getReplyCode() ); - buf.append( ", " ); - buf.append( "replyText=" ); - buf.append( getReplyText() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, - final ClientChannelMethodProcessor dispatcher) - throws IOException - { - - int replyCode = buffer.readUnsignedShort(); - AMQShortString replyText = buffer.readAMQShortString(); - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveExchangeBoundOk(replyCode, replyText); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ExchangeDeclareBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ExchangeDeclareBody.java deleted file mode 100644 index 4001ba7aa0..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ExchangeDeclareBody.java +++ /dev/null @@ -1,233 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class ExchangeDeclareBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 40; - public static final int METHOD_ID = 10; - - // Fields declared in specification - private final int _ticket; // [ticket] - private final AMQShortString _exchange; // [exchange] - private final AMQShortString _type; // [type] - private final byte _bitfield0; // [passive, durable, autoDelete, internal, nowait] - private final FieldTable _arguments; // [arguments] - - // Constructor - public ExchangeDeclareBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _ticket = buffer.readUnsignedShort(); - _exchange = buffer.readAMQShortString(); - _type = buffer.readAMQShortString(); - _bitfield0 = buffer.readByte(); - _arguments = EncodingUtils.readFieldTable(buffer); - } - - public ExchangeDeclareBody( - int ticket, - AMQShortString exchange, - AMQShortString type, - boolean passive, - boolean durable, - boolean autoDelete, - boolean internal, - boolean nowait, - FieldTable arguments - ) - { - _ticket = ticket; - _exchange = exchange; - _type = type; - byte bitfield0 = (byte)0; - if( passive ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 0)); - } - - if( durable ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 1)); - } - - if( autoDelete ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 2)); - } - - if( internal ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 3)); - } - - if( nowait ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 4)); - } - - _bitfield0 = bitfield0; - _arguments = arguments; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final int getTicket() - { - return _ticket; - } - public final AMQShortString getExchange() - { - return _exchange; - } - public final AMQShortString getType() - { - return _type; - } - public final boolean getPassive() - { - return (((int)(_bitfield0)) & ( 1 << 0)) != 0; - } - public final boolean getDurable() - { - return (((int)(_bitfield0)) & ( 1 << 1)) != 0; - } - public final boolean getAutoDelete() - { - return (((int)(_bitfield0)) & ( 1 << 2)) != 0; - } - public final boolean getInternal() - { - return (((int)(_bitfield0)) & ( 1 << 3)) != 0; - } - public final boolean getNowait() - { - return (((int)(_bitfield0)) & ( 1 << 4)) != 0; - } - public final FieldTable getArguments() - { - return _arguments; - } - - protected int getBodySize() - { - int size = 3; - size += getSizeOf( _exchange ); - size += getSizeOf( _type ); - size += getSizeOf( _arguments ); - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeUnsignedShort( buffer, _ticket ); - writeAMQShortString( buffer, _exchange ); - writeAMQShortString( buffer, _type ); - writeBitfield( buffer, _bitfield0 ); - writeFieldTable( buffer, _arguments ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchExchangeDeclare(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[ExchangeDeclareBodyImpl: "); - buf.append( "ticket=" ); - buf.append( getTicket() ); - buf.append( ", " ); - buf.append( "exchange=" ); - buf.append( getExchange() ); - buf.append( ", " ); - buf.append( "type=" ); - buf.append( getType() ); - buf.append( ", " ); - buf.append( "passive=" ); - buf.append( getPassive() ); - buf.append( ", " ); - buf.append( "durable=" ); - buf.append( getDurable() ); - buf.append( ", " ); - buf.append( "autoDelete=" ); - buf.append( getAutoDelete() ); - buf.append( ", " ); - buf.append( "internal=" ); - buf.append( getInternal() ); - buf.append( ", " ); - buf.append( "nowait=" ); - buf.append( getNowait() ); - buf.append( ", " ); - buf.append( "arguments=" ); - buf.append( getArguments() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, - final ServerChannelMethodProcessor dispatcher) throws IOException, AMQFrameDecodingException - { - - int ticket = buffer.readUnsignedShort(); - AMQShortString exchange = buffer.readAMQShortString(); - AMQShortString type = buffer.readAMQShortString(); - byte bitfield = buffer.readByte(); - boolean passive = (bitfield & 0x1) == 0x1; - boolean durable = (bitfield & 0x2) == 0x2; - boolean autoDelete = (bitfield & 0x4) == 0x4; - boolean internal = (bitfield & 0x8) == 0x8; - boolean nowait = (bitfield & 0x10) == 0x10; - FieldTable arguments = EncodingUtils.readFieldTable(buffer); - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveExchangeDeclare(exchange, - type, - passive, - durable, - autoDelete, - internal, - nowait, - arguments); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ExchangeDeclareOkBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ExchangeDeclareOkBody.java deleted file mode 100644 index 68b193cfb0..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ExchangeDeclareOkBody.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class ExchangeDeclareOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 40; - public static final int METHOD_ID = 11; - - // Fields declared in specification - - // Constructor - public ExchangeDeclareOkBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - } - - public ExchangeDeclareOkBody( - ) - { - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - - protected int getBodySize() - { - int size = 0; - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchExchangeDeclareOk(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[ExchangeDeclareOkBodyImpl: "); - buf.append("]"); - return buf.toString(); - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ExchangeDeleteBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ExchangeDeleteBody.java deleted file mode 100644 index f4646315cd..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ExchangeDeleteBody.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class ExchangeDeleteBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 40; - public static final int METHOD_ID = 20; - - // Fields declared in specification - private final int _ticket; // [ticket] - private final AMQShortString _exchange; // [exchange] - private final byte _bitfield0; // [ifUnused, nowait] - - // Constructor - public ExchangeDeleteBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _ticket = buffer.readUnsignedShort(); - _exchange = buffer.readAMQShortString(); - _bitfield0 = buffer.readByte(); - } - - public ExchangeDeleteBody( - int ticket, - AMQShortString exchange, - boolean ifUnused, - boolean nowait - ) - { - _ticket = ticket; - _exchange = exchange; - byte bitfield0 = (byte)0; - if( ifUnused ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 0)); - } - - if( nowait ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 1)); - } - _bitfield0 = bitfield0; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final int getTicket() - { - return _ticket; - } - public final AMQShortString getExchange() - { - return _exchange; - } - public final boolean getIfUnused() - { - return (((int)(_bitfield0)) & ( 1 << 0)) != 0; - } - public final boolean getNowait() - { - return (((int)(_bitfield0)) & ( 1 << 1)) != 0; - } - - protected int getBodySize() - { - int size = 3; - size += getSizeOf( _exchange ); - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeUnsignedShort( buffer, _ticket ); - writeAMQShortString( buffer, _exchange ); - writeBitfield( buffer, _bitfield0 ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchExchangeDelete(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[ExchangeDeleteBodyImpl: "); - buf.append( "ticket=" ); - buf.append( getTicket() ); - buf.append( ", " ); - buf.append( "exchange=" ); - buf.append( getExchange() ); - buf.append( ", " ); - buf.append( "ifUnused=" ); - buf.append( getIfUnused() ); - buf.append( ", " ); - buf.append( "nowait=" ); - buf.append( getNowait() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, - final ServerChannelMethodProcessor dispatcher) - throws IOException - { - - int ticket = buffer.readUnsignedShort(); - AMQShortString exchange = buffer.readAMQShortString(); - byte bitfield = buffer.readByte(); - boolean ifUnused = (bitfield & 0x01) == 0x01; - boolean nowait = (bitfield & 0x02) == 0x02; - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveExchangeDelete(exchange, ifUnused, nowait); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ExchangeDeleteOkBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ExchangeDeleteOkBody.java deleted file mode 100644 index 7af0b02ef0..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ExchangeDeleteOkBody.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class ExchangeDeleteOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 40; - public static final int METHOD_ID = 21; - - // Fields declared in specification - - // Constructor - public ExchangeDeleteOkBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - } - - public ExchangeDeleteOkBody( - ) - { - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - - protected int getBodySize() - { - int size = 0; - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchExchangeDeleteOk(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[ExchangeDeleteOkBodyImpl: "); - buf.append("]"); - return buf.toString(); - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ExtendedDataInput.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ExtendedDataInput.java deleted file mode 100644 index 04c1677892..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ExtendedDataInput.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.framing; - -import java.io.DataInput; - -public interface ExtendedDataInput extends DataInput -{ - AMQShortString readAMQShortString(); - - int available(); - - int position(); - - void position(int position); -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldArray.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldArray.java deleted file mode 100644 index d61d0e8385..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldArray.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.framing; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.math.BigDecimal; -import java.util.AbstractCollection; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Date; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -public class FieldArray extends AbstractCollection -{ - - private final Collection _underlying; - - private FieldArray(final Collection underlying) - { - _underlying = underlying; - } - - @Override - public Iterator iterator() - { - return _underlying.iterator(); - } - - @Override - public int size() - { - return _underlying.size(); - } - - public int getEncodingSize() - { - int size = 0; - for( T obj : this) - { - size += AMQTypedValue.toTypedValue(obj).getEncodingSize()+1; - } - return size; - } - - public static FieldArray asFieldArray(Collection collection) - { - if(collection instanceof FieldArray) - { - return (FieldArray) collection; - } - else - { - validateCollection(collection); - return new FieldArray<>(collection); - } - } - - private static final Set> SUPPORTED_CLASSES = new HashSet<>(Arrays.asList(Boolean.class, - Byte.class, - Short.class, - Character.class, - Integer.class, - Long.class, - Float.class, - Double.class, - String.class, - FieldTable.class, - Date.class, - BigDecimal.class, - byte[].class)); - - private static void validateCollection(final Collection collection) - { - for(T val : collection) - { - if(!(val == null || SUPPORTED_CLASSES.contains(val.getClass()) || val instanceof Collection || val instanceof Map)) - { - throw new IllegalArgumentException("Cannot convert an object of type " + val.getClass().getName()); - } - - } - } - - public void writeToBuffer(final DataOutput buffer) throws IOException - { - buffer.writeInt(getEncodingSize()); - for( T obj : this) - { - AMQTypedValue.toTypedValue(obj).writeToBuffer(buffer); - } - } - - public static FieldArray readFromBuffer(final DataInput buffer) throws IOException - { - ArrayList result = new ArrayList<>(); - int size = EncodingUtils.readInteger(buffer); - byte[] data = new byte[size]; - buffer.readFully(data); - ByteArrayDataInput slicedBuffer = new ByteArrayDataInput(data); - while(slicedBuffer.available() > 0) - { - result.add(AMQTypedValue.readFromBuffer(slicedBuffer).getValue()); - } - return new FieldArray<>(result); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java deleted file mode 100644 index 9a455ce868..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java +++ /dev/null @@ -1,1181 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.framing; - -import java.io.ByteArrayOutputStream; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.DataOutputStream; -import java.io.IOException; -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.apache.qpid.AMQPInvalidClassException; - -// extends FieldTable -public class FieldTable -{ - private static final Logger _logger = LoggerFactory.getLogger(FieldTable.class); - private static final String STRICT_AMQP_NAME = "STRICT_AMQP"; - private static final boolean STRICT_AMQP = Boolean.valueOf(System.getProperty(STRICT_AMQP_NAME, "false")); - - private byte[] _encodedForm; - private int _encodedFormOffset; - private LinkedHashMap _properties = null; - private long _encodedSize; - private static final int INITIAL_HASHMAP_CAPACITY = 16; - private static final int INITIAL_ENCODED_FORM_SIZE = 256; - private final boolean _strictAMQP; - - public FieldTable() - { - this(STRICT_AMQP); - } - - - public FieldTable(boolean strictAMQP) - { - super(); - _strictAMQP = strictAMQP; - } - - /** - * Construct a new field table. - * - * @param buffer the buffer from which to read data. The length byte must be read already - * @param length the length of the field table. Must be great than 0. - * @throws IOException if there is an issue reading the buffer - */ - public FieldTable(DataInput buffer, long length) throws IOException - { - this(); - _encodedForm = new byte[(int) length]; - buffer.readFully(_encodedForm); - _encodedSize = length; - } - - public FieldTable(byte[] encodedForm, int offset, int length) - { - this(); - _encodedForm = encodedForm; - _encodedFormOffset = offset; - _encodedSize = length; - } - - - public boolean isClean() - { - return _encodedForm != null; - } - - public AMQTypedValue getProperty(AMQShortString string) - { - checkPropertyName(string); - - synchronized (this) - { - if (_properties == null) - { - if (_encodedForm == null) - { - return null; - } - else - { - populateFromBuffer(); - } - } - } - - if (_properties == null) - { - return null; - } - else - { - return _properties.get(string); - } - } - - private void populateFromBuffer() - { - try - { - setFromBuffer(); - } - catch (AMQFrameDecodingException e) - { - _logger.error("Error decoding FieldTable in deferred decoding mode ", e); - throw new IllegalArgumentException(e); - } - catch (IOException e) - { - _logger.error("Unexpected IO exception decoding field table"); - throw new IllegalArgumentException(e); - - } - } - - private AMQTypedValue setProperty(AMQShortString key, AMQTypedValue val) - { - checkPropertyName(key); - initMapIfNecessary(); - if (_properties.containsKey(key)) - { - _encodedForm = null; - - if (val == null) - { - return removeKey(key); - } - } - else if ((_encodedForm != null) && (val != null)) - { - // We have updated data to store in the buffer - // So clear the _encodedForm to allow it to be rebuilt later - // this is safer than simply appending to any existing buffer. - _encodedForm = null; - } - else if (val == null) - { - return null; - } - - AMQTypedValue oldVal = _properties.put(key, val); - if (oldVal != null) - { - _encodedSize -= oldVal.getEncodingSize(); - } - else - { - _encodedSize += EncodingUtils.encodedShortStringLength(key) + 1; - } - - _encodedSize += val.getEncodingSize(); - - return oldVal; - } - - private void initMapIfNecessary() - { - synchronized (this) - { - if (_properties == null) - { - if ((_encodedForm == null) || (_encodedSize == 0)) - { - _properties = new LinkedHashMap(); - } - else - { - populateFromBuffer(); - } - } - - } - } - - public Boolean getBoolean(String string) - { - return getBoolean(AMQShortString.valueOf(string)); - } - - public Boolean getBoolean(AMQShortString string) - { - AMQTypedValue value = getProperty(string); - if ((value != null) && (value.getType() == AMQType.BOOLEAN)) - { - return (Boolean) value.getValue(); - } - else - { - return null; - } - } - - public Byte getByte(String string) - { - return getByte(AMQShortString.valueOf(string)); - } - - public Byte getByte(AMQShortString string) - { - AMQTypedValue value = getProperty(string); - if ((value != null) && (value.getType() == AMQType.BYTE)) - { - return (Byte) value.getValue(); - } - else - { - return null; - } - } - - public Short getShort(String string) - { - return getShort(AMQShortString.valueOf(string)); - } - - public Short getShort(AMQShortString string) - { - AMQTypedValue value = getProperty(string); - if ((value != null) && (value.getType() == AMQType.SHORT)) - { - return (Short) value.getValue(); - } - else - { - return null; - } - } - - public Integer getInteger(String string) - { - return getInteger(AMQShortString.valueOf(string)); - } - - public Integer getInteger(AMQShortString string) - { - AMQTypedValue value = getProperty(string); - if ((value != null) && (value.getType() == AMQType.INT)) - { - return (Integer) value.getValue(); - } - else - { - return null; - } - } - - public Long getLong(String string) - { - return getLong(AMQShortString.valueOf(string)); - } - - public Long getLong(AMQShortString string) - { - AMQTypedValue value = getProperty(string); - if ((value != null) && (value.getType() == AMQType.LONG)) - { - return (Long) value.getValue(); - } - else - { - return null; - } - } - - public Float getFloat(String string) - { - return getFloat(AMQShortString.valueOf(string)); - } - - public Float getFloat(AMQShortString string) - { - AMQTypedValue value = getProperty(string); - if ((value != null) && (value.getType() == AMQType.FLOAT)) - { - return (Float) value.getValue(); - } - else - { - return null; - } - } - - public Double getDouble(String string) - { - return getDouble(AMQShortString.valueOf(string)); - } - - public Double getDouble(AMQShortString string) - { - AMQTypedValue value = getProperty(string); - if ((value != null) && (value.getType() == AMQType.DOUBLE)) - { - return (Double) value.getValue(); - } - else - { - return null; - } - } - - public String getString(String string) - { - return getString(AMQShortString.valueOf(string)); - } - - public String getString(AMQShortString string) - { - AMQTypedValue value = getProperty(string); - if ((value != null) && ((value.getType() == AMQType.WIDE_STRING) || (value.getType() == AMQType.ASCII_STRING))) - { - return (String) value.getValue(); - } - else if ((value != null) && (value.getValue() != null) && !(value.getValue() instanceof byte[])) - { - return String.valueOf(value.getValue()); - } - else - { - return null; - } - - } - - public Character getCharacter(String string) - { - return getCharacter(AMQShortString.valueOf(string)); - } - - public Character getCharacter(AMQShortString string) - { - AMQTypedValue value = getProperty(string); - if ((value != null) && (value.getType() == AMQType.ASCII_CHARACTER)) - { - return (Character) value.getValue(); - } - else - { - return null; - } - } - - public byte[] getBytes(String string) - { - return getBytes(AMQShortString.valueOf(string)); - } - - public byte[] getBytes(AMQShortString string) - { - AMQTypedValue value = getProperty(string); - if ((value != null) && (value.getType() == AMQType.BINARY)) - { - return (byte[]) value.getValue(); - } - else - { - return null; - } - } - - /** - * Extracts a value from the field table that is itself a FieldTable associated with the specified parameter name. - * - * @param string The name of the parameter to get the associated FieldTable value for. - * - * @return The associated FieldTable value, or null if the associated value is not of FieldTable type or - * not present in the field table at all. - */ - public FieldTable getFieldTable(String string) - { - return getFieldTable(AMQShortString.valueOf(string)); - } - - /** - * Extracts a value from the field table that is itself a FieldTable associated with the specified parameter name. - * - * @param string The name of the parameter to get the associated FieldTable value for. - * - * @return The associated FieldTable value, or null if the associated value is not of FieldTable type or - * not present in the field table at all. - */ - public FieldTable getFieldTable(AMQShortString string) - { - AMQTypedValue value = getProperty(string); - - if ((value != null) && (value.getType() == AMQType.FIELD_TABLE)) - { - return (FieldTable) value.getValue(); - } - else - { - return null; - } - } - - public Object getObject(String string) - { - return getObject(AMQShortString.valueOf(string)); - } - - public Object getObject(AMQShortString string) - { - AMQTypedValue value = getProperty(string); - if (value != null) - { - return value.getValue(); - } - else - { - return value; - } - - } - - public Long getTimestamp(AMQShortString name) - { - AMQTypedValue value = getProperty(name); - if ((value != null) && (value.getType() == AMQType.TIMESTAMP)) - { - return (Long) value.getValue(); - } - else - { - return null; - } - } - - public BigDecimal getDecimal(AMQShortString propertyName) - { - AMQTypedValue value = getProperty(propertyName); - if ((value != null) && (value.getType() == AMQType.DECIMAL)) - { - return (BigDecimal) value.getValue(); - } - else - { - return null; - } - } - - // ************ Setters - public Object setBoolean(String string, Boolean b) - { - return setBoolean(AMQShortString.valueOf(string), b); - } - - public Object setBoolean(AMQShortString string, Boolean b) - { - return setProperty(string, AMQType.BOOLEAN.asTypedValue(b)); - } - - public Object setByte(String string, Byte b) - { - return setByte(AMQShortString.valueOf(string), b); - } - - public Object setByte(AMQShortString string, Byte b) - { - return setProperty(string, AMQType.BYTE.asTypedValue(b)); - } - - public Object setShort(String string, Short i) - { - return setShort(AMQShortString.valueOf(string), i); - } - - public Object setShort(AMQShortString string, Short i) - { - return setProperty(string, AMQType.SHORT.asTypedValue(i)); - } - - public Object setInteger(String string, int i) - { - return setInteger(AMQShortString.valueOf(string), i); - } - - public Object setInteger(AMQShortString string, int i) - { - return setProperty(string, AMQTypedValue.createAMQTypedValue(i)); - } - - public Object setLong(String string, long l) - { - return setLong(AMQShortString.valueOf(string), l); - } - - public Object setLong(AMQShortString string, long l) - { - return setProperty(string, AMQTypedValue.createAMQTypedValue(l)); - } - - public Object setFloat(String string, Float f) - { - return setFloat(AMQShortString.valueOf(string), f); - } - - public Object setFloat(AMQShortString string, Float v) - { - return setProperty(string, AMQType.FLOAT.asTypedValue(v)); - } - - public Object setDouble(String string, Double d) - { - return setDouble(AMQShortString.valueOf(string), d); - } - - public Object setDouble(AMQShortString string, Double v) - { - return setProperty(string, AMQType.DOUBLE.asTypedValue(v)); - } - - public Object setString(String string, String s) - { - return setString(AMQShortString.valueOf(string), s); - } - - public Object setAsciiString(AMQShortString string, String value) - { - if (value == null) - { - return setProperty(string, AMQType.VOID.asTypedValue(null)); - } - else - { - return setProperty(string, AMQType.ASCII_STRING.asTypedValue(value)); - } - } - - public Object setString(AMQShortString string, String value) - { - if (value == null) - { - return setProperty(string, AMQType.VOID.asTypedValue(null)); - } - else - { - return setProperty(string, AMQType.LONG_STRING.asTypedValue(value)); - } - } - - public Object setChar(String string, char c) - { - return setChar(AMQShortString.valueOf(string), c); - } - - public Object setChar(AMQShortString string, char c) - { - return setProperty(string, AMQType.ASCII_CHARACTER.asTypedValue(c)); - } - - public Object setFieldArray(String string, Collection collection) - { - return setFieldArray(AMQShortString.valueOf(string), collection); - } - public Object setFieldArray(AMQShortString string, Collection collection) - { - return setProperty(string, AMQType.FIELD_ARRAY.asTypedValue(collection)); - } - - public Object setBytes(String string, byte[] b) - { - return setBytes(AMQShortString.valueOf(string), b); - } - - public Object setBytes(AMQShortString string, byte[] bytes) - { - return setProperty(string, AMQType.BINARY.asTypedValue(bytes)); - } - - public Object setBytes(String string, byte[] bytes, int start, int length) - { - return setBytes(AMQShortString.valueOf(string), bytes, start, length); - } - - public Object setBytes(AMQShortString string, byte[] bytes, int start, int length) - { - byte[] newBytes = new byte[length]; - System.arraycopy(bytes, start, newBytes, 0, length); - - return setBytes(string, bytes); - } - - public Object setObject(String string, Object o) - { - return setObject(AMQShortString.valueOf(string), o); - } - - public Object setTimestamp(AMQShortString string, long datetime) - { - return setProperty(string, AMQType.TIMESTAMP.asTypedValue(datetime)); - } - - public Object setDecimal(AMQShortString string, BigDecimal decimal) - { - if (decimal.longValue() > Integer.MAX_VALUE) - { - throw new UnsupportedOperationException("AMQP does not support decimals larger than " + Integer.MAX_VALUE); - } - - if (decimal.scale() > Byte.MAX_VALUE) - { - throw new UnsupportedOperationException("AMQP does not support decimal scales larger than " + Byte.MAX_VALUE); - } - - return setProperty(string, AMQType.DECIMAL.asTypedValue(decimal)); - } - - public Object setVoid(AMQShortString string) - { - return setProperty(string, AMQType.VOID.asTypedValue(null)); - } - - /** - * Associates a nested field table with the specified parameter name. - * - * @param string The name of the parameter to store in the table. - * @param ftValue The field table value to associate with the parameter name. - * - * @return The stored value. - */ - public Object setFieldTable(String string, FieldTable ftValue) - { - return setFieldTable(AMQShortString.valueOf(string), ftValue); - } - - /** - * Associates a nested field table with the specified parameter name. - * - * @param string The name of the parameter to store in the table. - * @param ftValue The field table value to associate with the parameter name. - * - * @return The stored value. - */ - public Object setFieldTable(AMQShortString string, FieldTable ftValue) - { - return setProperty(string, AMQType.FIELD_TABLE.asTypedValue(ftValue)); - } - - public Object setObject(AMQShortString string, Object object) - { - if (object instanceof Boolean) - { - return setBoolean(string, (Boolean) object); - } - else if (object instanceof Byte) - { - return setByte(string, (Byte) object); - } - else if (object instanceof Short) - { - return setShort(string, (Short) object); - } - else if (object instanceof Integer) - { - return setInteger(string, (Integer) object); - } - else if (object instanceof Long) - { - return setLong(string, (Long) object); - } - else if (object instanceof Float) - { - return setFloat(string, (Float) object); - } - else if (object instanceof Double) - { - return setDouble(string, (Double) object); - } - else if (object instanceof String) - { - return setString(string, (String) object); - } - else if (object instanceof Character) - { - return setChar(string, (Character) object); - } - else if (object instanceof Collection) - { - return setFieldArray(string, (Collection)object); - } - else if (object instanceof FieldTable) - { - return setFieldTable(string, (FieldTable) object); - } - else if (object instanceof Map) - { - return setFieldTable(string, FieldTable.convertToFieldTable((Map) object)); - } - else if (object instanceof Date) - { - return setTimestamp(string, ((Date) object).getTime()); - } - else if (object instanceof BigDecimal) - { - return setDecimal(string, (BigDecimal) object); - } - else if (object instanceof byte[]) - { - return setBytes(string, (byte[]) object); - } - - throw new AMQPInvalidClassException(AMQPInvalidClassException.INVALID_OBJECT_MSG + (object == null ? "null" : object.getClass())); - } - - public boolean isNullStringValue(String name) - { - AMQTypedValue value = getProperty(AMQShortString.valueOf(name)); - - return (value != null) && (value.getType() == AMQType.VOID); - } - - // ***** Methods - - public Enumeration getPropertyNames() - { - return Collections.enumeration(keys()); - } - - public boolean propertyExists(AMQShortString propertyName) - { - return itemExists(propertyName); - } - - public boolean propertyExists(String propertyName) - { - return itemExists(propertyName); - } - - public boolean itemExists(AMQShortString propertyName) - { - checkPropertyName(propertyName); - initMapIfNecessary(); - - return _properties.containsKey(propertyName); - } - - public boolean itemExists(String string) - { - return itemExists(AMQShortString.valueOf(string)); - } - - public String toString() - { - initMapIfNecessary(); - - return _properties.toString(); - } - - private void checkPropertyName(AMQShortString propertyName) - { - if (propertyName == null) - { - throw new IllegalArgumentException("Property name must not be null"); - } - else if (propertyName.length() == 0) - { - throw new IllegalArgumentException("Property name must not be the empty string"); - } - - if (_strictAMQP) - { - checkIdentiferFormat(propertyName); - } - } - - protected static void checkIdentiferFormat(AMQShortString propertyName) - { - // AMQP Spec: 4.2.5.5 Field Tables - // Guidelines for implementers: - // * Field names MUST start with a letter, '$' or '#' and may continue with - // letters, '$' or '#', digits, or underlines, to a maximum length of 128 - // characters. - // * The server SHOULD validate field names and upon receiving an invalid - // field name, it SHOULD signal a connection exception with reply code - // 503 (syntax error). Conformance test: amq_wlp_table_01. - // * A peer MUST handle duplicate fields by using only the first instance. - - // AMQP length limit - if (propertyName.length() > 128) - { - throw new IllegalArgumentException("AMQP limits property names to 128 characters"); - } - - // AMQ start character - if (!(Character.isLetter(propertyName.charAt(0)) || (propertyName.charAt(0) == '$') - || (propertyName.charAt(0) == '#') || (propertyName.charAt(0) == '_'))) // Not official AMQP added for JMS. - { - throw new IllegalArgumentException("Identifier '" + propertyName - + "' does not start with a valid AMQP start character"); - } - } - - // ************************* Byte Buffer Processing - - public void writeToBuffer(DataOutput buffer) throws IOException - { - final boolean trace = _logger.isDebugEnabled(); - - if (trace) - { - _logger.debug("FieldTable::writeToBuffer: Writing encoded length of " + getEncodedSize() + "..."); - if (_properties != null) - { - _logger.debug(_properties.toString()); - } - } - - EncodingUtils.writeUnsignedInteger(buffer, getEncodedSize()); - - putDataInBuffer(buffer); - } - - public byte[] getDataAsBytes() - { - if(_encodedForm == null) - { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - try - { - putDataInBuffer(new DataOutputStream(baos)); - return baos.toByteArray(); - } - catch (IOException e) - { - throw new IllegalArgumentException("IO Exception should never be thrown here"); - } - - } - else if(_encodedFormOffset == 0 && _encodedSize == _encodedForm.length) - { - return _encodedForm.clone(); - } - else - { - byte[] encodedCopy = new byte[(int) _encodedSize]; - System.arraycopy(_encodedForm,_encodedFormOffset,encodedCopy,0,(int)_encodedSize); - return encodedCopy; - } - - } - - public long getEncodedSize() - { - return _encodedSize; - } - - private void recalculateEncodedSize() - { - - int encodedSize = 0; - if (_properties != null) - { - for (Map.Entry e : _properties.entrySet()) - { - encodedSize += EncodingUtils.encodedShortStringLength(e.getKey()); - encodedSize++; // the byte for the encoding Type - encodedSize += e.getValue().getEncodingSize(); - - } - } - - _encodedSize = encodedSize; - } - - public void addAll(FieldTable fieldTable) - { - initMapIfNecessary(); - fieldTable.initMapIfNecessary(); - if (fieldTable._properties != null) - { - _encodedForm = null; - _properties.putAll(fieldTable._properties); - recalculateEncodedSize(); - } - } - - public static Map convertToMap(final FieldTable fieldTable) - { - final Map map = new HashMap(); - - if(fieldTable != null) - { - fieldTable.processOverElements( - new FieldTableElementProcessor() - { - - public boolean processElement(String propertyName, AMQTypedValue value) - { - Object val = value.getValue(); - if(val instanceof AMQShortString) - { - val = val.toString(); - } - map.put(propertyName, val); - return true; - } - - public Object getResult() - { - return map; - } - }); - } - return map; - } - - - public static interface FieldTableElementProcessor - { - public boolean processElement(String propertyName, AMQTypedValue value); - - public Object getResult(); - } - - public Object processOverElements(FieldTableElementProcessor processor) - { - initMapIfNecessary(); - if (_properties != null) - { - for (Map.Entry e : _properties.entrySet()) - { - boolean result = processor.processElement(e.getKey().toString(), e.getValue()); - if (!result) - { - break; - } - } - } - - return processor.getResult(); - - } - - public int size() - { - initMapIfNecessary(); - - return _properties.size(); - - } - - public boolean isEmpty() - { - return size() == 0; - } - - public boolean containsKey(AMQShortString key) - { - initMapIfNecessary(); - - return _properties.containsKey(key); - } - - public boolean containsKey(String key) - { - return containsKey(AMQShortString.valueOf(key)); - } - - public Set keys() - { - initMapIfNecessary(); - Set keys = new LinkedHashSet(); - for (AMQShortString key : _properties.keySet()) - { - keys.add(key.toString()); - } - - return keys; - } - - public Iterator> iterator() - { - initMapIfNecessary(); - return _properties.entrySet().iterator(); - } - - public Object get(String key) - { - return get(AMQShortString.valueOf(key)); - } - - public Object get(AMQShortString key) - { - return getObject(key); - } - - public Object put(AMQShortString key, Object value) - { - return setObject(key, value); - } - - public Object remove(String key) - { - - return remove(AMQShortString.valueOf(key)); - - } - - public Object remove(AMQShortString key) - { - AMQTypedValue val = removeKey(key); - - return (val == null) ? null : val.getValue(); - - } - - public AMQTypedValue removeKey(AMQShortString key) - { - initMapIfNecessary(); - _encodedForm = null; - AMQTypedValue value = _properties.remove(key); - if (value == null) - { - return null; - } - else - { - _encodedSize -= EncodingUtils.encodedShortStringLength(key); - _encodedSize--; - _encodedSize -= value.getEncodingSize(); - - return value; - } - - } - - public void clear() - { - initMapIfNecessary(); - _encodedForm = null; - _properties.clear(); - _encodedSize = 0; - } - - public Set keySet() - { - initMapIfNecessary(); - - return _properties.keySet(); - } - - private void putDataInBuffer(DataOutput buffer) throws IOException - { - - if (_encodedForm != null) - { - buffer.write(_encodedForm,_encodedFormOffset,(int)_encodedSize); - } - else if (_properties != null) - { - final Iterator> it = _properties.entrySet().iterator(); - - // If there are values then write out the encoded Size... could check _encodedSize != 0 - // write out the total length, which we have kept up to date as data is added - - while (it.hasNext()) - { - final Map.Entry me = it.next(); - try - { - // Write the actual parameter name - EncodingUtils.writeShortStringBytes(buffer, me.getKey()); - me.getValue().writeToBuffer(buffer); - } - catch (Exception e) - { - throw new RuntimeException(e); - } - } - } - } - - private void setFromBuffer() throws AMQFrameDecodingException, IOException - { - - ByteArrayDataInput baid = new ByteArrayDataInput(_encodedForm, _encodedFormOffset, (int)_encodedSize); - - if (_encodedSize > 0) - { - - - _properties = new LinkedHashMap(INITIAL_HASHMAP_CAPACITY); - - do - { - - final AMQShortString key = baid.readAMQShortString(); - AMQTypedValue value = AMQTypedValue.readFromBuffer(baid); - _properties.put(key, value); - - } - while (baid.available() > 0); - - } - - } - - public int hashCode() - { - initMapIfNecessary(); - - return _properties.hashCode(); - } - - public boolean equals(Object o) - { - if (o == this) - { - return true; - } - - if (o == null) - { - return false; - } - - if (!(o instanceof FieldTable)) - { - return false; - } - - initMapIfNecessary(); - - FieldTable f = (FieldTable) o; - f.initMapIfNecessary(); - - return _properties.equals(f._properties); - } - - public static FieldTable convertToFieldTable(Map map) - { - if (map != null) - { - FieldTable table = new FieldTable(); - for(Map.Entry entry : map.entrySet()) - { - table.put(AMQShortString.valueOf(entry.getKey()), entry.getValue()); - } - - return table; - } - else - { - return null; - } - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTableFactory.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTableFactory.java deleted file mode 100644 index a2d4d27396..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTableFactory.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - * - */ -package org.apache.qpid.framing; - -import java.io.DataInput; -import java.io.IOException; - -public class FieldTableFactory -{ - private FieldTableFactory() - { - } - - public static FieldTable newFieldTable() - { - return new FieldTable(); - } - - public static FieldTable newFieldTable(DataInput byteBuffer, long length) throws AMQFrameDecodingException, IOException - { - return new FieldTable(byteBuffer, length); - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/FrameCreatingMethodProcessor.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/FrameCreatingMethodProcessor.java deleted file mode 100644 index 0d160a73d5..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/FrameCreatingMethodProcessor.java +++ /dev/null @@ -1,629 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.framing; - -import java.util.ArrayList; -import java.util.List; - -public class FrameCreatingMethodProcessor implements MethodProcessor, - ClientMethodProcessor, - ServerMethodProcessor -{ - private ProtocolVersion _protocolVersion; - - private final List _processedMethods = new ArrayList<>(); - private int _classId; - private int _methodId; - - public FrameCreatingMethodProcessor(final ProtocolVersion protocolVersion) - { - _protocolVersion = protocolVersion; - } - - public List getProcessedMethods() - { - return _processedMethods; - } - - @Override - public void receiveConnectionStart(final short versionMajor, - final short versionMinor, - final FieldTable serverProperties, - final byte[] mechanisms, - final byte[] locales) - { - _processedMethods.add(new AMQFrame(0, new ConnectionStartBody(versionMajor, versionMinor, serverProperties, mechanisms, locales))); - } - - @Override - public void receiveConnectionStartOk(final FieldTable clientProperties, - final AMQShortString mechanism, - final byte[] response, - final AMQShortString locale) - { - _processedMethods.add(new AMQFrame(0, new ConnectionStartOkBody(clientProperties, mechanism, response, locale))); - } - - @Override - public void receiveConnectionSecure(final byte[] challenge) - { - _processedMethods.add(new AMQFrame(0, new ConnectionSecureBody(challenge))); - } - - @Override - public void receiveConnectionSecureOk(final byte[] response) - { - _processedMethods.add(new AMQFrame(0, new ConnectionSecureOkBody(response))); - } - - @Override - public void receiveConnectionTune(final int channelMax, final long frameMax, final int heartbeat) - { - _processedMethods.add(new AMQFrame(0, new ConnectionTuneBody(channelMax, frameMax, heartbeat))); - } - - @Override - public void receiveConnectionTuneOk(final int channelMax, final long frameMax, final int heartbeat) - { - _processedMethods.add(new AMQFrame(0, new ConnectionTuneOkBody(channelMax, frameMax, heartbeat))); - } - - @Override - public void receiveConnectionOpen(final AMQShortString virtualHost, - final AMQShortString capabilities, - final boolean insist) - { - _processedMethods.add(new AMQFrame(0, new ConnectionOpenBody(virtualHost, capabilities, insist))); - } - - @Override - public void receiveConnectionOpenOk(final AMQShortString knownHosts) - { - _processedMethods.add(new AMQFrame(0, new ConnectionOpenOkBody(knownHosts))); - } - - @Override - public void receiveConnectionRedirect(final AMQShortString host, final AMQShortString knownHosts) - { - _processedMethods.add(new AMQFrame(0, new ConnectionRedirectBody(getProtocolVersion(), host, knownHosts))); - } - - @Override - public void receiveConnectionClose(final int replyCode, - final AMQShortString replyText, - final int classId, - final int methodId) - { - _processedMethods.add(new AMQFrame(0, new ConnectionCloseBody(getProtocolVersion(), replyCode, replyText, classId, methodId))); - } - - @Override - public void receiveConnectionCloseOk() - { - _processedMethods.add(new AMQFrame(0, ProtocolVersion.v8_0.equals(getProtocolVersion()) - ? ConnectionCloseOkBody.CONNECTION_CLOSE_OK_0_8 - : ConnectionCloseOkBody.CONNECTION_CLOSE_OK_0_9)); - } - - @Override - public void receiveChannelOpen(final int channelId) - { - _processedMethods.add(new AMQFrame(channelId, new ChannelOpenBody())); - } - - private void receiveExchangeBoundOk(final int channelId, final int replyCode, final AMQShortString replyText) - { - _processedMethods.add(new AMQFrame(channelId, new ExchangeBoundOkBody(replyCode, replyText))); - } - - @Override - public void receiveHeartbeat() - { - _processedMethods.add(new AMQFrame(0, new HeartbeatBody())); - } - - @Override - public ProtocolVersion getProtocolVersion() - { - return _protocolVersion; - } - - @Override - public ClientAndServerChannelMethodProcessor getChannelMethodProcessor(final int channelId) - { - return new FrameCreatingChannelMethodProcessor(channelId); - } - - public void setProtocolVersion(final ProtocolVersion protocolVersion) - { - _protocolVersion = protocolVersion; - } - - @Override - public void receiveProtocolHeader(final ProtocolInitiation protocolInitiation) - { - _processedMethods.add(protocolInitiation); - } - - @Override - public void setCurrentMethod(final int classId, final int methodId) - { - _classId = classId; - _methodId = methodId; - } - - @Override - public boolean ignoreAllButCloseOk() - { - return false; - } - - public int getClassId() - { - return _classId; - } - - public int getMethodId() - { - return _methodId; - } - - public static interface ClientAndServerChannelMethodProcessor extends ServerChannelMethodProcessor, ClientChannelMethodProcessor - { - - } - - private class FrameCreatingChannelMethodProcessor implements ClientAndServerChannelMethodProcessor - { - private final int _channelId; - - private FrameCreatingChannelMethodProcessor(final int channelId) - { - _channelId = channelId; - } - - - @Override - public void receiveChannelOpenOk() - { - _processedMethods.add(new AMQFrame(_channelId, ProtocolVersion.v8_0.equals(getProtocolVersion()) - ? ChannelOpenOkBody.INSTANCE_0_8 - : ChannelOpenOkBody.INSTANCE_0_9)); - } - - @Override - public void receiveChannelAlert(final int replyCode, final AMQShortString replyText, final FieldTable details) - { - _processedMethods.add(new AMQFrame(_channelId, new ChannelAlertBody(replyCode, replyText, details))); - } - - @Override - public void receiveAccessRequestOk(final int ticket) - { - _processedMethods.add(new AMQFrame(_channelId, new AccessRequestOkBody(ticket))); - } - - @Override - public void receiveExchangeDeclareOk() - { - _processedMethods.add(new AMQFrame(_channelId, new ExchangeDeclareOkBody())); - } - - @Override - public void receiveExchangeDeleteOk() - { - _processedMethods.add(new AMQFrame(_channelId, new ExchangeDeleteOkBody())); - } - - @Override - public void receiveExchangeBoundOk(final int replyCode, final AMQShortString replyText) - { - FrameCreatingMethodProcessor.this.receiveExchangeBoundOk(_channelId, replyCode, replyText); - } - - @Override - public void receiveQueueBindOk() - { - _processedMethods.add(new AMQFrame(_channelId, new QueueBindOkBody())); - } - - @Override - public void receiveQueueUnbindOk() - { - _processedMethods.add(new AMQFrame(_channelId, new QueueUnbindOkBody())); - } - - @Override - public void receiveQueueDeclareOk(final AMQShortString queue, final long messageCount, final long consumerCount) - { - _processedMethods.add(new AMQFrame(_channelId, new QueueDeclareOkBody(queue, messageCount, consumerCount))); - } - - @Override - public void receiveQueuePurgeOk(final long messageCount) - { - _processedMethods.add(new AMQFrame(_channelId, new QueuePurgeOkBody(messageCount))); - } - - @Override - public void receiveQueueDeleteOk(final long messageCount) - { - _processedMethods.add(new AMQFrame(_channelId, new QueueDeleteOkBody(messageCount))); - } - - @Override - public void receiveBasicRecoverSyncOk() - { - _processedMethods.add(new AMQFrame(_channelId, new BasicRecoverSyncOkBody(getProtocolVersion()))); - } - - @Override - public void receiveBasicQosOk() - { - _processedMethods.add(new AMQFrame(_channelId, new BasicQosOkBody())); - } - - @Override - public void receiveBasicConsumeOk(final AMQShortString consumerTag) - { - _processedMethods.add(new AMQFrame(_channelId, new BasicConsumeOkBody(consumerTag))); - } - - @Override - public void receiveBasicCancelOk(final AMQShortString consumerTag) - { - _processedMethods.add(new AMQFrame(_channelId, new BasicCancelOkBody(consumerTag))); - } - - @Override - public void receiveBasicReturn(final int replyCode, - final AMQShortString replyText, - final AMQShortString exchange, - final AMQShortString routingKey) - { - _processedMethods.add(new AMQFrame(_channelId, new BasicReturnBody(replyCode, - replyText, - exchange, - routingKey))); - } - - @Override - public void receiveBasicDeliver(final AMQShortString consumerTag, - final long deliveryTag, - final boolean redelivered, - final AMQShortString exchange, - final AMQShortString routingKey) - { - _processedMethods.add(new AMQFrame(_channelId, new BasicDeliverBody(consumerTag, - deliveryTag, - redelivered, - exchange, - routingKey))); - } - - @Override - public void receiveBasicGetOk(final long deliveryTag, - final boolean redelivered, - final AMQShortString exchange, - final AMQShortString routingKey, - final long messageCount) - { - _processedMethods.add(new AMQFrame(_channelId, new BasicGetOkBody(deliveryTag, - redelivered, - exchange, - routingKey, - messageCount))); - } - - @Override - public void receiveBasicGetEmpty() - { - _processedMethods.add(new AMQFrame(_channelId, new BasicGetEmptyBody((AMQShortString)null))); - } - - @Override - public void receiveTxSelectOk() - { - _processedMethods.add(new AMQFrame(_channelId, TxSelectOkBody.INSTANCE)); - } - - @Override - public void receiveTxCommitOk() - { - _processedMethods.add(new AMQFrame(_channelId, TxCommitOkBody.INSTANCE)); - } - - @Override - public void receiveTxRollbackOk() - { - _processedMethods.add(new AMQFrame(_channelId, TxRollbackOkBody.INSTANCE)); - } - - @Override - public void receiveConfirmSelectOk() - { - _processedMethods.add(new AMQFrame(_channelId, ConfirmSelectOkBody.INSTANCE)); - } - - @Override - public void receiveAccessRequest(final AMQShortString realm, - final boolean exclusive, - final boolean passive, - final boolean active, - final boolean write, - final boolean read) - { - _processedMethods.add(new AMQFrame(_channelId, new AccessRequestBody(realm, - exclusive, - passive, - active, - write, - read))); - } - - @Override - public void receiveExchangeDeclare(final AMQShortString exchange, - final AMQShortString type, - final boolean passive, - final boolean durable, - final boolean autoDelete, - final boolean internal, - final boolean nowait, - final FieldTable arguments) - { - _processedMethods.add(new AMQFrame(_channelId, new ExchangeDeclareBody(0, - exchange, - type, - passive, - durable, - autoDelete, - internal, - nowait, - arguments))); - } - - @Override - public void receiveExchangeDelete(final AMQShortString exchange, final boolean ifUnused, final boolean nowait) - { - _processedMethods.add(new AMQFrame(_channelId, new ExchangeDeleteBody(0, exchange, ifUnused, nowait))); - } - - @Override - public void receiveExchangeBound(final AMQShortString exchange, - final AMQShortString routingKey, - final AMQShortString queue) - { - _processedMethods.add(new AMQFrame(_channelId, new ExchangeBoundBody(exchange, routingKey, queue))); - } - - @Override - public void receiveQueueDeclare(final AMQShortString queue, - final boolean passive, - final boolean durable, - final boolean exclusive, - final boolean autoDelete, - final boolean nowait, - final FieldTable arguments) - { - _processedMethods.add(new AMQFrame(_channelId, new QueueDeclareBody(0, - queue, - passive, - durable, - exclusive, - autoDelete, - nowait, - arguments))); - } - - @Override - public void receiveQueueBind(final AMQShortString queue, - final AMQShortString exchange, - final AMQShortString bindingKey, - final boolean nowait, - final FieldTable arguments) - { - _processedMethods.add(new AMQFrame(_channelId, new QueueBindBody(0, - queue, - exchange, - bindingKey, - nowait, - arguments))); - } - - @Override - public void receiveQueuePurge(final AMQShortString queue, final boolean nowait) - { - _processedMethods.add(new AMQFrame(_channelId, new QueuePurgeBody(0, queue, nowait))); - } - - @Override - public void receiveQueueDelete(final AMQShortString queue, - final boolean ifUnused, - final boolean ifEmpty, - final boolean nowait) - { - _processedMethods.add(new AMQFrame(_channelId, new QueueDeleteBody(0, queue, ifUnused, ifEmpty, nowait))); - } - - @Override - public void receiveQueueUnbind(final AMQShortString queue, - final AMQShortString exchange, - final AMQShortString bindingKey, - final FieldTable arguments) - { - _processedMethods.add(new AMQFrame(_channelId, new QueueUnbindBody(0, - queue, - exchange, - bindingKey, - arguments))); - } - - @Override - public void receiveBasicRecover(final boolean requeue, final boolean sync) - { - if(ProtocolVersion.v8_0.equals(getProtocolVersion()) || !sync) - { - _processedMethods.add(new AMQFrame(_channelId, new BasicRecoverBody(requeue))); - } - else - { - _processedMethods.add(new AMQFrame(_channelId, new BasicRecoverSyncBody(getProtocolVersion(), requeue))); - } - } - - @Override - public void receiveBasicQos(final long prefetchSize, final int prefetchCount, final boolean global) - { - _processedMethods.add(new AMQFrame(_channelId, new BasicQosBody(prefetchSize, prefetchCount, global))); - } - - @Override - public void receiveBasicConsume(final AMQShortString queue, - final AMQShortString consumerTag, - final boolean noLocal, - final boolean noAck, - final boolean exclusive, - final boolean nowait, - final FieldTable arguments) - { - _processedMethods.add(new AMQFrame(_channelId, new BasicConsumeBody(0, - queue, - consumerTag, - noLocal, - noAck, - exclusive, - nowait, - arguments))); - } - - @Override - public void receiveBasicCancel(final AMQShortString consumerTag, final boolean noWait) - { - _processedMethods.add(new AMQFrame(_channelId, new BasicCancelBody(consumerTag, noWait))); - } - - @Override - public void receiveBasicPublish(final AMQShortString exchange, - final AMQShortString routingKey, - final boolean mandatory, - final boolean immediate) - { - _processedMethods.add(new AMQFrame(_channelId, new BasicPublishBody(0, - exchange, - routingKey, - mandatory, - immediate))); - } - - @Override - public void receiveBasicGet(final AMQShortString queue, final boolean noAck) - { - _processedMethods.add(new AMQFrame(_channelId, new BasicGetBody(0, queue, noAck))); - } - - @Override - public void receiveBasicAck(final long deliveryTag, final boolean multiple) - { - _processedMethods.add(new AMQFrame(_channelId, new BasicAckBody(deliveryTag, multiple))); - } - - @Override - public void receiveBasicReject(final long deliveryTag, final boolean requeue) - { - _processedMethods.add(new AMQFrame(_channelId, new BasicRejectBody(deliveryTag, requeue))); - } - - @Override - public void receiveTxSelect() - { - _processedMethods.add(new AMQFrame(_channelId, TxSelectBody.INSTANCE)); - } - - @Override - public void receiveTxCommit() - { - _processedMethods.add(new AMQFrame(_channelId, TxCommitBody.INSTANCE)); - } - - @Override - public void receiveTxRollback() - { - _processedMethods.add(new AMQFrame(_channelId, TxRollbackBody.INSTANCE)); - } - - @Override - public void receiveConfirmSelect(final boolean nowait) - { - _processedMethods.add(new AMQFrame(_channelId, new ConfirmSelectBody(nowait))); - } - - @Override - public void receiveChannelFlow(final boolean active) - { - _processedMethods.add(new AMQFrame(_channelId, new ChannelFlowBody(active))); - } - - @Override - public void receiveChannelFlowOk(final boolean active) - { - _processedMethods.add(new AMQFrame(_channelId, new ChannelFlowOkBody(active))); - } - - @Override - public void receiveChannelClose(final int replyCode, - final AMQShortString replyText, - final int classId, - final int methodId) - { - _processedMethods.add(new AMQFrame(_channelId, new ChannelCloseBody(replyCode, replyText, classId, methodId))); - } - - @Override - public void receiveChannelCloseOk() - { - _processedMethods.add(new AMQFrame(_channelId, ChannelCloseOkBody.INSTANCE)); - } - - @Override - public void receiveMessageContent(final byte[] data) - { - _processedMethods.add(new AMQFrame(_channelId, new ContentBody(data))); - } - - @Override - public void receiveMessageHeader(final BasicContentHeaderProperties properties, final long bodySize) - { - _processedMethods.add(new AMQFrame(_channelId, new ContentHeaderBody(properties, bodySize))); - } - - @Override - public boolean ignoreAllButCloseOk() - { - return false; - } - - @Override - public void receiveBasicNack(final long deliveryTag, final boolean multiple, final boolean requeue) - { - _processedMethods.add(new AMQFrame(_channelId, new BasicNackBody(deliveryTag, multiple, requeue))); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/HeartbeatBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/HeartbeatBody.java deleted file mode 100644 index 3afc082c89..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/HeartbeatBody.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.framing; - -import java.io.DataInputStream; -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; -import org.apache.qpid.protocol.AMQVersionAwareProtocolSession; -import org.apache.qpid.transport.ByteBufferSender; - -public class HeartbeatBody implements AMQBody -{ - public static final byte TYPE = 8; - public static final AMQFrame FRAME = new HeartbeatBody().toFrame(); - - public HeartbeatBody() - { - - } - - public HeartbeatBody(DataInputStream buffer, long size) throws IOException - { - if(size > 0) - { - //allow other implementations to have a payload, but ignore it: - buffer.skip(size); - } - } - - public byte getFrameType() - { - return TYPE; - } - - public int getSize() - { - return 0;//heartbeats we generate have no payload - } - - public void writePayload(DataOutput buffer) - { - } - - @Override - public long writePayload(final ByteBufferSender sender) throws IOException - { - return 0l; - } - - public void handle(final int channelId, final AMQVersionAwareProtocolSession session) - throws AMQException - { - session.heartbeatBodyReceived(channelId, this); - } - - protected void populateFromBuffer(DataInputStream buffer, long size) throws AMQFrameDecodingException, IOException - { - if(size > 0) - { - //allow other implementations to have a payload, but ignore it: - buffer.skip(size); - } - } - - public AMQFrame toFrame() - { - return new AMQFrame(0, this); - } - - public static void process(final int channel, - final MarkableDataInput in, - final MethodProcessor processor, - final long bodySize) throws IOException - { - - if(bodySize > 0) - { - in.skip(bodySize); - } - processor.receiveHeartbeat(); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/MessagePublishInfo.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/MessagePublishInfo.java deleted file mode 100644 index cc8f7eab58..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/MessagePublishInfo.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.framing; - -public final class MessagePublishInfo -{ - private AMQShortString _exchange; - private boolean _immediate; - private boolean _mandatory; - private AMQShortString _routingKey; - - public MessagePublishInfo() - { - } - - public MessagePublishInfo(AMQShortString exchange, boolean immediate, boolean mandatory, - AMQShortString routingKey) - { - _exchange = exchange; - _immediate = immediate; - _mandatory = mandatory; - _routingKey = routingKey; - } - - public AMQShortString getExchange() - { - return _exchange; - } - - public void setExchange(AMQShortString exchange) - { - _exchange = exchange; - } - - public boolean isImmediate() - { - return _immediate; - } - - public void setImmediate(boolean immedate) - { - _immediate = immedate; - } - - public boolean isMandatory() - { - return _mandatory; - } - - public void setMandatory(boolean mandatory) - { - _mandatory = mandatory; - } - - public AMQShortString getRoutingKey() - { - return _routingKey; - } - - public void setRoutingKey(AMQShortString routingKey) - { - _routingKey = routingKey; - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/MethodDispatcher.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/MethodDispatcher.java deleted file mode 100644 index a485397a5e..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/MethodDispatcher.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 0-9 - * 0-91 - * 8-0 - */ - -package org.apache.qpid.framing; - -public interface MethodDispatcher extends - ClientMethodDispatcher, ServerMethodDispatcher -{ - - boolean dispatchBasicNack(BasicNackBody basicNackBody, int channelId); -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/MethodProcessor.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/MethodProcessor.java deleted file mode 100644 index 62c0cd3c6d..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/MethodProcessor.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.framing; - -public interface MethodProcessor -{ - ProtocolVersion getProtocolVersion(); - - T getChannelMethodProcessor(int channelId); - - void receiveConnectionClose(int replyCode, AMQShortString replyText, int classId, int methodId); - - void receiveConnectionCloseOk(); - - void receiveHeartbeat(); - - void receiveProtocolHeader(ProtocolInitiation protocolInitiation); - - void setCurrentMethod(int classId, int methodId); - - boolean ignoreAllButCloseOk(); -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/MethodRegistry.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/MethodRegistry.java deleted file mode 100644 index d6ff437c3f..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/MethodRegistry.java +++ /dev/null @@ -1,557 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 0-9 - * 0-91 - * 8-0 - */ - -package org.apache.qpid.framing; - -public final class MethodRegistry -{ - private ProtocolVersion _protocolVersion; - - - public MethodRegistry(ProtocolVersion pv) - { - _protocolVersion = pv; - } - - public void setProtocolVersion(final ProtocolVersion protocolVersion) - { - _protocolVersion = protocolVersion; - } - - public final AccessRequestBody createAccessRequestBody(final AMQShortString realm, - final boolean exclusive, - final boolean passive, - final boolean active, - final boolean write, - final boolean read) - { - return new AccessRequestBody(realm, - exclusive, - passive, - active, - write, - read); - } - - public final AccessRequestOkBody createAccessRequestOkBody(final int ticket) - { - return new AccessRequestOkBody(ticket); - } - - - public final BasicQosBody createBasicQosBody(final long prefetchSize, - final int prefetchCount, - final boolean global) - { - return new BasicQosBody(prefetchSize, - prefetchCount, - global); - } - - public final BasicQosOkBody createBasicQosOkBody() - { - return new BasicQosOkBody(); - } - - public final BasicConsumeBody createBasicConsumeBody(final int ticket, - final AMQShortString queue, - final AMQShortString consumerTag, - final boolean noLocal, - final boolean noAck, - final boolean exclusive, - final boolean nowait, - final FieldTable arguments) - { - return new BasicConsumeBody(ticket, - queue, - consumerTag, - noLocal, - noAck, - exclusive, - nowait, - arguments); - } - - public final BasicConsumeOkBody createBasicConsumeOkBody(final AMQShortString consumerTag) - { - return new BasicConsumeOkBody(consumerTag); - } - - public final BasicCancelBody createBasicCancelBody(final AMQShortString consumerTag, - final boolean nowait) - { - return new BasicCancelBody(consumerTag, - nowait); - } - - public final BasicCancelOkBody createBasicCancelOkBody(final AMQShortString consumerTag) - { - return new BasicCancelOkBody(consumerTag); - } - - public final BasicPublishBody createBasicPublishBody(final int ticket, - final AMQShortString exchange, - final AMQShortString routingKey, - final boolean mandatory, - final boolean immediate) - { - return new BasicPublishBody(ticket, - exchange, - routingKey, - mandatory, - immediate); - } - - public final BasicReturnBody createBasicReturnBody(final int replyCode, - final AMQShortString replyText, - final AMQShortString exchange, - final AMQShortString routingKey) - { - return new BasicReturnBody(replyCode, - replyText, - exchange, - routingKey); - } - - public final BasicDeliverBody createBasicDeliverBody(final AMQShortString consumerTag, - final long deliveryTag, - final boolean redelivered, - final AMQShortString exchange, - final AMQShortString routingKey) - { - return new BasicDeliverBody(consumerTag, - deliveryTag, - redelivered, - exchange, - routingKey); - } - - public final BasicGetBody createBasicGetBody(final int ticket, - final AMQShortString queue, - final boolean noAck) - { - return new BasicGetBody(ticket, - queue, - noAck); - } - - public final BasicGetOkBody createBasicGetOkBody(final long deliveryTag, - final boolean redelivered, - final AMQShortString exchange, - final AMQShortString routingKey, - final long messageCount) - { - return new BasicGetOkBody(deliveryTag, - redelivered, - exchange, - routingKey, - messageCount); - } - - public final BasicGetEmptyBody createBasicGetEmptyBody(final AMQShortString clusterId) - { - return new BasicGetEmptyBody(clusterId); - } - - public final BasicAckBody createBasicAckBody(final long deliveryTag, - final boolean multiple) - { - return new BasicAckBody(deliveryTag, - multiple); - } - - public final BasicRejectBody createBasicRejectBody(final long deliveryTag, - final boolean requeue) - { - return new BasicRejectBody(deliveryTag, - requeue); - } - - public final BasicRecoverBody createBasicRecoverBody(final boolean requeue) - { - return new BasicRecoverBody(requeue); - } - - - public final BasicRecoverSyncOkBody createBasicRecoverSyncOkBody() - { - return new BasicRecoverSyncOkBody(_protocolVersion); - } - - - public final BasicRecoverSyncBody createBasicRecoverSyncBody(final boolean requeue) - { - return new BasicRecoverSyncBody(_protocolVersion, requeue); - } - - public final ChannelAlertBody createChannelAlertBody(final int replyCode, - final AMQShortString replyText, - final FieldTable details) - { - return new ChannelAlertBody(replyCode, - replyText, - details); - } - - public final ChannelOpenBody createChannelOpenBody(final AMQShortString outOfBand) - { - return new ChannelOpenBody(); - } - - public final ChannelOpenOkBody createChannelOpenOkBody(byte[] channelId) - { - return createChannelOpenOkBody(); - } - - public final ChannelOpenOkBody createChannelOpenOkBody() - { - return _protocolVersion.equals(ProtocolVersion.v8_0) - ? ChannelOpenOkBody.INSTANCE_0_8 - : ChannelOpenOkBody.INSTANCE_0_9; - } - - public final ChannelFlowBody createChannelFlowBody(final boolean active) - { - return new ChannelFlowBody(active); - } - - public final ChannelFlowOkBody createChannelFlowOkBody(final boolean active) - { - return new ChannelFlowOkBody(active); - } - - public final ChannelCloseBody createChannelCloseBody(final int replyCode, final AMQShortString replyText, - final int classId, - final int methodId - ) - { - return new ChannelCloseBody(replyCode, - replyText, - classId, - methodId); - } - - public final ChannelCloseOkBody createChannelCloseOkBody() - { - return ChannelCloseOkBody.INSTANCE; - } - - - - - public final ConnectionStartBody createConnectionStartBody(final short versionMajor, - final short versionMinor, - final FieldTable serverProperties, - final byte[] mechanisms, - final byte[] locales) - { - return new ConnectionStartBody(versionMajor, - versionMinor, - serverProperties, - mechanisms, - locales); - } - - public final ConnectionStartOkBody createConnectionStartOkBody(final FieldTable clientProperties, - final AMQShortString mechanism, - final byte[] response, - final AMQShortString locale) - { - return new ConnectionStartOkBody(clientProperties, - mechanism, - response, - locale); - } - - public final ConnectionSecureBody createConnectionSecureBody(final byte[] challenge) - { - return new ConnectionSecureBody(challenge); - } - - public final ConnectionSecureOkBody createConnectionSecureOkBody(final byte[] response) - { - return new ConnectionSecureOkBody(response); - } - - public final ConnectionTuneBody createConnectionTuneBody(final int channelMax, - final long frameMax, - final int heartbeat) - { - return new ConnectionTuneBody(channelMax, - frameMax, - heartbeat); - } - - public final ConnectionTuneOkBody createConnectionTuneOkBody(final int channelMax, - final long frameMax, - final int heartbeat) - { - return new ConnectionTuneOkBody(channelMax, - frameMax, - heartbeat); - } - - public final ConnectionOpenBody createConnectionOpenBody(final AMQShortString virtualHost, - final AMQShortString capabilities, - final boolean insist) - { - return new ConnectionOpenBody(virtualHost, - capabilities, - insist); - } - - public final ConnectionOpenOkBody createConnectionOpenOkBody(final AMQShortString knownHosts) - { - return new ConnectionOpenOkBody(knownHosts); - } - - public final ConnectionRedirectBody createConnectionRedirectBody(final AMQShortString host, - final AMQShortString knownHosts) - { - return new ConnectionRedirectBody(_protocolVersion, - host, - knownHosts); - } - - public final ConnectionCloseBody createConnectionCloseBody(final int replyCode, - final AMQShortString replyText, - final int classId, - final int methodId) - { - return new ConnectionCloseBody(_protocolVersion, - replyCode, - replyText, - classId, - methodId); - } - - public final ConnectionCloseOkBody createConnectionCloseOkBody() - { - return ProtocolVersion.v8_0.equals(_protocolVersion) - ? ConnectionCloseOkBody.CONNECTION_CLOSE_OK_0_8 - : ConnectionCloseOkBody.CONNECTION_CLOSE_OK_0_9; - } - - - public final ExchangeDeclareBody createExchangeDeclareBody(final int ticket, - final AMQShortString exchange, - final AMQShortString type, - final boolean passive, - final boolean durable, - final boolean autoDelete, - final boolean internal, - final boolean nowait, - final FieldTable arguments) - { - return new ExchangeDeclareBody(ticket, - exchange, - type, - passive, - durable, - autoDelete, - internal, - nowait, - arguments); - } - - public final ExchangeDeclareOkBody createExchangeDeclareOkBody() - { - return new ExchangeDeclareOkBody(); - } - - public final ExchangeDeleteBody createExchangeDeleteBody(final int ticket, - final AMQShortString exchange, - final boolean ifUnused, - final boolean nowait) - { - return new ExchangeDeleteBody(ticket, - exchange, - ifUnused, - nowait - ); - } - - public final ExchangeDeleteOkBody createExchangeDeleteOkBody() - { - return new ExchangeDeleteOkBody(); - } - - public final ExchangeBoundBody createExchangeBoundBody(final AMQShortString exchange, - final AMQShortString routingKey, - final AMQShortString queue) - { - return new ExchangeBoundBody(exchange, - routingKey, - queue); - } - - public final ExchangeBoundOkBody createExchangeBoundOkBody(final int replyCode, - final AMQShortString replyText) - { - return new ExchangeBoundOkBody(replyCode, - replyText); - } - - - public final QueueDeclareBody createQueueDeclareBody(final int ticket, - final AMQShortString queue, - final boolean passive, - final boolean durable, - final boolean exclusive, - final boolean autoDelete, - final boolean nowait, - final FieldTable arguments) - { - return new QueueDeclareBody(ticket, - queue, - passive, - durable, - exclusive, - autoDelete, - nowait, - arguments); - } - - public final QueueDeclareOkBody createQueueDeclareOkBody(final AMQShortString queue, - final long messageCount, - final long consumerCount) - { - return new QueueDeclareOkBody(queue, - messageCount, - consumerCount); - } - - public final QueueBindBody createQueueBindBody(final int ticket, - final AMQShortString queue, - final AMQShortString exchange, - final AMQShortString routingKey, - final boolean nowait, - final FieldTable arguments) - { - return new QueueBindBody(ticket, - queue, - exchange, - routingKey, - nowait, - arguments); - } - - public final QueueBindOkBody createQueueBindOkBody() - { - return new QueueBindOkBody(); - } - - public final QueuePurgeBody createQueuePurgeBody(final int ticket, - final AMQShortString queue, - final boolean nowait) - { - return new QueuePurgeBody(ticket, - queue, - nowait); - } - - public final QueuePurgeOkBody createQueuePurgeOkBody(final long messageCount) - { - return new QueuePurgeOkBody(messageCount); - } - - public final QueueDeleteBody createQueueDeleteBody(final int ticket, - final AMQShortString queue, - final boolean ifUnused, - final boolean ifEmpty, - final boolean nowait) - { - return new QueueDeleteBody(ticket, - queue, - ifUnused, - ifEmpty, - nowait); - } - - public final QueueDeleteOkBody createQueueDeleteOkBody(final long messageCount) - { - return new QueueDeleteOkBody(messageCount); - } - - public final QueueUnbindBody createQueueUnbindBody(final int ticket, - final AMQShortString queue, - final AMQShortString exchange, - final AMQShortString routingKey, - final FieldTable arguments) - { - return new QueueUnbindBody(ticket, - queue, - exchange, - routingKey, - arguments); - } - - public final QueueUnbindOkBody createQueueUnbindOkBody() - { - return new QueueUnbindOkBody(); - } - - - public final TxSelectBody createTxSelectBody() - { - return TxSelectBody.INSTANCE; - } - - public final TxSelectOkBody createTxSelectOkBody() - { - return TxSelectOkBody.INSTANCE; - } - - public final TxCommitBody createTxCommitBody() - { - return TxCommitBody.INSTANCE; - } - - public final TxCommitOkBody createTxCommitOkBody() - { - return TxCommitOkBody.INSTANCE; - } - - public final TxRollbackBody createTxRollbackBody() - { - return TxRollbackBody.INSTANCE; - } - - public final TxRollbackOkBody createTxRollbackOkBody() - { - return TxRollbackOkBody.INSTANCE; - } - - public ProtocolVersion getProtocolVersion() - { - return _protocolVersion; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ProtocolInitiation.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ProtocolInitiation.java deleted file mode 100644 index 9c8d2a8578..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ProtocolInitiation.java +++ /dev/null @@ -1,252 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.util.Arrays; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; -import org.apache.qpid.transport.ByteBufferSender; -import org.apache.qpid.util.BytesDataOutput; - -public class ProtocolInitiation extends AMQDataBlock implements EncodableAMQDataBlock -{ - - // TODO: generate these constants automatically from the xml protocol spec file - private static final byte[] AMQP_HEADER = new byte[]{(byte)'A',(byte)'M',(byte)'Q',(byte)'P'}; - - private static final byte CURRENT_PROTOCOL_CLASS = 1; - private static final byte TCP_PROTOCOL_INSTANCE = 1; - - private final byte[] _protocolHeader; - private final byte _protocolClass; - private final byte _protocolInstance; - private final byte _protocolMajor; - private final byte _protocolMinor; - - public ProtocolInitiation(byte[] protocolHeader, byte protocolClass, byte protocolInstance, byte protocolMajor, byte protocolMinor) - { - _protocolHeader = protocolHeader; - _protocolClass = protocolClass; - _protocolInstance = protocolInstance; - _protocolMajor = protocolMajor; - _protocolMinor = protocolMinor; - } - - public ProtocolInitiation(ProtocolVersion pv) - { - this(AMQP_HEADER, - pv.equals(ProtocolVersion.v0_91) ? 0 : CURRENT_PROTOCOL_CLASS, - pv.equals(ProtocolVersion.v0_91) ? 0 : TCP_PROTOCOL_INSTANCE, - pv.equals(ProtocolVersion.v0_91) ? 9 : pv.getMajorVersion(), - pv.equals(ProtocolVersion.v0_91) ? 1 : pv.getMinorVersion()); - } - - public ProtocolInitiation(MarkableDataInput in) throws IOException - { - _protocolHeader = new byte[4]; - in.read(_protocolHeader); - - _protocolClass = in.readByte(); - _protocolInstance = in.readByte(); - _protocolMajor = in.readByte(); - _protocolMinor = in.readByte(); - } - - public long getSize() - { - return 4 + 1 + 1 + 1 + 1; - } - - public void writePayload(DataOutput buffer) throws IOException - { - - buffer.write(_protocolHeader); - buffer.write(_protocolClass); - buffer.write(_protocolInstance); - buffer.write(_protocolMajor); - buffer.write(_protocolMinor); - } - - @Override - public long writePayload(final ByteBufferSender sender) throws IOException - { - byte[] data = new byte[8]; - BytesDataOutput out = new BytesDataOutput(data); - writePayload(out); - sender.send(ByteBuffer.wrap(data)); - return 8l; - } - - public boolean equals(Object o) - { - if (!(o instanceof ProtocolInitiation)) - { - return false; - } - - ProtocolInitiation pi = (ProtocolInitiation) o; - if (pi._protocolHeader == null) - { - return false; - } - - if (_protocolHeader.length != pi._protocolHeader.length) - { - return false; - } - - for (int i = 0; i < _protocolHeader.length; i++) - { - if (_protocolHeader[i] != pi._protocolHeader[i]) - { - return false; - } - } - - return (_protocolClass == pi._protocolClass && - _protocolInstance == pi._protocolInstance && - _protocolMajor == pi._protocolMajor && - _protocolMinor == pi._protocolMinor); - } - - @Override - public int hashCode() - { - int result = _protocolHeader != null ? Arrays.hashCode(_protocolHeader) : 0; - result = 31 * result + (int) _protocolClass; - result = 31 * result + (int) _protocolInstance; - result = 31 * result + (int) _protocolMajor; - result = 31 * result + (int) _protocolMinor; - return result; - } - - public static class Decoder //implements MessageDecoder - { - /** - * - * @param in input buffer - * @return true if we have enough data to decode the PI frame fully, false if more - * data is required - * @throws IOException if there is an issue reading the input - */ - public boolean decodable(MarkableDataInput in) throws IOException - { - return (in.available() >= 8); - } - - } - - public ProtocolVersion checkVersion() throws AMQException - { - - if(_protocolHeader.length != 4) - { - throw new AMQProtocolHeaderException("Protocol header should have exactly four octets", null); - } - for(int i = 0; i < 4; i++) - { - if(_protocolHeader[i] != AMQP_HEADER[i]) - { - try - { - throw new AMQProtocolHeaderException("Protocol header is not correct: Got " + new String(_protocolHeader,"ISO-8859-1") + " should be: " + new String(AMQP_HEADER, "ISO-8859-1"), null); - } - catch (UnsupportedEncodingException e) - { - - } - } - } - - ProtocolVersion pv; - - // Hack for 0-9-1 which changed how the header was defined - if(_protocolInstance == 0 && _protocolMajor == 9 && _protocolMinor == 1) - { - pv = ProtocolVersion.v0_91; - if (_protocolClass != 0) - { - throw new AMQProtocolClassException("Protocol class " + 0 + " was expected; received " + - _protocolClass, null); - } - } - else if (_protocolClass != CURRENT_PROTOCOL_CLASS) - { - throw new AMQProtocolClassException("Protocol class " + CURRENT_PROTOCOL_CLASS + " was expected; received " + - _protocolClass, null); - } - else if (_protocolInstance != TCP_PROTOCOL_INSTANCE) - { - throw new AMQProtocolInstanceException("Protocol instance " + TCP_PROTOCOL_INSTANCE + " was expected; received " + - _protocolInstance, null); - } - else - { - pv = new ProtocolVersion(_protocolMajor, _protocolMinor); - } - - - if (!pv.isSupported()) - { - // TODO: add list of available versions in list to msg... - throw new AMQProtocolVersionException("Protocol version " + - _protocolMajor + "." + _protocolMinor + " not suppoerted by this version of the Qpid broker.", null); - } - return pv; - } - - public byte getProtocolClass() - { - return _protocolClass; - } - - public byte getProtocolInstance() - { - return _protocolInstance; - } - - public byte getProtocolMajor() - { - return _protocolMajor; - } - - public byte getProtocolMinor() - { - return _protocolMinor; - } - - public String toString() - { - StringBuffer buffer = new StringBuffer(new String(_protocolHeader, StandardCharsets.US_ASCII)); - buffer.append(Integer.toHexString(_protocolClass)); - buffer.append(Integer.toHexString(_protocolInstance)); - buffer.append(Integer.toHexString(_protocolMajor)); - buffer.append(Integer.toHexString(_protocolMinor)); - return buffer.toString(); - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ProtocolVersion.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ProtocolVersion.java deleted file mode 100644 index 33c613ec94..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ProtocolVersion.java +++ /dev/null @@ -1,188 +0,0 @@ -/* -* -* Licensed to the Apache Software Foundation (ASF) under one -* or more contributor license agreements. See the NOTICE file -* distributed with this work for additional information -* regarding copyright ownership. The ASF licenses this file -* to you under the Apache License, Version 2.0 (the -* "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -* -*/ - -/* -* This file is auto-generated by Qpid Gentools v.0.1 - do not modify. -* Supported AMQP versions: -* 0-9 -* 0-91 -* 8-0 -*/ - -package org.apache.qpid.framing; - -import java.util.SortedSet; -import java.util.Collections; -import java.util.TreeSet; -import java.util.Map; -import java.util.HashMap; - -public class ProtocolVersion implements Comparable -{ - private final byte _majorVersion; - private final byte _minorVersion; - private final String _stringFormat; - - public ProtocolVersion(byte majorVersion, byte minorVersion) - { - _majorVersion = majorVersion; - _minorVersion = minorVersion; - _stringFormat = _majorVersion+"-"+_minorVersion; - } - - public byte getMajorVersion() - { - return _majorVersion; - } - - public byte getMinorVersion() - { - return _minorVersion; - } - - public byte getActualMinorVersion() - { - return _minorVersion > 90 ? (byte) (_minorVersion / 10) : _minorVersion; - } - - public byte getRevisionVersion() - { - return _minorVersion > 90 ? (byte) (_minorVersion % 10) : (byte) 0; - } - - public String toString() - { - return _stringFormat; - } - - public int compareTo(Object o) - { - ProtocolVersion pv = (ProtocolVersion) o; - - /* - * 0-8 has it's major and minor numbers the wrong way round (it's actually 8-0)... - * so we need to deal with that case specially - */ - - if((_majorVersion == (byte) 8) && (_minorVersion == (byte) 0)) - { - ProtocolVersion fixedThis = new ProtocolVersion(_minorVersion, _majorVersion); - return fixedThis.compareTo(pv); - } - - if((pv.getMajorVersion() == (byte) 8) && (pv.getMinorVersion() == (byte) 0)) - { - ProtocolVersion fixedOther = new ProtocolVersion(pv.getMinorVersion(), pv.getMajorVersion()); - return this.compareTo(fixedOther); - } - - if(_majorVersion > pv.getMajorVersion()) - { - return 1; - } - else if(_majorVersion < pv.getMajorVersion()) - { - return -1; - } - else if(_minorVersion > pv.getMinorVersion()) - { - return 1; - } - else if(getMinorVersion() < pv.getMinorVersion()) - { - return -1; - } - else - { - return 0; - } - - } - - public boolean equals(Object o) - { - return o != null && (o == this || (compareTo(o) == 0)); - } - - public int hashCode() - { - return (0xFF & (int)_minorVersion) | ((0xFF & (int)_majorVersion) << 8); - } - - public boolean isSupported() - { - return _supportedVersions.contains(this); - } - - public static ProtocolVersion getLatestSupportedVersion() - { - return _supportedVersions.last(); - } - - private static final SortedSet _supportedVersions; - private static final Map _nameToVersionMap = - new HashMap(); - private static final ProtocolVersion _defaultVersion; - - public static final ProtocolVersion v0_10 = new ProtocolVersion((byte)0,(byte)10); - - public static final ProtocolVersion v0_9 = new ProtocolVersion((byte)0,(byte)9); - public static final ProtocolVersion v0_91 = new ProtocolVersion((byte)0,(byte)91); - public static final ProtocolVersion v8_0 = new ProtocolVersion((byte)8,(byte)0); - - static - { - SortedSet versions = new TreeSet(); - - versions.add(v0_10); - _nameToVersionMap.put("0-10", v0_10); - versions.add(v0_9); - _nameToVersionMap.put("0-9", v0_9); - versions.add(v0_91); - _nameToVersionMap.put("0-91", v0_91); - versions.add(v8_0); - _nameToVersionMap.put("8-0", v8_0); - _supportedVersions = Collections.unmodifiableSortedSet(versions); - - ProtocolVersion systemDefinedVersion = - _nameToVersionMap.get(System.getProperty("org.apache.qpid.amqp_version")); - - _defaultVersion = (systemDefinedVersion == null) - ? getLatestSupportedVersion() - : systemDefinedVersion; - } - - public static SortedSet getSupportedProtocolVersions() - { - return _supportedVersions; - } - - public static ProtocolVersion parse(String name) - { - return _nameToVersionMap.get(name); - } - - public static ProtocolVersion defaultProtocolVersion() - { - return _defaultVersion; - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/QueueBindBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/QueueBindBody.java deleted file mode 100644 index 2b7e26a7f0..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/QueueBindBody.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class QueueBindBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 50; - public static final int METHOD_ID = 20; - - // Fields declared in specification - private final int _ticket; // [ticket] - private final AMQShortString _queue; // [queue] - private final AMQShortString _exchange; // [exchange] - private final AMQShortString _routingKey; // [routingKey] - private final byte _bitfield0; // [nowait] - private final FieldTable _arguments; // [arguments] - - // Constructor - public QueueBindBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _ticket = buffer.readUnsignedShort(); - _queue = buffer.readAMQShortString(); - _exchange = buffer.readAMQShortString(); - _routingKey = buffer.readAMQShortString(); - _bitfield0 = buffer.readByte(); - _arguments = EncodingUtils.readFieldTable(buffer); - } - - public QueueBindBody( - int ticket, - AMQShortString queue, - AMQShortString exchange, - AMQShortString routingKey, - boolean nowait, - FieldTable arguments - ) - { - _ticket = ticket; - _queue = queue; - _exchange = exchange; - _routingKey = routingKey; - byte bitfield0 = (byte)0; - if( nowait ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 0)); - } - - _bitfield0 = bitfield0; - _arguments = arguments; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final int getTicket() - { - return _ticket; - } - public final AMQShortString getQueue() - { - return _queue; - } - public final AMQShortString getExchange() - { - return _exchange; - } - public final AMQShortString getRoutingKey() - { - return _routingKey; - } - public final boolean getNowait() - { - return (((int)(_bitfield0)) & ( 1 << 0)) != 0; - } - public final FieldTable getArguments() - { - return _arguments; - } - - protected int getBodySize() - { - int size = 3; - size += getSizeOf( _queue ); - size += getSizeOf( _exchange ); - size += getSizeOf( _routingKey ); - size += getSizeOf( _arguments ); - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeUnsignedShort( buffer, _ticket ); - writeAMQShortString( buffer, _queue ); - writeAMQShortString( buffer, _exchange ); - writeAMQShortString( buffer, _routingKey ); - writeBitfield( buffer, _bitfield0 ); - writeFieldTable( buffer, _arguments ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchQueueBind(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[QueueBindBodyImpl: "); - buf.append( "ticket=" ); - buf.append( getTicket() ); - buf.append( ", " ); - buf.append( "queue=" ); - buf.append( getQueue() ); - buf.append( ", " ); - buf.append( "exchange=" ); - buf.append( getExchange() ); - buf.append( ", " ); - buf.append( "routingKey=" ); - buf.append( getRoutingKey() ); - buf.append( ", " ); - buf.append( "nowait=" ); - buf.append( getNowait() ); - buf.append( ", " ); - buf.append( "arguments=" ); - buf.append( getArguments() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, - final ServerChannelMethodProcessor dispatcher) throws IOException, AMQFrameDecodingException - { - - int ticket = buffer.readUnsignedShort(); - AMQShortString queue = buffer.readAMQShortString(); - AMQShortString exchange = buffer.readAMQShortString(); - AMQShortString bindingKey = buffer.readAMQShortString(); - boolean nowait = (buffer.readByte() & 0x01) == 0x01; - FieldTable arguments = EncodingUtils.readFieldTable(buffer); - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveQueueBind(queue, exchange, bindingKey, nowait, arguments); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/QueueBindOkBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/QueueBindOkBody.java deleted file mode 100644 index cf6b18b932..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/QueueBindOkBody.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class QueueBindOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 50; - public static final int METHOD_ID = 21; - - // Fields declared in specification - - // Constructor - public QueueBindOkBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - } - - public QueueBindOkBody( - ) - { - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - - protected int getBodySize() - { - int size = 0; - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchQueueBindOk(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[QueueBindOkBodyImpl: "); - buf.append("]"); - return buf.toString(); - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/QueueDeclareBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/QueueDeclareBody.java deleted file mode 100644 index 5a359dc8df..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/QueueDeclareBody.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class QueueDeclareBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 50; - public static final int METHOD_ID = 10; - - // Fields declared in specification - private final int _ticket; // [ticket] - private final AMQShortString _queue; // [queue] - private final byte _bitfield0; // [passive, durable, exclusive, autoDelete, nowait] - private final FieldTable _arguments; // [arguments] - - // Constructor - public QueueDeclareBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _ticket = buffer.readUnsignedShort(); - _queue = buffer.readAMQShortString(); - _bitfield0 = buffer.readByte(); - _arguments = EncodingUtils.readFieldTable(buffer); - } - - public QueueDeclareBody( - int ticket, - AMQShortString queue, - boolean passive, - boolean durable, - boolean exclusive, - boolean autoDelete, - boolean nowait, - FieldTable arguments - ) - { - _ticket = ticket; - _queue = queue; - byte bitfield0 = (byte)0; - if( passive ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 0)); - } - - if( durable ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 1)); - } - - if( exclusive ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 2)); - } - - if( autoDelete ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 3)); - } - - if( nowait ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 4)); - } - - _bitfield0 = bitfield0; - _arguments = arguments; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final int getTicket() - { - return _ticket; - } - public final AMQShortString getQueue() - { - return _queue; - } - public final boolean getPassive() - { - return (((int)(_bitfield0)) & ( 1 << 0)) != 0; - } - public final boolean getDurable() - { - return (((int)(_bitfield0)) & ( 1 << 1)) != 0; - } - public final boolean getExclusive() - { - return (((int)(_bitfield0)) & ( 1 << 2)) != 0; - } - public final boolean getAutoDelete() - { - return (((int)(_bitfield0)) & ( 1 << 3)) != 0; - } - public final boolean getNowait() - { - return (((int)(_bitfield0)) & ( 1 << 4)) != 0; - } - public final FieldTable getArguments() - { - return _arguments; - } - - protected int getBodySize() - { - int size = 3; - size += getSizeOf( _queue ); - size += getSizeOf( _arguments ); - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeUnsignedShort( buffer, _ticket ); - writeAMQShortString( buffer, _queue ); - writeBitfield( buffer, _bitfield0 ); - writeFieldTable( buffer, _arguments ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchQueueDeclare(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[QueueDeclareBodyImpl: "); - buf.append( "ticket=" ); - buf.append( getTicket() ); - buf.append( ", " ); - buf.append( "queue=" ); - buf.append( getQueue() ); - buf.append( ", " ); - buf.append( "passive=" ); - buf.append( getPassive() ); - buf.append( ", " ); - buf.append( "durable=" ); - buf.append( getDurable() ); - buf.append( ", " ); - buf.append( "exclusive=" ); - buf.append( getExclusive() ); - buf.append( ", " ); - buf.append( "autoDelete=" ); - buf.append( getAutoDelete() ); - buf.append( ", " ); - buf.append( "nowait=" ); - buf.append( getNowait() ); - buf.append( ", " ); - buf.append( "arguments=" ); - buf.append( getArguments() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, - final ServerChannelMethodProcessor dispatcher) throws IOException, AMQFrameDecodingException - { - - int ticket = buffer.readUnsignedShort(); - AMQShortString queue = buffer.readAMQShortString(); - byte bitfield = buffer.readByte(); - - boolean passive = (bitfield & 0x01 ) == 0x01; - boolean durable = (bitfield & 0x02 ) == 0x02; - boolean exclusive = (bitfield & 0x04 ) == 0x04; - boolean autoDelete = (bitfield & 0x08 ) == 0x08; - boolean nowait = (bitfield & 0x010 ) == 0x010; - FieldTable arguments = EncodingUtils.readFieldTable(buffer); - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveQueueDeclare(queue, passive, durable, exclusive, autoDelete, nowait, arguments); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/QueueDeclareOkBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/QueueDeclareOkBody.java deleted file mode 100644 index cf6fc656b3..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/QueueDeclareOkBody.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class QueueDeclareOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 50; - public static final int METHOD_ID = 11; - - // Fields declared in specification - private final AMQShortString _queue; // [queue] - private final long _messageCount; // [messageCount] - private final long _consumerCount; // [consumerCount] - - // Constructor - public QueueDeclareOkBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _queue = buffer.readAMQShortString(); - _messageCount = EncodingUtils.readUnsignedInteger(buffer); - _consumerCount = EncodingUtils.readUnsignedInteger(buffer); - } - - public QueueDeclareOkBody( - AMQShortString queue, - long messageCount, - long consumerCount - ) - { - _queue = queue; - _messageCount = messageCount; - _consumerCount = consumerCount; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final AMQShortString getQueue() - { - return _queue; - } - public final long getMessageCount() - { - return _messageCount; - } - public final long getConsumerCount() - { - return _consumerCount; - } - - protected int getBodySize() - { - int size = 8; - size += getSizeOf( _queue ); - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeAMQShortString( buffer, _queue ); - writeUnsignedInteger( buffer, _messageCount ); - writeUnsignedInteger( buffer, _consumerCount ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchQueueDeclareOk(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[QueueDeclareOkBodyImpl: "); - buf.append( "queue=" ); - buf.append( getQueue() ); - buf.append( ", " ); - buf.append( "messageCount=" ); - buf.append( getMessageCount() ); - buf.append( ", " ); - buf.append( "consumerCount=" ); - buf.append( getConsumerCount() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, - final ClientChannelMethodProcessor dispatcher) throws IOException - { - AMQShortString queue = buffer.readAMQShortString(); - long messageCount = EncodingUtils.readUnsignedInteger(buffer); - long consumerCount = EncodingUtils.readUnsignedInteger(buffer); - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveQueueDeclareOk(queue, messageCount, consumerCount); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/QueueDeleteBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/QueueDeleteBody.java deleted file mode 100644 index ea933dc644..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/QueueDeleteBody.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class QueueDeleteBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 50; - public static final int METHOD_ID = 40; - - // Fields declared in specification - private final int _ticket; // [ticket] - private final AMQShortString _queue; // [queue] - private final byte _bitfield0; // [ifUnused, ifEmpty, nowait] - - // Constructor - public QueueDeleteBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _ticket = buffer.readUnsignedShort(); - _queue = buffer.readAMQShortString(); - _bitfield0 = buffer.readByte(); - } - - public QueueDeleteBody( - int ticket, - AMQShortString queue, - boolean ifUnused, - boolean ifEmpty, - boolean nowait - ) - { - _ticket = ticket; - _queue = queue; - byte bitfield0 = (byte)0; - if( ifUnused ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 0)); - } - - if( ifEmpty ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 1)); - } - - if( nowait ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 2)); - } - _bitfield0 = bitfield0; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final int getTicket() - { - return _ticket; - } - public final AMQShortString getQueue() - { - return _queue; - } - public final boolean getIfUnused() - { - return (((int)(_bitfield0)) & ( 1 << 0)) != 0; - } - public final boolean getIfEmpty() - { - return (((int)(_bitfield0)) & ( 1 << 1)) != 0; - } - public final boolean getNowait() - { - return (((int)(_bitfield0)) & ( 1 << 2)) != 0; - } - - protected int getBodySize() - { - int size = 3; - size += getSizeOf( _queue ); - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeUnsignedShort( buffer, _ticket ); - writeAMQShortString( buffer, _queue ); - writeBitfield( buffer, _bitfield0 ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchQueueDelete(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[QueueDeleteBodyImpl: "); - buf.append( "ticket=" ); - buf.append( getTicket() ); - buf.append( ", " ); - buf.append( "queue=" ); - buf.append( getQueue() ); - buf.append( ", " ); - buf.append( "ifUnused=" ); - buf.append( getIfUnused() ); - buf.append( ", " ); - buf.append( "ifEmpty=" ); - buf.append( getIfEmpty() ); - buf.append( ", " ); - buf.append( "nowait=" ); - buf.append( getNowait() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, - final ServerChannelMethodProcessor dispatcher) throws IOException - { - - int ticket = buffer.readUnsignedShort(); - AMQShortString queue = buffer.readAMQShortString(); - byte bitfield = buffer.readByte(); - - boolean ifUnused = (bitfield & 0x01) == 0x01; - boolean ifEmpty = (bitfield & 0x02) == 0x02; - boolean nowait = (bitfield & 0x04) == 0x04; - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveQueueDelete(queue, ifUnused, ifEmpty, nowait); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/QueueDeleteOkBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/QueueDeleteOkBody.java deleted file mode 100644 index 6d50153c15..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/QueueDeleteOkBody.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class QueueDeleteOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 50; - public static final int METHOD_ID = 41; - - // Fields declared in specification - private final long _messageCount; // [messageCount] - - // Constructor - public QueueDeleteOkBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _messageCount = EncodingUtils.readUnsignedInteger(buffer); - } - - public QueueDeleteOkBody( - long messageCount - ) - { - _messageCount = messageCount; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final long getMessageCount() - { - return _messageCount; - } - - protected int getBodySize() - { - int size = 4; - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeUnsignedInteger( buffer, _messageCount ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchQueueDeleteOk(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[QueueDeleteOkBodyImpl: "); - buf.append( "messageCount=" ); - buf.append( getMessageCount() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, - final ClientChannelMethodProcessor dispatcher) throws IOException - { - long messageCount = EncodingUtils.readUnsignedInteger(buffer); - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveQueueDeleteOk(messageCount); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/QueuePurgeBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/QueuePurgeBody.java deleted file mode 100644 index 58a424387c..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/QueuePurgeBody.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class QueuePurgeBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 50; - public static final int METHOD_ID = 30; - - // Fields declared in specification - private final int _ticket; // [ticket] - private final AMQShortString _queue; // [queue] - private final byte _bitfield0; // [nowait] - - // Constructor - public QueuePurgeBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _ticket = buffer.readUnsignedShort(); - _queue = buffer.readAMQShortString(); - _bitfield0 = buffer.readByte(); - } - - public QueuePurgeBody( - int ticket, - AMQShortString queue, - boolean nowait - ) - { - _ticket = ticket; - _queue = queue; - byte bitfield0 = (byte)0; - if( nowait ) - { - bitfield0 = (byte) (((int) bitfield0) | (1 << 0)); - } - _bitfield0 = bitfield0; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final int getTicket() - { - return _ticket; - } - public final AMQShortString getQueue() - { - return _queue; - } - public final boolean getNowait() - { - return (((int)(_bitfield0)) & ( 1 << 0)) != 0; - } - - protected int getBodySize() - { - int size = 3; - size += getSizeOf( _queue ); - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeUnsignedShort( buffer, _ticket ); - writeAMQShortString( buffer, _queue ); - writeBitfield( buffer, _bitfield0 ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchQueuePurge(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[QueuePurgeBodyImpl: "); - buf.append( "ticket=" ); - buf.append( getTicket() ); - buf.append( ", " ); - buf.append( "queue=" ); - buf.append( getQueue() ); - buf.append( ", " ); - buf.append( "nowait=" ); - buf.append( getNowait() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, - final ServerChannelMethodProcessor dispatcher) throws IOException - { - - int ticket = buffer.readUnsignedShort(); - AMQShortString queue = buffer.readAMQShortString(); - boolean nowait = (buffer.readByte() & 0x01) == 0x01; - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveQueuePurge(queue, nowait); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/QueuePurgeOkBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/QueuePurgeOkBody.java deleted file mode 100644 index acab2bc052..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/QueuePurgeOkBody.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class QueuePurgeOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 50; - public static final int METHOD_ID = 31; - - // Fields declared in specification - private final long _messageCount; // [messageCount] - - // Constructor - public QueuePurgeOkBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _messageCount = EncodingUtils.readUnsignedInteger(buffer); - } - - public QueuePurgeOkBody( - long messageCount - ) - { - _messageCount = messageCount; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final long getMessageCount() - { - return _messageCount; - } - - protected int getBodySize() - { - int size = 4; - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeUnsignedInteger( buffer, _messageCount ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchQueuePurgeOk(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[QueuePurgeOkBodyImpl: "); - buf.append( "messageCount=" ); - buf.append( getMessageCount() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, - final ClientChannelMethodProcessor dispatcher) throws IOException - { - long messageCount = EncodingUtils.readUnsignedInteger(buffer); - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveQueuePurgeOk(messageCount); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/QueueUnbindBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/QueueUnbindBody.java deleted file mode 100644 index 30c5d19d27..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/QueueUnbindBody.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 0-91 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class QueueUnbindBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 50; - public static final int METHOD_ID = 50; - - // Fields declared in specification - private final int _ticket; // [ticket] - private final AMQShortString _queue; // [queue] - private final AMQShortString _exchange; // [exchange] - private final AMQShortString _routingKey; // [routingKey] - private final FieldTable _arguments; // [arguments] - - // Constructor - public QueueUnbindBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - _ticket = buffer.readUnsignedShort(); - _queue = buffer.readAMQShortString(); - _exchange = buffer.readAMQShortString(); - _routingKey = buffer.readAMQShortString(); - _arguments = EncodingUtils.readFieldTable(buffer); - } - - public QueueUnbindBody( - int ticket, - AMQShortString queue, - AMQShortString exchange, - AMQShortString routingKey, - FieldTable arguments - ) - { - _ticket = ticket; - _queue = queue; - _exchange = exchange; - _routingKey = routingKey; - _arguments = arguments; - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - public final int getTicket() - { - return _ticket; - } - public final AMQShortString getQueue() - { - return _queue; - } - public final AMQShortString getExchange() - { - return _exchange; - } - public final AMQShortString getRoutingKey() - { - return _routingKey; - } - public final FieldTable getArguments() - { - return _arguments; - } - - protected int getBodySize() - { - int size = 2; - size += getSizeOf( _queue ); - size += getSizeOf( _exchange ); - size += getSizeOf( _routingKey ); - size += getSizeOf( _arguments ); - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - writeUnsignedShort( buffer, _ticket ); - writeAMQShortString( buffer, _queue ); - writeAMQShortString( buffer, _exchange ); - writeAMQShortString( buffer, _routingKey ); - writeFieldTable( buffer, _arguments ); - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchQueueUnbind(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[QueueUnbindBodyImpl: "); - buf.append( "ticket=" ); - buf.append( getTicket() ); - buf.append( ", " ); - buf.append( "queue=" ); - buf.append( getQueue() ); - buf.append( ", " ); - buf.append( "exchange=" ); - buf.append( getExchange() ); - buf.append( ", " ); - buf.append( "routingKey=" ); - buf.append( getRoutingKey() ); - buf.append( ", " ); - buf.append( "arguments=" ); - buf.append( getArguments() ); - buf.append("]"); - return buf.toString(); - } - - public static void process(final MarkableDataInput buffer, - final ServerChannelMethodProcessor dispatcher) throws IOException, AMQFrameDecodingException - { - - int ticket = buffer.readUnsignedShort(); - AMQShortString queue = buffer.readAMQShortString(); - AMQShortString exchange = buffer.readAMQShortString(); - AMQShortString routingKey = buffer.readAMQShortString(); - FieldTable arguments = EncodingUtils.readFieldTable(buffer); - if(!dispatcher.ignoreAllButCloseOk()) - { - dispatcher.receiveQueueUnbind(queue, exchange, routingKey, arguments); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/QueueUnbindOkBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/QueueUnbindOkBody.java deleted file mode 100644 index 2e504d6fc7..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/QueueUnbindOkBody.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 0-91 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; -import org.apache.qpid.codec.MarkableDataInput; - -public class QueueUnbindOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 50; - public static final int METHOD_ID = 51; - - // Fields declared in specification - - // Constructor - public QueueUnbindOkBody(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException - { - } - - public QueueUnbindOkBody( - ) - { - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - - protected int getBodySize() - { - int size = 0; - return size; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchQueueUnbindOk(this, channelId); - } - - public String toString() - { - StringBuilder buf = new StringBuilder("[QueueUnbindOkBodyImpl: "); - buf.append("]"); - return buf.toString(); - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ServerChannelMethodProcessor.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ServerChannelMethodProcessor.java deleted file mode 100644 index 6d43accc96..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ServerChannelMethodProcessor.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.framing; - -public interface ServerChannelMethodProcessor extends ChannelMethodProcessor -{ - void receiveAccessRequest(AMQShortString realm, - boolean exclusive, - boolean passive, - boolean active, - boolean write, boolean read); - - void receiveExchangeDeclare(AMQShortString exchange, - AMQShortString type, - boolean passive, - boolean durable, - boolean autoDelete, boolean internal, boolean nowait, final FieldTable arguments); - - void receiveExchangeDelete(AMQShortString exchange, boolean ifUnused, boolean nowait); - - void receiveExchangeBound(AMQShortString exchange, AMQShortString routingKey, AMQShortString queue); - - void receiveQueueDeclare(AMQShortString queue, - boolean passive, - boolean durable, - boolean exclusive, - boolean autoDelete, boolean nowait, FieldTable arguments); - - void receiveQueueBind(AMQShortString queue, - AMQShortString exchange, - AMQShortString bindingKey, - boolean nowait, FieldTable arguments); - - void receiveQueuePurge(AMQShortString queue, boolean nowait); - - void receiveQueueDelete(AMQShortString queue, boolean ifUnused, boolean ifEmpty, boolean nowait); - - void receiveQueueUnbind(AMQShortString queue, - AMQShortString exchange, - AMQShortString bindingKey, - FieldTable arguments); - - void receiveBasicRecover(final boolean requeue, boolean sync); - - void receiveBasicQos(long prefetchSize, int prefetchCount, boolean global); - - void receiveBasicConsume(AMQShortString queue, - AMQShortString consumerTag, - boolean noLocal, - boolean noAck, - boolean exclusive, boolean nowait, FieldTable arguments); - - void receiveBasicCancel(AMQShortString consumerTag, boolean noWait); - - void receiveBasicPublish(AMQShortString exchange, - AMQShortString routingKey, - boolean mandatory, - boolean immediate); - - void receiveBasicGet(AMQShortString queue, boolean noAck); - - void receiveBasicAck(long deliveryTag, boolean multiple); - - void receiveBasicReject(long deliveryTag, boolean requeue); - - - - void receiveTxSelect(); - - void receiveTxCommit(); - - void receiveTxRollback(); - - void receiveConfirmSelect(boolean nowait); -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ServerMethodDispatcher.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ServerMethodDispatcher.java deleted file mode 100644 index d3961a1a59..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ServerMethodDispatcher.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 0-9 - * 0-91 - * 8-0 - */ - -package org.apache.qpid.framing; - -import org.apache.qpid.AMQException; - -public interface ServerMethodDispatcher -{ - boolean dispatchAccessRequest(AccessRequestBody accessRequestBody, int channelId) throws AMQException; - - public boolean dispatchBasicAck(BasicAckBody body, int channelId) throws AMQException; - public boolean dispatchBasicCancel(BasicCancelBody body, int channelId) throws AMQException; - public boolean dispatchBasicConsume(BasicConsumeBody body, int channelId) throws AMQException; - public boolean dispatchBasicGet(BasicGetBody body, int channelId) throws AMQException; - public boolean dispatchBasicPublish(BasicPublishBody body, int channelId) throws AMQException; - public boolean dispatchBasicQos(BasicQosBody body, int channelId) throws AMQException; - public boolean dispatchBasicRecover(BasicRecoverBody body, int channelId) throws AMQException; - public boolean dispatchBasicReject(BasicRejectBody body, int channelId) throws AMQException; - public boolean dispatchChannelClose(ChannelCloseBody body, int channelId) throws AMQException; - public boolean dispatchChannelCloseOk(ChannelCloseOkBody body, int channelId) throws AMQException; - public boolean dispatchChannelFlow(ChannelFlowBody body, int channelId) throws AMQException; - public boolean dispatchChannelFlowOk(ChannelFlowOkBody body, int channelId) throws AMQException; - public boolean dispatchChannelOpen(ChannelOpenBody body, int channelId) throws AMQException; - public boolean dispatchConnectionClose(ConnectionCloseBody body, int channelId) throws AMQException; - public boolean dispatchConnectionCloseOk(ConnectionCloseOkBody body, int channelId) throws AMQException; - public boolean dispatchConnectionOpen(ConnectionOpenBody body, int channelId) throws AMQException; - public boolean dispatchConnectionSecureOk(ConnectionSecureOkBody body, int channelId) throws AMQException; - public boolean dispatchConnectionStartOk(ConnectionStartOkBody body, int channelId) throws AMQException; - public boolean dispatchConnectionTuneOk(ConnectionTuneOkBody body, int channelId) throws AMQException; - public boolean dispatchExchangeBound(ExchangeBoundBody body, int channelId) throws AMQException; - public boolean dispatchExchangeDeclare(ExchangeDeclareBody body, int channelId) throws AMQException; - public boolean dispatchExchangeDelete(ExchangeDeleteBody body, int channelId) throws AMQException; - public boolean dispatchQueueBind(QueueBindBody body, int channelId) throws AMQException; - public boolean dispatchQueueDeclare(QueueDeclareBody body, int channelId) throws AMQException; - public boolean dispatchQueueDelete(QueueDeleteBody body, int channelId) throws AMQException; - public boolean dispatchQueuePurge(QueuePurgeBody body, int channelId) throws AMQException; - public boolean dispatchTxCommit(TxCommitBody body, int channelId) throws AMQException; - public boolean dispatchTxRollback(TxRollbackBody body, int channelId) throws AMQException; - public boolean dispatchTxSelect(TxSelectBody body, int channelId) throws AMQException; - - boolean dispatchQueueUnbind(QueueUnbindBody queueUnbindBody, int channelId) throws AMQException; - - boolean dispatchBasicRecoverSync(BasicRecoverSyncBody basicRecoverSyncBody, int channelId) throws AMQException; - - boolean dispatchConfirmSelect(ConfirmSelectBody confirmSelectBody, int channelId) throws AMQException; -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ServerMethodProcessor.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ServerMethodProcessor.java deleted file mode 100644 index 77b4a1fc6b..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ServerMethodProcessor.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.framing; - -public interface ServerMethodProcessor extends MethodProcessor -{ - void receiveConnectionStartOk(FieldTable clientProperties, - AMQShortString mechanism, - byte[] response, - AMQShortString locale); - - void receiveConnectionSecureOk(byte[] response); - - void receiveConnectionTuneOk(int channelMax, long frameMax, int heartbeat); - - void receiveConnectionOpen(AMQShortString virtualHost, AMQShortString capabilities, boolean insist); - - void receiveChannelOpen(int channelId); - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/TxCommitBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/TxCommitBody.java deleted file mode 100644 index 63c12dffc6..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/TxCommitBody.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; - -public class TxCommitBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 90; - public static final int METHOD_ID = 20; - - public static final TxCommitBody INSTANCE = new TxCommitBody(); - - // Constructor - - - public TxCommitBody() - { - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - - protected int getBodySize() - { - return 0; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchTxCommit(this, channelId); - } - - public String toString() - { - return "[TxCommitBody]"; - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/TxCommitOkBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/TxCommitOkBody.java deleted file mode 100644 index c1a8dd0d23..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/TxCommitOkBody.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; - -public class TxCommitOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 90; - public static final int METHOD_ID = 21; - - public static final TxCommitOkBody INSTANCE = new TxCommitOkBody(); - - // Constructor - private TxCommitOkBody() - { - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - - protected int getBodySize() - { - return 0; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchTxCommitOk(this, channelId); - } - - public String toString() - { - return "[TxCommitOkBody]"; - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/TxRollbackBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/TxRollbackBody.java deleted file mode 100644 index 97ac5ddcba..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/TxRollbackBody.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; - -public class TxRollbackBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 90; - public static final int METHOD_ID = 30; - - public static final TxRollbackBody INSTANCE = new TxRollbackBody(); - - - private TxRollbackBody() - { - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - - protected int getBodySize() - { - return 0; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchTxRollback(this, channelId); - } - - public String toString() - { - return "[TxRollbackBody]"; - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/TxRollbackOkBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/TxRollbackOkBody.java deleted file mode 100644 index d8ab92c1c3..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/TxRollbackOkBody.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; - -public class TxRollbackOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 90; - public static final int METHOD_ID = 31; - - public static final TxRollbackOkBody INSTANCE = new TxRollbackOkBody(); - - // Constructor - - private TxRollbackOkBody() - { - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - - protected int getBodySize() - { - return 0; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchTxRollbackOk(this, channelId); - } - - public String toString() - { - return "[TxRollbackOkBody]"; - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/TxSelectBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/TxSelectBody.java deleted file mode 100644 index 79af85f177..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/TxSelectBody.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; - -public class TxSelectBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 90; - public static final int METHOD_ID = 10; - - public static final TxSelectBody INSTANCE = new TxSelectBody(); - - // Fields declared in specification - - // Constructor - - private TxSelectBody() - { - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - - protected int getBodySize() - { - return 0; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchTxSelect(this, channelId); - } - - public String toString() - { - return "[TxSelectBody]"; - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/TxSelectOkBody.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/TxSelectOkBody.java deleted file mode 100644 index 64c8979deb..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/TxSelectOkBody.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -/* - * This file is auto-generated by Qpid Gentools v.0.1 - do not modify. - * Supported AMQP version: - * 8-0 - */ - -package org.apache.qpid.framing; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.qpid.AMQException; - -public class TxSelectOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody -{ - - public static final int CLASS_ID = 90; - public static final int METHOD_ID = 11; - - public static final TxSelectOkBody INSTANCE = new TxSelectOkBody(); - - private TxSelectOkBody() - { - } - - public int getClazz() - { - return CLASS_ID; - } - - public int getMethod() - { - return METHOD_ID; - } - - - protected int getBodySize() - { - return 0; - } - - public void writeMethodPayload(DataOutput buffer) throws IOException - { - } - - public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException - { - return dispatcher.dispatchTxSelectOk(this, channelId); - } - - public String toString() - { - return "[TxSelectOkBody]"; - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/messaging/Address.java b/qpid/java/common/src/main/java/org/apache/qpid/messaging/Address.java deleted file mode 100644 index 92cf1c91d5..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/messaging/Address.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.messaging; - -import org.apache.qpid.messaging.util.AddressParser; - -import static org.apache.qpid.messaging.util.PyPrint.pprint; - -import java.io.Serializable; -import java.util.Map; - - -/** - * Address - * - */ - -public class Address implements Serializable -{ - - private static final long serialVersionUID = 6096143531336726036L; - - private String _name; - private String _subject; - private Map _options; - private final String _myToString; - - public static Address parse(String address) - { - return new AddressParser(address).parse(); - } - - public Address(String name, String subject, Map options) - { - this._name = name; - this._subject = subject; - this._options = options; - this._myToString = String.format("%s/%s; %s", pprint(_name), pprint(_subject), pprint(_options)); - } - - public String getName() - { - return _name; - } - - public String getSubject() - { - return _subject; - } - - public Map getOptions() - { - return _options; - } - - public String toString() - { - return _myToString; - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/AddressParser.java b/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/AddressParser.java deleted file mode 100644 index 4e3782673c..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/AddressParser.java +++ /dev/null @@ -1,422 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.messaging.util; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -import org.apache.qpid.configuration.ClientProperties; -import org.apache.qpid.messaging.Address; - - -/** - * AddressParser - * - */ - -public class AddressParser extends Parser -{ - - private static Lexicon lxi = new Lexicon(); - - private static Token.Type LBRACE = lxi.define("LBRACE", "\\{"); - private static Token.Type RBRACE = lxi.define("RBRACE", "\\}"); - private static Token.Type LBRACK = lxi.define("LBRACK", "\\["); - private static Token.Type RBRACK = lxi.define("RBRACK", "\\]"); - private static Token.Type COLON = lxi.define("COLON", ":"); - private static Token.Type SEMI = lxi.define("SEMI", ";"); - private static Token.Type SLASH = lxi.define("SLASH", "/"); - private static Token.Type COMMA = lxi.define("COMMA", ","); - private static Token.Type NUMBER = lxi.define("NUMBER", "[+-]?[0-9]*\\.?[0-9]+"); - private static Token.Type TRUE = lxi.define("TRUE", "True"); - private static Token.Type FALSE = lxi.define("FALSE", "False"); - private static Token.Type ID = lxi.define("ID", "[a-zA-Z_](?:[a-zA-Z0-9_-]*[a-zA-Z0-9_])?"); - private static Token.Type STRING = lxi.define("STRING", "\"(?:[^\\\"]|\\.)*\"|'(?:[^\\']|\\.)*'"); - private static Token.Type ESC = lxi.define("ESC", "\\\\[^ux]|\\\\x[0-9a-fA-F][0-9a-fA-F]|\\\\u[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]"); - private static Token.Type SYM = lxi.define("SYM", "[.#*%@$^!+-]"); - private static Token.Type WSPACE = lxi.define("WSPACE", "[\\s]+"); - private static Token.Type EOF = lxi.eof("EOF"); - - private static Lexer LEXER = lxi.compile(); - - private static final int MAX_CACHED_ENTRIES = Integer.getInteger(ClientProperties.QPID_MAX_CACHED_ADDR_OPTION_STRINGS, - ClientProperties.DEFAULT_MAX_CACHED_ADDR_OPTION_STRINGS); - - // stores address options maps for options strings that we have encountered; using a synchronizedMap wrapper - // in case multiple threads are parsing addresses. - private static Map> optionsMaps = - Collections.synchronizedMap( - new LinkedHashMap>(MAX_CACHED_ENTRIES +1,1.1f,true) - { - @Override - protected boolean removeEldestEntry(Map.Entry> eldest) - { - return size() > MAX_CACHED_ENTRIES; - } - - }); - - public static List lex(String input) - { - return LEXER.lex(input); - } - - static List wlex(String input) - { - List tokens = new ArrayList(); - for (Token t : lex(input)) - { - if (t.getType() != WSPACE) - { - tokens.add(t); - } - } - return tokens; - } - - static String unquote(String st, Token tok) - { - StringBuilder result = new StringBuilder(); - for (int i = 1; i < st.length() - 1; i++) - { - char ch = st.charAt(i); - if (ch == '\\') - { - char code = st.charAt(i+1); - switch (code) - { - case '\n': - break; - case '\\': - result.append('\\'); - break; - case '\'': - result.append('\''); - break; - case '"': - result.append('"'); - break; - case 'a': - result.append((char) 0x07); - break; - case 'b': - result.append((char) 0x08); - break; - case 'f': - result.append('\f'); - break; - case 'n': - result.append('\n'); - break; - case 'r': - result.append('\r'); - break; - case 't': - result.append('\t'); - break; - case 'u': - result.append(decode(st.substring(i+2, i+6))); - i += 4; - break; - case 'v': - result.append((char) 0x0b); - break; - case 'o': - result.append(decode(st.substring(i+2, i+4), 8)); - i += 2; - break; - case 'x': - result.append(decode(st.substring(i+2, i+4))); - i += 2; - break; - default: - throw new ParseError(tok); - } - i += 1; - } - else - { - result.append(ch); - } - } - - return result.toString(); - } - - static char[] decode(String hex) - { - return decode(hex, 16); - } - - static char[] decode(String code, int radix) - { - return Character.toChars(Integer.parseInt(code, radix)); - } - - static String tok2str(Token tok) - { - Token.Type type = tok.getType(); - String value = tok.getValue(); - - if (type == STRING) - { - return unquote(value, tok); - } - else if (type == ESC) - { - if (value.charAt(1) == 'x' || value.charAt(1) == 'u') - { - return new String(decode(value.substring(2))); - } - else - { - return value.substring(1); - } - } - else - { - return value; - } - } - - static Object tok2obj(Token tok) - { - Token.Type type = tok.getType(); - String value = tok.getValue(); - if (type == STRING) - { - return unquote(value, tok); - } - else if (type == NUMBER) - { - if (value.indexOf('.') >= 0) - { - return Double.valueOf(value); - } - else - { - return Integer.decode(value); - } - } - else if (type == TRUE) - { - return true; - } - else if (type == FALSE) - { - return false; - } - else - { - return value; - } - } - - static String toks2str(List toks) - { - if (toks.size() > 0) - { - StringBuilder result = new StringBuilder(); - for (Token t : toks) - { - result.append(tok2str(t)); - } - return result.toString(); - } - else - { - return null; - } - } - - public AddressParser(String input) - { - super(wlex(input)); - } - - public Address parse() - { - Address result = address(); - eat(EOF); - return result; - } - - public Address address() - { - String name = toks2str(eat_until(SLASH, SEMI, EOF)); - - if (name == null) - { - throw new ParseError(next()); - } - - String subject; - if (matches(SLASH)) - { - eat(SLASH); - subject = toks2str(eat_until(SEMI, EOF)); - if ("None".equals(subject)) - { - subject = null; - } - } - else - { - subject = null; - } - - Map options; - if (matches(SEMI)) - { - eat(SEMI); - - // get the remaining string denoting the options and see if we've already encountered an address - // with the same options before - String optionsString = toks2str(remainder()); - Map storedMap = optionsMaps.get(optionsString); - if (storedMap == null) - { - // if these are new options, construct a new map and store it in the encountered collection - options = Collections.unmodifiableMap(map()); - optionsMaps.put(optionsString, options); - } - else - { - // if we already have the map for these options, use the stored map - options = storedMap; - eat_until(EOF); - } - } - else - { - options = null; - } - - return new Address(name, subject, options); - } - - public Map map() - { - eat(LBRACE); - - Map result = new HashMap(); - while (true) - { - if (matches(NUMBER, STRING, ID, LBRACE, LBRACK)) - { - keyval(result); - if (matches(COMMA)) - { - eat(COMMA); - } - else if (matches(RBRACE)) - { - break; - } - else - { - throw new ParseError(next(), COMMA, RBRACE); - } - } - else if (matches(RBRACE)) - { - break; - } - else - { - throw new ParseError(next(), NUMBER, STRING, ID, LBRACE, LBRACK, - RBRACE); - } - } - - eat(RBRACE); - return result; - } - - void keyval(Map map) - { - Object key = value(); - eat(COLON); - Object val = value(); - map.put(key, val); - } - - Object value() - { - if (matches(NUMBER, STRING, ID, TRUE, FALSE)) - { - return tok2obj(eat()); - } - else if (matches(LBRACE)) - { - return map(); - } - else if (matches(LBRACK)) - { - return list(); - } - else - { - throw new ParseError(next(), NUMBER, STRING, ID, LBRACE, LBRACK); - } - } - - List list() - { - eat(LBRACK); - - List result = new ArrayList(); - - while (true) - { - if (matches(RBRACK)) - { - break; - } - else - { - result.add(value()); - if (matches(COMMA)) - { - eat(COMMA); - } - else if (matches(RBRACK)) - { - break; - } - else - { - throw new ParseError(next(), COMMA, RBRACK); - } - } - } - - eat(RBRACK); - return result; - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/JAddr.java b/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/JAddr.java deleted file mode 100644 index c5c2cacd1a..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/JAddr.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.messaging.util; - -import org.apache.qpid.messaging.Address; - -import static org.apache.qpid.messaging.util.PyPrint.pprint; - -import java.io.InputStreamReader; -import java.util.List; - - -/** - * JAddr - * - */ - -public class JAddr -{ - private JAddr() - { - } - - public static final void main(String[] args) throws Exception - { - StringBuilder addr = new StringBuilder(); - InputStreamReader reader = new InputStreamReader(System.in); - - char[] buf = new char[1024]; - while (true) - { - int n = reader.read(buf, 0, buf.length); - if (n < 0) - { - break; - } - addr.append(buf, 0, n); - } - - if ("parse".equals(args[0])) - { - try - { - Address address = Address.parse(addr.toString()); - System.out.println(pprint_address(address)); - } - catch (ParseError e) - { - System.out.println(String.format("ERROR: %s", e.getMessage())); - } - } - else - { - List tokens = AddressParser.lex(addr.toString()); - for (Token t : tokens) - { - String value = t.getValue(); - if (value != null) - { - value = value.replace("\\", "\\\\").replace("\n", "\\n"); - System.out.println(String.format("%s:%s:%s", t.getType(), t.getPosition(), value)); - } - else - { - System.out.println(String.format("%s:%s", t.getType(), t.getPosition())); - } - } - } - } - - private static String pprint_address(Address addr) - { - return String.format("NAME: %s\nSUBJECT: %s\nOPTIONS: %s", - pprint(addr.getName()), - pprint(addr.getSubject()), - pprint(addr.getOptions())); - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/LexError.java b/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/LexError.java deleted file mode 100644 index b8d346dca4..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/LexError.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.messaging.util; - - -/** - * LexError - * - */ - -public class LexError extends RuntimeException -{ - - public LexError(String msg) - { - super(msg); - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/Lexer.java b/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/Lexer.java deleted file mode 100644 index 9638ec78e2..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/Lexer.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.messaging.util; - -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - - -/** - * Lexer - * - */ - -public class Lexer -{ - - private List types; - private Token.Type eof; - private Pattern rexp; - - public Lexer(List types, Token.Type eof, Pattern rexp) - { - this.types = types; - this.eof = eof; - this.rexp = rexp; - } - - public List lex(final String st) - { - List tokens = new ArrayList(); - - int position = 0; - Matcher m = rexp.matcher(st); - OUTER: while (position < st.length()) - { - m.region(position, st.length()); - if (m.lookingAt()) - { - for (int i = 1; i <= m.groupCount(); i++) - { - String value = m.group(i); - if (value != null) - { - tokens.add(new Token(types.get(i-1), value, st, m.start(i))); - position = m.end(i); - continue OUTER; - } - } - throw new RuntimeException("no group matched"); - } - else - { - throw new LexError("unrecognized characters line:" + LineInfo.get(st, position)); - } - } - - tokens.add(new Token(eof, null, st, position)); - - return tokens; - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/Lexicon.java b/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/Lexicon.java deleted file mode 100644 index 9ab610f37a..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/Lexicon.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.messaging.util; - -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Pattern; - - -/** - * Lexicon - * - */ - -public class Lexicon -{ - - private List types; - private Token.Type eof; - - public Lexicon() - { - this.types = new ArrayList(); - this.eof = null; - } - - public Token.Type define(String name, String pattern) - { - Token.Type t = new Token.Type(name, pattern); - types.add(t); - return t; - } - - public Token.Type eof(String name) - { - Token.Type t = new Token.Type(name, null); - eof = t; - return t; - } - - public Lexer compile() - { - StringBuilder joined = new StringBuilder(); - for (Token.Type t : types) - { - if (joined.length() > 0) - { - joined.append('|'); - } - joined.append('(').append(t.getPattern()).append(')'); - } - Pattern rexp = Pattern.compile(joined.toString()); - return new Lexer(new ArrayList(types), eof, rexp); - } - - public static final void main(String[] args) - { - StringBuilder input = new StringBuilder(); - for (String a : args) - { - if (input.length() > 0) - { - input.append(" "); - } - - input.append(a); - } - - Lexicon lxi = new Lexicon(); - lxi.define("FOR", "for"); - lxi.define("IF", "if"); - lxi.define("LPAREN", "\\("); - lxi.define("RPAREN", "\\)"); - lxi.define("ID", "[\\S]+"); - lxi.define("WSPACE", "[\\s]+"); - lxi.eof("EOF"); - Lexer lx = lxi.compile(); - - for (Token t : lx.lex(input.toString())) - { - System.out.println(t); - } - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/LineInfo.java b/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/LineInfo.java deleted file mode 100644 index 4952fc38a3..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/LineInfo.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.messaging.util; - - -/** - * LineInfo - * - */ - -public class LineInfo -{ - - public static LineInfo get(String st, int position) - { - int idx = 0; - int line = 1; - int column = 0; - int line_pos = 0; - while (idx < position) - { - if (st.charAt(idx) == '\n') - { - line += 1; - column = 0; - line_pos = idx; - } - - column += 1; - idx += 1; - } - - int end = st.indexOf('\n', line_pos); - if (end < 0) - { - end = st.length(); - } - - String text = st.substring(line_pos, end); - - return new LineInfo(line, column, text); - } - - private int line; - private int column; - private String text; - - public LineInfo(int line, int column, String text) - { - this.line = line; - this.column = column; - this.text = text; - } - - public int getLine() - { - return line; - } - - public int getColumn() - { - return column; - } - - public String getText() - { - return text; - } - - public String toString() - { - return String.format("%s,%s:%s", line, column, text); - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/ParseError.java b/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/ParseError.java deleted file mode 100644 index ce758e15fa..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/ParseError.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.messaging.util; - -import org.apache.qpid.util.Strings; - - -/** - * ParseError - * - */ - -public class ParseError extends RuntimeException -{ - - private static String msg(Token token, Token.Type ... expected) - { - LineInfo li = token.getLineInfo(); - String exp = Strings.join(", ", expected); - if (expected.length > 1) - { - exp = String.format("(%s)", exp); - } - - if (expected.length > 0) - { - return String.format("expecting %s, got %s line:%s", exp, token, li); - } - else - { - return String.format("unexpected token %s line:%s", token, li); - } - } - - public ParseError(Token token, Token.Type ... expected) - { - super(msg(token, expected)); - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/Parser.java b/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/Parser.java deleted file mode 100644 index 3019326963..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/Parser.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.messaging.util; - -import java.util.ArrayList; -import java.util.List; - - -/** - * Parser - * - */ - -class Parser -{ - - private List tokens; - private int idx = 0; - - Parser(List tokens) - { - this.tokens = tokens; - this.idx = 0; - } - - Token next() - { - return tokens.get(idx); - } - - boolean matches(Token.Type ... types) - { - for (Token.Type t : types) - { - if (next().getType() == t) - { - return true; - } - } - return false; - } - - Token eat(Token.Type ... types) - { - if (types.length > 0 && !matches(types)) - { - throw new ParseError(next(), types); - } - else - { - Token t = next(); - idx += 1; - return t; - } - } - - List eat_until(Token.Type ... types) - { - List result = new ArrayList(); - while (!matches(types)) - { - result.add(eat()); - } - return result; - } - - /** - * Returns the remaining list of tokens, without eating them - */ - List remainder() - { - List result = new ArrayList(); - for (int i = idx; i < tokens.size(); i++) - { - result.add(tokens.get(i)); - } - return result; - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/PyPrint.java b/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/PyPrint.java deleted file mode 100644 index 2681893482..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/PyPrint.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.messaging.util; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; - - -/** - * PyPrint - * - */ - -public class PyPrint -{ - private PyPrint() - { - } - - public static String pprint(Object obj) - { - if (obj instanceof Map) - { - return pprint_map((Map) obj); - } - else if (obj instanceof List) - { - return pprint_list((List) obj); - } - else if (obj instanceof String) - { - return pprint_string((String) obj); - } - else if (obj instanceof Boolean) - { - return ((Boolean) obj).booleanValue() ? "True" : "False"; - } - else if (obj == null) - { - return "None"; - } - else - { - return obj.toString(); - } - } - - private static String indent(String st) - { - return " " + st.replace("\n", "\n "); - } - - private static String pprint_map(Map map) - { - List items = new ArrayList(); - for (Map.Entry me : map.entrySet()) - { - items.add(String.format("%s: %s", pprint(me.getKey()), - pprint(me.getValue()))); - } - Collections.sort(items); - return pprint_items("{", items, "}"); - } - - private static String pprint_list(List list) - { - List items = new ArrayList(); - for (Object o : list) - { - items.add(pprint(o)); - } - return pprint_items("[", items, "]"); - } - - private static String pprint_items(String start, List items, - String end) - { - StringBuilder result = new StringBuilder(); - for (String item : items) - { - if (result.length() > 0) - { - result.append(",\n"); - } - result.append(indent(item)); - } - - if (result.length() > 0) - { - return String.format("%s\n%s\n%s", start, result, end); - } - else - { - return String.format("%s%s", start, end); - } - } - - private static String pprint_string(String st) - { - StringBuilder result = new StringBuilder(); - result.append('\''); - for (int i = 0; i < st.length(); i++) - { - char c = st.charAt(i); - switch (c) - { - case '\'': - result.append("\\'"); - break; - case '\n': - result.append("\\n"); - break; - default: - if (c >= 0x80) - { - result.append(String.format("\\u%04x", (int)c)); - } - else - { - result.append(c); - } - break; - } - } - result.append('\''); - return result.toString(); - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/Token.java b/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/Token.java deleted file mode 100644 index b9458d7997..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/messaging/util/Token.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.messaging.util; - - -/** - * Token - * - */ - -public class Token -{ - - public static class Type - { - - private String name; - private String pattern; - - Type(String name, String pattern) - { - this.name = name; - this.pattern = pattern; - } - - public String getName() - { - return name; - } - - public String getPattern() - { - return pattern; - } - - public String toString() - { - return name; - } - - } - - private Type type; - private String value; - private String input; - private int position; - - Token(Type type, String value, String input, int position) - { - this.type = type; - this.value = value; - this.input = input; - this.position = position; - } - - public Type getType() - { - return type; - } - - public String getValue() - { - return value; - } - - public int getPosition() - { - return position; - } - - public LineInfo getLineInfo() - { - return LineInfo.get(input, position); - } - - public String toString() - { - if (value == null) - { - return type.toString(); - } - else - { - return String.format("%s(%s)", type, value); - } - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/pool/ReferenceCountingExecutorService.java b/qpid/java/common/src/main/java/org/apache/qpid/pool/ReferenceCountingExecutorService.java deleted file mode 100644 index c9fbd824c5..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/pool/ReferenceCountingExecutorService.java +++ /dev/null @@ -1,187 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.pool; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - - -/** - * ReferenceCountingExecutorService wraps an ExecutorService in order to provide shared reference to it. It counts - * the references taken, instantiating the service on the first reference, and shutting it down when the last - * reference is released. - * - *

It is important to ensure that an executor service is correctly shut down as failing to do so prevents the JVM - * from terminating due to the existence of non-daemon threads. - * - *

- * TODO Might be more elegant to make this actually implement ExecutorService, providing better hiding of the - * implementation details. Also this class introduces a pattern (albeit specific to this usage) that could be - * generalized to reference count anything. That is, on first instance call a create method, on release of last - * instance call a destroy method. This could definitely be abstracted out as a re-usable piece of code; a - * reference counting factory. It could then be re-used to do reference counting in other places (such as - * messages). Countable objects have a simple create/destroy life cycle, capturable by an interface that the - * ref counting factory can call to manage the lifecycle. - *

- * TODO The {@link #getPool()} method breaks the encapsulation of the reference counter. Generally when getPool is used - * further checks are applied to ensure that the executor service has not been shutdown. This passes responsibility - * for managing the lifecycle of the reference counted object onto the caller rather than neatly encapsulating it - * here. Could think about adding more state to the lifecycle, to mark ref counted objects as invalid, and have an - * isValid method, or could make calling code deal with RejectedExecutionException raised by shutdown executors. - */ -public class ReferenceCountingExecutorService -{ - - - /** Defines the smallest thread pool that will be allocated, irrespective of the number of processors. */ - private static final int MINIMUM_POOL_SIZE = 4; - - /** Holds the number of processors on the machine. */ - private static final int NUM_CPUS = Runtime.getRuntime().availableProcessors(); - - /** Defines the thread pool size to use, which is the larger of the number of CPUs or the minimum size. */ - private static final int DEFAULT_POOL_SIZE = Math.max(NUM_CPUS, MINIMUM_POOL_SIZE); - - /** - * Holds the singleton instance of this reference counter. This is only created once, statically, so the - * {@link #getInstance()} method does not need to be synchronized. - */ - private static final ReferenceCountingExecutorService _instance = new ReferenceCountingExecutorService(); - - /** This lock is used to ensure that reference counts are updated atomically with create/destroy operations. */ - private final Object _lock = new Object(); - - /** The shared executor service that is reference counted. */ - private ExecutorService _pool; - - /** Holds the number of references given out to the executor service. */ - private int _refCount = 0; - - /** Holds the number of executor threads to create. */ - private int _poolSize = Integer.getInteger("amqj.read_write_pool_size", DEFAULT_POOL_SIZE); - - /** Thread Factory used to create thread of the pool. */ - private ThreadFactory _threadFactory = new SuppressingInheritedAccessControlContextThreadFactory(); - - /** - * Retrieves the singleton instance of this reference counter. - * - * @return The singleton instance of this reference counter. - */ - public static ReferenceCountingExecutorService getInstance() - { - return _instance; - } - - /** - * Private constructor to ensure that only a singleton instance can be created. - */ - private ReferenceCountingExecutorService() - { } - - /** - * Provides a reference to a shared executor service, incrementing the reference count. - * - * @return An executor service. - */ - public ExecutorService acquireExecutorService() - { - synchronized (_lock) - { - if (_refCount++ == 0) - { - _pool = new ThreadPoolExecutor(_poolSize, _poolSize, - 0L, TimeUnit.MILLISECONDS, - new LinkedBlockingQueue(), - _threadFactory); - } - - return _pool; - } - } - - /** - * Releases a reference to a shared executor service, decrementing the reference count. If the reference count falls - * to zero, the executor service is shut down. - */ - public void releaseExecutorService() - { - synchronized (_lock) - { - if (--_refCount == 0) - { - _pool.shutdownNow(); - } - } - } - - /** - * Provides access to the executor service, without touching the reference count. - * - * @return The shared executor service, or null if none has been instantiated yet. - */ - public ExecutorService getPool() - { - return _pool; - } - - /** - * Return the ReferenceCount to this ExecutorService - * @return reference count - */ - public int getReferenceCount() - { - return _refCount; - } - - /** - * - * Return the thread factory used by the {@link ThreadPoolExecutor} to create new threads. - * - * @return thread factory - */ - public ThreadFactory getThreadFactory() - { - return _threadFactory; - } - - /** - * Sets the thread factory used by the {@link ThreadPoolExecutor} to create new threads. - *

- * If the pool has been already created, the change will have no effect until - * {@link #getReferenceCount()} reaches zero and the pool recreated. For this reason, - * callers must invoke this method before calling {@link #acquireExecutorService()}. - * - * @param threadFactory thread factory - */ - public void setThreadFactory(final ThreadFactory threadFactory) - { - if (threadFactory == null) - { - throw new NullPointerException("threadFactory cannot be null"); - } - _threadFactory = threadFactory; - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/pool/SuppressingInheritedAccessControlContextThreadFactory.java b/qpid/java/common/src/main/java/org/apache/qpid/pool/SuppressingInheritedAccessControlContextThreadFactory.java deleted file mode 100644 index 37ce8f5d67..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/pool/SuppressingInheritedAccessControlContextThreadFactory.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.pool; - - -import javax.security.auth.Subject; -import java.security.PrivilegedAction; -import java.util.concurrent.Executors; -import java.util.concurrent.ThreadFactory; - -/** - * ThreadFactory to create threads with empty inherited java.security.AccessControlContext - *

- * It delegates thread creation to Executors default thread factory. - */ -public class SuppressingInheritedAccessControlContextThreadFactory implements ThreadFactory -{ - private final ThreadFactory _defaultThreadFactory = Executors.defaultThreadFactory(); - - @Override - public Thread newThread(final Runnable runnable) - { - return Subject.doAsPrivileged(null, new PrivilegedAction() - { - @Override - public Thread run() - { - return _defaultThreadFactory.newThread(runnable); - } - }, null); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java b/qpid/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java deleted file mode 100644 index 3569b4b460..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - * - */ -package org.apache.qpid.properties; - -import org.apache.qpid.transport.util.Logger; -import org.apache.qpid.util.SystemUtils; - -/** - * Constants for the various properties clients can - * set values for during the ConnectionStartOk reply. - */ -public class ConnectionStartProperties -{ - private static final Logger LOGGER = Logger.get(ConnectionStartProperties.class); - - /** - * Used for 0-8/0-9/0-9-1 connections to choose to close - * the connection when a transactional session receives a 'mandatory' message which - * can't be routed rather than returning the message. - */ - public static final String QPID_CLOSE_WHEN_NO_ROUTE = "qpid.close_when_no_route"; - - public static final String QPID_MESSAGE_COMPRESSION_SUPPORTED = "qpid.message_compression_supported"; - - - public static final String CLIENT_ID_0_10 = "clientName"; - public static final String CLIENT_ID_0_8 = "instance"; - - public static final String VERSION_0_8 = "version"; - public static final String VERSION_0_10 = "qpid.client_version"; - - public static final String PROCESS = "qpid.client_process"; - - public static final String PID = "qpid.client_pid"; - - public static final String PLATFORM = "platform"; - - public static final String PRODUCT ="product"; - - public static final String SESSION_FLOW = "qpid.session_flow"; - - public static final String QPID_CONFIRMED_PUBLISH_SUPPORTED = "qpid.confirmed_publish_supported"; - - public static final int _pid; - - public static final String _platformInfo; - - static - { - - _pid = SystemUtils.getProcessPidAsInt(); - - if (_pid == -1) - { - LOGGER.warn("Unable to get the process's PID"); - } - - StringBuilder fullSystemInfo = new StringBuilder(System.getProperty("java.runtime.name")); - fullSystemInfo.append(", "); - fullSystemInfo.append(System.getProperty("java.runtime.version")); - fullSystemInfo.append(", "); - fullSystemInfo.append(System.getProperty("java.vendor")); - fullSystemInfo.append(", "); - fullSystemInfo.append(SystemUtils.getOSArch()); - fullSystemInfo.append(", "); - fullSystemInfo.append(SystemUtils.getOSName()); - fullSystemInfo.append(", "); - fullSystemInfo.append(SystemUtils.getOSVersion()); - fullSystemInfo.append(", "); - fullSystemInfo.append(System.getProperty("sun.os.patch.level")); - - _platformInfo = fullSystemInfo.toString(); - } - - public static int getPID() - { - return _pid; - } - - public static String getPlatformInfo() - { - return _platformInfo; - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQConstant.java b/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQConstant.java deleted file mode 100644 index 5e39409382..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQConstant.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.protocol; - -import org.apache.qpid.framing.AMQShortString; - -import java.util.HashMap; -import java.util.Map; - -/** - * Defines constants for AMQP codes and also acts as a factory for creating such constants from the raw codes. Each - * constant also defines a short human readable description of the constant. - *

- * TODO Why would a constant be defined that is not in the map? Seems more natural that getConstant should raise an - * exception for an unknown constant. Or else provide an explanation of why this is so. Also, there is no way for - * callers to determine the unknown status of a code except by comparing its name to "unknown code", which would - * seem to render this scheme a little bit pointless? - *

- * TODO Java has a nice enum construct for doing this sort of thing. Maybe this is done in the old style for Java 1.4 - * backward compatability? Now that is handled through retrotranslater it may be time to use enum. - */ -public final class AMQConstant -{ - /** Defines a map from codes to constants. */ - private static Map _codeMap = new HashMap(); - - /** Indicates that the method completed successfully. */ - public static final AMQConstant REPLY_SUCCESS = new AMQConstant(200, "reply success", true); - - public static final AMQConstant FRAME_END = new AMQConstant(206, "frame end", true); - - /** - * The client asked for a specific message that is no longer available. The message was delivered to another - * client, or was purged from the queue for some other reason. - */ - public static final AMQConstant NOT_DELIVERED = new AMQConstant(310, "not delivered", true); - - /** - * The client attempted to transfer content larger than the server could accept at the present time. The client - * may retry at a later time. - */ - public static final AMQConstant MESSAGE_TOO_LARGE = new AMQConstant(311, "message too large", true); - - /** - * When the exchange cannot route the result of a .Publish, most likely due to an invalid routing key. Only when - * the mandatory flag is set. - */ - public static final AMQConstant NO_ROUTE = new AMQConstant(312, "no route", true); - - /** - * When the exchange cannot deliver to a consumer when the immediate flag is set. As a result of pending data on - * the queue or the absence of any consumers of the queue. - */ - public static final AMQConstant NO_CONSUMERS = new AMQConstant(313, "no consumers", true); - - /** - * An operator intervened to close the connection for some reason. The client may retry at some later date. - */ - public static final AMQConstant CONNECTION_FORCED = new AMQConstant(320, "connection forced", true); - - /** The client tried to work with an unknown virtual host or cluster. */ - public static final AMQConstant INVALID_PATH = new AMQConstant(402, "invalid path", true); - - /** The client attempted to work with a server entity to which it has no access due to security settings. */ - public static final AMQConstant ACCESS_REFUSED = new AMQConstant(403, "access refused", true); - - /** The client attempted to work with a server entity that does not exist. */ - public static final AMQConstant NOT_FOUND = new AMQConstant(404, "not found", true); - - /** - * The client attempted to work with a server entity to which it has no access because another client is - * working with it. - */ - public static final AMQConstant ALREADY_EXISTS = new AMQConstant(405, "Already exists", true); - - /** The client requested a method that was not allowed because some precondition failed. */ - public static final AMQConstant IN_USE = new AMQConstant(406, "In use", true); - - public static final AMQConstant INVALID_ROUTING_KEY = new AMQConstant(407, "routing key invalid", true); - - public static final AMQConstant REQUEST_TIMEOUT = new AMQConstant(408, "Request Timeout", true); - - public static final AMQConstant ARGUMENT_INVALID = new AMQConstant(409, "argument invalid", true); - - /** - * The client sent a malformed frame that the server could not decode. This strongly implies a programming error - * in the client. - */ - public static final AMQConstant FRAME_ERROR = new AMQConstant(501, "frame error", true); - - /** - * The client sent a frame that contained illegal values for one or more fields. This strongly implies a - * programming error in the client. - */ - public static final AMQConstant SYNTAX_ERROR = new AMQConstant(502, "syntax error", true); - - /** - * The client sent an invalid sequence of frames, attempting to perform an operation that was considered invalid - * by the server. This usually implies a programming error in the client. - */ - public static final AMQConstant COMMAND_INVALID = new AMQConstant(503, "command invalid", true); - - /** - * The client attempted to work with a channel that had not been correctly opened. This most likely indicates a - * fault in the client layer. - */ - public static final AMQConstant CHANNEL_ERROR = new AMQConstant(504, "channel error", true); - - /** - * The server could not complete the method because it lacked sufficient resources. This may be due to the client - * creating too many of some type of entity. - */ - public static final AMQConstant RESOURCE_ERROR = new AMQConstant(506, "resource error", true); - - /** - * The client tried to work with some entity in a manner that is prohibited by the server, due to security settings - * or by some other criteria. - */ - public static final AMQConstant NOT_ALLOWED = new AMQConstant(530, "not allowed", true); - - /** The client tried to use functionality that is not implemented in the server. */ - public static final AMQConstant NOT_IMPLEMENTED = new AMQConstant(540, "not implemented", true); - - /** - * The server could not complete the method because of an internal error. The server may require intervention by - * an operator in order to resume normal operations. - */ - public static final AMQConstant INTERNAL_ERROR = new AMQConstant(541, "internal error", true); - - public static final AMQConstant FRAME_MIN_SIZE = new AMQConstant(4096, "frame min size", true); - - public static final AMQConstant INVALID_ARGUMENT = new AMQConstant(542, "invalid argument", true); - /** - * The client imp does not support the protocol version - */ - public static final AMQConstant UNSUPPORTED_CLIENT_PROTOCOL_ERROR = new AMQConstant(543, "client unsupported protocol", true); - - /** The AMQP status code. */ - private int _code; - - /** A short description of the status code. */ - private AMQShortString _name; - - /** - * Creates a new AMQP status code. - * - * @param code The code. - * @param name A short description of the code. - * @param map true to register the code as a known code, false otherwise. - */ - private AMQConstant(int code, String name, boolean map) - { - _code = code; - _name = new AMQShortString(name); - if (map) - { - _codeMap.put(Integer.valueOf(code), this); - } - } - - /** - * Creates a constant for a status code by looking up the code in the map of known codes. If the code is not known - * a constant is still created for it, but it is marked as unknown. - * - * @param code The AMQP status code. - * - * @return The AMQP status code encapsulated as a constant. - */ - public static AMQConstant getConstant(int code) - { - AMQConstant c = _codeMap.get(Integer.valueOf(code)); - if (c == null) - { - c = new AMQConstant(code, "unknown code", false); - } - - return c; - } - - /** - * Gets the underlying AMQP status code. - * - * @return The AMQP status code. - */ - public int getCode() - { - return _code; - } - - /** - * Gets a short description of the status code. - * - * @return A short description of the status code. - */ - public AMQShortString getName() - { - return _name; - } - - /** - * Renders the constant as a string, mainly for debugging purposes. - * - * @return The status code and its description. - */ - public String toString() - { - return _code + ": " + _name; - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQMethodEvent.java b/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQMethodEvent.java deleted file mode 100644 index 9b38f7926b..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQMethodEvent.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.protocol; - -import org.apache.qpid.framing.AMQMethodBody; - -/** - * AMQMethodEvent encapsulates an AMQP method call, and the channel on which that method call occurred. - * - *

Supplies the: - *

    - *
  • channel id
  • - *
  • protocol method
  • - *
- * - *

As the event contains the context in which it occurred, event listeners do not need to be statefull. - * to listeners. Events are often handled by {@link AMQMethodListener}s. - */ -public class AMQMethodEvent -{ - /** Holds the method call. */ - private final M _method; - - /** Holds the channel handle for the method call. */ - private final int _channelId; - - /** - * Creates a method event to encasulate a method call and channel. - * - * @param channelId The channel on which the method call occurred. - * @param method The method call. - */ - public AMQMethodEvent(int channelId, M method) - { - _channelId = channelId; - _method = method; - } - - /** - * Gets the method call. - * - * @return The method call. - */ - public M getMethod() - { - return _method; - } - - /** - * Gets the channel handle for the method call. - * - * @return The channel handle for the method call. - */ - public int getChannelId() - { - return _channelId; - } - - /** - * Prints the method call as a string, mainly for debugging purposes. - * - * @return The method call as a string, mainly for debugging purposes. - */ - public String toString() - { - StringBuilder buf = new StringBuilder("Method event: "); - buf.append("\nChannel id: ").append(_channelId); - buf.append("\nMethod: ").append(_method); - - return buf.toString(); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQMethodListener.java b/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQMethodListener.java deleted file mode 100644 index 3e7c67493d..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQMethodListener.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.protocol; - -import org.apache.qpid.AMQException; -import org.apache.qpid.framing.AMQMethodBody; - -/** - * AMQMethodListener is a listener that receives notifications of AMQP methods. The methods are packaged as events in - * {@link AMQMethodEvent}. - * - *

An event listener may be associated with a particular context, usually an AMQP channel, and in addition to - * receiving method events will be notified of errors on that context. This enables listeners to perform any clean - * up that they need to do before the context is closed or retried. - *

- * TODO Document why the exception is passed to the error method. Is it so that the exception can be passed - * from the event handling thread to another thread and rethown from there? It is unusual to pass exceptions as - * method arguments, because they have their own mechanism for propagating through the call stack, so some - * explanation ought to be provided. - */ -public interface AMQMethodListener -{ - /** - * Notifies the listener that an AMQP method event has occurred. - * - * @param evt The AMQP method event (contains the method and channel). - * - * @return true if the handler processes the method frame, false otherwise. Note that this does - * not prohibit the method event being delivered to subsequent listeners but can be used to determine if - * nobody has dealt with an incoming method frame. - * - * @throws AMQException if an error has occurred. This exception may be delivered to all registered listeners using - * the error() method (see below) allowing them to perform cleanup if necessary. - *

- * TODO Consider narrowing the exception. - */ - boolean methodReceived(AMQMethodEvent evt) throws AMQException; - - /** - * Notifies the listener of an error on the event context to which it is listening. The listener should perform - * any necessary clean-up for the context. - * - * @param e The underlying exception that is the source of the error. - */ - void error(Exception e); -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQProtocolWriter.java b/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQProtocolWriter.java deleted file mode 100644 index 0a050becdc..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQProtocolWriter.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.protocol; - -import org.apache.qpid.framing.AMQDataBlock; - -/** - * AMQProtocolWriter provides a method to write a frame of data 'to the wire', in the context of the object - * that implements the method, usually some sort of session. The block of data, encapsulated by {@link AMQDataBlock}, - * will be encoded as it is written. - */ -public interface AMQProtocolWriter -{ - /** - * Writes a frame to the wire, encoding it as necessary, for example, into a sequence of bytes. - * - * @param frame The frame to be encoded and written. - */ - public void writeFrame(AMQDataBlock frame); -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQVersionAwareProtocolSession.java b/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQVersionAwareProtocolSession.java deleted file mode 100644 index 73c8653677..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQVersionAwareProtocolSession.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.protocol; - -import org.apache.qpid.AMQException; -import org.apache.qpid.framing.AMQMethodBody; -import org.apache.qpid.framing.ContentBody; -import org.apache.qpid.framing.ContentHeaderBody; -import org.apache.qpid.framing.HeartbeatBody; -import org.apache.qpid.framing.MethodRegistry; -import org.apache.qpid.transport.ByteBufferSender; - - -/** - * AMQVersionAwareProtocolSession is implemented by all AMQP session classes, that need to provide an awareness to - * callers of the version of the AMQP protocol that they are able to work with. - *

- * TODO Why is this a seperate interface to {@link ProtocolVersionAware}, could they be combined into a single - * interface and one of them eliminated? Move getRegistry method to ProtocolVersionAware, make the sessions - * implement AMQProtocolWriter directly and drop this interface. - */ -public interface AMQVersionAwareProtocolSession extends AMQProtocolWriter, ProtocolVersionAware -{ - /** - * Gets the method registry for a specific version of the AMQP. - * - * @return The method registry for a specific version of the AMQP. - */ - - MethodRegistry getMethodRegistry(); - - - public void methodFrameReceived(int channelId, AMQMethodBody body) throws AMQException; - public void contentHeaderReceived(int channelId, ContentHeaderBody body) throws AMQException; - public void contentBodyReceived(int channelId, ContentBody body) throws AMQException; - public void heartbeatBodyReceived(int channelId, HeartbeatBody body) throws AMQException; - - - public void setSender(ByteBufferSender sender); - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/protocol/ProtocolEngine.java b/qpid/java/common/src/main/java/org/apache/qpid/protocol/ProtocolEngine.java deleted file mode 100644 index f73f6d931a..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/protocol/ProtocolEngine.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.protocol; - -import java.net.SocketAddress; - -import org.apache.qpid.transport.ByteBufferReceiver; -import org.apache.qpid.transport.ByteBufferSender; -import org.apache.qpid.transport.network.NetworkConnection; -import org.apache.qpid.transport.network.TransportActivity; - -/** - * A ProtocolEngine is a Receiver for java.nio.ByteBuffers. It takes the data passed to it in the received - * decodes it and then process the result. - */ -public interface ProtocolEngine extends ByteBufferReceiver, TransportActivity -{ - // Returns the remote address of the NetworkDriver - SocketAddress getRemoteAddress(); - - // Returns the local address of the NetworkDriver - SocketAddress getLocalAddress(); - - // Returns number of bytes written - long getWrittenBytes(); - - // Returns number of bytes read - long getReadBytes(); - - // Called by the NetworkDriver when the socket has been closed for reading - void closed(); - - // Called when the NetworkEngine has not written data for the specified period of time (will trigger a - // heartbeat) - void writerIdle(); - - // Called when the NetworkEngine has not read data for the specified period of time (will close the connection) - void readerIdle(); - - void encryptedTransport(); - - public void setNetworkConnection(NetworkConnection network, ByteBufferSender sender); - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/protocol/ProtocolEngineFactory.java b/qpid/java/common/src/main/java/org/apache/qpid/protocol/ProtocolEngineFactory.java deleted file mode 100644 index 50448f1fe1..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/protocol/ProtocolEngineFactory.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.protocol; - -import java.net.SocketAddress; - -public interface ProtocolEngineFactory -{ - - // Returns a new instance of a ProtocolEngine - ProtocolEngine newProtocolEngine(final SocketAddress remoteSocketAddress); - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/protocol/ProtocolVersionAware.java b/qpid/java/common/src/main/java/org/apache/qpid/protocol/ProtocolVersionAware.java deleted file mode 100644 index f12cd9af8e..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/protocol/ProtocolVersionAware.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.protocol; - -import org.apache.qpid.framing.ProtocolVersion; - -/** - * ProtocolVersionAware is implemented by all AMQP handling classes, that need to provide an awareness to callers of - * the version of the AMQP protocol that they are able to handle. - */ -public interface ProtocolVersionAware -{ - /** - * @deprecated - * Reports the AMQP minor version, that the implementer can handle. - * - * @return The AMQP minor version. - */ - public byte getProtocolMinorVersion(); - - /** - * @deprecated - * Reports the AMQP major version, that the implementer can handle. - * - * @return The AMQP major version. - */ - public byte getProtocolMajorVersion(); - - public ProtocolVersion getProtocolVersion(); -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/ssl/SSLContextFactory.java b/qpid/java/common/src/main/java/org/apache/qpid/ssl/SSLContextFactory.java deleted file mode 100644 index e9dec362a6..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/ssl/SSLContextFactory.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.ssl; - -import org.apache.qpid.transport.network.security.ssl.QpidClientX509KeyManager; -import org.apache.qpid.transport.network.security.ssl.QpidMultipleTrustManager; -import org.apache.qpid.transport.network.security.ssl.SSLUtil; - -import javax.net.ssl.KeyManager; -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.SSLContext; -import javax.net.ssl.TrustManager; -import javax.net.ssl.TrustManagerFactory; -import javax.net.ssl.X509TrustManager; - -import java.io.IOException; -import java.security.GeneralSecurityException; -import java.security.KeyStore; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; - -/** - * Factory used to create SSLContexts. SSL needs to be configured - * before this will work. - * - */ -public class SSLContextFactory -{ - public static final String TRANSPORT_LAYER_SECURITY_CODE = "TLS"; - - private SSLContextFactory() - { - //no instances - } - - public static SSLContext buildClientContext(final String trustStorePath, - final String trustStorePassword, final String trustStoreType, - final String trustManagerFactoryAlgorithm, final String keyStorePath, - final String keyStorePassword, final String keyStoreType, - final String keyManagerFactoryAlgorithm, final String certAlias) - throws GeneralSecurityException, IOException - { - return buildContext(trustStorePath, - trustStorePassword, - trustStoreType, - trustManagerFactoryAlgorithm, - keyStorePath, - keyStorePassword, - keyStoreType, - keyManagerFactoryAlgorithm, - certAlias); - } - - private static SSLContext buildContext(String trustStorePath, - String trustStorePassword, - String trustStoreType, - String trustManagerFactoryAlgorithm, - String keyStorePath, - String keyStorePassword, - String keyStoreType, - String keyManagerFactoryAlgorithm, String certAlias) - throws GeneralSecurityException, IOException - { - // Initialize the SSLContext to work with our key managers. - final SSLContext sslContext = SSLContext - .getInstance(TRANSPORT_LAYER_SECURITY_CODE); - - final TrustManager[] trustManagers; - final KeyManager[] keyManagers; - - if (trustStorePath != null) - { - final KeyStore ts = SSLUtil.getInitializedKeyStore(trustStorePath, - trustStorePassword, trustStoreType); - final TrustManagerFactory tmf = TrustManagerFactory - .getInstance(trustManagerFactoryAlgorithm); - tmf.init(ts); - - trustManagers = tmf.getTrustManagers(); - } - else - { - trustManagers = null; - } - - if (keyStorePath != null) - { - if (certAlias != null) - { - keyManagers = new KeyManager[] { new QpidClientX509KeyManager( - certAlias, keyStorePath, keyStoreType, keyStorePassword, - keyManagerFactoryAlgorithm) }; - } - else - { - final KeyStore ks = SSLUtil.getInitializedKeyStore( - keyStorePath, keyStorePassword, keyStoreType); - - char[] keyStoreCharPassword = keyStorePassword == null ? null : keyStorePassword.toCharArray(); - // Set up key manager factory to use our key store - final KeyManagerFactory kmf = KeyManagerFactory - .getInstance(keyManagerFactoryAlgorithm); - kmf.init(ks, keyStoreCharPassword); - keyManagers = kmf.getKeyManagers(); - } - } - else - { - keyManagers = null; - } - - sslContext.init(keyManagers, trustManagers, null); - - return sslContext; - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/thread/DefaultThreadFactory.java b/qpid/java/common/src/main/java/org/apache/qpid/thread/DefaultThreadFactory.java deleted file mode 100644 index a96dac4109..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/thread/DefaultThreadFactory.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.qpid.thread; - - - -public class DefaultThreadFactory implements ThreadFactory -{ - - private final LoggingUncaughtExceptionHandler _loggingUncaughtExceptionHandler = new LoggingUncaughtExceptionHandler(); - - public Thread createThread(Runnable r) - { - Thread t = new Thread(r); - t.setUncaughtExceptionHandler(_loggingUncaughtExceptionHandler); - return t; - } - - public Thread createThread(Runnable r, int priority) - { - Thread t = createThread(r); - t.setPriority(priority); - return t; - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/thread/LoggingUncaughtExceptionHandler.java b/qpid/java/common/src/main/java/org/apache/qpid/thread/LoggingUncaughtExceptionHandler.java deleted file mode 100644 index 58d80454b7..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/thread/LoggingUncaughtExceptionHandler.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.thread; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.lang.Thread.UncaughtExceptionHandler; - -/** - * - * An {@link UncaughtExceptionHandler} that writes the exception to the application log via - * the SLF4J framework. Once registered with {@link Thread#setUncaughtExceptionHandler(UncaughtExceptionHandler)} - * it will be invoked by the JVM when a thread has been abruptly terminated due to an uncaught exception. - * Owing to the contract of {@link Runnable#run()}, the only possible exception types which can cause such a termination - * are instances of {@link RuntimeException} and {@link Error}. These exceptions are catastrophic and the client must - * restart the JVM. - *

- * The implementation also invokes {@link ThreadGroup#uncaughtException(Thread, Throwable)}. This - * is done to retain compatibility with any monitoring solutions (for example, log scraping of - * standard error) that existing users of older Qpid client libraries may have in place. - * - */ -public class LoggingUncaughtExceptionHandler implements UncaughtExceptionHandler -{ - private static final Logger _logger = LoggerFactory.getLogger(LoggingUncaughtExceptionHandler.class); - - @Override - public void uncaughtException(Thread t, Throwable e) - { - try - { - _logger.error("Uncaught exception in thread \"{}\"", t.getName(), e); - } - finally - { - // Invoke the thread group's handler too for compatibility with any - // existing clients who are already scraping stderr for such conditions. - t.getThreadGroup().uncaughtException(t, e); - } - } -} \ No newline at end of file diff --git a/qpid/java/common/src/main/java/org/apache/qpid/thread/QpidThreadExecutor.java b/qpid/java/common/src/main/java/org/apache/qpid/thread/QpidThreadExecutor.java deleted file mode 100644 index 06f5e6b835..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/thread/QpidThreadExecutor.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.qpid.thread; - -import java.util.concurrent.Executor; - -public class QpidThreadExecutor implements Executor -{ - public void execute(Runnable command) - { - try - { - Threading.getThreadFactory().createThread(command).start(); - } - catch(Exception e) - { - throw new RuntimeException("Error creating a thread using Qpid thread factory",e); - } - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/thread/RealtimeThreadFactory.java b/qpid/java/common/src/main/java/org/apache/qpid/thread/RealtimeThreadFactory.java deleted file mode 100644 index 631ee98b94..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/thread/RealtimeThreadFactory.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.thread; - - -import java.lang.reflect.Constructor; - -public class RealtimeThreadFactory implements ThreadFactory -{ - private final LoggingUncaughtExceptionHandler _loggingUncaughtExceptionHandler = new LoggingUncaughtExceptionHandler(); - - private Class threadClass; - private Constructor threadConstructor; - private Constructor priorityParameterConstructor; - private int defaultRTThreadPriority = 20; - - public RealtimeThreadFactory() throws Exception - { - defaultRTThreadPriority = Integer.getInteger("qpid.rt_thread_priority",20); - threadClass = Class.forName("javax.realtime.RealtimeThread"); - - Class schedulingParametersClass = Class.forName("javax.realtime.SchedulingParameters"); - Class releaseParametersClass = Class.forName("javax.realtime.ReleaseParameters"); - Class memoryParametersClass = Class.forName("javax.realtime.MemoryParameters"); - Class memoryAreaClass = Class.forName("javax.realtime.MemoryArea"); - Class processingGroupParametersClass = Class.forName("javax.realtime.ProcessingGroupParameters"); - - Class[] paramTypes = new Class[]{schedulingParametersClass, - releaseParametersClass, - memoryParametersClass, - memoryAreaClass, - processingGroupParametersClass, - java.lang.Runnable.class}; - - threadConstructor = threadClass.getConstructor(paramTypes); - - Class priorityParameterClass = Class.forName("javax.realtime.PriorityParameters"); - priorityParameterConstructor = priorityParameterClass.getConstructor(new Class[]{int.class}); - } - - public Thread createThread(Runnable r) throws Exception - { - return createThread(r,defaultRTThreadPriority); - } - - public Thread createThread(Runnable r, int priority) throws Exception - { - Object priorityParams = priorityParameterConstructor.newInstance(priority); - Thread thread = (Thread)threadConstructor.newInstance(priorityParams,null,null,null,null,r); - thread.setUncaughtExceptionHandler(_loggingUncaughtExceptionHandler); - return thread; - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/thread/ThreadFactory.java b/qpid/java/common/src/main/java/org/apache/qpid/thread/ThreadFactory.java deleted file mode 100644 index c8f1cbfcba..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/thread/ThreadFactory.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.thread; - - -public interface ThreadFactory -{ - public Thread createThread(Runnable r) throws Exception; - public Thread createThread(Runnable r, int priority) throws Exception; -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/thread/Threading.java b/qpid/java/common/src/main/java/org/apache/qpid/thread/Threading.java deleted file mode 100644 index d3ccc138dd..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/thread/Threading.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.thread; - - -public final class Threading -{ - private static ThreadFactory threadFactory; - - private Threading() - { - } - - static { - try - { - Class threadFactoryClass = - Class.forName(System.getProperty("qpid.thread_factory", - "org.apache.qpid.thread.DefaultThreadFactory")); - - threadFactory = (ThreadFactory)threadFactoryClass.newInstance(); - } - catch(Exception e) - { - throw new Error("Error occured while loading thread factory",e); - } - } - - public static ThreadFactory getThreadFactory() - { - return threadFactory; - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/Acquired.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/Acquired.java deleted file mode 100644 index 28e6e4c4e6..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/Acquired.java +++ /dev/null @@ -1,141 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - - - -public final class Acquired extends Struct { - - public static final int TYPE = 1028; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 4; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return -1; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private RangeSet transfers; - - - public Acquired() {} - - - public Acquired(RangeSet transfers) { - if(transfers != null) { - setTransfers(transfers); - } - - } - - - - - public final boolean hasTransfers() { - return (packing_flags & 256) != 0; - } - - public final Acquired clearTransfers() { - packing_flags &= ~256; - this.transfers = null; - setDirty(true); - return this; - } - - public final RangeSet getTransfers() { - return transfers; - } - - public final Acquired setTransfers(RangeSet value) { - this.transfers = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final Acquired transfers(RangeSet value) { - return setTransfers(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeSequenceSet(this.transfers); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.transfers = dec.readSequenceSet(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("transfers", getTransfers()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/Binary.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/Binary.java deleted file mode 100644 index e3e6f81f7c..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/Binary.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - -import static org.apache.qpid.transport.util.Functions.str; - -import java.nio.ByteBuffer; - - -/** - * Binary - * - */ - -public final class Binary -{ - - private byte[] bytes; - private int offset; - private int size; - private int hash = 0; - - public Binary(byte[] bytes, int offset, int size) - { - if (offset + size > bytes.length) - { - throw new ArrayIndexOutOfBoundsException(); - } - - this.bytes = bytes; - this.offset = offset; - this.size = size; - } - - public Binary(byte[] bytes) - { - this(bytes, 0, bytes.length); - } - - public final byte[] getBytes() - { - byte[] result = new byte[size]; - System.arraycopy(bytes, offset, result, 0, size); - return result; - } - - public final byte[] array() - { - return bytes; - } - - public final int offset() - { - return offset; - } - - public final int size() - { - return size; - } - - public final Binary slice(int low, int high) - { - int sz; - - if (high < 0) - { - sz = size + high; - } - else - { - sz = high - low; - } - - if (sz < 0) - { - sz = 0; - } - - return new Binary(bytes, offset + low, sz); - } - - public final int hashCode() - { - if (hash == 0) - { - int hc = 0; - for (int i = 0; i < size; i++) - { - hc = 31*hc + (0xFF & bytes[offset + i]); - } - hash = hc; - } - - return hash; - } - - public final boolean equals(Object o) - { - if (!(o instanceof Binary)) - { - return false; - } - - Binary buf = (Binary) o; - if (this.size != buf.size) - { - return false; - } - - for (int i = 0; i < size; i++) - { - if (bytes[offset + i] != buf.bytes[buf.offset + i]) - { - return false; - } - } - - return true; - } - - public String toString() - { - return str(ByteBuffer.wrap(bytes, offset, size)); - } - - public boolean hasExcessCapacity() - { - return size != bytes.length; - } - - public Binary copy() - { - return new Binary(getBytes()); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/Binding.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/Binding.java deleted file mode 100644 index f703c01567..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/Binding.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - - -/** - * Binding - * - */ - -public interface Binding -{ - - E endpoint(ByteBufferSender sender); - - ByteBufferReceiver receiver(E endpoint); - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ByteBufferReceiver.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ByteBufferReceiver.java deleted file mode 100644 index 1015f061c8..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ByteBufferReceiver.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - -import java.nio.ByteBuffer; - -public interface ByteBufferReceiver -{ - void received(ByteBuffer msg); - - void exception(Throwable t); - - void closed(); -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ByteBufferSender.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ByteBufferSender.java deleted file mode 100644 index 7dcaf61a26..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ByteBufferSender.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - -import java.nio.ByteBuffer; - -public interface ByteBufferSender -{ - void send(ByteBuffer msg); - - void flush(); - - void close(); -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java deleted file mode 100644 index 7c4e264ade..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java +++ /dev/null @@ -1,228 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - -import static org.apache.qpid.transport.Connection.State.OPEN; -import static org.apache.qpid.transport.Connection.State.RESUMING; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.security.sasl.SaslClient; -import javax.security.sasl.SaslException; - -import org.apache.qpid.common.QpidProperties; -import org.apache.qpid.configuration.ClientProperties; -import org.apache.qpid.properties.ConnectionStartProperties; -import org.apache.qpid.transport.util.Logger; - - -/** - * ClientDelegate - * - */ - -public class ClientDelegate extends ConnectionDelegate -{ - private static final Logger log = Logger.get(ClientDelegate.class); - - - - private final ConnectionSettings _connectionSettings; - - public ClientDelegate(ConnectionSettings settings) - { - _connectionSettings = settings; - } - - public void init(Connection conn, ProtocolHeader hdr) - { - if (!(hdr.getMajor() == 0 && hdr.getMinor() == 10)) - { - conn.exception(new ProtocolVersionException(hdr.getMajor(), hdr.getMinor())); - } - } - - @Override - public void connectionStart(Connection conn, ConnectionStart start) - { - Map clientProperties = new HashMap(); - - if(_connectionSettings.getClientProperties() != null) - { - clientProperties.putAll(_connectionSettings.getClientProperties()); - } - - clientProperties.put(ConnectionStartProperties.SESSION_FLOW, 1); - clientProperties.put(ConnectionStartProperties.PID, ConnectionStartProperties.getPID()); - clientProperties.put(ConnectionStartProperties.PROCESS, System.getProperty(ClientProperties.PROCESS_NAME, "Qpid Java Client")); - clientProperties.put(ConnectionStartProperties.VERSION_0_10, QpidProperties.getReleaseVersion()); - clientProperties.put(ConnectionStartProperties.PRODUCT, QpidProperties.getProductName()); - clientProperties.put(ConnectionStartProperties.PLATFORM, ConnectionStartProperties.getPlatformInfo()); - - List brokerMechs = start.getMechanisms(); - if (brokerMechs == null || brokerMechs.isEmpty()) - { - conn.connectionStartOk - (clientProperties, null, null, conn.getLocale()); - return; - } - conn.setServerProperties(start.getServerProperties()); - - try - { - final SaslClient sc = createSaslClient(brokerMechs); - - conn.setSaslClient(sc); - - byte[] response = sc.hasInitialResponse() ? - sc.evaluateChallenge(new byte[0]) : null; - conn.connectionStartOk - (clientProperties, sc.getMechanismName(), response, - conn.getLocale()); - } - catch (ConnectionException ce) - { - conn.exception(ce); - } - catch (SaslException e) - { - conn.exception(e); - } - } - - - protected SaslClient createSaslClient(List brokerMechs) throws ConnectionException, SaslException - { - throw new UnsupportedOperationException(); - } - - @Override - public void connectionSecure(Connection conn, ConnectionSecure secure) - { - SaslClient sc = conn.getSaslClient(); - try - { - byte[] response = sc.evaluateChallenge(secure.getChallenge()); - conn.connectionSecureOk(response); - } - catch (SaslException e) - { - conn.exception(e); - } - } - - @Override - public void connectionTune(Connection conn, ConnectionTune tune) - { - int heartbeatInterval = _connectionSettings.getHeartbeatInterval010(); - float heartbeatTimeoutFactor = _connectionSettings.getHeartbeatTimeoutFactor(); - int actualHeartbeatInterval = calculateHeartbeatInterval(heartbeatInterval, - tune.getHeartbeatMin(), - tune.getHeartbeatMax()); - int maxFrameSize = tune.getMaxFrameSize(); - int settingsMaxFrameSize = conn.getConnectionSettings().getMaxFrameSize(); - if(maxFrameSize == 0 && settingsMaxFrameSize != 0 && settingsMaxFrameSize < 0xffff) - { - maxFrameSize = Math.max(Constant.MIN_MAX_FRAME_SIZE, settingsMaxFrameSize); - } - else if(maxFrameSize != 0 && settingsMaxFrameSize != 0) - { - maxFrameSize = Math.max(Constant.MIN_MAX_FRAME_SIZE, Math.min(maxFrameSize, settingsMaxFrameSize)); - } - conn.connectionTuneOk(tune.getChannelMax(), - maxFrameSize, - actualHeartbeatInterval); - - conn.getNetworkConnection().setMaxReadIdle((int)(actualHeartbeatInterval*heartbeatTimeoutFactor)); - conn.getNetworkConnection().setMaxWriteIdle(actualHeartbeatInterval); - conn.setMaxFrameSize(maxFrameSize == 0 ? 0xffff : maxFrameSize); - - int channelMax = tune.getChannelMax(); - //0 means no implied limit, except available server resources - //(or that forced by protocol limitations [0xFFFF]) - conn.setChannelMax(channelMax == 0 ? Connection.MAX_CHANNEL_MAX : channelMax); - - conn.connectionOpen(_connectionSettings.getVhost(), null, Option.INSIST); - } - - @Override - public void connectionOpenOk(Connection conn, ConnectionOpenOk ok) - { - if (conn.isConnectionResuming()) - { - conn.setState(RESUMING); - } - else - { - conn.setState(OPEN); - } - } - - @Override - public void connectionRedirect(Connection conn, ConnectionRedirect redir) - { - conn.setRedirecting(true); - conn.getSender().close(); - for(ConnectionListener listener : conn.getListeners()) - { - if(listener.redirect(redir.getHost(), redir.getKnownHosts())) - { - break; - } - } - } - - @Override - public void connectionHeartbeat(Connection conn, ConnectionHeartbeat hearbeat) - { - conn.connectionHeartbeat(); - } - - /** - * Currently the spec specified the min and max for heartbeat using secs - */ - int calculateHeartbeatInterval(int heartbeat,int min, int max) - { - int i = heartbeat; - if (i == 0) - { - log.info("Heartbeat interval is 0 sec. Heartbeats are disabled."); - return 0; // heartbeats are disabled. - } - else if (i >= min && i <= max) - { - return i; - } - else - { - log.info("The broker does not support the configured connection heartbeat interval of %s sec," + - " using the brokers max supported value of %s sec instead.", i,max); - return max; - } - } - - public ConnectionSettings getConnectionSettings() - { - return _connectionSettings; - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java deleted file mode 100644 index 59237f8c69..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java +++ /dev/null @@ -1,881 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - -import static org.apache.qpid.transport.Connection.State.CLOSED; -import static org.apache.qpid.transport.Connection.State.CLOSING; -import static org.apache.qpid.transport.Connection.State.NEW; -import static org.apache.qpid.transport.Connection.State.OPEN; -import static org.apache.qpid.transport.Connection.State.OPENING; - -import java.net.SocketAddress; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicBoolean; - -import javax.security.sasl.SaslClient; -import javax.security.sasl.SaslServer; - -import org.apache.qpid.framing.ProtocolVersion; -import org.apache.qpid.properties.ConnectionStartProperties; -import org.apache.qpid.transport.network.Assembler; -import org.apache.qpid.transport.network.Disassembler; -import org.apache.qpid.transport.network.InputHandler; -import org.apache.qpid.transport.network.NetworkConnection; -import org.apache.qpid.transport.network.OutgoingNetworkTransport; -import org.apache.qpid.transport.network.Transport; -import org.apache.qpid.transport.network.TransportActivity; -import org.apache.qpid.transport.network.security.SecurityLayer; -import org.apache.qpid.transport.network.security.SecurityLayerFactory; -import org.apache.qpid.transport.util.Logger; -import org.apache.qpid.transport.util.Waiter; -import org.apache.qpid.util.Strings; - - -/** - * Connection - * - * @author Rafael H. Schloming - * - * TODO the channels map should probably be replaced with something - * more efficient, e.g. an array or a map implementation that can use - * short instead of Short - */ - -public class Connection extends ConnectionInvoker - implements ProtocolEventReceiver, ProtocolEventSender -{ - - protected static final Logger log = Logger.get(Connection.class); - - //Usable channels are numbered 0 to - 1 - public static final int MAX_CHANNEL_MAX = 0xFFFF; - public static final int MIN_USABLE_CHANNEL_NUM = 0; - private long _lastSendTime; - private long _lastReadTime; - private NetworkConnection _networkConnection; - private FrameSizeObserver _frameSizeObserver; - private boolean _messageCompressionSupported; - private final AtomicBoolean _redirecting = new AtomicBoolean(); - - public enum State { NEW, CLOSED, OPENING, OPEN, CLOSING, CLOSE_RCVD, RESUMING } - - static class DefaultConnectionListener implements ConnectionListener - { - public void opened(Connection conn) {} - public void exception(Connection conn, ConnectionException exception) - { - log.error(exception, "connection exception"); - } - public void closed(Connection conn) {} - - @Override - public boolean redirect(final String host, final List knownHosts) - { - return false; - } - } - - public static interface SessionFactory - { - Session newSession(Connection conn, Binary name, long expiry, boolean isNoReplay); - } - - private static final class DefaultSessionFactory implements SessionFactory - { - - public Session newSession(final Connection conn, final Binary name, final long expiry, final boolean isNoReplay) - { - return new Session(conn, name, expiry, isNoReplay); - } - } - - private static final SessionFactory DEFAULT_SESSION_FACTORY = new DefaultSessionFactory(); - - private SessionFactory _sessionFactory = DEFAULT_SESSION_FACTORY; - - private ConnectionDelegate delegate; - private ProtocolEventSender sender; - - final private Map sessions = new HashMap(); - final private Map channels = new ConcurrentHashMap(); - - private State state = NEW; - final private Object lock = new Object(); - private long timeout = 60000; - private List listeners = new ArrayList(); - private ConnectionException error = null; - - private int channelMax = 1; - private String locale; - private SaslServer saslServer; - private SaslClient saslClient; - private int idleTimeout = 0; - private Map _serverProperties; - private String userID; - private ConnectionSettings conSettings; - private SecurityLayer securityLayer; - - private final AtomicBoolean connectionLost = new AtomicBoolean(false); - - private SocketAddress _remoteAddress; - private SocketAddress _localAddress; - - public Connection() {} - - public void setConnectionDelegate(ConnectionDelegate delegate) - { - this.delegate = delegate; - } - - public void addConnectionListener(ConnectionListener listener) - { - listeners.add(listener); - } - - public List getListeners() - { - return Collections.unmodifiableList(listeners); - } - - public ProtocolEventSender getSender() - { - return sender; - } - - public void setSender(ProtocolEventSender sender) - { - this.sender = sender; - } - - protected void setState(State state) - { - synchronized (lock) - { - this.state = state; - lock.notifyAll(); - } - } - - void setLocale(String locale) - { - this.locale = locale; - } - - String getLocale() - { - return locale; - } - - void setSaslServer(SaslServer saslServer) - { - this.saslServer = saslServer; - } - - SaslServer getSaslServer() - { - return saslServer; - } - - void setSaslClient(SaslClient saslClient) - { - this.saslClient = saslClient; - } - - public SaslClient getSaslClient() - { - return saslClient; - } - - public void connect(String host, int port, String vhost, String username, String password, boolean ssl, String saslMechs) - { - connect(host, port, vhost, username, password, ssl, saslMechs, null); - } - - public void connect(String host, int port, String vhost, String username, String password, boolean ssl, String saslMechs, Map clientProps) - { - ConnectionSettings settings = new ConnectionSettings(); - settings.setHost(host); - settings.setPort(port); - settings.setVhost(vhost); - settings.setUsername(username); - settings.setPassword(password); - settings.setUseSSL(ssl); - settings.setSaslMechs(saslMechs); - settings.setClientProperties(clientProps); - connect(settings); - } - - public void connect(ConnectionSettings settings) - { - - synchronized (lock) - { - conSettings = settings; - _redirecting.set(false); - state = OPENING; - userID = settings.getUsername(); - connectionLost.set(false); - - securityLayer = SecurityLayerFactory.newInstance(getConnectionSettings()); - - OutgoingNetworkTransport transport = Transport.getOutgoingTransportInstance(ProtocolVersion.v0_10); - final InputHandler inputHandler = new InputHandler(new Assembler(this)); - addFrameSizeObserver(inputHandler); - ByteBufferReceiver secureReceiver = securityLayer.receiver(inputHandler); - if(secureReceiver instanceof ConnectionListener) - { - addConnectionListener((ConnectionListener)secureReceiver); - } - - _networkConnection = transport.connect(settings, secureReceiver, new ConnectionActivity()); - - - setRemoteAddress(_networkConnection.getRemoteAddress()); - setLocalAddress(_networkConnection.getLocalAddress()); - - final ByteBufferSender secureSender = securityLayer.sender(_networkConnection.getSender()); - if(secureSender instanceof ConnectionListener) - { - addConnectionListener((ConnectionListener)secureSender); - } - Disassembler disassembler = new Disassembler(secureSender, Constant.MIN_MAX_FRAME_SIZE); - sender = disassembler; - addFrameSizeObserver(disassembler); - - send(new ProtocolHeader(1, 0, 10)); - - Waiter w = new Waiter(lock, timeout); - while (w.hasTime() && ((state == OPENING && error == null) || isRedirecting())) - { - w.await(); - } - - if (error != null) - { - ConnectionException t = error; - error = null; - try - { - close(); - } - catch (ConnectionException ce) - { - if (!(t instanceof ProtocolVersionException)) - { - throw ce; - } - } - t.rethrow(); - } - - switch (state) - { - case OPENING: - close(); - throw new ConnectionException("connect() timed out"); - case OPEN: - case RESUMING: - connectionLost.set(false); - break; - case CLOSED: - throw new ConnectionException("connect() aborted"); - default: - throw new IllegalStateException(String.valueOf(state)); - } - } - - for (ConnectionListener listener: listeners) - { - listener.opened(this); - } - } - - public Session createSession() - { - return createSession(0); - } - - public Session createSession(long expiry) - { - return createSession(expiry, false); - } - - public Session createSession(long expiry, boolean isNoReplay) - { - return createSession(UUID.randomUUID().toString(), expiry, isNoReplay); - } - - public Session createSession(String name) - { - return createSession(name, 0); - } - - public Session createSession(String name, long expiry) - { - return createSession(Strings.toUTF8(name), expiry); - } - - public Session createSession(String name, long expiry,boolean isNoReplay) - { - return createSession(new Binary(Strings.toUTF8(name)), expiry, isNoReplay); - } - - public Session createSession(byte[] name, long expiry) - { - return createSession(new Binary(name), expiry); - } - - public Session createSession(Binary name, long expiry) - { - return createSession(name, expiry, false); - } - - public Session createSession(Binary name, long expiry, boolean isNoReplay) - { - synchronized (lock) - { - Waiter w = new Waiter(lock, timeout); - while (w.hasTime() && state != OPEN && error == null) - { - w.await(); - } - - if (state != OPEN) - { - throw new ConnectionException("Timed out waiting for connection to be ready. Current state is :" + state); - } - - Session ssn = _sessionFactory.newSession(this, name, expiry, isNoReplay); - registerSession(ssn); - map(ssn); - ssn.attach(); - return ssn; - } - } - - public void registerSession(Session ssn) - { - synchronized (lock) - { - sessions.put(ssn.getName(),ssn); - } - } - - public void removeSession(Session ssn) - { - synchronized (lock) - { - sessions.remove(ssn.getName()); - } - } - - public void setSessionFactory(SessionFactory sessionFactory) - { - assert sessionFactory != null; - - _sessionFactory = sessionFactory; - } - - public ConnectionDelegate getConnectionDelegate() - { - return delegate; - } - - public void received(ProtocolEvent event) - { - _lastReadTime = System.currentTimeMillis(); - if(log.isDebugEnabled()) - { - log.debug("RECV: [%s] %s", this, event); - } - event.delegate(this, delegate); - } - - public void send(ProtocolEvent event) - { - _lastSendTime = System.currentTimeMillis(); - if(log.isDebugEnabled()) - { - log.debug("SEND: [%s] %s", this, event); - } - ProtocolEventSender s = sender; - if (s == null) - { - throw new ConnectionException("connection closed"); - } - s.send(event); - } - - public void flush() - { - if(log.isDebugEnabled()) - { - log.debug("FLUSH: [%s]", this); - } - final ProtocolEventSender theSender = sender; - if(theSender != null) - { - theSender.flush(); - } - } - - protected void invoke(Method method) - { - method.setChannel(0); - send(method); - if (!method.isBatch()) - { - flush(); - } - } - - public void dispatch(Method method) - { - int channel = method.getChannel(); - Session ssn = getSession(channel); - if(ssn != null) - { - ssn.received(method); - } - else - { - /* - * A peer receiving any other control on a detached transport MUST discard it and - * send a session.detached with the "not-attached" reason code. - */ - if(log.isDebugEnabled()) - { - log.debug("Control received on unattached channel : %d", channel); - } - invokeSessionDetached(channel, SessionDetachCode.NOT_ATTACHED); - } - } - - public int getChannelMax() - { - return channelMax; - } - - void setChannelMax(int max) - { - channelMax = max; - } - - private int map(Session ssn) - { - synchronized (lock) - { - //For a negotiated channelMax N, there are channels 0 to N-1 available. - for (int i = 0; i < getChannelMax(); i++) - { - if (!channels.containsKey(i)) - { - map(ssn, i); - return i; - } - } - - throw new RuntimeException("no more channels available"); - } - } - - void map(Session ssn, int channel) - { - synchronized (lock) - { - channels.put(channel, ssn); - ssn.setChannel(channel); - } - } - - void unmap(Session ssn) - { - synchronized (lock) - { - channels.remove(ssn.getChannel()); - } - } - - public Session getSession(int channel) - { - synchronized (lock) - { - return channels.get(channel); - } - } - - public void resume() - { - synchronized (lock) - { - for (Session ssn : sessions.values()) - { - map(ssn); - ssn.resume(); - } - - setState(OPEN); - } - } - - public void exception(ConnectionException e) - { - connectionLost.set(true); - synchronized (lock) - { - switch (state) - { - case OPENING: - case CLOSING: - error = e; - lock.notifyAll(); - return; - } - } - - for (ConnectionListener listener: listeners) - { - listener.exception(this, e); - } - - } - - public void exception(Throwable t) - { - exception(new ConnectionException(t)); - } - - public void closeCode(ConnectionClose close) - { - synchronized (lock) - { - ConnectionCloseCode code = close.getReplyCode(); - if (code != ConnectionCloseCode.NORMAL) - { - exception(new ConnectionException(close)); - } - } - } - - public void closed() - { - if (state == OPEN) - { - exception(new ConnectionException("connection aborted")); - } - - log.debug("connection closed: %s", this); - - synchronized (lock) - { - List values = new ArrayList(channels.values()); - for (Session ssn : values) - { - ssn.closed(); - } - - try - { - sender.close(); - } - catch(Exception e) - { - // ignore. - } - sender = null; - setState(CLOSED); - } - - for (ConnectionListener listener: listeners) - { - listener.closed(this); - } - } - - public void close() - { - close(ConnectionCloseCode.NORMAL, null); - } - - - protected void sendConnectionClose(ConnectionCloseCode replyCode, String replyText, Option ... _options) - { - connectionClose(replyCode, replyText, _options); - } - - public void close(ConnectionCloseCode replyCode, String replyText, Option ... _options) - { - synchronized (lock) - { - switch (state) - { - case OPEN: - state = CLOSING; - connectionClose(replyCode, replyText, _options); - Waiter w = new Waiter(lock, timeout); - while (w.hasTime() && state == CLOSING && error == null) - { - w.await(); - } - - if (error != null) - { - close(replyCode, replyText, _options); - throw new ConnectionException(error); - } - - switch (state) - { - case CLOSING: - close(replyCode, replyText, _options); - throw new ConnectionException("close() timed out"); - case CLOSED: - break; - default: - throw new IllegalStateException(String.valueOf(state)); - } - break; - case CLOSED: - break; - default: - if (sender != null) - { - sender.close(); - w = new Waiter(lock, timeout); - while (w.hasTime() && sender != null && error == null) - { - w.await(); - } - - if (error != null) - { - throw new ConnectionException(error); - } - - if (sender != null) - { - throw new ConnectionException("close() timed out"); - } - } - break; - } - } - } - - public String getUserID() - { - return userID; - } - - public void setUserID(String id) - { - userID = id; - } - - public void setServerProperties(final Map serverProperties) - { - _serverProperties = serverProperties == null ? Collections.emptyMap() : serverProperties; - _messageCompressionSupported = Boolean.parseBoolean(String.valueOf(_serverProperties.get(ConnectionStartProperties.QPID_MESSAGE_COMPRESSION_SUPPORTED))); - } - - public Map getServerProperties() - { - return _serverProperties; - } - - public String toString() - { - return String.format("conn:%x", System.identityHashCode(this)); - } - - public ConnectionSettings getConnectionSettings() - { - return conSettings; - } - - public SecurityLayer getSecurityLayer() - { - return securityLayer; - } - - public boolean isConnectionResuming() - { - return connectionLost.get(); - } - - protected boolean isConnectionLost() - { - return connectionLost.get(); - } - - protected Collection getChannels() - { - return new ArrayList<>(channels.values()); - } - - public boolean hasSessionWithName(final byte[] name) - { - return sessions.containsKey(new Binary(name)); - } - - public void notifyFailoverRequired() - { - for (Session ssn : getChannels()) - { - ssn.notifyFailoverRequired(); - } - } - - public SocketAddress getRemoteAddress() - { - return _remoteAddress; - } - - public SocketAddress getLocalAddress() - { - return _localAddress; - } - - protected void setRemoteAddress(SocketAddress remoteAddress) - { - _remoteAddress = remoteAddress; - } - - protected void setLocalAddress(SocketAddress localAddress) - { - _localAddress = localAddress; - } - - - private void invokeSessionDetached(int channel, SessionDetachCode sessionDetachCode) - { - SessionDetached sessionDetached = new SessionDetached(); - sessionDetached.setChannel(channel); - sessionDetached.setCode(sessionDetachCode); - invoke(sessionDetached); - } - - - protected void doHeartBeat() - { - connectionHeartbeat(); - } - - private class ConnectionActivity implements TransportActivity - { - @Override - public long getLastReadTime() - { - return _lastReadTime; - } - - @Override - public long getLastWriteTime() - { - return _lastSendTime; - } - - @Override - public void writerIdle() - { - getConnectionDelegate().writerIdle(Connection.this); - connectionHeartbeat(); - } - - @Override - public void readerIdle() - { - log.error("Closing connection as no heartbeat or other activity detected within specified interval"); - _networkConnection.close(); - } - } - - - public void setNetworkConnection(NetworkConnection network) - { - _networkConnection = network; - } - - public NetworkConnection getNetworkConnection() - { - return _networkConnection; - } - - public void setMaxFrameSize(final int maxFrameSize) - { - if(_frameSizeObserver != null) - { - _frameSizeObserver.setMaxFrameSize(maxFrameSize); - } - } - - public void addFrameSizeObserver(final FrameSizeObserver frameSizeObserver) - { - if(_frameSizeObserver == null) - { - _frameSizeObserver = frameSizeObserver; - } - else - { - final FrameSizeObserver currentObserver = _frameSizeObserver; - _frameSizeObserver = new FrameSizeObserver() - { - @Override - public void setMaxFrameSize(final int frameSize) - { - currentObserver.setMaxFrameSize(frameSize); - frameSizeObserver.setMaxFrameSize(frameSize); - } - }; - } - } - - public boolean isMessageCompressionSupported() - { - return _messageCompressionSupported; - } - - public boolean isRedirecting() - { - return _redirecting.get(); - } - - public void setRedirecting(final boolean redirecting) - { - _redirecting.set(redirecting); - } - - public boolean isClosing() - { - synchronized (lock) - { - return state == CLOSING || state == CLOSED; - } - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionClose.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionClose.java deleted file mode 100644 index 8888f354d8..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionClose.java +++ /dev/null @@ -1,196 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class ConnectionClose extends Method { - - public static final int TYPE = 267; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L1; - } - - public final boolean isConnectionControl() - { - return true; - } - - private short packing_flags = 0; - private ConnectionCloseCode replyCode; - private String replyText; - - - public ConnectionClose() {} - - - public ConnectionClose(ConnectionCloseCode replyCode, String replyText, Option ... _options) { - if(replyCode != null) { - setReplyCode(replyCode); - } - if(replyText != null) { - setReplyText(replyText); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.connectionClose(context, this); - } - - - public final boolean hasReplyCode() { - return (packing_flags & 256) != 0; - } - - public final ConnectionClose clearReplyCode() { - packing_flags &= ~256; - this.replyCode = null; - setDirty(true); - return this; - } - - public final ConnectionCloseCode getReplyCode() { - return replyCode; - } - - public final ConnectionClose setReplyCode(ConnectionCloseCode value) { - this.replyCode = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final ConnectionClose replyCode(ConnectionCloseCode value) { - return setReplyCode(value); - } - - public final boolean hasReplyText() { - return (packing_flags & 512) != 0; - } - - public final ConnectionClose clearReplyText() { - packing_flags &= ~512; - this.replyText = null; - setDirty(true); - return this; - } - - public final String getReplyText() { - return replyText; - } - - public final ConnectionClose setReplyText(String value) { - this.replyText = value; - packing_flags |= 512; - setDirty(true); - return this; - } - - public final ConnectionClose replyText(String value) { - return setReplyText(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeUint16(this.replyCode.getValue()); - } - if ((packing_flags & 512) != 0) - { - enc.writeStr8(this.replyText); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.replyCode = ConnectionCloseCode.get(dec.readUint16()); - } - if ((packing_flags & 512) != 0) - { - this.replyText = dec.readStr8(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("replyCode", getReplyCode()); - } - if ((packing_flags & 512) != 0) - { - result.put("replyText", getReplyText()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionCloseCode.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionCloseCode.java deleted file mode 100644 index 18c5b257d2..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionCloseCode.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -public enum ConnectionCloseCode { - - NORMAL((int) 200), - CONNECTION_FORCED((int) 320), - INVALID_PATH((int) 402), - FRAMING_ERROR((int) 501); - - private final int value; - - ConnectionCloseCode(int value) - { - this.value = value; - } - - public int getValue() - { - return value; - } - - public static ConnectionCloseCode get(int value) - { - switch (value) - { - case (int) 200: return NORMAL; - case (int) 320: return CONNECTION_FORCED; - case (int) 402: return INVALID_PATH; - case (int) 501: return FRAMING_ERROR; - default: throw new IllegalArgumentException("no such value: " + value); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionCloseOk.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionCloseOk.java deleted file mode 100644 index b954ac2162..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionCloseOk.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class ConnectionCloseOk extends Method { - - public static final int TYPE = 268; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L1; - } - - public final boolean isConnectionControl() - { - return true; - } - - private short packing_flags = 0; - - - - - public ConnectionCloseOk(Option ... _options) { - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.connectionCloseOk(context, this); - } - - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionDelegate.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionDelegate.java deleted file mode 100644 index b3379890f3..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionDelegate.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - -import org.apache.qpid.transport.util.Logger; - -import static org.apache.qpid.transport.Connection.State.CLOSE_RCVD; - - -/** - * ConnectionDelegate - * - * @author Rafael H. Schloming - */ - -/** - * Currently only implemented client specific methods - * the server specific methods are dummy impls for testing - * - * the connectionClose is kind of different for both sides - */ -public abstract class ConnectionDelegate - extends MethodDelegate - implements ProtocolDelegate -{ - - private static final Logger log = Logger.get(ConnectionDelegate.class); - - public void control(Connection conn, Method method) - { - method.dispatch(conn, this); - } - - public void command(Connection conn, Method method) - { - method.dispatch(conn, this); - } - - public void error(Connection conn, ProtocolError error) - { - conn.exception(new ConnectionException(error.getMessage())); - } - - public void handle(Connection conn, Method method) - { - conn.dispatch(method); - } - - @Override public void connectionHeartbeat(Connection conn, ConnectionHeartbeat hearbeat) - { - // do nothing - } - - @Override public void connectionClose(Connection conn, ConnectionClose close) - { - sendConnectionCloseOkAndCloseSender(conn); - conn.closeCode(close); - conn.setState(CLOSE_RCVD); - } - - protected void sendConnectionCloseOkAndCloseSender(Connection conn) - { - conn.connectionCloseOk(); - conn.getSender().close(); - } - - @Override public void connectionCloseOk(Connection conn, ConnectionCloseOk ok) - { - conn.getSender().close(); - } - - @Override public void sessionDetach(Connection conn, SessionDetach dtc) - { - Session ssn = conn.getSession(dtc.getChannel()); - ssn.sessionDetached(dtc.getName(), ssn.getDetachCode() == null? SessionDetachCode.NORMAL: ssn.getDetachCode()); - conn.unmap(ssn); - ssn.closed(); - } - - @Override public void sessionDetached(Connection conn, SessionDetached dtc) - { - Session ssn = conn.getSession(dtc.getChannel()); - if (ssn != null) - { - ssn.setDetachCode(dtc.getCode()); - conn.unmap(ssn); - ssn.closed(); - } - } - - public void writerIdle(final Connection connection) - { - connection.doHeartBeat(); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionException.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionException.java deleted file mode 100644 index 6d3972eb43..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionException.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - - -/** - * ConnectionException - * - */ - -public class ConnectionException extends TransportException -{ - - private ConnectionClose close; - - public ConnectionException(String message, ConnectionClose close, Throwable cause) - { - super(message, cause); - this.close = close; - } - - public ConnectionException(String message) - { - this(message, null, null); - } - - public ConnectionException(String message, Throwable cause) - { - this(message, null, cause); - } - - public ConnectionException(Throwable cause) - { - this(cause.getMessage(), null, cause); - } - - public ConnectionException(ConnectionClose close) - { - this(close.getReplyText(), close, null); - } - - public ConnectionClose getClose() - { - return close; - } - - @Override public void rethrow() - { - throw new ConnectionException(getMessage(), close, this); - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionHeartbeat.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionHeartbeat.java deleted file mode 100644 index 190bca0eaa..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionHeartbeat.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class ConnectionHeartbeat extends Method { - - public static final int TYPE = 266; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L1; - } - - public final boolean isConnectionControl() - { - return true; - } - - private short packing_flags = 0; - - - - - public ConnectionHeartbeat(Option ... _options) { - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.connectionHeartbeat(context, this); - } - - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionInvoker.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionInvoker.java deleted file mode 100644 index 29045e17de..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionInvoker.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.Map; - -public abstract class ConnectionInvoker { - - final void connectionStart(Map serverProperties, java.util.List mechanisms, java.util.List locales, Option ... _options) { - invoke(new ConnectionStart(serverProperties, mechanisms, locales, _options)); - } - - final void connectionStartOk(Map clientProperties, String mechanism, byte[] response, String locale, Option ... _options) { - invoke(new ConnectionStartOk(clientProperties, mechanism, response, locale, _options)); - } - - final void connectionSecure(byte[] challenge, Option ... _options) { - invoke(new ConnectionSecure(challenge, _options)); - } - - final void connectionSecureOk(byte[] response, Option ... _options) { - invoke(new ConnectionSecureOk(response, _options)); - } - - final void connectionTune(int channelMax, int maxFrameSize, int heartbeatMin, int heartbeatMax, Option ... _options) { - invoke(new ConnectionTune(channelMax, maxFrameSize, heartbeatMin, heartbeatMax, _options)); - } - - final void connectionTuneOk(int channelMax, int maxFrameSize, int heartbeat, Option ... _options) { - invoke(new ConnectionTuneOk(channelMax, maxFrameSize, heartbeat, _options)); - } - - final void connectionOpen(String virtualHost, java.util.List capabilities, Option ... _options) { - invoke(new ConnectionOpen(virtualHost, capabilities, _options)); - } - - final void connectionOpenOk(java.util.List knownHosts, Option ... _options) { - invoke(new ConnectionOpenOk(knownHosts, _options)); - } - - final void connectionRedirect(String host, java.util.List knownHosts, Option ... _options) { - invoke(new ConnectionRedirect(host, knownHosts, _options)); - } - - final void connectionHeartbeat(Option ... _options) { - invoke(new ConnectionHeartbeat(_options)); - } - - final void connectionClose(ConnectionCloseCode replyCode, String replyText, Option ... _options) { - invoke(new ConnectionClose(replyCode, replyText, _options)); - } - - final void connectionCloseOk(Option ... _options) { - invoke(new ConnectionCloseOk(_options)); - } - - protected abstract void invoke(Method method); - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionListener.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionListener.java deleted file mode 100644 index b055b9f5e1..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionListener.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - - -import java.util.List; - -/** - * ConnectionListener - * - */ - -public interface ConnectionListener -{ - - void opened(Connection connection); - - void exception(Connection connection, ConnectionException exception); - - void closed(Connection connection); - - boolean redirect(String host, List knownHosts); -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionOpen.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionOpen.java deleted file mode 100644 index b17a3810f2..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionOpen.java +++ /dev/null @@ -1,235 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class ConnectionOpen extends Method { - - public static final int TYPE = 263; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L1; - } - - public final boolean isConnectionControl() - { - return true; - } - - private short packing_flags = 0; - private String virtualHost; - private java.util.List capabilities; - - - public ConnectionOpen() {} - - - public ConnectionOpen(String virtualHost, java.util.List capabilities, Option ... _options) { - if(virtualHost != null) { - setVirtualHost(virtualHost); - } - if(capabilities != null) { - setCapabilities(capabilities); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case INSIST: packing_flags |= 1024; break; - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.connectionOpen(context, this); - } - - - public final boolean hasVirtualHost() { - return (packing_flags & 256) != 0; - } - - public final ConnectionOpen clearVirtualHost() { - packing_flags &= ~256; - this.virtualHost = null; - setDirty(true); - return this; - } - - public final String getVirtualHost() { - return virtualHost; - } - - public final ConnectionOpen setVirtualHost(String value) { - this.virtualHost = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final ConnectionOpen virtualHost(String value) { - return setVirtualHost(value); - } - - public final boolean hasCapabilities() { - return (packing_flags & 512) != 0; - } - - public final ConnectionOpen clearCapabilities() { - packing_flags &= ~512; - this.capabilities = null; - setDirty(true); - return this; - } - - public final java.util.List getCapabilities() { - return capabilities; - } - - public final ConnectionOpen setCapabilities(java.util.List value) { - this.capabilities = value; - packing_flags |= 512; - setDirty(true); - return this; - } - - public final ConnectionOpen capabilities(java.util.List value) { - return setCapabilities(value); - } - - public final boolean hasInsist() { - return (packing_flags & 1024) != 0; - } - - public final ConnectionOpen clearInsist() { - packing_flags &= ~1024; - - setDirty(true); - return this; - } - - public final boolean getInsist() { - return hasInsist(); - } - - public final ConnectionOpen setInsist(boolean value) { - - if (value) - { - packing_flags |= 1024; - } - else - { - packing_flags &= ~1024; - } - - setDirty(true); - return this; - } - - public final ConnectionOpen insist(boolean value) { - return setInsist(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeStr8(this.virtualHost); - } - if ((packing_flags & 512) != 0) - { - enc.writeArray(this.capabilities); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.virtualHost = dec.readStr8(); - } - if ((packing_flags & 512) != 0) - { - this.capabilities = dec.readArray(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("virtualHost", getVirtualHost()); - } - if ((packing_flags & 512) != 0) - { - result.put("capabilities", getCapabilities()); - } - if ((packing_flags & 1024) != 0) - { - result.put("insist", getInsist()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionOpenOk.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionOpenOk.java deleted file mode 100644 index 0cbbba51bb..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionOpenOk.java +++ /dev/null @@ -1,154 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class ConnectionOpenOk extends Method { - - public static final int TYPE = 264; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L1; - } - - public final boolean isConnectionControl() - { - return true; - } - - private short packing_flags = 0; - private java.util.List knownHosts; - - - public ConnectionOpenOk() {} - - - public ConnectionOpenOk(java.util.List knownHosts, Option ... _options) { - if(knownHosts != null) { - setKnownHosts(knownHosts); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.connectionOpenOk(context, this); - } - - - public final boolean hasKnownHosts() { - return (packing_flags & 256) != 0; - } - - public final ConnectionOpenOk clearKnownHosts() { - packing_flags &= ~256; - this.knownHosts = null; - setDirty(true); - return this; - } - - public final java.util.List getKnownHosts() { - return knownHosts; - } - - public final ConnectionOpenOk setKnownHosts(java.util.List value) { - this.knownHosts = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final ConnectionOpenOk knownHosts(java.util.List value) { - return setKnownHosts(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeArray(this.knownHosts); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.knownHosts = dec.readArray(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("knownHosts", getKnownHosts()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionRedirect.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionRedirect.java deleted file mode 100644 index c84758c54c..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionRedirect.java +++ /dev/null @@ -1,196 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class ConnectionRedirect extends Method { - - public static final int TYPE = 265; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L1; - } - - public final boolean isConnectionControl() - { - return true; - } - - private short packing_flags = 0; - private String host; - private java.util.List knownHosts; - - - public ConnectionRedirect() {} - - - public ConnectionRedirect(String host, java.util.List knownHosts, Option ... _options) { - if(host != null) { - setHost(host); - } - if(knownHosts != null) { - setKnownHosts(knownHosts); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.connectionRedirect(context, this); - } - - - public final boolean hasHost() { - return (packing_flags & 256) != 0; - } - - public final ConnectionRedirect clearHost() { - packing_flags &= ~256; - this.host = null; - setDirty(true); - return this; - } - - public final String getHost() { - return host; - } - - public final ConnectionRedirect setHost(String value) { - this.host = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final ConnectionRedirect host(String value) { - return setHost(value); - } - - public final boolean hasKnownHosts() { - return (packing_flags & 512) != 0; - } - - public final ConnectionRedirect clearKnownHosts() { - packing_flags &= ~512; - this.knownHosts = null; - setDirty(true); - return this; - } - - public final java.util.List getKnownHosts() { - return knownHosts; - } - - public final ConnectionRedirect setKnownHosts(java.util.List value) { - this.knownHosts = value; - packing_flags |= 512; - setDirty(true); - return this; - } - - public final ConnectionRedirect knownHosts(java.util.List value) { - return setKnownHosts(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeStr16(this.host); - } - if ((packing_flags & 512) != 0) - { - enc.writeArray(this.knownHosts); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.host = dec.readStr16(); - } - if ((packing_flags & 512) != 0) - { - this.knownHosts = dec.readArray(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("host", getHost()); - } - if ((packing_flags & 512) != 0) - { - result.put("knownHosts", getKnownHosts()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionSecure.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionSecure.java deleted file mode 100644 index 44fbac2b19..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionSecure.java +++ /dev/null @@ -1,154 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class ConnectionSecure extends Method { - - public static final int TYPE = 259; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L1; - } - - public final boolean isConnectionControl() - { - return true; - } - - private short packing_flags = 0; - private byte[] challenge; - - - public ConnectionSecure() {} - - - public ConnectionSecure(byte[] challenge, Option ... _options) { - if(challenge != null) { - setChallenge(challenge); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.connectionSecure(context, this); - } - - - public final boolean hasChallenge() { - return (packing_flags & 256) != 0; - } - - public final ConnectionSecure clearChallenge() { - packing_flags &= ~256; - this.challenge = null; - setDirty(true); - return this; - } - - public final byte[] getChallenge() { - return challenge; - } - - public final ConnectionSecure setChallenge(byte[] value) { - this.challenge = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final ConnectionSecure challenge(byte[] value) { - return setChallenge(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeVbin32(this.challenge); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.challenge = dec.readVbin32(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("challenge", getChallenge()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionSecureOk.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionSecureOk.java deleted file mode 100644 index 2a2b7df83a..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionSecureOk.java +++ /dev/null @@ -1,154 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class ConnectionSecureOk extends Method { - - public static final int TYPE = 260; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L1; - } - - public final boolean isConnectionControl() - { - return true; - } - - private short packing_flags = 0; - private byte[] response; - - - public ConnectionSecureOk() {} - - - public ConnectionSecureOk(byte[] response, Option ... _options) { - if(response != null) { - setResponse(response); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.connectionSecureOk(context, this); - } - - - public final boolean hasResponse() { - return (packing_flags & 256) != 0; - } - - public final ConnectionSecureOk clearResponse() { - packing_flags &= ~256; - this.response = null; - setDirty(true); - return this; - } - - public final byte[] getResponse() { - return response; - } - - public final ConnectionSecureOk setResponse(byte[] value) { - this.response = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final ConnectionSecureOk response(byte[] value) { - return setResponse(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeVbin32(this.response); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.response = dec.readVbin32(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("response", getResponse()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionSettings.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionSettings.java deleted file mode 100644 index 7f7799bd45..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionSettings.java +++ /dev/null @@ -1,431 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - -import static org.apache.qpid.configuration.ClientProperties.AMQJ_HEARTBEAT_DELAY; -import static org.apache.qpid.configuration.ClientProperties.AMQJ_HEARTBEAT_TIMEOUT_FACTOR; -import static org.apache.qpid.configuration.ClientProperties.IDLE_TIMEOUT_PROP_NAME; -import static org.apache.qpid.configuration.ClientProperties.QPID_HEARTBEAT_INTERVAL; -import static org.apache.qpid.configuration.ClientProperties.QPID_HEARTBEAT_INTERVAL_010_DEFAULT; -import static org.apache.qpid.configuration.ClientProperties.QPID_HEARTBEAT_TIMEOUT_FACTOR; -import static org.apache.qpid.configuration.ClientProperties.QPID_HEARTBEAT_TIMEOUT_FACTOR_DEFAULT; -import static org.apache.qpid.configuration.ClientProperties.AMQJ_TCP_NODELAY_PROP_NAME; -import static org.apache.qpid.configuration.ClientProperties.QPID_SSL_KEY_MANAGER_FACTORY_ALGORITHM_PROP_NAME; -import static org.apache.qpid.configuration.ClientProperties.QPID_SSL_KEY_STORE_CERT_TYPE_PROP_NAME; -import static org.apache.qpid.configuration.ClientProperties.QPID_SSL_TRUST_MANAGER_FACTORY_ALGORITHM_PROP_NAME; -import static org.apache.qpid.configuration.ClientProperties.QPID_SSL_TRUST_STORE_CERT_TYPE_PROP_NAME; -import static org.apache.qpid.configuration.ClientProperties.QPID_TCP_NODELAY_PROP_NAME; -import static org.apache.qpid.configuration.ClientProperties.RECEIVE_BUFFER_SIZE_PROP_NAME; -import static org.apache.qpid.configuration.ClientProperties.SEND_BUFFER_SIZE_PROP_NAME; -import static org.apache.qpid.configuration.ClientProperties.LEGACY_RECEIVE_BUFFER_SIZE_PROP_NAME; -import static org.apache.qpid.configuration.ClientProperties.LEGACY_SEND_BUFFER_SIZE_PROP_NAME; - -import java.security.KeyStore; -import java.util.Map; - -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.TrustManagerFactory; - -import org.apache.qpid.configuration.QpidProperty; - - -/** - * A ConnectionSettings object can only be associated with - * one Connection object. I have added an assertion that will - * throw an exception if it is used by more than on Connection - * - */ -public class ConnectionSettings -{ - public static final String WILDCARD_ADDRESS = "*"; - - - private String protocol = "tcp"; - private String host = "localhost"; - private String vhost; - private String username; - private String password; - private int port = 5672; - private boolean tcpNodelay = QpidProperty.booleanProperty(Boolean.TRUE, QPID_TCP_NODELAY_PROP_NAME, AMQJ_TCP_NODELAY_PROP_NAME).get(); - private int maxChannelCount = 32767; - private int maxFrameSize = 65535; - private Integer hearbeatIntervalLegacyMs = QpidProperty.intProperty(null, IDLE_TIMEOUT_PROP_NAME).get(); - private Integer heartbeatInterval = QpidProperty.intProperty(null, QPID_HEARTBEAT_INTERVAL, AMQJ_HEARTBEAT_DELAY).get(); - private float heartbeatTimeoutFactor = QpidProperty.floatProperty(QPID_HEARTBEAT_TIMEOUT_FACTOR_DEFAULT, QPID_HEARTBEAT_TIMEOUT_FACTOR, AMQJ_HEARTBEAT_TIMEOUT_FACTOR).get(); - private int connectTimeout = 30000; - private int readBufferSize = QpidProperty.intProperty(65535, RECEIVE_BUFFER_SIZE_PROP_NAME, LEGACY_RECEIVE_BUFFER_SIZE_PROP_NAME).get(); - private int writeBufferSize = QpidProperty.intProperty(65535, SEND_BUFFER_SIZE_PROP_NAME, LEGACY_SEND_BUFFER_SIZE_PROP_NAME).get();; - - // SSL props - private boolean useSSL; - private String keyStorePath = System.getProperty("javax.net.ssl.keyStore"); - private String keyStorePassword = System.getProperty("javax.net.ssl.keyStorePassword"); - private String keyStoreType = System.getProperty("javax.net.ssl.keyStoreType",KeyStore.getDefaultType()); - private String keyManagerFactoryAlgorithm = QpidProperty.stringProperty(KeyManagerFactory.getDefaultAlgorithm(), QPID_SSL_KEY_MANAGER_FACTORY_ALGORITHM_PROP_NAME, QPID_SSL_KEY_STORE_CERT_TYPE_PROP_NAME).get(); - private String trustManagerFactoryAlgorithm = QpidProperty.stringProperty(TrustManagerFactory.getDefaultAlgorithm(), QPID_SSL_TRUST_MANAGER_FACTORY_ALGORITHM_PROP_NAME, QPID_SSL_TRUST_STORE_CERT_TYPE_PROP_NAME).get(); - private String trustStorePath = System.getProperty("javax.net.ssl.trustStore"); - private String trustStorePassword = System.getProperty("javax.net.ssl.trustStorePassword"); - private String trustStoreType = System.getProperty("javax.net.ssl.trustStoreType",KeyStore.getDefaultType()); - private String certAlias; - private boolean verifyHostname; - - // SASL props - private String saslMechs = System.getProperty("qpid.sasl_mechs", null); - private String saslProtocol = System.getProperty("qpid.sasl_protocol", "AMQP"); - private String saslServerName = System.getProperty("qpid.sasl_server_name", "localhost"); - private boolean useSASLEncryption; - - private Map _clientProperties; - - public boolean isTcpNodelay() - { - return tcpNodelay; - } - - public void setTcpNodelay(boolean tcpNodelay) - { - this.tcpNodelay = tcpNodelay; - } - - /** - * Gets the heartbeat interval (seconds) for 0-8/9/9-1 protocols. - * 0 means heartbeating is disabled. - * null means use the broker-supplied value. - * @return the heartbeat interval - */ - public Integer getHeartbeatInterval08() - { - if (heartbeatInterval != null) - { - return heartbeatInterval; - } - else if (hearbeatIntervalLegacyMs != null) - { - return hearbeatIntervalLegacyMs / 1000; - } - else - { - return null; - } - } - - /** - * Gets the heartbeat interval (seconds) for the 0-10 protocol. - * 0 means heartbeating is disabled. - * @return the heartbeat interval - */ - public int getHeartbeatInterval010() - { - if (heartbeatInterval != null) - { - return heartbeatInterval; - } - else if (hearbeatIntervalLegacyMs != null) - { - return hearbeatIntervalLegacyMs / 1000; - } - else - { - return QPID_HEARTBEAT_INTERVAL_010_DEFAULT; - } - } - - public void setHeartbeatInterval(int heartbeatInterval) - { - this.heartbeatInterval = heartbeatInterval; - } - - public float getHeartbeatTimeoutFactor() - { - return this.heartbeatTimeoutFactor; - } - - public String getProtocol() - { - return protocol; - } - - public void setProtocol(String protocol) - { - this.protocol = protocol; - } - - public String getHost() - { - return host; - } - - public void setHost(String host) - { - this.host = host; - } - - public int getPort() - { - return port; - } - - public void setPort(int port) - { - this.port = port; - } - - public String getVhost() - { - return vhost; - } - - public void setVhost(String vhost) - { - this.vhost = vhost; - } - - public String getUsername() - { - return username; - } - - public void setUsername(String username) - { - this.username = username; - } - - public String getPassword() - { - return password; - } - - public void setPassword(String password) - { - this.password = password; - } - - public boolean isUseSSL() - { - return useSSL; - } - - public void setUseSSL(boolean useSSL) - { - this.useSSL = useSSL; - } - - public boolean isUseSASLEncryption() - { - return useSASLEncryption; - } - - public void setUseSASLEncryption(boolean useSASLEncryption) - { - this.useSASLEncryption = useSASLEncryption; - } - - public String getSaslMechs() - { - return saslMechs; - } - - public void setSaslMechs(String saslMechs) - { - this.saslMechs = saslMechs; - } - - public String getSaslProtocol() - { - return saslProtocol; - } - - public void setSaslProtocol(String saslProtocol) - { - this.saslProtocol = saslProtocol; - } - - public String getSaslServerName() - { - return saslServerName; - } - - public void setSaslServerName(String saslServerName) - { - this.saslServerName = saslServerName; - } - - public int getMaxChannelCount() - { - return maxChannelCount; - } - - public void setMaxChannelCount(int maxChannelCount) - { - this.maxChannelCount = maxChannelCount; - } - - public int getMaxFrameSize() - { - return maxFrameSize; - } - - public void setMaxFrameSize(int maxFrameSize) - { - this.maxFrameSize = maxFrameSize; - } - - public void setClientProperties(final Map clientProperties) - { - _clientProperties = clientProperties; - } - - public Map getClientProperties() - { - return _clientProperties; - } - - public String getKeyStorePath() - { - return keyStorePath; - } - - public void setKeyStorePath(String keyStorePath) - { - this.keyStorePath = keyStorePath; - } - - public String getKeyStorePassword() - { - return keyStorePassword; - } - - public void setKeyStorePassword(String keyStorePassword) - { - this.keyStorePassword = keyStorePassword; - } - - public void setKeyStoreType(String keyStoreType) - { - this.keyStoreType = keyStoreType; - } - - public String getKeyStoreType() - { - return keyStoreType; - } - - public String getTrustStorePath() - { - return trustStorePath; - } - - public void setTrustStorePath(String trustStorePath) - { - this.trustStorePath = trustStorePath; - } - - public String getTrustStorePassword() - { - return trustStorePassword; - } - - public void setTrustStorePassword(String trustStorePassword) - { - this.trustStorePassword = trustStorePassword; - } - - public String getCertAlias() - { - return certAlias; - } - - public void setCertAlias(String certAlias) - { - this.certAlias = certAlias; - } - - public boolean isVerifyHostname() - { - return verifyHostname; - } - - public void setVerifyHostname(boolean verifyHostname) - { - this.verifyHostname = verifyHostname; - } - - public String getKeyManagerFactoryAlgorithm() - { - return keyManagerFactoryAlgorithm; - } - - public void setKeyManagerFactoryAlgorithm(String keyManagerFactoryAlgorithm) - { - this.keyManagerFactoryAlgorithm = keyManagerFactoryAlgorithm; - } - - public String getTrustManagerFactoryAlgorithm() - { - return trustManagerFactoryAlgorithm; - } - - public void setTrustManagerFactoryAlgorithm(String trustManagerFactoryAlgorithm) - { - this.trustManagerFactoryAlgorithm = trustManagerFactoryAlgorithm; - } - - public String getTrustStoreType() - { - return trustStoreType; - } - - public void setTrustStoreType(String trustStoreType) - { - this.trustStoreType = trustStoreType; - } - - public int getConnectTimeout() - { - return connectTimeout; - } - - public void setConnectTimeout(int connectTimeout) - { - this.connectTimeout = connectTimeout; - } - - public int getReadBufferSize() - { - return readBufferSize; - } - - public void setReadBufferSize(int readBufferSize) - { - this.readBufferSize = readBufferSize; - } - - public int getWriteBufferSize() - { - return writeBufferSize; - } - - public void setWriteBufferSize(int writeBufferSize) - { - this.writeBufferSize = writeBufferSize; - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionStart.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionStart.java deleted file mode 100644 index 6193122c56..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionStart.java +++ /dev/null @@ -1,238 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class ConnectionStart extends Method { - - public static final int TYPE = 257; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L1; - } - - public final boolean isConnectionControl() - { - return true; - } - - private short packing_flags = 0; - private Map serverProperties; - private java.util.List mechanisms; - private java.util.List locales; - - - public ConnectionStart() {} - - - public ConnectionStart(Map serverProperties, java.util.List mechanisms, java.util.List locales, Option ... _options) { - if(serverProperties != null) { - setServerProperties(serverProperties); - } - if(mechanisms != null) { - setMechanisms(mechanisms); - } - if(locales != null) { - setLocales(locales); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.connectionStart(context, this); - } - - - public final boolean hasServerProperties() { - return (packing_flags & 256) != 0; - } - - public final ConnectionStart clearServerProperties() { - packing_flags &= ~256; - this.serverProperties = null; - setDirty(true); - return this; - } - - public final Map getServerProperties() { - return serverProperties; - } - - public final ConnectionStart setServerProperties(Map value) { - this.serverProperties = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final ConnectionStart serverProperties(Map value) { - return setServerProperties(value); - } - - public final boolean hasMechanisms() { - return (packing_flags & 512) != 0; - } - - public final ConnectionStart clearMechanisms() { - packing_flags &= ~512; - this.mechanisms = null; - setDirty(true); - return this; - } - - public final java.util.List getMechanisms() { - return mechanisms; - } - - public final ConnectionStart setMechanisms(java.util.List value) { - this.mechanisms = value; - packing_flags |= 512; - setDirty(true); - return this; - } - - public final ConnectionStart mechanisms(java.util.List value) { - return setMechanisms(value); - } - - public final boolean hasLocales() { - return (packing_flags & 1024) != 0; - } - - public final ConnectionStart clearLocales() { - packing_flags &= ~1024; - this.locales = null; - setDirty(true); - return this; - } - - public final java.util.List getLocales() { - return locales; - } - - public final ConnectionStart setLocales(java.util.List value) { - this.locales = value; - packing_flags |= 1024; - setDirty(true); - return this; - } - - public final ConnectionStart locales(java.util.List value) { - return setLocales(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeMap(this.serverProperties); - } - if ((packing_flags & 512) != 0) - { - enc.writeArray(this.mechanisms); - } - if ((packing_flags & 1024) != 0) - { - enc.writeArray(this.locales); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.serverProperties = dec.readMap(); - } - if ((packing_flags & 512) != 0) - { - this.mechanisms = dec.readArray(); - } - if ((packing_flags & 1024) != 0) - { - this.locales = dec.readArray(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("serverProperties", getServerProperties()); - } - if ((packing_flags & 512) != 0) - { - result.put("mechanisms", getMechanisms()); - } - if ((packing_flags & 1024) != 0) - { - result.put("locales", getLocales()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionStartOk.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionStartOk.java deleted file mode 100644 index 13fe27de34..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionStartOk.java +++ /dev/null @@ -1,280 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class ConnectionStartOk extends Method { - - public static final int TYPE = 258; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L1; - } - - public final boolean isConnectionControl() - { - return true; - } - - private short packing_flags = 0; - private Map clientProperties; - private String mechanism; - private byte[] response; - private String locale; - - - public ConnectionStartOk() {} - - - public ConnectionStartOk(Map clientProperties, String mechanism, byte[] response, String locale, Option ... _options) { - if(clientProperties != null) { - setClientProperties(clientProperties); - } - if(mechanism != null) { - setMechanism(mechanism); - } - if(response != null) { - setResponse(response); - } - if(locale != null) { - setLocale(locale); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.connectionStartOk(context, this); - } - - - public final boolean hasClientProperties() { - return (packing_flags & 256) != 0; - } - - public final ConnectionStartOk clearClientProperties() { - packing_flags &= ~256; - this.clientProperties = null; - setDirty(true); - return this; - } - - public final Map getClientProperties() { - return clientProperties; - } - - public final ConnectionStartOk setClientProperties(Map value) { - this.clientProperties = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final ConnectionStartOk clientProperties(Map value) { - return setClientProperties(value); - } - - public final boolean hasMechanism() { - return (packing_flags & 512) != 0; - } - - public final ConnectionStartOk clearMechanism() { - packing_flags &= ~512; - this.mechanism = null; - setDirty(true); - return this; - } - - public final String getMechanism() { - return mechanism; - } - - public final ConnectionStartOk setMechanism(String value) { - this.mechanism = value; - packing_flags |= 512; - setDirty(true); - return this; - } - - public final ConnectionStartOk mechanism(String value) { - return setMechanism(value); - } - - public final boolean hasResponse() { - return (packing_flags & 1024) != 0; - } - - public final ConnectionStartOk clearResponse() { - packing_flags &= ~1024; - this.response = null; - setDirty(true); - return this; - } - - public final byte[] getResponse() { - return response; - } - - public final ConnectionStartOk setResponse(byte[] value) { - this.response = value; - packing_flags |= 1024; - setDirty(true); - return this; - } - - public final ConnectionStartOk response(byte[] value) { - return setResponse(value); - } - - public final boolean hasLocale() { - return (packing_flags & 2048) != 0; - } - - public final ConnectionStartOk clearLocale() { - packing_flags &= ~2048; - this.locale = null; - setDirty(true); - return this; - } - - public final String getLocale() { - return locale; - } - - public final ConnectionStartOk setLocale(String value) { - this.locale = value; - packing_flags |= 2048; - setDirty(true); - return this; - } - - public final ConnectionStartOk locale(String value) { - return setLocale(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeMap(this.clientProperties); - } - if ((packing_flags & 512) != 0) - { - enc.writeStr8(this.mechanism); - } - if ((packing_flags & 1024) != 0) - { - enc.writeVbin32(this.response); - } - if ((packing_flags & 2048) != 0) - { - enc.writeStr8(this.locale); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.clientProperties = dec.readMap(); - } - if ((packing_flags & 512) != 0) - { - this.mechanism = dec.readStr8(); - } - if ((packing_flags & 1024) != 0) - { - this.response = dec.readVbin32(); - } - if ((packing_flags & 2048) != 0) - { - this.locale = dec.readStr8(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("clientProperties", getClientProperties()); - } - if ((packing_flags & 512) != 0) - { - result.put("mechanism", getMechanism()); - } - if ((packing_flags & 1024) != 0) - { - result.put("response", getResponse()); - } - if ((packing_flags & 2048) != 0) - { - result.put("locale", getLocale()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionTune.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionTune.java deleted file mode 100644 index b838532878..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionTune.java +++ /dev/null @@ -1,272 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class ConnectionTune extends Method { - - public static final int TYPE = 261; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L1; - } - - public final boolean isConnectionControl() - { - return true; - } - - private short packing_flags = 0; - private int channelMax; - private int maxFrameSize; - private int heartbeatMin; - private int heartbeatMax; - - - public ConnectionTune() {} - - - public ConnectionTune(int channelMax, int maxFrameSize, int heartbeatMin, int heartbeatMax, Option ... _options) { - setChannelMax(channelMax); - setMaxFrameSize(maxFrameSize); - setHeartbeatMin(heartbeatMin); - setHeartbeatMax(heartbeatMax); - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.connectionTune(context, this); - } - - - public final boolean hasChannelMax() { - return (packing_flags & 256) != 0; - } - - public final ConnectionTune clearChannelMax() { - packing_flags &= ~256; - this.channelMax = 0; - setDirty(true); - return this; - } - - public final int getChannelMax() { - return channelMax; - } - - public final ConnectionTune setChannelMax(int value) { - this.channelMax = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final ConnectionTune channelMax(int value) { - return setChannelMax(value); - } - - public final boolean hasMaxFrameSize() { - return (packing_flags & 512) != 0; - } - - public final ConnectionTune clearMaxFrameSize() { - packing_flags &= ~512; - this.maxFrameSize = 0; - setDirty(true); - return this; - } - - public final int getMaxFrameSize() { - return maxFrameSize; - } - - public final ConnectionTune setMaxFrameSize(int value) { - this.maxFrameSize = value; - packing_flags |= 512; - setDirty(true); - return this; - } - - public final ConnectionTune maxFrameSize(int value) { - return setMaxFrameSize(value); - } - - public final boolean hasHeartbeatMin() { - return (packing_flags & 1024) != 0; - } - - public final ConnectionTune clearHeartbeatMin() { - packing_flags &= ~1024; - this.heartbeatMin = 0; - setDirty(true); - return this; - } - - public final int getHeartbeatMin() { - return heartbeatMin; - } - - public final ConnectionTune setHeartbeatMin(int value) { - this.heartbeatMin = value; - packing_flags |= 1024; - setDirty(true); - return this; - } - - public final ConnectionTune heartbeatMin(int value) { - return setHeartbeatMin(value); - } - - public final boolean hasHeartbeatMax() { - return (packing_flags & 2048) != 0; - } - - public final ConnectionTune clearHeartbeatMax() { - packing_flags &= ~2048; - this.heartbeatMax = 0; - setDirty(true); - return this; - } - - public final int getHeartbeatMax() { - return heartbeatMax; - } - - public final ConnectionTune setHeartbeatMax(int value) { - this.heartbeatMax = value; - packing_flags |= 2048; - setDirty(true); - return this; - } - - public final ConnectionTune heartbeatMax(int value) { - return setHeartbeatMax(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeUint16(this.channelMax); - } - if ((packing_flags & 512) != 0) - { - enc.writeUint16(this.maxFrameSize); - } - if ((packing_flags & 1024) != 0) - { - enc.writeUint16(this.heartbeatMin); - } - if ((packing_flags & 2048) != 0) - { - enc.writeUint16(this.heartbeatMax); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.channelMax = dec.readUint16(); - } - if ((packing_flags & 512) != 0) - { - this.maxFrameSize = dec.readUint16(); - } - if ((packing_flags & 1024) != 0) - { - this.heartbeatMin = dec.readUint16(); - } - if ((packing_flags & 2048) != 0) - { - this.heartbeatMax = dec.readUint16(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("channelMax", getChannelMax()); - } - if ((packing_flags & 512) != 0) - { - result.put("maxFrameSize", getMaxFrameSize()); - } - if ((packing_flags & 1024) != 0) - { - result.put("heartbeatMin", getHeartbeatMin()); - } - if ((packing_flags & 2048) != 0) - { - result.put("heartbeatMax", getHeartbeatMax()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionTuneOk.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionTuneOk.java deleted file mode 100644 index 17b5d34752..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ConnectionTuneOk.java +++ /dev/null @@ -1,232 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class ConnectionTuneOk extends Method { - - public static final int TYPE = 262; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L1; - } - - public final boolean isConnectionControl() - { - return true; - } - - private short packing_flags = 0; - private int channelMax; - private int maxFrameSize; - private int heartbeat; - - - public ConnectionTuneOk() {} - - - public ConnectionTuneOk(int channelMax, int maxFrameSize, int heartbeat, Option ... _options) { - setChannelMax(channelMax); - setMaxFrameSize(maxFrameSize); - setHeartbeat(heartbeat); - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.connectionTuneOk(context, this); - } - - - public final boolean hasChannelMax() { - return (packing_flags & 256) != 0; - } - - public final ConnectionTuneOk clearChannelMax() { - packing_flags &= ~256; - this.channelMax = 0; - setDirty(true); - return this; - } - - public final int getChannelMax() { - return channelMax; - } - - public final ConnectionTuneOk setChannelMax(int value) { - this.channelMax = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final ConnectionTuneOk channelMax(int value) { - return setChannelMax(value); - } - - public final boolean hasMaxFrameSize() { - return (packing_flags & 512) != 0; - } - - public final ConnectionTuneOk clearMaxFrameSize() { - packing_flags &= ~512; - this.maxFrameSize = 0; - setDirty(true); - return this; - } - - public final int getMaxFrameSize() { - return maxFrameSize; - } - - public final ConnectionTuneOk setMaxFrameSize(int value) { - this.maxFrameSize = value; - packing_flags |= 512; - setDirty(true); - return this; - } - - public final ConnectionTuneOk maxFrameSize(int value) { - return setMaxFrameSize(value); - } - - public final boolean hasHeartbeat() { - return (packing_flags & 1024) != 0; - } - - public final ConnectionTuneOk clearHeartbeat() { - packing_flags &= ~1024; - this.heartbeat = 0; - setDirty(true); - return this; - } - - public final int getHeartbeat() { - return heartbeat; - } - - public final ConnectionTuneOk setHeartbeat(int value) { - this.heartbeat = value; - packing_flags |= 1024; - setDirty(true); - return this; - } - - public final ConnectionTuneOk heartbeat(int value) { - return setHeartbeat(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeUint16(this.channelMax); - } - if ((packing_flags & 512) != 0) - { - enc.writeUint16(this.maxFrameSize); - } - if ((packing_flags & 1024) != 0) - { - enc.writeUint16(this.heartbeat); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.channelMax = dec.readUint16(); - } - if ((packing_flags & 512) != 0) - { - this.maxFrameSize = dec.readUint16(); - } - if ((packing_flags & 1024) != 0) - { - this.heartbeat = dec.readUint16(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("channelMax", getChannelMax()); - } - if ((packing_flags & 512) != 0) - { - result.put("maxFrameSize", getMaxFrameSize()); - } - if ((packing_flags & 1024) != 0) - { - result.put("heartbeat", getHeartbeat()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/Constant.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/Constant.java deleted file mode 100644 index 17355d3465..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/Constant.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - - - -public interface Constant -{ - public static final int MIN_MAX_FRAME_SIZE = 4096; -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/DeliveryProperties.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/DeliveryProperties.java deleted file mode 100644 index ded5a42247..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/DeliveryProperties.java +++ /dev/null @@ -1,593 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - - - -public final class DeliveryProperties extends Struct { - - public static final int TYPE = 1025; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 4; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return -1; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private MessageDeliveryPriority priority; - private MessageDeliveryMode deliveryMode; - private long ttl; - private long timestamp; - private long expiration; - private String exchange; - private String routingKey; - private String resumeId; - private long resumeTtl; - - - public DeliveryProperties() {} - - - public DeliveryProperties(MessageDeliveryPriority priority, MessageDeliveryMode deliveryMode, long ttl, long timestamp, long expiration, String exchange, String routingKey, String resumeId, long resumeTtl, Option ... _options) { - if(priority != null) { - setPriority(priority); - } - if(deliveryMode != null) { - setDeliveryMode(deliveryMode); - } - setTtl(ttl); - setTimestamp(timestamp); - setExpiration(expiration); - if(exchange != null) { - setExchange(exchange); - } - if(routingKey != null) { - setRoutingKey(routingKey); - } - if(resumeId != null) { - setResumeId(resumeId); - } - setResumeTtl(resumeTtl); - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case DISCARD_UNROUTABLE: packing_flags |= 256; break; - case IMMEDIATE: packing_flags |= 512; break; - case REDELIVERED: packing_flags |= 1024; break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - - - - public final boolean hasDiscardUnroutable() { - return (packing_flags & 256) != 0; - } - - public final DeliveryProperties clearDiscardUnroutable() { - packing_flags &= ~256; - - setDirty(true); - return this; - } - - public final boolean getDiscardUnroutable() { - return hasDiscardUnroutable(); - } - - public final DeliveryProperties setDiscardUnroutable(boolean value) { - - if (value) - { - packing_flags |= 256; - } - else - { - packing_flags &= ~256; - } - - setDirty(true); - return this; - } - - public final DeliveryProperties discardUnroutable(boolean value) { - return setDiscardUnroutable(value); - } - - public final boolean hasImmediate() { - return (packing_flags & 512) != 0; - } - - public final DeliveryProperties clearImmediate() { - packing_flags &= ~512; - - setDirty(true); - return this; - } - - public final boolean getImmediate() { - return hasImmediate(); - } - - public final DeliveryProperties setImmediate(boolean value) { - - if (value) - { - packing_flags |= 512; - } - else - { - packing_flags &= ~512; - } - - setDirty(true); - return this; - } - - public final DeliveryProperties immediate(boolean value) { - return setImmediate(value); - } - - public final boolean hasRedelivered() { - return (packing_flags & 1024) != 0; - } - - public final DeliveryProperties clearRedelivered() { - packing_flags &= ~1024; - - setDirty(true); - return this; - } - - public final boolean getRedelivered() { - return hasRedelivered(); - } - - public final DeliveryProperties setRedelivered(boolean value) { - - if (value) - { - packing_flags |= 1024; - } - else - { - packing_flags &= ~1024; - } - - setDirty(true); - return this; - } - - public final DeliveryProperties redelivered(boolean value) { - return setRedelivered(value); - } - - public final boolean hasPriority() { - return (packing_flags & 2048) != 0; - } - - public final DeliveryProperties clearPriority() { - packing_flags &= ~2048; - this.priority = null; - setDirty(true); - return this; - } - - public final MessageDeliveryPriority getPriority() { - return priority; - } - - public final DeliveryProperties setPriority(MessageDeliveryPriority value) { - this.priority = value; - packing_flags |= 2048; - setDirty(true); - return this; - } - - public final DeliveryProperties priority(MessageDeliveryPriority value) { - return setPriority(value); - } - - public final boolean hasDeliveryMode() { - return (packing_flags & 4096) != 0; - } - - public final DeliveryProperties clearDeliveryMode() { - packing_flags &= ~4096; - this.deliveryMode = null; - setDirty(true); - return this; - } - - public final MessageDeliveryMode getDeliveryMode() { - return deliveryMode; - } - - public final DeliveryProperties setDeliveryMode(MessageDeliveryMode value) { - this.deliveryMode = value; - packing_flags |= 4096; - setDirty(true); - return this; - } - - public final DeliveryProperties deliveryMode(MessageDeliveryMode value) { - return setDeliveryMode(value); - } - - public final boolean hasTtl() { - return (packing_flags & 8192) != 0; - } - - public final DeliveryProperties clearTtl() { - packing_flags &= ~8192; - this.ttl = 0; - setDirty(true); - return this; - } - - public final long getTtl() { - return ttl; - } - - public final DeliveryProperties setTtl(long value) { - this.ttl = value; - packing_flags |= 8192; - setDirty(true); - return this; - } - - public final DeliveryProperties ttl(long value) { - return setTtl(value); - } - - public final boolean hasTimestamp() { - return (packing_flags & 16384) != 0; - } - - public final DeliveryProperties clearTimestamp() { - packing_flags &= ~16384; - this.timestamp = 0; - setDirty(true); - return this; - } - - public final long getTimestamp() { - return timestamp; - } - - public final DeliveryProperties setTimestamp(long value) { - this.timestamp = value; - packing_flags |= 16384; - setDirty(true); - return this; - } - - public final DeliveryProperties timestamp(long value) { - return setTimestamp(value); - } - - public final boolean hasExpiration() { - return (packing_flags & 32768) != 0; - } - - public final DeliveryProperties clearExpiration() { - packing_flags &= ~32768; - this.expiration = 0; - setDirty(true); - return this; - } - - public final long getExpiration() { - return expiration; - } - - public final DeliveryProperties setExpiration(long value) { - this.expiration = value; - packing_flags |= 32768; - setDirty(true); - return this; - } - - public final DeliveryProperties expiration(long value) { - return setExpiration(value); - } - - public final boolean hasExchange() { - return (packing_flags & 1) != 0; - } - - public final DeliveryProperties clearExchange() { - packing_flags &= ~1; - this.exchange = null; - setDirty(true); - return this; - } - - public final String getExchange() { - return exchange; - } - - public final DeliveryProperties setExchange(String value) { - this.exchange = value; - packing_flags |= 1; - setDirty(true); - return this; - } - - public final DeliveryProperties exchange(String value) { - return setExchange(value); - } - - public final boolean hasRoutingKey() { - return (packing_flags & 2) != 0; - } - - public final DeliveryProperties clearRoutingKey() { - packing_flags &= ~2; - this.routingKey = null; - setDirty(true); - return this; - } - - public final String getRoutingKey() { - return routingKey; - } - - public final DeliveryProperties setRoutingKey(String value) { - this.routingKey = value; - packing_flags |= 2; - setDirty(true); - return this; - } - - public final DeliveryProperties routingKey(String value) { - return setRoutingKey(value); - } - - public final boolean hasResumeId() { - return (packing_flags & 4) != 0; - } - - public final DeliveryProperties clearResumeId() { - packing_flags &= ~4; - this.resumeId = null; - setDirty(true); - return this; - } - - public final String getResumeId() { - return resumeId; - } - - public final DeliveryProperties setResumeId(String value) { - this.resumeId = value; - packing_flags |= 4; - setDirty(true); - return this; - } - - public final DeliveryProperties resumeId(String value) { - return setResumeId(value); - } - - public final boolean hasResumeTtl() { - return (packing_flags & 8) != 0; - } - - public final DeliveryProperties clearResumeTtl() { - packing_flags &= ~8; - this.resumeTtl = 0; - setDirty(true); - return this; - } - - public final long getResumeTtl() { - return resumeTtl; - } - - public final DeliveryProperties setResumeTtl(long value) { - this.resumeTtl = value; - packing_flags |= 8; - setDirty(true); - return this; - } - - public final DeliveryProperties resumeTtl(long value) { - return setResumeTtl(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 2048) != 0) - { - enc.writeUint8(this.priority.getValue()); - } - if ((packing_flags & 4096) != 0) - { - enc.writeUint8(this.deliveryMode.getValue()); - } - if ((packing_flags & 8192) != 0) - { - enc.writeUint64(this.ttl); - } - if ((packing_flags & 16384) != 0) - { - enc.writeDatetime(this.timestamp); - } - if ((packing_flags & 32768) != 0) - { - enc.writeDatetime(this.expiration); - } - if ((packing_flags & 1) != 0) - { - enc.writeStr8(this.exchange); - } - if ((packing_flags & 2) != 0) - { - enc.writeStr8(this.routingKey); - } - if ((packing_flags & 4) != 0) - { - enc.writeStr16(this.resumeId); - } - if ((packing_flags & 8) != 0) - { - enc.writeUint64(this.resumeTtl); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 2048) != 0) - { - this.priority = MessageDeliveryPriority.get(dec.readUint8()); - } - if ((packing_flags & 4096) != 0) - { - this.deliveryMode = MessageDeliveryMode.get(dec.readUint8()); - } - if ((packing_flags & 8192) != 0) - { - this.ttl = dec.readUint64(); - } - if ((packing_flags & 16384) != 0) - { - this.timestamp = dec.readDatetime(); - } - if ((packing_flags & 32768) != 0) - { - this.expiration = dec.readDatetime(); - } - if ((packing_flags & 1) != 0) - { - this.exchange = dec.readStr8(); - } - if ((packing_flags & 2) != 0) - { - this.routingKey = dec.readStr8(); - } - if ((packing_flags & 4) != 0) - { - this.resumeId = dec.readStr16(); - } - if ((packing_flags & 8) != 0) - { - this.resumeTtl = dec.readUint64(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("discardUnroutable", getDiscardUnroutable()); - } - if ((packing_flags & 512) != 0) - { - result.put("immediate", getImmediate()); - } - if ((packing_flags & 1024) != 0) - { - result.put("redelivered", getRedelivered()); - } - if ((packing_flags & 2048) != 0) - { - result.put("priority", getPriority()); - } - if ((packing_flags & 4096) != 0) - { - result.put("deliveryMode", getDeliveryMode()); - } - if ((packing_flags & 8192) != 0) - { - result.put("ttl", getTtl()); - } - if ((packing_flags & 16384) != 0) - { - result.put("timestamp", getTimestamp()); - } - if ((packing_flags & 32768) != 0) - { - result.put("expiration", getExpiration()); - } - if ((packing_flags & 1) != 0) - { - result.put("exchange", getExchange()); - } - if ((packing_flags & 2) != 0) - { - result.put("routingKey", getRoutingKey()); - } - if ((packing_flags & 4) != 0) - { - result.put("resumeId", getResumeId()); - } - if ((packing_flags & 8) != 0) - { - result.put("resumeTtl", getResumeTtl()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/DtxCommit.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/DtxCommit.java deleted file mode 100644 index 315b37025d..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/DtxCommit.java +++ /dev/null @@ -1,193 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class DtxCommit extends Method { - - public static final int TYPE = 1540; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private Xid xid; - - - public DtxCommit() {} - - - public DtxCommit(Xid xid, Option ... _options) { - if(xid != null) { - setXid(xid); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case ONE_PHASE: packing_flags |= 512; break; - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.dtxCommit(context, this); - } - - - public final boolean hasXid() { - return (packing_flags & 256) != 0; - } - - public final DtxCommit clearXid() { - packing_flags &= ~256; - this.xid = null; - setDirty(true); - return this; - } - - public final Xid getXid() { - return xid; - } - - public final DtxCommit setXid(Xid value) { - this.xid = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final DtxCommit xid(Xid value) { - return setXid(value); - } - - public final boolean hasOnePhase() { - return (packing_flags & 512) != 0; - } - - public final DtxCommit clearOnePhase() { - packing_flags &= ~512; - - setDirty(true); - return this; - } - - public final boolean getOnePhase() { - return hasOnePhase(); - } - - public final DtxCommit setOnePhase(boolean value) { - - if (value) - { - packing_flags |= 512; - } - else - { - packing_flags &= ~512; - } - - setDirty(true); - return this; - } - - public final DtxCommit onePhase(boolean value) { - return setOnePhase(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeStruct(Xid.TYPE, this.xid); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.xid = (Xid)dec.readStruct(Xid.TYPE); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("xid", getXid()); - } - if ((packing_flags & 512) != 0) - { - result.put("onePhase", getOnePhase()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/DtxEnd.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/DtxEnd.java deleted file mode 100644 index 70cac46379..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/DtxEnd.java +++ /dev/null @@ -1,232 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class DtxEnd extends Method { - - public static final int TYPE = 1539; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private Xid xid; - - - public DtxEnd() {} - - - public DtxEnd(Xid xid, Option ... _options) { - if(xid != null) { - setXid(xid); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case FAIL: packing_flags |= 512; break; - case SUSPEND: packing_flags |= 1024; break; - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.dtxEnd(context, this); - } - - - public final boolean hasXid() { - return (packing_flags & 256) != 0; - } - - public final DtxEnd clearXid() { - packing_flags &= ~256; - this.xid = null; - setDirty(true); - return this; - } - - public final Xid getXid() { - return xid; - } - - public final DtxEnd setXid(Xid value) { - this.xid = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final DtxEnd xid(Xid value) { - return setXid(value); - } - - public final boolean hasFail() { - return (packing_flags & 512) != 0; - } - - public final DtxEnd clearFail() { - packing_flags &= ~512; - - setDirty(true); - return this; - } - - public final boolean getFail() { - return hasFail(); - } - - public final DtxEnd setFail(boolean value) { - - if (value) - { - packing_flags |= 512; - } - else - { - packing_flags &= ~512; - } - - setDirty(true); - return this; - } - - public final DtxEnd fail(boolean value) { - return setFail(value); - } - - public final boolean hasSuspend() { - return (packing_flags & 1024) != 0; - } - - public final DtxEnd clearSuspend() { - packing_flags &= ~1024; - - setDirty(true); - return this; - } - - public final boolean getSuspend() { - return hasSuspend(); - } - - public final DtxEnd setSuspend(boolean value) { - - if (value) - { - packing_flags |= 1024; - } - else - { - packing_flags &= ~1024; - } - - setDirty(true); - return this; - } - - public final DtxEnd suspend(boolean value) { - return setSuspend(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeStruct(Xid.TYPE, this.xid); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.xid = (Xid)dec.readStruct(Xid.TYPE); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("xid", getXid()); - } - if ((packing_flags & 512) != 0) - { - result.put("fail", getFail()); - } - if ((packing_flags & 1024) != 0) - { - result.put("suspend", getSuspend()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/DtxForget.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/DtxForget.java deleted file mode 100644 index 0d57488e78..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/DtxForget.java +++ /dev/null @@ -1,154 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class DtxForget extends Method { - - public static final int TYPE = 1541; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private Xid xid; - - - public DtxForget() {} - - - public DtxForget(Xid xid, Option ... _options) { - if(xid != null) { - setXid(xid); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.dtxForget(context, this); - } - - - public final boolean hasXid() { - return (packing_flags & 256) != 0; - } - - public final DtxForget clearXid() { - packing_flags &= ~256; - this.xid = null; - setDirty(true); - return this; - } - - public final Xid getXid() { - return xid; - } - - public final DtxForget setXid(Xid value) { - this.xid = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final DtxForget xid(Xid value) { - return setXid(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeStruct(Xid.TYPE, this.xid); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.xid = (Xid)dec.readStruct(Xid.TYPE); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("xid", getXid()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/DtxGetTimeout.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/DtxGetTimeout.java deleted file mode 100644 index 42293a865f..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/DtxGetTimeout.java +++ /dev/null @@ -1,154 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class DtxGetTimeout extends Method { - - public static final int TYPE = 1542; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private Xid xid; - - - public DtxGetTimeout() {} - - - public DtxGetTimeout(Xid xid, Option ... _options) { - if(xid != null) { - setXid(xid); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.dtxGetTimeout(context, this); - } - - - public final boolean hasXid() { - return (packing_flags & 256) != 0; - } - - public final DtxGetTimeout clearXid() { - packing_flags &= ~256; - this.xid = null; - setDirty(true); - return this; - } - - public final Xid getXid() { - return xid; - } - - public final DtxGetTimeout setXid(Xid value) { - this.xid = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final DtxGetTimeout xid(Xid value) { - return setXid(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeStruct(Xid.TYPE, this.xid); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.xid = (Xid)dec.readStruct(Xid.TYPE); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("xid", getXid()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/DtxPrepare.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/DtxPrepare.java deleted file mode 100644 index 8a771e638f..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/DtxPrepare.java +++ /dev/null @@ -1,154 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class DtxPrepare extends Method { - - public static final int TYPE = 1543; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private Xid xid; - - - public DtxPrepare() {} - - - public DtxPrepare(Xid xid, Option ... _options) { - if(xid != null) { - setXid(xid); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.dtxPrepare(context, this); - } - - - public final boolean hasXid() { - return (packing_flags & 256) != 0; - } - - public final DtxPrepare clearXid() { - packing_flags &= ~256; - this.xid = null; - setDirty(true); - return this; - } - - public final Xid getXid() { - return xid; - } - - public final DtxPrepare setXid(Xid value) { - this.xid = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final DtxPrepare xid(Xid value) { - return setXid(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeStruct(Xid.TYPE, this.xid); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.xid = (Xid)dec.readStruct(Xid.TYPE); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("xid", getXid()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/DtxRecover.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/DtxRecover.java deleted file mode 100644 index bbda4a0a60..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/DtxRecover.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class DtxRecover extends Method { - - public static final int TYPE = 1544; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - - - - - public DtxRecover(Option ... _options) { - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.dtxRecover(context, this); - } - - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/DtxRollback.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/DtxRollback.java deleted file mode 100644 index d3cb28638c..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/DtxRollback.java +++ /dev/null @@ -1,154 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class DtxRollback extends Method { - - public static final int TYPE = 1545; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private Xid xid; - - - public DtxRollback() {} - - - public DtxRollback(Xid xid, Option ... _options) { - if(xid != null) { - setXid(xid); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.dtxRollback(context, this); - } - - - public final boolean hasXid() { - return (packing_flags & 256) != 0; - } - - public final DtxRollback clearXid() { - packing_flags &= ~256; - this.xid = null; - setDirty(true); - return this; - } - - public final Xid getXid() { - return xid; - } - - public final DtxRollback setXid(Xid value) { - this.xid = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final DtxRollback xid(Xid value) { - return setXid(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeStruct(Xid.TYPE, this.xid); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.xid = (Xid)dec.readStruct(Xid.TYPE); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("xid", getXid()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/DtxSelect.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/DtxSelect.java deleted file mode 100644 index b70a4884ff..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/DtxSelect.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class DtxSelect extends Method { - - public static final int TYPE = 1537; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - - - - - public DtxSelect(Option ... _options) { - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.dtxSelect(context, this); - } - - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/DtxSetTimeout.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/DtxSetTimeout.java deleted file mode 100644 index 0c8b78e12c..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/DtxSetTimeout.java +++ /dev/null @@ -1,194 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class DtxSetTimeout extends Method { - - public static final int TYPE = 1546; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private Xid xid; - private long timeout; - - - public DtxSetTimeout() {} - - - public DtxSetTimeout(Xid xid, long timeout, Option ... _options) { - if(xid != null) { - setXid(xid); - } - setTimeout(timeout); - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.dtxSetTimeout(context, this); - } - - - public final boolean hasXid() { - return (packing_flags & 256) != 0; - } - - public final DtxSetTimeout clearXid() { - packing_flags &= ~256; - this.xid = null; - setDirty(true); - return this; - } - - public final Xid getXid() { - return xid; - } - - public final DtxSetTimeout setXid(Xid value) { - this.xid = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final DtxSetTimeout xid(Xid value) { - return setXid(value); - } - - public final boolean hasTimeout() { - return (packing_flags & 512) != 0; - } - - public final DtxSetTimeout clearTimeout() { - packing_flags &= ~512; - this.timeout = 0; - setDirty(true); - return this; - } - - public final long getTimeout() { - return timeout; - } - - public final DtxSetTimeout setTimeout(long value) { - this.timeout = value; - packing_flags |= 512; - setDirty(true); - return this; - } - - public final DtxSetTimeout timeout(long value) { - return setTimeout(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeStruct(Xid.TYPE, this.xid); - } - if ((packing_flags & 512) != 0) - { - enc.writeUint32(this.timeout); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.xid = (Xid)dec.readStruct(Xid.TYPE); - } - if ((packing_flags & 512) != 0) - { - this.timeout = dec.readUint32(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("xid", getXid()); - } - if ((packing_flags & 512) != 0) - { - result.put("timeout", getTimeout()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/DtxStart.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/DtxStart.java deleted file mode 100644 index 7e60f1fbf1..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/DtxStart.java +++ /dev/null @@ -1,232 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class DtxStart extends Method { - - public static final int TYPE = 1538; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private Xid xid; - - - public DtxStart() {} - - - public DtxStart(Xid xid, Option ... _options) { - if(xid != null) { - setXid(xid); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case JOIN: packing_flags |= 512; break; - case RESUME: packing_flags |= 1024; break; - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.dtxStart(context, this); - } - - - public final boolean hasXid() { - return (packing_flags & 256) != 0; - } - - public final DtxStart clearXid() { - packing_flags &= ~256; - this.xid = null; - setDirty(true); - return this; - } - - public final Xid getXid() { - return xid; - } - - public final DtxStart setXid(Xid value) { - this.xid = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final DtxStart xid(Xid value) { - return setXid(value); - } - - public final boolean hasJoin() { - return (packing_flags & 512) != 0; - } - - public final DtxStart clearJoin() { - packing_flags &= ~512; - - setDirty(true); - return this; - } - - public final boolean getJoin() { - return hasJoin(); - } - - public final DtxStart setJoin(boolean value) { - - if (value) - { - packing_flags |= 512; - } - else - { - packing_flags &= ~512; - } - - setDirty(true); - return this; - } - - public final DtxStart join(boolean value) { - return setJoin(value); - } - - public final boolean hasResume() { - return (packing_flags & 1024) != 0; - } - - public final DtxStart clearResume() { - packing_flags &= ~1024; - - setDirty(true); - return this; - } - - public final boolean getResume() { - return hasResume(); - } - - public final DtxStart setResume(boolean value) { - - if (value) - { - packing_flags |= 1024; - } - else - { - packing_flags &= ~1024; - } - - setDirty(true); - return this; - } - - public final DtxStart resume(boolean value) { - return setResume(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeStruct(Xid.TYPE, this.xid); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.xid = (Xid)dec.readStruct(Xid.TYPE); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("xid", getXid()); - } - if ((packing_flags & 512) != 0) - { - result.put("join", getJoin()); - } - if ((packing_flags & 1024) != 0) - { - result.put("resume", getResume()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/DtxXaStatus.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/DtxXaStatus.java deleted file mode 100644 index 9300354ad4..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/DtxXaStatus.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -public enum DtxXaStatus { - - XA_OK((int) 0), - XA_RBROLLBACK((int) 1), - XA_RBTIMEOUT((int) 2), - XA_HEURHAZ((int) 3), - XA_HEURCOM((int) 4), - XA_HEURRB((int) 5), - XA_HEURMIX((int) 6), - XA_RDONLY((int) 7); - - private final int value; - - DtxXaStatus(int value) - { - this.value = value; - } - - public int getValue() - { - return value; - } - - public static DtxXaStatus get(int value) - { - switch (value) - { - case (int) 0: return XA_OK; - case (int) 1: return XA_RBROLLBACK; - case (int) 2: return XA_RBTIMEOUT; - case (int) 3: return XA_HEURHAZ; - case (int) 4: return XA_HEURCOM; - case (int) 5: return XA_HEURRB; - case (int) 6: return XA_HEURMIX; - case (int) 7: return XA_RDONLY; - default: throw new IllegalArgumentException("no such value: " + value); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ExchangeBind.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ExchangeBind.java deleted file mode 100644 index 6ef3b0b460..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ExchangeBind.java +++ /dev/null @@ -1,280 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class ExchangeBind extends Method { - - public static final int TYPE = 1796; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private String queue; - private String exchange; - private String bindingKey; - private Map arguments; - - - public ExchangeBind() {} - - - public ExchangeBind(String queue, String exchange, String bindingKey, Map arguments, Option ... _options) { - if(queue != null) { - setQueue(queue); - } - if(exchange != null) { - setExchange(exchange); - } - if(bindingKey != null) { - setBindingKey(bindingKey); - } - if(arguments != null) { - setArguments(arguments); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.exchangeBind(context, this); - } - - - public final boolean hasQueue() { - return (packing_flags & 256) != 0; - } - - public final ExchangeBind clearQueue() { - packing_flags &= ~256; - this.queue = null; - setDirty(true); - return this; - } - - public final String getQueue() { - return queue; - } - - public final ExchangeBind setQueue(String value) { - this.queue = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final ExchangeBind queue(String value) { - return setQueue(value); - } - - public final boolean hasExchange() { - return (packing_flags & 512) != 0; - } - - public final ExchangeBind clearExchange() { - packing_flags &= ~512; - this.exchange = null; - setDirty(true); - return this; - } - - public final String getExchange() { - return exchange; - } - - public final ExchangeBind setExchange(String value) { - this.exchange = value; - packing_flags |= 512; - setDirty(true); - return this; - } - - public final ExchangeBind exchange(String value) { - return setExchange(value); - } - - public final boolean hasBindingKey() { - return (packing_flags & 1024) != 0; - } - - public final ExchangeBind clearBindingKey() { - packing_flags &= ~1024; - this.bindingKey = null; - setDirty(true); - return this; - } - - public final String getBindingKey() { - return bindingKey; - } - - public final ExchangeBind setBindingKey(String value) { - this.bindingKey = value; - packing_flags |= 1024; - setDirty(true); - return this; - } - - public final ExchangeBind bindingKey(String value) { - return setBindingKey(value); - } - - public final boolean hasArguments() { - return (packing_flags & 2048) != 0; - } - - public final ExchangeBind clearArguments() { - packing_flags &= ~2048; - this.arguments = null; - setDirty(true); - return this; - } - - public final Map getArguments() { - return arguments; - } - - public final ExchangeBind setArguments(Map value) { - this.arguments = value; - packing_flags |= 2048; - setDirty(true); - return this; - } - - public final ExchangeBind arguments(Map value) { - return setArguments(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeStr8(this.queue); - } - if ((packing_flags & 512) != 0) - { - enc.writeStr8(this.exchange); - } - if ((packing_flags & 1024) != 0) - { - enc.writeStr8(this.bindingKey); - } - if ((packing_flags & 2048) != 0) - { - enc.writeMap(this.arguments); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.queue = dec.readStr8(); - } - if ((packing_flags & 512) != 0) - { - this.exchange = dec.readStr8(); - } - if ((packing_flags & 1024) != 0) - { - this.bindingKey = dec.readStr8(); - } - if ((packing_flags & 2048) != 0) - { - this.arguments = dec.readMap(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("queue", getQueue()); - } - if ((packing_flags & 512) != 0) - { - result.put("exchange", getExchange()); - } - if ((packing_flags & 1024) != 0) - { - result.put("bindingKey", getBindingKey()); - } - if ((packing_flags & 2048) != 0) - { - result.put("arguments", getArguments()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ExchangeBound.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ExchangeBound.java deleted file mode 100644 index 5847feed9b..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ExchangeBound.java +++ /dev/null @@ -1,280 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class ExchangeBound extends Method { - - public static final int TYPE = 1798; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private String exchange; - private String queue; - private String bindingKey; - private Map arguments; - - - public ExchangeBound() {} - - - public ExchangeBound(String exchange, String queue, String bindingKey, Map arguments, Option ... _options) { - if(exchange != null) { - setExchange(exchange); - } - if(queue != null) { - setQueue(queue); - } - if(bindingKey != null) { - setBindingKey(bindingKey); - } - if(arguments != null) { - setArguments(arguments); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.exchangeBound(context, this); - } - - - public final boolean hasExchange() { - return (packing_flags & 256) != 0; - } - - public final ExchangeBound clearExchange() { - packing_flags &= ~256; - this.exchange = null; - setDirty(true); - return this; - } - - public final String getExchange() { - return exchange; - } - - public final ExchangeBound setExchange(String value) { - this.exchange = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final ExchangeBound exchange(String value) { - return setExchange(value); - } - - public final boolean hasQueue() { - return (packing_flags & 512) != 0; - } - - public final ExchangeBound clearQueue() { - packing_flags &= ~512; - this.queue = null; - setDirty(true); - return this; - } - - public final String getQueue() { - return queue; - } - - public final ExchangeBound setQueue(String value) { - this.queue = value; - packing_flags |= 512; - setDirty(true); - return this; - } - - public final ExchangeBound queue(String value) { - return setQueue(value); - } - - public final boolean hasBindingKey() { - return (packing_flags & 1024) != 0; - } - - public final ExchangeBound clearBindingKey() { - packing_flags &= ~1024; - this.bindingKey = null; - setDirty(true); - return this; - } - - public final String getBindingKey() { - return bindingKey; - } - - public final ExchangeBound setBindingKey(String value) { - this.bindingKey = value; - packing_flags |= 1024; - setDirty(true); - return this; - } - - public final ExchangeBound bindingKey(String value) { - return setBindingKey(value); - } - - public final boolean hasArguments() { - return (packing_flags & 2048) != 0; - } - - public final ExchangeBound clearArguments() { - packing_flags &= ~2048; - this.arguments = null; - setDirty(true); - return this; - } - - public final Map getArguments() { - return arguments; - } - - public final ExchangeBound setArguments(Map value) { - this.arguments = value; - packing_flags |= 2048; - setDirty(true); - return this; - } - - public final ExchangeBound arguments(Map value) { - return setArguments(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeStr8(this.exchange); - } - if ((packing_flags & 512) != 0) - { - enc.writeStr8(this.queue); - } - if ((packing_flags & 1024) != 0) - { - enc.writeStr8(this.bindingKey); - } - if ((packing_flags & 2048) != 0) - { - enc.writeMap(this.arguments); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.exchange = dec.readStr8(); - } - if ((packing_flags & 512) != 0) - { - this.queue = dec.readStr8(); - } - if ((packing_flags & 1024) != 0) - { - this.bindingKey = dec.readStr8(); - } - if ((packing_flags & 2048) != 0) - { - this.arguments = dec.readMap(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("exchange", getExchange()); - } - if ((packing_flags & 512) != 0) - { - result.put("queue", getQueue()); - } - if ((packing_flags & 1024) != 0) - { - result.put("bindingKey", getBindingKey()); - } - if ((packing_flags & 2048) != 0) - { - result.put("arguments", getArguments()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ExchangeBoundResult.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ExchangeBoundResult.java deleted file mode 100644 index 04d944ea33..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ExchangeBoundResult.java +++ /dev/null @@ -1,301 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - - - -public final class ExchangeBoundResult extends Struct { - - public static final int TYPE = 1794; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 4; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return -1; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - - - public ExchangeBoundResult() {} - - - public ExchangeBoundResult(Option ... _options) { - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case EXCHANGE_NOT_FOUND: packing_flags |= 256; break; - case QUEUE_NOT_FOUND: packing_flags |= 512; break; - case QUEUE_NOT_MATCHED: packing_flags |= 1024; break; - case KEY_NOT_MATCHED: packing_flags |= 2048; break; - case ARGS_NOT_MATCHED: packing_flags |= 4096; break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - - - - public final boolean hasExchangeNotFound() { - return (packing_flags & 256) != 0; - } - - public final ExchangeBoundResult clearExchangeNotFound() { - packing_flags &= ~256; - - setDirty(true); - return this; - } - - public final boolean getExchangeNotFound() { - return hasExchangeNotFound(); - } - - public final ExchangeBoundResult setExchangeNotFound(boolean value) { - - if (value) - { - packing_flags |= 256; - } - else - { - packing_flags &= ~256; - } - - setDirty(true); - return this; - } - - public final ExchangeBoundResult exchangeNotFound(boolean value) { - return setExchangeNotFound(value); - } - - public final boolean hasQueueNotFound() { - return (packing_flags & 512) != 0; - } - - public final ExchangeBoundResult clearQueueNotFound() { - packing_flags &= ~512; - - setDirty(true); - return this; - } - - public final boolean getQueueNotFound() { - return hasQueueNotFound(); - } - - public final ExchangeBoundResult setQueueNotFound(boolean value) { - - if (value) - { - packing_flags |= 512; - } - else - { - packing_flags &= ~512; - } - - setDirty(true); - return this; - } - - public final ExchangeBoundResult queueNotFound(boolean value) { - return setQueueNotFound(value); - } - - public final boolean hasQueueNotMatched() { - return (packing_flags & 1024) != 0; - } - - public final ExchangeBoundResult clearQueueNotMatched() { - packing_flags &= ~1024; - - setDirty(true); - return this; - } - - public final boolean getQueueNotMatched() { - return hasQueueNotMatched(); - } - - public final ExchangeBoundResult setQueueNotMatched(boolean value) { - - if (value) - { - packing_flags |= 1024; - } - else - { - packing_flags &= ~1024; - } - - setDirty(true); - return this; - } - - public final ExchangeBoundResult queueNotMatched(boolean value) { - return setQueueNotMatched(value); - } - - public final boolean hasKeyNotMatched() { - return (packing_flags & 2048) != 0; - } - - public final ExchangeBoundResult clearKeyNotMatched() { - packing_flags &= ~2048; - - setDirty(true); - return this; - } - - public final boolean getKeyNotMatched() { - return hasKeyNotMatched(); - } - - public final ExchangeBoundResult setKeyNotMatched(boolean value) { - - if (value) - { - packing_flags |= 2048; - } - else - { - packing_flags &= ~2048; - } - - setDirty(true); - return this; - } - - public final ExchangeBoundResult keyNotMatched(boolean value) { - return setKeyNotMatched(value); - } - - public final boolean hasArgsNotMatched() { - return (packing_flags & 4096) != 0; - } - - public final ExchangeBoundResult clearArgsNotMatched() { - packing_flags &= ~4096; - - setDirty(true); - return this; - } - - public final boolean getArgsNotMatched() { - return hasArgsNotMatched(); - } - - public final ExchangeBoundResult setArgsNotMatched(boolean value) { - - if (value) - { - packing_flags |= 4096; - } - else - { - packing_flags &= ~4096; - } - - setDirty(true); - return this; - } - - public final ExchangeBoundResult argsNotMatched(boolean value) { - return setArgsNotMatched(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("exchangeNotFound", getExchangeNotFound()); - } - if ((packing_flags & 512) != 0) - { - result.put("queueNotFound", getQueueNotFound()); - } - if ((packing_flags & 1024) != 0) - { - result.put("queueNotMatched", getQueueNotMatched()); - } - if ((packing_flags & 2048) != 0) - { - result.put("keyNotMatched", getKeyNotMatched()); - } - if ((packing_flags & 4096) != 0) - { - result.put("argsNotMatched", getArgsNotMatched()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ExchangeDeclare.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ExchangeDeclare.java deleted file mode 100644 index e339801f44..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ExchangeDeclare.java +++ /dev/null @@ -1,397 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class ExchangeDeclare extends Method { - - public static final int TYPE = 1793; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private String exchange; - private String type; - private String alternateExchange; - private Map arguments; - - - public ExchangeDeclare() {} - - - public ExchangeDeclare(String exchange, String type, String alternateExchange, Map arguments, Option ... _options) { - if(exchange != null) { - setExchange(exchange); - } - if(type != null) { - setType(type); - } - if(alternateExchange != null) { - setAlternateExchange(alternateExchange); - } - if(arguments != null) { - setArguments(arguments); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case PASSIVE: packing_flags |= 2048; break; - case DURABLE: packing_flags |= 4096; break; - case AUTO_DELETE: packing_flags |= 8192; break; - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.exchangeDeclare(context, this); - } - - - public final boolean hasExchange() { - return (packing_flags & 256) != 0; - } - - public final ExchangeDeclare clearExchange() { - packing_flags &= ~256; - this.exchange = null; - setDirty(true); - return this; - } - - public final String getExchange() { - return exchange; - } - - public final ExchangeDeclare setExchange(String value) { - this.exchange = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final ExchangeDeclare exchange(String value) { - return setExchange(value); - } - - public final boolean hasType() { - return (packing_flags & 512) != 0; - } - - public final ExchangeDeclare clearType() { - packing_flags &= ~512; - this.type = null; - setDirty(true); - return this; - } - - public final String getType() { - return type; - } - - public final ExchangeDeclare setType(String value) { - this.type = value; - packing_flags |= 512; - setDirty(true); - return this; - } - - public final ExchangeDeclare type(String value) { - return setType(value); - } - - public final boolean hasAlternateExchange() { - return (packing_flags & 1024) != 0; - } - - public final ExchangeDeclare clearAlternateExchange() { - packing_flags &= ~1024; - this.alternateExchange = null; - setDirty(true); - return this; - } - - public final String getAlternateExchange() { - return alternateExchange; - } - - public final ExchangeDeclare setAlternateExchange(String value) { - this.alternateExchange = value; - packing_flags |= 1024; - setDirty(true); - return this; - } - - public final ExchangeDeclare alternateExchange(String value) { - return setAlternateExchange(value); - } - - public final boolean hasPassive() { - return (packing_flags & 2048) != 0; - } - - public final ExchangeDeclare clearPassive() { - packing_flags &= ~2048; - - setDirty(true); - return this; - } - - public final boolean getPassive() { - return hasPassive(); - } - - public final ExchangeDeclare setPassive(boolean value) { - - if (value) - { - packing_flags |= 2048; - } - else - { - packing_flags &= ~2048; - } - - setDirty(true); - return this; - } - - public final ExchangeDeclare passive(boolean value) { - return setPassive(value); - } - - public final boolean hasDurable() { - return (packing_flags & 4096) != 0; - } - - public final ExchangeDeclare clearDurable() { - packing_flags &= ~4096; - - setDirty(true); - return this; - } - - public final boolean getDurable() { - return hasDurable(); - } - - public final ExchangeDeclare setDurable(boolean value) { - - if (value) - { - packing_flags |= 4096; - } - else - { - packing_flags &= ~4096; - } - - setDirty(true); - return this; - } - - public final ExchangeDeclare durable(boolean value) { - return setDurable(value); - } - - public final boolean hasAutoDelete() { - return (packing_flags & 8192) != 0; - } - - public final ExchangeDeclare clearAutoDelete() { - packing_flags &= ~8192; - - setDirty(true); - return this; - } - - public final boolean getAutoDelete() { - return hasAutoDelete(); - } - - public final ExchangeDeclare setAutoDelete(boolean value) { - - if (value) - { - packing_flags |= 8192; - } - else - { - packing_flags &= ~8192; - } - - setDirty(true); - return this; - } - - public final ExchangeDeclare autoDelete(boolean value) { - return setAutoDelete(value); - } - - public final boolean hasArguments() { - return (packing_flags & 16384) != 0; - } - - public final ExchangeDeclare clearArguments() { - packing_flags &= ~16384; - this.arguments = null; - setDirty(true); - return this; - } - - public final Map getArguments() { - return arguments; - } - - public final ExchangeDeclare setArguments(Map value) { - this.arguments = value; - packing_flags |= 16384; - setDirty(true); - return this; - } - - public final ExchangeDeclare arguments(Map value) { - return setArguments(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeStr8(this.exchange); - } - if ((packing_flags & 512) != 0) - { - enc.writeStr8(this.type); - } - if ((packing_flags & 1024) != 0) - { - enc.writeStr8(this.alternateExchange); - } - if ((packing_flags & 16384) != 0) - { - enc.writeMap(this.arguments); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.exchange = dec.readStr8(); - } - if ((packing_flags & 512) != 0) - { - this.type = dec.readStr8(); - } - if ((packing_flags & 1024) != 0) - { - this.alternateExchange = dec.readStr8(); - } - if ((packing_flags & 16384) != 0) - { - this.arguments = dec.readMap(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("exchange", getExchange()); - } - if ((packing_flags & 512) != 0) - { - result.put("type", getType()); - } - if ((packing_flags & 1024) != 0) - { - result.put("alternateExchange", getAlternateExchange()); - } - if ((packing_flags & 2048) != 0) - { - result.put("passive", getPassive()); - } - if ((packing_flags & 4096) != 0) - { - result.put("durable", getDurable()); - } - if ((packing_flags & 8192) != 0) - { - result.put("autoDelete", getAutoDelete()); - } - if ((packing_flags & 16384) != 0) - { - result.put("arguments", getArguments()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ExchangeDelete.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ExchangeDelete.java deleted file mode 100644 index a7dcd0cf2c..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ExchangeDelete.java +++ /dev/null @@ -1,193 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class ExchangeDelete extends Method { - - public static final int TYPE = 1794; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private String exchange; - - - public ExchangeDelete() {} - - - public ExchangeDelete(String exchange, Option ... _options) { - if(exchange != null) { - setExchange(exchange); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case IF_UNUSED: packing_flags |= 512; break; - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.exchangeDelete(context, this); - } - - - public final boolean hasExchange() { - return (packing_flags & 256) != 0; - } - - public final ExchangeDelete clearExchange() { - packing_flags &= ~256; - this.exchange = null; - setDirty(true); - return this; - } - - public final String getExchange() { - return exchange; - } - - public final ExchangeDelete setExchange(String value) { - this.exchange = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final ExchangeDelete exchange(String value) { - return setExchange(value); - } - - public final boolean hasIfUnused() { - return (packing_flags & 512) != 0; - } - - public final ExchangeDelete clearIfUnused() { - packing_flags &= ~512; - - setDirty(true); - return this; - } - - public final boolean getIfUnused() { - return hasIfUnused(); - } - - public final ExchangeDelete setIfUnused(boolean value) { - - if (value) - { - packing_flags |= 512; - } - else - { - packing_flags &= ~512; - } - - setDirty(true); - return this; - } - - public final ExchangeDelete ifUnused(boolean value) { - return setIfUnused(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeStr8(this.exchange); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.exchange = dec.readStr8(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("exchange", getExchange()); - } - if ((packing_flags & 512) != 0) - { - result.put("ifUnused", getIfUnused()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ExchangeQuery.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ExchangeQuery.java deleted file mode 100644 index d5f46e7bbf..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ExchangeQuery.java +++ /dev/null @@ -1,154 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class ExchangeQuery extends Method { - - public static final int TYPE = 1795; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private String name; - - - public ExchangeQuery() {} - - - public ExchangeQuery(String name, Option ... _options) { - if(name != null) { - setName(name); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.exchangeQuery(context, this); - } - - - public final boolean hasName() { - return (packing_flags & 256) != 0; - } - - public final ExchangeQuery clearName() { - packing_flags &= ~256; - this.name = null; - setDirty(true); - return this; - } - - public final String getName() { - return name; - } - - public final ExchangeQuery setName(String value) { - this.name = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final ExchangeQuery name(String value) { - return setName(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeStr8(this.name); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.name = dec.readStr8(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("name", getName()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ExchangeQueryResult.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ExchangeQueryResult.java deleted file mode 100644 index 9f83a4aaa7..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ExchangeQueryResult.java +++ /dev/null @@ -1,268 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - - - -public final class ExchangeQueryResult extends Struct { - - public static final int TYPE = 1793; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 4; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return -1; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private String type; - private Map arguments; - - - public ExchangeQueryResult() {} - - - public ExchangeQueryResult(String type, Map arguments, Option ... _options) { - if(type != null) { - setType(type); - } - if(arguments != null) { - setArguments(arguments); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case DURABLE: packing_flags |= 512; break; - case NOT_FOUND: packing_flags |= 1024; break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - - - - public final boolean hasType() { - return (packing_flags & 256) != 0; - } - - public final ExchangeQueryResult clearType() { - packing_flags &= ~256; - this.type = null; - setDirty(true); - return this; - } - - public final String getType() { - return type; - } - - public final ExchangeQueryResult setType(String value) { - this.type = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final ExchangeQueryResult type(String value) { - return setType(value); - } - - public final boolean hasDurable() { - return (packing_flags & 512) != 0; - } - - public final ExchangeQueryResult clearDurable() { - packing_flags &= ~512; - - setDirty(true); - return this; - } - - public final boolean getDurable() { - return hasDurable(); - } - - public final ExchangeQueryResult setDurable(boolean value) { - - if (value) - { - packing_flags |= 512; - } - else - { - packing_flags &= ~512; - } - - setDirty(true); - return this; - } - - public final ExchangeQueryResult durable(boolean value) { - return setDurable(value); - } - - public final boolean hasNotFound() { - return (packing_flags & 1024) != 0; - } - - public final ExchangeQueryResult clearNotFound() { - packing_flags &= ~1024; - - setDirty(true); - return this; - } - - public final boolean getNotFound() { - return hasNotFound(); - } - - public final ExchangeQueryResult setNotFound(boolean value) { - - if (value) - { - packing_flags |= 1024; - } - else - { - packing_flags &= ~1024; - } - - setDirty(true); - return this; - } - - public final ExchangeQueryResult notFound(boolean value) { - return setNotFound(value); - } - - public final boolean hasArguments() { - return (packing_flags & 2048) != 0; - } - - public final ExchangeQueryResult clearArguments() { - packing_flags &= ~2048; - this.arguments = null; - setDirty(true); - return this; - } - - public final Map getArguments() { - return arguments; - } - - public final ExchangeQueryResult setArguments(Map value) { - this.arguments = value; - packing_flags |= 2048; - setDirty(true); - return this; - } - - public final ExchangeQueryResult arguments(Map value) { - return setArguments(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeStr8(this.type); - } - if ((packing_flags & 2048) != 0) - { - enc.writeMap(this.arguments); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.type = dec.readStr8(); - } - if ((packing_flags & 2048) != 0) - { - this.arguments = dec.readMap(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("type", getType()); - } - if ((packing_flags & 512) != 0) - { - result.put("durable", getDurable()); - } - if ((packing_flags & 1024) != 0) - { - result.put("notFound", getNotFound()); - } - if ((packing_flags & 2048) != 0) - { - result.put("arguments", getArguments()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ExchangeUnbind.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ExchangeUnbind.java deleted file mode 100644 index ba3fe95952..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ExchangeUnbind.java +++ /dev/null @@ -1,238 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class ExchangeUnbind extends Method { - - public static final int TYPE = 1797; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private String queue; - private String exchange; - private String bindingKey; - - - public ExchangeUnbind() {} - - - public ExchangeUnbind(String queue, String exchange, String bindingKey, Option ... _options) { - if(queue != null) { - setQueue(queue); - } - if(exchange != null) { - setExchange(exchange); - } - if(bindingKey != null) { - setBindingKey(bindingKey); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.exchangeUnbind(context, this); - } - - - public final boolean hasQueue() { - return (packing_flags & 256) != 0; - } - - public final ExchangeUnbind clearQueue() { - packing_flags &= ~256; - this.queue = null; - setDirty(true); - return this; - } - - public final String getQueue() { - return queue; - } - - public final ExchangeUnbind setQueue(String value) { - this.queue = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final ExchangeUnbind queue(String value) { - return setQueue(value); - } - - public final boolean hasExchange() { - return (packing_flags & 512) != 0; - } - - public final ExchangeUnbind clearExchange() { - packing_flags &= ~512; - this.exchange = null; - setDirty(true); - return this; - } - - public final String getExchange() { - return exchange; - } - - public final ExchangeUnbind setExchange(String value) { - this.exchange = value; - packing_flags |= 512; - setDirty(true); - return this; - } - - public final ExchangeUnbind exchange(String value) { - return setExchange(value); - } - - public final boolean hasBindingKey() { - return (packing_flags & 1024) != 0; - } - - public final ExchangeUnbind clearBindingKey() { - packing_flags &= ~1024; - this.bindingKey = null; - setDirty(true); - return this; - } - - public final String getBindingKey() { - return bindingKey; - } - - public final ExchangeUnbind setBindingKey(String value) { - this.bindingKey = value; - packing_flags |= 1024; - setDirty(true); - return this; - } - - public final ExchangeUnbind bindingKey(String value) { - return setBindingKey(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeStr8(this.queue); - } - if ((packing_flags & 512) != 0) - { - enc.writeStr8(this.exchange); - } - if ((packing_flags & 1024) != 0) - { - enc.writeStr8(this.bindingKey); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.queue = dec.readStr8(); - } - if ((packing_flags & 512) != 0) - { - this.exchange = dec.readStr8(); - } - if ((packing_flags & 1024) != 0) - { - this.bindingKey = dec.readStr8(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("queue", getQueue()); - } - if ((packing_flags & 512) != 0) - { - result.put("exchange", getExchange()); - } - if ((packing_flags & 1024) != 0) - { - result.put("bindingKey", getBindingKey()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ExecutionErrorCode.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ExecutionErrorCode.java deleted file mode 100644 index 0ba83296e7..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ExecutionErrorCode.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -public enum ExecutionErrorCode { - - UNAUTHORIZED_ACCESS((int) 403), - NOT_FOUND((int) 404), - RESOURCE_LOCKED((int) 405), - PRECONDITION_FAILED((int) 406), - RESOURCE_DELETED((int) 408), - ILLEGAL_STATE((int) 409), - COMMAND_INVALID((int) 503), - RESOURCE_LIMIT_EXCEEDED((int) 506), - NOT_ALLOWED((int) 530), - ILLEGAL_ARGUMENT((int) 531), - NOT_IMPLEMENTED((int) 540), - INTERNAL_ERROR((int) 541), - INVALID_ARGUMENT((int) 542); - - private final int value; - - ExecutionErrorCode(int value) - { - this.value = value; - } - - public int getValue() - { - return value; - } - - public static ExecutionErrorCode get(int value) - { - switch (value) - { - case (int) 403: return UNAUTHORIZED_ACCESS; - case (int) 404: return NOT_FOUND; - case (int) 405: return RESOURCE_LOCKED; - case (int) 406: return PRECONDITION_FAILED; - case (int) 408: return RESOURCE_DELETED; - case (int) 409: return ILLEGAL_STATE; - case (int) 503: return COMMAND_INVALID; - case (int) 506: return RESOURCE_LIMIT_EXCEEDED; - case (int) 530: return NOT_ALLOWED; - case (int) 531: return ILLEGAL_ARGUMENT; - case (int) 540: return NOT_IMPLEMENTED; - case (int) 541: return INTERNAL_ERROR; - case (int) 542: return INVALID_ARGUMENT; - default: throw new IllegalArgumentException("no such value: " + value); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ExecutionException.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ExecutionException.java deleted file mode 100644 index 0f61272476..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ExecutionException.java +++ /dev/null @@ -1,398 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class ExecutionException extends Method { - - public static final int TYPE = 771; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private ExecutionErrorCode errorCode; - private int commandId; - private short classCode; - private short commandCode; - private short fieldIndex; - private String description; - private Map errorInfo; - - - public ExecutionException() {} - - - public ExecutionException(ExecutionErrorCode errorCode, int commandId, short classCode, short commandCode, short fieldIndex, String description, Map errorInfo, Option ... _options) { - if(errorCode != null) { - setErrorCode(errorCode); - } - setCommandId(commandId); - setClassCode(classCode); - setCommandCode(commandCode); - setFieldIndex(fieldIndex); - if(description != null) { - setDescription(description); - } - if(errorInfo != null) { - setErrorInfo(errorInfo); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.executionException(context, this); - } - - - public final boolean hasErrorCode() { - return (packing_flags & 256) != 0; - } - - public final ExecutionException clearErrorCode() { - packing_flags &= ~256; - this.errorCode = null; - setDirty(true); - return this; - } - - public final ExecutionErrorCode getErrorCode() { - return errorCode; - } - - public final ExecutionException setErrorCode(ExecutionErrorCode value) { - this.errorCode = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final ExecutionException errorCode(ExecutionErrorCode value) { - return setErrorCode(value); - } - - public final boolean hasCommandId() { - return (packing_flags & 512) != 0; - } - - public final ExecutionException clearCommandId() { - packing_flags &= ~512; - this.commandId = 0; - setDirty(true); - return this; - } - - public final int getCommandId() { - return commandId; - } - - public final ExecutionException setCommandId(int value) { - this.commandId = value; - packing_flags |= 512; - setDirty(true); - return this; - } - - public final ExecutionException commandId(int value) { - return setCommandId(value); - } - - public final boolean hasClassCode() { - return (packing_flags & 1024) != 0; - } - - public final ExecutionException clearClassCode() { - packing_flags &= ~1024; - this.classCode = 0; - setDirty(true); - return this; - } - - public final short getClassCode() { - return classCode; - } - - public final ExecutionException setClassCode(short value) { - this.classCode = value; - packing_flags |= 1024; - setDirty(true); - return this; - } - - public final ExecutionException classCode(short value) { - return setClassCode(value); - } - - public final boolean hasCommandCode() { - return (packing_flags & 2048) != 0; - } - - public final ExecutionException clearCommandCode() { - packing_flags &= ~2048; - this.commandCode = 0; - setDirty(true); - return this; - } - - public final short getCommandCode() { - return commandCode; - } - - public final ExecutionException setCommandCode(short value) { - this.commandCode = value; - packing_flags |= 2048; - setDirty(true); - return this; - } - - public final ExecutionException commandCode(short value) { - return setCommandCode(value); - } - - public final boolean hasFieldIndex() { - return (packing_flags & 4096) != 0; - } - - public final ExecutionException clearFieldIndex() { - packing_flags &= ~4096; - this.fieldIndex = 0; - setDirty(true); - return this; - } - - public final short getFieldIndex() { - return fieldIndex; - } - - public final ExecutionException setFieldIndex(short value) { - this.fieldIndex = value; - packing_flags |= 4096; - setDirty(true); - return this; - } - - public final ExecutionException fieldIndex(short value) { - return setFieldIndex(value); - } - - public final boolean hasDescription() { - return (packing_flags & 8192) != 0; - } - - public final ExecutionException clearDescription() { - packing_flags &= ~8192; - this.description = null; - setDirty(true); - return this; - } - - public final String getDescription() { - return description; - } - - public final ExecutionException setDescription(String value) { - this.description = value; - packing_flags |= 8192; - setDirty(true); - return this; - } - - public final ExecutionException description(String value) { - return setDescription(value); - } - - public final boolean hasErrorInfo() { - return (packing_flags & 16384) != 0; - } - - public final ExecutionException clearErrorInfo() { - packing_flags &= ~16384; - this.errorInfo = null; - setDirty(true); - return this; - } - - public final Map getErrorInfo() { - return errorInfo; - } - - public final ExecutionException setErrorInfo(Map value) { - this.errorInfo = value; - packing_flags |= 16384; - setDirty(true); - return this; - } - - public final ExecutionException errorInfo(Map value) { - return setErrorInfo(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeUint16(this.errorCode.getValue()); - } - if ((packing_flags & 512) != 0) - { - enc.writeSequenceNo(this.commandId); - } - if ((packing_flags & 1024) != 0) - { - enc.writeUint8(this.classCode); - } - if ((packing_flags & 2048) != 0) - { - enc.writeUint8(this.commandCode); - } - if ((packing_flags & 4096) != 0) - { - enc.writeUint8(this.fieldIndex); - } - if ((packing_flags & 8192) != 0) - { - enc.writeStr16(this.description); - } - if ((packing_flags & 16384) != 0) - { - enc.writeMap(this.errorInfo); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.errorCode = ExecutionErrorCode.get(dec.readUint16()); - } - if ((packing_flags & 512) != 0) - { - this.commandId = dec.readSequenceNo(); - } - if ((packing_flags & 1024) != 0) - { - this.classCode = dec.readUint8(); - } - if ((packing_flags & 2048) != 0) - { - this.commandCode = dec.readUint8(); - } - if ((packing_flags & 4096) != 0) - { - this.fieldIndex = dec.readUint8(); - } - if ((packing_flags & 8192) != 0) - { - this.description = dec.readStr16(); - } - if ((packing_flags & 16384) != 0) - { - this.errorInfo = dec.readMap(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("errorCode", getErrorCode()); - } - if ((packing_flags & 512) != 0) - { - result.put("commandId", getCommandId()); - } - if ((packing_flags & 1024) != 0) - { - result.put("classCode", getClassCode()); - } - if ((packing_flags & 2048) != 0) - { - result.put("commandCode", getCommandCode()); - } - if ((packing_flags & 4096) != 0) - { - result.put("fieldIndex", getFieldIndex()); - } - if ((packing_flags & 8192) != 0) - { - result.put("description", getDescription()); - } - if ((packing_flags & 16384) != 0) - { - result.put("errorInfo", getErrorInfo()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ExecutionResult.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ExecutionResult.java deleted file mode 100644 index 123848b7eb..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ExecutionResult.java +++ /dev/null @@ -1,194 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class ExecutionResult extends Method { - - public static final int TYPE = 770; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private int commandId; - private Struct value; - - - public ExecutionResult() {} - - - public ExecutionResult(int commandId, Struct value, Option ... _options) { - setCommandId(commandId); - if(value != null) { - setValue(value); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.executionResult(context, this); - } - - - public final boolean hasCommandId() { - return (packing_flags & 256) != 0; - } - - public final ExecutionResult clearCommandId() { - packing_flags &= ~256; - this.commandId = 0; - setDirty(true); - return this; - } - - public final int getCommandId() { - return commandId; - } - - public final ExecutionResult setCommandId(int value) { - this.commandId = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final ExecutionResult commandId(int value) { - return setCommandId(value); - } - - public final boolean hasValue() { - return (packing_flags & 512) != 0; - } - - public final ExecutionResult clearValue() { - packing_flags &= ~512; - this.value = null; - setDirty(true); - return this; - } - - public final Struct getValue() { - return value; - } - - public final ExecutionResult setValue(Struct value) { - this.value = value; - packing_flags |= 512; - setDirty(true); - return this; - } - - public final ExecutionResult value(Struct value) { - return setValue(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeSequenceNo(this.commandId); - } - if ((packing_flags & 512) != 0) - { - enc.writeStruct32(this.value); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.commandId = dec.readSequenceNo(); - } - if ((packing_flags & 512) != 0) - { - this.value = dec.readStruct32(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("commandId", getCommandId()); - } - if ((packing_flags & 512) != 0) - { - result.put("value", getValue()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ExecutionSync.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ExecutionSync.java deleted file mode 100644 index db35beb161..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ExecutionSync.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class ExecutionSync extends Method { - - public static final int TYPE = 769; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - - - - - public ExecutionSync(Option ... _options) { - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.executionSync(context, this); - } - - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/Field.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/Field.java deleted file mode 100644 index bc6bf10041..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/Field.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - - -/** - * Field - * - */ - -public abstract class Field -{ - - private final Class container; - private final Class type; - private final String name; - private final int index; - - Field(Class container, Class type, String name, int index) - { - this.container = container; - this.type = type; - this.name = name; - this.index = index; - } - - public final Class getContainer() - { - return container; - } - - public final Class getType() - { - return type; - } - - public final String getName() - { - return name; - } - - public final int getIndex() - { - return index; - } - - protected final C check(Object struct) - { - return container.cast(struct); - } - - public abstract boolean has(Object struct); - - public abstract void has(Object struct, boolean value); - - public abstract T get(Object struct); - - public abstract void read(Decoder dec, Object struct); - - public abstract void write(Encoder enc, Object struct); - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/FileReturnCode.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/FileReturnCode.java deleted file mode 100644 index 2c0b4d510b..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/FileReturnCode.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -public enum FileReturnCode { - - CONTENT_TOO_LARGE((int) 311), - NO_ROUTE((int) 312), - NO_CONSUMERS((int) 313); - - private final int value; - - FileReturnCode(int value) - { - this.value = value; - } - - public int getValue() - { - return value; - } - - public static FileReturnCode get(int value) - { - switch (value) - { - case (int) 311: return CONTENT_TOO_LARGE; - case (int) 312: return NO_ROUTE; - case (int) 313: return NO_CONSUMERS; - default: throw new IllegalArgumentException("no such value: " + value); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/FragmentProperties.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/FragmentProperties.java deleted file mode 100644 index 0b9774355e..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/FragmentProperties.java +++ /dev/null @@ -1,224 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - - - -public final class FragmentProperties extends Struct { - - public static final int TYPE = 1026; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 4; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return -1; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private long fragmentSize; - - - public FragmentProperties() {} - - - public FragmentProperties(long fragmentSize, Option ... _options) { - setFragmentSize(fragmentSize); - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case FIRST: packing_flags |= 256; break; - case LAST: packing_flags |= 512; break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - - - - public final boolean hasFirst() { - return (packing_flags & 256) != 0; - } - - public final FragmentProperties clearFirst() { - packing_flags &= ~256; - - setDirty(true); - return this; - } - - public final boolean getFirst() { - return hasFirst(); - } - - public final FragmentProperties setFirst(boolean value) { - - if (value) - { - packing_flags |= 256; - } - else - { - packing_flags &= ~256; - } - - setDirty(true); - return this; - } - - public final FragmentProperties first(boolean value) { - return setFirst(value); - } - - public final boolean hasLast() { - return (packing_flags & 512) != 0; - } - - public final FragmentProperties clearLast() { - packing_flags &= ~512; - - setDirty(true); - return this; - } - - public final boolean getLast() { - return hasLast(); - } - - public final FragmentProperties setLast(boolean value) { - - if (value) - { - packing_flags |= 512; - } - else - { - packing_flags &= ~512; - } - - setDirty(true); - return this; - } - - public final FragmentProperties last(boolean value) { - return setLast(value); - } - - public final boolean hasFragmentSize() { - return (packing_flags & 1024) != 0; - } - - public final FragmentProperties clearFragmentSize() { - packing_flags &= ~1024; - this.fragmentSize = 0; - setDirty(true); - return this; - } - - public final long getFragmentSize() { - return fragmentSize; - } - - public final FragmentProperties setFragmentSize(long value) { - this.fragmentSize = value; - packing_flags |= 1024; - setDirty(true); - return this; - } - - public final FragmentProperties fragmentSize(long value) { - return setFragmentSize(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 1024) != 0) - { - enc.writeUint64(this.fragmentSize); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 1024) != 0) - { - this.fragmentSize = dec.readUint64(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("first", getFirst()); - } - if ((packing_flags & 512) != 0) - { - result.put("last", getLast()); - } - if ((packing_flags & 1024) != 0) - { - result.put("fragmentSize", getFragmentSize()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/FrameSizeObserver.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/FrameSizeObserver.java deleted file mode 100644 index 94d0080fbb..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/FrameSizeObserver.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - -public interface FrameSizeObserver -{ - void setMaxFrameSize(int frameSize); -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/Future.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/Future.java deleted file mode 100644 index d8cde61af5..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/Future.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - - -/** - * Future - * - * @author Rafael H. Schloming - */ - -public interface Future -{ - - T get(); - - boolean isDone(); - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/GetTimeoutResult.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/GetTimeoutResult.java deleted file mode 100644 index ebff105464..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/GetTimeoutResult.java +++ /dev/null @@ -1,139 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - - - -public final class GetTimeoutResult extends Struct { - - public static final int TYPE = 1538; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 4; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return -1; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private long timeout; - - - public GetTimeoutResult() {} - - - public GetTimeoutResult(long timeout) { - setTimeout(timeout); - - } - - - - - public final boolean hasTimeout() { - return (packing_flags & 256) != 0; - } - - public final GetTimeoutResult clearTimeout() { - packing_flags &= ~256; - this.timeout = 0; - setDirty(true); - return this; - } - - public final long getTimeout() { - return timeout; - } - - public final GetTimeoutResult setTimeout(long value) { - this.timeout = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final GetTimeoutResult timeout(long value) { - return setTimeout(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeUint32(this.timeout); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.timeout = dec.readUint32(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("timeout", getTimeout()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/Header.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/Header.java deleted file mode 100644 index 7ac75f9163..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/Header.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - -import java.util.List; - - -/** - * Header - * - * @author Rafael H. Schloming - */ - -public class Header -{ - - private final DeliveryProperties _deliveryProps; - private final MessageProperties _messageProps; - private final List _nonStandardProps; - - public Header(DeliveryProperties deliveryProps, MessageProperties messageProps) - { - this(deliveryProps, messageProps, null); - } - - public Header(DeliveryProperties deliveryProps, MessageProperties messageProps, List nonStandardProps) - { - _deliveryProps = deliveryProps; - _messageProps = messageProps; - _nonStandardProps = nonStandardProps; - } - - public Struct[] getStructs() - { - int size = 0; - if(_deliveryProps != null) - { - size++; - } - if(_messageProps != null) - { - size++; - } - if(_nonStandardProps != null) - { - size+=_nonStandardProps.size(); - } - Struct[] structs = new Struct[size]; - int index = 0; - if(_deliveryProps != null) - { - structs[index++] = _deliveryProps; - } - if(_messageProps != null) - { - structs[index++] = _messageProps; - } - if(_nonStandardProps != null) - { - for(Struct struct : _nonStandardProps) - { - structs[index++] = struct; - } - } - - return structs; - } - - public DeliveryProperties getDeliveryProperties() - { - return _deliveryProps; - } - - public MessageProperties getMessageProperties() - { - return _messageProps; - } - - public List getNonStandardProperties() - { - return _nonStandardProps; - } - - public String toString() - { - StringBuilder str = new StringBuilder(); - str.append(" Header("); - boolean first = true; - if(_deliveryProps !=null) - { - first=false; - str.append(_deliveryProps); - } - if(_messageProps != null) - { - if (first) - { - first = false; - } - else - { - str.append(", "); - } - str.append(_messageProps); - } - if(_nonStandardProps != null) - { - for (Struct s : _nonStandardProps) - { - if (first) - { - first = false; - } - else - { - str.append(", "); - } - str.append(s); - } - } - str.append(')'); - return str.toString(); - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageAccept.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageAccept.java deleted file mode 100644 index e30a4e4f66..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageAccept.java +++ /dev/null @@ -1,154 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class MessageAccept extends Method { - - public static final int TYPE = 1026; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private RangeSet transfers; - - - public MessageAccept() {} - - - public MessageAccept(RangeSet transfers, Option ... _options) { - if(transfers != null) { - setTransfers(transfers); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.messageAccept(context, this); - } - - - public final boolean hasTransfers() { - return (packing_flags & 256) != 0; - } - - public final MessageAccept clearTransfers() { - packing_flags &= ~256; - this.transfers = null; - setDirty(true); - return this; - } - - public final RangeSet getTransfers() { - return transfers; - } - - public final MessageAccept setTransfers(RangeSet value) { - this.transfers = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final MessageAccept transfers(RangeSet value) { - return setTransfers(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeSequenceSet(this.transfers); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.transfers = dec.readSequenceSet(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("transfers", getTransfers()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageAcceptMode.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageAcceptMode.java deleted file mode 100644 index 0f11560c66..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageAcceptMode.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -public enum MessageAcceptMode { - - EXPLICIT((short) 0), - NONE((short) 1); - - private final short value; - - MessageAcceptMode(short value) - { - this.value = value; - } - - public short getValue() - { - return value; - } - - public static MessageAcceptMode get(short value) - { - switch (value) - { - case (short) 0: return EXPLICIT; - case (short) 1: return NONE; - default: throw new IllegalArgumentException("no such value: " + value); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageAcquire.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageAcquire.java deleted file mode 100644 index 6ef5283163..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageAcquire.java +++ /dev/null @@ -1,154 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class MessageAcquire extends Method { - - public static final int TYPE = 1029; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private RangeSet transfers; - - - public MessageAcquire() {} - - - public MessageAcquire(RangeSet transfers, Option ... _options) { - if(transfers != null) { - setTransfers(transfers); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.messageAcquire(context, this); - } - - - public final boolean hasTransfers() { - return (packing_flags & 256) != 0; - } - - public final MessageAcquire clearTransfers() { - packing_flags &= ~256; - this.transfers = null; - setDirty(true); - return this; - } - - public final RangeSet getTransfers() { - return transfers; - } - - public final MessageAcquire setTransfers(RangeSet value) { - this.transfers = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final MessageAcquire transfers(RangeSet value) { - return setTransfers(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeSequenceSet(this.transfers); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.transfers = dec.readSequenceSet(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("transfers", getTransfers()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageAcquireMode.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageAcquireMode.java deleted file mode 100644 index 3d46baf1af..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageAcquireMode.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -public enum MessageAcquireMode { - - PRE_ACQUIRED((short) 0), - NOT_ACQUIRED((short) 1); - - private final short value; - - MessageAcquireMode(short value) - { - this.value = value; - } - - public short getValue() - { - return value; - } - - public static MessageAcquireMode get(short value) - { - switch (value) - { - case (short) 0: return PRE_ACQUIRED; - case (short) 1: return NOT_ACQUIRED; - default: throw new IllegalArgumentException("no such value: " + value); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageCancel.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageCancel.java deleted file mode 100644 index 1ab510150d..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageCancel.java +++ /dev/null @@ -1,154 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class MessageCancel extends Method { - - public static final int TYPE = 1032; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private String destination; - - - public MessageCancel() {} - - - public MessageCancel(String destination, Option ... _options) { - if(destination != null) { - setDestination(destination); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.messageCancel(context, this); - } - - - public final boolean hasDestination() { - return (packing_flags & 256) != 0; - } - - public final MessageCancel clearDestination() { - packing_flags &= ~256; - this.destination = null; - setDirty(true); - return this; - } - - public final String getDestination() { - return destination; - } - - public final MessageCancel setDestination(String value) { - this.destination = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final MessageCancel destination(String value) { - return setDestination(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeStr8(this.destination); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.destination = dec.readStr8(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("destination", getDestination()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageCreditUnit.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageCreditUnit.java deleted file mode 100644 index f3ade93c69..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageCreditUnit.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -public enum MessageCreditUnit { - - MESSAGE((short) 0), - BYTE((short) 1); - - private final short value; - - MessageCreditUnit(short value) - { - this.value = value; - } - - public short getValue() - { - return value; - } - - public static MessageCreditUnit get(short value) - { - switch (value) - { - case (short) 0: return MESSAGE; - case (short) 1: return BYTE; - default: throw new IllegalArgumentException("no such value: " + value); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageDeliveryMode.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageDeliveryMode.java deleted file mode 100644 index eb21465c10..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageDeliveryMode.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -public enum MessageDeliveryMode { - - NON_PERSISTENT((short) 1), - PERSISTENT((short) 2); - - private final short value; - - MessageDeliveryMode(short value) - { - this.value = value; - } - - public short getValue() - { - return value; - } - - public static MessageDeliveryMode get(short value) - { - switch (value) - { - case (short) 1: return NON_PERSISTENT; - case (short) 2: return PERSISTENT; - default: throw new IllegalArgumentException("no such value: " + value); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageDeliveryPriority.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageDeliveryPriority.java deleted file mode 100644 index d5d1b861e8..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageDeliveryPriority.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -public enum MessageDeliveryPriority { - - LOWEST((short) 0), - LOWER((short) 1), - LOW((short) 2), - BELOW_AVERAGE((short) 3), - MEDIUM((short) 4), - ABOVE_AVERAGE((short) 5), - HIGH((short) 6), - HIGHER((short) 7), - VERY_HIGH((short) 8), - HIGHEST((short) 9); - - private final short value; - - MessageDeliveryPriority(short value) - { - this.value = value; - } - - public short getValue() - { - return value; - } - - public static MessageDeliveryPriority get(short value) - { - switch (value) - { - case (short) 0: return LOWEST; - case (short) 1: return LOWER; - case (short) 2: return LOW; - case (short) 3: return BELOW_AVERAGE; - case (short) 4: return MEDIUM; - case (short) 5: return ABOVE_AVERAGE; - case (short) 6: return HIGH; - case (short) 7: return HIGHER; - case (short) 8: return VERY_HIGH; - case (short) 9: return HIGHEST; - default: throw new IllegalArgumentException("no such value: " + value); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageFlow.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageFlow.java deleted file mode 100644 index 0ece4245b3..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageFlow.java +++ /dev/null @@ -1,236 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class MessageFlow extends Method { - - public static final int TYPE = 1034; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private String destination; - private MessageCreditUnit unit; - private long value; - - - public MessageFlow() {} - - - public MessageFlow(String destination, MessageCreditUnit unit, long value, Option ... _options) { - if(destination != null) { - setDestination(destination); - } - if(unit != null) { - setUnit(unit); - } - setValue(value); - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.messageFlow(context, this); - } - - - public final boolean hasDestination() { - return (packing_flags & 256) != 0; - } - - public final MessageFlow clearDestination() { - packing_flags &= ~256; - this.destination = null; - setDirty(true); - return this; - } - - public final String getDestination() { - return destination; - } - - public final MessageFlow setDestination(String value) { - this.destination = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final MessageFlow destination(String value) { - return setDestination(value); - } - - public final boolean hasUnit() { - return (packing_flags & 512) != 0; - } - - public final MessageFlow clearUnit() { - packing_flags &= ~512; - this.unit = null; - setDirty(true); - return this; - } - - public final MessageCreditUnit getUnit() { - return unit; - } - - public final MessageFlow setUnit(MessageCreditUnit value) { - this.unit = value; - packing_flags |= 512; - setDirty(true); - return this; - } - - public final MessageFlow unit(MessageCreditUnit value) { - return setUnit(value); - } - - public final boolean hasValue() { - return (packing_flags & 1024) != 0; - } - - public final MessageFlow clearValue() { - packing_flags &= ~1024; - this.value = 0; - setDirty(true); - return this; - } - - public final long getValue() { - return value; - } - - public final MessageFlow setValue(long value) { - this.value = value; - packing_flags |= 1024; - setDirty(true); - return this; - } - - public final MessageFlow value(long value) { - return setValue(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeStr8(this.destination); - } - if ((packing_flags & 512) != 0) - { - enc.writeUint8(this.unit.getValue()); - } - if ((packing_flags & 1024) != 0) - { - enc.writeUint32(this.value); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.destination = dec.readStr8(); - } - if ((packing_flags & 512) != 0) - { - this.unit = MessageCreditUnit.get(dec.readUint8()); - } - if ((packing_flags & 1024) != 0) - { - this.value = dec.readUint32(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("destination", getDestination()); - } - if ((packing_flags & 512) != 0) - { - result.put("unit", getUnit()); - } - if ((packing_flags & 1024) != 0) - { - result.put("value", getValue()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageFlowMode.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageFlowMode.java deleted file mode 100644 index 60670260fb..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageFlowMode.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -public enum MessageFlowMode { - - CREDIT((short) 0), - WINDOW((short) 1); - - private final short value; - - MessageFlowMode(short value) - { - this.value = value; - } - - public short getValue() - { - return value; - } - - public static MessageFlowMode get(short value) - { - switch (value) - { - case (short) 0: return CREDIT; - case (short) 1: return WINDOW; - default: throw new IllegalArgumentException("no such value: " + value); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageFlush.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageFlush.java deleted file mode 100644 index 8e093dd003..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageFlush.java +++ /dev/null @@ -1,154 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class MessageFlush extends Method { - - public static final int TYPE = 1035; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private String destination; - - - public MessageFlush() {} - - - public MessageFlush(String destination, Option ... _options) { - if(destination != null) { - setDestination(destination); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.messageFlush(context, this); - } - - - public final boolean hasDestination() { - return (packing_flags & 256) != 0; - } - - public final MessageFlush clearDestination() { - packing_flags &= ~256; - this.destination = null; - setDirty(true); - return this; - } - - public final String getDestination() { - return destination; - } - - public final MessageFlush setDestination(String value) { - this.destination = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final MessageFlush destination(String value) { - return setDestination(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeStr8(this.destination); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.destination = dec.readStr8(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("destination", getDestination()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageProperties.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageProperties.java deleted file mode 100644 index 37b5e7a052..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageProperties.java +++ /dev/null @@ -1,475 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - - - -public final class MessageProperties extends Struct { - - public static final int TYPE = 1027; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 4; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return -1; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private long contentLength; - private java.util.UUID messageId; - private byte[] correlationId; - private ReplyTo replyTo; - private String contentType; - private String contentEncoding; - private byte[] userId; - private byte[] appId; - private Map applicationHeaders; - - - public MessageProperties() {} - - - public MessageProperties(long contentLength, java.util.UUID messageId, byte[] correlationId, ReplyTo replyTo, String contentType, String contentEncoding, byte[] userId, byte[] appId, Map applicationHeaders) { - setContentLength(contentLength); - if(messageId != null) { - setMessageId(messageId); - } - if(correlationId != null) { - setCorrelationId(correlationId); - } - if(replyTo != null) { - setReplyTo(replyTo); - } - if(contentType != null) { - setContentType(contentType); - } - if(contentEncoding != null) { - setContentEncoding(contentEncoding); - } - if(userId != null) { - setUserId(userId); - } - if(appId != null) { - setAppId(appId); - } - if(applicationHeaders != null) { - setApplicationHeaders(applicationHeaders); - } - - } - - - - - public final boolean hasContentLength() { - return (packing_flags & 256) != 0; - } - - public final MessageProperties clearContentLength() { - packing_flags &= ~256; - this.contentLength = 0; - setDirty(true); - return this; - } - - public final long getContentLength() { - return contentLength; - } - - public final MessageProperties setContentLength(long value) { - this.contentLength = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final MessageProperties contentLength(long value) { - return setContentLength(value); - } - - public final boolean hasMessageId() { - return (packing_flags & 512) != 0; - } - - public final MessageProperties clearMessageId() { - packing_flags &= ~512; - this.messageId = null; - setDirty(true); - return this; - } - - public final java.util.UUID getMessageId() { - return messageId; - } - - public final MessageProperties setMessageId(java.util.UUID value) { - this.messageId = value; - packing_flags |= 512; - setDirty(true); - return this; - } - - public final MessageProperties messageId(java.util.UUID value) { - return setMessageId(value); - } - - public final boolean hasCorrelationId() { - return (packing_flags & 1024) != 0; - } - - public final MessageProperties clearCorrelationId() { - packing_flags &= ~1024; - this.correlationId = null; - setDirty(true); - return this; - } - - public final byte[] getCorrelationId() { - return correlationId; - } - - public final MessageProperties setCorrelationId(byte[] value) { - this.correlationId = value; - packing_flags |= 1024; - setDirty(true); - return this; - } - - public final MessageProperties correlationId(byte[] value) { - return setCorrelationId(value); - } - - public final boolean hasReplyTo() { - return (packing_flags & 2048) != 0; - } - - public final MessageProperties clearReplyTo() { - packing_flags &= ~2048; - this.replyTo = null; - setDirty(true); - return this; - } - - public final ReplyTo getReplyTo() { - return replyTo; - } - - public final MessageProperties setReplyTo(ReplyTo value) { - this.replyTo = value; - packing_flags |= 2048; - setDirty(true); - return this; - } - - public final MessageProperties replyTo(ReplyTo value) { - return setReplyTo(value); - } - - public final boolean hasContentType() { - return (packing_flags & 4096) != 0; - } - - public final MessageProperties clearContentType() { - packing_flags &= ~4096; - this.contentType = null; - setDirty(true); - return this; - } - - public final String getContentType() { - return contentType; - } - - public final MessageProperties setContentType(String value) { - this.contentType = value; - packing_flags |= 4096; - setDirty(true); - return this; - } - - public final MessageProperties contentType(String value) { - return setContentType(value); - } - - public final boolean hasContentEncoding() { - return (packing_flags & 8192) != 0; - } - - public final MessageProperties clearContentEncoding() { - packing_flags &= ~8192; - this.contentEncoding = null; - setDirty(true); - return this; - } - - public final String getContentEncoding() { - return contentEncoding; - } - - public final MessageProperties setContentEncoding(String value) { - this.contentEncoding = value; - packing_flags |= 8192; - setDirty(true); - return this; - } - - public final MessageProperties contentEncoding(String value) { - return setContentEncoding(value); - } - - public final boolean hasUserId() { - return (packing_flags & 16384) != 0; - } - - public final MessageProperties clearUserId() { - packing_flags &= ~16384; - this.userId = null; - setDirty(true); - return this; - } - - public final byte[] getUserId() { - return userId; - } - - public final MessageProperties setUserId(byte[] value) { - this.userId = value; - packing_flags |= 16384; - setDirty(true); - return this; - } - - public final MessageProperties userId(byte[] value) { - return setUserId(value); - } - - public final boolean hasAppId() { - return (packing_flags & 32768) != 0; - } - - public final MessageProperties clearAppId() { - packing_flags &= ~32768; - this.appId = null; - setDirty(true); - return this; - } - - public final byte[] getAppId() { - return appId; - } - - public final MessageProperties setAppId(byte[] value) { - this.appId = value; - packing_flags |= 32768; - setDirty(true); - return this; - } - - public final MessageProperties appId(byte[] value) { - return setAppId(value); - } - - public final boolean hasApplicationHeaders() { - return (packing_flags & 1) != 0; - } - - public final MessageProperties clearApplicationHeaders() { - packing_flags &= ~1; - this.applicationHeaders = null; - setDirty(true); - return this; - } - - public final Map getApplicationHeaders() { - return applicationHeaders; - } - - public final MessageProperties setApplicationHeaders(Map value) { - this.applicationHeaders = value; - packing_flags |= 1; - setDirty(true); - return this; - } - - public final MessageProperties applicationHeaders(Map value) { - return setApplicationHeaders(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeUint64(this.contentLength); - } - if ((packing_flags & 512) != 0) - { - enc.writeUuid(this.messageId); - } - if ((packing_flags & 1024) != 0) - { - enc.writeVbin16(this.correlationId); - } - if ((packing_flags & 2048) != 0) - { - enc.writeStruct(ReplyTo.TYPE, this.replyTo); - } - if ((packing_flags & 4096) != 0) - { - enc.writeStr8(this.contentType); - } - if ((packing_flags & 8192) != 0) - { - enc.writeStr8(this.contentEncoding); - } - if ((packing_flags & 16384) != 0) - { - enc.writeVbin16(this.userId); - } - if ((packing_flags & 32768) != 0) - { - enc.writeVbin16(this.appId); - } - if ((packing_flags & 1) != 0) - { - enc.writeMap(this.applicationHeaders); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.contentLength = dec.readUint64(); - } - if ((packing_flags & 512) != 0) - { - this.messageId = dec.readUuid(); - } - if ((packing_flags & 1024) != 0) - { - this.correlationId = dec.readVbin16(); - } - if ((packing_flags & 2048) != 0) - { - this.replyTo = (ReplyTo)dec.readStruct(ReplyTo.TYPE); - } - if ((packing_flags & 4096) != 0) - { - this.contentType = dec.readStr8(); - } - if ((packing_flags & 8192) != 0) - { - this.contentEncoding = dec.readStr8(); - } - if ((packing_flags & 16384) != 0) - { - this.userId = dec.readVbin16(); - } - if ((packing_flags & 32768) != 0) - { - this.appId = dec.readVbin16(); - } - if ((packing_flags & 1) != 0) - { - this.applicationHeaders = dec.readMap(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("contentLength", getContentLength()); - } - if ((packing_flags & 512) != 0) - { - result.put("messageId", getMessageId()); - } - if ((packing_flags & 1024) != 0) - { - result.put("correlationId", getCorrelationId()); - } - if ((packing_flags & 2048) != 0) - { - result.put("replyTo", getReplyTo()); - } - if ((packing_flags & 4096) != 0) - { - result.put("contentType", getContentType()); - } - if ((packing_flags & 8192) != 0) - { - result.put("contentEncoding", getContentEncoding()); - } - if ((packing_flags & 16384) != 0) - { - result.put("userId", getUserId()); - } - if ((packing_flags & 32768) != 0) - { - result.put("appId", getAppId()); - } - if ((packing_flags & 1) != 0) - { - result.put("applicationHeaders", getApplicationHeaders()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageReject.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageReject.java deleted file mode 100644 index 60cb37d55c..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageReject.java +++ /dev/null @@ -1,238 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class MessageReject extends Method { - - public static final int TYPE = 1027; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private RangeSet transfers; - private MessageRejectCode code; - private String text; - - - public MessageReject() {} - - - public MessageReject(RangeSet transfers, MessageRejectCode code, String text, Option ... _options) { - if(transfers != null) { - setTransfers(transfers); - } - if(code != null) { - setCode(code); - } - if(text != null) { - setText(text); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.messageReject(context, this); - } - - - public final boolean hasTransfers() { - return (packing_flags & 256) != 0; - } - - public final MessageReject clearTransfers() { - packing_flags &= ~256; - this.transfers = null; - setDirty(true); - return this; - } - - public final RangeSet getTransfers() { - return transfers; - } - - public final MessageReject setTransfers(RangeSet value) { - this.transfers = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final MessageReject transfers(RangeSet value) { - return setTransfers(value); - } - - public final boolean hasCode() { - return (packing_flags & 512) != 0; - } - - public final MessageReject clearCode() { - packing_flags &= ~512; - this.code = null; - setDirty(true); - return this; - } - - public final MessageRejectCode getCode() { - return code; - } - - public final MessageReject setCode(MessageRejectCode value) { - this.code = value; - packing_flags |= 512; - setDirty(true); - return this; - } - - public final MessageReject code(MessageRejectCode value) { - return setCode(value); - } - - public final boolean hasText() { - return (packing_flags & 1024) != 0; - } - - public final MessageReject clearText() { - packing_flags &= ~1024; - this.text = null; - setDirty(true); - return this; - } - - public final String getText() { - return text; - } - - public final MessageReject setText(String value) { - this.text = value; - packing_flags |= 1024; - setDirty(true); - return this; - } - - public final MessageReject text(String value) { - return setText(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeSequenceSet(this.transfers); - } - if ((packing_flags & 512) != 0) - { - enc.writeUint16(this.code.getValue()); - } - if ((packing_flags & 1024) != 0) - { - enc.writeStr8(this.text); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.transfers = dec.readSequenceSet(); - } - if ((packing_flags & 512) != 0) - { - this.code = MessageRejectCode.get(dec.readUint16()); - } - if ((packing_flags & 1024) != 0) - { - this.text = dec.readStr8(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("transfers", getTransfers()); - } - if ((packing_flags & 512) != 0) - { - result.put("code", getCode()); - } - if ((packing_flags & 1024) != 0) - { - result.put("text", getText()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageRejectCode.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageRejectCode.java deleted file mode 100644 index dc41de100b..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageRejectCode.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -public enum MessageRejectCode { - - UNSPECIFIED((int) 0), - UNROUTABLE((int) 1), - IMMEDIATE((int) 2); - - private final int value; - - MessageRejectCode(int value) - { - this.value = value; - } - - public int getValue() - { - return value; - } - - public static MessageRejectCode get(int value) - { - switch (value) - { - case (int) 0: return UNSPECIFIED; - case (int) 1: return UNROUTABLE; - case (int) 2: return IMMEDIATE; - default: throw new IllegalArgumentException("no such value: " + value); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageRelease.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageRelease.java deleted file mode 100644 index 557139dd01..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageRelease.java +++ /dev/null @@ -1,193 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class MessageRelease extends Method { - - public static final int TYPE = 1028; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private RangeSet transfers; - - - public MessageRelease() {} - - - public MessageRelease(RangeSet transfers, Option ... _options) { - if(transfers != null) { - setTransfers(transfers); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SET_REDELIVERED: packing_flags |= 512; break; - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.messageRelease(context, this); - } - - - public final boolean hasTransfers() { - return (packing_flags & 256) != 0; - } - - public final MessageRelease clearTransfers() { - packing_flags &= ~256; - this.transfers = null; - setDirty(true); - return this; - } - - public final RangeSet getTransfers() { - return transfers; - } - - public final MessageRelease setTransfers(RangeSet value) { - this.transfers = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final MessageRelease transfers(RangeSet value) { - return setTransfers(value); - } - - public final boolean hasSetRedelivered() { - return (packing_flags & 512) != 0; - } - - public final MessageRelease clearSetRedelivered() { - packing_flags &= ~512; - - setDirty(true); - return this; - } - - public final boolean getSetRedelivered() { - return hasSetRedelivered(); - } - - public final MessageRelease setSetRedelivered(boolean value) { - - if (value) - { - packing_flags |= 512; - } - else - { - packing_flags &= ~512; - } - - setDirty(true); - return this; - } - - public final MessageRelease setRedelivered(boolean value) { - return setSetRedelivered(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeSequenceSet(this.transfers); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.transfers = dec.readSequenceSet(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("transfers", getTransfers()); - } - if ((packing_flags & 512) != 0) - { - result.put("setRedelivered", getSetRedelivered()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageResume.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageResume.java deleted file mode 100644 index e0dfbdfd57..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageResume.java +++ /dev/null @@ -1,196 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class MessageResume extends Method { - - public static final int TYPE = 1030; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private String destination; - private String resumeId; - - - public MessageResume() {} - - - public MessageResume(String destination, String resumeId, Option ... _options) { - if(destination != null) { - setDestination(destination); - } - if(resumeId != null) { - setResumeId(resumeId); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.messageResume(context, this); - } - - - public final boolean hasDestination() { - return (packing_flags & 256) != 0; - } - - public final MessageResume clearDestination() { - packing_flags &= ~256; - this.destination = null; - setDirty(true); - return this; - } - - public final String getDestination() { - return destination; - } - - public final MessageResume setDestination(String value) { - this.destination = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final MessageResume destination(String value) { - return setDestination(value); - } - - public final boolean hasResumeId() { - return (packing_flags & 512) != 0; - } - - public final MessageResume clearResumeId() { - packing_flags &= ~512; - this.resumeId = null; - setDirty(true); - return this; - } - - public final String getResumeId() { - return resumeId; - } - - public final MessageResume setResumeId(String value) { - this.resumeId = value; - packing_flags |= 512; - setDirty(true); - return this; - } - - public final MessageResume resumeId(String value) { - return setResumeId(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeStr8(this.destination); - } - if ((packing_flags & 512) != 0) - { - enc.writeStr16(this.resumeId); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.destination = dec.readStr8(); - } - if ((packing_flags & 512) != 0) - { - this.resumeId = dec.readStr16(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("destination", getDestination()); - } - if ((packing_flags & 512) != 0) - { - result.put("resumeId", getResumeId()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageResumeResult.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageResumeResult.java deleted file mode 100644 index 1524b09509..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageResumeResult.java +++ /dev/null @@ -1,139 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - - - -public final class MessageResumeResult extends Struct { - - public static final int TYPE = 1029; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 4; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return -1; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private long offset; - - - public MessageResumeResult() {} - - - public MessageResumeResult(long offset) { - setOffset(offset); - - } - - - - - public final boolean hasOffset() { - return (packing_flags & 256) != 0; - } - - public final MessageResumeResult clearOffset() { - packing_flags &= ~256; - this.offset = 0; - setDirty(true); - return this; - } - - public final long getOffset() { - return offset; - } - - public final MessageResumeResult setOffset(long value) { - this.offset = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final MessageResumeResult offset(long value) { - return setOffset(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeUint64(this.offset); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.offset = dec.readUint64(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("offset", getOffset()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageSetFlowMode.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageSetFlowMode.java deleted file mode 100644 index 09457b9764..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageSetFlowMode.java +++ /dev/null @@ -1,196 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class MessageSetFlowMode extends Method { - - public static final int TYPE = 1033; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private String destination; - private MessageFlowMode flowMode; - - - public MessageSetFlowMode() {} - - - public MessageSetFlowMode(String destination, MessageFlowMode flowMode, Option ... _options) { - if(destination != null) { - setDestination(destination); - } - if(flowMode != null) { - setFlowMode(flowMode); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.messageSetFlowMode(context, this); - } - - - public final boolean hasDestination() { - return (packing_flags & 256) != 0; - } - - public final MessageSetFlowMode clearDestination() { - packing_flags &= ~256; - this.destination = null; - setDirty(true); - return this; - } - - public final String getDestination() { - return destination; - } - - public final MessageSetFlowMode setDestination(String value) { - this.destination = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final MessageSetFlowMode destination(String value) { - return setDestination(value); - } - - public final boolean hasFlowMode() { - return (packing_flags & 512) != 0; - } - - public final MessageSetFlowMode clearFlowMode() { - packing_flags &= ~512; - this.flowMode = null; - setDirty(true); - return this; - } - - public final MessageFlowMode getFlowMode() { - return flowMode; - } - - public final MessageSetFlowMode setFlowMode(MessageFlowMode value) { - this.flowMode = value; - packing_flags |= 512; - setDirty(true); - return this; - } - - public final MessageSetFlowMode flowMode(MessageFlowMode value) { - return setFlowMode(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeStr8(this.destination); - } - if ((packing_flags & 512) != 0) - { - enc.writeUint8(this.flowMode.getValue()); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.destination = dec.readStr8(); - } - if ((packing_flags & 512) != 0) - { - this.flowMode = MessageFlowMode.get(dec.readUint8()); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("destination", getDestination()); - } - if ((packing_flags & 512) != 0) - { - result.put("flowMode", getFlowMode()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageStop.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageStop.java deleted file mode 100644 index 45bb0ffe68..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageStop.java +++ /dev/null @@ -1,154 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class MessageStop extends Method { - - public static final int TYPE = 1036; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private String destination; - - - public MessageStop() {} - - - public MessageStop(String destination, Option ... _options) { - if(destination != null) { - setDestination(destination); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.messageStop(context, this); - } - - - public final boolean hasDestination() { - return (packing_flags & 256) != 0; - } - - public final MessageStop clearDestination() { - packing_flags &= ~256; - this.destination = null; - setDirty(true); - return this; - } - - public final String getDestination() { - return destination; - } - - public final MessageStop setDestination(String value) { - this.destination = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final MessageStop destination(String value) { - return setDestination(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeStr8(this.destination); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.destination = dec.readStr8(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("destination", getDestination()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageSubscribe.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageSubscribe.java deleted file mode 100644 index 4f9a1edf64..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageSubscribe.java +++ /dev/null @@ -1,443 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class MessageSubscribe extends Method { - - public static final int TYPE = 1031; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private String queue; - private String destination; - private MessageAcceptMode acceptMode; - private MessageAcquireMode acquireMode; - private String resumeId; - private long resumeTtl; - private Map arguments; - - - public MessageSubscribe() {} - - - public MessageSubscribe(String queue, String destination, MessageAcceptMode acceptMode, MessageAcquireMode acquireMode, String resumeId, long resumeTtl, Map arguments, Option ... _options) { - if(queue != null) { - setQueue(queue); - } - if(destination != null) { - setDestination(destination); - } - if(acceptMode != null) { - setAcceptMode(acceptMode); - } - if(acquireMode != null) { - setAcquireMode(acquireMode); - } - if(resumeId != null) { - setResumeId(resumeId); - } - setResumeTtl(resumeTtl); - if(arguments != null) { - setArguments(arguments); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case EXCLUSIVE: packing_flags |= 4096; break; - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.messageSubscribe(context, this); - } - - - public final boolean hasQueue() { - return (packing_flags & 256) != 0; - } - - public final MessageSubscribe clearQueue() { - packing_flags &= ~256; - this.queue = null; - setDirty(true); - return this; - } - - public final String getQueue() { - return queue; - } - - public final MessageSubscribe setQueue(String value) { - this.queue = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final MessageSubscribe queue(String value) { - return setQueue(value); - } - - public final boolean hasDestination() { - return (packing_flags & 512) != 0; - } - - public final MessageSubscribe clearDestination() { - packing_flags &= ~512; - this.destination = null; - setDirty(true); - return this; - } - - public final String getDestination() { - return destination; - } - - public final MessageSubscribe setDestination(String value) { - this.destination = value; - packing_flags |= 512; - setDirty(true); - return this; - } - - public final MessageSubscribe destination(String value) { - return setDestination(value); - } - - public final boolean hasAcceptMode() { - return (packing_flags & 1024) != 0; - } - - public final MessageSubscribe clearAcceptMode() { - packing_flags &= ~1024; - this.acceptMode = null; - setDirty(true); - return this; - } - - public final MessageAcceptMode getAcceptMode() { - return acceptMode; - } - - public final MessageSubscribe setAcceptMode(MessageAcceptMode value) { - this.acceptMode = value; - packing_flags |= 1024; - setDirty(true); - return this; - } - - public final MessageSubscribe acceptMode(MessageAcceptMode value) { - return setAcceptMode(value); - } - - public final boolean hasAcquireMode() { - return (packing_flags & 2048) != 0; - } - - public final MessageSubscribe clearAcquireMode() { - packing_flags &= ~2048; - this.acquireMode = null; - setDirty(true); - return this; - } - - public final MessageAcquireMode getAcquireMode() { - return acquireMode; - } - - public final MessageSubscribe setAcquireMode(MessageAcquireMode value) { - this.acquireMode = value; - packing_flags |= 2048; - setDirty(true); - return this; - } - - public final MessageSubscribe acquireMode(MessageAcquireMode value) { - return setAcquireMode(value); - } - - public final boolean hasExclusive() { - return (packing_flags & 4096) != 0; - } - - public final MessageSubscribe clearExclusive() { - packing_flags &= ~4096; - - setDirty(true); - return this; - } - - public final boolean getExclusive() { - return hasExclusive(); - } - - public final MessageSubscribe setExclusive(boolean value) { - - if (value) - { - packing_flags |= 4096; - } - else - { - packing_flags &= ~4096; - } - - setDirty(true); - return this; - } - - public final MessageSubscribe exclusive(boolean value) { - return setExclusive(value); - } - - public final boolean hasResumeId() { - return (packing_flags & 8192) != 0; - } - - public final MessageSubscribe clearResumeId() { - packing_flags &= ~8192; - this.resumeId = null; - setDirty(true); - return this; - } - - public final String getResumeId() { - return resumeId; - } - - public final MessageSubscribe setResumeId(String value) { - this.resumeId = value; - packing_flags |= 8192; - setDirty(true); - return this; - } - - public final MessageSubscribe resumeId(String value) { - return setResumeId(value); - } - - public final boolean hasResumeTtl() { - return (packing_flags & 16384) != 0; - } - - public final MessageSubscribe clearResumeTtl() { - packing_flags &= ~16384; - this.resumeTtl = 0; - setDirty(true); - return this; - } - - public final long getResumeTtl() { - return resumeTtl; - } - - public final MessageSubscribe setResumeTtl(long value) { - this.resumeTtl = value; - packing_flags |= 16384; - setDirty(true); - return this; - } - - public final MessageSubscribe resumeTtl(long value) { - return setResumeTtl(value); - } - - public final boolean hasArguments() { - return (packing_flags & 32768) != 0; - } - - public final MessageSubscribe clearArguments() { - packing_flags &= ~32768; - this.arguments = null; - setDirty(true); - return this; - } - - public final Map getArguments() { - return arguments; - } - - public final MessageSubscribe setArguments(Map value) { - this.arguments = value; - packing_flags |= 32768; - setDirty(true); - return this; - } - - public final MessageSubscribe arguments(Map value) { - return setArguments(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeStr8(this.queue); - } - if ((packing_flags & 512) != 0) - { - enc.writeStr8(this.destination); - } - if ((packing_flags & 1024) != 0) - { - enc.writeUint8(this.acceptMode.getValue()); - } - if ((packing_flags & 2048) != 0) - { - enc.writeUint8(this.acquireMode.getValue()); - } - if ((packing_flags & 8192) != 0) - { - enc.writeStr16(this.resumeId); - } - if ((packing_flags & 16384) != 0) - { - enc.writeUint64(this.resumeTtl); - } - if ((packing_flags & 32768) != 0) - { - enc.writeMap(this.arguments); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.queue = dec.readStr8(); - } - if ((packing_flags & 512) != 0) - { - this.destination = dec.readStr8(); - } - if ((packing_flags & 1024) != 0) - { - this.acceptMode = MessageAcceptMode.get(dec.readUint8()); - } - if ((packing_flags & 2048) != 0) - { - this.acquireMode = MessageAcquireMode.get(dec.readUint8()); - } - if ((packing_flags & 8192) != 0) - { - this.resumeId = dec.readStr16(); - } - if ((packing_flags & 16384) != 0) - { - this.resumeTtl = dec.readUint64(); - } - if ((packing_flags & 32768) != 0) - { - this.arguments = dec.readMap(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("queue", getQueue()); - } - if ((packing_flags & 512) != 0) - { - result.put("destination", getDestination()); - } - if ((packing_flags & 1024) != 0) - { - result.put("acceptMode", getAcceptMode()); - } - if ((packing_flags & 2048) != 0) - { - result.put("acquireMode", getAcquireMode()); - } - if ((packing_flags & 4096) != 0) - { - result.put("exclusive", getExclusive()); - } - if ((packing_flags & 8192) != 0) - { - result.put("resumeId", getResumeId()); - } - if ((packing_flags & 16384) != 0) - { - result.put("resumeTtl", getResumeTtl()); - } - if ((packing_flags & 32768) != 0) - { - result.put("arguments", getArguments()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageTransfer.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageTransfer.java deleted file mode 100644 index 38fe5d89d8..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/MessageTransfer.java +++ /dev/null @@ -1,302 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import java.nio.ByteBuffer; -import org.apache.qpid.util.Strings; -import org.apache.qpid.transport.network.Frame; - - -public final class MessageTransfer extends Method { - - public static final int TYPE = 1025; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return true; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private String destination; - private MessageAcceptMode acceptMode; - private MessageAcquireMode acquireMode; - private Header header; - private ByteBuffer body; - - - public MessageTransfer() {} - - - public MessageTransfer(String destination, MessageAcceptMode acceptMode, MessageAcquireMode acquireMode, Header header, java.nio.ByteBuffer body, Option ... _options) { - if(destination != null) { - setDestination(destination); - } - if(acceptMode != null) { - setAcceptMode(acceptMode); - } - if(acquireMode != null) { - setAcquireMode(acquireMode); - } - setHeader(header); - setBody(body); - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.messageTransfer(context, this); - } - - - public final boolean hasDestination() { - return (packing_flags & 256) != 0; - } - - public final MessageTransfer clearDestination() { - packing_flags &= ~256; - this.destination = null; - setDirty(true); - return this; - } - - public final String getDestination() { - return destination; - } - - public final MessageTransfer setDestination(String value) { - this.destination = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final MessageTransfer destination(String value) { - return setDestination(value); - } - - public final boolean hasAcceptMode() { - return (packing_flags & 512) != 0; - } - - public final MessageTransfer clearAcceptMode() { - packing_flags &= ~512; - this.acceptMode = null; - setDirty(true); - return this; - } - - public final MessageAcceptMode getAcceptMode() { - return acceptMode; - } - - public final MessageTransfer setAcceptMode(MessageAcceptMode value) { - this.acceptMode = value; - packing_flags |= 512; - setDirty(true); - return this; - } - - public final MessageTransfer acceptMode(MessageAcceptMode value) { - return setAcceptMode(value); - } - - public final boolean hasAcquireMode() { - return (packing_flags & 1024) != 0; - } - - public final MessageTransfer clearAcquireMode() { - packing_flags &= ~1024; - this.acquireMode = null; - setDirty(true); - return this; - } - - public final MessageAcquireMode getAcquireMode() { - return acquireMode; - } - - public final MessageTransfer setAcquireMode(MessageAcquireMode value) { - this.acquireMode = value; - packing_flags |= 1024; - setDirty(true); - return this; - } - - public final MessageTransfer acquireMode(MessageAcquireMode value) { - return setAcquireMode(value); - } - - - public final Header getHeader() { - return this.header; - } - - public final void setHeader(Header header) { - this.header = header; - } - - public final MessageTransfer header(Header header) { - setHeader(header); - return this; - } - - public int getBodySize() - { - return this.body == null ? 0 : this.body.remaining(); - } - - public final ByteBuffer getBody() { - if (this.body == null) - { - return null; - } - else - { - return this.body.slice(); - } - } - - public final void setBody(ByteBuffer body) { - this.body = body; - } - - public final MessageTransfer body(ByteBuffer body) - { - setBody(body); - return this; - } - - public final byte[] getBodyBytes() { - ByteBuffer buf = getBody(); - byte[] bytes = new byte[buf.remaining()]; - buf.get(bytes); - return bytes; - } - - public final void setBody(byte[] body) - { - setBody(ByteBuffer.wrap(body)); - } - - public final String getBodyString() { - return Strings.fromUTF8(getBodyBytes()); - } - - public final void setBody(String body) { - setBody(Strings.toUTF8(body)); - } - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeStr8(this.destination); - } - if ((packing_flags & 512) != 0) - { - enc.writeUint8(this.acceptMode.getValue()); - } - if ((packing_flags & 1024) != 0) - { - enc.writeUint8(this.acquireMode.getValue()); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.destination = dec.readStr8(); - } - if ((packing_flags & 512) != 0) - { - this.acceptMode = MessageAcceptMode.get(dec.readUint8()); - } - if ((packing_flags & 1024) != 0) - { - this.acquireMode = MessageAcquireMode.get(dec.readUint8()); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("destination", getDestination()); - } - if ((packing_flags & 512) != 0) - { - result.put("acceptMode", getAcceptMode()); - } - if ((packing_flags & 1024) != 0) - { - result.put("acquireMode", getAcquireMode()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/Method.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/Method.java deleted file mode 100644 index cddcd45d6f..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/Method.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - -import org.apache.qpid.transport.network.Frame; - -import static org.apache.qpid.transport.util.Functions.str; - -import java.nio.ByteBuffer; - -/** - * Method - * - * @author Rafael H. Schloming - */ - -public abstract class Method extends Struct implements ProtocolEvent -{ - - - public static final Method create(int type) - { - // XXX: should generate separate factories for separate - // namespaces - return (Method) StructFactory.createInstruction(type); - } - - // XXX: command subclass? - public static interface CompletionListener - { - public void onComplete(Method method); - } - - private int id; - private int channel; - private boolean idSet = false; - private boolean sync = false; - private boolean batch = false; - private boolean unreliable = false; - private CompletionListener completionListener; - - public final int getId() - { - return id; - } - - void setId(int id) - { - this.id = id; - this.idSet = true; - } - - boolean idSet() - { - return idSet; - } - - public final int getChannel() - { - return channel; - } - - public final void setChannel(int channel) - { - this.channel = channel; - } - - public final boolean isSync() - { - return sync; - } - - public final void setSync(boolean value) - { - this.sync = value; - } - - public final boolean isBatch() - { - return batch; - } - - final void setBatch(boolean value) - { - this.batch = value; - } - - public final boolean isUnreliable() - { - return unreliable; - } - - final void setUnreliable(boolean value) - { - this.unreliable = value; - } - - public abstract boolean hasPayload(); - - public Header getHeader() - { - return null; - } - - public void setHeader(Header header) - { - throw new UnsupportedOperationException(); - } - - public ByteBuffer getBody() - { - return null; - } - - public void setBody(ByteBuffer body) - { - throw new UnsupportedOperationException(); - } - - public int getBodySize() - { - ByteBuffer body = getBody(); - if (body == null) - { - return 0; - } - else - { - return body.remaining(); - } - } - - public abstract byte getEncodedTrack(); - - public abstract void dispatch(C context, MethodDelegate delegate); - - public void delegate(C context, ProtocolDelegate delegate) - { - if (getEncodedTrack() == Frame.L4) - { - delegate.command(context, this); - } - else - { - delegate.control(context, this); - } - } - - - public void setCompletionListener(CompletionListener completionListener) - { - this.completionListener = completionListener; - } - - public void complete() - { - if(completionListener!= null) - { - completionListener.onComplete(this); - completionListener = null; - } - } - - public boolean hasCompletionListener() - { - return completionListener != null; - } - - public String toString() - { - StringBuilder str = new StringBuilder(); - - str.append("ch="); - str.append(channel); - - if (getEncodedTrack() == Frame.L4 && idSet) - { - str.append(" id="); - str.append(id); - } - - if (sync || batch) - { - str.append(" "); - str.append("["); - if (sync) - { - str.append("S"); - } - if (batch) - { - str.append("B"); - } - str.append("]"); - } - - str.append(" "); - str.append(super.toString()); - Header hdr = getHeader(); - if (hdr != null) - { - for (Struct st : hdr.getStructs()) - { - str.append("\n "); - str.append(st); - } - } - ByteBuffer body = getBody(); - if (body != null) - { - str.append("\n body="); - str.append(str(body, 64)); - } - - return str.toString(); - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/MethodDelegate.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/MethodDelegate.java deleted file mode 100644 index 33f52d9f2b..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/MethodDelegate.java +++ /dev/null @@ -1,217 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -public abstract class MethodDelegate { - - public abstract void handle(C context, Method method); - - public void connectionStart(C context, ConnectionStart method) { - handle(context, method); - } - public void connectionStartOk(C context, ConnectionStartOk method) { - handle(context, method); - } - public void connectionSecure(C context, ConnectionSecure method) { - handle(context, method); - } - public void connectionSecureOk(C context, ConnectionSecureOk method) { - handle(context, method); - } - public void connectionTune(C context, ConnectionTune method) { - handle(context, method); - } - public void connectionTuneOk(C context, ConnectionTuneOk method) { - handle(context, method); - } - public void connectionOpen(C context, ConnectionOpen method) { - handle(context, method); - } - public void connectionOpenOk(C context, ConnectionOpenOk method) { - handle(context, method); - } - public void connectionRedirect(C context, ConnectionRedirect method) { - handle(context, method); - } - public void connectionHeartbeat(C context, ConnectionHeartbeat method) { - handle(context, method); - } - public void connectionClose(C context, ConnectionClose method) { - handle(context, method); - } - public void connectionCloseOk(C context, ConnectionCloseOk method) { - handle(context, method); - } - public void sessionAttach(C context, SessionAttach method) { - handle(context, method); - } - public void sessionAttached(C context, SessionAttached method) { - handle(context, method); - } - public void sessionDetach(C context, SessionDetach method) { - handle(context, method); - } - public void sessionDetached(C context, SessionDetached method) { - handle(context, method); - } - public void sessionRequestTimeout(C context, SessionRequestTimeout method) { - handle(context, method); - } - public void sessionTimeout(C context, SessionTimeout method) { - handle(context, method); - } - public void sessionCommandPoint(C context, SessionCommandPoint method) { - handle(context, method); - } - public void sessionExpected(C context, SessionExpected method) { - handle(context, method); - } - public void sessionConfirmed(C context, SessionConfirmed method) { - handle(context, method); - } - public void sessionCompleted(C context, SessionCompleted method) { - handle(context, method); - } - public void sessionKnownCompleted(C context, SessionKnownCompleted method) { - handle(context, method); - } - public void sessionFlush(C context, SessionFlush method) { - handle(context, method); - } - public void sessionGap(C context, SessionGap method) { - handle(context, method); - } - public void executionSync(C context, ExecutionSync method) { - handle(context, method); - } - public void executionResult(C context, ExecutionResult method) { - handle(context, method); - } - public void executionException(C context, ExecutionException method) { - handle(context, method); - } - public void messageTransfer(C context, MessageTransfer method) { - handle(context, method); - } - public void messageAccept(C context, MessageAccept method) { - handle(context, method); - } - public void messageReject(C context, MessageReject method) { - handle(context, method); - } - public void messageRelease(C context, MessageRelease method) { - handle(context, method); - } - public void messageAcquire(C context, MessageAcquire method) { - handle(context, method); - } - public void messageResume(C context, MessageResume method) { - handle(context, method); - } - public void messageSubscribe(C context, MessageSubscribe method) { - handle(context, method); - } - public void messageCancel(C context, MessageCancel method) { - handle(context, method); - } - public void messageSetFlowMode(C context, MessageSetFlowMode method) { - handle(context, method); - } - public void messageFlow(C context, MessageFlow method) { - handle(context, method); - } - public void messageFlush(C context, MessageFlush method) { - handle(context, method); - } - public void messageStop(C context, MessageStop method) { - handle(context, method); - } - public void txSelect(C context, TxSelect method) { - handle(context, method); - } - public void txCommit(C context, TxCommit method) { - handle(context, method); - } - public void txRollback(C context, TxRollback method) { - handle(context, method); - } - public void dtxSelect(C context, DtxSelect method) { - handle(context, method); - } - public void dtxStart(C context, DtxStart method) { - handle(context, method); - } - public void dtxEnd(C context, DtxEnd method) { - handle(context, method); - } - public void dtxCommit(C context, DtxCommit method) { - handle(context, method); - } - public void dtxForget(C context, DtxForget method) { - handle(context, method); - } - public void dtxGetTimeout(C context, DtxGetTimeout method) { - handle(context, method); - } - public void dtxPrepare(C context, DtxPrepare method) { - handle(context, method); - } - public void dtxRecover(C context, DtxRecover method) { - handle(context, method); - } - public void dtxRollback(C context, DtxRollback method) { - handle(context, method); - } - public void dtxSetTimeout(C context, DtxSetTimeout method) { - handle(context, method); - } - public void exchangeDeclare(C context, ExchangeDeclare method) { - handle(context, method); - } - public void exchangeDelete(C context, ExchangeDelete method) { - handle(context, method); - } - public void exchangeQuery(C context, ExchangeQuery method) { - handle(context, method); - } - public void exchangeBind(C context, ExchangeBind method) { - handle(context, method); - } - public void exchangeUnbind(C context, ExchangeUnbind method) { - handle(context, method); - } - public void exchangeBound(C context, ExchangeBound method) { - handle(context, method); - } - public void queueDeclare(C context, QueueDeclare method) { - handle(context, method); - } - public void queueDelete(C context, QueueDelete method) { - handle(context, method); - } - public void queuePurge(C context, QueuePurge method) { - handle(context, method); - } - public void queueQuery(C context, QueueQuery method) { - handle(context, method); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/NetworkEventReceiver.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/NetworkEventReceiver.java deleted file mode 100644 index 8b9c3f4f83..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/NetworkEventReceiver.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - -import org.apache.qpid.transport.network.NetworkEvent; - -public interface NetworkEventReceiver -{ - void received(NetworkEvent msg); - - void exception(Throwable t); - - void closed(); -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/NetworkTransportConfiguration.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/NetworkTransportConfiguration.java deleted file mode 100644 index 7af3b7af39..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/NetworkTransportConfiguration.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - -import java.net.InetSocketAddress; -import java.util.Collection; - -/** - * This interface provides a means for NetworkDrivers to configure TCP options such as incoming and outgoing - * buffer sizes and set particular options on the socket. NetworkDrivers should honour the values returned - * from here if the underlying implementation supports them. - */ -public interface NetworkTransportConfiguration -{ - // Taken from Socket - boolean getTcpNoDelay(); - - // The amount of memory in bytes to allocate to the incoming buffer - int getReceiveBufferSize(); - - // The amount of memory in bytes to allocate to the outgoing buffer - int getSendBufferSize(); - - InetSocketAddress getAddress(); - - boolean needClientAuth(); - - boolean wantClientAuth(); - - Collection getEnabledCipherSuites(); - - Collection getDisabledCipherSuites(); -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/Option.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/Option.java deleted file mode 100644 index 72187795b3..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/Option.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -public enum Option { - - SYNC, - DISCARD_UNROUTABLE, - IMMEDIATE, - REDELIVERED, - FIRST, - LAST, - DURABLE, - NOT_FOUND, - EXCHANGE_NOT_FOUND, - QUEUE_NOT_FOUND, - QUEUE_NOT_MATCHED, - KEY_NOT_MATCHED, - ARGS_NOT_MATCHED, - EXCLUSIVE, - AUTO_DELETE, - INSIST, - FORCE, - TIMELY_REPLY, - EXPECTED, - CONFIRMED, - COMPLETED, - SET_REDELIVERED, - JOIN, - RESUME, - FAIL, - SUSPEND, - ONE_PHASE, - PASSIVE, - IF_UNUSED, - IF_EMPTY, - - BATCH, - UNRELIABLE, - NONE -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolDelegate.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolDelegate.java deleted file mode 100644 index a90948fc1d..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolDelegate.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - - -/** - * ProtocolDelegate - * - */ - -public interface ProtocolDelegate -{ - - void init(C context, ProtocolHeader header); - - void control(C context, Method control); - - void command(C context, Method command); - - void error(C context, ProtocolError error); - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolError.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolError.java deleted file mode 100644 index 8a5edc302e..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolError.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - -import org.apache.qpid.transport.network.NetworkDelegate; -import org.apache.qpid.transport.network.NetworkEvent; - - -/** - * ProtocolError - * - * @author Rafael H. Schloming - */ - -public final class ProtocolError implements NetworkEvent, ProtocolEvent -{ - - private int channel; - private final byte track; - private final String format; - private final Object[] args; - - public ProtocolError(byte track, String format, Object ... args) - { - this.track = track; - this.format = format; - this.args = args; - } - - public int getChannel() - { - return channel; - } - - public void setChannel(int channel) - { - this.channel = channel; - } - - public byte getEncodedTrack() - { - return track; - } - - public boolean isConnectionControl() - { - return false; - } - - public String getMessage() - { - return String.format(format, args); - } - - public void delegate(C context, ProtocolDelegate delegate) - { - delegate.error(context, this); - } - - public void delegate(NetworkDelegate delegate) - { - delegate.error(this); - } - - public String toString() - { - return String.format("protocol error: %s", getMessage()); - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolEvent.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolEvent.java deleted file mode 100644 index b51a540701..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolEvent.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - - -/** - * ProtocolEvent - * - */ - -public interface ProtocolEvent -{ - - int getChannel(); - - void setChannel(int channel); - - byte getEncodedTrack(); - - void delegate(C context, ProtocolDelegate delegate); - - boolean isConnectionControl(); -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolEventReceiver.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolEventReceiver.java deleted file mode 100644 index e4ab540ce9..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolEventReceiver.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - -public interface ProtocolEventReceiver -{ - void received(ProtocolEvent msg); - - void exception(Throwable t); - - void closed(); -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolEventSender.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolEventSender.java deleted file mode 100644 index 418f31b42a..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolEventSender.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - -public interface ProtocolEventSender -{ - void send(ProtocolEvent msg); - - void flush(); - - void close(); -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolHeader.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolHeader.java deleted file mode 100644 index 3959dc8d95..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolHeader.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - -import org.apache.qpid.transport.network.Frame; -import org.apache.qpid.transport.network.NetworkDelegate; -import org.apache.qpid.transport.network.NetworkEvent; - -import java.nio.ByteBuffer; - - -/** - * ProtocolHeader - * - * @author Rafael H. Schloming - */ - -public final class ProtocolHeader implements NetworkEvent, ProtocolEvent -{ - - private static final byte[] AMQP = {'A', 'M', 'Q', 'P' }; - private static final byte CLASS = 1; - - final private byte protoClass; - final private byte instance; - final private byte major; - final private byte minor; - private int channel; - - public ProtocolHeader(byte protoClass, byte instance, byte major, byte minor) - { - this.protoClass = protoClass; - this.instance = instance; - this.major = major; - this.minor = minor; - } - - public ProtocolHeader(int instance, int major, int minor) - { - this(CLASS, (byte) instance, (byte) major, (byte) minor); - } - - public byte getInstance() - { - return instance; - } - - public byte getMajor() - { - return major; - } - - public byte getMinor() - { - return minor; - } - - public int getChannel() - { - return channel; - } - - public void setChannel(int channel) - { - this.channel = channel; - } - - public byte getEncodedTrack() - { - return Frame.L1; - } - - public boolean isConnectionControl() - { - return false; - } - - public ByteBuffer toByteBuffer() - { - ByteBuffer buf = ByteBuffer.allocate(8); - buf.put(AMQP); - buf.put(protoClass); - buf.put(instance); - buf.put(major); - buf.put(minor); - buf.flip(); - return buf; - } - - public void delegate(C context, ProtocolDelegate delegate) - { - delegate.init(context, this); - } - - public void delegate(NetworkDelegate delegate) - { - delegate.init(this); - } - - public String toString() - { - return String.format("AMQP.%d %d-%d", instance, major, minor); - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolVersionException.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolVersionException.java deleted file mode 100644 index db8064268c..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolVersionException.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - - -/** - * ProtocolVersionException - * - */ - -public final class ProtocolVersionException extends ConnectionException -{ - - private final byte major; - private final byte minor; - - public ProtocolVersionException(byte major, byte minor, Throwable cause) - { - super(String.format("version mismatch: %s-%s", major, minor), cause); - this.major = major; - this.minor = minor; - } - - public ProtocolVersionException(byte major, byte minor) - { - this(major, minor, null); - } - - public byte getMajor() - { - return this.major; - } - - public byte getMinor() - { - return this.minor; - } - - @Override public void rethrow() - { - throw new ProtocolVersionException(major, minor, this); - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/QueueDeclare.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/QueueDeclare.java deleted file mode 100644 index 2b7495e622..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/QueueDeclare.java +++ /dev/null @@ -1,394 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class QueueDeclare extends Method { - - public static final int TYPE = 2049; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private String queue; - private String alternateExchange; - private Map arguments; - - - public QueueDeclare() {} - - - public QueueDeclare(String queue, String alternateExchange, Map arguments, Option ... _options) { - if(queue != null) { - setQueue(queue); - } - if(alternateExchange != null) { - setAlternateExchange(alternateExchange); - } - if(arguments != null) { - setArguments(arguments); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case PASSIVE: packing_flags |= 1024; break; - case DURABLE: packing_flags |= 2048; break; - case EXCLUSIVE: packing_flags |= 4096; break; - case AUTO_DELETE: packing_flags |= 8192; break; - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.queueDeclare(context, this); - } - - - public final boolean hasQueue() { - return (packing_flags & 256) != 0; - } - - public final QueueDeclare clearQueue() { - packing_flags &= ~256; - this.queue = null; - setDirty(true); - return this; - } - - public final String getQueue() { - return queue; - } - - public final QueueDeclare setQueue(String value) { - this.queue = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final QueueDeclare queue(String value) { - return setQueue(value); - } - - public final boolean hasAlternateExchange() { - return (packing_flags & 512) != 0; - } - - public final QueueDeclare clearAlternateExchange() { - packing_flags &= ~512; - this.alternateExchange = null; - setDirty(true); - return this; - } - - public final String getAlternateExchange() { - return alternateExchange; - } - - public final QueueDeclare setAlternateExchange(String value) { - this.alternateExchange = value; - packing_flags |= 512; - setDirty(true); - return this; - } - - public final QueueDeclare alternateExchange(String value) { - return setAlternateExchange(value); - } - - public final boolean hasPassive() { - return (packing_flags & 1024) != 0; - } - - public final QueueDeclare clearPassive() { - packing_flags &= ~1024; - - setDirty(true); - return this; - } - - public final boolean getPassive() { - return hasPassive(); - } - - public final QueueDeclare setPassive(boolean value) { - - if (value) - { - packing_flags |= 1024; - } - else - { - packing_flags &= ~1024; - } - - setDirty(true); - return this; - } - - public final QueueDeclare passive(boolean value) { - return setPassive(value); - } - - public final boolean hasDurable() { - return (packing_flags & 2048) != 0; - } - - public final QueueDeclare clearDurable() { - packing_flags &= ~2048; - - setDirty(true); - return this; - } - - public final boolean getDurable() { - return hasDurable(); - } - - public final QueueDeclare setDurable(boolean value) { - - if (value) - { - packing_flags |= 2048; - } - else - { - packing_flags &= ~2048; - } - - setDirty(true); - return this; - } - - public final QueueDeclare durable(boolean value) { - return setDurable(value); - } - - public final boolean hasExclusive() { - return (packing_flags & 4096) != 0; - } - - public final QueueDeclare clearExclusive() { - packing_flags &= ~4096; - - setDirty(true); - return this; - } - - public final boolean getExclusive() { - return hasExclusive(); - } - - public final QueueDeclare setExclusive(boolean value) { - - if (value) - { - packing_flags |= 4096; - } - else - { - packing_flags &= ~4096; - } - - setDirty(true); - return this; - } - - public final QueueDeclare exclusive(boolean value) { - return setExclusive(value); - } - - public final boolean hasAutoDelete() { - return (packing_flags & 8192) != 0; - } - - public final QueueDeclare clearAutoDelete() { - packing_flags &= ~8192; - - setDirty(true); - return this; - } - - public final boolean getAutoDelete() { - return hasAutoDelete(); - } - - public final QueueDeclare setAutoDelete(boolean value) { - - if (value) - { - packing_flags |= 8192; - } - else - { - packing_flags &= ~8192; - } - - setDirty(true); - return this; - } - - public final QueueDeclare autoDelete(boolean value) { - return setAutoDelete(value); - } - - public final boolean hasArguments() { - return (packing_flags & 16384) != 0; - } - - public final QueueDeclare clearArguments() { - packing_flags &= ~16384; - this.arguments = null; - setDirty(true); - return this; - } - - public final Map getArguments() { - return arguments; - } - - public final QueueDeclare setArguments(Map value) { - this.arguments = value; - packing_flags |= 16384; - setDirty(true); - return this; - } - - public final QueueDeclare arguments(Map value) { - return setArguments(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeStr8(this.queue); - } - if ((packing_flags & 512) != 0) - { - enc.writeStr8(this.alternateExchange); - } - if ((packing_flags & 16384) != 0) - { - enc.writeMap(this.arguments); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.queue = dec.readStr8(); - } - if ((packing_flags & 512) != 0) - { - this.alternateExchange = dec.readStr8(); - } - if ((packing_flags & 16384) != 0) - { - this.arguments = dec.readMap(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("queue", getQueue()); - } - if ((packing_flags & 512) != 0) - { - result.put("alternateExchange", getAlternateExchange()); - } - if ((packing_flags & 1024) != 0) - { - result.put("passive", getPassive()); - } - if ((packing_flags & 2048) != 0) - { - result.put("durable", getDurable()); - } - if ((packing_flags & 4096) != 0) - { - result.put("exclusive", getExclusive()); - } - if ((packing_flags & 8192) != 0) - { - result.put("autoDelete", getAutoDelete()); - } - if ((packing_flags & 16384) != 0) - { - result.put("arguments", getArguments()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/QueueDelete.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/QueueDelete.java deleted file mode 100644 index 2c0040ff1d..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/QueueDelete.java +++ /dev/null @@ -1,232 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class QueueDelete extends Method { - - public static final int TYPE = 2050; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private String queue; - - - public QueueDelete() {} - - - public QueueDelete(String queue, Option ... _options) { - if(queue != null) { - setQueue(queue); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case IF_UNUSED: packing_flags |= 512; break; - case IF_EMPTY: packing_flags |= 1024; break; - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.queueDelete(context, this); - } - - - public final boolean hasQueue() { - return (packing_flags & 256) != 0; - } - - public final QueueDelete clearQueue() { - packing_flags &= ~256; - this.queue = null; - setDirty(true); - return this; - } - - public final String getQueue() { - return queue; - } - - public final QueueDelete setQueue(String value) { - this.queue = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final QueueDelete queue(String value) { - return setQueue(value); - } - - public final boolean hasIfUnused() { - return (packing_flags & 512) != 0; - } - - public final QueueDelete clearIfUnused() { - packing_flags &= ~512; - - setDirty(true); - return this; - } - - public final boolean getIfUnused() { - return hasIfUnused(); - } - - public final QueueDelete setIfUnused(boolean value) { - - if (value) - { - packing_flags |= 512; - } - else - { - packing_flags &= ~512; - } - - setDirty(true); - return this; - } - - public final QueueDelete ifUnused(boolean value) { - return setIfUnused(value); - } - - public final boolean hasIfEmpty() { - return (packing_flags & 1024) != 0; - } - - public final QueueDelete clearIfEmpty() { - packing_flags &= ~1024; - - setDirty(true); - return this; - } - - public final boolean getIfEmpty() { - return hasIfEmpty(); - } - - public final QueueDelete setIfEmpty(boolean value) { - - if (value) - { - packing_flags |= 1024; - } - else - { - packing_flags &= ~1024; - } - - setDirty(true); - return this; - } - - public final QueueDelete ifEmpty(boolean value) { - return setIfEmpty(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeStr8(this.queue); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.queue = dec.readStr8(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("queue", getQueue()); - } - if ((packing_flags & 512) != 0) - { - result.put("ifUnused", getIfUnused()); - } - if ((packing_flags & 1024) != 0) - { - result.put("ifEmpty", getIfEmpty()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/QueuePurge.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/QueuePurge.java deleted file mode 100644 index 972149e251..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/QueuePurge.java +++ /dev/null @@ -1,154 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class QueuePurge extends Method { - - public static final int TYPE = 2051; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private String queue; - - - public QueuePurge() {} - - - public QueuePurge(String queue, Option ... _options) { - if(queue != null) { - setQueue(queue); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.queuePurge(context, this); - } - - - public final boolean hasQueue() { - return (packing_flags & 256) != 0; - } - - public final QueuePurge clearQueue() { - packing_flags &= ~256; - this.queue = null; - setDirty(true); - return this; - } - - public final String getQueue() { - return queue; - } - - public final QueuePurge setQueue(String value) { - this.queue = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final QueuePurge queue(String value) { - return setQueue(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeStr8(this.queue); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.queue = dec.readStr8(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("queue", getQueue()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/QueueQuery.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/QueueQuery.java deleted file mode 100644 index 22da74f6b7..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/QueueQuery.java +++ /dev/null @@ -1,154 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class QueueQuery extends Method { - - public static final int TYPE = 2052; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private String queue; - - - public QueueQuery() {} - - - public QueueQuery(String queue, Option ... _options) { - if(queue != null) { - setQueue(queue); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.queueQuery(context, this); - } - - - public final boolean hasQueue() { - return (packing_flags & 256) != 0; - } - - public final QueueQuery clearQueue() { - packing_flags &= ~256; - this.queue = null; - setDirty(true); - return this; - } - - public final String getQueue() { - return queue; - } - - public final QueueQuery setQueue(String value) { - this.queue = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final QueueQuery queue(String value) { - return setQueue(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeStr8(this.queue); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.queue = dec.readStr8(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("queue", getQueue()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/QueueQueryResult.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/QueueQueryResult.java deleted file mode 100644 index ca0c027603..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/QueueQueryResult.java +++ /dev/null @@ -1,429 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - - - -public final class QueueQueryResult extends Struct { - - public static final int TYPE = 2049; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 4; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return -1; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private String queue; - private String alternateExchange; - private Map arguments; - private long messageCount; - private long subscriberCount; - - - public QueueQueryResult() {} - - - public QueueQueryResult(String queue, String alternateExchange, Map arguments, long messageCount, long subscriberCount, Option ... _options) { - if(queue != null) { - setQueue(queue); - } - if(alternateExchange != null) { - setAlternateExchange(alternateExchange); - } - if(arguments != null) { - setArguments(arguments); - } - setMessageCount(messageCount); - setSubscriberCount(subscriberCount); - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case DURABLE: packing_flags |= 1024; break; - case EXCLUSIVE: packing_flags |= 2048; break; - case AUTO_DELETE: packing_flags |= 4096; break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - - - - public final boolean hasQueue() { - return (packing_flags & 256) != 0; - } - - public final QueueQueryResult clearQueue() { - packing_flags &= ~256; - this.queue = null; - setDirty(true); - return this; - } - - public final String getQueue() { - return queue; - } - - public final QueueQueryResult setQueue(String value) { - this.queue = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final QueueQueryResult queue(String value) { - return setQueue(value); - } - - public final boolean hasAlternateExchange() { - return (packing_flags & 512) != 0; - } - - public final QueueQueryResult clearAlternateExchange() { - packing_flags &= ~512; - this.alternateExchange = null; - setDirty(true); - return this; - } - - public final String getAlternateExchange() { - return alternateExchange; - } - - public final QueueQueryResult setAlternateExchange(String value) { - this.alternateExchange = value; - packing_flags |= 512; - setDirty(true); - return this; - } - - public final QueueQueryResult alternateExchange(String value) { - return setAlternateExchange(value); - } - - public final boolean hasDurable() { - return (packing_flags & 1024) != 0; - } - - public final QueueQueryResult clearDurable() { - packing_flags &= ~1024; - - setDirty(true); - return this; - } - - public final boolean getDurable() { - return hasDurable(); - } - - public final QueueQueryResult setDurable(boolean value) { - - if (value) - { - packing_flags |= 1024; - } - else - { - packing_flags &= ~1024; - } - - setDirty(true); - return this; - } - - public final QueueQueryResult durable(boolean value) { - return setDurable(value); - } - - public final boolean hasExclusive() { - return (packing_flags & 2048) != 0; - } - - public final QueueQueryResult clearExclusive() { - packing_flags &= ~2048; - - setDirty(true); - return this; - } - - public final boolean getExclusive() { - return hasExclusive(); - } - - public final QueueQueryResult setExclusive(boolean value) { - - if (value) - { - packing_flags |= 2048; - } - else - { - packing_flags &= ~2048; - } - - setDirty(true); - return this; - } - - public final QueueQueryResult exclusive(boolean value) { - return setExclusive(value); - } - - public final boolean hasAutoDelete() { - return (packing_flags & 4096) != 0; - } - - public final QueueQueryResult clearAutoDelete() { - packing_flags &= ~4096; - - setDirty(true); - return this; - } - - public final boolean getAutoDelete() { - return hasAutoDelete(); - } - - public final QueueQueryResult setAutoDelete(boolean value) { - - if (value) - { - packing_flags |= 4096; - } - else - { - packing_flags &= ~4096; - } - - setDirty(true); - return this; - } - - public final QueueQueryResult autoDelete(boolean value) { - return setAutoDelete(value); - } - - public final boolean hasArguments() { - return (packing_flags & 8192) != 0; - } - - public final QueueQueryResult clearArguments() { - packing_flags &= ~8192; - this.arguments = null; - setDirty(true); - return this; - } - - public final Map getArguments() { - return arguments; - } - - public final QueueQueryResult setArguments(Map value) { - this.arguments = value; - packing_flags |= 8192; - setDirty(true); - return this; - } - - public final QueueQueryResult arguments(Map value) { - return setArguments(value); - } - - public final boolean hasMessageCount() { - return (packing_flags & 16384) != 0; - } - - public final QueueQueryResult clearMessageCount() { - packing_flags &= ~16384; - this.messageCount = 0; - setDirty(true); - return this; - } - - public final long getMessageCount() { - return messageCount; - } - - public final QueueQueryResult setMessageCount(long value) { - this.messageCount = value; - packing_flags |= 16384; - setDirty(true); - return this; - } - - public final QueueQueryResult messageCount(long value) { - return setMessageCount(value); - } - - public final boolean hasSubscriberCount() { - return (packing_flags & 32768) != 0; - } - - public final QueueQueryResult clearSubscriberCount() { - packing_flags &= ~32768; - this.subscriberCount = 0; - setDirty(true); - return this; - } - - public final long getSubscriberCount() { - return subscriberCount; - } - - public final QueueQueryResult setSubscriberCount(long value) { - this.subscriberCount = value; - packing_flags |= 32768; - setDirty(true); - return this; - } - - public final QueueQueryResult subscriberCount(long value) { - return setSubscriberCount(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeStr8(this.queue); - } - if ((packing_flags & 512) != 0) - { - enc.writeStr8(this.alternateExchange); - } - if ((packing_flags & 8192) != 0) - { - enc.writeMap(this.arguments); - } - if ((packing_flags & 16384) != 0) - { - enc.writeUint32(this.messageCount); - } - if ((packing_flags & 32768) != 0) - { - enc.writeUint32(this.subscriberCount); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.queue = dec.readStr8(); - } - if ((packing_flags & 512) != 0) - { - this.alternateExchange = dec.readStr8(); - } - if ((packing_flags & 8192) != 0) - { - this.arguments = dec.readMap(); - } - if ((packing_flags & 16384) != 0) - { - this.messageCount = dec.readUint32(); - } - if ((packing_flags & 32768) != 0) - { - this.subscriberCount = dec.readUint32(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("queue", getQueue()); - } - if ((packing_flags & 512) != 0) - { - result.put("alternateExchange", getAlternateExchange()); - } - if ((packing_flags & 1024) != 0) - { - result.put("durable", getDurable()); - } - if ((packing_flags & 2048) != 0) - { - result.put("exclusive", getExclusive()); - } - if ((packing_flags & 4096) != 0) - { - result.put("autoDelete", getAutoDelete()); - } - if ((packing_flags & 8192) != 0) - { - result.put("arguments", getArguments()); - } - if ((packing_flags & 16384) != 0) - { - result.put("messageCount", getMessageCount()); - } - if ((packing_flags & 32768) != 0) - { - result.put("subscriberCount", getSubscriberCount()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/Range.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/Range.java deleted file mode 100644 index 413ec8e8fd..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/Range.java +++ /dev/null @@ -1,306 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - -import static org.apache.qpid.util.Serial.gt; -import static org.apache.qpid.util.Serial.le; -import static org.apache.qpid.util.Serial.max; -import static org.apache.qpid.util.Serial.min; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - - -/** - * Range - * - * @author Rafael H. Schloming - */ - -public abstract class Range implements RangeSet -{ - public static Range newInstance(int point) - { - return new PointImpl(point); - } - - public static Range newInstance(int lower, int upper) - { - return lower == upper ? new PointImpl(lower) : new RangeImpl(lower, upper); - } - - public abstract int getLower(); - - public abstract int getUpper(); - - public abstract boolean includes(int value); - - public abstract boolean includes(Range range); - - public abstract boolean intersects(Range range); - - public abstract boolean touches(Range range); - - public abstract Range span(Range range); - - public abstract List subtract(Range range); - - - public Range intersect(Range range) - { - int l = max(getLower(), range.getLower()); - int r = min(getUpper(), range.getUpper()); - if (gt(l, r)) - { - return null; - } - else - { - return newInstance(l, r); - } - } - - - - public int size() - { - return 1; - } - - public Iterator iterator() - { - return new RangeIterator(); - } - - public Range getFirst() - { - return this; - } - - public Range getLast() - { - return this; - } - - public void add(Range range) - { - throw new UnsupportedOperationException(); - } - - public void add(int lower, int upper) - { - throw new UnsupportedOperationException(); - } - - public void add(int value) - { - throw new UnsupportedOperationException(); - } - - public void clear() - { - throw new UnsupportedOperationException(); - } - - public void subtract(RangeSet rangeSet) - { - throw new UnsupportedOperationException(); - } - - public RangeSet copy() - { - RangeSet rangeSet = RangeSetFactory.createRangeSet(); - rangeSet.add(this); - return rangeSet; - } - - private static class PointImpl extends Range - { - private final int point; - - private PointImpl(int point) - { - this.point = point; - } - - public int getLower() - { - return point; - } - - public int getUpper() - { - return point; - } - - public boolean includes(int value) - { - return value == point; - } - - - public boolean includes(Range range) - { - return range.getLower() == point && range.getUpper() == point; - } - - public boolean intersects(Range range) - { - return range.includes(point); - } - - public boolean touches(Range range) - { - return intersects(range) || - includes(range.getUpper() + 1) || includes(range.getLower() - 1) || - range.includes(point + 1) || range.includes(point - 1); - } - - public Range span(Range range) - { - return newInstance(min(point, range.getLower()), max(point, range.getUpper())); - } - - public List subtract(Range range) - { - if(range.includes(point)) - { - return Collections.emptyList(); - } - else - { - return Collections.singletonList((Range) this); - } - } - - public String toString() - { - return "[" + point + ", " + point + "]"; - } - - - } - - private static class RangeImpl extends Range - { - private final int lower; - private final int upper; - - private RangeImpl(int lower, int upper) - { - this.lower = lower; - this.upper = upper; - } - - public int getLower() - { - return lower; - } - - public int getUpper() - { - return upper; - } - - public boolean includes(int value) - { - return le(lower, value) && le(value, upper); - } - - public boolean includes(Range range) - { - return includes(range.getLower()) && includes(range.getUpper()); - } - - public boolean intersects(Range range) - { - return (includes(range.getLower()) || includes(range.getUpper()) || - range.includes(lower) || range.includes(upper)); - } - - public boolean touches(Range range) - { - return (intersects(range) || - includes(range.getUpper() + 1) || includes(range.getLower() - 1) || - range.includes(upper + 1) || range.includes(lower - 1)); - } - - public Range span(Range range) - { - return newInstance(min(lower, range.getLower()), max(upper, range.getUpper())); - } - - public List subtract(Range range) - { - List result = new ArrayList(); - - if (includes(range.getLower()) && le(lower, range.getLower() - 1)) - { - result.add(newInstance(lower, range.getLower() - 1)); - } - - if (includes(range.getUpper()) && le(range.getUpper() + 1, upper)) - { - result.add(newInstance(range.getUpper() + 1, upper)); - } - - if (result.isEmpty() && !range.includes(this)) - { - result.add(this); - } - - return result; - } - - - public String toString() - { - return "[" + lower + ", " + upper + "]"; - } - } - - - private class RangeIterator implements Iterator - { - private boolean atFirst = true; - - public boolean hasNext() - { - return atFirst; - } - - public Range next() - { - - Range range = atFirst ? Range.this : null; - atFirst = false; - return range; - } - - - public void remove() - { - throw new UnsupportedOperationException(); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/RangeSet.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/RangeSet.java deleted file mode 100644 index 19990a4610..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/RangeSet.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - -import java.util.Iterator; - -/** - * RangeSet - * - * @author Rafael H. Schloming - */ - -public interface RangeSet extends Iterable -{ - - int size(); - - Iterator iterator(); - - Range getFirst(); - - Range getLast(); - - boolean includes(Range range); - - boolean includes(int n); - - void add(Range range); - - void add(int lower, int upper); - - void add(int value); - - void subtract(final RangeSet other); - - void clear(); - - RangeSet copy(); - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/RangeSetFactory.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/RangeSetFactory.java deleted file mode 100644 index 0f049aba8e..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/RangeSetFactory.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - -public class RangeSetFactory -{ - private RangeSetFactory() - { - } - - public static RangeSet createRangeSet() - { - return new RangeSetImpl(); - } - - public static RangeSet createRangeSet(int size) - { - return new RangeSetImpl(size); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/RangeSetImpl.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/RangeSetImpl.java deleted file mode 100644 index adf18e2920..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/RangeSetImpl.java +++ /dev/null @@ -1,240 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - -import static org.apache.qpid.util.Serial.lt; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; - -public class RangeSetImpl implements RangeSet -{ - - private List ranges; - - public RangeSetImpl() - { - ranges = new ArrayList(); - } - - public RangeSetImpl(int size) - { - ranges = new ArrayList(size); - } - - - public RangeSetImpl(org.apache.qpid.transport.RangeSetImpl copy) - { - ranges = new ArrayList(copy.ranges); - } - - public int size() - { - return ranges.size(); - } - - public Iterator iterator() - { - return ranges.iterator(); - } - - public Range getFirst() - { - return ranges.get(0); - } - - public Range getLast() - { - return ranges.get(ranges.size() - 1); - } - - public boolean includes(Range range) - { - for (Range r : this) - { - if (r.includes(range)) - { - return true; - } - } - - return false; - } - - public boolean includes(int n) - { - for (Range r : this) - { - if (r.includes(n)) - { - return true; - } - } - - return false; - } - - public void add(Range range) - { - ListIterator it = ranges.listIterator(); - - while (it.hasNext()) - { - Range next = it.next(); - if (range.touches(next)) - { - it.remove(); - range = range.span(next); - } - else if (lt(range.getUpper(), next.getLower())) - { - it.previous(); - it.add(range); - return; - } - } - - it.add(range); - } - - public void add(int lower, int upper) - { - switch(ranges.size()) - { - case 0: - ranges.add(Range.newInstance(lower, upper)); - break; - - case 1: - Range first = ranges.get(0); - if(first.getUpper() + 1 >= lower && upper >= first.getUpper()) - { - ranges.set(0, Range.newInstance(first.getLower(), upper)); - break; - } - - default: - add(Range.newInstance(lower, upper)); - } - - - } - - public void add(int value) - { - add(value, value); - } - - public void clear() - { - ranges.clear(); - } - - public void subtract(final RangeSet other) - { - final Iterator otherIter = other.iterator() ; - if (otherIter.hasNext()) - { - Range otherRange = otherIter.next(); - final ListIterator iter = ranges.listIterator() ; - if (iter.hasNext()) - { - Range range = iter.next(); - do - { - if (otherRange.getUpper() < range.getLower()) - { - otherRange = nextRange(otherIter) ; - } - else if (range.getUpper() < otherRange.getLower()) - { - range = nextRange(iter) ; - } - else - { - final boolean first = range.getLower() < otherRange.getLower() ; - final boolean second = otherRange.getUpper() < range.getUpper() ; - - if (first) - { - iter.set(Range.newInstance(range.getLower(), otherRange.getLower()-1)) ; - if (second) - { - iter.add(Range.newInstance(otherRange.getUpper()+1, range.getUpper())) ; - iter.previous() ; - range = iter.next() ; - } - else - { - range = nextRange(iter) ; - } - } - else if (second) - { - range = Range.newInstance(otherRange.getUpper()+1, range.getUpper()) ; - iter.set(range) ; - otherRange = nextRange(otherIter) ; - } - else - { - iter.remove() ; - range = nextRange(iter) ; - } - } - } - while ((otherRange != null) && (range != null)) ; - } - } - } - - private Range nextRange(final Iterator iter) - { - return (iter.hasNext() ? iter.next() : null) ; - } - - public RangeSet copy() - { - return new org.apache.qpid.transport.RangeSetImpl(this); - } - - public String toString() - { - StringBuffer str = new StringBuffer(); - str.append("{"); - boolean first = true; - for (Range range : ranges) - { - if (first) - { - first = false; - } - else - { - str.append(", "); - } - str.append(range); - } - str.append("}"); - return str.toString(); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/RecoverResult.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/RecoverResult.java deleted file mode 100644 index 7a78f373f6..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/RecoverResult.java +++ /dev/null @@ -1,141 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - - - -public final class RecoverResult extends Struct { - - public static final int TYPE = 1539; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 4; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return -1; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private java.util.List inDoubt; - - - public RecoverResult() {} - - - public RecoverResult(java.util.List inDoubt) { - if(inDoubt != null) { - setInDoubt(inDoubt); - } - - } - - - - - public final boolean hasInDoubt() { - return (packing_flags & 256) != 0; - } - - public final RecoverResult clearInDoubt() { - packing_flags &= ~256; - this.inDoubt = null; - setDirty(true); - return this; - } - - public final java.util.List getInDoubt() { - return inDoubt; - } - - public final RecoverResult setInDoubt(java.util.List value) { - this.inDoubt = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final RecoverResult inDoubt(java.util.List value) { - return setInDoubt(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeArray(this.inDoubt); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.inDoubt = dec.readArray(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("inDoubt", getInDoubt()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ReplyTo.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ReplyTo.java deleted file mode 100644 index 38340db5ce..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ReplyTo.java +++ /dev/null @@ -1,200 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - - - -public final class ReplyTo extends Struct { - - public static final int TYPE = -3; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 2; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return -1; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private String exchange; - private String routingKey; - - - public ReplyTo() {} - - - public ReplyTo(String exchange, String routingKey) { - if(exchange != null) { - setExchange(exchange); - } - if(routingKey != null) { - setRoutingKey(routingKey); - } - - } - - - - - public final boolean hasExchange() { - return (packing_flags & 256) != 0; - } - - public final ReplyTo clearExchange() { - packing_flags &= ~256; - this.exchange = null; - setDirty(true); - return this; - } - - public final String getExchange() { - return exchange; - } - - public final ReplyTo setExchange(String value) { - this.exchange = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final ReplyTo exchange(String value) { - return setExchange(value); - } - - public final boolean hasRoutingKey() { - return (packing_flags & 512) != 0; - } - - public final ReplyTo clearRoutingKey() { - packing_flags &= ~512; - this.routingKey = null; - setDirty(true); - return this; - } - - public final String getRoutingKey() { - return routingKey; - } - - public final ReplyTo setRoutingKey(String value) { - this.routingKey = value; - packing_flags |= 512; - setDirty(true); - return this; - } - - public final ReplyTo routingKey(String value) { - return setRoutingKey(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeStr8(this.exchange); - } - if ((packing_flags & 512) != 0) - { - enc.writeStr8(this.routingKey); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.exchange = dec.readStr8(); - } - if ((packing_flags & 512) != 0) - { - this.routingKey = dec.readStr8(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("exchange", getExchange()); - } - if ((packing_flags & 512) != 0) - { - result.put("routingKey", getRoutingKey()); - } - - - return result; - } - - public boolean equals(final Object obj){ - if (this == obj){ - return true; - } - - if(!(obj instanceof ReplyTo)){ - return false; - } - - final ReplyTo reply = (ReplyTo) obj; - return (routingKey == null ? reply.getRoutingKey() == null : routingKey.equals(reply.getRoutingKey())) - && (exchange == null ? reply.getExchange() == null : exchange.equals(reply.getExchange())); - } - - public int hashCode(){ - int result = routingKey == null ? 1 : routingKey.hashCode(); - return 31 * result + (exchange == null ? 5 : exchange.hashCode()); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/SegmentType.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/SegmentType.java deleted file mode 100644 index c9ba87abf4..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/SegmentType.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -public enum SegmentType { - - CONTROL((short) 0), - COMMAND((short) 1), - HEADER((short) 2), - BODY((short) 3); - - private final short value; - - SegmentType(short value) - { - this.value = value; - } - - public short getValue() - { - return value; - } - - public static SegmentType get(short value) - { - switch (value) - { - case (short) 0: return CONTROL; - case (short) 1: return COMMAND; - case (short) 2: return HEADER; - case (short) 3: return BODY; - default: throw new IllegalArgumentException("no such value: " + value); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/SenderClosedException.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/SenderClosedException.java deleted file mode 100644 index 924c327861..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/SenderClosedException.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - - -/** - * SenderClosedException - * - */ - -public class SenderClosedException extends SenderException -{ - - public SenderClosedException(String message, Throwable cause) - { - super(message, cause); - } - - public SenderClosedException(String message) - { - super(message); - } - - public SenderClosedException(Throwable cause) - { - super(cause); - } - - public void rethrow() - { - throw new SenderClosedException(getMessage(), this); - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/SenderException.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/SenderException.java deleted file mode 100644 index a96079dc27..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/SenderException.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - - -/** - * SenderException - * - */ - -public class SenderException extends TransportException -{ - - public SenderException(String message, Throwable cause) - { - super(message, cause); - } - - public SenderException(String message) - { - super(message); - } - - public SenderException(Throwable cause) - { - super(cause); - } - - public void rethrow() - { - throw new SenderException(getMessage(), this); - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ServerDelegate.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ServerDelegate.java deleted file mode 100644 index f8fd286f17..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ServerDelegate.java +++ /dev/null @@ -1,214 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - -import static org.apache.qpid.transport.Connection.State.OPEN; - -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import javax.security.sasl.Sasl; -import javax.security.sasl.SaslException; -import javax.security.sasl.SaslServer; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * ServerDelegate - */ -public class ServerDelegate extends ConnectionDelegate -{ - protected static final Logger _logger = LoggerFactory.getLogger(ServerDelegate.class); - - private List _locales; - private List _mechanisms; - private Map _clientProperties; - - - public ServerDelegate() - { - this(null, Collections.emptyList(), Collections.singletonList((Object)"utf8")); - } - - protected ServerDelegate(Map clientProperties, List mechanisms, List locales) - { - _clientProperties = clientProperties; - _mechanisms = mechanisms; - _locales = locales; - } - - public void init(Connection conn, ProtocolHeader hdr) - { - conn.send(new ProtocolHeader(1, 0, 10)); - - conn.connectionStart(_clientProperties, _mechanisms, _locales); - } - - @Override - public void connectionStartOk(Connection conn, ConnectionStartOk ok) - { - conn.setLocale(ok.getLocale()); - String mechanism = ok.getMechanism(); - - if (mechanism == null || mechanism.length() == 0) - { - conn.connectionClose(ConnectionCloseCode.CONNECTION_FORCED, - "No Sasl mechanism was specified"); - return; - } - - try - { - - SaslServer ss = createSaslServer(conn, mechanism); - if (ss == null) - { - conn.connectionClose(ConnectionCloseCode.CONNECTION_FORCED, - "No SaslServer could be created for mechanism: " + mechanism); - return; - } - conn.setSaslServer(ss); - secure(conn, ok.getResponse()); - } - catch (SaslException e) - { - connectionAuthFailed(conn, e); - } - } - - protected SaslServer createSaslServer(Connection conn, String mechanism) - throws SaslException - { - SaslServer ss = Sasl.createSaslServer(mechanism, "AMQP", "localhost", null, null); - return ss; - } - - protected void secure(final SaslServer ss, final Connection conn, final byte[] response) - { - try - { - byte[] challenge = ss.evaluateResponse(response); - if (ss.isComplete()) - { - ss.dispose(); - tuneAuthorizedConnection(conn); - } - else - { - connectionAuthContinue(conn, challenge); - } - } - catch (SaslException e) - { - connectionAuthFailed(conn, e); - } - } - - protected void connectionAuthFailed(final Connection conn, Exception e) - { - if (e != null) - { - conn.exception(e); - } - conn.connectionClose(ConnectionCloseCode.CONNECTION_FORCED, e == null ? "Authentication failed" : e.getMessage()); - } - - protected void connectionAuthContinue(final Connection conn, byte[] challenge) - { - conn.connectionSecure(challenge); - } - - protected void tuneAuthorizedConnection(final Connection conn) - { - conn.connectionTune(getChannelMax(), getFrameMax(), 0, getHeartbeatMax()); - } - - protected int getFrameMax() - { - return org.apache.qpid.transport.network.ConnectionBinding.MAX_FRAME_SIZE; - } - - protected void secure(final Connection conn, final byte[] response) - { - final SaslServer ss = conn.getSaslServer(); - secure(ss, conn, response); - } - - protected int getHeartbeatMax() - { - return 0xFFFF; - } - - protected int getChannelMax() - { - return 0xFFFF; - } - - @Override - public void connectionSecureOk(Connection conn, ConnectionSecureOk ok) - { - secure(conn, ok.getResponse()); - } - - @Override - public void connectionTuneOk(Connection conn, ConnectionTuneOk ok) - { - - } - - @Override - public void connectionOpen(Connection conn, ConnectionOpen open) - { - conn.connectionOpenOk(Collections.emptyList()); - - conn.setState(OPEN); - } - - protected Session getSession(Connection conn, SessionDelegate delegate, SessionAttach atc) - { - return new Session(conn, delegate, new Binary(atc.getName()), 0); - } - - - public Session getSession(Connection conn, SessionAttach atc) - { - return new Session(conn, new Binary(atc.getName()), 0); - } - - @Override - public void sessionAttach(Connection conn, SessionAttach atc) - { - Session ssn = getSession(conn, atc); - conn.map(ssn, atc.getChannel()); - conn.registerSession(ssn); - ssn.sessionAttached(atc.getName()); - ssn.setState(Session.State.OPEN); - } - - protected void setConnectionTuneOkChannelMax(final Connection conn, final int okChannelMax) - { - //0 means no implied limit, except available server resources - //(or that forced by protocol limitations [0xFFFF]) - conn.setChannelMax(okChannelMax == 0 ? Connection.MAX_CHANNEL_MAX : okChannelMax); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/Session.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/Session.java deleted file mode 100644 index 90288eedcc..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/Session.java +++ /dev/null @@ -1,1215 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - - -import org.apache.qpid.configuration.ClientProperties; -import org.apache.qpid.transport.network.Frame; -import org.apache.qpid.transport.util.Logger; -import org.apache.qpid.transport.util.Waiter; -import static org.apache.qpid.transport.Option.COMPLETED; -import static org.apache.qpid.transport.Option.SYNC; -import static org.apache.qpid.transport.Option.TIMELY_REPLY; -import static org.apache.qpid.transport.Session.State.CLOSED; -import static org.apache.qpid.transport.Session.State.CLOSING; -import static org.apache.qpid.transport.Session.State.DETACHED; -import static org.apache.qpid.transport.Session.State.NEW; -import static org.apache.qpid.transport.Session.State.OPEN; -import static org.apache.qpid.transport.Session.State.RESUMING; -import static org.apache.qpid.util.Serial.ge; -import static org.apache.qpid.util.Serial.gt; -import static org.apache.qpid.util.Serial.le; -import static org.apache.qpid.util.Serial.lt; -import static org.apache.qpid.util.Serial.max; -import static org.apache.qpid.util.Strings.toUTF8; - -import java.nio.ByteBuffer; -import java.util.HashMap; -import java.util.Map; -import java.util.TreeMap; -import java.util.concurrent.Semaphore; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; - -/** - * Session - * - * @author Rafael H. Schloming - */ - -public class Session extends SessionInvoker -{ - private static final Logger log = Logger.get(Session.class); - - public enum State { NEW, DETACHED, RESUMING, OPEN, CLOSING, CLOSED } - - static class DefaultSessionListener implements SessionListener - { - - public void opened(Session ssn) {} - - public void resumed(Session ssn) {} - - public void message(Session ssn, MessageTransfer xfr) - { - log.info("message: %s", xfr); - } - - public void exception(Session ssn, SessionException exc) - { - log.error(exc, "session exception"); - } - - public void closed(Session ssn) {} - } - - public static final int UNLIMITED_CREDIT = 0xFFFFFFFF; - - private Connection connection; - private Binary name; - private long expiry; - private boolean closing; - private int channel; - private SessionDelegate delegate; - private SessionListener listener = new DefaultSessionListener(); - private final long timeout = Long.getLong(ClientProperties.QPID_SYNC_OP_TIMEOUT, - Long.getLong(ClientProperties.AMQJ_DEFAULT_SYNCWRITE_TIMEOUT, - ClientProperties.DEFAULT_SYNC_OPERATION_TIMEOUT)); - private final long blockedSendTimeout = Long.getLong(ClientProperties.QPID_FLOW_CONTROL_WAIT_FAILURE, - ClientProperties.DEFAULT_FLOW_CONTROL_WAIT_FAILURE); - private long blockedSendReportingPeriod = Long.getLong(ClientProperties.QPID_FLOW_CONTROL_WAIT_NOTIFY_PERIOD, - ClientProperties.DEFAULT_FLOW_CONTROL_WAIT_NOTIFY_PERIOD); - - private boolean autoSync = false; - - private boolean incomingInit; - // incoming command count - private int commandsIn; - // completed incoming commands - private final Object processedLock = new Object(); - private RangeSet processed; - private int maxProcessed; - private int syncPoint; - - // outgoing command count - private int commandsOut = 0; - private final int commandLimit = Integer.getInteger("qpid.session.command_limit", 64 * 1024); - private Map commands = new HashMap(); - private final Object commandsLock = new Object(); - private int commandBytes = 0; - private int byteLimit = Integer.getInteger("qpid.session.byte_limit", 1024*1024); - private int maxComplete = commandsOut - 1; - private boolean needSync = false; - - private State state = NEW; - - // transfer flow control - private volatile boolean flowControl = false; - private Semaphore credit = new Semaphore(0); - - private Thread resumer = null; - private boolean transacted = false; - private SessionDetachCode detachCode; - private final Object stateLock = new Object(); - - private final AtomicBoolean _failoverRequired = new AtomicBoolean(false); - private boolean _isNoReplay = false; - - protected Session(Connection connection, Binary name, long expiry) - { - this(connection, new SessionDelegate(), name, expiry); - } - - protected Session(Connection connection, Binary name, long expiry, boolean noReplay) - { - this(connection, new SessionDelegate(), name, expiry, noReplay); - } - - protected Session(Connection connection, SessionDelegate delegate, Binary name, long expiry) - { - this(connection, delegate, name, expiry,false); - } - - protected Session(Connection connection, SessionDelegate delegate, Binary name, long expiry, boolean noReplay) - { - this.connection = connection; - this.delegate = delegate; - this.name = name; - this.expiry = expiry; - this.closing = false; - this._isNoReplay = noReplay; - initReceiver(); - } - - public Connection getConnection() - { - return connection; - } - - public Binary getName() - { - return name; - } - - void setExpiry(long expiry) - { - this.expiry = expiry; - } - - protected void setClose(boolean close) - { - this.closing = close; - } - - public int getChannel() - { - return channel; - } - - void setChannel(int channel) - { - this.channel = channel; - } - - public void setSessionListener(SessionListener listener) - { - if (listener == null) - { - this.listener = new DefaultSessionListener(); - } - else - { - this.listener = listener; - } - } - - public SessionListener getSessionListener() - { - return listener; - } - - public void setAutoSync(boolean value) - { - synchronized (commandsLock) - { - this.autoSync = value; - } - } - - protected void setState(State state) - { - synchronized (commandsLock) - { - this.state = state; - commandsLock.notifyAll(); - } - } - - protected State getState() - { - return this.state; - } - - void setFlowControl(boolean value) - { - flowControl = value; - } - - void addCredit(int value) - { - credit.release(value); - } - - void drainCredit() - { - credit.drainPermits(); - } - - void acquireCredit() - { - if (flowControl) - { - try - { - long wait = blockedSendTimeout > blockedSendReportingPeriod ? blockedSendReportingPeriod : - blockedSendTimeout; - long totalWait = 1L; - while(totalWait <= blockedSendTimeout && !credit.tryAcquire(wait, TimeUnit.MILLISECONDS)) - { - totalWait+=wait; - log.warn("Message send delayed by " + (totalWait)/1000 + "s due to broker enforced flow control"); - - - } - if(totalWait > blockedSendTimeout) - { - log.error("Message send failed due to timeout waiting on broker enforced flow control"); - throw new SessionException - ("timed out waiting for message credit"); - } - } - catch (InterruptedException e) - { - throw new SessionException - ("interrupted while waiting for credit", null, e); - } - } - } - - private void initReceiver() - { - synchronized (processedLock) - { - incomingInit = false; - processed = RangeSetFactory.createRangeSet(); - } - } - - void attach() - { - initReceiver(); - sessionAttach(name.getBytes()); - sessionRequestTimeout(0);//use expiry here only if/when session resume is supported - } - - void resume() - { - _failoverRequired.set(false); - - synchronized (commandsLock) - { - attach(); - - for (int i = maxComplete + 1; lt(i, commandsOut); i++) - { - Method m = getCommand(i); - if (m == null) - { - m = new ExecutionSync(); - m.setId(i); - } - else if (m instanceof MessageTransfer) - { - MessageTransfer xfr = (MessageTransfer)m; - - Header header = xfr.getHeader(); - - if (header != null) - { - if (header.getDeliveryProperties() != null) - { - header.getDeliveryProperties().setRedelivered(true); - } - else - { - DeliveryProperties deliveryProps = new DeliveryProperties(); - deliveryProps.setRedelivered(true); - - xfr.setHeader(new Header(deliveryProps, header.getMessageProperties(), - header.getNonStandardProperties())); - } - - } - else - { - DeliveryProperties deliveryProps = new DeliveryProperties(); - deliveryProps.setRedelivered(true); - xfr.setHeader(new Header(deliveryProps, null, null)); - } - } - sessionCommandPoint(m.getId(), 0); - send(m); - } - - sessionCommandPoint(commandsOut, 0); - - sessionFlush(COMPLETED); - resumer = Thread.currentThread(); - state = RESUMING; - - if(isTransacted()) - { - txSelect(); - } - - listener.resumed(this); - resumer = null; - } - } - - private Method getCommand(int i) - { - return commands.get(i); - } - - private void setCommand(int commandId, Method command) - { - commands.put(commandId, command); - } - - private Method removeCommand(int id) - { - return commands.remove(id); - } - - void dump() - { - synchronized (commandsLock) - { - TreeMap ordered = new TreeMap(commands); - for (Method m : ordered.values()) - { - if (m != null) - { - log.debug("%s", m); - } - } - } - } - - final void commandPoint(int id) - { - synchronized (processedLock) - { - this.commandsIn = id; - if (!incomingInit) - { - incomingInit = true; - maxProcessed = commandsIn - 1; - syncPoint = maxProcessed; - } - } - } - - public int getCommandsOut() - { - return commandsOut; - } - - public int getCommandsIn() - { - return commandsIn; - } - - public int nextCommandId() - { - return commandsIn++; - } - - final void identify(Method cmd) - { - if (!incomingInit) - { - throw new IllegalStateException(); - } - - int id = nextCommandId(); - cmd.setId(id); - - if(log.isDebugEnabled()) - { - log.debug("identify: ch=%s, commandId=%s", this.channel, id); - } - - if ((id & 0xff) == 0) - { - flushProcessed(TIMELY_REPLY); - } - } - - public void processed(Method command) - { - processed(command.getId()); - } - - public void processed(int command) - { - processed(command, command); - } - - public void processed(Range range) - { - - processed(range.getLower(), range.getUpper()); - } - - public void processed(int lower, int upper) - { - if(log.isDebugEnabled()) - { - log.debug("%s ch=%s processed([%d,%d]) %s %s", this, channel, lower, upper, syncPoint, maxProcessed); - } - - boolean flush; - synchronized (processedLock) - { - if(log.isDebugEnabled()) - { - log.debug("%s processed: %s", this, processed); - } - - if (ge(upper, commandsIn)) - { - throw new IllegalArgumentException - ("range exceeds max received command-id: " + Range.newInstance(lower, upper)); - } - - processed.add(lower, upper); - - Range first = processed.getFirst(); - - int flower = first.getLower(); - int fupper = first.getUpper(); - int old = maxProcessed; - if (le(flower, maxProcessed + 1)) - { - maxProcessed = max(maxProcessed, fupper); - } - boolean synced = ge(maxProcessed, syncPoint); - flush = lt(old, syncPoint) && synced; - if (synced) - { - syncPoint = maxProcessed; - } - } - if (flush) - { - flushProcessed(); - } - } - - void flushExpected() - { - RangeSet rs = RangeSetFactory.createRangeSet(); - synchronized (processedLock) - { - if (incomingInit) - { - rs.add(commandsIn); - } - } - sessionExpected(rs, null); - } - - public void flushProcessed(Option ... options) - { - RangeSet copy; - synchronized (processedLock) - { - copy = processed.copy(); - } - - synchronized (commandsLock) - { - if (state == DETACHED || state == CLOSING || state == CLOSED) - { - return; - } - if (copy.size() > 0) - { - sessionCompleted(copy, options); - } - } - } - - void knownComplete(RangeSet kc) - { - if (kc.size() > 0) - { - synchronized (processedLock) - { - processed.subtract(kc) ; - } - } - } - - void syncPoint() - { - int id = getCommandsIn() - 1; - log.debug("%s synced to %d", this, id); - boolean flush; - synchronized (processedLock) - { - syncPoint = id; - flush = ge(maxProcessed, syncPoint); - } - if (flush) - { - flushProcessed(); - } - } - - protected boolean complete(int lower, int upper) - { - //avoid autoboxing - if(log.isDebugEnabled()) - { - log.debug("%s complete(%d, %d)", this, lower, upper); - } - synchronized (commandsLock) - { - int old = maxComplete; - for (int id = max(maxComplete, lower); le(id, upper); id++) - { - Method m = removeCommand(id); - if (m != null) - { - commandBytes -= m.getBodySize(); - m.complete(); - } - } - if (le(lower, maxComplete + 1)) - { - maxComplete = max(maxComplete, upper); - } - - if(log.isDebugEnabled()) - { - log.debug("%s commands remaining: %s", this, commandsOut - maxComplete); - } - - commandsLock.notifyAll(); - return gt(maxComplete, old); - } - } - - void received(Method m) - { - m.delegate(this, delegate); - } - - private void send(Method m) - { - m.setChannel(channel); - connection.send(m); - - if (!m.isBatch()) - { - connection.flush(); - } - } - - protected boolean isFull(int id) - { - return isCommandsFull(id) || isBytesFull(); - } - - protected boolean isBytesFull() - { - return commandBytes >= byteLimit; - } - - protected boolean isCommandsFull(int id) - { - return id - maxComplete >= commandLimit; - } - - public void invoke(Method m) - { - invoke(m,(Runnable)null); - } - - public void invoke(Method m, Runnable postIdSettingAction) - { - if (m.getEncodedTrack() == Frame.L4) - { - if (m.hasPayload()) - { - acquireCredit(); - } - - synchronized (commandsLock) - { - if (state == DETACHED && m.isUnreliable()) - { - Thread current = Thread.currentThread(); - if (!current.equals(resumer)) - { - return; - } - } - - if (state != OPEN && state != CLOSED && state != CLOSING) - { - Thread current = Thread.currentThread(); - if (!current.equals(resumer) ) - { - Waiter w = new Waiter(commandsLock, timeout); - while (w.hasTime() && (state != OPEN && state != CLOSED)) - { - checkFailoverRequired("Command was interrupted because of failover, before being sent"); - w.await(); - } - } - } - - switch (state) - { - case OPEN: - break; - case RESUMING: - Thread current = Thread.currentThread(); - if (!current.equals(resumer)) - { - throw new SessionException - ("timed out waiting for resume to finish"); - } - break; - case CLOSING: - case CLOSED: - ExecutionException exc = getException(); - if (exc != null) - { - throw new SessionException(exc); - } - else - { - throw new SessionClosedException(); - } - default: - throw new SessionException - (String.format - ("timed out waiting for session to become open " + - "(state=%s)", state)); - } - - int next; - next = commandsOut++; - m.setId(next); - if(postIdSettingAction != null) - { - postIdSettingAction.run(); - } - - if (isFull(next)) - { - Waiter w = new Waiter(commandsLock, timeout); - while (w.hasTime() && isFull(next) && state != CLOSED) - { - if (state == OPEN || state == RESUMING) - { - try - { - sessionFlush(COMPLETED); - } - catch (SenderException e) - { - if (!closing) - { - // if expiry is > 0 then this will - // happen again on resume - log.error(e, "error sending flush (full replay buffer)"); - } - else - { - e.rethrow(); - } - } - } - checkFailoverRequired("Command was interrupted because of failover, before being sent"); - w.await(); - } - } - - if (state == CLOSED) - { - ExecutionException exc = getException(); - if (exc != null) - { - throw new SessionException(exc); - } - else - { - throw new SessionClosedException(); - } - } - - if (isFull(next)) - { - throw new SessionException("timed out waiting for completion"); - } - - if (next == 0) - { - sessionCommandPoint(0, 0); - } - - boolean replayTransfer = !_isNoReplay && !closing && !transacted && - m instanceof MessageTransfer && - ! m.isUnreliable(); - - if ((replayTransfer) || m.hasCompletionListener()) - { - setCommand(next, m); - commandBytes += m.getBodySize(); - } - if (autoSync) - { - m.setSync(true); - } - needSync = !m.isSync(); - - try - { - send(m); - } - catch (SenderException e) - { - if (!closing) - { - // if we are not closing then this will happen - // again on resume - log.error(e, "error sending command"); - } - else - { - e.rethrow(); - } - } - if (autoSync) - { - sync(); - } - - // flush every 64K commands to avoid ambiguity on - // wraparound - if (shouldIssueFlush(next)) - { - try - { - sessionFlush(COMPLETED); - } - catch (SenderException e) - { - if (!closing) - { - // if expiry is > 0 then this will happen - // again on resume - log.error(e, "error sending flush (periodic)"); - } - else - { - e.rethrow(); - } - } - } - } - } - else - { - send(m); - } - } - - private void checkFailoverRequired(String message) - { - if (_failoverRequired.get()) - { - throw new SessionException(message); - } - } - - protected boolean shouldIssueFlush(int next) - { - return (next % 65536) == 0; - } - - public void sync() - { - sync(timeout); - } - - public void sync(long timeout) - { - log.debug("%s sync()", this); - synchronized (commandsLock) - { - int point = commandsOut - 1; - - if (needSync && lt(maxComplete, point)) - { - executionSync(SYNC); - } - - Waiter w = new Waiter(commandsLock, timeout); - while (w.hasTime() && state != CLOSED && lt(maxComplete, point)) - { - checkFailoverRequired("Session sync was interrupted by failover."); - if(log.isDebugEnabled()) - { - log.debug("%s waiting for[%d]: %d, %s", this, point, maxComplete, commands); - } - w.await(); - } - - if (lt(maxComplete, point)) - { - if (state != CLOSED) - { - throw new SessionException( - String.format("timed out waiting for sync: complete = %s, point = %s", - maxComplete, point)); - } - else - { - ExecutionException ee = getException(); - if (ee != null) - { - throw new SessionException(ee); - } - } - } - } - } - - private Map> results = new HashMap>(); - private ExecutionException exception = null; - - void result(int command, Struct result) - { - ResultFuture future; - synchronized (results) - { - future = results.remove(command); - } - - if (future != null) - { - future.set(result); - } - else - { - log.warn("Received a response to a command" + - " that's no longer valid on the client side." + - " [ command id : %s , result : %s ]",command, result); - } - } - - void setException(ExecutionException exc) - { - synchronized (results) - { - if (exception != null) - { - throw new IllegalStateException( - String.format("too many exceptions: %s, %s", exception, exc)); - } - exception = exc; - } - } - - ExecutionException getException() - { - synchronized (results) - { - return exception; - } - } - - protected Future invoke(Method m, Class klass) - { - synchronized (commandsLock) - { - int command = commandsOut; - ResultFuture future = new ResultFuture(klass); - synchronized (results) - { - results.put(command, future); - } - invoke(m); - return future; - } - } - - private class ResultFuture implements Future - { - - private final Class klass; - private T result; - - private ResultFuture(Class klass) - { - this.klass = klass; - } - - private void set(Struct result) - { - synchronized (this) - { - this.result = klass.cast(result); - notifyAll(); - } - } - - public T get(long timeout) - { - synchronized (this) - { - Waiter w = new Waiter(this, timeout); - while (w.hasTime() && state != CLOSED && !isDone()) - { - checkFailoverRequired("Operation was interrupted by failover."); - log.debug("%s waiting for result: %s", Session.this, this); - w.await(); - } - } - - if (isDone()) - { - return result; - } - else if (state == CLOSED) - { - ExecutionException ex = getException(); - if(ex == null) - { - throw new SessionClosedException(); - } - throw new SessionException(ex); - } - else - { - throw new SessionException( - String.format("%s timed out waiting for result: %s", - Session.this, this)); - } - } - - public T get() - { - return get(timeout); - } - - public boolean isDone() - { - return result != null; - } - - public String toString() - { - return String.format("Future(%s)", isDone() ? result : klass); - } - - } - - public final void messageTransfer(String destination, - MessageAcceptMode acceptMode, - MessageAcquireMode acquireMode, - Header header, - byte[] body, - Option ... _options) { - messageTransfer(destination, acceptMode, acquireMode, header, - ByteBuffer.wrap(body), _options); - } - - public final void messageTransfer(String destination, - MessageAcceptMode acceptMode, - MessageAcquireMode acquireMode, - Header header, - String body, - Option ... _options) { - messageTransfer(destination, acceptMode, acquireMode, header, - toUTF8(body), _options); - } - - public void close() - { - if (log.isDebugEnabled()) - { - log.debug("Closing [%s] in state [%s]", this, state); - } - synchronized (commandsLock) - { - switch(state) - { - case DETACHED: - state = CLOSED; - delegate.closed(this); - connection.removeSession(this); - listener.closed(this); - break; - case CLOSED: - break; - default: - state = CLOSING; - setClose(true); - sessionRequestTimeout(0); - sessionDetach(name.getBytes()); - awaitClose(); - } - } - } - - protected void awaitClose() - { - Waiter w = new Waiter(commandsLock, timeout); - while (w.hasTime() && state != CLOSED) - { - checkFailoverRequired("close() was interrupted by failover."); - w.await(); - } - - if (state != CLOSED) - { - throw new SessionException("close() timed out"); - } - } - - public void exception(Throwable t) - { - log.error(t, "caught exception"); - } - - public void closed() - { - synchronized (commandsLock) - { - if (closing || getException() != null) - { - state = CLOSED; - } - else - { - state = DETACHED; - } - - commandsLock.notifyAll(); - - synchronized (results) - { - for (ResultFuture result : results.values()) - { - synchronized(result) - { - result.notifyAll(); - } - } - } - if(state == CLOSED) - { - delegate.closed(this); - } - else - { - delegate.detached(this); - } - } - - if(state == CLOSED) - { - connection.removeSession(this); - listener.closed(this); - } - } - - public boolean isClosing() - { - return state == CLOSED || state == CLOSING; - } - - public String toString() - { - return String.format("ssn:%s", name); - } - - public void setTransacted(boolean b) { - this.transacted = b; - } - - public boolean isTransacted(){ - return transacted; - } - - public void setDetachCode(SessionDetachCode dtc) - { - this.detachCode = dtc; - } - - public SessionDetachCode getDetachCode() - { - return this.detachCode; - } - - public void awaitOpen() - { - switch (state) - { - case NEW: - synchronized(stateLock) - { - Waiter w = new Waiter(stateLock, timeout); - while (w.hasTime() && state == NEW) - { - checkFailoverRequired("Session opening was interrupted by failover."); - w.await(); - } - } - - if (state != OPEN) - { - throw new SessionException("Timed out waiting for Session to open"); - } - break; - case DETACHED: - case CLOSING: - case CLOSED: - throw new SessionException("Session closed"); - default : - break; - } - } - - public Object getStateLock() - { - return stateLock; - } - - protected void notifyFailoverRequired() - { - //ensure any operations waiting are aborted to - //prevent them waiting for timeout for 60 seconds - //and possibly preventing failover proceeding - _failoverRequired.set(true); - synchronized (commandsLock) - { - commandsLock.notifyAll(); - } - synchronized (results) - { - for (ResultFuture result : results.values()) - { - synchronized(result) - { - result.notifyAll(); - } - } - } - } - - /** - * An auxiliary method for test purposes only - * @return true if flow is blocked - */ - public boolean isFlowBlocked() - { - return flowControl && credit.availablePermits() == 0; - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionAttach.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionAttach.java deleted file mode 100644 index cc056c2157..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionAttach.java +++ /dev/null @@ -1,193 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class SessionAttach extends Method { - - public static final int TYPE = 513; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L2; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private byte[] name; - - - public SessionAttach() {} - - - public SessionAttach(byte[] name, Option ... _options) { - if(name != null) { - setName(name); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case FORCE: packing_flags |= 512; break; - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.sessionAttach(context, this); - } - - - public final boolean hasName() { - return (packing_flags & 256) != 0; - } - - public final SessionAttach clearName() { - packing_flags &= ~256; - this.name = null; - setDirty(true); - return this; - } - - public final byte[] getName() { - return name; - } - - public final SessionAttach setName(byte[] value) { - this.name = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final SessionAttach name(byte[] value) { - return setName(value); - } - - public final boolean hasForce() { - return (packing_flags & 512) != 0; - } - - public final SessionAttach clearForce() { - packing_flags &= ~512; - - setDirty(true); - return this; - } - - public final boolean getForce() { - return hasForce(); - } - - public final SessionAttach setForce(boolean value) { - - if (value) - { - packing_flags |= 512; - } - else - { - packing_flags &= ~512; - } - - setDirty(true); - return this; - } - - public final SessionAttach force(boolean value) { - return setForce(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeVbin16(this.name); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.name = dec.readVbin16(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("name", getName()); - } - if ((packing_flags & 512) != 0) - { - result.put("force", getForce()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionAttached.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionAttached.java deleted file mode 100644 index edba391120..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionAttached.java +++ /dev/null @@ -1,154 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class SessionAttached extends Method { - - public static final int TYPE = 514; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L2; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private byte[] name; - - - public SessionAttached() {} - - - public SessionAttached(byte[] name, Option ... _options) { - if(name != null) { - setName(name); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.sessionAttached(context, this); - } - - - public final boolean hasName() { - return (packing_flags & 256) != 0; - } - - public final SessionAttached clearName() { - packing_flags &= ~256; - this.name = null; - setDirty(true); - return this; - } - - public final byte[] getName() { - return name; - } - - public final SessionAttached setName(byte[] value) { - this.name = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final SessionAttached name(byte[] value) { - return setName(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeVbin16(this.name); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.name = dec.readVbin16(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("name", getName()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionClosedException.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionClosedException.java deleted file mode 100644 index 01fe05c851..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionClosedException.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - -/** - * SessionClosedException - * - */ - -public class SessionClosedException extends SessionException -{ - - public SessionClosedException() - { - this(null); - } - - public SessionClosedException(Throwable cause) - { - super("session closed", null, cause); - } - - @Override public void rethrow() - { - throw new SessionClosedException(this); - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionCommandFragment.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionCommandFragment.java deleted file mode 100644 index 6ae2d45238..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionCommandFragment.java +++ /dev/null @@ -1,138 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - - - -public final class SessionCommandFragment extends Struct { - - public static final int TYPE = -2; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 0; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return -1; - } - - public final boolean isConnectionControl() - { - return false; - } - - private int commandId; - private RangeSet byteRanges; - - - public SessionCommandFragment() {} - - - public SessionCommandFragment(int commandId, RangeSet byteRanges) { - setCommandId(commandId); - if(byteRanges != null) { - setByteRanges(byteRanges); - } - - } - - - - - public final int getCommandId() { - return commandId; - } - - public final SessionCommandFragment setCommandId(int value) { - this.commandId = value; - - setDirty(true); - return this; - } - - public final SessionCommandFragment commandId(int value) { - return setCommandId(value); - } - - public final RangeSet getByteRanges() { - return byteRanges; - } - - public final SessionCommandFragment setByteRanges(RangeSet value) { - this.byteRanges = value; - - setDirty(true); - return this; - } - - public final SessionCommandFragment byteRanges(RangeSet value) { - return setByteRanges(value); - } - - - - - public void write(Encoder enc) - { - enc.writeSequenceNo(this.commandId); - enc.writeByteRanges(this.byteRanges); - - } - - public void read(Decoder dec) - { - this.commandId = dec.readSequenceNo(); - this.byteRanges = dec.readByteRanges(); - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - result.put("commandId", getCommandId()); - result.put("byteRanges", getByteRanges()); - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionCommandPoint.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionCommandPoint.java deleted file mode 100644 index b0bb0559fe..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionCommandPoint.java +++ /dev/null @@ -1,192 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class SessionCommandPoint extends Method { - - public static final int TYPE = 519; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L3; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private int commandId; - private long commandOffset; - - - public SessionCommandPoint() {} - - - public SessionCommandPoint(int commandId, long commandOffset, Option ... _options) { - setCommandId(commandId); - setCommandOffset(commandOffset); - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.sessionCommandPoint(context, this); - } - - - public final boolean hasCommandId() { - return (packing_flags & 256) != 0; - } - - public final SessionCommandPoint clearCommandId() { - packing_flags &= ~256; - this.commandId = 0; - setDirty(true); - return this; - } - - public final int getCommandId() { - return commandId; - } - - public final SessionCommandPoint setCommandId(int value) { - this.commandId = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final SessionCommandPoint commandId(int value) { - return setCommandId(value); - } - - public final boolean hasCommandOffset() { - return (packing_flags & 512) != 0; - } - - public final SessionCommandPoint clearCommandOffset() { - packing_flags &= ~512; - this.commandOffset = 0; - setDirty(true); - return this; - } - - public final long getCommandOffset() { - return commandOffset; - } - - public final SessionCommandPoint setCommandOffset(long value) { - this.commandOffset = value; - packing_flags |= 512; - setDirty(true); - return this; - } - - public final SessionCommandPoint commandOffset(long value) { - return setCommandOffset(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeSequenceNo(this.commandId); - } - if ((packing_flags & 512) != 0) - { - enc.writeUint64(this.commandOffset); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.commandId = dec.readSequenceNo(); - } - if ((packing_flags & 512) != 0) - { - this.commandOffset = dec.readUint64(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("commandId", getCommandId()); - } - if ((packing_flags & 512) != 0) - { - result.put("commandOffset", getCommandOffset()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionCompleted.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionCompleted.java deleted file mode 100644 index 2b30f376b2..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionCompleted.java +++ /dev/null @@ -1,193 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class SessionCompleted extends Method { - - public static final int TYPE = 522; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L3; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private RangeSet commands; - - - public SessionCompleted() {} - - - public SessionCompleted(RangeSet commands, Option ... _options) { - if(commands != null) { - setCommands(commands); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case TIMELY_REPLY: packing_flags |= 512; break; - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.sessionCompleted(context, this); - } - - - public final boolean hasCommands() { - return (packing_flags & 256) != 0; - } - - public final SessionCompleted clearCommands() { - packing_flags &= ~256; - this.commands = null; - setDirty(true); - return this; - } - - public final RangeSet getCommands() { - return commands; - } - - public final SessionCompleted setCommands(RangeSet value) { - this.commands = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final SessionCompleted commands(RangeSet value) { - return setCommands(value); - } - - public final boolean hasTimelyReply() { - return (packing_flags & 512) != 0; - } - - public final SessionCompleted clearTimelyReply() { - packing_flags &= ~512; - - setDirty(true); - return this; - } - - public final boolean getTimelyReply() { - return hasTimelyReply(); - } - - public final SessionCompleted setTimelyReply(boolean value) { - - if (value) - { - packing_flags |= 512; - } - else - { - packing_flags &= ~512; - } - - setDirty(true); - return this; - } - - public final SessionCompleted timelyReply(boolean value) { - return setTimelyReply(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeSequenceSet(this.commands); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.commands = dec.readSequenceSet(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("commands", getCommands()); - } - if ((packing_flags & 512) != 0) - { - result.put("timelyReply", getTimelyReply()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionConfirmed.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionConfirmed.java deleted file mode 100644 index d162fb8e10..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionConfirmed.java +++ /dev/null @@ -1,196 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class SessionConfirmed extends Method { - - public static final int TYPE = 521; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L3; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private RangeSet commands; - private java.util.List fragments; - - - public SessionConfirmed() {} - - - public SessionConfirmed(RangeSet commands, java.util.List fragments, Option ... _options) { - if(commands != null) { - setCommands(commands); - } - if(fragments != null) { - setFragments(fragments); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.sessionConfirmed(context, this); - } - - - public final boolean hasCommands() { - return (packing_flags & 256) != 0; - } - - public final SessionConfirmed clearCommands() { - packing_flags &= ~256; - this.commands = null; - setDirty(true); - return this; - } - - public final RangeSet getCommands() { - return commands; - } - - public final SessionConfirmed setCommands(RangeSet value) { - this.commands = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final SessionConfirmed commands(RangeSet value) { - return setCommands(value); - } - - public final boolean hasFragments() { - return (packing_flags & 512) != 0; - } - - public final SessionConfirmed clearFragments() { - packing_flags &= ~512; - this.fragments = null; - setDirty(true); - return this; - } - - public final java.util.List getFragments() { - return fragments; - } - - public final SessionConfirmed setFragments(java.util.List value) { - this.fragments = value; - packing_flags |= 512; - setDirty(true); - return this; - } - - public final SessionConfirmed fragments(java.util.List value) { - return setFragments(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeSequenceSet(this.commands); - } - if ((packing_flags & 512) != 0) - { - enc.writeArray(this.fragments); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.commands = dec.readSequenceSet(); - } - if ((packing_flags & 512) != 0) - { - this.fragments = dec.readArray(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("commands", getCommands()); - } - if ((packing_flags & 512) != 0) - { - result.put("fragments", getFragments()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionDelegate.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionDelegate.java deleted file mode 100644 index cabff1cd13..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionDelegate.java +++ /dev/null @@ -1,246 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - -import org.apache.qpid.transport.util.Logger; - - -/** - * SessionDelegate - * - * @author Rafael H. Schloming - */ - -public class SessionDelegate - extends MethodDelegate - implements ProtocolDelegate -{ - protected static final Logger log = Logger.get(SessionDelegate.class); - - public void init(Session ssn, ProtocolHeader hdr) - { - log.warn("INIT: [%s] %s", ssn, hdr); - } - - public void control(Session ssn, Method method) - { - method.dispatch(ssn, this); - } - - public void command(Session ssn, Method method) - { - command(ssn, method, !method.hasPayload()); - } - public void command(Session ssn, Method method, boolean processed) - { - ssn.identify(method); - method.dispatch(ssn, this); - if (processed) - { - ssn.processed(method); - } - } - - public void error(Session ssn, ProtocolError error) - { - log.warn("ERROR: [%s] %s", ssn, error); - } - - public void handle(Session ssn, Method method) - { - log.warn("UNHANDLED: [%s] %s", ssn, method); - } - - @Override public void sessionRequestTimeout(Session ssn, SessionRequestTimeout t) - { - if (t.getTimeout() == 0) - { - ssn.setClose(true); - } - ssn.sessionTimeout(0); // Always report back an expiry of 0 until it is implemented - } - - @Override public void sessionAttached(Session ssn, SessionAttached atc) - { - ssn.setState(Session.State.OPEN); - synchronized (ssn.getStateLock()) - { - ssn.getStateLock().notifyAll(); - } - } - - @Override public void sessionTimeout(Session ssn, SessionTimeout t) - { - // Setting of expiry is not implemented - } - - @Override public void sessionCompleted(Session ssn, SessionCompleted cmp) - { - RangeSet ranges = cmp.getCommands(); - RangeSet known = null; - - if (ranges != null) - { - if(ranges.size() == 1) - { - Range range = ranges.getFirst(); - boolean advanced = ssn.complete(range.getLower(), range.getUpper()); - - if(advanced && cmp.getTimelyReply()) - { - known = range; - } - } - else - { - if (cmp.getTimelyReply()) - { - known = RangeSetFactory.createRangeSet(); - } - for (Range range : ranges) - { - boolean advanced = ssn.complete(range.getLower(), range.getUpper()); - if (advanced && known != null) - { - known.add(range); - } - } - } - } - else if (cmp.getTimelyReply()) - { - known = RangeSetFactory.createRangeSet(); - } - - if (known != null) - { - ssn.sessionKnownCompleted(known); - } - } - - @Override public void sessionKnownCompleted(Session ssn, SessionKnownCompleted kcmp) - { - RangeSet kc = kcmp.getCommands(); - if (kc != null) - { - ssn.knownComplete(kc); - } - } - - @Override public void sessionFlush(Session ssn, SessionFlush flush) - { - if (flush.getCompleted()) - { - ssn.flushProcessed(); - } - if (flush.getConfirmed()) - { - ssn.flushProcessed(); - } - if (flush.getExpected()) - { - ssn.flushExpected(); - } - } - - @Override public void sessionCommandPoint(Session ssn, SessionCommandPoint scp) - { - ssn.commandPoint(scp.getCommandId()); - } - - @Override public void executionSync(Session ssn, ExecutionSync sync) - { - ssn.syncPoint(); - } - - @Override public void executionResult(Session ssn, ExecutionResult result) - { - ssn.result(result.getCommandId(), result.getValue()); - } - - @Override public void executionException(Session ssn, ExecutionException exc) - { - ssn.setException(exc); - ssn.getSessionListener().exception(ssn, new SessionException(exc)); - ssn.closed(); - } - - @Override public void messageTransfer(Session ssn, MessageTransfer xfr) - { - ssn.getSessionListener().message(ssn, xfr); - } - - @Override public void messageSetFlowMode(Session ssn, MessageSetFlowMode sfm) - { - if ("".equals(sfm.getDestination()) && - MessageFlowMode.CREDIT.equals(sfm.getFlowMode())) - { - ssn.setFlowControl(true); - } - else - { - super.messageSetFlowMode(ssn, sfm); - } - } - - @Override public void messageFlow(Session ssn, MessageFlow flow) - { - if ("".equals(flow.getDestination()) && - MessageCreditUnit.MESSAGE.equals(flow.getUnit())) - { - ssn.addCredit((int) flow.getValue()); - } - else - { - super.messageFlow(ssn, flow); - } - } - - @Override public void messageStop(Session ssn, MessageStop stop) - { - if ("".equals(stop.getDestination())) - { - ssn.drainCredit(); - } - else - { - super.messageStop(ssn, stop); - } - } - - public void closed(Session session) - { - log.debug("CLOSED: [%s]", session); - synchronized (session.getStateLock()) - { - session.getStateLock().notifyAll(); - } - } - - public void detached(Session session) - { - log.debug("DETACHED: [%s]", session); - synchronized (session.getStateLock()) - { - session.getStateLock().notifyAll(); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionDetach.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionDetach.java deleted file mode 100644 index c6f8e9bad4..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionDetach.java +++ /dev/null @@ -1,154 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class SessionDetach extends Method { - - public static final int TYPE = 515; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L2; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private byte[] name; - - - public SessionDetach() {} - - - public SessionDetach(byte[] name, Option ... _options) { - if(name != null) { - setName(name); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.sessionDetach(context, this); - } - - - public final boolean hasName() { - return (packing_flags & 256) != 0; - } - - public final SessionDetach clearName() { - packing_flags &= ~256; - this.name = null; - setDirty(true); - return this; - } - - public final byte[] getName() { - return name; - } - - public final SessionDetach setName(byte[] value) { - this.name = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final SessionDetach name(byte[] value) { - return setName(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeVbin16(this.name); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.name = dec.readVbin16(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("name", getName()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionDetachCode.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionDetachCode.java deleted file mode 100644 index 892f0edc36..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionDetachCode.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -public enum SessionDetachCode { - - NORMAL((short) 0), - SESSION_BUSY((short) 1), - TRANSPORT_BUSY((short) 2), - NOT_ATTACHED((short) 3), - UNKNOWN_IDS((short) 4); - - private final short value; - - SessionDetachCode(short value) - { - this.value = value; - } - - public short getValue() - { - return value; - } - - public static SessionDetachCode get(short value) - { - switch (value) - { - case (short) 0: return NORMAL; - case (short) 1: return SESSION_BUSY; - case (short) 2: return TRANSPORT_BUSY; - case (short) 3: return NOT_ATTACHED; - case (short) 4: return UNKNOWN_IDS; - default: throw new IllegalArgumentException("no such value: " + value); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionDetached.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionDetached.java deleted file mode 100644 index d577d7c28a..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionDetached.java +++ /dev/null @@ -1,196 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class SessionDetached extends Method { - - public static final int TYPE = 516; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L2; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private byte[] name; - private SessionDetachCode code; - - - public SessionDetached() {} - - - public SessionDetached(byte[] name, SessionDetachCode code, Option ... _options) { - if(name != null) { - setName(name); - } - if(code != null) { - setCode(code); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.sessionDetached(context, this); - } - - - public final boolean hasName() { - return (packing_flags & 256) != 0; - } - - public final SessionDetached clearName() { - packing_flags &= ~256; - this.name = null; - setDirty(true); - return this; - } - - public final byte[] getName() { - return name; - } - - public final SessionDetached setName(byte[] value) { - this.name = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final SessionDetached name(byte[] value) { - return setName(value); - } - - public final boolean hasCode() { - return (packing_flags & 512) != 0; - } - - public final SessionDetached clearCode() { - packing_flags &= ~512; - this.code = null; - setDirty(true); - return this; - } - - public final SessionDetachCode getCode() { - return code; - } - - public final SessionDetached setCode(SessionDetachCode value) { - this.code = value; - packing_flags |= 512; - setDirty(true); - return this; - } - - public final SessionDetached code(SessionDetachCode value) { - return setCode(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeVbin16(this.name); - } - if ((packing_flags & 512) != 0) - { - enc.writeUint8(this.code.getValue()); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.name = dec.readVbin16(); - } - if ((packing_flags & 512) != 0) - { - this.code = SessionDetachCode.get(dec.readUint8()); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("name", getName()); - } - if ((packing_flags & 512) != 0) - { - result.put("code", getCode()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionException.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionException.java deleted file mode 100644 index 6095b892f8..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionException.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - -/** - * SessionException - * - */ - -public class SessionException extends TransportException -{ - - private ExecutionException exception; - - public SessionException(String message, ExecutionException exception, Throwable cause) - { - super(message, cause); - this.exception = exception; - } - - public SessionException(ExecutionException exception) - { - this(String.valueOf(exception), exception, null); - } - - public SessionException(String message) - { - this(message, null, null); - } - - public ExecutionException getException() - { - return exception; - } - - @Override public void rethrow() - { - throw new SessionException(getMessage(), exception, this); - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionExpected.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionExpected.java deleted file mode 100644 index 324316f88c..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionExpected.java +++ /dev/null @@ -1,196 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class SessionExpected extends Method { - - public static final int TYPE = 520; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L3; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private RangeSet commands; - private java.util.List fragments; - - - public SessionExpected() {} - - - public SessionExpected(RangeSet commands, java.util.List fragments, Option ... _options) { - if(commands != null) { - setCommands(commands); - } - if(fragments != null) { - setFragments(fragments); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.sessionExpected(context, this); - } - - - public final boolean hasCommands() { - return (packing_flags & 256) != 0; - } - - public final SessionExpected clearCommands() { - packing_flags &= ~256; - this.commands = null; - setDirty(true); - return this; - } - - public final RangeSet getCommands() { - return commands; - } - - public final SessionExpected setCommands(RangeSet value) { - this.commands = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final SessionExpected commands(RangeSet value) { - return setCommands(value); - } - - public final boolean hasFragments() { - return (packing_flags & 512) != 0; - } - - public final SessionExpected clearFragments() { - packing_flags &= ~512; - this.fragments = null; - setDirty(true); - return this; - } - - public final java.util.List getFragments() { - return fragments; - } - - public final SessionExpected setFragments(java.util.List value) { - this.fragments = value; - packing_flags |= 512; - setDirty(true); - return this; - } - - public final SessionExpected fragments(java.util.List value) { - return setFragments(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeSequenceSet(this.commands); - } - if ((packing_flags & 512) != 0) - { - enc.writeArray(this.fragments); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.commands = dec.readSequenceSet(); - } - if ((packing_flags & 512) != 0) - { - this.fragments = dec.readArray(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("commands", getCommands()); - } - if ((packing_flags & 512) != 0) - { - result.put("fragments", getFragments()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionFlush.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionFlush.java deleted file mode 100644 index 193fe9b255..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionFlush.java +++ /dev/null @@ -1,229 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class SessionFlush extends Method { - - public static final int TYPE = 524; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L3; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - - - public SessionFlush() {} - - - public SessionFlush(Option ... _options) { - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case EXPECTED: packing_flags |= 256; break; - case CONFIRMED: packing_flags |= 512; break; - case COMPLETED: packing_flags |= 1024; break; - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.sessionFlush(context, this); - } - - - public final boolean hasExpected() { - return (packing_flags & 256) != 0; - } - - public final SessionFlush clearExpected() { - packing_flags &= ~256; - - setDirty(true); - return this; - } - - public final boolean getExpected() { - return hasExpected(); - } - - public final SessionFlush setExpected(boolean value) { - - if (value) - { - packing_flags |= 256; - } - else - { - packing_flags &= ~256; - } - - setDirty(true); - return this; - } - - public final SessionFlush expected(boolean value) { - return setExpected(value); - } - - public final boolean hasConfirmed() { - return (packing_flags & 512) != 0; - } - - public final SessionFlush clearConfirmed() { - packing_flags &= ~512; - - setDirty(true); - return this; - } - - public final boolean getConfirmed() { - return hasConfirmed(); - } - - public final SessionFlush setConfirmed(boolean value) { - - if (value) - { - packing_flags |= 512; - } - else - { - packing_flags &= ~512; - } - - setDirty(true); - return this; - } - - public final SessionFlush confirmed(boolean value) { - return setConfirmed(value); - } - - public final boolean hasCompleted() { - return (packing_flags & 1024) != 0; - } - - public final SessionFlush clearCompleted() { - packing_flags &= ~1024; - - setDirty(true); - return this; - } - - public final boolean getCompleted() { - return hasCompleted(); - } - - public final SessionFlush setCompleted(boolean value) { - - if (value) - { - packing_flags |= 1024; - } - else - { - packing_flags &= ~1024; - } - - setDirty(true); - return this; - } - - public final SessionFlush completed(boolean value) { - return setCompleted(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("expected", getExpected()); - } - if ((packing_flags & 512) != 0) - { - result.put("confirmed", getConfirmed()); - } - if ((packing_flags & 1024) != 0) - { - result.put("completed", getCompleted()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionGap.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionGap.java deleted file mode 100644 index 62cf753df6..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionGap.java +++ /dev/null @@ -1,154 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class SessionGap extends Method { - - public static final int TYPE = 525; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L3; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private RangeSet commands; - - - public SessionGap() {} - - - public SessionGap(RangeSet commands, Option ... _options) { - if(commands != null) { - setCommands(commands); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.sessionGap(context, this); - } - - - public final boolean hasCommands() { - return (packing_flags & 256) != 0; - } - - public final SessionGap clearCommands() { - packing_flags &= ~256; - this.commands = null; - setDirty(true); - return this; - } - - public final RangeSet getCommands() { - return commands; - } - - public final SessionGap setCommands(RangeSet value) { - this.commands = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final SessionGap commands(RangeSet value) { - return setCommands(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeSequenceSet(this.commands); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.commands = dec.readSequenceSet(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("commands", getCommands()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionHeader.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionHeader.java deleted file mode 100644 index 9287d594b1..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionHeader.java +++ /dev/null @@ -1,145 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - - - -public final class SessionHeader extends Struct { - - public static final int TYPE = -1; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 1; - } - - public final int getPackWidth() { - return 1; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return -1; - } - - public final boolean isConnectionControl() - { - return false; - } - - private byte packing_flags = 0; - - - public SessionHeader() {} - - - public SessionHeader(Option ... _options) { - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: packing_flags |= 1; break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - - - - public final boolean hasSync() { - return (packing_flags & 1) != 0; - } - - public final SessionHeader clearSync() { - packing_flags &= ~1; - - setDirty(true); - return this; - } - - public final boolean getSync() { - return hasSync(); - } - - public final SessionHeader setSync(boolean value) { - - if (value) - { - packing_flags |= 1; - } - else - { - packing_flags &= ~1; - } - - setDirty(true); - return this; - } - - public final SessionHeader sync(boolean value) { - return setSync(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint8(packing_flags); - - } - - public void read(Decoder dec) - { - packing_flags = (byte) dec.readUint8(); - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 1) != 0) - { - result.put("sync", getSync()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionInvoker.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionInvoker.java deleted file mode 100644 index 2d5c54d96c..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionInvoker.java +++ /dev/null @@ -1,236 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.Map; - -public abstract class SessionInvoker { - - final void sessionAttach(byte[] name, Option ... _options) { - invoke(new SessionAttach(name, _options)); - } - - final void sessionAttached(byte[] name, Option ... _options) { - invoke(new SessionAttached(name, _options)); - } - - final void sessionDetach(byte[] name, Option ... _options) { - invoke(new SessionDetach(name, _options)); - } - - final void sessionDetached(byte[] name, SessionDetachCode code, Option ... _options) { - invoke(new SessionDetached(name, code, _options)); - } - - final void sessionRequestTimeout(long timeout, Option ... _options) { - invoke(new SessionRequestTimeout(timeout, _options)); - } - - final void sessionTimeout(long timeout, Option ... _options) { - invoke(new SessionTimeout(timeout, _options)); - } - - final void sessionCommandPoint(int commandId, long commandOffset, Option ... _options) { - invoke(new SessionCommandPoint(commandId, commandOffset, _options)); - } - - final void sessionExpected(RangeSet commands, java.util.List fragments, Option ... _options) { - invoke(new SessionExpected(commands, fragments, _options)); - } - - final void sessionConfirmed(RangeSet commands, java.util.List fragments, Option ... _options) { - invoke(new SessionConfirmed(commands, fragments, _options)); - } - - final void sessionCompleted(RangeSet commands, Option ... _options) { - invoke(new SessionCompleted(commands, _options)); - } - - final void sessionKnownCompleted(RangeSet commands, Option ... _options) { - invoke(new SessionKnownCompleted(commands, _options)); - } - - final void sessionFlush(Option ... _options) { - invoke(new SessionFlush(_options)); - } - - final void sessionGap(RangeSet commands, Option ... _options) { - invoke(new SessionGap(commands, _options)); - } - - public final void executionSync(Option ... _options) { - invoke(new ExecutionSync(_options)); - } - - public final void executionResult(int commandId, Struct value, Option ... _options) { - invoke(new ExecutionResult(commandId, value, _options)); - } - - public final void executionException(ExecutionErrorCode errorCode, int commandId, short classCode, short commandCode, short fieldIndex, String description, Map errorInfo, Option ... _options) { - invoke(new ExecutionException(errorCode, commandId, classCode, commandCode, fieldIndex, description, errorInfo, _options)); - } - - public final void messageTransfer(String destination, MessageAcceptMode acceptMode, MessageAcquireMode acquireMode, Header header, java.nio.ByteBuffer body, Option ... _options) { - invoke(new MessageTransfer(destination, acceptMode, acquireMode, header, body, _options)); - } - - public final void messageAccept(RangeSet transfers, Option ... _options) { - invoke(new MessageAccept(transfers, _options)); - } - - public final void messageReject(RangeSet transfers, MessageRejectCode code, String text, Option ... _options) { - invoke(new MessageReject(transfers, code, text, _options)); - } - - public final void messageRelease(RangeSet transfers, Option ... _options) { - invoke(new MessageRelease(transfers, _options)); - } - - public final Future messageAcquire(RangeSet transfers, Option ... _options) { - return invoke(new MessageAcquire(transfers, _options), Acquired.class); - } - - public final Future messageResume(String destination, String resumeId, Option ... _options) { - return invoke(new MessageResume(destination, resumeId, _options), MessageResumeResult.class); - } - - public final void messageSubscribe(String queue, String destination, MessageAcceptMode acceptMode, MessageAcquireMode acquireMode, String resumeId, long resumeTtl, Map arguments, Option ... _options) { - invoke(new MessageSubscribe(queue, destination, acceptMode, acquireMode, resumeId, resumeTtl, arguments, _options)); - } - - public final void messageCancel(String destination, Option ... _options) { - invoke(new MessageCancel(destination, _options)); - } - - public final void messageSetFlowMode(String destination, MessageFlowMode flowMode, Option ... _options) { - invoke(new MessageSetFlowMode(destination, flowMode, _options)); - } - - public final void messageFlow(String destination, MessageCreditUnit unit, long value, Option ... _options) { - invoke(new MessageFlow(destination, unit, value, _options)); - } - - public final void messageFlush(String destination, Option ... _options) { - invoke(new MessageFlush(destination, _options)); - } - - public final void messageStop(String destination, Option ... _options) { - invoke(new MessageStop(destination, _options)); - } - - public final void txSelect(Option ... _options) { - invoke(new TxSelect(_options)); - } - - public final void txCommit(Option ... _options) { - invoke(new TxCommit(_options)); - } - - public final void txRollback(Option ... _options) { - invoke(new TxRollback(_options)); - } - - public final void dtxSelect(Option ... _options) { - invoke(new DtxSelect(_options)); - } - - public final Future dtxStart(Xid xid, Option ... _options) { - return invoke(new DtxStart(xid, _options), XaResult.class); - } - - public final Future dtxEnd(Xid xid, Option ... _options) { - return invoke(new DtxEnd(xid, _options), XaResult.class); - } - - public final Future dtxCommit(Xid xid, Option ... _options) { - return invoke(new DtxCommit(xid, _options), XaResult.class); - } - - public final void dtxForget(Xid xid, Option ... _options) { - invoke(new DtxForget(xid, _options)); - } - - public final Future dtxGetTimeout(Xid xid, Option ... _options) { - return invoke(new DtxGetTimeout(xid, _options), GetTimeoutResult.class); - } - - public final Future dtxPrepare(Xid xid, Option ... _options) { - return invoke(new DtxPrepare(xid, _options), XaResult.class); - } - - public final Future dtxRecover(Option ... _options) { - return invoke(new DtxRecover(_options), RecoverResult.class); - } - - public final Future dtxRollback(Xid xid, Option ... _options) { - return invoke(new DtxRollback(xid, _options), XaResult.class); - } - - public final void dtxSetTimeout(Xid xid, long timeout, Option ... _options) { - invoke(new DtxSetTimeout(xid, timeout, _options)); - } - - public final void exchangeDeclare(String exchange, String type, String alternateExchange, Map arguments, Option ... _options) { - invoke(new ExchangeDeclare(exchange, type, alternateExchange, arguments, _options)); - } - - public final void exchangeDelete(String exchange, Option ... _options) { - invoke(new ExchangeDelete(exchange, _options)); - } - - public final Future exchangeQuery(String name, Option ... _options) { - return invoke(new ExchangeQuery(name, _options), ExchangeQueryResult.class); - } - - public final void exchangeBind(String queue, String exchange, String bindingKey, Map arguments, Option ... _options) { - invoke(new ExchangeBind(queue, exchange, bindingKey, arguments, _options)); - } - - public final void exchangeUnbind(String queue, String exchange, String bindingKey, Option ... _options) { - invoke(new ExchangeUnbind(queue, exchange, bindingKey, _options)); - } - - public final Future exchangeBound(String exchange, String queue, String bindingKey, Map arguments, Option ... _options) { - return invoke(new ExchangeBound(exchange, queue, bindingKey, arguments, _options), ExchangeBoundResult.class); - } - - public final void queueDeclare(String queue, String alternateExchange, Map arguments, Option ... _options) { - invoke(new QueueDeclare(queue, alternateExchange, arguments, _options)); - } - - public final void queueDelete(String queue, Option ... _options) { - invoke(new QueueDelete(queue, _options)); - } - - public final void queuePurge(String queue, Option ... _options) { - invoke(new QueuePurge(queue, _options)); - } - - public final Future queueQuery(String queue, Option ... _options) { - return invoke(new QueueQuery(queue, _options), QueueQueryResult.class); - } - - protected abstract void invoke(Method method); - - protected abstract Future invoke(Method method, Class resultClass); - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionKnownCompleted.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionKnownCompleted.java deleted file mode 100644 index 4f78724ee0..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionKnownCompleted.java +++ /dev/null @@ -1,154 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class SessionKnownCompleted extends Method { - - public static final int TYPE = 523; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L3; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private RangeSet commands; - - - public SessionKnownCompleted() {} - - - public SessionKnownCompleted(RangeSet commands, Option ... _options) { - if(commands != null) { - setCommands(commands); - } - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.sessionKnownCompleted(context, this); - } - - - public final boolean hasCommands() { - return (packing_flags & 256) != 0; - } - - public final SessionKnownCompleted clearCommands() { - packing_flags &= ~256; - this.commands = null; - setDirty(true); - return this; - } - - public final RangeSet getCommands() { - return commands; - } - - public final SessionKnownCompleted setCommands(RangeSet value) { - this.commands = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final SessionKnownCompleted commands(RangeSet value) { - return setCommands(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeSequenceSet(this.commands); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.commands = dec.readSequenceSet(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("commands", getCommands()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionListener.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionListener.java deleted file mode 100644 index eb650eb9ed..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionListener.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - - -/** - * SessionListener - * - */ - -public interface SessionListener -{ - - void opened(Session session); - - void resumed(Session session); - - void message(Session ssn, MessageTransfer xfr); - - void exception(Session session, SessionException exception); - - void closed(Session session); - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionRequestTimeout.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionRequestTimeout.java deleted file mode 100644 index 7608c8e75e..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionRequestTimeout.java +++ /dev/null @@ -1,152 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class SessionRequestTimeout extends Method { - - public static final int TYPE = 517; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L3; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private long timeout; - - - public SessionRequestTimeout() {} - - - public SessionRequestTimeout(long timeout, Option ... _options) { - setTimeout(timeout); - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.sessionRequestTimeout(context, this); - } - - - public final boolean hasTimeout() { - return (packing_flags & 256) != 0; - } - - public final SessionRequestTimeout clearTimeout() { - packing_flags &= ~256; - this.timeout = 0; - setDirty(true); - return this; - } - - public final long getTimeout() { - return timeout; - } - - public final SessionRequestTimeout setTimeout(long value) { - this.timeout = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final SessionRequestTimeout timeout(long value) { - return setTimeout(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeUint32(this.timeout); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.timeout = dec.readUint32(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("timeout", getTimeout()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionTimeout.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionTimeout.java deleted file mode 100644 index cc5054ab28..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/SessionTimeout.java +++ /dev/null @@ -1,152 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class SessionTimeout extends Method { - - public static final int TYPE = 518; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L3; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private long timeout; - - - public SessionTimeout() {} - - - public SessionTimeout(long timeout, Option ... _options) { - setTimeout(timeout); - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.sessionTimeout(context, this); - } - - - public final boolean hasTimeout() { - return (packing_flags & 256) != 0; - } - - public final SessionTimeout clearTimeout() { - packing_flags &= ~256; - this.timeout = 0; - setDirty(true); - return this; - } - - public final long getTimeout() { - return timeout; - } - - public final SessionTimeout setTimeout(long value) { - this.timeout = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final SessionTimeout timeout(long value) { - return setTimeout(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeUint32(this.timeout); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.timeout = dec.readUint32(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("timeout", getTimeout()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/StreamReturnCode.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/StreamReturnCode.java deleted file mode 100644 index 7a4e8c083b..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/StreamReturnCode.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -public enum StreamReturnCode { - - CONTENT_TOO_LARGE((int) 311), - NO_ROUTE((int) 312), - NO_CONSUMERS((int) 313); - - private final int value; - - StreamReturnCode(int value) - { - this.value = value; - } - - public int getValue() - { - return value; - } - - public static StreamReturnCode get(int value) - { - switch (value) - { - case (int) 311: return CONTENT_TOO_LARGE; - case (int) 312: return NO_ROUTE; - case (int) 313: return NO_CONSUMERS; - default: throw new IllegalArgumentException("no such value: " + value); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/Struct.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/Struct.java deleted file mode 100644 index 045939e415..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/Struct.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encodable; -import org.apache.qpid.transport.codec.Encoder; -import org.apache.qpid.transport.util.Functions; - -import java.util.Arrays; -import java.util.Map; - - -/** - * Struct - * - * @author Rafael H. Schloming - */ - -public abstract class Struct implements Encodable -{ - - public static Struct create(int type) - { - return StructFactory.create(type); - } - - private boolean dirty = true; - - public boolean isDirty() - { - return dirty; - } - - public void setDirty(boolean dirty) - { - this.dirty = dirty; - } - - public abstract int getStructType(); - - public abstract int getSizeWidth(); - - public abstract int getPackWidth(); - - public final int getEncodedType() - { - int type = getStructType(); - if (type < 0) - { - throw new UnsupportedOperationException(); - } - return type; - } - - private final boolean isBit(Field f) - { - return f.getType().equals(Boolean.class); - } - - private final boolean packed() - { - return getPackWidth() > 0; - } - - private final boolean encoded(Field f) - { - return !packed() || !isBit(f) && f.has(this); - } - - private final int getFlagWidth() - { - return (getFields().size() + 7)/8; - } - - private final int getPaddWidth() - { - int pw = getPackWidth() - getFlagWidth(); - assert pw > 0; - return pw; - } - - private final int getFlagCount() - { - return 8*getPackWidth(); - } - - private final int getReservedFlagCount() - { - return getFlagCount() - getFields().size(); - } - - public abstract void read(Decoder dec); - - public abstract void write(Encoder enc); - - public abstract Map getFields(); - - public String toString() - { - StringBuilder str = new StringBuilder(); - str.append(getClass().getSimpleName()); - - str.append("("); - boolean first = true; - for (Map.Entry me : getFields().entrySet()) - { - if (first) - { - first = false; - } - else - { - str.append(", "); - } - str.append(me.getKey()); - str.append("="); - str.append(formatValue(me.getValue())); - } - str.append(")"); - - return str.toString(); - } - - private Object formatValue(Object value) - { - if(value instanceof byte[]) - { - return Functions.str((byte[])value); - } - else if(value instanceof Object[]) - { - return Arrays.asList((Object[])value); - } - return value; - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/StructFactory.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/StructFactory.java deleted file mode 100644 index 4dcd02da9f..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/StructFactory.java +++ /dev/null @@ -1,200 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -class StructFactory { - - public static Struct create(int type) - { - switch (type) - { - case SessionHeader.TYPE: - return new SessionHeader(); - case SessionCommandFragment.TYPE: - return new SessionCommandFragment(); - case DeliveryProperties.TYPE: - return new DeliveryProperties(); - case FragmentProperties.TYPE: - return new FragmentProperties(); - case ReplyTo.TYPE: - return new ReplyTo(); - case MessageProperties.TYPE: - return new MessageProperties(); - case XaResult.TYPE: - return new XaResult(); - case Xid.TYPE: - return new Xid(); - case Acquired.TYPE: - return new Acquired(); - case MessageResumeResult.TYPE: - return new MessageResumeResult(); - case GetTimeoutResult.TYPE: - return new GetTimeoutResult(); - case RecoverResult.TYPE: - return new RecoverResult(); - case ExchangeQueryResult.TYPE: - return new ExchangeQueryResult(); - case ExchangeBoundResult.TYPE: - return new ExchangeBoundResult(); - case QueueQueryResult.TYPE: - return new QueueQueryResult(); - default: - throw new IllegalArgumentException("type: " + type); - } - } - - public static Struct createInstruction(int type) - { - switch (type) - { - case ConnectionStart.TYPE: - return new ConnectionStart(); - case ConnectionStartOk.TYPE: - return new ConnectionStartOk(); - case ConnectionSecure.TYPE: - return new ConnectionSecure(); - case ConnectionSecureOk.TYPE: - return new ConnectionSecureOk(); - case ConnectionTune.TYPE: - return new ConnectionTune(); - case ConnectionTuneOk.TYPE: - return new ConnectionTuneOk(); - case ConnectionOpen.TYPE: - return new ConnectionOpen(); - case ConnectionOpenOk.TYPE: - return new ConnectionOpenOk(); - case ConnectionRedirect.TYPE: - return new ConnectionRedirect(); - case ConnectionHeartbeat.TYPE: - return new ConnectionHeartbeat(); - case ConnectionClose.TYPE: - return new ConnectionClose(); - case ConnectionCloseOk.TYPE: - return new ConnectionCloseOk(); - case SessionAttach.TYPE: - return new SessionAttach(); - case SessionAttached.TYPE: - return new SessionAttached(); - case SessionDetach.TYPE: - return new SessionDetach(); - case SessionDetached.TYPE: - return new SessionDetached(); - case SessionRequestTimeout.TYPE: - return new SessionRequestTimeout(); - case SessionTimeout.TYPE: - return new SessionTimeout(); - case SessionCommandPoint.TYPE: - return new SessionCommandPoint(); - case SessionExpected.TYPE: - return new SessionExpected(); - case SessionConfirmed.TYPE: - return new SessionConfirmed(); - case SessionCompleted.TYPE: - return new SessionCompleted(); - case SessionKnownCompleted.TYPE: - return new SessionKnownCompleted(); - case SessionFlush.TYPE: - return new SessionFlush(); - case SessionGap.TYPE: - return new SessionGap(); - case ExecutionSync.TYPE: - return new ExecutionSync(); - case ExecutionResult.TYPE: - return new ExecutionResult(); - case ExecutionException.TYPE: - return new ExecutionException(); - case MessageTransfer.TYPE: - return new MessageTransfer(); - case MessageAccept.TYPE: - return new MessageAccept(); - case MessageReject.TYPE: - return new MessageReject(); - case MessageRelease.TYPE: - return new MessageRelease(); - case MessageAcquire.TYPE: - return new MessageAcquire(); - case MessageResume.TYPE: - return new MessageResume(); - case MessageSubscribe.TYPE: - return new MessageSubscribe(); - case MessageCancel.TYPE: - return new MessageCancel(); - case MessageSetFlowMode.TYPE: - return new MessageSetFlowMode(); - case MessageFlow.TYPE: - return new MessageFlow(); - case MessageFlush.TYPE: - return new MessageFlush(); - case MessageStop.TYPE: - return new MessageStop(); - case TxSelect.TYPE: - return new TxSelect(); - case TxCommit.TYPE: - return new TxCommit(); - case TxRollback.TYPE: - return new TxRollback(); - case DtxSelect.TYPE: - return new DtxSelect(); - case DtxStart.TYPE: - return new DtxStart(); - case DtxEnd.TYPE: - return new DtxEnd(); - case DtxCommit.TYPE: - return new DtxCommit(); - case DtxForget.TYPE: - return new DtxForget(); - case DtxGetTimeout.TYPE: - return new DtxGetTimeout(); - case DtxPrepare.TYPE: - return new DtxPrepare(); - case DtxRecover.TYPE: - return new DtxRecover(); - case DtxRollback.TYPE: - return new DtxRollback(); - case DtxSetTimeout.TYPE: - return new DtxSetTimeout(); - case ExchangeDeclare.TYPE: - return new ExchangeDeclare(); - case ExchangeDelete.TYPE: - return new ExchangeDelete(); - case ExchangeQuery.TYPE: - return new ExchangeQuery(); - case ExchangeBind.TYPE: - return new ExchangeBind(); - case ExchangeUnbind.TYPE: - return new ExchangeUnbind(); - case ExchangeBound.TYPE: - return new ExchangeBound(); - case QueueDeclare.TYPE: - return new QueueDeclare(); - case QueueDelete.TYPE: - return new QueueDelete(); - case QueuePurge.TYPE: - return new QueuePurge(); - case QueueQuery.TYPE: - return new QueueQuery(); - default: - throw new IllegalArgumentException("type: " + type); - } - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/Track.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/Track.java deleted file mode 100644 index 861a992a83..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/Track.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -public enum Track { - - CONTROL((short) 0), - COMMAND((short) 1); - - private final short value; - - Track(short value) - { - this.value = value; - } - - public short getValue() - { - return value; - } - - public static Track get(short value) - { - switch (value) - { - case (short) 0: return CONTROL; - case (short) 1: return COMMAND; - default: throw new IllegalArgumentException("no such value: " + value); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/TransportException.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/TransportException.java deleted file mode 100644 index 0de190dfad..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/TransportException.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport; - - -/** - * TransportException - */ - -public class TransportException extends RuntimeException -{ - - public TransportException(String msg) - { - super(msg); - } - - public TransportException(String msg, Throwable cause) - { - super(msg, cause); - } - - public TransportException(Throwable cause) - { - super(cause); - } - - public void rethrow() - { - throw new TransportException(getMessage(), this); - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/TxCommit.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/TxCommit.java deleted file mode 100644 index 837aa1e1d4..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/TxCommit.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class TxCommit extends Method { - - public static final int TYPE = 1282; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - - - - - public TxCommit(Option ... _options) { - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.txCommit(context, this); - } - - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/TxRollback.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/TxRollback.java deleted file mode 100644 index f8b54f2e5c..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/TxRollback.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class TxRollback extends Method { - - public static final int TYPE = 1283; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - - - - - public TxRollback(Option ... _options) { - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.txRollback(context, this); - } - - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/TxSelect.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/TxSelect.java deleted file mode 100644 index 6fd886e94e..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/TxSelect.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - -import org.apache.qpid.transport.network.Frame; - - -public final class TxSelect extends Method { - - public static final int TYPE = 1281; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 0; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return Frame.L4; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - - - - - public TxSelect(Option ... _options) { - - for (int i=0; i < _options.length; i++) { - switch (_options[i]) { - case SYNC: this.setSync(true); break; - case BATCH: this.setBatch(true); break; - case UNRELIABLE: this.setUnreliable(true); break; - case NONE: break; - default: throw new IllegalArgumentException("invalid option: " + _options[i]); - } - } - - } - - public void dispatch(C context, MethodDelegate delegate) { - delegate.txSelect(context, this); - } - - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/Type.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/Type.java deleted file mode 100644 index 05904f2995..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/Type.java +++ /dev/null @@ -1,148 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - - - -public enum Type -{ - - BIN8((byte) 0x00, 1, true), - INT8((byte) 0x01, 1, true), - UINT8((byte) 0x02, 1, true), - CHAR((byte) 0x04, 1, true), - BOOLEAN((byte) 0x08, 1, true), - BIN16((byte) 0x10, 2, true), - INT16((byte) 0x11, 2, true), - UINT16((byte) 0x12, 2, true), - BIN32((byte) 0x20, 4, true), - INT32((byte) 0x21, 4, true), - UINT32((byte) 0x22, 4, true), - FLOAT((byte) 0x23, 4, true), - CHAR_UTF32((byte) 0x27, 4, true), - BIN64((byte) 0x30, 8, true), - INT64((byte) 0x31, 8, true), - UINT64((byte) 0x32, 8, true), - DOUBLE((byte) 0x33, 8, true), - DATETIME((byte) 0x38, 8, true), - BIN128((byte) 0x40, 16, true), - UUID((byte) 0x48, 16, true), - BIN256((byte) 0x50, 32, true), - BIN512((byte) 0x60, 64, true), - BIN1024((byte) 0x70, 128, true), - VBIN8((byte) 0x80, 1, false), - STR8_LATIN((byte) 0x84, 1, false), - STR8((byte) 0x85, 1, false), - STR8_UTF16((byte) 0x86, 1, false), - VBIN16((byte) 0x90, 2, false), - STR16_LATIN((byte) 0x94, 2, false), - STR16((byte) 0x95, 2, false), - STR16_UTF16((byte) 0x96, 2, false), - VBIN32((byte) 0xa0, 4, false), - MAP((byte) 0xa8, 4, false), - LIST((byte) 0xa9, 4, false), - ARRAY((byte) 0xaa, 4, false), - STRUCT32((byte) 0xab, 4, false), - BIN40((byte) 0xc0, 5, true), - DEC32((byte) 0xc8, 5, true), - BIN72((byte) 0xd0, 9, true), - DEC64((byte) 0xd8, 9, true), - VOID((byte) 0xf0, 0, true), - BIT((byte) 0xf1, 0, true); - - private final byte code; - private final int width; - private final boolean fixed; - - Type(byte code, int width, boolean fixed) - { - this.code = code; - this.width = width; - this.fixed = fixed; - } - - public byte getCode() - { - return code; - } - - public int getWidth() - { - return width; - } - - public boolean isFixed() - { - return fixed; - } - - public static Type get(byte code) - { - switch (code) - { - case (byte) 0x00: return BIN8; - case (byte) 0x01: return INT8; - case (byte) 0x02: return UINT8; - case (byte) 0x04: return CHAR; - case (byte) 0x08: return BOOLEAN; - case (byte) 0x10: return BIN16; - case (byte) 0x11: return INT16; - case (byte) 0x12: return UINT16; - case (byte) 0x20: return BIN32; - case (byte) 0x21: return INT32; - case (byte) 0x22: return UINT32; - case (byte) 0x23: return FLOAT; - case (byte) 0x27: return CHAR_UTF32; - case (byte) 0x30: return BIN64; - case (byte) 0x31: return INT64; - case (byte) 0x32: return UINT64; - case (byte) 0x33: return DOUBLE; - case (byte) 0x38: return DATETIME; - case (byte) 0x40: return BIN128; - case (byte) 0x48: return UUID; - case (byte) 0x50: return BIN256; - case (byte) 0x60: return BIN512; - case (byte) 0x70: return BIN1024; - case (byte) 0x80: return VBIN8; - case (byte) 0x84: return STR8_LATIN; - case (byte) 0x85: return STR8; - case (byte) 0x86: return STR8_UTF16; - case (byte) 0x90: return VBIN16; - case (byte) 0x94: return STR16_LATIN; - case (byte) 0x95: return STR16; - case (byte) 0x96: return STR16_UTF16; - case (byte) 0xa0: return VBIN32; - case (byte) 0xa8: return MAP; - case (byte) 0xa9: return LIST; - case (byte) 0xaa: return ARRAY; - case (byte) 0xab: return STRUCT32; - case (byte) 0xc0: return BIN40; - case (byte) 0xc8: return DEC32; - case (byte) 0xd0: return BIN72; - case (byte) 0xd8: return DEC64; - case (byte) 0xf0: return VOID; - case (byte) 0xf1: return BIT; - - default: return null; - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/XaResult.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/XaResult.java deleted file mode 100644 index c9d502f7ea..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/XaResult.java +++ /dev/null @@ -1,141 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - - - -public final class XaResult extends Struct { - - public static final int TYPE = 1537; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 4; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return -1; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private DtxXaStatus status; - - - public XaResult() {} - - - public XaResult(DtxXaStatus status) { - if(status != null) { - setStatus(status); - } - - } - - - - - public final boolean hasStatus() { - return (packing_flags & 256) != 0; - } - - public final XaResult clearStatus() { - packing_flags &= ~256; - this.status = null; - setDirty(true); - return this; - } - - public final DtxXaStatus getStatus() { - return status; - } - - public final XaResult setStatus(DtxXaStatus value) { - this.status = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final XaResult status(DtxXaStatus value) { - return setStatus(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeUint16(this.status.getValue()); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.status = DtxXaStatus.get(dec.readUint16()); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("status", getStatus()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/Xid.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/Xid.java deleted file mode 100644 index 4e142079af..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/Xid.java +++ /dev/null @@ -1,223 +0,0 @@ -package org.apache.qpid.transport; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.transport.codec.Decoder; -import org.apache.qpid.transport.codec.Encoder; - - - -public final class Xid extends Struct { - - public static final int TYPE = 1540; - - public final int getStructType() { - return TYPE; - } - - public final int getSizeWidth() { - return 4; - } - - public final int getPackWidth() { - return 2; - } - - public final boolean hasPayload() { - return false; - } - - public final byte getEncodedTrack() { - return -1; - } - - public final boolean isConnectionControl() - { - return false; - } - - private short packing_flags = 0; - private long format; - private byte[] globalId; - private byte[] branchId; - - - public Xid() {} - - - public Xid(long format, byte[] globalId, byte[] branchId) { - setFormat(format); - if(globalId != null) { - setGlobalId(globalId); - } - if(branchId != null) { - setBranchId(branchId); - } - - } - - - - - public final boolean hasFormat() { - return (packing_flags & 256) != 0; - } - - public final Xid clearFormat() { - packing_flags &= ~256; - this.format = 0; - setDirty(true); - return this; - } - - public final long getFormat() { - return format; - } - - public final Xid setFormat(long value) { - this.format = value; - packing_flags |= 256; - setDirty(true); - return this; - } - - public final Xid format(long value) { - return setFormat(value); - } - - public final boolean hasGlobalId() { - return (packing_flags & 512) != 0; - } - - public final Xid clearGlobalId() { - packing_flags &= ~512; - this.globalId = null; - setDirty(true); - return this; - } - - public final byte[] getGlobalId() { - return globalId; - } - - public final Xid setGlobalId(byte[] value) { - this.globalId = value; - packing_flags |= 512; - setDirty(true); - return this; - } - - public final Xid globalId(byte[] value) { - return setGlobalId(value); - } - - public final boolean hasBranchId() { - return (packing_flags & 1024) != 0; - } - - public final Xid clearBranchId() { - packing_flags &= ~1024; - this.branchId = null; - setDirty(true); - return this; - } - - public final byte[] getBranchId() { - return branchId; - } - - public final Xid setBranchId(byte[] value) { - this.branchId = value; - packing_flags |= 1024; - setDirty(true); - return this; - } - - public final Xid branchId(byte[] value) { - return setBranchId(value); - } - - - - - public void write(Encoder enc) - { - enc.writeUint16(packing_flags); - if ((packing_flags & 256) != 0) - { - enc.writeUint32(this.format); - } - if ((packing_flags & 512) != 0) - { - enc.writeVbin8(this.globalId); - } - if ((packing_flags & 1024) != 0) - { - enc.writeVbin8(this.branchId); - } - - } - - public void read(Decoder dec) - { - packing_flags = (short) dec.readUint16(); - if ((packing_flags & 256) != 0) - { - this.format = dec.readUint32(); - } - if ((packing_flags & 512) != 0) - { - this.globalId = dec.readVbin8(); - } - if ((packing_flags & 1024) != 0) - { - this.branchId = dec.readVbin8(); - } - - } - - public Map getFields() - { - Map result = new LinkedHashMap(); - - if ((packing_flags & 256) != 0) - { - result.put("format", getFormat()); - } - if ((packing_flags & 512) != 0) - { - result.put("globalId", getGlobalId()); - } - if ((packing_flags & 1024) != 0) - { - result.put("branchId", getBranchId()); - } - - - return result; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/AbstractDecoder.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/AbstractDecoder.java deleted file mode 100644 index 27fce6e167..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/AbstractDecoder.java +++ /dev/null @@ -1,478 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.codec; - -import org.apache.qpid.transport.Binary; -import org.apache.qpid.transport.Range; -import org.apache.qpid.transport.RangeSet; -import org.apache.qpid.transport.RangeSetFactory; -import org.apache.qpid.transport.Struct; -import org.apache.qpid.transport.Type; - -import java.io.UnsupportedEncodingException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; - - -/** - * AbstractDecoder - * - * @author Rafael H. Schloming - */ - -abstract class AbstractDecoder implements Decoder -{ - - private final Map str8cache = new LinkedHashMap() - { - @Override protected boolean removeEldestEntry(Map.Entry me) - { - return size() > 4*1024; - } - }; - - protected abstract byte doGet(); - - protected abstract void doGet(byte[] bytes); - - protected byte get() - { - return doGet(); - } - - protected void get(byte[] bytes) - { - doGet(bytes); - } - - protected Binary get(int size) - { - byte[] bytes = new byte[size]; - get(bytes); - return new Binary(bytes); - } - - protected short uget() - { - return (short) (0xFF & get()); - } - - public short readUint8() - { - return uget(); - } - - public int readUint16() - { - int i = uget() << 8; - i |= uget(); - return i; - } - - public long readUint32() - { - long l = uget() << 24; - l |= uget() << 16; - l |= uget() << 8; - l |= uget(); - return l; - } - - public int readSequenceNo() - { - return (int) readUint32(); - } - - public long readUint64() - { - long l = 0; - for (int i = 0; i < 8; i++) - { - l |= ((long) (0xFF & get())) << (56 - i*8); - } - return l; - } - - public long readDatetime() - { - return readUint64(); - } - - private static final String decode(byte[] bytes, int offset, int length, String charset) - { - try - { - return new String(bytes, offset, length, charset); - } - catch (UnsupportedEncodingException e) - { - throw new RuntimeException(e); - } - } - - private static final String decode(byte[] bytes, String charset) - { - return decode(bytes, 0, bytes.length, charset); - } - - public String readStr8() - { - short size = readUint8(); - Binary bin = get(size); - String str = str8cache.get(bin); - - if (str == null) - { - str = decode(bin.array(), bin.offset(), bin.size(), "UTF-8"); - if(bin.hasExcessCapacity()) - { - str8cache.put(bin.copy(), str); - } - else - { - str8cache.put(bin, str); - } - } - return str; - } - - public String readStr16() - { - int size = readUint16(); - byte[] bytes = new byte[size]; - get(bytes); - return decode(bytes, "UTF-8"); - } - - public byte[] readVbin8() - { - int size = readUint8(); - byte[] bytes = new byte[size]; - get(bytes); - return bytes; - } - - public byte[] readVbin16() - { - int size = readUint16(); - byte[] bytes = new byte[size]; - get(bytes); - return bytes; - } - - public byte[] readVbin32() - { - int size = (int) readUint32(); - byte[] bytes = new byte[size]; - get(bytes); - return bytes; - } - - public RangeSet readSequenceSet() - { - int count = readUint16()/8; - switch(count) - { - case 0: - return null; - case 1: - return Range.newInstance(readSequenceNo(), readSequenceNo()); - default: - RangeSet ranges = RangeSetFactory.createRangeSet(count); - for (int i = 0; i < count; i++) - { - ranges.add(readSequenceNo(), readSequenceNo()); - } - return ranges; - } - } - - public RangeSet readByteRanges() - { - throw new Error("not implemented"); - } - - public UUID readUuid() - { - long msb = readUint64(); - long lsb = readUint64(); - return new UUID(msb, lsb); - } - - public String readContent() - { - throw new Error("Deprecated"); - } - - public Struct readStruct(int type) - { - Struct st = Struct.create(type); - int width = st.getSizeWidth(); - if (width > 0) - { - long size = readSize(width); - if (size == 0) - { - return null; - } - } - if (type > 0) - { - int code = readUint16(); - assert code == type; - } - st.read(this); - return st; - } - - public Struct readStruct32() - { - long size = readUint32(); - if (size == 0) - { - return null; - } - else - { - int type = readUint16(); - Struct result = Struct.create(type); - result.read(this); - return result; - } - } - - public Map readMap() - { - long size = readUint32(); - - if (size == 0) - { - return null; - } - - long count = readUint32(); - - if (count == 0) - { - return Collections.EMPTY_MAP; - } - - Map result = new LinkedHashMap(); - for (int i = 0; i < count; i++) - { - String key = readStr8(); - byte code = get(); - Type t = getType(code); - Object value = read(t); - result.put(key, value); - } - - return result; - } - - public List readList() - { - long size = readUint32(); - - if (size == 0) - { - return null; - } - - long count = readUint32(); - - if (count == 0) - { - return Collections.EMPTY_LIST; - } - - List result = new ArrayList(); - for (int i = 0; i < count; i++) - { - byte code = get(); - Type t = getType(code); - Object value = read(t); - result.add(value); - } - return result; - } - - public List readArray() - { - long size = readUint32(); - - if (size == 0) - { - return null; - } - - byte code = get(); - Type t = getType(code); - long count = readUint32(); - - if (count == 0) - { - return Collections.EMPTY_LIST; - } - - List result = new ArrayList(); - for (int i = 0; i < count; i++) - { - Object value = read(t); - result.add(value); - } - return result; - } - - private Type getType(byte code) - { - Type type = Type.get(code); - if (type == null) - { - throw new IllegalArgumentException("unknown code: " + code); - } - else - { - return type; - } - } - - private long readSize(Type t) - { - if (t.isFixed()) - { - return t.getWidth(); - } - else - { - return readSize(t.getWidth()); - } - } - - private long readSize(int width) - { - switch (width) - { - case 1: - return readUint8(); - case 2: - return readUint16(); - case 4: - return readUint32(); - default: - throw new IllegalStateException("illegal width: " + width); - } - } - - private byte[] readBytes(Type t) - { - long size = readSize(t); - byte[] result = new byte[(int) size]; - get(result); - return result; - } - - private Object read(Type t) - { - switch (t) - { - case BIN8: - case UINT8: - return readUint8(); - case INT8: - return get(); - case CHAR: - return (char) get(); - case BOOLEAN: - return get() > 0; - - case BIN16: - case UINT16: - return readUint16(); - - case INT16: - return (short) readUint16(); - - case BIN32: - case UINT32: - return readUint32(); - - case CHAR_UTF32: - case INT32: - return (int) readUint32(); - - case FLOAT: - return Float.intBitsToFloat((int) readUint32()); - - case BIN64: - case UINT64: - case INT64: - case DATETIME: - return readUint64(); - - case DOUBLE: - return Double.longBitsToDouble(readUint64()); - - case UUID: - return readUuid(); - - case STR8: - return readStr8(); - - case STR16: - return readStr16(); - - case STR8_LATIN: - case STR8_UTF16: - case STR16_LATIN: - case STR16_UTF16: - // XXX: need to do character conversion - return new String(readBytes(t)); - - case MAP: - return readMap(); - case LIST: - return readList(); - case ARRAY: - return readArray(); - case STRUCT32: - return readStruct32(); - - case BIN40: - case DEC32: - case BIN72: - case DEC64: - // XXX: what types are we supposed to use here? - return readBytes(t); - - case VOID: - return null; - - default: - return readBytes(t); - } - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/AbstractEncoder.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/AbstractEncoder.java deleted file mode 100644 index 070621db9b..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/AbstractEncoder.java +++ /dev/null @@ -1,620 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.codec; - -import static org.apache.qpid.transport.util.Functions.lsb; - -import java.io.UnsupportedEncodingException; -import java.nio.ByteBuffer; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import org.apache.qpid.transport.Range; -import org.apache.qpid.transport.RangeSet; -import org.apache.qpid.transport.Struct; -import org.apache.qpid.transport.Type; -import org.apache.qpid.transport.Xid; - - -/** - * AbstractEncoder - * - * @author Rafael H. Schloming - */ - -public abstract class AbstractEncoder implements Encoder -{ - - private static Map,Type> ENCODINGS = new HashMap,Type>(); - static - { - ENCODINGS.put(Boolean.class, Type.BOOLEAN); - ENCODINGS.put(String.class, Type.STR16); - ENCODINGS.put(Long.class, Type.INT64); - ENCODINGS.put(Integer.class, Type.INT32); - ENCODINGS.put(Short.class, Type.INT16); - ENCODINGS.put(Byte.class, Type.INT8); - ENCODINGS.put(Map.class, Type.MAP); - ENCODINGS.put(List.class, Type.LIST); - ENCODINGS.put(Float.class, Type.FLOAT); - ENCODINGS.put(Double.class, Type.DOUBLE); - ENCODINGS.put(Character.class, Type.CHAR); - ENCODINGS.put(byte[].class, Type.VBIN32); - ENCODINGS.put(UUID.class, Type.UUID); - ENCODINGS.put(Xid.class, Type.STRUCT32); - } - - private final Map str8cache = new LinkedHashMap() - { - @Override protected boolean removeEldestEntry(Map.Entry me) - { - return size() > 4*1024; - } - }; - - protected abstract void doPut(byte b); - - protected abstract void doPut(ByteBuffer src); - - protected void put(byte b) - { - doPut(b); - } - - protected void put(ByteBuffer src) - { - doPut(src); - } - - protected void put(byte[] bytes) - { - put(ByteBuffer.wrap(bytes)); - } - - protected abstract int beginSize8(); - protected abstract void endSize8(int pos); - - protected abstract int beginSize16(); - protected abstract void endSize16(int pos); - - protected abstract int beginSize32(); - protected abstract void endSize32(int pos); - - public void writeUint8(short b) - { - assert b < 0x100; - - put((byte) b); - } - - public void writeUint16(int s) - { - assert s < 0x10000; - - put(lsb(s >>> 8)); - put(lsb(s)); - } - - public void writeUint32(long i) - { - assert i < 0x100000000L; - - put(lsb(i >>> 24)); - put(lsb(i >>> 16)); - put(lsb(i >>> 8)); - put(lsb(i)); - } - - public void writeSequenceNo(int i) - { - writeUint32(i); - } - - public void writeUint64(long l) - { - for (int i = 0; i < 8; i++) - { - put(lsb(l >> (56 - i*8))); - } - } - - - public void writeDatetime(long l) - { - writeUint64(l); - } - - private static final byte[] encode(String s, String charset) - { - try - { - return s.getBytes(charset); - } - catch (UnsupportedEncodingException e) - { - throw new RuntimeException(e); - } - } - - public void writeStr8(String s) - { - if (s == null) - { - s = ""; - } - - byte[] bytes = str8cache.get(s); - if (bytes == null) - { - bytes = encode(s, "UTF-8"); - str8cache.put(s, bytes); - } - writeUint8((short) bytes.length); - put(bytes); - } - - public void writeStr16(String s) - { - if (s == null) - { - s = ""; - } - - byte[] bytes = encode(s, "UTF-8"); - writeUint16(bytes.length); - put(bytes); - } - - public void writeVbin8(byte[] bytes) - { - if (bytes == null) { bytes = new byte[0]; } - if (bytes.length > 255) - { - throw new IllegalArgumentException("array too long: " + bytes.length); - } - writeUint8((short) bytes.length); - put(ByteBuffer.wrap(bytes)); - } - - public void writeVbin16(byte[] bytes) - { - if (bytes == null) { bytes = new byte[0]; } - writeUint16(bytes.length); - put(ByteBuffer.wrap(bytes)); - } - - public void writeVbin32(byte[] bytes) - { - if (bytes == null) { bytes = new byte[0]; } - writeUint32(bytes.length); - put(ByteBuffer.wrap(bytes)); - } - - public void writeSequenceSet(RangeSet ranges) - { - if (ranges == null) - { - writeUint16((short) 0); - } - else - { - writeUint16(ranges.size() * 8); - for (Range range : ranges) - { - writeSequenceNo(range.getLower()); - writeSequenceNo(range.getUpper()); - } - } - } - - public void writeByteRanges(RangeSet ranges) - { - throw new Error("not implemented"); - } - - public void writeUuid(UUID uuid) - { - long msb = 0; - long lsb = 0; - if (uuid != null) - { - msb = uuid.getMostSignificantBits(); - lsb = uuid.getLeastSignificantBits(); - } - writeUint64(msb); - writeUint64(lsb); - } - - public void writeStruct(int type, Struct s) - { - boolean empty = false; - if (s == null) - { - s = Struct.create(type); - empty = true; - } - - int width = s.getSizeWidth(); - int pos = -1; - if (width > 0) - { - pos = beginSize(width); - } - - if (type > 0) - { - writeUint16(type); - } - - s.write(this); - - if (width > 0) - { - endSize(width, pos); - } - } - - public void writeStruct32(Struct s) - { - if (s == null) - { - writeUint32(0); - } - else - { - int pos = beginSize32(); - writeUint16(s.getEncodedType()); - s.write(this); - endSize32(pos); - } - } - - private Type encoding(Object value) - { - if (value == null) - { - return Type.VOID; - } - - Class klass = value.getClass(); - Type type = resolve(klass); - - if (type == null) - { - throw new IllegalArgumentException - ("unable to resolve type: " + klass + ", " + value); - } - else - { - return type; - } - } - - static final Type resolve(Class klass) - { - Type type = ENCODINGS.get(klass); - if (type != null) - { - return type; - } - - Class sup = klass.getSuperclass(); - if (sup != null) - { - type = resolve(klass.getSuperclass()); - - if (type != null) - { - return type; - } - } - - for (Class iface : klass.getInterfaces()) - { - type = resolve(iface); - if (type != null) - { - return type; - } - } - - return null; - } - - public void writeMap(Map map) - { - int pos = beginSize32(); - if (map != null) - { - writeUint32(map.size()); - writeMapEntries(map); - } - endSize32(pos); - } - - protected void writeMapEntries(Map map) - { - for (Map.Entry entry : map.entrySet()) - { - String key = entry.getKey(); - Object value = entry.getValue(); - Type type = encoding(value); - writeStr8(key); - put(type.getCode()); - write(type, value); - } - } - - public void writeList(List list) - { - int pos = beginSize32(); - if (list != null) - { - writeUint32(list.size()); - writeListEntries(list); - } - endSize32(pos); - } - - protected void writeListEntries(List list) - { - for (Object value : list) - { - Type type = encoding(value); - put(type.getCode()); - write(type, value); - } - } - - public void writeArray(List array) - { - int pos = beginSize32(); - if (array != null) - { - writeArrayEntries(array); - } - endSize32(pos); - } - - protected void writeArrayEntries(List array) - { - Type type; - - if (array.isEmpty()) - { - return; - } - else - { - type = encoding(array.get(0)); - } - - put(type.getCode()); - - writeUint32(array.size()); - - for (Object value : array) - { - write(type, value); - } - } - - private void writeSize(Type t, int size) - { - if (t.isFixed()) - { - if (size != t.getWidth()) - { - throw new IllegalArgumentException - ("size does not match fixed width " + t.getWidth() + ": " + - size); - } - } - else - { - writeSize(t.getWidth(), size); - } - } - - private void writeSize(int width, int size) - { - // XXX: should check lengths - switch (width) - { - case 1: - writeUint8((short) size); - break; - case 2: - writeUint16(size); - break; - case 4: - writeUint32(size); - break; - default: - throw new IllegalStateException("illegal width: " + width); - } - } - - private int beginSize(int width) - { - switch (width) - { - case 1: - return beginSize8(); - case 2: - return beginSize16(); - case 4: - return beginSize32(); - default: - throw new IllegalStateException("illegal width: " + width); - } - } - - private void endSize(int width, int pos) - { - switch (width) - { - case 1: - endSize8(pos); - break; - case 2: - endSize16(pos); - break; - case 4: - endSize32(pos); - break; - default: - throw new IllegalStateException("illegal width: " + width); - } - } - - private void writeBytes(Type t, byte[] bytes) - { - writeSize(t, bytes.length); - put(bytes); - } - - private T coerce(Class klass, Object value) - { - if (klass.isInstance(value)) - { - return klass.cast(value); - } - else - { - throw new IllegalArgumentException("" + value); - } - } - - private void write(Type t, Object value) - { - switch (t) - { - case BIN8: - case UINT8: - writeUint8(coerce(Short.class, value)); - break; - case INT8: - put(coerce(Byte.class, value)); - break; - case CHAR: - put((byte) ((char)coerce(Character.class, value))); - break; - case BOOLEAN: - if (coerce(Boolean.class, value)) - { - put((byte) 1); - } - else - { - put((byte) 0); - } - break; - - case BIN16: - case UINT16: - writeUint16(coerce(Integer.class, value)); - break; - - case INT16: - writeUint16(coerce(Short.class, value)); - break; - - case BIN32: - case UINT32: - writeUint32(coerce(Long.class, value)); - break; - - case CHAR_UTF32: - case INT32: - writeUint32(coerce(Integer.class, value)); - break; - - case FLOAT: - writeUint32(Float.floatToIntBits(coerce(Float.class, value))); - break; - - case BIN64: - case UINT64: - case INT64: - case DATETIME: - writeUint64(coerce(Long.class, value)); - break; - - case DOUBLE: - long bits = Double.doubleToLongBits(coerce(Double.class, value)); - writeUint64(bits); - break; - - case UUID: - writeUuid(coerce(UUID.class, value)); - break; - - case STR8: - writeStr8(coerce(String.class, value)); - break; - - case STR16: - writeStr16(coerce(String.class, value)); - break; - - case STR8_LATIN: - case STR8_UTF16: - case STR16_LATIN: - case STR16_UTF16: - // XXX: need to do character conversion - writeBytes(t, coerce(String.class, value).getBytes()); - break; - - case MAP: - writeMap((Map) coerce(Map.class, value)); - break; - case LIST: - writeList(coerce(List.class, value)); - break; - case ARRAY: - writeArray(coerce(List.class, value)); - break; - case STRUCT32: - writeStruct32(coerce(Struct.class, value)); - break; - - case BIN40: - case DEC32: - case BIN72: - case DEC64: - // XXX: what types are we supposed to use here? - writeBytes(t, coerce(byte[].class, value)); - break; - - case VOID: - break; - - default: - writeBytes(t, coerce(byte[].class, value)); - break; - } - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/BBDecoder.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/BBDecoder.java deleted file mode 100644 index a8ac44200f..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/BBDecoder.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.codec; - -import org.apache.qpid.transport.Binary; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; - -/** - * Byte Buffer Decoder. - * Decoder concrete implementor using a backing byte buffer for decoding data. - * - * @author Rafael H. Schloming - */ -public final class BBDecoder extends AbstractDecoder -{ - private ByteBuffer in; - - public void init(ByteBuffer in) - { - this.in = in; - this.in.order(ByteOrder.BIG_ENDIAN); - } - - public void releaseBuffer() - { - in = null; - } - - protected byte doGet() - { - return in.get(); - } - - protected void doGet(byte[] bytes) - { - in.get(bytes); - } - - protected Binary get(int size) - { - if (in.hasArray()) - { - byte[] bytes = in.array(); - Binary bin = new Binary(bytes, in.arrayOffset() + in.position(), size); - in.position(in.position() + size); - return bin; - } - else - { - return super.get(size); - } - } - - public boolean hasRemaining() - { - return in.hasRemaining(); - } - - public short readUint8() - { - return (short) (0xFF & in.get()); - } - - public int readUint16() - { - return 0xFFFF & in.getShort(); - } - - public long readUint32() - { - return 0xFFFFFFFFL & in.getInt(); - } - - public long readUint64() - { - return in.getLong(); - } - - public byte[] readBin128() - { - byte[] result = new byte[16]; - get(result); - return result; - } - - public byte[] readBytes(int howManyBytes) - { - byte[] result = new byte[howManyBytes]; - get(result); - return result; - } - - public double readDouble() - { - return in.getDouble(); - } - - public float readFloat() - { - return in.getFloat(); - } - - public short readInt16() - { - return in.getShort(); - } - - public int readInt32() - { - return in.getInt(); - } - - public byte readInt8() - { - return in.get(); - } - - public byte[] readReaminingBytes() - { - byte[] result = new byte[in.limit() - in.position()]; - get(result); - return result; - } - - public long readInt64() - { - return in.getLong(); - } -} \ No newline at end of file diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/BBEncoder.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/BBEncoder.java deleted file mode 100644 index 407df71824..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/BBEncoder.java +++ /dev/null @@ -1,363 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.codec; - -import java.nio.BufferOverflowException; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.util.UUID; - - -/** - * Byte Buffer Encoder. - * Encoder concrete implementor using a backing byte buffer for encoding data. - * - * @author Rafael H. Schloming - */ -public final class BBEncoder extends AbstractEncoder -{ - private ByteBuffer out; - private int segment; - - public BBEncoder(int capacity) { - out = ByteBuffer.allocate(capacity); - out.order(ByteOrder.BIG_ENDIAN); - segment = 0; - } - - public void init() - { - out.clear(); - segment = 0; - } - - public ByteBuffer segment() - { - int pos = out.position(); - out.position(segment); - ByteBuffer slice = out.slice(); - slice.limit(pos - segment); - out.position(pos); - segment = pos; - return slice; - } - - public ByteBuffer buffer() - { - int pos = out.position(); - out.position(segment); - ByteBuffer slice = out.slice(); - slice.limit(pos - segment); - out.position(pos); - return slice; - } - - public int position() - { - return out.position(); - } - - public ByteBuffer underlyingBuffer() - { - return out; - } - - private void grow(int size) - { - ByteBuffer old = out; - int capacity = old.capacity(); - out = ByteBuffer.allocate(Math.max(capacity + size, 2*capacity)); - out.order(ByteOrder.BIG_ENDIAN); - old.flip(); - out.put(old); - } - - protected void doPut(byte b) - { - try - { - out.put(b); - } - catch (BufferOverflowException e) - { - grow(1); - out.put(b); - } - } - - protected void doPut(ByteBuffer src) - { - try - { - out.put(src); - } - catch (BufferOverflowException e) - { - grow(src.remaining()); - out.put(src); - } - } - - protected void put(byte[] bytes) - { - try - { - out.put(bytes); - } - catch (BufferOverflowException e) - { - grow(bytes.length); - out.put(bytes); - } - } - - public void writeUint8(short b) - { - assert b < 0x100; - - try - { - out.put((byte) b); - } - catch (BufferOverflowException e) - { - grow(1); - out.put((byte) b); - } - } - - public void writeUint16(int s) - { - assert s < 0x10000; - - try - { - out.putShort((short) s); - } - catch (BufferOverflowException e) - { - grow(2); - out.putShort((short) s); - } - } - - public void writeUint32(long i) - { - assert i < 0x100000000L; - - try - { - out.putInt((int) i); - } - catch (BufferOverflowException e) - { - grow(4); - out.putInt((int) i); - } - } - - public void writeUint64(long l) - { - try - { - out.putLong(l); - } - catch (BufferOverflowException e) - { - grow(8); - out.putLong(l); - } - } - - public int beginSize8() - { - int pos = out.position(); - try - { - out.put((byte) 0); - } - catch (BufferOverflowException e) - { - grow(1); - out.put((byte) 0); - } - return pos; - } - - public void endSize8(int pos) - { - int cur = out.position(); - out.put(pos, (byte) (cur - pos - 1)); - } - - public int beginSize16() - { - int pos = out.position(); - try - { - out.putShort((short) 0); - } - catch (BufferOverflowException e) - { - grow(2); - out.putShort((short) 0); - } - return pos; - } - - public void endSize16(int pos) - { - int cur = out.position(); - out.putShort(pos, (short) (cur - pos - 2)); - } - - public int beginSize32() - { - int pos = out.position(); - try - { - out.putInt(0); - } - catch (BufferOverflowException e) - { - grow(4); - out.putInt(0); - } - return pos; - } - - public void endSize32(int pos) - { - int cur = out.position(); - out.putInt(pos, (cur - pos - 4)); - } - - public void writeDouble(double aDouble) - { - try - { - out.putDouble(aDouble); - } catch(BufferOverflowException exception) - { - grow(8); - out.putDouble(aDouble); - } - } - - public void writeInt16(short aShort) - { - try - { - out.putShort(aShort); - } catch(BufferOverflowException exception) - { - grow(2); - out.putShort(aShort); - } - } - - public void writeInt32(int anInt) - { - try - { - out.putInt(anInt); - } catch(BufferOverflowException exception) - { - grow(4); - out.putInt(anInt); - } - } - - public void writeInt64(long aLong) - { - try - { - out.putLong(aLong); - } catch(BufferOverflowException exception) - { - grow(8); - out.putLong(aLong); - } - } - - public void writeInt8(byte aByte) - { - try - { - out.put(aByte); - } catch(BufferOverflowException exception) - { - grow(1); - out.put(aByte); - } - } - - public void writeBin128(byte[] byteArray) - { - byteArray = (byteArray != null) ? byteArray : new byte [16]; - - assert byteArray.length == 16; - - try - { - out.put(byteArray); - } catch(BufferOverflowException exception) - { - grow(16); - out.put(byteArray); - } - } - - public void writeBin128(UUID id) - { - byte[] data = new byte[16]; - - long msb = id.getMostSignificantBits(); - long lsb = id.getLeastSignificantBits(); - - assert data.length == 16; - for (int i=7; i>=0; i--) - { - data[i] = (byte)(msb & 0xff); - msb = msb >> 8; - } - - for (int i=15; i>=8; i--) - { - data[i] = (byte)(lsb & 0xff); - lsb = (lsb >> 8); - } - writeBin128(data); - } - - public void writeFloat(float aFloat) - { - try - { - out.putFloat(aFloat); - } catch(BufferOverflowException exception) - { - grow(4); - out.putFloat(aFloat); - } - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/Decoder.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/Decoder.java deleted file mode 100644 index 6c027adcad..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/Decoder.java +++ /dev/null @@ -1,283 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.codec; - -import org.apache.qpid.transport.RangeSet; -import org.apache.qpid.transport.Struct; - -import java.util.List; -import java.util.Map; -import java.util.UUID; - - -/** - * Decoder interface. - * Each concrete implementor must specify how to decode given values. - * - * @author Rafael H. Schloming - */ -public interface Decoder -{ - /** - * Tells whether there are any remaining byte(s) to be read. - * - * @return true if there are remaining bytes, false otherwise. - */ - boolean hasRemaining(); - - /** - * The uint8 type is an 8-bit unsigned integral value. - * - * @return an 8-bit unsigned integral value. - */ - short readUint8(); - - /** - *The uint16 type is a 16-bit unsigned integral value encoded in network byte order. - * - * @return a 16-bit unsigned integral value encoded in network byte order. - */ - int readUint16(); - - /** - *The uint32 type is a 32-bit unsigned integral value encoded in network byte order. - * - * @return a 32-bit unsigned integral value encoded in network byte order. - */ - long readUint32(); - - /** - * The uint64 type is a 64-bit unsigned integral value encoded in network byte order. - * - * @return a 64-bit unsigned integral value encoded in network byte order. - */ - long readUint64(); - - /** - * The datetime type encodes a date and time using the 64 bit POSIX time_t format. - * - * @return a date and time using the 64 bit POSIX time_t format. - */ - long readDatetime(); - - /** - * The uuid type encodes a universally unique id as defined by RFC-4122. - * The format and operations for this type can be found in section 4.1.2 of RFC-4122. - * - * @return a universally unique id as defined by RFC-4122. - */ - UUID readUuid(); - - /** -// *The sequence-no type encodes, in network byte order, a serial number as defined in RFC-1982. - * - * @return a serial number as defined in RFC-1982. - */ - int readSequenceNo(); - - RangeSet readSequenceSet(); // XXX - RangeSet readByteRanges(); // XXX - - /** - * The str8 type encodes up to 255 octets worth of UTF-8 unicode. - * The number of octets of unicode is first encoded as an 8-bit unsigned integral value. - * This is followed by the actual UTF-8 unicode. - * Note that the encoded size refers to the number of octets of unicode, not necessarily the number of characters since - * the UTF-8 unicode may include multi-byte character sequences. - * - * @return a string. - */ - String readStr8(); - - /** - * The str16 type encodes up to 65535 octets worth of UTF-8 unicode. - * The number of octets is first encoded as a 16-bit unsigned integral value in network byte order. - * This is followed by the actual UTF-8 unicode. - * Note that the encoded size refers to the number of octets of unicode, not necessarily the number of unicode - * characters since the UTF-8 unicode may include multi-byte character sequences. - * - * @return a string. - */ - String readStr16(); - - /** - * The vbin8 type encodes up to 255 octets of opaque binary data. - * - * @return a byte array. - */ - byte[] readVbin8(); - - /** - * The vbin16 type encodes up to 65535 octets of opaque binary data. - * - * @return the corresponding byte array. - */ - byte[] readVbin16(); - - /** - * The vbin32 type encodes up to 4294967295 octets of opaque binary data. - * - * @return the corresponding byte array. - */ - byte[] readVbin32(); - - /** - * The struct32 type describes any coded struct with a 32-bit (4 octet) size. - * The type is restricted to be only coded structs with a 32-bit size, consequently the first six octets of any encoded - * value for this type MUST always contain the size, class-code, and struct-code in that order. - * The size is encoded as a 32-bit unsigned integral value in network byte order that is equal to the size of the - * encoded field-data, packing-flags, class-code, and struct-code. The class-code is a single octet that may be set to any - * valid class code. - * The struct-code is a single octet that may be set to any valid struct code within the given class-code. - * The first six octets are then followed by the packing flags and encoded field data. - * The presence and quantity of packingflags, as well as the specific fields are determined by the struct definition - * identified with the encoded class-code and struct-code. - * - * @return the decoded struct. - */ - Struct readStruct32(); - - /** - * A map is a set of distinct keys where each key has an associated (type,value) pair. - * The triple of the key, type, and value, form an entry within a map. Each entry within a given map MUST have a - * distinct key. - * A map is encoded as a size in octets, a count of the number of entries, followed by the encoded entries themselves. - * An encoded map may contain up to (4294967295 - 4) octets worth of encoded entries. - * The size is encoded as a 32-bit unsigned integral value in network byte order equal to the number of octets worth of - * encoded entries plus 4. (The extra 4 octets is added for the entry count.) - * The size is then followed by the number of entries encoded as a 32-bit unsigned integral value in network byte order. - * Finally the entries are encoded sequentially. - * An entry is encoded as the key, followed by the type, and then the value. The key is always a string encoded as a str8. - * The type is a single octet that may contain any valid AMQP type code. - * The value is encoded according to the rules defined by the type code for that entry. - * - * @return the decoded map. - */ - Map readMap(); - - /** - * A list is an ordered sequence of (type, value) pairs. The (type, value) pair forms an item within the list. - * The list may contain items of many distinct types. A list is encoded as a size in octets, followed by a count of the - * number of items, followed by the items themselves encoded in their defined order. - * An encoded list may contain up to (4294967295 - 4) octets worth of encoded items. - * The size is encoded as a 32-bit unsigned integral value in network byte order equal to the number of octets worth - * of encoded items plus 4. (The extra4 octets is added for the item count.) - * The size is then followed by the number of items encoded as a 32-bit unsigned integral value in network byte order. - * Finally the items are encoded sequentially in their defined order. - * An item is encoded as the type followed by the value. The type is a single octet that may contain any valid AMQP type - * code. - * The value is encoded according to the rules defined by the type code for that item. - * - * @return the decoded list. - */ - List readList(); - - /** - * An array is an ordered sequence of values of the same type. - * The array is encoded in as a size in octets, followed by a type code, then a count of the number values in the array, - * and finally the values encoded in their defined order. - * An encoded array may contain up to (4294967295 - 5) octets worth of encoded values. - * The size is encoded as a 32-bit unsigned integral value in network byte order equal to the number of octets worth of - * encoded values plus 5. (The extra 5 octets consist of 4 octets for the count of the number of values, and one octet to - * hold the type code for the items inthe array.) - * The size is then followed by a single octet that may contain any valid AMQP type code. - * The type code is then followed by the number of values encoded as a 32-bit unsigned integral value in network byte - * order. - * Finally the values are encoded sequentially in their defined order according to the rules defined by the type code for - * the array. - * - * @return the decoded array. - */ - List readArray(); - - /** - * - * @param type the type of the struct. - * @return the decoded struct. - */ - Struct readStruct(int type); - - /** - * The float type encodes a single precision 32-bit floating point number. - * The format and operations are defined by the IEEE 754 standard for 32-bit single precision floating point numbers. - * - * @return the decoded float. - */ - float readFloat(); - - /** - * The double type encodes a double precision 64-bit floating point number. - * The format and operations are defined by the IEEE 754 standard for 64-bit double precision floating point numbers. - * - * @return the decoded double - */ - double readDouble(); - - /** - * The int8 type is a signed integral value encoded using an 8-bit two's complement representation. - * - * @return the decoded integer. - */ - byte readInt8(); - - /** - * The int16 type is a signed integral value encoded using a 16-bit two's complement representation in network byte order. - * - * @return the decoded integer. - */ - short readInt16(); - - /** - * The int32 type is a signed integral value encoded using a 32-bit two's complement representation in network byte order. - * - * @return the decoded integer. - */ - int readInt32(); - - /** - * The int64 type is a signed integral value encoded using a 64-bit two's complement representation in network byte order. - * - * @return the decoded integer (as long). - */ - long readInt64(); - - /** - * The bin128 type consists of 16 consecutive octets of opaque binary data. - * - * @return the decoded byte array. - */ - byte [] readBin128(); - - /** - * Reads the remaining bytes on the underlying buffer. - * - * @return the remaining bytes on the underlying buffer. - */ - byte[] readReaminingBytes (); - - /** - * Reads the given number of bytes. - * - * @param howManyBytes how many bytes need to be read? - * @return a byte array containing the requested data. - */ - byte[] readBytes (int howManyBytes); -} \ No newline at end of file diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/Encodable.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/Encodable.java deleted file mode 100644 index 37ce8a5cb7..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/Encodable.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.codec; - - -/** - * Encodable - * - * @author Rafael H. Schloming - */ -public interface Encodable -{ - /** - * Encodes this encodable using the given encoder. - * - * @param encoder the encoder. - */ - void write(Encoder encoder); - - /** - * Decodes this encodable using the given decoder. - * - * @param decoder the decoder. - */ - void read(Decoder decoder); -} \ No newline at end of file diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/Encoder.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/Encoder.java deleted file mode 100644 index b5ab29cdcf..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/codec/Encoder.java +++ /dev/null @@ -1,284 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.codec; - -import java.nio.ByteBuffer; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import org.apache.qpid.transport.RangeSet; -import org.apache.qpid.transport.Struct; - - -/** - * Encoder interface. - * Each concrete implementor must specify how to encode given values. - * - * @author Rafael H. Schloming - */ -public interface Encoder -{ - /** - * The uint8 type is an 8-bit unsigned integral value. - * - * @param b the unsigned integer to be encoded. - */ - void writeUint8(short b); - - /** - *The uint16 type is a 16-bit unsigned integral value encoded in network byte order. - * - * @param s the unsigned integer to be encoded. - */ - void writeUint16(int s); - - /** - *The uint32 type is a 32-bit unsigned integral value encoded in network byte order. - * - * @param i the unsigned integer to be encoded. - */ - void writeUint32(long i); - - /** - * The uint64 type is a 64-bit unsigned integral value encoded in network byte order. - * - * @param l the unsigned integer to be encoded. - */ - void writeUint64(long l); - - /** - * The datetime type encodes a date and time using the 64 bit POSIX time_t format. - * - * @param l the datetime (as long) to be encoded. - */ - void writeDatetime(long l); - - /** - * The uuid type encodes a universally unique id as defined by RFC-4122. - * The format and operations for this type can be found in section 4.1.2 of RFC-4122. - * - * @param uuid the uuid to be encoded. - */ - void writeUuid(UUID uuid); - - /** - *The sequence-no type encodes, in network byte order, a serial number as defined in RFC-1982. - * - * @param s the sequence number to be encoded. - */ - void writeSequenceNo(int s); - - void writeSequenceSet(RangeSet ranges); // XXX - void writeByteRanges(RangeSet ranges); // XXX - - /** - * The str8 type encodes up to 255 octets worth of UTF-8 unicode. - * The number of octets of unicode is first encoded as an 8-bit unsigned integral value. - * This is followed by the actual UTF-8 unicode. - * Note that the encoded size refers to the number of octets of unicode, not necessarily the number of characters since - * the UTF-8 unicode may include multi-byte character sequences. - * - * @param s the string to be encoded. - */ - void writeStr8(String s); - - /** - * The str16 type encodes up to 65535 octets worth of UTF-8 unicode. - * The number of octets is first encoded as a 16-bit unsigned integral value in network byte order. - * This is followed by the actual UTF-8 unicode. - * Note that the encoded size refers to the number of octets of unicode, not necessarily the number of unicode - * characters since the UTF-8 unicode may include multi-byte character sequences. - * - * @param s the string to be encoded. - */ - void writeStr16(String s); - - /** - * The vbin8 type encodes up to 255 octets of opaque binary data. - * The number of octets is first encoded as an 8-bit unsigned integral value. - * This is followed by the actual data. - * - * @param bytes the byte array to be encoded. - */ - void writeVbin8(byte[] bytes); - - /** - * The vbin16 type encodes up to 65535 octets of opaque binary data. - * The number of octets is first encoded as a 16-bit unsigned integral value in network byte order. - * This is followed by the actual data. - * - * @param bytes the byte array to be encoded. - */ - void writeVbin16(byte[] bytes); - - /** - * The vbin32 type encodes up to 4294967295 octets of opaque binary data. - * The number of octets is first encoded as a 32-bit unsigned integral value in network byte order. - * This is followed by the actual data. - * - * @param bytes the byte array to be encoded. - */ - void writeVbin32(byte[] bytes); - - /** - * The struct32 type describes any coded struct with a 32-bit (4 octet) size. - * The type is restricted to be only coded structs with a 32-bit size, consequently the first six octets of any encoded - * value for this type MUST always contain the size, class-code, and struct-code in that order. - * The size is encoded as a 32-bit unsigned integral value in network byte order that is equal to the size of the - * encoded field-data, packing-flags, class-code, and struct-code. The class-code is a single octet that may be set to any - * valid class code. - * The struct-code is a single octet that may be set to any valid struct code within the given class-code. - * The first six octets are then followed by the packing flags and encoded field data. - * The presence and quantity of packingflags, as well as the specific fields are determined by the struct definition - * identified with the encoded class-code and struct-code. - * - * @param struct the struct to be encoded. - */ - void writeStruct32(Struct struct); - - /** - * A map is a set of distinct keys where each key has an associated (type,value) pair. - * The triple of the key, type, and value, form an entry within a map. Each entry within a given map MUST have a - * distinct key. - * A map is encoded as a size in octets, a count of the number of entries, followed by the encoded entries themselves. - * An encoded map may contain up to (4294967295 - 4) octets worth of encoded entries. - * The size is encoded as a 32-bit unsigned integral value in network byte order equal to the number of octets worth of - * encoded entries plus 4. (The extra 4 octets is added for the entry count.) - * The size is then followed by the number of entries encoded as a 32-bit unsigned integral value in network byte order. - * Finally the entries are encoded sequentially. - * An entry is encoded as the key, followed by the type, and then the value. The key is always a string encoded as a str8. - * The type is a single octet that may contain any valid AMQP type code. - * The value is encoded according to the rules defined by the type code for that entry. - * - * @param map the map to be encoded. - */ - void writeMap(Map map); - - /** - * A list is an ordered sequence of (type, value) pairs. The (type, value) pair forms an item within the list. - * The list may contain items of many distinct types. A list is encoded as a size in octets, followed by a count of the - * number of items, followed by the items themselves encoded in their defined order. - * An encoded list may contain up to (4294967295 - 4) octets worth of encoded items. - * The size is encoded as a 32-bit unsigned integral value in network byte order equal to the number of octets worth - * of encoded items plus 4. (The extra4 octets is added for the item count.) - * The size is then followed by the number of items encoded as a 32-bit unsigned integral value in network byte order. - * Finally the items are encoded sequentially in their defined order. - * An item is encoded as the type followed by the value. The type is a single octet that may contain any valid AMQP type - * code. - * The value is encoded according to the rules defined by the type code for that item. - * - * @param list the list to be encoded. - */ - void writeList(List list); - - /** - * An array is an ordered sequence of values of the same type. - * The array is encoded in as a size in octets, followed by a type code, then a count of the number values in the array, - * and finally the values encoded in their defined order. - * An encoded array may contain up to (4294967295 - 5) octets worth of encoded values. - * The size is encoded as a 32-bit unsigned integral value in network byte order equal to the number of octets worth of - * encoded values plus 5. (The extra 5 octets consist of 4 octets for the count of the number of values, and one octet to - * hold the type code for the items inthe array.) - * The size is then followed by a single octet that may contain any valid AMQP type code. - * The type code is then followed by the number of values encoded as a 32-bit unsigned integral value in network byte - * order. - * Finally the values are encoded sequentially in their defined order according to the rules defined by the type code for - * the array. - * - * @param array the array to be encoded. - */ - void writeArray(List array); - - /** - * The struct32 type describes any coded struct with a 32-bit (4 octet) size. - * The type is restricted to be only coded structs with a 32-bit size, consequently the first six octets of any encoded - * value for this type MUST always contain the size, class-code, and struct-code in that order. - * The size is encoded as a 32-bit unsigned integral value in network byte order that is equal to the size of the - * encoded field-data, packing-flags, class-code, and struct-code. The class-code is a single octet that may be set to any - * valid class code. - * The struct-code is a single octet that may be set to any valid struct code within the given class-code. - * The first six octets are then followed by the packing flags and encoded field data. - * The presence and quantity of packingflags, as well as the specific fields are determined by the struct definition - * identified with the encoded class-code and struct-code. - * - * @param type the type of the struct. - * @param struct the struct to be encoded. - */ - void writeStruct(int type, Struct struct); - - /** - * The float type encodes a single precision 32-bit floating point number. - * The format and operations are defined by the IEEE 754 standard for 32-bit single precision floating point numbers. - * - * @param aFloat the float to be encoded. - */ - void writeFloat(float aFloat); - - /** - * The double type encodes a double precision 64-bit floating point number. - * The format and operations are defined by the IEEE 754 standard for 64-bit double precision floating point numbers. - * - * @param aDouble the double to be encoded. - */ - void writeDouble(double aDouble); - - /** - * The int8 type is a signed integral value encoded using an 8-bit two's complement representation. - * - * @param aByte the integer to be encoded. - */ - void writeInt8(byte aByte); - - /** - * The int16 type is a signed integral value encoded using a 16-bit two's complement representation in network byte order. - * - * @param aShort the integer to be encoded. - */ - void writeInt16(short aShort); - - /** - * The int32 type is a signed integral value encoded using a 32-bit two's complement representation in network byte order. - * - * @param anInt the integer to be encoded. - */ - void writeInt32(int anInt); - - /** - * The int64 type is a signed integral value encoded using a 64-bit two's complement representation in network byte order. - * - * @param aLong the integer to be encoded. - */ - void writeInt64(long aLong); - - /** - * The bin128 type consists of 16 consecutive octets of opaque binary data. - * - * @param bytes the bytes array to be encoded. - */ - void writeBin128(byte [] bytes); - - int position(); - - ByteBuffer underlyingBuffer(); - - void init(); -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Assembler.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Assembler.java deleted file mode 100644 index a7e96167c2..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Assembler.java +++ /dev/null @@ -1,280 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.network; - -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.qpid.transport.DeliveryProperties; -import org.apache.qpid.transport.Header; -import org.apache.qpid.transport.MessageProperties; -import org.apache.qpid.transport.Method; -import org.apache.qpid.transport.NetworkEventReceiver; -import org.apache.qpid.transport.ProtocolError; -import org.apache.qpid.transport.ProtocolEvent; -import org.apache.qpid.transport.ProtocolEventReceiver; -import org.apache.qpid.transport.ProtocolHeader; -import org.apache.qpid.transport.Struct; -import org.apache.qpid.transport.codec.BBDecoder; - -/** - * Assembler - * - */ -public class Assembler implements NetworkEventReceiver, NetworkDelegate -{ - // Use a small array to store incomplete Methods for low-value channels, instead of allocating a huge - // array or always boxing the channelId and looking it up in the map. This value must be of the form 2^X - 1. - private static final int ARRAY_SIZE = 0xFF; - private final Method[] _incompleteMethodArray = new Method[ARRAY_SIZE + 1]; - private final Map _incompleteMethodMap = new HashMap(); - - private final ProtocolEventReceiver receiver; - private final Map> segments; - private static final ThreadLocal _decoder = new ThreadLocal() - { - public BBDecoder initialValue() - { - return new BBDecoder(); - } - }; - - public Assembler(ProtocolEventReceiver receiver) - { - this.receiver = receiver; - segments = new HashMap>(); - } - - private int segmentKey(Frame frame) - { - return (frame.getTrack() + 1) * frame.getChannel(); - } - - private List getSegment(Frame frame) - { - return segments.get(segmentKey(frame)); - } - - private void setSegment(Frame frame, List segment) - { - int key = segmentKey(frame); - if (segments.containsKey(key)) - { - error(new ProtocolError(Frame.L2, "segment in progress: %s", - frame)); - } - segments.put(segmentKey(frame), segment); - } - - private void clearSegment(Frame frame) - { - segments.remove(segmentKey(frame)); - } - - private void emit(int channel, ProtocolEvent event) - { - event.setChannel(channel); - receiver.received(event); - } - - public void received(NetworkEvent event) - { - event.delegate(this); - } - - public void exception(Throwable t) - { - this.receiver.exception(t); - } - - public void closed() - { - this.receiver.closed(); - } - - public void init(ProtocolHeader header) - { - emit(0, header); - } - - public void error(ProtocolError error) - { - emit(0, error); - } - - public void frame(Frame frame) - { - ByteBuffer segment; - if (frame.isFirstFrame() && frame.isLastFrame()) - { - segment = frame.getBody(); - assemble(frame, segment); - } - else - { - List frames; - if (frame.isFirstFrame()) - { - frames = new ArrayList(); - setSegment(frame, frames); - } - else - { - frames = getSegment(frame); - } - - frames.add(frame); - - if (frame.isLastFrame()) - { - clearSegment(frame); - - int size = 0; - for (Frame f : frames) - { - size += f.getSize(); - } - segment = ByteBuffer.allocate(size); - for (Frame f : frames) - { - segment.put(f.getBody()); - } - segment.flip(); - assemble(frame, segment); - } - } - - } - - private void assemble(Frame frame, ByteBuffer segment) - { - BBDecoder dec = _decoder.get(); - dec.init(segment); - - int channel = frame.getChannel(); - Method command; - - switch (frame.getType()) - { - case CONTROL: - int controlType = dec.readUint16(); - Method control = Method.create(controlType); - control.read(dec); - emit(channel, control); - break; - case COMMAND: - int commandType = dec.readUint16(); - // read in the session header, right now we don't use it - int hdr = dec.readUint16(); - command = Method.create(commandType); - command.setSync((0x0001 & hdr) != 0); - command.read(dec); - if (command.hasPayload() && !frame.isLastSegment()) - { - setIncompleteCommand(channel, command); - } - else - { - emit(channel, command); - } - break; - case HEADER: - command = getIncompleteCommand(channel); - List structs = null; - DeliveryProperties deliveryProps = null; - MessageProperties messageProps = null; - - while (dec.hasRemaining()) - { - Struct struct = dec.readStruct32(); - if(struct instanceof DeliveryProperties && deliveryProps == null) - { - deliveryProps = (DeliveryProperties) struct; - } - else if(struct instanceof MessageProperties && messageProps == null) - { - messageProps = (MessageProperties) struct; - } - else - { - if(structs == null) - { - structs = new ArrayList(2); - } - structs.add(struct); - } - - } - command.setHeader(new Header(deliveryProps,messageProps,structs)); - - if (frame.isLastSegment()) - { - setIncompleteCommand(channel, null); - emit(channel, command); - } - break; - case BODY: - command = getIncompleteCommand(channel); - command.setBody(segment); - setIncompleteCommand(channel, null); - emit(channel, command); - break; - default: - throw new IllegalStateException("unknown frame type: " + frame.getType()); - } - - dec.releaseBuffer(); - } - - private void setIncompleteCommand(int channelId, Method incomplete) - { - if ((channelId & ARRAY_SIZE) == channelId) - { - _incompleteMethodArray[channelId] = incomplete; - } - else - { - if(incomplete != null) - { - _incompleteMethodMap.put(channelId, incomplete); - } - else - { - _incompleteMethodMap.remove(channelId); - } - } - } - - private Method getIncompleteCommand(int channelId) - { - if ((channelId & ARRAY_SIZE) == channelId) - { - return _incompleteMethodArray[channelId]; - } - else - { - return _incompleteMethodMap.get(channelId); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/ConnectionBinding.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/ConnectionBinding.java deleted file mode 100644 index 5463cd2587..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/ConnectionBinding.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.network; - -import org.apache.qpid.transport.Binding; -import org.apache.qpid.transport.ByteBufferReceiver; -import org.apache.qpid.transport.ByteBufferSender; -import org.apache.qpid.transport.Connection; -import org.apache.qpid.transport.ConnectionDelegate; -import org.apache.qpid.transport.ConnectionListener; -import org.apache.qpid.transport.Constant; -import org.apache.qpid.transport.network.security.sasl.SASLReceiver; -import org.apache.qpid.transport.network.security.sasl.SASLSender; - -/** - * ConnectionBinding - * - */ - -public abstract class ConnectionBinding - implements Binding -{ - - public static Binding get(final Connection connection) - { - return new ConnectionBinding() - { - public Connection connection() - { - return connection; - } - }; - } - - public static Binding get(final ConnectionDelegate delegate) - { - return new ConnectionBinding() - { - public Connection connection() - { - Connection conn = new Connection(); - conn.setConnectionDelegate(delegate); - return conn; - } - }; - } - - public static final int MAX_FRAME_SIZE = 64 * 1024 - 1; - - public abstract Connection connection(); - - public Connection endpoint(ByteBufferSender sender) - { - Connection conn = connection(); - - if (conn.getConnectionSettings() != null && - conn.getConnectionSettings().isUseSASLEncryption()) - { - sender = new SASLSender(sender); - conn.addConnectionListener((ConnectionListener)sender); - } - - // XXX: hardcoded max-frame - Disassembler dis = new Disassembler(sender, Constant.MIN_MAX_FRAME_SIZE); - conn.addFrameSizeObserver(dis); - conn.setSender(dis); - return conn; - } - - public ByteBufferReceiver receiver(Connection conn) - { - final InputHandler inputHandler = new InputHandler(new Assembler(conn)); - conn.addFrameSizeObserver(inputHandler); - if (conn.getConnectionSettings() != null && - conn.getConnectionSettings().isUseSASLEncryption()) - { - SASLReceiver receiver = new SASLReceiver(inputHandler); - conn.addConnectionListener(receiver); - return receiver; - } - else - { - return inputHandler; - } - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Disassembler.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Disassembler.java deleted file mode 100644 index c45b2049a1..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Disassembler.java +++ /dev/null @@ -1,266 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.network; - -import static java.lang.Math.min; -import static org.apache.qpid.transport.network.Frame.FIRST_FRAME; -import static org.apache.qpid.transport.network.Frame.FIRST_SEG; -import static org.apache.qpid.transport.network.Frame.HEADER_SIZE; -import static org.apache.qpid.transport.network.Frame.LAST_FRAME; -import static org.apache.qpid.transport.network.Frame.LAST_SEG; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; - -import org.apache.qpid.transport.ByteBufferSender; -import org.apache.qpid.transport.FrameSizeObserver; -import org.apache.qpid.transport.Header; -import org.apache.qpid.transport.Method; -import org.apache.qpid.transport.ProtocolDelegate; -import org.apache.qpid.transport.ProtocolError; -import org.apache.qpid.transport.ProtocolEvent; -import org.apache.qpid.transport.ProtocolEventSender; -import org.apache.qpid.transport.ProtocolHeader; -import org.apache.qpid.transport.SegmentType; -import org.apache.qpid.transport.Struct; -import org.apache.qpid.transport.codec.BBEncoder; -import org.apache.qpid.transport.codec.Encoder; - -/** - * Disassembler - */ -public final class Disassembler implements ProtocolEventSender, ProtocolDelegate, FrameSizeObserver -{ - private final ByteBufferSender sender; - private int maxPayload; - private final Object sendlock = new Object(); - private final static ThreadLocal _encoder = new ThreadLocal() - { - public BBEncoder initialValue() - { - return new BBEncoder(4*1024); - } - }; - - public Disassembler(ByteBufferSender sender, int maxFrame) - { - this.sender = sender; - if (maxFrame <= HEADER_SIZE || maxFrame >= 64*1024) - { - throw new IllegalArgumentException("maxFrame must be > HEADER_SIZE and < 64K: " + maxFrame); - } - this.maxPayload = maxFrame - HEADER_SIZE; - } - - public void send(ProtocolEvent event) - { - event.delegate(null, this); - } - - public void flush() - { - synchronized (sendlock) - { - sender.flush(); - } - } - - public void close() - { - synchronized (sendlock) - { - sender.close(); - } - } - - private final ByteBuffer _frameHeader = ByteBuffer.allocate(HEADER_SIZE); - - { - _frameHeader.order(ByteOrder.BIG_ENDIAN); - } - - private void frame(byte flags, byte type, byte track, int channel, int size, ByteBuffer buf) - { - synchronized (sendlock) - { - ByteBuffer data = _frameHeader; - _frameHeader.rewind(); - - - data.put(0, flags); - data.put(1, type); - data.putShort(2, (short) (size + HEADER_SIZE)); - data.put(5, track); - data.putShort(6, (short) channel); - - - int limit = buf.limit(); - buf.limit(buf.position() + size); - - data.rewind(); - sender.send(data); - sender.send(buf); - buf.limit(limit); - - } - } - - private void fragment(byte flags, SegmentType type, ProtocolEvent event, ByteBuffer buf) - { - byte typeb = (byte) type.getValue(); - byte track = event.getEncodedTrack() == Frame.L4 ? (byte) 1 : (byte) 0; - - int remaining = buf.remaining(); - boolean first = true; - while (true) - { - int size = min(maxPayload, remaining); - remaining -= size; - - byte newflags = flags; - if (first) - { - newflags |= FIRST_FRAME; - first = false; - } - if (remaining == 0) - { - newflags |= LAST_FRAME; - } - - frame(newflags, typeb, track, event.getChannel(), size, buf); - - if (remaining == 0) - { - break; - } - } - } - - public void init(Void v, ProtocolHeader header) - { - synchronized (sendlock) - { - sender.send(header.toByteBuffer()); - sender.flush(); - } - } - - public void control(Void v, Method method) - { - method(method, SegmentType.CONTROL); - } - - public void command(Void v, Method method) - { - method(method, SegmentType.COMMAND); - } - - private void method(Method method, SegmentType type) - { - Encoder enc = _encoder.get(); - enc.init(); - enc.writeUint16(method.getEncodedType()); - if (type == SegmentType.COMMAND) - { - if (method.isSync()) - { - enc.writeUint16(0x0101); - } - else - { - enc.writeUint16(0x0100); - } - } - method.write(enc); - int methodLimit = enc.position(); - - byte flags = FIRST_SEG; - - boolean payload = method.hasPayload(); - if (!payload) - { - flags |= LAST_SEG; - } - - int headerLimit = -1; - if (payload) - { - final Header hdr = method.getHeader(); - if (hdr != null) - { - if(hdr.getDeliveryProperties() != null) - { - enc.writeStruct32(hdr.getDeliveryProperties()); - } - if(hdr.getMessageProperties() != null) - { - enc.writeStruct32(hdr.getMessageProperties()); - } - if(hdr.getNonStandardProperties() != null) - { - for (Struct st : hdr.getNonStandardProperties()) - { - enc.writeStruct32(st); - } - } - } - headerLimit = enc.position(); - } - - synchronized (sendlock) - { - ByteBuffer buf = enc.underlyingBuffer(); - buf.position(0); - buf.limit(methodLimit); - - fragment(flags, type, method, buf); - if (payload) - { - ByteBuffer body = method.getBody(); - buf.limit(headerLimit); - buf.position(methodLimit); - fragment(body == null ? LAST_SEG : 0x0, SegmentType.HEADER, method, buf); - if (body != null) - { - fragment(LAST_SEG, SegmentType.BODY, method, body); - } - - } - } - } - - public void error(Void v, ProtocolError error) - { - throw new IllegalArgumentException(String.valueOf(error)); - } - - @Override - public void setMaxFrameSize(final int maxFrame) - { - if (maxFrame <= HEADER_SIZE || maxFrame >= 64*1024) - { - throw new IllegalArgumentException("maxFrame must be > HEADER_SIZE and < 64K: " + maxFrame); - } - this.maxPayload = maxFrame - HEADER_SIZE; - - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Frame.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Frame.java deleted file mode 100644 index e810d9e8ae..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Frame.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.network; - -import static org.apache.qpid.transport.util.Functions.str; - -import java.nio.ByteBuffer; - -import org.apache.qpid.transport.SegmentType; - - -/** - * Frame - * - * @author Rafael H. Schloming - */ - -public final class Frame implements NetworkEvent -{ - public static final int HEADER_SIZE = 12; - - // XXX: enums? - public static final byte L1 = 0; - public static final byte L2 = 1; - public static final byte L3 = 2; - public static final byte L4 = 3; - - public static final byte RESERVED = 0x0; - - public static final byte VERSION = 0x0; - - public static final byte FIRST_SEG = 0x8; - public static final byte LAST_SEG = 0x4; - public static final byte FIRST_FRAME = 0x2; - public static final byte LAST_FRAME = 0x1; - - final private byte flags; - final private SegmentType type; - final private byte track; - final private int channel; - final private ByteBuffer body; - - public Frame(byte flags, SegmentType type, byte track, int channel, - ByteBuffer body) - { - this.flags = flags; - this.type = type; - this.track = track; - this.channel = channel; - this.body = body; - } - - public ByteBuffer getBody() - { - return body.slice(); - } - - public byte getFlags() - { - return flags; - } - - public int getChannel() - { - return channel; - } - - public int getSize() - { - return body.remaining(); - } - - public SegmentType getType() - { - return type; - } - - public byte getTrack() - { - return track; - } - - private boolean flag(byte mask) - { - return (flags & mask) != 0; - } - - public boolean isFirstSegment() - { - return flag(FIRST_SEG); - } - - public boolean isLastSegment() - { - return flag(LAST_SEG); - } - - public boolean isFirstFrame() - { - return flag(FIRST_FRAME); - } - - public boolean isLastFrame() - { - return flag(LAST_FRAME); - } - - public void delegate(NetworkDelegate delegate) - { - delegate.frame(this); - } - - public String toString() - { - StringBuilder str = new StringBuilder(); - - str.append(String.format - ("[%05d %05d %1d %s %d%d%d%d] ", getChannel(), getSize(), - getTrack(), getType(), - isFirstSegment() ? 1 : 0, isLastSegment() ? 1 : 0, - isFirstFrame() ? 1 : 0, isLastFrame() ? 1 : 0)); - - str.append(str(body)); - - return str.toString(); - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/IncomingNetworkTransport.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/IncomingNetworkTransport.java deleted file mode 100644 index f378c54026..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/IncomingNetworkTransport.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.network; - -import java.util.Set; - -import javax.net.ssl.SSLContext; - -import org.apache.qpid.protocol.ProtocolEngineFactory; -import org.apache.qpid.transport.NetworkTransportConfiguration; - -public interface IncomingNetworkTransport extends NetworkTransport -{ - public void accept(NetworkTransportConfiguration config, - ProtocolEngineFactory factory, - SSLContext sslContext, - final Set encryptionSet); - - public int getAcceptingPort(); -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/InputHandler.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/InputHandler.java deleted file mode 100644 index a58bed5877..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/InputHandler.java +++ /dev/null @@ -1,218 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.network; - -import static org.apache.qpid.transport.network.InputHandler.State.ERROR; -import static org.apache.qpid.transport.network.InputHandler.State.FRAME_BODY; -import static org.apache.qpid.transport.network.InputHandler.State.FRAME_HDR; -import static org.apache.qpid.transport.network.InputHandler.State.PROTO_HDR; -import static org.apache.qpid.transport.util.Functions.str; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; - -import org.apache.qpid.transport.ByteBufferReceiver; -import org.apache.qpid.transport.Constant; -import org.apache.qpid.transport.FrameSizeObserver; -import org.apache.qpid.transport.NetworkEventReceiver; -import org.apache.qpid.transport.ProtocolError; -import org.apache.qpid.transport.ProtocolHeader; -import org.apache.qpid.transport.SegmentType; - - -/** - * InputHandler - * - * @author Rafael H. Schloming - */ - -public class InputHandler implements ByteBufferReceiver, FrameSizeObserver -{ - - private int _maxFrameSize = Constant.MIN_MAX_FRAME_SIZE; - - public enum State - { - PROTO_HDR, - FRAME_HDR, - FRAME_BODY, - ERROR - } - - private final NetworkEventReceiver receiver; - private State state; - private ByteBuffer input = null; - private int needed; - - private byte flags; - private SegmentType type; - private byte track; - private int channel; - - public InputHandler(NetworkEventReceiver receiver, State state) - { - this.receiver = receiver; - this.state = state; - - switch (state) - { - case PROTO_HDR: - needed = 8; - break; - case FRAME_HDR: - needed = Frame.HEADER_SIZE; - break; - } - } - - public InputHandler(NetworkEventReceiver receiver) - { - this(receiver, PROTO_HDR); - } - - public void setMaxFrameSize(final int maxFrameSize) - { - _maxFrameSize = maxFrameSize; - } - - private void error(String fmt, Object ... args) - { - receiver.received(new ProtocolError(Frame.L1, fmt, args)); - } - - public void received(ByteBuffer buf) - { - int limit = buf.limit(); - int remaining = buf.remaining(); - while (remaining > 0) - { - if (remaining >= needed) - { - int consumed = needed; - int pos = buf.position(); - if (input == null) - { - buf.limit(pos + needed); - input = buf; - state = next(pos); - buf.limit(limit); - buf.position(pos + consumed); - } - else - { - buf.limit(pos + needed); - input.put(buf); - buf.limit(limit); - input.flip(); - state = next(0); - } - - remaining -= consumed; - input = null; - } - else - { - if (input == null) - { - input = ByteBuffer.allocate(needed); - } - input.put(buf); - needed -= remaining; - remaining = 0; - } - } - } - - private State next(int pos) - { - input.order(ByteOrder.BIG_ENDIAN); - - switch (state) { - case PROTO_HDR: - if (input.get(pos) != 'A' && - input.get(pos + 1) != 'M' && - input.get(pos + 2) != 'Q' && - input.get(pos + 3) != 'P') - { - error("bad protocol header: %s", str(input)); - return ERROR; - } - - byte protoClass = input.get(pos + 4); - byte instance = input.get(pos + 5); - byte major = input.get(pos + 6); - byte minor = input.get(pos + 7); - receiver.received(new ProtocolHeader(protoClass, instance, major, minor)); - needed = Frame.HEADER_SIZE; - return FRAME_HDR; - case FRAME_HDR: - flags = input.get(pos); - type = SegmentType.get(input.get(pos + 1)); - int size = (0xFFFF & input.getShort(pos + 2)); - size -= Frame.HEADER_SIZE; - _maxFrameSize = 64 * 1024; - if (size < 0 || size > (_maxFrameSize - 12)) - { - error("bad frame size: %d", size); - return ERROR; - } - byte b = input.get(pos + 5); - if ((b & 0xF0) != 0) { - error("non-zero reserved bits in upper nibble of " + - "frame header byte 5: '%x'", b); - return ERROR; - } else { - track = (byte) (b & 0xF); - } - channel = (0xFFFF & input.getShort(pos + 6)); - if (size == 0) - { - Frame frame = new Frame(flags, type, track, channel, ByteBuffer.allocate(0)); - receiver.received(frame); - needed = Frame.HEADER_SIZE; - return FRAME_HDR; - } - else - { - needed = size; - return FRAME_BODY; - } - case FRAME_BODY: - Frame frame = new Frame(flags, type, track, channel, input.slice()); - receiver.received(frame); - needed = Frame.HEADER_SIZE; - return FRAME_HDR; - default: - throw new IllegalStateException(); - } - } - - public void exception(Throwable t) - { - receiver.exception(t); - } - - public void closed() - { - receiver.closed(); - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/NetworkConnection.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/NetworkConnection.java deleted file mode 100644 index bef266f214..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/NetworkConnection.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.network; - -import java.net.SocketAddress; -import java.security.Principal; - -import org.apache.qpid.transport.ByteBufferSender; - -public interface NetworkConnection -{ - ByteBufferSender getSender(); - - void start(); - - void close(); - - /** - * @return the remote address of the underlying socket. - */ - SocketAddress getRemoteAddress(); - - /** - * @return the local address of the underlying socket. - */ - SocketAddress getLocalAddress(); - - void setMaxWriteIdle(int sec); - - void setMaxReadIdle(int sec); - - Principal getPeerPrincipal(); - - int getMaxReadIdle(); - - int getMaxWriteIdle(); -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/NetworkDelegate.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/NetworkDelegate.java deleted file mode 100644 index fbdfe6e84c..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/NetworkDelegate.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.network; - -import org.apache.qpid.transport.ProtocolError; -import org.apache.qpid.transport.ProtocolHeader; - - -/** - * NetworkDelegate - * - * @author Rafael H. Schloming - */ - -public interface NetworkDelegate -{ - - void init(ProtocolHeader header); - - void frame(Frame frame); - - void error(ProtocolError error); - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/NetworkEvent.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/NetworkEvent.java deleted file mode 100644 index 91314cd4ad..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/NetworkEvent.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.network; - - -/** - * NetworkEvent - * - */ - -public interface NetworkEvent -{ - - void delegate(NetworkDelegate delegate); - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/NetworkTransport.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/NetworkTransport.java deleted file mode 100644 index f71d39c381..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/NetworkTransport.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.network; - -/** - * A network transport is responsible for the establishment of network connections. - * NetworkTransport implementations are pluggable via the {@link Transport} class. - */ -public interface NetworkTransport -{ - public void close(); -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/OutgoingNetworkTransport.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/OutgoingNetworkTransport.java deleted file mode 100644 index f2735f1800..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/OutgoingNetworkTransport.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.network; - -import org.apache.qpid.transport.ByteBufferReceiver; -import org.apache.qpid.transport.ConnectionSettings; - -public interface OutgoingNetworkTransport extends NetworkTransport -{ - public NetworkConnection getConnection(); - - public NetworkConnection connect(ConnectionSettings settings, - ByteBufferReceiver delegate, - TransportActivity transportActivity); -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Ticker.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Ticker.java deleted file mode 100644 index 210b014a57..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Ticker.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.qpid.transport.network; - -public interface Ticker -{ - int getTimeToNextTick(long currentTime); - - int tick(long currentTime); -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Transport.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Transport.java deleted file mode 100644 index 55ba95ad75..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Transport.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.network; - -import org.apache.qpid.framing.ProtocolVersion; -import org.apache.qpid.transport.TransportException; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -public class Transport -{ - public static final String QPID_TRANSPORT_PROPNAME = "qpid.transport"; - public static final String QPID_TRANSPORT_V0_8_PROPNAME = "qpid.transport.v0_8"; - public static final String QPID_TRANSPORT_V0_9_PROPNAME = "qpid.transport.v0_9"; - public static final String QPID_TRANSPORT_V0_9_1_PROPNAME = "qpid.transport.v0_9_1"; - public static final String QPID_TRANSPORT_V0_10_PROPNAME = "qpid.transport.v0_10"; - public static final String QPID_BROKER_TRANSPORT_PROPNAME = "qpid.broker.transport"; - - // Can't reference the class directly here, as this would preclude the ability to bundle transports separately. - private static final String IO_TRANSPORT_CLASSNAME = "org.apache.qpid.transport.network.io.IoNetworkTransport"; - - public static final String TCP = "tcp"; - - private final static Map OUTGOING_PROTOCOL_TO_IMPLDEFAULTS_MAP; - - static - { - final Map map = new HashMap(); - map.put(ProtocolVersion.v8_0, IO_TRANSPORT_CLASSNAME); - map.put(ProtocolVersion.v0_9, IO_TRANSPORT_CLASSNAME); - map.put(ProtocolVersion.v0_91, IO_TRANSPORT_CLASSNAME); - map.put(ProtocolVersion.v0_10, IO_TRANSPORT_CLASSNAME); - - OUTGOING_PROTOCOL_TO_IMPLDEFAULTS_MAP = Collections.unmodifiableMap(map); - } - - private Transport() - { - } - - public static IncomingNetworkTransport getIncomingTransportInstance() - { - return (IncomingNetworkTransport) loadTransportClass( - System.getProperty(QPID_BROKER_TRANSPORT_PROPNAME, IO_TRANSPORT_CLASSNAME)); - } - - public static OutgoingNetworkTransport getOutgoingTransportInstance( - final ProtocolVersion protocolVersion) - { - - final String overrride = getOverrideClassNameFromSystemProperty(protocolVersion); - final String networkTransportClassName; - if (overrride != null) - { - networkTransportClassName = overrride; - } - else - { - networkTransportClassName = OUTGOING_PROTOCOL_TO_IMPLDEFAULTS_MAP.get(protocolVersion); - } - - return (OutgoingNetworkTransport) loadTransportClass(networkTransportClassName); - } - - private static NetworkTransport loadTransportClass(final String networkTransportClassName) - { - if (networkTransportClassName == null) - { - throw new IllegalArgumentException("transport class name must not be null"); - } - - try - { - final Class clazz = Class.forName(networkTransportClassName); - return (NetworkTransport) clazz.newInstance(); - } - catch (InstantiationException e) - { - throw new TransportException("Unable to instantiate transport class " + networkTransportClassName, e); - } - catch (IllegalAccessException e) - { - throw new TransportException("Access exception " + networkTransportClassName, e); - } - catch (ClassNotFoundException e) - { - throw new TransportException("Unable to load transport class " + networkTransportClassName, e); - } - } - - private static String getOverrideClassNameFromSystemProperty(final ProtocolVersion protocolVersion) - { - final String protocolSpecificSystemProperty; - - if (ProtocolVersion.v0_10.equals(protocolVersion)) - { - protocolSpecificSystemProperty = QPID_TRANSPORT_V0_10_PROPNAME; - } - else if (ProtocolVersion.v0_91.equals(protocolVersion)) - { - protocolSpecificSystemProperty = QPID_TRANSPORT_V0_9_1_PROPNAME; - } - else if (ProtocolVersion.v0_9.equals(protocolVersion)) - { - protocolSpecificSystemProperty = QPID_TRANSPORT_V0_9_PROPNAME; - } - else if (ProtocolVersion.v8_0.equals(protocolVersion)) - { - protocolSpecificSystemProperty = QPID_TRANSPORT_V0_8_PROPNAME; - } - else - { - throw new IllegalArgumentException("Unknown ProtocolVersion " + protocolVersion); - } - - return System.getProperty(protocolSpecificSystemProperty, System.getProperty(QPID_TRANSPORT_PROPNAME)); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/TransportActivity.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/TransportActivity.java deleted file mode 100644 index 2ee336d9b2..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/TransportActivity.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.qpid.transport.network; - -public interface TransportActivity -{ - long getLastReadTime(); - - long getLastWriteTime(); - - void writerIdle(); - - void readerIdle(); -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/TransportEncryption.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/TransportEncryption.java deleted file mode 100644 index b3f1f1c7dd..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/TransportEncryption.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.network; - -public enum TransportEncryption -{ - NONE, TLS -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/AbstractNetworkTransport.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/AbstractNetworkTransport.java deleted file mode 100644 index 8d19c5a2ce..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/AbstractNetworkTransport.java +++ /dev/null @@ -1,342 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.network.io; - -import java.io.IOException; -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.net.ServerSocket; -import java.net.Socket; -import java.net.SocketException; -import java.util.Set; - -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLServerSocket; -import javax.net.ssl.SSLServerSocketFactory; - -import org.slf4j.LoggerFactory; - -import org.apache.qpid.configuration.CommonProperties; -import org.apache.qpid.protocol.ProtocolEngine; -import org.apache.qpid.protocol.ProtocolEngineFactory; -import org.apache.qpid.transport.ByteBufferReceiver; -import org.apache.qpid.transport.ConnectionSettings; -import org.apache.qpid.transport.NetworkTransportConfiguration; -import org.apache.qpid.transport.TransportException; -import org.apache.qpid.transport.network.IncomingNetworkTransport; -import org.apache.qpid.transport.network.NetworkConnection; -import org.apache.qpid.transport.network.OutgoingNetworkTransport; -import org.apache.qpid.transport.network.TransportActivity; -import org.apache.qpid.transport.network.TransportEncryption; -import org.apache.qpid.transport.network.security.ssl.SSLUtil; - -// TODO we are no longer using the IncomingNetworkTransport -public abstract class AbstractNetworkTransport implements OutgoingNetworkTransport, IncomingNetworkTransport -{ - private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(AbstractNetworkTransport.class); - private static final int TIMEOUT = Integer.getInteger(CommonProperties.IO_NETWORK_TRANSPORT_TIMEOUT_PROP_NAME, - CommonProperties.IO_NETWORK_TRANSPORT_TIMEOUT_DEFAULT); - private static final int HANSHAKE_TIMEOUT = Integer.getInteger(CommonProperties.HANDSHAKE_TIMEOUT_PROP_NAME , - CommonProperties.HANDSHAKE_TIMEOUT_DEFAULT); - private Socket _socket; - private NetworkConnection _connection; - private AcceptingThread _acceptor; - - public NetworkConnection connect(ConnectionSettings settings, - ByteBufferReceiver delegate, - TransportActivity transportActivity) - { - int sendBufferSize = settings.getWriteBufferSize(); - int receiveBufferSize = settings.getReadBufferSize(); - - try - { - _socket = new Socket(); - _socket.setReuseAddress(true); - _socket.setTcpNoDelay(settings.isTcpNodelay()); - _socket.setSendBufferSize(sendBufferSize); - _socket.setReceiveBufferSize(receiveBufferSize); - - if(LOGGER.isDebugEnabled()) - { - LOGGER.debug("SO_RCVBUF : " + _socket.getReceiveBufferSize()); - LOGGER.debug("SO_SNDBUF : " + _socket.getSendBufferSize()); - LOGGER.debug("TCP_NODELAY : " + _socket.getTcpNoDelay()); - } - - InetAddress address = InetAddress.getByName(settings.getHost()); - - _socket.connect(new InetSocketAddress(address, settings.getPort()), settings.getConnectTimeout()); - } - catch (SocketException e) - { - throw new TransportException("Error connecting to broker", e); - } - catch (IOException e) - { - throw new TransportException("Error connecting to broker", e); - } - - try - { - IdleTimeoutTicker ticker = new IdleTimeoutTicker(transportActivity, TIMEOUT); - _connection = createNetworkConnection(_socket, delegate, sendBufferSize, receiveBufferSize, TIMEOUT, ticker); - ticker.setConnection(_connection); - _connection.start(); - } - catch(Exception e) - { - try - { - _socket.close(); - } - catch(IOException ioe) - { - //ignored, throw based on original exception - } - - throw new TransportException("Error creating network connection", e); - } - - return _connection; - } - - public void close() - { - if(_connection != null) - { - _connection.close(); - } - if(_acceptor != null) - { - _acceptor.close(); - } - } - - public NetworkConnection getConnection() - { - return _connection; - } - - public void accept(NetworkTransportConfiguration config, - ProtocolEngineFactory factory, - SSLContext sslContext, final Set encryptionSet) - { - try - { - _acceptor = new AcceptingThread(config, factory, sslContext); - _acceptor.setDaemon(false); - _acceptor.start(); - } - catch (IOException e) - { - throw new TransportException("Failed to start AMQP on port : " + config, e); - } - } - - public int getAcceptingPort() - { - return _acceptor == null ? -1 : _acceptor.getPort(); - } - - protected abstract NetworkConnection createNetworkConnection(Socket socket, - ByteBufferReceiver engine, - Integer sendBufferSize, - Integer receiveBufferSize, - int timeout, - IdleTimeoutTicker ticker); - - private class AcceptingThread extends Thread - { - private volatile boolean _closed = false; - private NetworkTransportConfiguration _config; - private ProtocolEngineFactory _factory; - private SSLContext _sslContext; - private ServerSocket _serverSocket; - private int _timeout; - - private AcceptingThread(NetworkTransportConfiguration config, - ProtocolEngineFactory factory, - SSLContext sslContext) throws IOException - { - _config = config; - _factory = factory; - _sslContext = sslContext; - _timeout = TIMEOUT; - - InetSocketAddress address = config.getAddress(); - - if(sslContext == null) - { - _serverSocket = new ServerSocket(); - } - else - { - SSLServerSocketFactory socketFactory = _sslContext.getServerSocketFactory(); - _serverSocket = socketFactory.createServerSocket(); - - SSLServerSocket sslServerSocket = (SSLServerSocket) _serverSocket; - - SSLUtil.removeSSLv3Support(sslServerSocket); - - if(config.needClientAuth()) - { - sslServerSocket.setNeedClientAuth(true); - } - else if(config.wantClientAuth()) - { - sslServerSocket.setWantClientAuth(true); - } - - } - - _serverSocket.setReuseAddress(true); - _serverSocket.bind(address); - } - - - /** - Close the underlying ServerSocket if it has not already been closed. - */ - public void close() - { - LOGGER.debug("Shutting down the Acceptor"); - _closed = true; - - if (!_serverSocket.isClosed()) - { - try - { - _serverSocket.close(); - } - catch (IOException e) - { - throw new TransportException(e); - } - } - } - - private int getPort() - { - return _serverSocket.getLocalPort(); - } - - @Override - public void run() - { - try - { - while (!_closed) - { - Socket socket = null; - try - { - socket = _serverSocket.accept(); - - ProtocolEngine engine = _factory.newProtocolEngine(socket.getRemoteSocketAddress()); - - if(engine != null) - { - socket.setTcpNoDelay(_config.getTcpNoDelay()); - socket.setSoTimeout(1000 * HANSHAKE_TIMEOUT); - - final Integer sendBufferSize = _config.getSendBufferSize(); - final Integer receiveBufferSize = _config.getReceiveBufferSize(); - - socket.setSendBufferSize(sendBufferSize); - socket.setReceiveBufferSize(receiveBufferSize); - - - final IdleTimeoutTicker ticker = new IdleTimeoutTicker(engine, TIMEOUT); - - NetworkConnection connection = - createNetworkConnection(socket, - engine, - sendBufferSize, - receiveBufferSize, - _timeout, - ticker); - - connection.setMaxReadIdle(HANSHAKE_TIMEOUT); - - ticker.setConnection(connection); - - engine.setNetworkConnection(connection, connection.getSender()); - - connection.start(); - } - else - { - socket.close(); - } - } - catch(RuntimeException e) - { - LOGGER.error("Error in Acceptor thread on address " + _config.getAddress(), e); - closeSocketIfNecessary(socket); - } - catch(IOException e) - { - if(!_closed) - { - LOGGER.error("Error in Acceptor thread on address " + _config.getAddress(), e); - closeSocketIfNecessary(socket); - try - { - //Delay to avoid tight spinning the loop during issues such as too many open files - Thread.sleep(1000); - } - catch (InterruptedException ie) - { - LOGGER.debug("Stopping acceptor due to interrupt request"); - _closed = true; - } - } - } - } - } - finally - { - if(LOGGER.isDebugEnabled()) - { - LOGGER.debug("Acceptor exiting, no new connections will be accepted on address " - + _config.getAddress()); - } - } - } - - private void closeSocketIfNecessary(final Socket socket) - { - if(socket != null) - { - try - { - socket.close(); - } - catch (IOException e) - { - LOGGER.debug("Exception while closing socket", e); - } - } - } - - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IdleTimeoutTicker.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IdleTimeoutTicker.java deleted file mode 100644 index 71704fca3a..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IdleTimeoutTicker.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.qpid.transport.network.io; - -import org.apache.qpid.transport.network.NetworkConnection; -import org.apache.qpid.transport.network.Ticker; -import org.apache.qpid.transport.network.TransportActivity; - -public class IdleTimeoutTicker implements Ticker -{ - private final TransportActivity _transport; - private final int _defaultTimeout; - private NetworkConnection _connection; - - public IdleTimeoutTicker(TransportActivity transport, int defaultTimeout) - { - _transport = transport; - _defaultTimeout = defaultTimeout; - } - - @Override - public int getTimeToNextTick(long currentTime) - { - long nextTime = -1; - final long maxReadIdle = 1000l * _connection.getMaxReadIdle(); - - if(maxReadIdle > 0) - { - nextTime = _transport.getLastReadTime() + maxReadIdle; - } - - long maxWriteIdle = 1000l * _connection.getMaxWriteIdle(); - - if(maxWriteIdle > 0) - { - long writeTime = _transport.getLastWriteTime() + maxWriteIdle; - if(nextTime == -1l || writeTime < nextTime) - { - nextTime = writeTime; - } - } - return nextTime == -1 ? _defaultTimeout : (int) (nextTime - currentTime); - } - - @Override - public int tick(long currentTime) - { - // writer Idle - long maxWriteIdle = 1000l * _connection.getMaxWriteIdle(); - if(maxWriteIdle > 0 && maxWriteIdle+ _transport.getLastWriteTime() <= currentTime) - { - _transport.writerIdle(); - } - // reader Idle - final long maxReadIdle = 1000l * _connection.getMaxReadIdle(); - if(maxReadIdle > 0 && maxReadIdle+ _transport.getLastReadTime() <= currentTime) - { - - _transport.readerIdle(); - } - return getTimeToNextTick(currentTime); - } - - public void setConnection(NetworkConnection connection) - { - _connection = connection; - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoNetworkConnection.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoNetworkConnection.java deleted file mode 100644 index 5008849ef3..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoNetworkConnection.java +++ /dev/null @@ -1,146 +0,0 @@ -/* -* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.network.io; - -import java.net.Socket; -import java.net.SocketAddress; -import java.security.Principal; - -import javax.net.ssl.SSLPeerUnverifiedException; -import javax.net.ssl.SSLSocket; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.apache.qpid.transport.ByteBufferReceiver; -import org.apache.qpid.transport.ByteBufferSender; -import org.apache.qpid.transport.network.NetworkConnection; -import org.apache.qpid.transport.network.Ticker; - -public class IoNetworkConnection implements NetworkConnection -{ - private static final Logger LOGGER = LoggerFactory.getLogger(IoNetworkConnection.class); - private final Socket _socket; - private final long _timeout; - private final IoSender _ioSender; - private final IoReceiver _ioReceiver; - private int _maxReadIdle; - private int _maxWriteIdle; - private Principal _principal; - private boolean _principalChecked; - private final Object _lock = new Object(); - - public IoNetworkConnection(Socket socket, ByteBufferReceiver delegate, - int sendBufferSize, int receiveBufferSize, long timeout, Ticker ticker) - { - _socket = socket; - _timeout = timeout; - - _ioReceiver = new IoReceiver(_socket, delegate, receiveBufferSize,_timeout); - _ioReceiver.setTicker(ticker); - - _ioSender = new IoSender(_socket, 2 * sendBufferSize, _timeout); - - _ioSender.setReceiver(_ioReceiver); - - } - - public void start() - { - _ioSender.initiate(); - _ioReceiver.initiate(); - } - - public ByteBufferSender getSender() - { - return _ioSender; - } - - public void close() - { - try - { - _ioSender.close(); - } - finally - { - _ioReceiver.close(false); - } - } - - public SocketAddress getRemoteAddress() - { - return _socket.getRemoteSocketAddress(); - } - - public SocketAddress getLocalAddress() - { - return _socket.getLocalSocketAddress(); - } - - public void setMaxWriteIdle(int sec) - { - _maxWriteIdle = sec; - } - - public void setMaxReadIdle(int sec) - { - _maxReadIdle = sec; - } - - @Override - public Principal getPeerPrincipal() - { - synchronized (_lock) - { - if(!_principalChecked) - { - if(_socket instanceof SSLSocket) - { - try - { - _principal = ((SSLSocket) _socket).getSession().getPeerPrincipal(); - } - catch(SSLPeerUnverifiedException e) - { - _principal = null; - } - } - - _principalChecked = true; - } - - return _principal; - } - } - - @Override - public int getMaxReadIdle() - { - return _maxReadIdle; - } - - @Override - public int getMaxWriteIdle() - { - return _maxWriteIdle; - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoNetworkTransport.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoNetworkTransport.java deleted file mode 100644 index ccab1d93cf..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoNetworkTransport.java +++ /dev/null @@ -1,43 +0,0 @@ -/* -* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.network.io; - -import java.net.Socket; - -import org.apache.qpid.transport.ByteBufferReceiver; - -public class IoNetworkTransport extends AbstractNetworkTransport -{ - - - @Override - protected IoNetworkConnection createNetworkConnection(final Socket socket, - final ByteBufferReceiver engine, - final Integer sendBufferSize, - final Integer receiveBufferSize, - final int timeout, - final IdleTimeoutTicker ticker) - { - return new IoNetworkConnection(socket, engine, sendBufferSize, receiveBufferSize, timeout, - ticker); - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoReceiver.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoReceiver.java deleted file mode 100644 index 790583e92b..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoReceiver.java +++ /dev/null @@ -1,265 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.network.io; - -import java.io.IOException; -import java.io.InputStream; -import java.net.Socket; -import java.net.SocketException; -import java.net.SocketTimeoutException; -import java.nio.ByteBuffer; -import java.util.concurrent.atomic.AtomicBoolean; - -import javax.net.ssl.SSLSocket; - -import org.apache.qpid.thread.Threading; -import org.apache.qpid.transport.ByteBufferReceiver; -import org.apache.qpid.transport.TransportException; -import org.apache.qpid.transport.network.Ticker; -import org.apache.qpid.transport.util.Logger; -import org.apache.qpid.util.SystemUtils; - -/** - * IoReceiver - * - */ - -final class IoReceiver implements Runnable -{ - - private static final Logger log = Logger.get(IoReceiver.class); - - private final ByteBufferReceiver receiver; - private final int bufferSize; - private final Socket socket; - private final long timeout; - private final AtomicBoolean closed = new AtomicBoolean(false); - private final Thread receiverThread; - private static final boolean shutdownBroken; - - private Ticker _ticker; - static - { - shutdownBroken = SystemUtils.isWindows(); - } - - public IoReceiver(Socket socket, ByteBufferReceiver receiver, int bufferSize, long timeout) - { - this.receiver = receiver; - this.bufferSize = bufferSize; - this.socket = socket; - this.timeout = timeout; - - try - { - //Create but deliberately don't start the thread. - receiverThread = Threading.getThreadFactory().createThread(this); - } - catch(Exception e) - { - throw new RuntimeException("Error creating IOReceiver thread",e); - } - receiverThread.setDaemon(true); - receiverThread.setName(String.format("IoReceiver-%s", socket.getRemoteSocketAddress())); - } - - public void initiate() - { - receiverThread.start(); - } - - public void close() - { - close(false); - } - - void close(boolean block) - { - if (!closed.getAndSet(true)) - { - try - { - try - { - if (shutdownBroken || socket instanceof SSLSocket) - { - socket.close(); - } - else - { - socket.shutdownInput(); - } - } - catch(SocketException se) - { - if(!socket.isClosed() && !socket.isInputShutdown()) - { - throw se; - } - } - if (block && Thread.currentThread() != receiverThread) - { - receiverThread.join(timeout); - if (receiverThread.isAlive()) - { - throw new TransportException("join timed out"); - } - } - } - catch (InterruptedException e) - { - throw new TransportException(e); - } - catch (IOException e) - { - throw new TransportException(e); - } - - } - } - - public void run() - { - final int threshold = bufferSize / 2; - - // I set the read buffer size similar to SO_RCVBUF - // Haven't tested with a lower value to see if it's better or worse - byte[] buffer = new byte[bufferSize]; - try - { - InputStream in = socket.getInputStream(); - int read = 0; - int offset = 0; - long currentTime; - while(read != -1) - { - try - { - while ((read = in.read(buffer, offset, bufferSize-offset)) != -1) - { - if (read > 0) - { - ByteBuffer b = ByteBuffer.wrap(buffer,offset,read); - receiver.received(b); - offset+=read; - if (offset > threshold) - { - offset = 0; - buffer = new byte[bufferSize]; - } - } - currentTime = System.currentTimeMillis(); - - if(_ticker != null) - { - int tick = _ticker.getTimeToNextTick(currentTime); - if(tick <= 0) - { - tick = _ticker.tick(currentTime); - } - try - { - if(!socket.isClosed()) - { - socket.setSoTimeout(tick <= 0 ? 1 : tick); - } - } - catch(SocketException e) - { - // ignore - closed socket - } - } - } - } - catch (SocketTimeoutException e) - { - currentTime = System.currentTimeMillis(); - if(_ticker != null) - { - final int tick = _ticker.tick(currentTime); - if(!socket.isClosed()) - { - try - { - socket.setSoTimeout(tick <= 0 ? 1 : tick ); - } - catch(SocketException ex) - { - // ignore - closed socket - } - } - } - } - } - } - catch (Exception t) - { - if (shouldReport(t)) - { - receiver.exception(t); - } - } - finally - { - receiver.closed(); - try - { - socket.close(); - } - catch(Exception e) - { - log.warn(e, "Error closing socket"); - } - } - } - - private boolean shouldReport(Throwable t) - { - boolean brokenClose = closed.get() && - shutdownBroken && - t instanceof SocketException && - "socket closed".equalsIgnoreCase(t.getMessage()); - - boolean sslSocketClosed = closed.get() && - socket instanceof SSLSocket && - t instanceof SocketException && - "Socket is closed".equalsIgnoreCase(t.getMessage()); - - boolean recvFailed = closed.get() && - shutdownBroken && - t instanceof SocketException && - "Socket operation on nonsocket: recv failed".equalsIgnoreCase(t.getMessage()); - - return !brokenClose && !sslSocketClosed && !recvFailed; - } - - public Ticker getTicker() - { - return _ticker; - } - - public void setTicker(Ticker ticker) - { - _ticker = ticker; - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoSender.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoSender.java deleted file mode 100644 index cd01cddb05..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoSender.java +++ /dev/null @@ -1,373 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.qpid.transport.network.io; - -import static org.apache.qpid.transport.util.Functions.mod; - -import java.io.IOException; -import java.io.OutputStream; -import java.net.Socket; -import java.nio.ByteBuffer; -import java.util.concurrent.atomic.AtomicBoolean; - -import javax.net.ssl.SSLSocket; - -import org.apache.qpid.thread.Threading; -import org.apache.qpid.transport.ByteBufferSender; -import org.apache.qpid.transport.SenderClosedException; -import org.apache.qpid.transport.SenderException; -import org.apache.qpid.transport.TransportException; -import org.apache.qpid.transport.util.Logger; -import org.apache.qpid.util.SystemUtils; - - -public final class IoSender implements Runnable, ByteBufferSender -{ - - private static final Logger log = Logger.get(IoSender.class); - - // by starting here, we ensure that we always test the wraparound - // case, we should probably make this configurable somehow so that - // we can test other cases as well - private final static int START = Integer.MAX_VALUE - 10; - - private final long timeout; - private final Socket socket; - private final OutputStream out; - - private final byte[] buffer; - private volatile int head = START; - private volatile int tail = START; - private volatile boolean idle = true; - private final Object notFull = new Object(); - private final Object notEmpty = new Object(); - private final AtomicBoolean closed = new AtomicBoolean(false); - private final Thread senderThread; - private IoReceiver _receiver; - private final String _remoteSocketAddress; - private static final boolean shutdownBroken; - - static - { - shutdownBroken = SystemUtils.isWindows(); - } - - private volatile Throwable exception = null; - - public IoSender(Socket socket, int bufferSize, long timeout) - { - this.socket = socket; - this.buffer = new byte[pof2(bufferSize)]; // buffer size must be a power of 2 - this.timeout = timeout; - _remoteSocketAddress = socket.getRemoteSocketAddress().toString(); - - try - { - out = socket.getOutputStream(); - } - catch (IOException e) - { - throw new TransportException("Error getting output stream for socket", e); - } - - try - { - //Create but deliberately don't start the thread. - senderThread = Threading.getThreadFactory().createThread(this); - } - catch(Exception e) - { - throw new Error("Error creating IOSender thread",e); - } - - senderThread.setDaemon(true); - senderThread.setName(String.format("IoSender-%s", _remoteSocketAddress)); - } - - public void initiate() - { - senderThread.start(); - } - - private static final int pof2(int n) - { - int result = 1; - while (result < n) - { - result *= 2; - } - return result; - } - - public void send(ByteBuffer buf) - { - checkNotAlreadyClosed(); - - if(!senderThread.isAlive()) - { - throw new SenderException(String.format("sender thread for socket %s is not alive", _remoteSocketAddress)); - } - - final int size = buffer.length; - int remaining = buf.remaining(); - - while (remaining > 0) - { - final int hd = head; - final int tl = tail; - - if (hd - tl >= size) - { - flush(); - synchronized (notFull) - { - final long start = System.currentTimeMillis(); - long elapsed = 0; - while (!closed.get() && head - tail >= size && elapsed < timeout) - { - try - { - notFull.wait(timeout - elapsed); - } - catch (InterruptedException e) - { - // pass - } - elapsed = System.currentTimeMillis() - start; - } - - checkNotAlreadyClosed(); - - if (head - tail >= size) - { - try - { - log.error("write timed out for socket %s: head %d, tail %d", _remoteSocketAddress, head, tail); - throw new SenderException(String.format("write timed out for socket %s: head %d, tail %d", _remoteSocketAddress, head, tail)); - } - finally - { - close(false, false); - } - } - } - continue; - } - - final int hd_idx = mod(hd, size); - final int tl_idx = mod(tl, size); - final int length; - - if (tl_idx > hd_idx) - { - length = Math.min(tl_idx - hd_idx, remaining); - } - else - { - length = Math.min(size - hd_idx, remaining); - } - - buf.get(buffer, hd_idx, length); - head += length; - remaining -= length; - } - } - - public void flush() - { - if (idle) - { - synchronized (notEmpty) - { - notEmpty.notify(); - } - } - } - - public void close() - { - close(true, true); - } - - private void close(boolean awaitSenderBeforeClose, boolean reportException) - { - if (!closed.getAndSet(true)) - { - synchronized (notFull) - { - notFull.notify(); - } - - synchronized (notEmpty) - { - notEmpty.notify(); - } - - try - { - if (awaitSenderBeforeClose) - { - awaitSenderThreadShutdown(); - } - } - finally - { - closeReceiver(); - } - if (reportException && exception != null) - { - throw new SenderException(exception); - } - } - } - - private void closeReceiver() - { - if(_receiver != null) - { - try - { - _receiver.close(); - } - catch(RuntimeException e) - { - log.error(e, "Exception closing receiver for socket %s", _remoteSocketAddress); - throw new SenderException(e.getMessage(), e); - } - } - } - - public void run() - { - final int size = buffer.length; - while (true) - { - final int hd = head; - final int tl = tail; - - if (hd == tl) - { - if (closed.get()) - { - break; - } - - idle = true; - - synchronized (notEmpty) - { - while (head == tail && !closed.get()) - { - try - { - notEmpty.wait(); - } - catch (InterruptedException e) - { - // pass - } - } - } - - idle = false; - - continue; - } - - final int hd_idx = mod(hd, size); - final int tl_idx = mod(tl, size); - - final int length; - if (tl_idx < hd_idx) - { - length = hd_idx - tl_idx; - } - else - { - length = size - tl_idx; - } - - try - { - out.write(buffer, tl_idx, length); - } - catch (IOException e) - { - log.info("Exception in thread sending to '" + _remoteSocketAddress + "': " + e); - exception = e; - close(false, false); - break; - } - tail += length; - if (head - tl >= size) - { - synchronized (notFull) - { - notFull.notify(); - } - } - } - - if (!shutdownBroken && !(socket instanceof SSLSocket)) - { - try - { - socket.shutdownOutput(); - } - catch (IOException e) - { - //pass - } - } - } - - public void setReceiver(IoReceiver receiver) - { - _receiver = receiver; - } - - private void awaitSenderThreadShutdown() - { - if (Thread.currentThread() != senderThread) - { - try - { - senderThread.join(timeout); - if (senderThread.isAlive()) - { - log.error("join timed out for socket %s to stop", _remoteSocketAddress); - throw new SenderException(String.format("join timed out for socket %s to stop", _remoteSocketAddress)); - } - } - catch (InterruptedException e) - { - log.error("interrupted whilst waiting for sender thread for socket %s to stop", _remoteSocketAddress); - throw new SenderException(e); - } - } - } - - private void checkNotAlreadyClosed() - { - if (closed.get()) - { - throw new SenderClosedException(String.format("sender for socket %s is closed", _remoteSocketAddress), exception); - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/SSLStatus.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/SSLStatus.java deleted file mode 100644 index 9db7dd557a..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/SSLStatus.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.qpid.transport.network.security; - -import java.util.concurrent.atomic.AtomicBoolean; - -public class SSLStatus -{ - private final Object _sslLock = new Object(); - private final AtomicBoolean _sslErrorFlag = new AtomicBoolean(false); - - /** - * Lock used to coordinate the SSL sender with the SSL receiver. - * - * @return lock - */ - public Object getSslLock() - { - return _sslLock; - } - - public boolean getSslErrorFlag() - { - return _sslErrorFlag.get(); - } - - public void setSslErrorFlag() - { - _sslErrorFlag.set(true); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/SecurityLayer.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/SecurityLayer.java deleted file mode 100644 index 271135f411..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/SecurityLayer.java +++ /dev/null @@ -1,34 +0,0 @@ -/* -* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.network.security; - -import org.apache.qpid.transport.ByteBufferReceiver; -import org.apache.qpid.transport.ByteBufferSender; - -public interface SecurityLayer -{ - - public ByteBufferSender sender(ByteBufferSender delegate); - public ByteBufferReceiver receiver(ByteBufferReceiver delegate); - public String getUserID(); - -} - diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/SecurityLayerFactory.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/SecurityLayerFactory.java deleted file mode 100644 index d25e97ffe4..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/SecurityLayerFactory.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.network.security; - -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLEngine; - -import org.apache.qpid.ssl.SSLContextFactory; -import org.apache.qpid.transport.ByteBufferReceiver; -import org.apache.qpid.transport.ByteBufferSender; -import org.apache.qpid.transport.ConnectionSettings; -import org.apache.qpid.transport.TransportException; -import org.apache.qpid.transport.network.security.sasl.SASLReceiver; -import org.apache.qpid.transport.network.security.sasl.SASLSender; -import org.apache.qpid.transport.network.security.ssl.SSLReceiver; -import org.apache.qpid.transport.network.security.ssl.SSLSender; -import org.apache.qpid.transport.network.security.ssl.SSLUtil; - -public class SecurityLayerFactory -{ - private SecurityLayerFactory() - { - } - - public static SecurityLayer newInstance(ConnectionSettings settings) - { - - SecurityLayer layer = NullSecurityLayer.getInstance(); - - if (settings.isUseSSL()) - { - layer = new SSLSecurityLayer(settings, layer); - } - if (settings.isUseSASLEncryption()) - { - layer = new SASLSecurityLayer(layer); - } - - return layer; - - } - - static class SSLSecurityLayer implements SecurityLayer - { - - private final SSLEngine _engine; - private final SSLStatus _sslStatus = new SSLStatus(); - private String _hostname; - private SecurityLayer _layer; - - - public SSLSecurityLayer(ConnectionSettings settings, SecurityLayer layer) - { - - SSLContext sslCtx; - _layer = layer; - try - { - sslCtx = SSLContextFactory - .buildClientContext(settings.getTrustStorePath(), - settings.getTrustStorePassword(), - settings.getTrustStoreType(), - settings.getTrustManagerFactoryAlgorithm(), - settings.getKeyStorePath(), - settings.getKeyStorePassword(), - settings.getKeyStoreType(), - settings.getKeyManagerFactoryAlgorithm(), - settings.getCertAlias()); - } - catch (Exception e) - { - throw new TransportException("Error creating SSL Context", e); - } - - if(settings.isVerifyHostname()) - { - _hostname = settings.getHost(); - } - - try - { - _engine = sslCtx.createSSLEngine(); - _engine.setUseClientMode(true); - SSLUtil.removeSSLv3Support(_engine); - } - catch(Exception e) - { - throw new TransportException("Error creating SSL Engine", e); - } - - } - - public ByteBufferSender sender(ByteBufferSender delegate) - { - SSLSender sender = new SSLSender(_engine, _layer.sender(delegate), _sslStatus); - sender.setHostname(_hostname); - return sender; - } - - public ByteBufferReceiver receiver(ByteBufferReceiver delegate) - { - SSLReceiver receiver = new SSLReceiver(_engine, _layer.receiver(delegate), _sslStatus); - receiver.setHostname(_hostname); - return receiver; - } - - public String getUserID() - { - return SSLUtil.retrieveIdentity(_engine); - } - } - - - static class SASLSecurityLayer implements SecurityLayer - { - - private SecurityLayer _layer; - - SASLSecurityLayer(SecurityLayer layer) - { - _layer = layer; - } - - public SASLSender sender(ByteBufferSender delegate) - { - SASLSender sender = new SASLSender(_layer.sender(delegate)); - return sender; - } - - public SASLReceiver receiver(ByteBufferReceiver delegate) - { - SASLReceiver receiver = new SASLReceiver(_layer.receiver(delegate)); - return receiver; - } - - public String getUserID() - { - return _layer.getUserID(); - } - } - - - static class NullSecurityLayer implements SecurityLayer - { - - private static final NullSecurityLayer INSTANCE = new NullSecurityLayer(); - - private NullSecurityLayer() - { - } - - public ByteBufferSender sender(ByteBufferSender delegate) - { - return delegate; - } - - public ByteBufferReceiver receiver(ByteBufferReceiver delegate) - { - return delegate; - } - - public String getUserID() - { - return null; - } - - public static NullSecurityLayer getInstance() - { - return INSTANCE; - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLEncryptor.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLEncryptor.java deleted file mode 100644 index 5ef94b7d13..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLEncryptor.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.network.security.sasl; - - -import java.util.List; - -import javax.security.sasl.Sasl; -import javax.security.sasl.SaslClient; - -import org.apache.qpid.transport.Connection; -import org.apache.qpid.transport.ConnectionException; -import org.apache.qpid.transport.ConnectionListener; - -public abstract class SASLEncryptor implements ConnectionListener -{ - private SaslClient saslClient; - private boolean securityLayerEstablished = false; - private int sendBuffSize; - private int recvBuffSize; - - public boolean isSecurityLayerEstablished() - { - return securityLayerEstablished; - } - - public void opened(Connection conn) - { - if (conn.getSaslClient() != null) - { - saslClient = conn.getSaslClient(); - if (saslClient.isComplete() && "auth-conf".equals(saslClient.getNegotiatedProperty(Sasl.QOP))) - { - sendBuffSize = Integer.parseInt( - (String)saslClient.getNegotiatedProperty(Sasl.RAW_SEND_SIZE)); - recvBuffSize = Integer.parseInt( - (String)saslClient.getNegotiatedProperty(Sasl.MAX_BUFFER)); - securityLayerEstablished(); - securityLayerEstablished = true; - } - } - } - - @Override - public boolean redirect(final String host, final List knownHosts) - { - return false; - } - - public void exception(Connection conn, ConnectionException exception){} - public void closed(Connection conn) {} - - public abstract void securityLayerEstablished(); - - public SaslClient getSaslClient() - { - return saslClient; - } - - public int getSendBuffSize() - { - return sendBuffSize; - } - - public int getRecvBuffSize() - { - return recvBuffSize; - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLReceiver.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLReceiver.java deleted file mode 100644 index 983e3bdf90..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLReceiver.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.network.security.sasl; - - -import java.nio.ByteBuffer; - -import javax.security.sasl.SaslException; - -import org.apache.qpid.transport.ByteBufferReceiver; -import org.apache.qpid.transport.SenderException; -import org.apache.qpid.transport.util.Logger; - -public class SASLReceiver extends SASLEncryptor implements ByteBufferReceiver { - - private ByteBufferReceiver delegate; - private byte[] netData; - private static final Logger log = Logger.get(SASLReceiver.class); - - public SASLReceiver(ByteBufferReceiver delegate) - { - this.delegate = delegate; - } - - public void closed() - { - delegate.closed(); - } - - - public void exception(Throwable t) - { - delegate.exception(t); - } - - public void received(ByteBuffer buf) - { - if (isSecurityLayerEstablished()) - { - while (buf.hasRemaining()) - { - int length = Math.min(buf.remaining(), getRecvBuffSize()); - buf.get(netData, 0, length); - try - { - byte[] out = getSaslClient().unwrap(netData, 0, length); - delegate.received(ByteBuffer.wrap(out)); - } - catch (SaslException e) - { - throw new SenderException("SASL Sender, Error occurred while encrypting data",e); - } - } - } - else - { - delegate.received(buf); - } - } - - public void securityLayerEstablished() - { - netData = new byte[getRecvBuffSize()]; - log.debug("SASL Security Layer Established"); - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLSender.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLSender.java deleted file mode 100644 index 335f8992ca..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLSender.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.network.security.sasl; - - -import java.nio.ByteBuffer; -import java.util.concurrent.atomic.AtomicBoolean; - -import javax.security.sasl.SaslException; - -import org.apache.qpid.transport.ByteBufferSender; -import org.apache.qpid.transport.SenderException; -import org.apache.qpid.transport.util.Logger; - -public class SASLSender extends SASLEncryptor implements ByteBufferSender -{ - - private ByteBufferSender delegate; - private byte[] appData; - private final AtomicBoolean closed = new AtomicBoolean(false); - private static final Logger log = Logger.get(SASLSender.class); - - public SASLSender(ByteBufferSender delegate) - { - this.delegate = delegate; - log.debug("SASL Sender enabled"); - } - - public void close() - { - - if (!closed.getAndSet(true)) - { - delegate.close(); - if (isSecurityLayerEstablished()) - { - try - { - getSaslClient().dispose(); - } - catch (SaslException e) - { - throw new SenderException("Error closing SASL Sender",e); - } - } - } - } - - public void flush() - { - delegate.flush(); - } - - public void send(ByteBuffer buf) - { - if (closed.get()) - { - throw new SenderException("SSL Sender is closed"); - } - - if (isSecurityLayerEstablished()) - { - while (buf.hasRemaining()) - { - int length = Math.min(buf.remaining(), getSendBuffSize()); - log.debug("sendBuffSize %s", getSendBuffSize()); - log.debug("buf.remaining() %s", buf.remaining()); - - buf.get(appData, 0, length); - try - { - byte[] out = getSaslClient().wrap(appData, 0, length); - log.debug("out.length %s", out.length); - - delegate.send(ByteBuffer.wrap(out)); - } - catch (SaslException e) - { - log.error("Exception while encrypting data.",e); - throw new SenderException("SASL Sender, Error occurred while encrypting data",e); - } - } - } - else - { - delegate.send(buf); - } - } - - public void securityLayerEstablished() - { - appData = new byte[getSendBuffSize()]; - log.debug("SASL Security Layer Established"); - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/QpidClientX509KeyManager.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/QpidClientX509KeyManager.java deleted file mode 100644 index c61684e2bb..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/QpidClientX509KeyManager.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.network.security.ssl; - -import org.apache.qpid.transport.util.Logger; - -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.SSLEngine; -import javax.net.ssl.X509ExtendedKeyManager; -import java.io.IOException; -import java.net.Socket; -import java.net.URL; -import java.security.GeneralSecurityException; -import java.security.KeyStore; -import java.security.Principal; -import java.security.PrivateKey; -import java.security.cert.X509Certificate; - -public class QpidClientX509KeyManager extends X509ExtendedKeyManager -{ - private static final Logger log = Logger.get(QpidClientX509KeyManager.class); - - private X509ExtendedKeyManager delegate; - private String alias; - - public QpidClientX509KeyManager(String alias, String keyStorePath, String keyStoreType, - String keyStorePassword, String keyManagerFactoryAlgorithmName) throws GeneralSecurityException, IOException - { - this.alias = alias; - KeyStore ks = SSLUtil.getInitializedKeyStore(keyStorePath,keyStorePassword,keyStoreType); - KeyManagerFactory kmf = KeyManagerFactory.getInstance(keyManagerFactoryAlgorithmName); - kmf.init(ks, keyStorePassword.toCharArray()); - this.delegate = (X509ExtendedKeyManager)kmf.getKeyManagers()[0]; - } - - public QpidClientX509KeyManager(String alias, URL keyStoreUrl, String keyStoreType, - String keyStorePassword, String keyManagerFactoryAlgorithmName) throws GeneralSecurityException, IOException - { - this.alias = alias; - KeyStore ks = SSLUtil.getInitializedKeyStore(keyStoreUrl,keyStorePassword,keyStoreType); - KeyManagerFactory kmf = KeyManagerFactory.getInstance(keyManagerFactoryAlgorithmName); - kmf.init(ks, keyStorePassword.toCharArray()); - this.delegate = (X509ExtendedKeyManager)kmf.getKeyManagers()[0]; - } - - public String chooseClientAlias(String[] keyType, Principal[] issuers, Socket socket) - { - log.debug("chooseClientAlias:Returning alias " + alias); - return alias; - } - - public String chooseServerAlias(String keyType, Principal[] issuers, Socket socket) - { - return delegate.chooseServerAlias(keyType, issuers, socket); - } - - public X509Certificate[] getCertificateChain(String alias) - { - return delegate.getCertificateChain(alias); - } - - public String[] getClientAliases(String keyType, Principal[] issuers) - { - log.debug("getClientAliases:Returning alias " + alias); - return new String[]{alias}; - } - - public PrivateKey getPrivateKey(String alias) - { - return delegate.getPrivateKey(alias); - } - - public String[] getServerAliases(String keyType, Principal[] issuers) - { - return delegate.getServerAliases(keyType, issuers); - } - - public String chooseEngineClientAlias(String[] keyType, Principal[] issuers, SSLEngine engine) - { - log.debug("chooseEngineClientAlias:Returning alias " + alias); - return alias; - } - - public String chooseEngineServerAlias(String keyType, Principal[] issuers, SSLEngine engine) - { - return delegate.chooseEngineServerAlias(keyType, issuers, engine); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/QpidMultipleTrustManager.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/QpidMultipleTrustManager.java deleted file mode 100644 index 0705f31fcb..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/QpidMultipleTrustManager.java +++ /dev/null @@ -1,103 +0,0 @@ -/* -* -* Licensed to the Apache Software Foundation (ASF) under one -* or more contributor license agreements. See the NOTICE file -* distributed with this work for additional information -* regarding copyright ownership. The ASF licenses this file -* to you under the Apache License, Version 2.0 (the -* "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -* -*/ -package org.apache.qpid.transport.network.security.ssl; - -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; - -import javax.net.ssl.X509TrustManager; - -/** - * Supports multiple X509TrustManager(s). Check succeeds if any of the - * underlying managers succeeds. - */ -public class QpidMultipleTrustManager implements X509TrustManager { - - private List trustManagers; - - public QpidMultipleTrustManager() { - this.trustManagers = new ArrayList(); - } - - public boolean isEmpty() - { - return trustManagers.isEmpty(); - } - - public void addTrustManager(final X509TrustManager trustManager) - { - this.trustManagers.add(trustManager); - } - - @Override - public void checkClientTrusted(X509Certificate[] chain, String authType) - throws CertificateException { - for (X509TrustManager trustManager : this.trustManagers) - { - try - { - trustManager.checkClientTrusted(chain, authType); - // this trustManager check succeeded, no need to check another one - return; - } - catch(CertificateException ex) - { - // do nothing, try another one in a loop - } - } - // no trustManager call succeeded, throw an exception - throw new CertificateException(); - } - - @Override - public void checkServerTrusted(X509Certificate[] chain, String authType) - throws CertificateException { - for (X509TrustManager trustManager : this.trustManagers) - { - try - { - trustManager.checkServerTrusted(chain, authType); - // this trustManager check succeeded, no need to check another one - return; - } - catch(CertificateException ex) - { - // do nothing, try another one in a loop - } - } - // no trustManager call succeeded, throw an exception - throw new CertificateException(); - } - - @Override - public X509Certificate[] getAcceptedIssuers() { - final Collection accIssuersCol = new ArrayList(); - for (X509TrustManager trustManager : this.trustManagers) - { - accIssuersCol.addAll(Arrays.asList(trustManager.getAcceptedIssuers())); - } - return accIssuersCol.toArray(new X509Certificate[accIssuersCol.size()]); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/QpidPeersOnlyTrustManager.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/QpidPeersOnlyTrustManager.java deleted file mode 100644 index c988ff8d69..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/QpidPeersOnlyTrustManager.java +++ /dev/null @@ -1,81 +0,0 @@ -/* -* -* Licensed to the Apache Software Foundation (ASF) under one -* or more contributor license agreements. See the NOTICE file -* distributed with this work for additional information -* regarding copyright ownership. The ASF licenses this file -* to you under the Apache License, Version 2.0 (the -* "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -* -*/ -package org.apache.qpid.transport.network.security.ssl; - -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.cert.Certificate; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.List; - -import javax.net.ssl.X509TrustManager; - -/** - * TrustManager implementation which accepts the client certificate - * only if the underlying check by the delegate pass through and - * the certificate is physically saved in the truststore. - */ -public class QpidPeersOnlyTrustManager implements X509TrustManager { - - final private KeyStore ts; - final private X509TrustManager delegate; - final List trustedCerts = new ArrayList(); - - public QpidPeersOnlyTrustManager(KeyStore ts, X509TrustManager trustManager) throws KeyStoreException { - this.ts = ts; - this.delegate = trustManager; - Enumeration aliases = this.ts.aliases(); - while (aliases.hasMoreElements()) - { - trustedCerts.add(ts.getCertificate(aliases.nextElement())); - } - } - - @Override - public void checkClientTrusted(X509Certificate[] chain, String authType) - throws CertificateException { - this.delegate.checkClientTrusted(chain, authType); - for (Certificate serverTrustedCert : this.trustedCerts) - { - // first position in the chain contains the peer's own certificate - if (chain[0].equals(serverTrustedCert)) - return; // peer's certificate found in the store - } - // peer's certificate was not found in the store, do not trust the client - throw new CertificateException(); - } - - @Override - public void checkServerTrusted(X509Certificate[] chain, String authType) - throws CertificateException { - this.delegate.checkServerTrusted(chain, authType); - } - - @Override - public X509Certificate[] getAcceptedIssuers() { - // return empty array since this implementation of TrustManager doesn't - // rely on certification authorities - return new X509Certificate[0]; - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLBufferingSender.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLBufferingSender.java deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLReceiver.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLReceiver.java deleted file mode 100644 index 49e4ad631a..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLReceiver.java +++ /dev/null @@ -1,213 +0,0 @@ -/* -* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.network.security.ssl; - -import java.nio.ByteBuffer; - -import javax.net.ssl.SSLEngine; -import javax.net.ssl.SSLEngineResult; -import javax.net.ssl.SSLEngineResult.HandshakeStatus; -import javax.net.ssl.SSLEngineResult.Status; -import javax.net.ssl.SSLException; - -import org.apache.qpid.transport.ByteBufferReceiver; -import org.apache.qpid.transport.TransportException; -import org.apache.qpid.transport.network.security.SSLStatus; -import org.apache.qpid.transport.util.Logger; - -public class SSLReceiver implements ByteBufferReceiver -{ - private static final Logger log = Logger.get(SSLReceiver.class); - - private final ByteBufferReceiver delegate; - private final SSLEngine engine; - private final int sslBufSize; - private final ByteBuffer localBuffer; - private final SSLStatus _sslStatus; - private ByteBuffer appData; - private boolean dataCached = false; - - private String _hostname; - - public SSLReceiver(final SSLEngine engine, final ByteBufferReceiver delegate, final SSLStatus sslStatus) - { - this.engine = engine; - this.delegate = delegate; - this.sslBufSize = engine.getSession().getApplicationBufferSize(); - appData = ByteBuffer.allocate(sslBufSize); - localBuffer = ByteBuffer.allocate(sslBufSize); - _sslStatus = sslStatus; - } - - public void setHostname(String hostname) - { - _hostname = hostname; - } - - public void closed() - { - delegate.closed(); - } - - public void exception(Throwable t) - { - delegate.exception(t); - } - - private ByteBuffer addPreviouslyUnreadData(ByteBuffer buf) - { - if (dataCached) - { - ByteBuffer b = ByteBuffer.allocate(localBuffer.remaining() + buf.remaining()); - b.put(localBuffer); - b.put(buf); - b.flip(); - dataCached = false; - return b; - } - else - { - return buf; - } - } - - public void received(ByteBuffer buf) - { - ByteBuffer netData = addPreviouslyUnreadData(buf); - - HandshakeStatus handshakeStatus; - Status status; - - while (netData.hasRemaining()) - { - try - { - SSLEngineResult result = engine.unwrap(netData, appData); - synchronized (_sslStatus.getSslLock()) - { - _sslStatus.getSslLock().notifyAll(); - } - - int read = result.bytesProduced(); - status = result.getStatus(); - handshakeStatus = result.getHandshakeStatus(); - - if (read > 0) - { - int limit = appData.limit(); - appData.limit(appData.position()); - appData.position(appData.position() - read); - - ByteBuffer data = appData.slice(); - - appData.limit(limit); - appData.position(appData.position() + read); - - delegate.received(data); - } - - - switch(status) - { - case CLOSED: - synchronized(_sslStatus.getSslLock()) - { - _sslStatus.getSslLock().notifyAll(); - } - return; - - case BUFFER_OVERFLOW: - appData = ByteBuffer.allocate(sslBufSize); - continue; - - case BUFFER_UNDERFLOW: - localBuffer.clear(); - localBuffer.put(netData); - localBuffer.flip(); - dataCached = true; - break; - - case OK: - break; // do nothing - - default: - throw new IllegalStateException("SSLReceiver: Invalid State " + status); - } - - switch (handshakeStatus) - { - case NEED_UNWRAP: - if (netData.hasRemaining()) - { - continue; - } - break; - - case NEED_TASK: - doTasks(); - handshakeStatus = engine.getHandshakeStatus(); - - case FINISHED: - if (_hostname != null) - { - SSLUtil.verifyHostname(engine, _hostname); - } - - case NEED_WRAP: - case NOT_HANDSHAKING: - synchronized(_sslStatus.getSslLock()) - { - _sslStatus.getSslLock().notifyAll(); - } - break; - - default: - throw new IllegalStateException("SSLReceiver: Invalid State " + status); - } - - - } - catch(SSLException e) - { - if (log.isDebugEnabled()) - { - log.debug(e, "Error caught in SSLReceiver"); - } - _sslStatus.setSslErrorFlag(); - synchronized(_sslStatus.getSslLock()) - { - _sslStatus.getSslLock().notifyAll(); - } - exception(new TransportException("Error in SSLReceiver: " + e.getMessage(),e)); - } - - } - } - - private void doTasks() - { - Runnable runnable; - while ((runnable = engine.getDelegatedTask()) != null) { - runnable.run(); - } - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLSender.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLSender.java deleted file mode 100644 index 3d133cb9b7..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLSender.java +++ /dev/null @@ -1,268 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.network.security.ssl; - -import java.nio.ByteBuffer; -import java.util.concurrent.atomic.AtomicBoolean; - -import javax.net.ssl.SSLEngine; -import javax.net.ssl.SSLEngineResult; -import javax.net.ssl.SSLEngineResult.HandshakeStatus; -import javax.net.ssl.SSLEngineResult.Status; -import javax.net.ssl.SSLException; - -import org.apache.qpid.transport.ByteBufferSender; -import org.apache.qpid.transport.SenderException; -import org.apache.qpid.transport.network.security.SSLStatus; -import org.apache.qpid.transport.util.Logger; - -public class SSLSender implements ByteBufferSender -{ - private static final Logger log = Logger.get(SSLSender.class); - - private final ByteBufferSender delegate; - private final SSLEngine engine; - private final int sslBufSize; - private final ByteBuffer netData; - private final long timeout; - private final SSLStatus _sslStatus; - - private String _hostname; - - private final AtomicBoolean closed = new AtomicBoolean(false); - - - public SSLSender(SSLEngine engine, ByteBufferSender delegate, SSLStatus sslStatus) - { - this.engine = engine; - this.delegate = delegate; - sslBufSize = engine.getSession().getPacketBufferSize(); - netData = ByteBuffer.allocate(sslBufSize); - timeout = Long.getLong("qpid.ssl_timeout", 60000); - _sslStatus = sslStatus; - } - - public void setHostname(String hostname) - { - _hostname = hostname; - } - - public void close() - { - if (!closed.getAndSet(true)) - { - if (engine.isOutboundDone()) - { - return; - } - log.debug("Closing SSL connection"); - - engine.closeOutbound(); - try - { - tearDownSSLConnection(); - } - catch(Exception e) - { - throw new SenderException("Error closing SSL connection",e); - } - - - synchronized(_sslStatus.getSslLock()) - { - while (!engine.isOutboundDone()) - { - try - { - _sslStatus.getSslLock().wait(); - } - catch(InterruptedException e) - { - // pass - } - - } - } - delegate.close(); - } - } - - private void tearDownSSLConnection() throws Exception - { - SSLEngineResult result = engine.wrap(ByteBuffer.allocate(0), netData); - Status status = result.getStatus(); - int read = result.bytesProduced(); - while (status != Status.CLOSED) - { - if (status == Status.BUFFER_OVERFLOW) - { - netData.clear(); - } - if(read > 0) - { - int limit = netData.limit(); - netData.limit(netData.position()); - netData.position(netData.position() - read); - - ByteBuffer data = netData.slice(); - - netData.limit(limit); - netData.position(netData.position() + read); - - delegate.send(data); - flush(); - } - result = engine.wrap(ByteBuffer.allocate(0), netData); - status = result.getStatus(); - read = result.bytesProduced(); - } - } - - public void flush() - { - delegate.flush(); - } - - public void send(ByteBuffer appData) - { - if (closed.get() && !_sslStatus.getSslErrorFlag()) - { - throw new SenderException("SSL Sender is closed"); - } - - HandshakeStatus handshakeStatus; - Status status; - - while(appData.hasRemaining() && !_sslStatus.getSslErrorFlag()) - { - int read = 0; - try - { - SSLEngineResult result = engine.wrap(appData, netData); - read = result.bytesProduced(); - status = result.getStatus(); - handshakeStatus = result.getHandshakeStatus(); - } - catch(SSLException e) - { - // Should this set _sslError?? - throw new SenderException("SSL, Error occurred while encrypting data",e); - } - - if(read > 0) - { - int limit = netData.limit(); - netData.limit(netData.position()); - netData.position(netData.position() - read); - - ByteBuffer data = netData.slice(); - - netData.limit(limit); - netData.position(netData.position() + read); - - delegate.send(data); - } - - switch(status) - { - case CLOSED: - throw new SenderException("SSLEngine is closed"); - - case BUFFER_OVERFLOW: - netData.clear(); - continue; - - case OK: - break; // do nothing - - default: - throw new IllegalStateException("SSLReceiver: Invalid State " + status); - } - - switch (handshakeStatus) - { - case NEED_WRAP: - if (netData.hasRemaining()) - { - continue; - } - - case NEED_TASK: - doTasks(); - break; - - case NEED_UNWRAP: - flush(); - synchronized(_sslStatus.getSslLock()) - { - if (_sslStatus.getSslErrorFlag()) - { - break; - } - - switch (engine.getHandshakeStatus()) - { - case NEED_UNWRAP: - final long start = System.currentTimeMillis(); - try - { - _sslStatus.getSslLock().wait(timeout); - } - catch(InterruptedException e) - { - // pass - } - - if (!_sslStatus.getSslErrorFlag() && System.currentTimeMillis() - start >= timeout) - { - throw new SenderException( - "SSL Engine timed out after waiting " + timeout + "ms. for a response." + - "To get more info,run with -Djavax.net.debug=ssl"); - } - break; - } - } - break; - - case FINISHED: - if (_hostname != null) - { - SSLUtil.verifyHostname(engine, _hostname); - } - - case NOT_HANDSHAKING: - break; //do nothing - - default: - throw new IllegalStateException("SSLSender: Invalid State " + status); - } - - } - } - - private void doTasks() - { - Runnable runnable; - while ((runnable = engine.getDelegatedTask()) != null) { - runnable.run(); - } - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLUtil.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLUtil.java deleted file mode 100644 index 67dde84440..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLUtil.java +++ /dev/null @@ -1,371 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.network.security.ssl; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; -import java.net.URL; -import java.security.GeneralSecurityException; -import java.security.KeyStore; -import java.security.Principal; -import java.security.cert.Certificate; -import java.security.cert.CertificateParsingException; -import java.security.cert.X509Certificate; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - -import javax.naming.InvalidNameException; -import javax.naming.ldap.LdapName; -import javax.naming.ldap.Rdn; -import javax.net.ssl.SSLEngine; -import javax.net.ssl.SSLPeerUnverifiedException; -import javax.net.ssl.SSLServerSocket; -import javax.net.ssl.SSLSocket; - -import org.apache.qpid.transport.TransportException; -import org.apache.qpid.transport.util.Logger; - -public class SSLUtil -{ - private static final Logger log = Logger.get(SSLUtil.class); - private static final Integer DNS_NAME_TYPE = 2; - public static final String SSLV3_PROTOCOL = "SSLv3"; - - private SSLUtil() - { - } - - public static void verifyHostname(SSLEngine engine,String hostnameExpected) - { - try - { - Certificate cert = engine.getSession().getPeerCertificates()[0]; - verifyHostname(hostnameExpected, (X509Certificate) cert); - } - catch(SSLPeerUnverifiedException e) - { - log.warn("Exception received while trying to verify hostname",e); - // For some reason the SSL engine sets the handshake status to FINISH twice - // in succession. The first time the peer certificate - // info is not available. The second time it works ! - // Therefore have no choice but to ignore the exception here. - } - } - - public static void verifyHostname(final String hostnameExpected, final X509Certificate cert) - { - Principal p = cert.getSubjectDN(); - - SortedSet names = new TreeSet<>(); - String dn = p.getName(); - try - { - LdapName ldapName = new LdapName(dn); - for (Rdn part : ldapName.getRdns()) - { - if (part.getType().equalsIgnoreCase("CN")) - { - names.add(part.getValue().toString()); - break; - } - } - - if(cert.getSubjectAlternativeNames() != null) - { - for (List entry : cert.getSubjectAlternativeNames()) - { - if (DNS_NAME_TYPE.equals(entry.get(0))) - { - names.add((String) entry.get(1)); - } - } - } - - if (names.isEmpty()) - { - throw new TransportException("SSL hostname verification failed. Certificate for did not contain CN or DNS subjectAlt"); - } - - boolean match = false; - - final String hostName = hostnameExpected.trim().toLowerCase(); - for (String cn : names) - { - - boolean doWildcard = cn.startsWith("*.") && - cn.lastIndexOf('.') >= 3 && - !cn.matches("\\*\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}"); - - - match = doWildcard - ? hostName.endsWith(cn.substring(1)) && hostName.indexOf(".") == (1 + hostName.length() - cn.length()) - : hostName.equals(cn); - - if (match) - { - break; - } - - } - if (!match) - { - throw new TransportException("SSL hostname verification failed." + - " Expected : " + hostnameExpected + - " Found in cert : " + names); - } - - } - catch (InvalidNameException e) - { - throw new TransportException("SSL hostname verification failed. Could not parse name " + dn, e); - } - catch (CertificateParsingException e) - { - throw new TransportException("SSL hostname verification failed. Could not parse certificate: " + e.getMessage(), e); - } - } - - public static String getIdFromSubjectDN(String dn) - { - String cnStr = null; - String dcStr = null; - if(dn == null) - { - return ""; - } - else - { - try - { - LdapName ln = new LdapName(dn); - for(Rdn rdn : ln.getRdns()) - { - if("CN".equalsIgnoreCase(rdn.getType())) - { - cnStr = rdn.getValue().toString(); - } - else if("DC".equalsIgnoreCase(rdn.getType())) - { - if(dcStr == null) - { - dcStr = rdn.getValue().toString(); - } - else - { - dcStr = rdn.getValue().toString() + '.' + dcStr; - } - } - } - return cnStr == null || cnStr.length()==0 ? "" : dcStr == null ? cnStr : cnStr + '@' + dcStr; - } - catch (InvalidNameException e) - { - log.warn("Invalid name: '"+dn+"'. "); - return ""; - } - } - } - - - public static String retrieveIdentity(SSLEngine engine) - { - String id = ""; - Certificate cert = engine.getSession().getLocalCertificates()[0]; - Principal p = ((X509Certificate)cert).getSubjectDN(); - String dn = p.getName(); - try - { - id = SSLUtil.getIdFromSubjectDN(dn); - } - catch (Exception e) - { - log.info("Exception received while trying to retrieve client identity from SSL cert", e); - } - log.debug("Extracted Identity from client certificate : " + id); - return id; - } - - public static KeyStore getInitializedKeyStore(String storePath, String storePassword, String keyStoreType) throws GeneralSecurityException, IOException - { - KeyStore ks = KeyStore.getInstance(keyStoreType); - InputStream in = null; - try - { - File f = new File(storePath); - if (f.exists()) - { - in = new FileInputStream(f); - } - else - { - in = Thread.currentThread().getContextClassLoader().getResourceAsStream(storePath); - } - if (in == null && !"PKCS11".equalsIgnoreCase(keyStoreType)) // PKCS11 will not require an explicit path - { - throw new IOException("Unable to load keystore resource: " + storePath); - } - - char[] storeCharPassword = storePassword == null ? null : storePassword.toCharArray(); - - ks.load(in, storeCharPassword); - } - finally - { - if (in != null) - { - //noinspection EmptyCatchBlock - try - { - in.close(); - } - catch (IOException ignored) - { - } - } - } - return ks; - } - - public static KeyStore getInitializedKeyStore(URL storePath, String storePassword, String keyStoreType) throws GeneralSecurityException, IOException - { - KeyStore ks = KeyStore.getInstance(keyStoreType); - try(InputStream in = storePath.openStream()) - { - if (in == null && !"PKCS11".equalsIgnoreCase(keyStoreType)) // PKCS11 will not require an explicit path - { - throw new IOException("Unable to load keystore resource: " + storePath); - } - - char[] storeCharPassword = storePassword == null ? null : storePassword.toCharArray(); - - ks.load(in, storeCharPassword); - } - return ks; - } - - private static interface SSLEntity - { - String[] getEnabledCipherSuites(); - - void setEnabledCipherSuites(String[] strings); - - String[] getEnabledProtocols(); - - void setEnabledProtocols(String[] protocols); - - String[] getSupportedCipherSuites(); - - String[] getSupportedProtocols(); - } - - private static SSLEntity asSSLEntity(final Object object, final Class clazz) - { - return (SSLEntity) Proxy.newProxyInstance(SSLEntity.class.getClassLoader(), new Class[] { SSLEntity.class }, new InvocationHandler() - { - @Override - public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable - { - Method delegateMethod = clazz.getMethod(method.getName(), method.getParameterTypes()); - return delegateMethod.invoke(object, args); - } - }) ; - } - - private static void removeSSLv3Support(final SSLEntity engine) - { - List enabledProtocols = Arrays.asList(engine.getEnabledProtocols()); - if(enabledProtocols.contains(SSLV3_PROTOCOL)) - { - List allowedProtocols = new ArrayList<>(enabledProtocols); - allowedProtocols.remove(SSLV3_PROTOCOL); - engine.setEnabledProtocols(allowedProtocols.toArray(new String[allowedProtocols.size()])); - } - } - - public static void removeSSLv3Support(final SSLEngine engine) - { - removeSSLv3Support(asSSLEntity(engine, SSLEngine.class)); - } - - public static void removeSSLv3Support(final SSLSocket socket) - { - removeSSLv3Support(asSSLEntity(socket, SSLSocket.class)); - } - - public static void removeSSLv3Support(final SSLServerSocket socket) - { - removeSSLv3Support(asSSLEntity(socket, SSLServerSocket.class)); - } - - private static void updateEnabledCipherSuites(final SSLEntity entity, - final Collection enabledCipherSuites, - final Collection disabledCipherSuites) - { - if(enabledCipherSuites != null && !enabledCipherSuites.isEmpty()) - { - final Set supportedSuites = - new HashSet<>(Arrays.asList(entity.getSupportedCipherSuites())); - supportedSuites.retainAll(enabledCipherSuites); - entity.setEnabledCipherSuites(supportedSuites.toArray(new String[supportedSuites.size()])); - } - - if(disabledCipherSuites != null && !disabledCipherSuites.isEmpty()) - { - final Set enabledSuites = new HashSet<>(Arrays.asList(entity.getEnabledCipherSuites())); - enabledSuites.removeAll(disabledCipherSuites); - entity.setEnabledCipherSuites(enabledSuites.toArray(new String[enabledSuites.size()])); - } - - } - - - public static void updateEnabledCipherSuites(final SSLEngine engine, - final Collection enabledCipherSuites, - final Collection disabledCipherSuites) - { - updateEnabledCipherSuites(asSSLEntity(engine, SSLEngine.class), enabledCipherSuites, disabledCipherSuites); - } - - public static void updateEnabledCipherSuites(final SSLServerSocket socket, - final Collection enabledCipherSuites, - final Collection disabledCipherSuites) - { - updateEnabledCipherSuites(asSSLEntity(socket, SSLServerSocket.class), enabledCipherSuites, disabledCipherSuites); - } - - public static void updateEnabledCipherSuites(final SSLSocket socket, - final Collection enabledCipherSuites, - final Collection disabledCipherSuites) - { - updateEnabledCipherSuites(asSSLEntity(socket, SSLSocket.class), enabledCipherSuites, disabledCipherSuites); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/util/Functions.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/util/Functions.java deleted file mode 100644 index 61d5f0629c..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/util/Functions.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.util; - -import static java.lang.Math.min; - -import java.nio.ByteBuffer; - - -/** - * Functions - * - * @author Rafael H. Schloming - */ - -public final class Functions -{ - private static final char[] HEX_CHARACTERS = - {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; - - private Functions() - { - } - - public static final int mod(int n, int m) - { - int r = n % m; - return r < 0 ? m + r : r; - } - - public static final byte lsb(int i) - { - return (byte) (0xFF & i); - } - - public static final byte lsb(long l) - { - return (byte) (0xFF & l); - } - - public static final String str(ByteBuffer buf) - { - return str(buf, buf.remaining()); - } - - public static final String str(ByteBuffer buf, int limit) - { - return str(buf, limit,buf.position()); - } - - public static final String str(ByteBuffer buf, int limit,int start) - { - StringBuilder str = new StringBuilder(); - str.append('"'); - - for (int i = start; i < min(buf.limit(), limit); i++) - { - byte c = buf.get(i); - - if (c > 31 && c < 127 && c != '\\') - { - str.append((char)c); - } - else - { - str.append(String.format("\\x%02x", c)); - } - } - - str.append('"'); - - if (limit < buf.remaining()) - { - str.append("..."); - } - - return str.toString(); - } - - public static final String str(byte[] bytes) - { - return str(ByteBuffer.wrap(bytes)); - } - - public static final String str(byte[] bytes, int limit) - { - return str(ByteBuffer.wrap(bytes), limit); - } - - public static String hex(byte[] bytes, int limit) - { - limit = Math.min(limit, bytes == null ? 0 : bytes.length); - StringBuilder sb = new StringBuilder(3 + limit*2); - for(int i = 0; i < limit; i++) - { - sb.append(HEX_CHARACTERS[(((int)bytes[i]) & 0xf0)>>4]); - sb.append(HEX_CHARACTERS[(((int)bytes[i]) & 0x0f)]); - - } - if(bytes != null && bytes.length>limit) - { - sb.append("..."); - } - return sb.toString(); - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/util/Logger.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/util/Logger.java deleted file mode 100644 index 8c4818df92..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/util/Logger.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.util; - -import org.slf4j.LoggerFactory; - -/** - * Logger - * - */ - -public final class Logger -{ - - public static final Logger get(Class klass) - { - return new Logger(LoggerFactory.getLogger(klass)); - } - - private final org.slf4j.Logger log; - - private Logger(org.slf4j.Logger log) - { - this.log = log; - } - - public boolean isDebugEnabled() - { - return log.isDebugEnabled(); - } - - public void debug(String message, Object ... args) - { - if (log.isDebugEnabled()) - { - log.debug(String.format(message, args)); - } - } - - public void debug(Throwable t, String message, Object ... args) - { - if (log.isDebugEnabled()) - { - log.debug(String.format(message, args), t); - } - } - - public void error(String message, Object ... args) - { - if (log.isErrorEnabled()) - { - log.error(String.format(message, args)); - } - } - - public void error(Throwable t, String message, Object ... args) - { - if (log.isErrorEnabled()) - { - log.error(String.format(message, args), t); - } - } - - public void warn(String message, Object ... args) - { - if (log.isWarnEnabled()) - { - log.warn(String.format(message, args)); - } - } - - public void warn(Throwable t, String message, Object ... args) - { - if (log.isWarnEnabled()) - { - log.warn(String.format(message, args), t); - } - } - - public void info(String message, Object ... args) - { - if (log.isInfoEnabled()) - { - log.info(String.format(message, args)); - } - } - - public void info(Throwable t, String message, Object ... args) - { - if (log.isInfoEnabled()) - { - log.info(String.format(message, args), t); - } - } - - public void trace(String message, Object ... args) - { - if (log.isTraceEnabled()) - { - log.trace(String.format(message, args)); - } - } - - public void trace(Throwable t, String message, Object ... args) - { - if (log.isTraceEnabled()) - { - log.trace(String.format(message, args), t); - } - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/util/Waiter.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/util/Waiter.java deleted file mode 100644 index e034d779ca..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/util/Waiter.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.transport.util; - - -/** - * Waiter - * - */ - -public final class Waiter -{ - - private final Object lock; - private final long timeout; - private final long start; - private long elapsed; - - public Waiter(Object lock, long timeout) - { - this.lock = lock; - this.timeout = timeout; - this.start = System.currentTimeMillis(); - this.elapsed = 0; - } - - public boolean hasTime() - { - return elapsed < timeout; - } - - public void await() - { - try - { - lock.wait(timeout - elapsed); - } - catch (InterruptedException e) - { - // pass - } - elapsed = System.currentTimeMillis() - start; - } - -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/typedmessage/TypedBytesCodes.java b/qpid/java/common/src/main/java/org/apache/qpid/typedmessage/TypedBytesCodes.java deleted file mode 100644 index 0e12ac65d8..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/typedmessage/TypedBytesCodes.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.typedmessage; - -public interface TypedBytesCodes -{ - static final byte BOOLEAN_TYPE = (byte) 1; - - static final byte BYTE_TYPE = (byte) 2; - - static final byte BYTEARRAY_TYPE = (byte) 3; - - static final byte SHORT_TYPE = (byte) 4; - - static final byte CHAR_TYPE = (byte) 5; - - static final byte INT_TYPE = (byte) 6; - - static final byte LONG_TYPE = (byte) 7; - - static final byte FLOAT_TYPE = (byte) 8; - - static final byte DOUBLE_TYPE = (byte) 9; - - static final byte STRING_TYPE = (byte) 10; - - static final byte NULL_STRING_TYPE = (byte) 11; -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/typedmessage/TypedBytesContentReader.java b/qpid/java/common/src/main/java/org/apache/qpid/typedmessage/TypedBytesContentReader.java deleted file mode 100644 index 674a0e9468..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/typedmessage/TypedBytesContentReader.java +++ /dev/null @@ -1,670 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.typedmessage; - - -import java.io.EOFException; -import java.nio.ByteBuffer; -import java.nio.CharBuffer; -import java.nio.charset.CharacterCodingException; -import java.nio.charset.Charset; -import java.nio.charset.CharsetDecoder; - -public class TypedBytesContentReader implements TypedBytesCodes -{ - - private final ByteBuffer _data; - private final int _position; - private final int _limit; - - - private static final Charset UTF8_CHARSET = Charset.forName("UTF-8"); - - private final CharsetDecoder _charsetDecoder = UTF8_CHARSET.newDecoder(); - - private int _byteArrayRemaining = -1; - - - public TypedBytesContentReader(final ByteBuffer data) - { - _data = data.duplicate(); - _position = _data.position(); - _limit = _data.limit(); - } - - /** - * Check that there is at least a certain number of bytes available to read - * - * @param len the number of bytes - * @throws EOFException if there are less than len bytes available to read - */ - public void checkAvailable(int len) throws EOFException - { - if (_data.remaining() < len) - { - throw new EOFException("Unable to read " + len + " bytes"); - } - } - - public byte readWireType() throws TypedBytesFormatException, EOFException - { - checkAvailable(1); - return _data.get(); - } - - public boolean readBoolean() throws EOFException, TypedBytesFormatException - { - int position = _data.position(); - byte wireType = readWireType(); - boolean result; - try - { - switch (wireType) - { - case BOOLEAN_TYPE: - checkAvailable(1); - result = readBooleanImpl(); - break; - case STRING_TYPE: - checkAvailable(1); - result = Boolean.parseBoolean(readStringImpl()); - break; - default: - _data.position(position); - throw new TypedBytesFormatException("Unable to convert " + wireType + " to a boolean"); - } - return result; - } - catch (RuntimeException e) - { - _data.position(position); - throw e; - } - } - - public boolean readBooleanImpl() - { - return _data.get() != 0; - } - - public byte readByte() throws EOFException, TypedBytesFormatException - { - int position = _data.position(); - byte wireType = readWireType(); - byte result; - try - { - switch (wireType) - { - case BYTE_TYPE: - checkAvailable(1); - result = readByteImpl(); - break; - case STRING_TYPE: - checkAvailable(1); - result = Byte.parseByte(readStringImpl()); - break; - default: - _data.position(position); - throw new TypedBytesFormatException("Unable to convert " + wireType + " to a byte"); - } - } - catch (RuntimeException e) - { - _data.position(position); - throw e; - } - return result; - } - - public byte readByteImpl() - { - return _data.get(); - } - - public short readShort() throws EOFException, TypedBytesFormatException - { - int position = _data.position(); - byte wireType = readWireType(); - short result; - try - { - switch (wireType) - { - case SHORT_TYPE: - checkAvailable(2); - result = readShortImpl(); - break; - case STRING_TYPE: - checkAvailable(1); - result = Short.parseShort(readStringImpl()); - break; - case BYTE_TYPE: - checkAvailable(1); - result = readByteImpl(); - break; - default: - _data.position(position); - throw new TypedBytesFormatException("Unable to convert " + wireType + " to a short"); - } - } - catch (RuntimeException e) - { - _data.position(position); - throw e; - } - return result; - } - - public short readShortImpl() - { - return _data.getShort(); - } - - /** - * Note that this method reads a unicode character as two bytes from the stream - * - * @return the character read from the stream - * @throws EOFException if there are less than the required bytes available to read - * @throws TypedBytesFormatException if the current write type is not compatible - */ - public char readChar() throws EOFException, TypedBytesFormatException - { - int position = _data.position(); - byte wireType = readWireType(); - try - { - if (wireType == NULL_STRING_TYPE) - { - throw new NullPointerException(); - } - - if (wireType != CHAR_TYPE) - { - _data.position(position); - throw new TypedBytesFormatException("Unable to convert " + wireType + " to a char"); - } - else - { - checkAvailable(2); - return readCharImpl(); - } - } - catch (RuntimeException e) - { - _data.position(position); - throw e; - } - } - - public char readCharImpl() - { - return _data.getChar(); - } - - public int readInt() throws EOFException, TypedBytesFormatException - { - int position = _data.position(); - byte wireType = readWireType(); - int result; - try - { - switch (wireType) - { - case INT_TYPE: - checkAvailable(4); - result = readIntImpl(); - break; - case SHORT_TYPE: - checkAvailable(2); - result = readShortImpl(); - break; - case STRING_TYPE: - checkAvailable(1); - result = Integer.parseInt(readStringImpl()); - break; - case BYTE_TYPE: - checkAvailable(1); - result = readByteImpl(); - break; - default: - _data.position(position); - throw new TypedBytesFormatException("Unable to convert " + wireType + " to an int"); - } - return result; - } - catch (RuntimeException e) - { - _data.position(position); - throw e; - } - } - - public int readIntImpl() - { - return _data.getInt(); - } - - public long readLong() throws EOFException, TypedBytesFormatException - { - int position = _data.position(); - byte wireType = readWireType(); - long result; - try - { - switch (wireType) - { - case LONG_TYPE: - checkAvailable(8); - result = readLongImpl(); - break; - case INT_TYPE: - checkAvailable(4); - result = readIntImpl(); - break; - case SHORT_TYPE: - checkAvailable(2); - result = readShortImpl(); - break; - case STRING_TYPE: - checkAvailable(1); - result = Long.parseLong(readStringImpl()); - break; - case BYTE_TYPE: - checkAvailable(1); - result = readByteImpl(); - break; - default: - _data.position(position); - throw new TypedBytesFormatException("Unable to convert " + wireType + " to a long"); - } - return result; - } - catch (RuntimeException e) - { - _data.position(position); - throw e; - } - } - - public long readLongImpl() - { - return _data.getLong(); - } - - public float readFloat() throws EOFException, TypedBytesFormatException - { - int position = _data.position(); - byte wireType = readWireType(); - float result; - try - { - switch (wireType) - { - case FLOAT_TYPE: - checkAvailable(4); - result = readFloatImpl(); - break; - case STRING_TYPE: - checkAvailable(1); - result = Float.parseFloat(readStringImpl()); - break; - default: - _data.position(position); - throw new TypedBytesFormatException("Unable to convert " + wireType + " to a float"); - } - return result; - } - catch (RuntimeException e) - { - _data.position(position); - throw e; - } - } - - public float readFloatImpl() - { - return _data.getFloat(); - } - - public double readDouble() throws TypedBytesFormatException, EOFException - { - int position = _data.position(); - byte wireType = readWireType(); - double result; - try - { - switch (wireType) - { - case DOUBLE_TYPE: - checkAvailable(8); - result = readDoubleImpl(); - break; - case FLOAT_TYPE: - checkAvailable(4); - result = readFloatImpl(); - break; - case STRING_TYPE: - checkAvailable(1); - result = Double.parseDouble(readStringImpl()); - break; - default: - _data.position(position); - throw new TypedBytesFormatException("Unable to convert " + wireType + " to a double"); - } - return result; - } - catch (RuntimeException e) - { - _data.position(position); - throw e; - } - } - - public double readDoubleImpl() - { - return _data.getDouble(); - } - - public String readString() throws EOFException, TypedBytesFormatException - { - int position = _data.position(); - byte wireType = readWireType(); - String result; - try - { - switch (wireType) - { - case STRING_TYPE: - checkAvailable(1); - result = readStringImpl(); - break; - case NULL_STRING_TYPE: - result = null; - throw new NullPointerException("data is null"); - case BOOLEAN_TYPE: - checkAvailable(1); - result = String.valueOf(readBooleanImpl()); - break; - case LONG_TYPE: - checkAvailable(8); - result = String.valueOf(readLongImpl()); - break; - case INT_TYPE: - checkAvailable(4); - result = String.valueOf(readIntImpl()); - break; - case SHORT_TYPE: - checkAvailable(2); - result = String.valueOf(readShortImpl()); - break; - case BYTE_TYPE: - checkAvailable(1); - result = String.valueOf(readByteImpl()); - break; - case FLOAT_TYPE: - checkAvailable(4); - result = String.valueOf(readFloatImpl()); - break; - case DOUBLE_TYPE: - checkAvailable(8); - result = String.valueOf(readDoubleImpl()); - break; - case CHAR_TYPE: - checkAvailable(2); - result = String.valueOf(readCharImpl()); - break; - default: - _data.position(position); - throw new TypedBytesFormatException("Unable to convert " + wireType + " to a String"); - } - return result; - } - catch (RuntimeException e) - { - _data.position(position); - throw e; - } - } - - public String readStringImpl() throws TypedBytesFormatException - { - try - { - _charsetDecoder.reset(); - ByteBuffer dup = _data.duplicate(); - int pos = _data.position(); - byte b; - while((b = _data.get()) != 0) {}; - dup.limit(_data.position()-1); - return _charsetDecoder.decode(dup).toString(); - - } - catch (CharacterCodingException e) - { - TypedBytesFormatException jmse = new TypedBytesFormatException("Error decoding byte stream as a UTF8 string: " + e); - jmse.initCause(e); - throw jmse; - } - } - - public int readBytes(byte[] bytes) throws EOFException, TypedBytesFormatException - { - if (bytes == null) - { - throw new IllegalArgumentException("byte array must not be null"); - } - // first call - if (_byteArrayRemaining == -1) - { - // type discriminator checked separately so you get a MessageFormatException rather than - // an EOF even in the case where both would be applicable - checkAvailable(1); - byte wireType = readWireType(); - if (wireType != BYTEARRAY_TYPE) - { - throw new TypedBytesFormatException("Unable to convert " + wireType + " to a byte array"); - } - checkAvailable(4); - int size = _data.getInt(); - // length of -1 indicates null - if (size == -1) - { - return -1; - } - else - { - if (size > _data.remaining()) - { - throw new EOFException("Byte array has stated length " - + size - + " but message only contains " - + - _data.remaining() - + " bytes"); - } - else - { - _byteArrayRemaining = size; - } - } - } - else if (_byteArrayRemaining == 0) - { - _byteArrayRemaining = -1; - return -1; - } - - int returnedSize = readBytesImpl(bytes); - if (returnedSize < bytes.length) - { - _byteArrayRemaining = -1; - } - return returnedSize; - } - - private int readBytesImpl(byte[] bytes) - { - int count = (_byteArrayRemaining >= bytes.length ? bytes.length : _byteArrayRemaining); - _byteArrayRemaining -= count; - - if (count == 0) - { - return 0; - } - else - { - _data.get(bytes, 0, count); - return count; - } - } - - public Object readObject() throws EOFException, TypedBytesFormatException - { - int position = _data.position(); - byte wireType = readWireType(); - Object result = null; - try - { - switch (wireType) - { - case BOOLEAN_TYPE: - checkAvailable(1); - result = readBooleanImpl(); - break; - case BYTE_TYPE: - checkAvailable(1); - result = readByteImpl(); - break; - case BYTEARRAY_TYPE: - checkAvailable(4); - int size = _data.getInt(); - if (size == -1) - { - result = null; - } - else - { - _byteArrayRemaining = size; - byte[] bytesResult = new byte[size]; - readBytesImpl(bytesResult); - result = bytesResult; - } - break; - case SHORT_TYPE: - checkAvailable(2); - result = readShortImpl(); - break; - case CHAR_TYPE: - checkAvailable(2); - result = readCharImpl(); - break; - case INT_TYPE: - checkAvailable(4); - result = readIntImpl(); - break; - case LONG_TYPE: - checkAvailable(8); - result = readLongImpl(); - break; - case FLOAT_TYPE: - checkAvailable(4); - result = readFloatImpl(); - break; - case DOUBLE_TYPE: - checkAvailable(8); - result = readDoubleImpl(); - break; - case NULL_STRING_TYPE: - result = null; - break; - case STRING_TYPE: - checkAvailable(1); - result = readStringImpl(); - break; - } - return result; - } - catch (RuntimeException e) - { - _data.position(position); - throw e; - } - } - - public void reset() - { - _byteArrayRemaining = -1; - _data.position(_position); - _data.limit(_limit); - } - - public ByteBuffer getData() - { - ByteBuffer buf = _data.duplicate(); - buf.position(_position); - buf.limit(_limit); - return buf; - } - - public long size() - { - return _limit - _position; - } - - public int remaining() - { - return _data.remaining(); - } - - public void readRawBytes(final byte[] bytes, final int offset, final int count) - { - _data.get(bytes, offset, count); - } - - public String readLengthPrefixedUTF() throws TypedBytesFormatException - { - try - { - short length = readShortImpl(); - if(length == 0) - { - return ""; - } - else - { - _charsetDecoder.reset(); - ByteBuffer encodedString = _data.slice(); - encodedString.limit(length); - _data.position(_data.position()+length); - CharBuffer string = _charsetDecoder.decode(encodedString); - - return string.toString(); - } - } - catch(CharacterCodingException e) - { - TypedBytesFormatException jmse = new TypedBytesFormatException("Error decoding byte stream as a UTF8 string: " + e); - jmse.initCause(e); - throw jmse; - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/typedmessage/TypedBytesContentWriter.java b/qpid/java/common/src/main/java/org/apache/qpid/typedmessage/TypedBytesContentWriter.java deleted file mode 100644 index c7ca2d7df7..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/typedmessage/TypedBytesContentWriter.java +++ /dev/null @@ -1,366 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.typedmessage; - -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.CharBuffer; -import java.nio.charset.CharacterCodingException; -import java.nio.charset.Charset; -import java.nio.charset.CharsetEncoder; - -public class TypedBytesContentWriter implements TypedBytesCodes -{ - private final ByteArrayOutputStream _baos = new ByteArrayOutputStream(); - private final DataOutputStream _data = new DataOutputStream(_baos); - private static final Charset UTF8 = Charset.forName("UTF-8"); - - protected void writeTypeDiscriminator(byte type) - { - try - { - _data.writeByte(type); - } - catch (IOException e) - { - throw handle(e); - } - } - - private RuntimeException handle(final IOException e) - { - RuntimeException jmsEx = new RuntimeException("Unable to write value: " + e.getMessage()); - return jmsEx; - } - - - public void writeBoolean(boolean b) - { - writeTypeDiscriminator(BOOLEAN_TYPE); - writeBooleanImpl(b); - } - - public void writeBooleanImpl(final boolean b) - { - try - { - _data.writeByte(b ? (byte) 1 : (byte) 0); - } - catch (IOException e) - { - throw handle(e); - } - } - - public void writeByte(byte b) - { - writeTypeDiscriminator(BYTE_TYPE); - writeByteImpl(b); - } - - public void writeByteImpl(final byte b) - { - try - { - _data.writeByte(b); - } - catch (IOException e) - { - throw handle(e); - } - } - - public void writeShort(short i) - { - writeTypeDiscriminator(SHORT_TYPE); - writeShortImpl(i); - } - - public void writeShortImpl(final short i) - { - try - { - _data.writeShort(i); - } - catch (IOException e) - { - throw handle(e); - } - } - - public void writeChar(char c) - { - writeTypeDiscriminator(CHAR_TYPE); - writeCharImpl(c); - } - - public void writeCharImpl(final char c) - { - try - { - _data.writeChar(c); - } - catch (IOException e) - { - throw handle(e); - } - } - - public void writeInt(int i) - { - writeTypeDiscriminator(INT_TYPE); - writeIntImpl(i); - } - - public void writeIntImpl(int i) - { - try - { - _data.writeInt(i); - } - catch (IOException e) - { - throw handle(e); - } - } - - public void writeLong(long l) - { - writeTypeDiscriminator(LONG_TYPE); - writeLongImpl(l); - } - - public void writeLongImpl(final long l) - { - try - { - _data.writeLong(l); - } - catch (IOException e) - { - throw handle(e); - } - } - - public void writeFloat(float v) - { - writeTypeDiscriminator(FLOAT_TYPE); - writeFloatImpl(v); - } - - public void writeFloatImpl(final float v) - { - try - { - _data.writeFloat(v); - } - catch (IOException e) - { - throw handle(e); - } - } - - public void writeDouble(double v) - { - writeTypeDiscriminator(DOUBLE_TYPE); - writeDoubleImpl(v); - } - - public void writeDoubleImpl(final double v) - { - try - { - _data.writeDouble(v); - } - catch (IOException e) - { - throw handle(e); - } - } - - public void writeString(String string) - { - if (string == null) - { - writeTypeDiscriminator(NULL_STRING_TYPE); - } - else - { - writeTypeDiscriminator(STRING_TYPE); - writeNullTerminatedStringImpl(string); - } - } - - public void writeNullTerminatedStringImpl(String string) - - { - try - { - _data.write(string.getBytes(UTF8)); - _data.writeByte((byte) 0); - } - catch (IOException e) - { - throw handle(e); - } - - } - - public void writeBytes(byte[] bytes) - { - writeBytes(bytes, 0, bytes == null ? 0 : bytes.length); - } - - public void writeBytes(byte[] bytes, int offset, int length) - { - writeTypeDiscriminator(BYTEARRAY_TYPE); - writeBytesImpl(bytes, offset, length); - } - - public void writeBytesImpl(final byte[] bytes, final int offset, final int length) - { - try - { - if (bytes == null) - { - _data.writeInt(-1); - } - else - { - _data.writeInt(length); - _data.write(bytes, offset, length); - } - } - catch (IOException e) - { - throw handle(e); - } - } - - public void writeBytesRaw(final byte[] bytes, final int offset, final int length) - { - try - { - if (bytes != null) - { - _data.write(bytes, offset, length); - } - } - catch (IOException e) - { - throw handle(e); - } - } - - - public void writeObject(Object object) throws TypedBytesFormatException - { - Class clazz; - - if (object == null) - { - // string handles the output of null values - clazz = String.class; - } - else - { - clazz = object.getClass(); - } - - if (clazz == Byte.class) - { - writeByte((Byte) object); - } - else if (clazz == Boolean.class) - { - writeBoolean((Boolean) object); - } - else if (clazz == byte[].class) - { - writeBytes((byte[]) object); - } - else if (clazz == Short.class) - { - writeShort((Short) object); - } - else if (clazz == Character.class) - { - writeChar((Character) object); - } - else if (clazz == Integer.class) - { - writeInt((Integer) object); - } - else if (clazz == Long.class) - { - writeLong((Long) object); - } - else if (clazz == Float.class) - { - writeFloat((Float) object); - } - else if (clazz == Double.class) - { - writeDouble((Double) object); - } - else if (clazz == String.class) - { - writeString((String) object); - } - else - { - throw new TypedBytesFormatException("Only primitives plus byte arrays and String are valid types"); - } - } - - public ByteBuffer getData() - { - return ByteBuffer.wrap(_baos.toByteArray()); - } - - public void writeLengthPrefixedUTF(final String string) throws TypedBytesFormatException - { - try - { - CharsetEncoder encoder = UTF8.newEncoder(); - java.nio.ByteBuffer encodedString = encoder.encode(CharBuffer.wrap(string)); - - writeShortImpl((short) encodedString.limit()); - while(encodedString.hasRemaining()) - { - _data.writeByte(encodedString.get()); - } - } - catch (CharacterCodingException e) - { - TypedBytesFormatException jmse = new TypedBytesFormatException("Unable to encode string: " + e); - jmse.initCause(e); - throw jmse; - } - catch (IOException e) - { - throw handle(e); - } - - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/typedmessage/TypedBytesFormatException.java b/qpid/java/common/src/main/java/org/apache/qpid/typedmessage/TypedBytesFormatException.java deleted file mode 100644 index 24fdbcfde5..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/typedmessage/TypedBytesFormatException.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.typedmessage; - -public class TypedBytesFormatException extends Exception -{ - public TypedBytesFormatException(String s) - { - super(s); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/url/AMQBindingURL.java b/qpid/java/common/src/main/java/org/apache/qpid/url/AMQBindingURL.java deleted file mode 100644 index 3ea99ce4ab..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/url/AMQBindingURL.java +++ /dev/null @@ -1,246 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.url; - -import java.net.URISyntaxException; -import java.util.HashMap; -import java.util.Map; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.apache.qpid.exchange.ExchangeDefaults; -import org.apache.qpid.framing.AMQShortString; - -public class AMQBindingURL implements BindingURL -{ - private static final Logger _logger = LoggerFactory.getLogger(AMQBindingURL.class); - - private String _url; - private AMQShortString _exchangeClass = AMQShortString.valueOf(ExchangeDefaults.DIRECT_EXCHANGE_CLASS); - private AMQShortString _exchangeName = new AMQShortString(""); - private AMQShortString _destinationName = new AMQShortString(""); - private AMQShortString _queueName = new AMQShortString(""); - private AMQShortString[] _bindingKeys = new AMQShortString[0]; - private HashMap _options; - - public AMQBindingURL(String url) throws URISyntaxException - { - // format: - // :///[]/[]?