activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r565003 [6/17] - in /activemq/trunk: activemq-fileserver/src/main/java/org/apache/activemq/util/ activemq-fileserver/src/test/java/org/apache/activemq/util/ activemq-jaas/src/main/java/org/apache/activemq/jaas/ activemq-jaas/src/test/java/o...
Date Sun, 12 Aug 2007 05:27:34 GMT
Modified: activemq/trunk/activemq-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/CppMarshallingClassesGenerator.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/CppMarshallingClassesGenerator.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/CppMarshallingClassesGenerator.java
(original)
+++ activemq/trunk/activemq-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/CppMarshallingClassesGenerator.java
Sat Aug 11 22:27:21 2007
@@ -16,11 +16,6 @@
  */
 package org.apache.activemq.openwire.tool;
 
-import org.codehaus.jam.JAnnotation;
-import org.codehaus.jam.JAnnotationValue;
-import org.codehaus.jam.JClass;
-import org.codehaus.jam.JProperty;
-
 import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -28,8 +23,12 @@
 import java.util.Iterator;
 import java.util.List;
 
+import org.codehaus.jam.JAnnotation;
+import org.codehaus.jam.JAnnotationValue;
+import org.codehaus.jam.JClass;
+import org.codehaus.jam.JProperty;
+
 /**
- *
  * @version $Revision: 381410 $
  */
 public class CppMarshallingClassesGenerator extends CppMarshallingHeadersGenerator {
@@ -45,40 +44,29 @@
 
         if (type.equals("boolean")) {
             out.println("info." + setter + "( bs.readBoolean() );");
-        }
-        else if (type.equals("byte")) {
+        } else if (type.equals("byte")) {
             out.println("info." + setter + "( DataStreamMarshaller.readByte(dataIn) );");
-        }
-        else if (type.equals("char")) {
+        } else if (type.equals("char")) {
             out.println("info." + setter + "( DataStreamMarshaller.readChar(dataIn) );");
-        }
-        else if (type.equals("short")) {
+        } else if (type.equals("short")) {
             out.println("info." + setter + "( DataStreamMarshaller.readShort(dataIn) );");
-        }
-        else if (type.equals("int")) {
+        } else if (type.equals("int")) {
             out.println("info." + setter + "( DataStreamMarshaller.readInt(dataIn) );");
-        }
-        else if (type.equals("long")) {
+        } else if (type.equals("long")) {
             out.println("info." + setter + "( UnmarshalLong(wireFormat, dataIn, bs) );");
-        }
-        else if (type.equals("String")) {
+        } else if (type.equals("String")) {
             out.println("info." + setter + "( readString(dataIn, bs) );");
-        }
-        else if (type.equals("byte[]") || type.equals("ByteSequence")) {
+        } else if (type.equals("byte[]") || type.equals("ByteSequence")) {
             if (size != null) {
                 out.println("info." + setter + "( readBytes(dataIn, " + size.asInt() + ")
);");
-            }
-            else {
+            } else {
                 out.println("info." + setter + "( readBytes(dataIn, bs.readBoolean()) );");
             }
-        }
-        else if (isThrowable(property.getType())) {
+        } else if (isThrowable(property.getType())) {
             out.println("info." + setter + "( unmarshalBrokerError(wireFormat, dataIn, bs)
);");
-        }
-        else if (isCachedProperty(property)) {
+        } else if (isCachedProperty(property)) {
             out.println("info." + setter + "( (" + type + ") unmarshalCachedObject(wireFormat,
dataIn, bs) );");
-        }
-        else {
+        } else {
             out.println("info." + setter + "( (" + type + ") unmarshalNestedObject(wireFormat,
dataIn, bs) );");
         }
     }
@@ -96,8 +84,7 @@
             out.println("        }");
             out.println("        info." + setter + "( value );");
             out.println("    }");
-        }
-        else {
+        } else {
             out.println("    if (bs.readBoolean()) {");
             out.println("        short size = DataStreamMarshaller.readShort(dataIn);");
             out.println("        " + arrayType + "[] value = new " + arrayType + "[size];");
@@ -116,7 +103,7 @@
         List properties = getProperties();
         int baseSize = 0;
         for (Iterator iter = properties.iterator(); iter.hasNext();) {
-            JProperty property = (JProperty) iter.next();
+            JProperty property = (JProperty)iter.next();
             JAnnotation annotation = property.getAnnotation("openwire:property");
             JAnnotationValue size = annotation.getValue("size");
             JClass propertyType = property.getType();
@@ -126,50 +113,37 @@
             out.print(indent);
             if (type.equals("boolean")) {
                 out.println("bs.writeBoolean(" + getter + ");");
-            }
-            else if (type.equals("byte")) {
+            } else if (type.equals("byte")) {
                 baseSize += 1;
-            }
-            else if (type.equals("char")) {
+            } else if (type.equals("char")) {
                 baseSize += 1;
-            }
-            else if (type.equals("short")) {
+            } else if (type.equals("short")) {
                 baseSize += 1;
-            }
-            else if (type.equals("int")) {
+            } else if (type.equals("int")) {
                 baseSize += 1;
-            }
-            else if (type.equals("long")) {
+            } else if (type.equals("long")) {
                 out.println("rc += marshal1Long(wireFormat, " + getter + ", bs);");
-            }
-            else if (type.equals("String")) {
+            } else if (type.equals("String")) {
                 out.println("rc += writeString(" + getter + ", bs);");
-            }
-            else if (type.equals("byte[]") || type.equals("ByteSequence")) {
+            } else if (type.equals("byte[]") || type.equals("ByteSequence")) {
                 if (size == null) {
                     out.println("bs.writeBoolean(" + getter + "!=null);");
                     out.println("    rc += " + getter + "==null ? 0 : " + getter + ".Length+4;");
-                }
-                else {
+                } else {
                     baseSize += size.asInt();
                 }
-            }
-            else if (propertyType.isArrayType()) {
+            } else if (propertyType.isArrayType()) {
                 if (size != null) {
                     out.println("rc += marshalObjectArrayConstSize(wireFormat, " + getter
+ ", bs, " + size.asInt() + ");");
-                }
-                else {
+                } else {
                     out.println("rc += marshalObjectArray(wireFormat, " + getter + ", bs);");
                 }
-            }
-            else if (isThrowable(propertyType)) {
+            } else if (isThrowable(propertyType)) {
                 out.println("rc += marshalBrokerError(wireFormat, " + getter + ", bs);");
-            }
-            else {
+            } else {
                 if (isCachedProperty(property)) {
                     out.println("rc += marshal1CachedObject(wireFormat, " + getter + ", bs);");
-                }
-                else {
+                } else {
                     out.println("rc += marshal1NestedObject(wireFormat, " + getter + ", bs);");
                 }
             }
@@ -180,7 +154,7 @@
     protected void generateMarshal2Body(PrintWriter out) {
         List properties = getProperties();
         for (Iterator iter = properties.iterator(); iter.hasNext();) {
-            JProperty property = (JProperty) iter.next();
+            JProperty property = (JProperty)iter.next();
             JAnnotation annotation = property.getAnnotation("openwire:property");
             JAnnotationValue size = annotation.getValue("size");
             JClass propertyType = property.getType();
@@ -190,216 +164,203 @@
             out.print(indent);
             if (type.equals("boolean")) {
                 out.println("bs.readBoolean();");
-            }
-            else if (type.equals("byte")) {
+            } else if (type.equals("byte")) {
                 out.println("DataStreamMarshaller.writeByte(" + getter + ", dataOut);");
-            }
-            else if (type.equals("char")) {
+            } else if (type.equals("char")) {
                 out.println("DataStreamMarshaller.writeChar(" + getter + ", dataOut);");
-            }
-            else if (type.equals("short")) {
+            } else if (type.equals("short")) {
                 out.println("DataStreamMarshaller.writeShort(" + getter + ", dataOut);");
-            }
-            else if (type.equals("int")) {
+            } else if (type.equals("int")) {
                 out.println("DataStreamMarshaller.writeInt(" + getter + ", dataOut);");
-            }
-            else if (type.equals("long")) {
+            } else if (type.equals("long")) {
                 out.println("marshal2Long(wireFormat, " + getter + ", dataOut, bs);");
-            }
-            else if (type.equals("String")) {
+            } else if (type.equals("String")) {
                 out.println("writeString(" + getter + ", dataOut, bs);");
-            }
-            else if (type.equals("byte[]") || type.equals("ByteSequence")) {
+            } else if (type.equals("byte[]") || type.equals("ByteSequence")) {
                 if (size != null) {
                     out.println("dataOut.write(" + getter + ", 0, " + size.asInt() + ");");
-                }
-                else {
+                } else {
                     out.println("if(bs.readBoolean()) {");
                     out.println("       DataStreamMarshaller.writeInt(" + getter + ".Length,
dataOut);");
                     out.println("       dataOut.write(" + getter + ");");
                     out.println("    }");
                 }
-            }
-            else if (propertyType.isArrayType()) {
+            } else if (propertyType.isArrayType()) {
                 if (size != null) {
                     out.println("marshalObjectArrayConstSize(wireFormat, " + getter + ",
dataOut, bs, " + size.asInt() + ");");
-                }
-                else {
+                } else {
                     out.println("marshalObjectArray(wireFormat, " + getter + ", dataOut,
bs);");
                 }
-            }
-            else if (isThrowable(propertyType)) {
+            } else if (isThrowable(propertyType)) {
                 out.println("marshalBrokerError(wireFormat, " + getter + ", dataOut, bs);");
-            }
-            else {
+            } else {
                 if (isCachedProperty(property)) {
                     out.println("marshal2CachedObject(wireFormat, " + getter + ", dataOut,
bs);");
-                }
-                else {
+                } else {
                     out.println("marshal2NestedObject(wireFormat, " + getter + ", dataOut,
bs);");
                 }
             }
         }
     }
-    
-    
-	protected void generateFile(PrintWriter out) throws Exception {
-		generateLicence(out);
-		
-out.println("#include \"marshal/"+className+".hpp\"");
-out.println("");
-out.println("using namespace apache::activemq::client::marshal;");
-out.println("");
-out.println("/*");
-out.println(" *  Marshalling code for Open Wire Format for "+jclass.getSimpleName()+"");
-out.println(" *");
-out.println(" * NOTE!: This file is autogenerated - do not modify!");
-out.println(" *        if you need to make a change, please see the Groovy scripts in the");
-out.println(" *        activemq-core module");
-out.println(" */");
-out.println("");
-out.println(""+className+"::"+className+"()");
-out.println("{");
-out.println("    // no-op");
-out.println("}");
-out.println("");
-out.println(""+className+"::~"+className+"()");
-out.println("{");
-out.println("    // no-op");
-out.println("}");
-out.println("");
-
-		if( !isAbstractClass() ) {
-out.println("");
-out.println("");
-out.println("IDataStructure* "+className+"::createObject() ");
-out.println("{");
-out.println("    return new "+jclass.getSimpleName()+"();");
-out.println("}");
-out.println("");
-out.println("char "+className+"::getDataStructureType() ");
-out.println("{");
-out.println("    return "+jclass.getSimpleName()+".ID_"+jclass.getSimpleName()+";");
-out.println("}");
-		}
-
-out.println("");
-out.println("    /* ");
-out.println("     * Un-marshal an object instance from the data input stream");
-out.println("     */ ");
-out.println("void "+className+"::unmarshal(ProtocolFormat& wireFormat, Object o, BinaryReader&
dataIn, BooleanStream& bs) ");
-out.println("{");
-out.println("    base.unmarshal(wireFormat, o, dataIn, bs);");
- 
-		List properties = getProperties();
-		boolean marshallerAware = isMarshallerAware();
-		if( !properties.isEmpty() || marshallerAware )  {
-out.println("");
-out.println("    "+jclass.getSimpleName()+"& info = ("+jclass.getSimpleName()+"&)
o;");
-		}
-
-		if( marshallerAware ) {
-out.println("");
-out.println("    info.beforeUnmarshall(wireFormat);");
-out.println("        ");
-		}
-
-		generateTightUnmarshalBody(out);
-
-		if( marshallerAware ) {
-out.println("");
-out.println("    info.afterUnmarshall(wireFormat);");
-		}
-
-out.println("");
-out.println("}");
-out.println("");
-out.println("");
-out.println("/*");
-out.println(" * Write the booleans that this object uses to a BooleanStream");
-out.println(" */");
-out.println("int "+className+"::marshal1(ProtocolFormat& wireFormat, Object& o, BooleanStream&
bs) {");
-out.println("    "+jclass.getSimpleName()+"& info = ("+jclass.getSimpleName()+"&)
o;");
-
-
-		if( marshallerAware ) {
-out.println("");
-out.println("    info.beforeMarshall(wireFormat);");
-		}
-
-out.println("");
-out.println("    int rc = base.marshal1(wireFormat, info, bs);");
-
-		int baseSize = generateMarshal1Body(out);
-    
-out.println("");
-out.println("    return rc + "+baseSize+";");
-out.println("}");
-out.println("");
-out.println("/* ");
-out.println(" * Write a object instance to data output stream");
-out.println(" */");
-out.println("void "+className+"::marshal2(ProtocolFormat& wireFormat, Object& o,
BinaryWriter& dataOut, BooleanStream& bs) {");
-out.println("    base.marshal2(wireFormat, o, dataOut, bs);");
-
-		if( !properties.isEmpty() || marshallerAware ) {
-out.println("");
-out.println("    "+jclass.getSimpleName()+"& info = ("+jclass.getSimpleName()+"&)
o;");
-		}
-
-		generateMarshal2Body(out);
-
-		if( marshallerAware ) {
-out.println("");
-out.println("    info.afterMarshall(wireFormat);");
-		}
 
-out.println("");
-out.println("}");
+    protected void generateFile(PrintWriter out) throws Exception {
+        generateLicence(out);
+
+        out.println("#include \"marshal/" + className + ".hpp\"");
+        out.println("");
+        out.println("using namespace apache::activemq::client::marshal;");
+        out.println("");
+        out.println("/*");
+        out.println(" *  Marshalling code for Open Wire Format for " + jclass.getSimpleName()
+ "");
+        out.println(" *");
+        out.println(" * NOTE!: This file is autogenerated - do not modify!");
+        out.println(" *        if you need to make a change, please see the Groovy scripts
in the");
+        out.println(" *        activemq-core module");
+        out.println(" */");
+        out.println("");
+        out.println("" + className + "::" + className + "()");
+        out.println("{");
+        out.println("    // no-op");
+        out.println("}");
+        out.println("");
+        out.println("" + className + "::~" + className + "()");
+        out.println("{");
+        out.println("    // no-op");
+        out.println("}");
+        out.println("");
+
+        if (!isAbstractClass()) {
+            out.println("");
+            out.println("");
+            out.println("IDataStructure* " + className + "::createObject() ");
+            out.println("{");
+            out.println("    return new " + jclass.getSimpleName() + "();");
+            out.println("}");
+            out.println("");
+            out.println("char " + className + "::getDataStructureType() ");
+            out.println("{");
+            out.println("    return " + jclass.getSimpleName() + ".ID_" + jclass.getSimpleName()
+ ";");
+            out.println("}");
+        }
+
+        out.println("");
+        out.println("    /* ");
+        out.println("     * Un-marshal an object instance from the data input stream");
+        out.println("     */ ");
+        out.println("void " + className + "::unmarshal(ProtocolFormat& wireFormat, Object
o, BinaryReader& dataIn, BooleanStream& bs) ");
+        out.println("{");
+        out.println("    base.unmarshal(wireFormat, o, dataIn, bs);");
+
+        List properties = getProperties();
+        boolean marshallerAware = isMarshallerAware();
+        if (!properties.isEmpty() || marshallerAware) {
+            out.println("");
+            out.println("    " + jclass.getSimpleName() + "& info = (" + jclass.getSimpleName()
+ "&) o;");
+        }
+
+        if (marshallerAware) {
+            out.println("");
+            out.println("    info.beforeUnmarshall(wireFormat);");
+            out.println("        ");
+        }
+
+        generateTightUnmarshalBody(out);
+
+        if (marshallerAware) {
+            out.println("");
+            out.println("    info.afterUnmarshall(wireFormat);");
+        }
+
+        out.println("");
+        out.println("}");
+        out.println("");
+        out.println("");
+        out.println("/*");
+        out.println(" * Write the booleans that this object uses to a BooleanStream");
+        out.println(" */");
+        out.println("int " + className + "::marshal1(ProtocolFormat& wireFormat, Object&
o, BooleanStream& bs) {");
+        out.println("    " + jclass.getSimpleName() + "& info = (" + jclass.getSimpleName()
+ "&) o;");
+
+        if (marshallerAware) {
+            out.println("");
+            out.println("    info.beforeMarshall(wireFormat);");
+        }
+
+        out.println("");
+        out.println("    int rc = base.marshal1(wireFormat, info, bs);");
+
+        int baseSize = generateMarshal1Body(out);
+
+        out.println("");
+        out.println("    return rc + " + baseSize + ";");
+        out.println("}");
+        out.println("");
+        out.println("/* ");
+        out.println(" * Write a object instance to data output stream");
+        out.println(" */");
+        out.println("void " + className + "::marshal2(ProtocolFormat& wireFormat, Object&
o, BinaryWriter& dataOut, BooleanStream& bs) {");
+        out.println("    base.marshal2(wireFormat, o, dataOut, bs);");
+
+        if (!properties.isEmpty() || marshallerAware) {
+            out.println("");
+            out.println("    " + jclass.getSimpleName() + "& info = (" + jclass.getSimpleName()
+ "&) o;");
+        }
+
+        generateMarshal2Body(out);
+
+        if (marshallerAware) {
+            out.println("");
+            out.println("    info.afterMarshall(wireFormat);");
+        }
+
+        out.println("");
+        out.println("}");
     }
- 	
+
+    @SuppressWarnings("unchecked")
     public void generateFactory(PrintWriter out) {
-		generateLicence(out);
-out.println("");
-out.println("// Marshalling code for Open Wire Format");
-out.println("//");
-out.println("//");
-out.println("// NOTE!: This file is autogenerated - do not modify!");
-out.println("//        if you need to make a change, please see the Groovy scripts in the");
-out.println("//        activemq-openwire module");
-out.println("//");
-out.println("");
-out.println("#include \"marshal/"+className+".hpp\"");
-out.println("");
-
-		List list = new ArrayList(getConcreteClasses());
-		Collections.sort(list, new Comparator(){
-			public int compare(Object o1, Object o2) {
-				JClass c1 = (JClass) o1;
-				JClass c2 = (JClass) o2;
-				return c1.getSimpleName().compareTo(c2.getSimpleName());
-			}});
-		
-		for (Iterator iter = list.iterator(); iter.hasNext();) {
-			JClass jclass = (JClass) iter.next();
-out.println("#include \"marshal/"+jclass.getSimpleName()+"Marshaller.hpp\"");
-	    }        
-
-out.println("");
-out.println("");
-out.println("using namespace apache::activemq::client::marshal;");
-out.println("");
-out.println("");
-out.println("void MarshallerFactory::configure(ProtocolFormat& format) ");
-out.println("{");
-
-		for (Iterator iter = list.iterator(); iter.hasNext();) {
-			JClass jclass = (JClass) iter.next();
-out.println("    format.addMarshaller(new "+jclass.getSimpleName()+"Marshaller());");
-	    }        
+        generateLicence(out);
+        out.println("");
+        out.println("// Marshalling code for Open Wire Format");
+        out.println("//");
+        out.println("//");
+        out.println("// NOTE!: This file is autogenerated - do not modify!");
+        out.println("//        if you need to make a change, please see the Groovy scripts
in the");
+        out.println("//        activemq-openwire module");
+        out.println("//");
+        out.println("");
+        out.println("#include \"marshal/" + className + ".hpp\"");
+        out.println("");
+
+        List list = new ArrayList(getConcreteClasses());
+        Collections.sort(list, new Comparator() {
+            public int compare(Object o1, Object o2) {
+                JClass c1 = (JClass)o1;
+                JClass c2 = (JClass)o2;
+                return c1.getSimpleName().compareTo(c2.getSimpleName());
+            }
+        });
+
+        for (Iterator iter = list.iterator(); iter.hasNext();) {
+            JClass jclass = (JClass)iter.next();
+            out.println("#include \"marshal/" + jclass.getSimpleName() + "Marshaller.hpp\"");
+        }
+
+        out.println("");
+        out.println("");
+        out.println("using namespace apache::activemq::client::marshal;");
+        out.println("");
+        out.println("");
+        out.println("void MarshallerFactory::configure(ProtocolFormat& format) ");
+        out.println("{");
+
+        for (Iterator iter = list.iterator(); iter.hasNext();) {
+            JClass jclass = (JClass)iter.next();
+            out.println("    format.addMarshaller(new " + jclass.getSimpleName() + "Marshaller());");
+        }
 
-out.println("");
-out.println("}");
+        out.println("");
+        out.println("}");
 
     }
 }

Modified: activemq/trunk/activemq-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/CppMarshallingHeadersGenerator.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/CppMarshallingHeadersGenerator.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/CppMarshallingHeadersGenerator.java
(original)
+++ activemq/trunk/activemq-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/CppMarshallingHeadersGenerator.java
Sat Aug 11 22:27:21 2007
@@ -20,165 +20,162 @@
 import java.io.PrintWriter;
 
 /**
- *
  * @version $Revision: 381410 $
  */
 public class CppMarshallingHeadersGenerator extends JavaMarshallingGenerator {
 
-	protected String targetDir="./src";
+    protected String targetDir = "./src";
 
     public Object run() {
         filePostFix = getFilePostFix();
         if (destDir == null) {
-            destDir = new File(targetDir+"/marshal");
+            destDir = new File(targetDir + "/marshal");
         }
         return super.run();
-    }	   
-    
+    }
+
     protected String getFilePostFix() {
         return ".hpp";
     }
-    
-    
-	protected void generateLicence(PrintWriter out) {
-out.println("/*");
-out.println(" *");
-out.println(" * Licensed to the Apache Software Foundation (ASF) under one or more");
-out.println(" * contributor license agreements.  See the NOTICE file distributed with");
-out.println(" * this work for additional information regarding copyright ownership.");
-out.println(" * The ASF licenses this file to You under the Apache License, Version 2.0");
-out.println(" * (the \"License\"); you may not use this file except in compliance with");
-out.println(" * the License.  You may obtain a copy of the License at");
-out.println(" *");
-out.println(" * http://www.apache.org/licenses/LICENSE-2.0");
-out.println(" *");
-out.println(" * Unless required by applicable law or agreed to in writing, software");
-out.println(" * distributed under the License is distributed on an \"AS IS\" BASIS,");
-out.println(" * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.");
-out.println(" * See the License for the specific language governing permissions and");
-out.println(" * limitations under the License.");
-out.println(" */");
-	}
-
-	protected void generateFile(PrintWriter out) throws Exception {
-		generateLicence(out);
-		
-out.println("#ifndef "+className+"_hpp_");
-out.println("#define "+className+"_hpp_");
-out.println("");
-out.println("#include <string>");
-out.println("");
-out.println("#include \"command/IDataStructure.hpp\"");
-out.println("");
-out.println("/* we could cut this down  - for now include all possible headers */");
-out.println("#include \"command/BrokerId.hpp\"");
-out.println("#include \"command/ConnectionId.hpp\"");
-out.println("#include \"command/ConsumerId.hpp\"");
-out.println("#include \"command/ProducerId.hpp\"");
-out.println("#include \"command/SessionId.hpp\"");
-out.println("");
-out.println("#include \"io/BinaryReader.hpp\"");
-out.println("#include \"io/BinaryWriter.hpp\"");
-out.println("");
-out.println("#include \"command/"+baseClass+".hpp\"");
-out.println("#include \"util/ifr/p.hpp\"");
-out.println("");
-out.println("#include \"protocol/ProtocolFormat.hpp\"");
-out.println("");
-out.println("namespace apache");
-out.println("{");
-out.println("  namespace activemq");
-out.println("  {");
-out.println("    namespace client");
-out.println("    {");
-out.println("      namespace marshal");
-out.println("      {");
-out.println("        using namespace ifr ;");
-out.println("        using namespace apache::activemq::client::command;");
-out.println("        using namespace apache::activemq::client::io;");
-out.println("        using namespace apache::activemq::client::protocol;");
-out.println("");
-out.println("/*");
-out.println(" *");
-out.println(" */");
-out.println("class "+className+" : public "+baseClass+"");
-out.println("{");
-out.println("public:");
-out.println("    "+className+"() ;");
-out.println("    virtual ~"+className+"() ;");
-out.println("");
-out.println("    virtual IDataStructure* createCommand() ;");
-out.println("    virtual char getDataStructureType() ;");
-out.println("    ");
-out.println("    virtual void unmarshal(ProtocolFormat& wireFormat, Object o, BinaryReader&
dataIn, BooleanStream& bs) ;");
-out.println("    virtual int marshal1(ProtocolFormat& wireFormat, Object& o, BooleanStream&
bs) ;");
-out.println("    virtual void marshal2(ProtocolFormat& wireFormat, Object& o, BinaryWriter&
dataOut, BooleanStream& bs) ;");
-out.println("} ;");
-out.println("");
-out.println("/* namespace */");
-out.println("     }");
-out.println("    }");
-out.println("  }");
-out.println("}");
-out.println("#endif /*"+className+"_hpp_*/");
-        }
- 	
+
+    protected void generateLicence(PrintWriter out) {
+        out.println("/**");
+        out.println(" * Licensed to the Apache Software Foundation (ASF) under one or more");
+        out.println(" * contributor license agreements.  See the NOTICE file distributed
with");
+        out.println(" * this work for additional information regarding copyright ownership.");
+        out.println(" * The ASF licenses this file to You under the Apache License, Version
2.0");
+        out.println(" * (the \"License\"); you may not use this file except in compliance
with");
+        out.println(" * the License.  You may obtain a copy of the License at");
+        out.println(" *");
+        out.println(" *      http://www.apache.org/licenses/LICENSE-2.0");
+        out.println(" *");
+        out.println(" * Unless required by applicable law or agreed to in writing, software");
+        out.println(" * distributed under the License is distributed on an \"AS IS\" BASIS,");
+        out.println(" * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.");
+        out.println(" * See the License for the specific language governing permissions and");
+        out.println(" * limitations under the License.");
+        out.println(" */");
+    }
+
+    protected void generateFile(PrintWriter out) throws Exception {
+        generateLicence(out);
+
+        out.println("#ifndef " + className + "_hpp_");
+        out.println("#define " + className + "_hpp_");
+        out.println("");
+        out.println("#include <string>");
+        out.println("");
+        out.println("#include \"command/IDataStructure.hpp\"");
+        out.println("");
+        out.println("/* we could cut this down  - for now include all possible headers */");
+        out.println("#include \"command/BrokerId.hpp\"");
+        out.println("#include \"command/ConnectionId.hpp\"");
+        out.println("#include \"command/ConsumerId.hpp\"");
+        out.println("#include \"command/ProducerId.hpp\"");
+        out.println("#include \"command/SessionId.hpp\"");
+        out.println("");
+        out.println("#include \"io/BinaryReader.hpp\"");
+        out.println("#include \"io/BinaryWriter.hpp\"");
+        out.println("");
+        out.println("#include \"command/" + baseClass + ".hpp\"");
+        out.println("#include \"util/ifr/p.hpp\"");
+        out.println("");
+        out.println("#include \"protocol/ProtocolFormat.hpp\"");
+        out.println("");
+        out.println("namespace apache");
+        out.println("{");
+        out.println("  namespace activemq");
+        out.println("  {");
+        out.println("    namespace client");
+        out.println("    {");
+        out.println("      namespace marshal");
+        out.println("      {");
+        out.println("        using namespace ifr ;");
+        out.println("        using namespace apache::activemq::client::command;");
+        out.println("        using namespace apache::activemq::client::io;");
+        out.println("        using namespace apache::activemq::client::protocol;");
+        out.println("");
+        out.println("/*");
+        out.println(" *");
+        out.println(" */");
+        out.println("class " + className + " : public " + baseClass + "");
+        out.println("{");
+        out.println("public:");
+        out.println("    " + className + "() ;");
+        out.println("    virtual ~" + className + "() ;");
+        out.println("");
+        out.println("    virtual IDataStructure* createCommand() ;");
+        out.println("    virtual char getDataStructureType() ;");
+        out.println("    ");
+        out.println("    virtual void unmarshal(ProtocolFormat& wireFormat, Object o,
BinaryReader& dataIn, BooleanStream& bs) ;");
+        out.println("    virtual int marshal1(ProtocolFormat& wireFormat, Object&
o, BooleanStream& bs) ;");
+        out.println("    virtual void marshal2(ProtocolFormat& wireFormat, Object&
o, BinaryWriter& dataOut, BooleanStream& bs) ;");
+        out.println("} ;");
+        out.println("");
+        out.println("/* namespace */");
+        out.println("     }");
+        out.println("    }");
+        out.println("  }");
+        out.println("}");
+        out.println("#endif /*" + className + "_hpp_*/");
+    }
+
     public void generateFactory(PrintWriter out) {
-		generateLicence(out);
-out.println("");
-out.println("// Marshalling code for Open Wire Format ");
-out.println("//");
-out.println("//");
-out.println("// NOTE!: This file is autogenerated - do not modify!");
-out.println("//        if you need to make a change, please see the Groovy scripts in the");
-out.println("//        activemq-openwire module");
-out.println("//");
-out.println("");
-out.println("#ifndef MarshallerFactory_hpp_");
-out.println("#define MarshallerFactory_hpp_");
-out.println("");
-out.println("");
-out.println("namespace apache");
-out.println("{");
-out.println("  namespace activemq");
-out.println("  {");
-out.println("    namespace client");
-out.println("    {");
-out.println("      namespace marshal");
-out.println("      {");
-out.println("        using namespace ifr ;");
-out.println("        using namespace std ;");
-out.println("        using namespace apache::activemq::client;");
-out.println("        using namespace apache::activemq::client::command;");
-out.println("        using namespace apache::activemq::client::io;");
-out.println("");
-out.println("/*");
-out.println(" * ");
-out.println(" */");
-out.println("class MarshallerFactory");
-out.println("{");
-out.println("public:");
-out.println("    MarshallerFactory() ;");
-out.println("    virtual ~MarshallerFactory() ;");
-out.println("");
-out.println("	  virtual void configure(ProtocolFormat& format) ;");
-out.println("} ;");
-out.println("");
-out.println("/* namespace */");
-out.println("      }");
-out.println("    }");
-out.println("  }");
-out.println("}");
-out.println("");
-out.println("#endif /*MarshallerFactory_hpp_*/");
-out.println("");
-    }
-
-	public String getTargetDir() {
-		return targetDir;
-	}
-
-	public void setTargetDir(String targetDir) {
-		this.targetDir = targetDir;
-	}
+        generateLicence(out);
+        out.println("");
+        out.println("// Marshalling code for Open Wire Format ");
+        out.println("//");
+        out.println("//");
+        out.println("// NOTE!: This file is autogenerated - do not modify!");
+        out.println("//        if you need to make a change, please see the Groovy scripts
in the");
+        out.println("//        activemq-openwire module");
+        out.println("//");
+        out.println("");
+        out.println("#ifndef MarshallerFactory_hpp_");
+        out.println("#define MarshallerFactory_hpp_");
+        out.println("");
+        out.println("");
+        out.println("namespace apache");
+        out.println("{");
+        out.println("  namespace activemq");
+        out.println("  {");
+        out.println("    namespace client");
+        out.println("    {");
+        out.println("      namespace marshal");
+        out.println("      {");
+        out.println("        using namespace ifr ;");
+        out.println("        using namespace std ;");
+        out.println("        using namespace apache::activemq::client;");
+        out.println("        using namespace apache::activemq::client::command;");
+        out.println("        using namespace apache::activemq::client::io;");
+        out.println("");
+        out.println("/*");
+        out.println(" * ");
+        out.println(" */");
+        out.println("class MarshallerFactory");
+        out.println("{");
+        out.println("public:");
+        out.println("    MarshallerFactory() ;");
+        out.println("    virtual ~MarshallerFactory() ;");
+        out.println("");
+        out.println("    virtual void configure(ProtocolFormat& format) ;");
+        out.println("} ;");
+        out.println("");
+        out.println("/* namespace */");
+        out.println("      }");
+        out.println("    }");
+        out.println("  }");
+        out.println("}");
+        out.println("");
+        out.println("#endif /*MarshallerFactory_hpp_*/");
+        out.println("");
+    }
+
+    public String getTargetDir() {
+        return targetDir;
+    }
+
+    public void setTargetDir(String targetDir) {
+        this.targetDir = targetDir;
+    }
 }

Modified: activemq/trunk/activemq-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/JavaGeneratorTask.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/JavaGeneratorTask.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/JavaGeneratorTask.java
(original)
+++ activemq/trunk/activemq-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/JavaGeneratorTask.java
Sat Aug 11 22:27:21 2007
@@ -26,79 +26,80 @@
 import org.codehaus.jam.JamServiceParams;
 
 /**
- * 
  * @version $Revision: 384826 $
  */
 public class JavaGeneratorTask extends Task {
-	
-	int version = 2;
-	File basedir = new File(".");
-	
+
+    int version = 2;
+    File basedir = new File(".");
+
     public static void main(String[] args) {
-    	
+
         Project project = new Project();
         project.init();
-    	JavaGeneratorTask generator = new JavaGeneratorTask();
-    	generator.setProject(project);
-    	
-    	if( args.length > 0 ) {
-    		generator.version = Integer.parseInt(args[0]);
-    	}
-
-    	if( args.length > 1 ) {
-    		generator.basedir = new File(args[1]);
-    	}    	
-    	
-    	generator.execute();
-	}
-    
+        JavaGeneratorTask generator = new JavaGeneratorTask();
+        generator.setProject(project);
+
+        if (args.length > 0) {
+            generator.version = Integer.parseInt(args[0]);
+        }
+
+        if (args.length > 1) {
+            generator.basedir = new File(args[1]);
+        }
+
+        generator.execute();
+    }
+
     public void execute() throws BuildException {
         try {
-        	
-        	String sourceDir = basedir+"/src/main/java";
-        	
+
+            String sourceDir = basedir + "/src/main/java";
+
             System.out.println("Parsing source files in: " + sourceDir);
 
             JamServiceFactory jamServiceFactory = JamServiceFactory.getInstance();
-            JamServiceParams params = jamServiceFactory.createServiceParams();          
 
-            File[] dirs = new File[]{new File(sourceDir)};            
+            JamServiceParams params = jamServiceFactory.createServiceParams();
+            File[] dirs = new File[] {
+                new File(sourceDir)
+            };
             params.includeSourcePattern(dirs, "**/*.java");
             JamService jam = jamServiceFactory.createService(params);
 
             {
-	            JavaMarshallingGenerator script = new JavaMarshallingGenerator();
-	        	script.setJam(jam);
-	        	script.setTargetDir(basedir+"/src/main/java");
-	        	script.setOpenwireVersion(version);
-	        	script.run();
+                JavaMarshallingGenerator script = new JavaMarshallingGenerator();
+                script.setJam(jam);
+                script.setTargetDir(basedir + "/src/main/java");
+                script.setOpenwireVersion(version);
+                script.run();
             }
             {
-	            JavaTestsGenerator script = new JavaTestsGenerator();
-	        	script.setJam(jam);
-	        	script.setTargetDir(basedir+"/src/test/java");
-	        	script.setOpenwireVersion(version);
-	        	script.run();
+                JavaTestsGenerator script = new JavaTestsGenerator();
+                script.setJam(jam);
+                script.setTargetDir(basedir + "/src/test/java");
+                script.setOpenwireVersion(version);
+                script.run();
             }
-            
+
         } catch (Exception e) {
-        	throw new BuildException(e);
+            throw new BuildException(e);
         }
     }
 
-	public int getVersion() {
-		return version;
-	}
-
-	public void setVersion(int version) {
-		this.version = version;
-	}
-
-	public File getBasedir() {
-		return basedir;
-	}
-
-	public void setBasedir(File basedir) {
-		this.basedir = basedir;
-	}
+    public int getVersion() {
+        return version;
+    }
+
+    public void setVersion(int version) {
+        this.version = version;
+    }
+
+    public File getBasedir() {
+        return basedir;
+    }
+
+    public void setBasedir(File basedir) {
+        this.basedir = basedir;
+    }
 
 }



Mime
View raw message