Save This Page
Home » activemq-parent-5.3.1-source-release » org.apache » activemq » openwire » tool » [javadoc | source]
    1   /**
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    * Unless required by applicable law or agreed to in writing, software
   12    * distributed under the License is distributed on an "AS IS" BASIS,
   13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    * See the License for the specific language governing permissions and
   15    * limitations under the License.
   16    */
   17   package org.apache.activemq.openwire.tool;
   18   
   19   import java.io.File;
   20   
   21   import org.apache.tools.ant.BuildException;
   22   import org.apache.tools.ant.Project;
   23   import org.apache.tools.ant.Task;
   24   import org.codehaus.jam.JamService;
   25   import org.codehaus.jam.JamServiceFactory;
   26   import org.codehaus.jam.JamServiceParams;
   27   
   28   /**
   29    * @version $Revision: 384826 $
   30    */
   31   public class CSharpGeneratorTask extends Task {
   32   
   33       int version = 2;
   34       File source = new File(".");
   35       File target = new File(".");
   36   
   37       public static void main(String[] args) {
   38   
   39           Project project = new Project();
   40           project.init();
   41           CSharpGeneratorTask generator = new CSharpGeneratorTask();
   42           generator.setProject(project);
   43   
   44           if (args.length > 0) {
   45               generator.version = Integer.parseInt(args[0]);
   46           }
   47   
   48           if (args.length > 1) {
   49               generator.source = new File(args[1]);
   50           }
   51   
   52           if (args.length > 2) {
   53               generator.target = new File(args[2]);
   54           }
   55   
   56           generator.execute();
   57       }
   58   
   59       public void execute() throws BuildException {
   60           try {
   61   
   62               String sourceDir = source + "/src/main/java";
   63   
   64               System.out.println("Parsing source files in: " + sourceDir);
   65   
   66               JamServiceFactory jamServiceFactory = JamServiceFactory.getInstance();
   67               JamServiceParams params = jamServiceFactory.createServiceParams();
   68               File[] dirs = new File[] {
   69                   new File(sourceDir)
   70               };
   71               params.includeSourcePattern(dirs, "**/*.java");
   72               JamService jam = jamServiceFactory.createService(params);
   73   
   74               {
   75                   CSharpClassesGenerator script = new CSharpClassesGenerator();
   76                   script.setJam(jam);
   77                   script.setTargetDir(target + "/src/main/csharp");
   78                   script.setOpenwireVersion(version);
   79                   script.run();
   80               }
   81               {
   82                   CSharpMarshallingGenerator script = new CSharpMarshallingGenerator();
   83                   script.setJam(jam);
   84                   script.setTargetDir(target + "/src/main/csharp");
   85                   script.setOpenwireVersion(version);
   86                   script.run();
   87               }
   88   
   89           } catch (Exception e) {
   90               throw new BuildException(e);
   91           }
   92       }
   93   
   94       public int getVersion() {
   95           return version;
   96       }
   97   
   98       public void setVersion(int version) {
   99           this.version = version;
  100       }
  101   
  102       public File getSource() {
  103           return source;
  104       }
  105   
  106       public void setSource(File basedir) {
  107           this.source = basedir;
  108       }
  109   
  110       public File getTarget() {
  111           return target;
  112       }
  113   
  114       public void setTarget(File target) {
  115           this.target = target;
  116       }
  117   
  118   }

Save This Page
Home » activemq-parent-5.3.1-source-release » org.apache » activemq » openwire » tool » [javadoc | source]