activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject git commit: Support customizing the package names generated by the openwire generator so that the plugin can be re-used by other projects that need to generate openwire codecs.
Date Fri, 21 Feb 2014 16:58:52 GMT
Repository: activemq-apollo
Updated Branches:
  refs/heads/trunk b1b19fdda -> 4cbe349ac


Support customizing the package names generated by the openwire generator so that the plugin
can be re-used by other projects that need to generate openwire codecs.

Project: http://git-wip-us.apache.org/repos/asf/activemq-apollo/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-apollo/commit/4cbe349a
Tree: http://git-wip-us.apache.org/repos/asf/activemq-apollo/tree/4cbe349a
Diff: http://git-wip-us.apache.org/repos/asf/activemq-apollo/diff/4cbe349a

Branch: refs/heads/trunk
Commit: 4cbe349ac657590d99d5051c3a2598b17666d9a3
Parents: b1b19fd
Author: Hiram Chirino <hiram@hiramchirino.com>
Authored: Fri Feb 21 11:58:45 2014 -0500
Committer: Hiram Chirino <hiram@hiramchirino.com>
Committed: Fri Feb 21 11:58:45 2014 -0500

----------------------------------------------------------------------
 .../generator/ApolloMarshallingGenerator.scala  | 32 ++++++++++++++------
 .../openwire/generator/GeneratorTask.scala      | 13 ++++++++
 2 files changed, 35 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-apollo/blob/4cbe349a/apollo-openwire-generator/src/main/scala/org/apache/activemq/apollo/openwire/generator/ApolloMarshallingGenerator.scala
----------------------------------------------------------------------
diff --git a/apollo-openwire-generator/src/main/scala/org/apache/activemq/apollo/openwire/generator/ApolloMarshallingGenerator.scala
b/apollo-openwire-generator/src/main/scala/org/apache/activemq/apollo/openwire/generator/ApolloMarshallingGenerator.scala
index ade816a..36570ec 100644
--- a/apollo-openwire-generator/src/main/scala/org/apache/activemq/apollo/openwire/generator/ApolloMarshallingGenerator.scala
+++ b/apollo-openwire-generator/src/main/scala/org/apache/activemq/apollo/openwire/generator/ApolloMarshallingGenerator.scala
@@ -31,6 +31,7 @@ import org.apache.tools.ant.Project
 import org.apache.tools.ant.taskdefs.FixCRLF
 import org.apache.tools.ant.taskdefs.FixCRLF.CrLf
 import org.codehaus.jam._
+import scala.beans.BeanProperty
 
 /**
  * <p>
@@ -39,9 +40,24 @@ import org.codehaus.jam._
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
  */
 class ApolloMarshallingGenerator extends MultiSourceGenerator {
+
+  protected var concreteClasses: List[JClass] = new ArrayList[JClass]
+  protected var factoryFile: File = null
+  protected var factoryFileName: String = "MarshallerFactory"
+  protected var indent: String = "    "
+  protected var targetDir: String = "src/main/java"
+
+  @BeanProperty
+  var commandPackage = "org.apache.activemq.apollo.openwire.command"
+
+  @BeanProperty
+  var packagePrefix = "org.apache.activemq.apollo.openwire.codec"
+
+  def packagePrefixPath = packagePrefix.replace('.', '/');
+
   override def run: AnyRef = {
     if (destDir == null) {
-      destDir = new File(targetDir + "/org/apache/activemq/apollo/openwire/codec/v" + getOpenwireVersion)
+      destDir = new File(targetDir + "/"+packagePrefixPath+"/v"+getOpenwireVersion)
     }
     var answer: AnyRef = super.run
     processFactory
@@ -81,14 +97,14 @@ class ApolloMarshallingGenerator extends MultiSourceGenerator {
   protected def generateFile(out: PrintWriter): Unit = {
     generateLicence(out)
     out.println("")
-    out.println("package org.apache.activemq.apollo.openwire.codec.v" + getOpenwireVersion
+ ";")
+    out.println("package "+packagePrefix +".v"+ getOpenwireVersion + ";")
     out.println("")
     out.println("import org.fusesource.hawtbuf.DataByteArrayInputStream;")
     out.println("import org.fusesource.hawtbuf.DataByteArrayOutputStream;")
     out.println("import java.io.IOException;")
     out.println("")
-    out.println("import org.apache.activemq.apollo.openwire.codec.*;")
-    out.println("import org.apache.activemq.apollo.openwire.command.*;")
+    out.println("import "+packagePrefix+".*;")
+    out.println("import "+commandPackage+".*;")
 
     out.println("")
     out.println("")
@@ -669,7 +685,7 @@ class ApolloMarshallingGenerator extends MultiSourceGenerator {
   override def isMarshallAware(j: JClass): Boolean = {
     if (filePostFix.endsWith("java")) {
       j.getInterfaces.foreach { x=>
-        if (x.getQualifiedName == "org.apache.activemq.apollo.openwire.command.MarshallAware")
{
+        if (x.getQualifiedName == commandPackage+".MarshallAware") {
           return true
         }
       }
@@ -735,10 +751,6 @@ class ApolloMarshallingGenerator extends MultiSourceGenerator {
     this.targetDir = sourceDir
   }
 
-  protected var concreteClasses: List[JClass] = new ArrayList[JClass]
-  protected var factoryFile: File = null
-  protected var factoryFileName: String = "MarshallerFactory"
-  protected var indent: String = "    "
-  protected var targetDir: String = "src/main/java"
+
 }
 

http://git-wip-us.apache.org/repos/asf/activemq-apollo/blob/4cbe349a/apollo-openwire-generator/src/main/scala/org/apache/activemq/apollo/openwire/generator/GeneratorTask.scala
----------------------------------------------------------------------
diff --git a/apollo-openwire-generator/src/main/scala/org/apache/activemq/apollo/openwire/generator/GeneratorTask.scala
b/apollo-openwire-generator/src/main/scala/org/apache/activemq/apollo/openwire/generator/GeneratorTask.scala
index e858f5b..62017ea 100644
--- a/apollo-openwire-generator/src/main/scala/org/apache/activemq/apollo/openwire/generator/GeneratorTask.scala
+++ b/apollo-openwire-generator/src/main/scala/org/apache/activemq/apollo/openwire/generator/GeneratorTask.scala
@@ -73,6 +73,13 @@ class GeneratorTask extends Task {
   @BeanProperty
   var targetDir = new File("./src/main/scala")
 
+  @BeanProperty
+  var commandPackage:String = null
+
+  @BeanProperty
+  var packagePrefix:String = null
+
+
   override def execute: Unit = {
     try {
 
@@ -92,6 +99,12 @@ class GeneratorTask extends Task {
         script.setJam(jam)
         script.setTargetDir(targetDir.getCanonicalPath)
         script.setOpenwireVersion(i)
+        if( getPackagePrefix()!=null ) {
+          script.setPackagePrefix(getPackagePrefix())
+        }
+        if( getCommandPackage()!=null ) {
+          script.setCommandPackage(getCommandPackage())
+        }
         script.run
       }
 


Mime
View raw message