activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r366534 - in /incubator/activemq/trunk/activemq-core: maven.xml project.xml src/gram/script/GenerateCMarshalling.groovy src/gram/script/GenerateCSharpClasses.groovy src/gram/script/GenerateCSharpMarshalling.groovy
Date Fri, 06 Jan 2006 17:12:00 GMT
Author: jstrachan
Date: Fri Jan  6 09:11:53 2006
New Revision: 366534

URL: http://svn.apache.org/viewcvs?rev=366534&view=rev
Log:
first spike at getting the OpenWire.Net to work; also upgraded to latest groovy

Modified:
    incubator/activemq/trunk/activemq-core/maven.xml
    incubator/activemq/trunk/activemq-core/project.xml
    incubator/activemq/trunk/activemq-core/src/gram/script/GenerateCMarshalling.groovy
    incubator/activemq/trunk/activemq-core/src/gram/script/GenerateCSharpClasses.groovy
    incubator/activemq/trunk/activemq-core/src/gram/script/GenerateCSharpMarshalling.groovy

Modified: incubator/activemq/trunk/activemq-core/maven.xml
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/maven.xml?rev=366534&r1=366533&r2=366534&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/maven.xml (original)
+++ incubator/activemq/trunk/activemq-core/maven.xml Fri Jan  6 09:11:53 2006
@@ -109,12 +109,10 @@
       <classpath refid="openwire.classpath" />
       <sysproperty key="openwire.version" value="${openwire.version}" />
       <arg value="src/main/java/org/apache/activemq/command" />
+      <arg value="src/gram/script/GenerateCSharpClasses.groovy" />
+      <arg value="src/gram/script/GenerateCSharpMarshalling.groovy" />
       <arg value="src/gram/script/GenerateJavaMarshalling.groovy" />
       <arg value="src/gram/script/GenerateCMarshalling.groovy" />
-      <!--
-            <arg value="src/gram/script/GenerateCSharpClasses.groovy" />
-            <arg value="src/gram/script/GenerateCSharpMarshalling.groovy" />
-            -->
     </java>
 
   </goal>

Modified: incubator/activemq/trunk/activemq-core/project.xml
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/project.xml?rev=366534&r1=366533&r2=366534&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/project.xml (original)
+++ incubator/activemq/trunk/activemq-core/project.xml Fri Jan  6 09:11:53 2006
@@ -259,7 +259,7 @@
         <dependency>
             <groupId>groovy</groupId>
             <artifactId>groovy-all</artifactId>
-            <version>1.0-jsr-01</version>
+            <version>1.0-jsr-04</version>
             <type>jar</type>
         </dependency>
         <dependency>

Modified: incubator/activemq/trunk/activemq-core/src/gram/script/GenerateCMarshalling.groovy
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/gram/script/GenerateCMarshalling.groovy?rev=366534&r1=366533&r2=366534&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/gram/script/GenerateCMarshalling.groovy (original)
+++ incubator/activemq/trunk/activemq-core/src/gram/script/GenerateCMarshalling.groovy Fri
Jan  6 09:11:53 2006
@@ -285,7 +285,7 @@
 """
          for (jclass in openwireClasses) {
 	
-	            def properties = jclass.declaredProperties.findAll { isValidProperty(it) }
+	            properties = jclass.declaredProperties.findAll { isValidProperty(it) }
 	            def name = jclass.simpleName;
 	            def type = ("ow_"+name).toUpperCase()+"_TYPE"
 	            
@@ -337,7 +337,7 @@
    ow_marshal1_${baseName}(buffer, (ow_${baseName}*)object);
 """
 
-	            def properties = jclass.declaredProperties.findAll { isValidProperty(it) }
+	             properties = jclass.declaredProperties.findAll { isValidProperty(it) }
                for (property in properties) {
                    def propname = toPropertyCase(property.simpleName);
                    def cached = isCachedProperty(property);
@@ -345,7 +345,7 @@
                    def size = annotation.getValue("size");
 
                    out << "   ";
-                   def type = property.type.qualifiedName
+                   type = property.type.qualifiedName
                    switch (type) {
                    
                    case "boolean":
@@ -404,7 +404,7 @@
    ow_marshal2_${baseName}(buffer, bitbuffer, (ow_${baseName}*)object);   
 """
 
-	            def properties = jclass.declaredProperties.findAll { isValidProperty(it) }
+	             properties = jclass.declaredProperties.findAll { isValidProperty(it) }
                for (property in properties) {
                    def annotation = property.getter.getAnnotation("openwire:property");
                    def size = annotation.getValue("size");
@@ -412,7 +412,7 @@
                    def cached = isCachedProperty(property);
                    
                    out << "   "
-                   def type = property.type.qualifiedName
+                   type = property.type.qualifiedName
                    switch (type) {                   
                    case "boolean": 
                        out << "ow_bit_buffer_read(bitbuffer);"; break;
@@ -478,7 +478,7 @@
    ow_unmarshal_${baseName}(buffer, bitbuffer, (ow_${baseName}*)object, pool);   
 """
 
-	            def properties = jclass.declaredProperties.findAll { isValidProperty(it) }
+	             properties = jclass.declaredProperties.findAll { isValidProperty(it) }
                for (property in properties) {
                    def annotation = property.getter.getAnnotation("openwire:property");
                    def size = annotation.getValue("size");
@@ -486,7 +486,7 @@
                    def cached = isCachedProperty(property);
                    
                    out << "   "
-                   def type = property.type.qualifiedName
+                   type = property.type.qualifiedName
                    switch (type) {                   
                    case "boolean":
                        out << "object->$propname = ow_bit_buffer_read(bitbuffer);";
break;

Modified: incubator/activemq/trunk/activemq-core/src/gram/script/GenerateCSharpClasses.groovy
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/gram/script/GenerateCSharpClasses.groovy?rev=366534&r1=366533&r2=366534&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/gram/script/GenerateCSharpClasses.groovy (original)
+++ incubator/activemq/trunk/activemq-core/src/gram/script/GenerateCSharpClasses.groovy Fri
Jan  6 09:11:53 2006
@@ -24,10 +24,12 @@
 class GenerateCSharpClasses extends OpenWireScript {
 
     Object run() {
-        def destDir = new File("target/generated/dotnet/cs/org/apache/activemq/openwire")
+        def destDir = new File("../openwire-dotnet/src/OpenWire.Core/Commands")
         destDir.mkdirs()
 
-        def messageClasses = classes.findAll { isMessageType(it) }
+        def messageClasses = classes.findAll {
+        		it.getAnnotation("openwire:marshaller")!=null
+        }
 
         println "Generating Java marshalling code to directory ${destDir}"
 
@@ -43,7 +45,7 @@
             def properties = jclass.declaredProperties.findAll { isValidProperty(it) }
             def file = new File(destDir, jclass.simpleName + ".cs")
 
-            String baseClass = "AbstractPacket"
+            String baseClass = "AbstractCommand"
             if (jclass.superclass?.simpleName == "ActiveMQMessage") {
                 baseClass = "ActiveMQMessage"
             }
@@ -53,19 +55,21 @@
 """
 
             file.withWriter { out |
-                out << """/**
- * Marshalling code for Open Wire Format for ${jclass.simpleName}
- *
- *
- * NOTE!: This file is autogenerated - do not modify!
- *        if you need to make a change, please see the Groovy scripts in the
- *        activemq-openwire module
- */
+                out << """//
+// Marshalling code for Open Wire Format for ${jclass.simpleName}
+//
+//
+// NOTE!: This file is autogenerated - do not modify!
+//        if you need to make a change, please see the Groovy scripts in the
+//        activemq-openwire module
+//
 
 using System;
 using System.Collections;
 
-namespace ActiveMQ
+using OpenWire.Core;
+
+namespace OpenWire.Core.Commands
 {
     public class ${jclass.simpleName} : $baseClass
     {
@@ -86,7 +90,7 @@
         // TODO generate ToString method
 
 
-        public overide int getPacketType() {
+        public override int GetCommandType() {
             return ${getEnum(jclass)};
         }
 
@@ -97,21 +101,27 @@
                 for (property in properties) {
                     def type = toCSharpType(property.type)
                     def name = decapitalize(property.simpleName)
-                    def getter = property.getter.simpleName
-                    def setter = property.setter.simpleName
+                    def propertyName = property.simpleName
+                    if (propertyName == jclass.simpleName) {
+                        // TODO think of a better naming convention :)
+                    		propertyName += "Value"
+                    }
+                    def getter = capitalize(property.getter.simpleName)
+                    def setter = capitalize(property.setter.simpleName)
 
 
                     out << """
-        public $type $getter()
+        public $type $propertyName
         {
-            return this.$name;
-        }
-
-        public void $setter($type $name)
-        {
-              this.$name = $name;
+            get
+            {
+                return $name;
+            }
+            set
+            {
+                $name = value;
+            }            
         }
-
 """
                 }
 
@@ -123,17 +133,25 @@
         }
     }
 
+    def getEnum(type) {
+    			return 1
+		}
+		
     def toCSharpType(type) {
         def name = type.qualifiedName
         switch (type) {
             case "java.lang.String":
                 return "string"
+            case "boolean":
+                return "bool"
+            case "org.apache.activemq.command.DataStructure":
+                return "Command"
             case "org.apache.activemq.message.ActiveMQDestination":
                 return "ActiveMQDestination"
             case "org.apache.activemq.message.ActiveMQXid":
                 return "ActiveMQXid"
             default:
-                return name
+                return type.simpleName
         }
     }
 }

Modified: incubator/activemq/trunk/activemq-core/src/gram/script/GenerateCSharpMarshalling.groovy
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/gram/script/GenerateCSharpMarshalling.groovy?rev=366534&r1=366533&r2=366534&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/gram/script/GenerateCSharpMarshalling.groovy
(original)
+++ incubator/activemq/trunk/activemq-core/src/gram/script/GenerateCSharpMarshalling.groovy
Fri Jan  6 09:11:53 2006
@@ -24,10 +24,12 @@
 class GenerateCSharpMarshalling extends OpenWireScript {
 
     Object run() {
-        def destDir = new File("target/generated/dotnet/cs/org/apache/activemq/openwire/io")
+        def destDir = new File("../openwire-dotnet/src/OpenWire.Core/IO")
         destDir.mkdirs()
 
-        def messageClasses = classes.findAll { isMessageType(it) }
+        def messageClasses = classes.findAll {
+        		it.getAnnotation("openwire:marshaller")!=null
+        }
 
         println "Generating Java marshalling code to directory ${destDir}"
 
@@ -35,15 +37,17 @@
 
         int counter = 0
         Map map = [:]
+        def propertyList = null
+        def type = null
 
         for (jclass in messageClasses) {
 
             println "Processing $jclass.simpleName"
 
-            def properties = jclass.declaredProperties.findAll { isValidProperty(it) }
+            propertyList = jclass.declaredProperties.findAll { isValidProperty(it) }
             def file = new File(destDir, jclass.simpleName + "Marshaller.cs")
 
-            String baseClass = "AbstractPacketMarshaller"
+            String baseClass = "AbstractCommandMarshaller"
             if (jclass.superclass?.simpleName == "ActiveMQMessage") {
                 baseClass = "ActiveMQMessageMarshaller"
             }
@@ -53,39 +57,40 @@
 """
 
             file.withWriter { out |
-                out << """/**
- * Marshalling code for Open Wire Format for ${jclass.simpleName}
- *
- *
- * NOTE!: This file is autogenerated - do not modify!
- *        if you need to make a change, please see the Groovy scripts in the
- *        activemq-openwire module
- */
+                out << """//
+// Marshalling code for Open Wire Format for ${jclass.simpleName}
+//
+//
+// NOTE!: This file is autogenerated - do not modify!
+//        if you need to make a change, please see the Groovy scripts in the
+//        activemq-openwire module
+//
 
 using System;
 using System.Collections;
+using System.IO;
+
+using OpenWire.Core;
+using OpenWire.Core.Commands;
+using OpenWire.Core.IO;
 
-namespace ActiveMQ
+namespace OpenWire.Core.IO
 {
-    public class ${jclass.simpleName} : $baseClass
+    public class ${jclass.simpleName}Marshaller : $baseClass
     {
 
-        public override int GetPacketType() {
-            return ${getEnum(jclass)};
-        }
-
-        public override Packet CreatePacket() {
+        public override Command CreateCommand() {
             return new ${jclass.simpleName}();
         }
 
-        public override void BuildPacket(Packet packet, DataInput dataIn) throws IOException
{
-            super.buildPacket(packet, dataIn);
-            ${jclass.simpleName} info = (${jclass.simpleName}) packet;
+        public override void BuildCommand(Command command, BinaryReader dataIn) {
+            super.buildCommand(command, dataIn);
+            ${jclass.simpleName} info = (${jclass.simpleName}) command;
 """
-                for (property in properties) {
+                for (property in propertyList) {
                     out << "            info.${property.setter.simpleName}("
 
-                    def type = property.type.qualifiedName
+                    type = property.type.qualifiedName
                     switch (type) {
                         case "java.lang.String":
                             out << "dataIn.readUTF()"
@@ -137,15 +142,15 @@
                 out << """
         }
 
-        public override void WritePacket(Packet packet, DataOutput dataOut) throws IOException
{
-            super.writePacket(packet, dataOut);
-            ${jclass.simpleName} info = (${jclass.simpleName}) packet;
+        public override void WriteCommand(Command command, BinaryWriter dataOut) {
+            super.writeCommand(command, dataOut);
+            ${jclass.simpleName} info = (${jclass.simpleName}) command;
 """
-                for (property in properties) {
+                for (property in propertyList) {
                     def getter = "info." + property.getter.simpleName + "()"
                     out << "            "
 
-                    def type = property.type.qualifiedName
+                    type = property.type.qualifiedName
                     switch (type) {
                         case "java.lang.String":
                             out << "writeUTF($getter, dataOut);"



Mime
View raw message