| Classes in this File | Line Coverage | Branch Coverage | Complexity | |||||||
| Main |
|
| 1.0;1 |
| 1 | /* |
|
| 2 | * Copyright 2006 Outsource Cafe, Inc. |
|
| 3 | * |
|
| 4 | * Licensed under the Apache License, Version 2.0 (the 'License') |
|
| 5 | * you may not use this file except in compliance with the License. |
|
| 6 | * You may obtain a copy of the License at |
|
| 7 | * |
|
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 9 | * |
|
| 10 | * Unless required by applicable law or agreed to in writing, software |
|
| 11 | * distributed under the License is distributed on an 'AS IS' BASIS, |
|
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 13 | * See the License for the specific language governing permissions and |
|
| 14 | * limitations under the License. |
|
| 15 | */ |
|
| 16 | package org.javagen.revgen; |
|
| 17 | ||
| 18 | import org.javagen.agile.core.ioc.spring.SpringMain; |
|
| 19 | ||
| 20 | /** |
|
| 21 | * Loads RevGen configuration and executes code generation pipeline using Spring framework IoC BeanFactory. |
|
| 22 | * <p> |
|
| 23 | * This class excepts two arguments: <code>revgen.properties</code> and <code>RevGenSpringConfig.xml</code>. |
|
| 24 | * <p> |
|
| 25 | * <code>revgen.properties</code> is meant to be the first (ie easiest) level of RevGen configuration specifying: |
|
| 26 | * <ul> |
|
| 27 | * <li>Database connection properties</li> |
|
| 28 | * <li>Generated project name and directory location</li> |
|
| 29 | * <li>Source folder layout</li> |
|
| 30 | * <li>Output types: annotations vs XML, Hibernate vs Spring vs EJB3 implementations, etc.</li> |
|
| 31 | * <li>The global overwrite policy (aka <code>overwriteAll</code>)</li> |
|
| 32 | * </ul> |
|
| 33 | * |
|
| 34 | * Any type of configuration can be achieved using <code>RevGenSpringConfig.xml</code> including: |
|
| 35 | * <ul> |
|
| 36 | * <li>Pipeline components and order of execution</li> |
|
| 37 | * <li>Template names, locations and types and their artifact naming patterns and relative output locations</li> |
|
| 38 | * <li>Per-template overwrite predicates</li> |
|
| 39 | * <li>Binding templates to model instances</li> |
|
| 40 | * <li>Root structure of model tree including global properties and parent containers for generated model instances</li> |
|
| 41 | * <li>Default and artifact-specific naming patterns using model and emitter contexts</li> |
|
| 42 | * <li>Reading, writing and merging of metadata</li> |
|
| 43 | * <li>Database table selection</li> |
|
| 44 | * <li>Code naming and conversion implementations</li> |
|
| 45 | * <li>Anything that <code>revgen.properties</code> can specify</li> |
|
| 46 | * </ul> |
|
| 47 | * <p> |
|
| 48 | * <p> |
|
| 49 | * Properties inputs have the following precedence from lowest to highest: |
|
| 50 | * <ol> |
|
| 51 | * <li>Properties specified in the <code>GlobalPropertyHolder</code> bean within the RevGenSpringConfig.xml file.</li> |
|
| 52 | * <li>Properties specified in the external <code>propertyFile</code>. Note: this can be specified as a <code>GlobalPropertyHolder</code> property and overridden here.</li> |
|
| 53 | * <li>Properties specified in the <code>properties</code> instance. Note: these are usually set by the invoking tool (i.e. Maven).</li> |
|
| 54 | * </ol> |
|
| 55 | * This is an extremely flexible way to configure the code generator, avoiding a one-size-fits-all approach. |
|
| 56 | * <p> |
|
| 57 | * @author Richard Easterling |
|
| 58 | */ |
|
| 59 | public class Main extends SpringMain { |
|
| 60 | ||
| 61 | 2 | public Main() { |
| 62 | 2 | this.setConfigFile("classpath:RevGenSpringConfig.xml"); |
| 63 | 2 | } |
| 64 | /** |
|
| 65 | * Loads and runs RevGen using Spring configuration file. RevGen is started by invoking |
|
| 66 | * the <code>pipeline</code> bean. |
|
| 67 | * <p> |
|
| 68 | * @param args takes an optional Spring XML configuration file location and/or a properties file. |
|
| 69 | * Files can be any valid URL or classpath location. File types are recognized by their extension, |
|
| 70 | * names and order are not important. Here are some valid examples: |
|
| 71 | * <ul> |
|
| 72 | * <li>file:src/revgen/RevGenSpringConfig.xml</li> |
|
| 73 | * <li>classpath:RevGenSpringConfig.xml</li> |
|
| 74 | * <li>file:src/revgen/revgen.properties</li> |
|
| 75 | * <li>classpath:revgen.properties</li> |
|
| 76 | * </ul> |
|
| 77 | */ |
|
| 78 | public static void main(String[] args) throws Exception { |
|
| 79 | 0 | Main main = new Main(); |
| 80 | 0 | main.setArgs(args); |
| 81 | 0 | main.runPipeline(); |
| 82 | 0 | } |
| 83 | ||
| 84 | } |