From d779fd968deef2dd5395a93f39f70ebf677ea1b3 Mon Sep 17 00:00:00 2001 From: Robert Godfrey Date: Wed, 22 Jan 2014 17:16:44 +0000 Subject: QPID-5504 : initial refactoring to move common code into shared classes, make transports work similarly with respect to message routing git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1560424 13f79535-47bb-0310-9956-ffa450edef68 --- .../qpid/framing/BasicContentHeaderProperties.java | 2 +- .../framing/CommonContentHeaderProperties.java | 81 ---------------------- .../org/apache/qpid/framing/ContentHeaderBody.java | 10 +-- .../qpid/framing/ContentHeaderProperties.java | 62 ----------------- .../framing/ContentHeaderPropertiesFactory.java | 4 +- .../qpid/framing/abstraction/ContentChunk.java | 30 -------- .../abstraction/MessagePublishInfoConverter.java | 32 --------- .../ProtocolVersionMethodConverter.java | 12 ++-- .../qpid/framing/amqp_0_9/MethodConverter_0_9.java | 68 ------------------ .../framing/amqp_0_91/MethodConverter_0_91.java | 68 ------------------ .../qpid/framing/amqp_8_0/MethodConverter_8_0.java | 50 ------------- 11 files changed, 12 insertions(+), 407 deletions(-) delete mode 100644 java/common/src/main/java/org/apache/qpid/framing/CommonContentHeaderProperties.java delete mode 100644 java/common/src/main/java/org/apache/qpid/framing/ContentHeaderProperties.java delete mode 100644 java/common/src/main/java/org/apache/qpid/framing/abstraction/ContentChunk.java delete mode 100644 java/common/src/main/java/org/apache/qpid/framing/abstraction/MessagePublishInfoConverter.java (limited to 'java/common/src') diff --git a/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java b/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java index 366c8231a1..60dac24cfc 100644 --- a/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java +++ b/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java @@ -27,7 +27,7 @@ import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; -public class BasicContentHeaderProperties implements CommonContentHeaderProperties +public class BasicContentHeaderProperties { //persistent & non-persistent constants, values as per JMS DeliveryMode public static final int NON_PERSISTENT = 1; diff --git a/java/common/src/main/java/org/apache/qpid/framing/CommonContentHeaderProperties.java b/java/common/src/main/java/org/apache/qpid/framing/CommonContentHeaderProperties.java deleted file mode 100644 index 7162c37062..0000000000 --- a/java/common/src/main/java/org/apache/qpid/framing/CommonContentHeaderProperties.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.framing; - -public interface CommonContentHeaderProperties extends ContentHeaderProperties -{ - AMQShortString getContentType(); - - void setContentType(AMQShortString contentType); - - FieldTable getHeaders(); - - void setHeaders(FieldTable headers); - - byte getDeliveryMode(); - - void setDeliveryMode(byte deliveryMode); - - byte getPriority(); - - void setPriority(byte priority); - - AMQShortString getCorrelationId(); - - void setCorrelationId(AMQShortString correlationId); - - AMQShortString getReplyTo(); - - void setReplyTo(AMQShortString replyTo); - - long getExpiration(); - - void setExpiration(long expiration); - - AMQShortString getMessageId(); - - void setMessageId(AMQShortString messageId); - - long getTimestamp(); - - void setTimestamp(long timestamp); - - AMQShortString getType(); - - void setType(AMQShortString type); - - AMQShortString getUserId(); - - void setUserId(AMQShortString userId); - - AMQShortString getAppId(); - - void setAppId(AMQShortString appId); - - AMQShortString getClusterId(); - - void setClusterId(AMQShortString clusterId); - - AMQShortString getEncoding(); - - void setEncoding(AMQShortString encoding); -} diff --git a/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderBody.java b/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderBody.java index f6fa89a91c..131d796af4 100644 --- a/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderBody.java +++ b/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderBody.java @@ -39,7 +39,7 @@ public class ContentHeaderBody implements AMQBody private long bodySize; /** must never be null */ - private ContentHeaderProperties properties; + private BasicContentHeaderProperties properties; public ContentHeaderBody() { @@ -57,13 +57,13 @@ public class ContentHeaderBody implements AMQBody } - public ContentHeaderBody(ContentHeaderProperties props, int classId) + public ContentHeaderBody(BasicContentHeaderProperties props, int classId) { properties = props; this.classId = classId; } - public ContentHeaderBody(int classId, int weight, ContentHeaderProperties props, long bodySize) + public ContentHeaderBody(int classId, int weight, BasicContentHeaderProperties props, long bodySize) { this(props, classId); this.weight = weight; @@ -121,12 +121,12 @@ public class ContentHeaderBody implements AMQBody return new AMQFrame(channelId, body); } - public ContentHeaderProperties getProperties() + public BasicContentHeaderProperties getProperties() { return properties; } - public void setProperties(ContentHeaderProperties props) + public void setProperties(BasicContentHeaderProperties props) { properties = props; } diff --git a/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderProperties.java b/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderProperties.java deleted file mode 100644 index 2e1b988aa3..0000000000 --- a/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderProperties.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.framing; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; - - -/** - * There will be an implementation of this interface for each content type. All content types have associated - * header properties and this provides a way to encode and decode them. - */ -public interface ContentHeaderProperties -{ - /** - * Writes the property list to the buffer, in a suitably encoded form. - * @param buffer The buffer to write to - */ - void writePropertyListPayload(DataOutput buffer) throws IOException; - - /** - * Populates the properties from buffer. - * @param buffer The buffer to read from. - * @param propertyFlags he property flags. - * @throws AMQFrameDecodingException when the buffer does not contain valid data - */ - void populatePropertiesFromBuffer(DataInput buffer, int propertyFlags, int size) - throws AMQFrameDecodingException, IOException; - - /** - * @return the size of the encoded property list in bytes. - */ - int getPropertyListSize(); - - /** - * Gets the property flags. Property flags indicate which properties are set in the list. The - * position and meaning of each flag is defined in the protocol specification for the particular - * content type with which these properties are associated. - * @return flags - */ - int getPropertyFlags(); - -} diff --git a/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java b/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java index ff97c0b28f..55961db06b 100644 --- a/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java +++ b/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java @@ -38,11 +38,11 @@ public class ContentHeaderPropertiesFactory { } - public ContentHeaderProperties createContentHeaderProperties(int classId, int propertyFlags, + public BasicContentHeaderProperties createContentHeaderProperties(int classId, int propertyFlags, DataInput buffer, int size) throws AMQFrameDecodingException, IOException { - ContentHeaderProperties properties; + 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. diff --git a/java/common/src/main/java/org/apache/qpid/framing/abstraction/ContentChunk.java b/java/common/src/main/java/org/apache/qpid/framing/abstraction/ContentChunk.java deleted file mode 100644 index 470b7b05e3..0000000000 --- a/java/common/src/main/java/org/apache/qpid/framing/abstraction/ContentChunk.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.framing.abstraction; - -public interface ContentChunk -{ - int getSize(); - byte[] getData(); - - void reduceToFit(); -} diff --git a/java/common/src/main/java/org/apache/qpid/framing/abstraction/MessagePublishInfoConverter.java b/java/common/src/main/java/org/apache/qpid/framing/abstraction/MessagePublishInfoConverter.java deleted file mode 100644 index 01d1a8a17b..0000000000 --- a/java/common/src/main/java/org/apache/qpid/framing/abstraction/MessagePublishInfoConverter.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.abstraction; - -import org.apache.qpid.framing.AMQMethodBody; - - -public interface MessagePublishInfoConverter -{ - public MessagePublishInfo convertToInfo(AMQMethodBody body); - public AMQMethodBody convertToBody(MessagePublishInfo info); - -} diff --git a/java/common/src/main/java/org/apache/qpid/framing/abstraction/ProtocolVersionMethodConverter.java b/java/common/src/main/java/org/apache/qpid/framing/abstraction/ProtocolVersionMethodConverter.java index d1e53d6907..b3897771c5 100644 --- a/java/common/src/main/java/org/apache/qpid/framing/abstraction/ProtocolVersionMethodConverter.java +++ b/java/common/src/main/java/org/apache/qpid/framing/abstraction/ProtocolVersionMethodConverter.java @@ -21,14 +21,10 @@ package org.apache.qpid.framing.abstraction; -import org.apache.qpid.framing.AMQBody; +import org.apache.qpid.framing.AMQMethodBody; -public interface ProtocolVersionMethodConverter extends MessagePublishInfoConverter +public interface ProtocolVersionMethodConverter { - AMQBody convertToBody(ContentChunk contentBody); - ContentChunk convertToContentChunk(AMQBody body); - - void configure(); - - AMQBody convertToBody(byte[] input); + public MessagePublishInfo convertToInfo(AMQMethodBody body); + public AMQMethodBody convertToBody(MessagePublishInfo info); } diff --git a/java/common/src/main/java/org/apache/qpid/framing/amqp_0_9/MethodConverter_0_9.java b/java/common/src/main/java/org/apache/qpid/framing/amqp_0_9/MethodConverter_0_9.java index b3eb1211a5..6456eacab1 100644 --- a/java/common/src/main/java/org/apache/qpid/framing/amqp_0_9/MethodConverter_0_9.java +++ b/java/common/src/main/java/org/apache/qpid/framing/amqp_0_9/MethodConverter_0_9.java @@ -21,13 +21,10 @@ package org.apache.qpid.framing.amqp_0_9; -import org.apache.qpid.framing.AMQBody; import org.apache.qpid.framing.AMQMethodBody; import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.framing.BasicPublishBody; -import org.apache.qpid.framing.ContentBody; import org.apache.qpid.framing.abstraction.AbstractMethodConverter; -import org.apache.qpid.framing.abstraction.ContentChunk; import org.apache.qpid.framing.abstraction.MessagePublishInfo; import org.apache.qpid.framing.abstraction.MessagePublishInfoImpl; import org.apache.qpid.framing.abstraction.ProtocolVersionMethodConverter; @@ -35,48 +32,12 @@ import org.apache.qpid.framing.abstraction.ProtocolVersionMethodConverter; public class MethodConverter_0_9 extends AbstractMethodConverter implements ProtocolVersionMethodConverter { - private int _basicPublishClassId; - private int _basicPublishMethodId; public MethodConverter_0_9() { super((byte)0,(byte)9); - - - } - - public AMQBody convertToBody(ContentChunk contentChunk) - { - if(contentChunk instanceof ContentChunk_0_9) - { - return ((ContentChunk_0_9)contentChunk).toBody(); - } - else - { - return new ContentBody(contentChunk.getData()); - } - } - - public ContentChunk convertToContentChunk(AMQBody body) - { - final ContentBody contentBodyChunk = (ContentBody) body; - - return new ContentChunk_0_9(contentBodyChunk); - - } - - public void configure() - { - - _basicPublishClassId = org.apache.qpid.framing.amqp_0_9.BasicPublishBodyImpl.CLASS_ID; - _basicPublishMethodId = BasicPublishBodyImpl.METHOD_ID; - } - public AMQBody convertToBody(byte[] data) - { - return new ContentBody(data); - } public MessagePublishInfo convertToInfo(AMQMethodBody methodBody) { @@ -103,33 +64,4 @@ public class MethodConverter_0_9 extends AbstractMethodConverter implements Prot } - private static class ContentChunk_0_9 implements ContentChunk - { - private final ContentBody _contentBodyChunk; - - public ContentChunk_0_9(final ContentBody contentBodyChunk) - { - _contentBodyChunk = contentBodyChunk; - } - - public int getSize() - { - return _contentBodyChunk.getSize(); - } - - public byte[] getData() - { - return _contentBodyChunk.getPayload(); - } - - public void reduceToFit() - { - _contentBodyChunk.reduceBufferToFit(); - } - - public AMQBody toBody() - { - return _contentBodyChunk; - } - } } diff --git a/java/common/src/main/java/org/apache/qpid/framing/amqp_0_91/MethodConverter_0_91.java b/java/common/src/main/java/org/apache/qpid/framing/amqp_0_91/MethodConverter_0_91.java index d33749d795..e25dc8a022 100644 --- a/java/common/src/main/java/org/apache/qpid/framing/amqp_0_91/MethodConverter_0_91.java +++ b/java/common/src/main/java/org/apache/qpid/framing/amqp_0_91/MethodConverter_0_91.java @@ -21,61 +21,22 @@ package org.apache.qpid.framing.amqp_0_91; -import org.apache.qpid.framing.AMQBody; import org.apache.qpid.framing.AMQMethodBody; import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.framing.BasicPublishBody; -import org.apache.qpid.framing.ContentBody; import org.apache.qpid.framing.abstraction.AbstractMethodConverter; -import org.apache.qpid.framing.abstraction.ContentChunk; import org.apache.qpid.framing.abstraction.MessagePublishInfo; import org.apache.qpid.framing.abstraction.MessagePublishInfoImpl; import org.apache.qpid.framing.abstraction.ProtocolVersionMethodConverter; public class MethodConverter_0_91 extends AbstractMethodConverter implements ProtocolVersionMethodConverter { - private int _basicPublishClassId; - private int _basicPublishMethodId; public MethodConverter_0_91() { super((byte)0,(byte)9); - - - } - - public AMQBody convertToBody(ContentChunk contentChunk) - { - if(contentChunk instanceof ContentChunk_0_9) - { - return ((ContentChunk_0_9)contentChunk).toBody(); - } - else - { - return new ContentBody(contentChunk.getData()); - } - } - - public ContentChunk convertToContentChunk(AMQBody body) - { - final ContentBody contentBodyChunk = (ContentBody) body; - - return new ContentChunk_0_9(contentBodyChunk); - - } - - public void configure() - { - - _basicPublishClassId = BasicPublishBodyImpl.CLASS_ID; - _basicPublishMethodId = BasicPublishBodyImpl.METHOD_ID; - } - public AMQBody convertToBody(byte[] data) - { - return new ContentBody(data); - } public MessagePublishInfo convertToInfo(AMQMethodBody methodBody) { @@ -102,33 +63,4 @@ public class MethodConverter_0_91 extends AbstractMethodConverter implements Pro } - private static class ContentChunk_0_9 implements ContentChunk - { - private final ContentBody _contentBodyChunk; - - public ContentChunk_0_9(final ContentBody contentBodyChunk) - { - _contentBodyChunk = contentBodyChunk; - } - - public int getSize() - { - return _contentBodyChunk.getSize(); - } - - public byte[] getData() - { - return _contentBodyChunk.getPayload(); - } - - public void reduceToFit() - { - _contentBodyChunk.reduceBufferToFit(); - } - - public AMQBody toBody() - { - return _contentBodyChunk; - } - } } \ No newline at end of file diff --git a/java/common/src/main/java/org/apache/qpid/framing/amqp_8_0/MethodConverter_8_0.java b/java/common/src/main/java/org/apache/qpid/framing/amqp_8_0/MethodConverter_8_0.java index 575816db4f..5e50c2b3fb 100644 --- a/java/common/src/main/java/org/apache/qpid/framing/amqp_8_0/MethodConverter_8_0.java +++ b/java/common/src/main/java/org/apache/qpid/framing/amqp_8_0/MethodConverter_8_0.java @@ -21,71 +21,21 @@ package org.apache.qpid.framing.amqp_8_0; -import org.apache.qpid.framing.AMQBody; import org.apache.qpid.framing.AMQMethodBody; import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.framing.BasicPublishBody; -import org.apache.qpid.framing.ContentBody; import org.apache.qpid.framing.abstraction.AbstractMethodConverter; -import org.apache.qpid.framing.abstraction.ContentChunk; import org.apache.qpid.framing.abstraction.MessagePublishInfo; import org.apache.qpid.framing.abstraction.MessagePublishInfoImpl; import org.apache.qpid.framing.abstraction.ProtocolVersionMethodConverter; public class MethodConverter_8_0 extends AbstractMethodConverter implements ProtocolVersionMethodConverter { - private int _basicPublishClassId; - private int _basicPublishMethodId; - public MethodConverter_8_0() { super((byte)8,(byte)0); - - - } - - public AMQBody convertToBody(ContentChunk contentChunk) - { - return new ContentBody(contentChunk.getData()); } - public ContentChunk convertToContentChunk(AMQBody body) - { - final ContentBody contentBodyChunk = (ContentBody) body; - - return new ContentChunk() - { - - public int getSize() - { - return contentBodyChunk.getSize(); - } - - public byte[] getData() - { - return contentBodyChunk.getPayload(); - } - - public void reduceToFit() - { - contentBodyChunk.reduceBufferToFit(); - } - }; - - } - - public void configure() - { - - _basicPublishClassId = BasicPublishBodyImpl.CLASS_ID; - _basicPublishMethodId = BasicPublishBodyImpl.METHOD_ID; - - } - - public AMQBody convertToBody(byte[] data) - { - return new ContentBody(data); - } public MessagePublishInfo convertToInfo(AMQMethodBody methodBody) { -- cgit v1.2.1