diff options
| author | Robert Gemmell <robbie@apache.org> | 2013-09-29 17:23:06 +0000 |
|---|---|---|
| committer | Robert Gemmell <robbie@apache.org> | 2013-09-29 17:23:06 +0000 |
| commit | c4a0841859a991af801d5200c397dfb4b344db8d (patch) | |
| tree | cdc408b57c01335c05d5f4ebd385f07e8d20ae0a /java | |
| parent | 96ada238c30186d12a3d15528a2cf42bc340135e (diff) | |
| download | qpid-python-c4a0841859a991af801d5200c397dfb4b344db8d.tar.gz | |
QPID-5192: update protocol generation templates to remove whitespace errors in and improve readability of generated classes
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1527357 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
19 files changed, 199 insertions, 262 deletions
diff --git a/java/common/Composite.tpl b/java/common/Composite.tpl index 2b2f8fda09..b03f002f16 100644 --- a/java/common/Composite.tpl +++ b/java/common/Composite.tpl @@ -1,6 +1,6 @@ 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 @@ -8,16 +8,16 @@ package org.apache.qpid.transport; * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * */ diff --git a/java/common/Constant.tpl b/java/common/Constant.tpl index da4233c847..911f790bcf 100644 --- a/java/common/Constant.tpl +++ b/java/common/Constant.tpl @@ -1,6 +1,6 @@ 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 @@ -8,16 +8,16 @@ package org.apache.qpid.transport; * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * */ diff --git a/java/common/Enum.tpl b/java/common/Enum.tpl index 0835d34a20..79ade419c5 100644 --- a/java/common/Enum.tpl +++ b/java/common/Enum.tpl @@ -1,6 +1,6 @@ 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 @@ -8,16 +8,16 @@ package org.apache.qpid.transport; * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * */ diff --git a/java/common/Invoker.tpl b/java/common/Invoker.tpl index 2087710517..3f317f96df 100644 --- a/java/common/Invoker.tpl +++ b/java/common/Invoker.tpl @@ -1,6 +1,6 @@ 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 @@ -8,16 +8,16 @@ package org.apache.qpid.transport; * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * */ diff --git a/java/common/MethodDelegate.tpl b/java/common/MethodDelegate.tpl index 27e20a7ef2..fd3e069b6b 100644 --- a/java/common/MethodDelegate.tpl +++ b/java/common/MethodDelegate.tpl @@ -1,6 +1,6 @@ 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 @@ -8,16 +8,16 @@ package org.apache.qpid.transport; * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * */ diff --git a/java/common/Option.tpl b/java/common/Option.tpl index c22b35b999..fc85d6b2f5 100644 --- a/java/common/Option.tpl +++ b/java/common/Option.tpl @@ -1,6 +1,6 @@ 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 @@ -8,16 +8,16 @@ package org.apache.qpid.transport; * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * */ diff --git a/java/common/StructFactory.tpl b/java/common/StructFactory.tpl index 09c669f74e..6e7d1158cd 100644 --- a/java/common/StructFactory.tpl +++ b/java/common/StructFactory.tpl @@ -1,6 +1,6 @@ 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 @@ -8,16 +8,16 @@ package org.apache.qpid.transport; * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * */ diff --git a/java/common/Type.tpl b/java/common/Type.tpl index 4635c4e367..31ac02af73 100644 --- a/java/common/Type.tpl +++ b/java/common/Type.tpl @@ -1,6 +1,6 @@ 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 @@ -8,16 +8,16 @@ package org.apache.qpid.transport; * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * */ diff --git a/java/common/templates/method/MethodBodyInterface.vm b/java/common/templates/method/MethodBodyInterface.vm index d5feba12de..29ecc4f115 100644 --- a/java/common/templates/method/MethodBodyInterface.vm +++ b/java/common/templates/method/MethodBodyInterface.vm @@ -2,16 +2,11 @@ #set( $name = "${name.substring(0,1).toUpperCase()}${name.substring(1)}" ) #end #macro( toUpperCamel $name )${name.substring(0,1).toUpperCase()}${name.substring(1)}#end - - - #set( $amqp_ClassName = $amqpClass.Name) #UpperCamel( $amqp_ClassName ) #set( $amqp_MethodName = $amqpMethod.Name ) #UpperCamel( $amqp_MethodName ) #set( $javaClassName = "${amqp_ClassName}${amqp_MethodName}Body" ) - - #set( $filename = "${javaClassName}.java") /* * @@ -22,9 +17,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -41,22 +36,15 @@ * $supportedVersion.getMajor()-$supportedVersion.getMinor() #end */ - - -package org.apache.qpid.framing; +package org.apache.qpid.framing; public interface ${javaClassName} extends EncodableAMQDataBlock, AMQMethodBody { - - #foreach( $field in $amqpMethod.Fields ) #if( $amqpMethod.isCommon( $field ) ) public $field.ConsistentNativeType get#toUpperCamel( ${field.Name} )(); #end #end - - - } diff --git a/java/common/templates/method/version/MethodBodyClass.vm b/java/common/templates/method/version/MethodBodyClass.vm index caa7277d22..a960d357d2 100644 --- a/java/common/templates/method/version/MethodBodyClass.vm +++ b/java/common/templates/method/version/MethodBodyClass.vm @@ -19,9 +19,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -36,10 +36,9 @@ * Supported AMQP version: * $version.getMajor()-$version.getMinor() */ - + #set( $clazz = $amqpClass.asSingleVersionClass( $version ) ) #set( $method = $amqpMethod.asSingleVersionMethod( $version ) ) - package org.apache.qpid.framing.amqp_$version.getMajor()_$version.getMinor(); import org.apache.qpid.codec.MarkableDataInput; @@ -57,37 +56,29 @@ public class ${javaClassName} extends AMQMethodBody_$version.getMajor()_$version { return new ${javaClassName}(in); } - - }; - - + public static AMQMethodBodyInstanceFactory getFactory() { return FACTORY_INSTANCE; } - public static final int CLASS_ID = $clazz.ClassId; - - public static final int METHOD_ID = $method.MethodId; - + public static final int CLASS_ID = $clazz.ClassId; + public static final int METHOD_ID = $method.MethodId; - // Fields declared in specification #foreach( $field in $method.ConsolidatedFields ) private final $field.NativeType _$field.getName(); // $field.UnderlyingFields #end - // Constructor - public ${javaClassName}(MarkableDataInput buffer) throws AMQFrameDecodingException, IOException { #foreach( $field in $method.ConsolidatedFields ) _$field.Name = read$field.getEncodingType()( buffer ); #end - } - + } + public ${javaClassName}( #foreach( $field in $method.FieldList ) #if( $velocityCount == $method.getFieldList().size() ) @@ -109,35 +100,34 @@ public class ${javaClassName} extends AMQMethodBody_$version.getMajor()_$version byte $consolidatedFieldName = (byte)0; #end if( $field.Name ) - { + { $consolidatedFieldName = (byte) (((int) $consolidatedFieldName) | (1 << $method.getPositionInBitField( $field.Name ))); - } + } #if( $velocityCount == $method.getFieldList().size()) - _$consolidatedFieldName = $consolidatedFieldName; -#else - -#end + _$consolidatedFieldName = $consolidatedFieldName; +#else + +#end #else #if( !$consolidatedFieldName.equals("") ) - _$consolidatedFieldName = $consolidatedFieldName; + _$consolidatedFieldName = $consolidatedFieldName; #end #set( $consolidatedFieldName = "" ) _$field.Name = $field.Name; #end #end } - - public int getClazz() - { - return CLASS_ID; + + public int getClazz() + { + return CLASS_ID; } - - public int getMethod() - { - return METHOD_ID; + + public int getMethod() + { + return METHOD_ID; } - #foreach( $field in $method.FieldList ) public final $field.NativeType get#toUpperCamel( ${field.Name} )() { @@ -150,20 +140,20 @@ public class ${javaClassName} extends AMQMethodBody_$version.getMajor()_$version #end protected int getBodySize() - { + { #set( $fixedSize = 0 ) #foreach( $field in $method.ConsolidatedFields ) -#if( $field.isFixedSize() ) +#if( $field.isFixedSize() ) #set( $fixedSize = $fixedSize + $field.Size ) #end #end - int size = $fixedSize; + int size = $fixedSize; #foreach( $field in $method.ConsolidatedFields ) -#if( ! $field.isFixedSize() ) +#if( ! $field.isFixedSize() ) size += getSizeOf( _$field.Name ); #end #end - return size; + return size; } public void writeMethodPayload(DataOutput buffer) throws IOException @@ -179,32 +169,28 @@ public class ${javaClassName} extends AMQMethodBody_$version.getMajor()_$version #set( $amqpMethodNameFirstCharU = $amqpMethodNameFirstChar.toUpperCase() ) #set( $amqpMethodNameUpperCamel = "$amqpMethodNameFirstCharU$amqpMethod.getName().substring(1)" ) #if( $amqpMethod.inAllVersions() ) - return dispatcher.dispatch${amqpClassNameUpperCamel}${amqpMethodNameUpperCamel}(this, channelId); + return dispatcher.dispatch${amqpClassNameUpperCamel}${amqpMethodNameUpperCamel}(this, channelId); #else - return ((MethodDispatcher_$version.getMajor()_$version.getMinor())dispatcher).dispatch${amqp_ClassName}${amqpMethodNameUpperCamel}(this, channelId); - -#end - + return ((MethodDispatcher_$version.getMajor()_$version.getMinor())dispatcher).dispatch${amqp_ClassName}${amqpMethodNameUpperCamel}(this, channelId); +#end } - - + public String toString() { StringBuilder buf = new StringBuilder("[$javaClassName: "); #foreach( $field in $method.FieldList ) buf.append( "$field.Name=" ); #if( $field.NativeType == "byte[]" ) - buf.append( get#toUpperCamel( $field.Name )() == null ? "null" : java.util.Arrays.toString( get#toUpperCamel( $field.Name )() ) ); + buf.append( get#toUpperCamel( $field.Name )() == null ? "null" : java.util.Arrays.toString( get#toUpperCamel( $field.Name )() ) ); #else - buf.append( get#toUpperCamel( $field.Name )() ); + buf.append( get#toUpperCamel( $field.Name )() ); #end #if( $velocityCount != $method.FieldList.size() ) - buf.append( ", " ); + buf.append( ", " ); #end #end buf.append("]"); return buf.toString(); } - } diff --git a/java/common/templates/model/ClientMethodDispatcherInterface.vm b/java/common/templates/model/ClientMethodDispatcherInterface.vm index 9e4aee7dee..e814d6b672 100644 --- a/java/common/templates/model/ClientMethodDispatcherInterface.vm +++ b/java/common/templates/model/ClientMethodDispatcherInterface.vm @@ -8,9 +8,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -27,12 +27,11 @@ * $supportedVersion.getMajor()-$supportedVersion.getMinor() #end */ - + package org.apache.qpid.framing; import org.apache.qpid.AMQException; - public interface ClientMethodDispatcher { @@ -48,7 +47,7 @@ public interface ClientMethodDispatcher #set( $amqpMethodNameFirstCharU = $amqpMethodNameFirstChar.toUpperCase() ) #set( $amqpMethodNameUpperCamel = "$amqpMethodNameFirstCharU$amqpMethod.getName().substring(1)" ) public boolean dispatch${amqpClassNameUpperCamel}${amqpMethodNameUpperCamel}(${amqpClassNameUpperCamel}${amqpMethodNameUpperCamel}Body body, int channelId) throws AMQException; -#end +#end #end #end #end diff --git a/java/common/templates/model/MethodDispatcherInterface.vm b/java/common/templates/model/MethodDispatcherInterface.vm index a2c6328c4e..698d68e76c 100644 --- a/java/common/templates/model/MethodDispatcherInterface.vm +++ b/java/common/templates/model/MethodDispatcherInterface.vm @@ -1,36 +1,36 @@ -#set( $filename = "MethodDispatcher.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.
- *
- */
-
-/*
- * This file is auto-generated by $generator - do not modify.
- * Supported AMQP version:
- #foreach( $supportedVersion in $model.VersionSet )
- * $supportedVersion.getMajor()-$supportedVersion.getMinor()
- #end
- */
-
-package org.apache.qpid.framing;
-
-public interface MethodDispatcher extends
- ClientMethodDispatcher, ServerMethodDispatcher
-{
-}
+#set( $filename = "MethodDispatcher.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. + * + */ + +/* + * This file is auto-generated by $generator - do not modify. + * Supported AMQP version: + #foreach( $supportedVersion in $model.VersionSet ) + * $supportedVersion.getMajor()-$supportedVersion.getMinor() + #end + */ + +package org.apache.qpid.framing; + +public interface MethodDispatcher extends + ClientMethodDispatcher, ServerMethodDispatcher +{ +} diff --git a/java/common/templates/model/MethodRegistryClass.vm b/java/common/templates/model/MethodRegistryClass.vm index f8a55f245a..cad115aa6c 100644 --- a/java/common/templates/model/MethodRegistryClass.vm +++ b/java/common/templates/model/MethodRegistryClass.vm @@ -8,9 +8,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -27,7 +27,7 @@ * $supportedVersion.getMajor()-$supportedVersion.getMinor() #end */ - + package org.apache.qpid.framing; import java.io.IOException; @@ -48,12 +48,10 @@ public abstract class MethodRegistry #set( $verName = "_$supportedVersion.getMajor()_$supportedVersion.getMinor()" ) #set( $regPackage = "org.apache.qpid.framing.amqp$verName" ) - public static final MethodRegistry registry_$supportedVersion.getMajor()_$supportedVersion.getMinor() = - new ${regPackage}.MethodRegistry${verName}(); - + public static final MethodRegistry registry_$supportedVersion.getMajor()_$supportedVersion.getMinor() = + new ${regPackage}.MethodRegistry${verName}(); #end - - + public abstract AMQMethodBody convertToBody(MarkableDataInput in, long size) throws AMQFrameDecodingException, IOException; @@ -61,7 +59,6 @@ public abstract class MethodRegistry public abstract int getMaxMethodId(int classId); - protected MethodRegistry(ProtocolVersion pv) { _registries.put(pv, this); @@ -84,22 +81,18 @@ public abstract class MethodRegistry #set( $amqpMethodNameFirstChar = $amqpMethod.getName().substring(0,1) ) #set( $amqpMethodNameFirstCharU = $amqpMethodNameFirstChar.toUpperCase() ) #set( $amqpMethodNameUpperCamel = "$amqpMethodNameFirstCharU$amqpMethod.getName().substring(1)" ) - public abstract ${amqpClassNameUpperCamel}${amqpMethodNameUpperCamel}Body create${amqpClassNameUpperCamel}${amqpMethodNameUpperCamel}Body( + public abstract ${amqpClassNameUpperCamel}${amqpMethodNameUpperCamel}Body create${amqpClassNameUpperCamel}${amqpMethodNameUpperCamel}Body( #foreach( $field in $amqpMethod.FieldList ) #if( $velocityCount == $amqpMethod.getFieldList().size() ) final $field.NativeType $field.Name #else final $field.NativeType $field.Name, #end -#end - ); - - +#end + ); #end #end #end - - public abstract ProtocolVersionMethodConverter getProtocolVersionMethodConverter(); - + public abstract ProtocolVersionMethodConverter getProtocolVersionMethodConverter(); } diff --git a/java/common/templates/model/ProtocolVersionListClass.vm b/java/common/templates/model/ProtocolVersionListClass.vm index 78605c70ff..e8e2b8cc5d 100644 --- a/java/common/templates/model/ProtocolVersionListClass.vm +++ b/java/common/templates/model/ProtocolVersionListClass.vm @@ -8,9 +8,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at -* +* * http://www.apache.org/licenses/LICENSE-2.0 -* +* * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -36,14 +36,12 @@ 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; @@ -66,7 +64,6 @@ public class ProtocolVersion implements Comparable return _minorVersion > 90 ? (byte) (_minorVersion / 10) : _minorVersion; } - public byte getRevisionVersion() { return _minorVersion > 90 ? (byte) (_minorVersion % 10) : (byte) 0; @@ -77,28 +74,27 @@ public class ProtocolVersion implements Comparable 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 - */ - + + /* + * 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); - } - + { + 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; @@ -131,71 +127,63 @@ public class ProtocolVersion implements Comparable { 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<ProtocolVersion> _supportedVersions; - private static final Map<String, ProtocolVersion> _nameToVersionMap = - new HashMap<String, ProtocolVersion>(); - private static final ProtocolVersion _defaultVersion; + private static final Map<String, ProtocolVersion> _nameToVersionMap = + new HashMap<String, ProtocolVersion>(); + private static final ProtocolVersion _defaultVersion; - public static final ProtocolVersion v0_10 = new ProtocolVersion((byte)0,(byte)10); #foreach( $version in $model.getVersionSet() ) #set( $versionId = "v$version.getMajor()_$version.getMinor()" ) public static final ProtocolVersion $versionId = new ProtocolVersion((byte)$version.getMajor(),(byte)$version.getMinor()); #end - - + static { SortedSet<ProtocolVersion> versions = new TreeSet<ProtocolVersion>(); - versions.add(v0_10); - _nameToVersionMap.put("0-10", v0_10); + versions.add(v0_10); + _nameToVersionMap.put("0-10", v0_10); #foreach( $version in $model.getVersionSet() ) #set( $versionId = "v$version.getMajor()_$version.getMinor()" ) versions.add($versionId); - _nameToVersionMap.put("${version.getMajor()}-${version.getMinor()}", $versionId); + _nameToVersionMap.put("${version.getMajor()}-${version.getMinor()}", $versionId); #end _supportedVersions = Collections.unmodifiableSortedSet(versions); - - - ProtocolVersion systemDefinedVersion = - _nameToVersionMap.get(System.getProperty("org.apache.qpid.amqp_version")); - - _defaultVersion = (systemDefinedVersion == null) - ? getLatestSupportedVersion() - : systemDefinedVersion; + + ProtocolVersion systemDefinedVersion = + _nameToVersionMap.get(System.getProperty("org.apache.qpid.amqp_version")); + + _defaultVersion = (systemDefinedVersion == null) + ? getLatestSupportedVersion() + : systemDefinedVersion; } - public static SortedSet<ProtocolVersion> getSupportedProtocolVersions() { return _supportedVersions; } - - public static ProtocolVersion parse(String name) { return _nameToVersionMap.get(name); } - + public static ProtocolVersion defaultProtocolVersion() { return _defaultVersion; } - } diff --git a/java/common/templates/model/ServerMethodDispatcherInterface.vm b/java/common/templates/model/ServerMethodDispatcherInterface.vm index b80d6027b7..fd7b643806 100644 --- a/java/common/templates/model/ServerMethodDispatcherInterface.vm +++ b/java/common/templates/model/ServerMethodDispatcherInterface.vm @@ -8,9 +8,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -27,12 +27,11 @@ * $supportedVersion.getMajor()-$supportedVersion.getMinor() #end */ - + package org.apache.qpid.framing; import org.apache.qpid.AMQException; - public interface ServerMethodDispatcher { @@ -48,7 +47,7 @@ public interface ServerMethodDispatcher #set( $amqpMethodNameFirstCharU = $amqpMethodNameFirstChar.toUpperCase() ) #set( $amqpMethodNameUpperCamel = "$amqpMethodNameFirstCharU$amqpMethod.getName().substring(1)" ) public boolean dispatch${amqpClassNameUpperCamel}${amqpMethodNameUpperCamel}(${amqpClassNameUpperCamel}${amqpMethodNameUpperCamel}Body body, int channelId) throws AMQException; -#end +#end #end #end #end diff --git a/java/common/templates/model/version/ClientMethodDispatcherInterface.vm b/java/common/templates/model/version/ClientMethodDispatcherInterface.vm index 80705c1a39..24fe9e8223 100644 --- a/java/common/templates/model/version/ClientMethodDispatcherInterface.vm +++ b/java/common/templates/model/version/ClientMethodDispatcherInterface.vm @@ -8,9 +8,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -27,13 +27,12 @@ * $supportedVersion.getMajor()-$supportedVersion.getMinor() #end */ - + package org.apache.qpid.framing.amqp_$version.getMajor()_$version.getMinor(); import org.apache.qpid.AMQException; import org.apache.qpid.framing.*; - public interface ClientMethodDispatcher_${version.getMajor()}_${version.getMinor()} extends ClientMethodDispatcher { diff --git a/java/common/templates/model/version/MethodDispatcherInterface.vm b/java/common/templates/model/version/MethodDispatcherInterface.vm index 272ceff915..2209188b15 100644 --- a/java/common/templates/model/version/MethodDispatcherInterface.vm +++ b/java/common/templates/model/version/MethodDispatcherInterface.vm @@ -8,9 +8,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -27,14 +27,14 @@ * $supportedVersion.getMajor()-$supportedVersion.getMinor() #end */ - + package org.apache.qpid.framing.amqp_$version.getMajor()_$version.getMinor(); import org.apache.qpid.framing.*; -public interface MethodDispatcher_${version.getMajor()}_${version.getMinor()} +public interface MethodDispatcher_${version.getMajor()}_${version.getMinor()} extends MethodDispatcher, - ServerMethodDispatcher_${version.getMajor()}_${version.getMinor()}, + ServerMethodDispatcher_${version.getMajor()}_${version.getMinor()}, ClientMethodDispatcher_${version.getMajor()}_${version.getMinor()} { diff --git a/java/common/templates/model/version/MethodRegistryClass.vm b/java/common/templates/model/version/MethodRegistryClass.vm index ab5db0ea38..0c14bdd786 100644 --- a/java/common/templates/model/version/MethodRegistryClass.vm +++ b/java/common/templates/model/version/MethodRegistryClass.vm @@ -8,9 +8,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -25,7 +25,7 @@ * Supported AMQP version: * $version.getMajor()-$version.getMinor() */ - + package org.apache.qpid.framing.amqp_${version.getMajor()}_${version.getMinor()}; import org.apache.qpid.framing.*; @@ -43,25 +43,23 @@ import org.apache.qpid.codec.MarkableDataInput; public class MethodRegistry_$version.getMajor()_$version.getMinor() extends MethodRegistry { - + private static final Logger _log = LoggerFactory.getLogger(MethodRegistry.class); private ProtocolVersionMethodConverter _protocolVersionConverter = new MethodConverter_$version.getMajor()_$version.getMinor()(); - -#set( $specificModel = $model.asSingleVersionModel() ) - - -#set( $maxClassId = $specificModel.getMaximumClassId()+1 ) + +#set( $specificModel = $model.asSingleVersionModel() ) +#set( $maxClassId = $specificModel.getMaximumClassId()+1 ) private final AMQMethodBodyInstanceFactory[][] _factories = new AMQMethodBodyInstanceFactory[$maxClassId][]; public MethodRegistry_$version.getMajor()_$version.getMinor()() { this(new ProtocolVersion((byte)$version.getMajor(),(byte)$version.getMinor())); } - + public MethodRegistry_$version.getMajor()_$version.getMinor()(ProtocolVersion pv) { - super(pv); + super(pv); #foreach( $amqpClass in $specificModel.getClassList() ) #set( $amqpClassNameFirstChar = $amqpClass.getName().substring(0,1) ) #set( $amqpClassNameFirstCharU = $amqpClassNameFirstChar.toUpperCase() ) @@ -71,28 +69,24 @@ public class MethodRegistry_$version.getMajor()_$version.getMinor() extends Meth // Register method body instance factories for the $amqpClassNameUpperCamel class. -#set( $maxMethodId = $amqpClass.getMaximumMethodId()+1 ) +#set( $maxMethodId = $amqpClass.getMaximumMethodId()+1 ) _factories[$amqpClass.getClassId()] = new AMQMethodBodyInstanceFactory[$maxMethodId]; - + #foreach( $amqpMethod in $amqpClass.getMethodList() ) #set( $amqpMethodNameFirstChar = $amqpMethod.getName().substring(0,1) ) #set( $amqpMethodNameFirstCharU = $amqpMethodNameFirstChar.toUpperCase() ) #set( $amqpMethodNameUpperCamel = "$amqpMethodNameFirstCharU$amqpMethod.getName().substring(1)" ) - _factories[$amqpClass.getClassId()][$amqpMethod.getMethodId()] = ${amqpClassNameUpperCamel}${amqpMethodNameUpperCamel}BodyImpl.getFactory(); -#end - + _factories[$amqpClass.getClassId()][$amqpMethod.getMethodId()] = ${amqpClassNameUpperCamel}${amqpMethodNameUpperCamel}BodyImpl.getFactory(); +#end #end - - } - public AMQMethodBody convertToBody(MarkableDataInput in, long size) throws AMQFrameDecodingException, IOException { int classId = in.readUnsignedShort(); int methodId = in.readUnsignedShort(); - + AMQMethodBodyInstanceFactory bodyFactory; try { @@ -122,7 +116,6 @@ public class MethodRegistry_$version.getMajor()_$version.getMinor() extends Meth } } - if (bodyFactory == null) { throw new AMQFrameDecodingException(AMQConstant.COMMAND_INVALID, @@ -130,44 +123,38 @@ public class MethodRegistry_$version.getMajor()_$version.getMinor() extends Meth + " (while trying to decode class " + classId + " method " + methodId + "."); } - return bodyFactory.newInstance(in, size); - - } - public int getMaxClassId() { return $specificModel.getMaximumClassId(); } - + public int getMaxMethodId(int classId) { - return _factories[classId].length - 1; + return _factories[classId].length - 1; } - - #foreach( $amqpClass in $specificModel.getClassList() ) #set( $amqpClassNameFirstChar = $amqpClass.getName().substring(0,1) ) #set( $amqpClassNameFirstCharU = $amqpClassNameFirstChar.toUpperCase() ) #set( $amqpClassNameUpperCamel = "$amqpClassNameFirstCharU$amqpClass.getName().substring(1)" ) - + #foreach( $amqpMethod in $amqpClass.getMethodList() ) #set( $amqpMethodNameFirstChar = $amqpMethod.getName().substring(0,1) ) #set( $amqpMethodNameFirstCharU = $amqpMethodNameFirstChar.toUpperCase() ) #set( $amqpMethodNameUpperCamel = "$amqpMethodNameFirstCharU$amqpMethod.getName().substring(1)" ) - public ${amqpClassNameUpperCamel}${amqpMethodNameUpperCamel}Body create${amqpClassNameUpperCamel}${amqpMethodNameUpperCamel}Body( + public ${amqpClassNameUpperCamel}${amqpMethodNameUpperCamel}Body create${amqpClassNameUpperCamel}${amqpMethodNameUpperCamel}Body( #foreach( $field in $amqpMethod.FieldList ) #if( $velocityCount == $amqpMethod.getFieldList().size() ) final $field.NativeType $field.Name #else final $field.NativeType $field.Name, #end -#end - ) +#end + ) { return new ${amqpClassNameUpperCamel}${amqpMethodNameUpperCamel}BodyImpl( #foreach( $field in $amqpMethod.FieldList ) @@ -176,19 +163,17 @@ public class MethodRegistry_$version.getMajor()_$version.getMinor() extends Meth #else $field.Name, #end -#end - ); +#end + ); } - -#end - + +#end + #end - - + public ProtocolVersionMethodConverter getProtocolVersionMethodConverter() { return _protocolVersionConverter; - } + } - } diff --git a/java/common/templates/model/version/ServerMethodDispatcherInterface.vm b/java/common/templates/model/version/ServerMethodDispatcherInterface.vm index db388fcc65..a26154ff84 100644 --- a/java/common/templates/model/version/ServerMethodDispatcherInterface.vm +++ b/java/common/templates/model/version/ServerMethodDispatcherInterface.vm @@ -8,9 +8,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -27,7 +27,7 @@ * $supportedVersion.getMajor()-$supportedVersion.getMinor() #end */ - + package org.apache.qpid.framing.amqp_$version.getMajor()_$version.getMinor(); import org.apache.qpid.AMQException; |
