View Javadoc

    1   /*
    2    * joey-gen and its relative products are published under the terms
    3    * of the Apache Software License.
    4    *
    5    * Created on 2005/01/13 17:58:48
    6    */
    7   package org.asyrinx.joey.gen.task;
    8
    9   import org.asyrinx.brownie.seasar.aop.CacheInterceptor;
    10  import org.asyrinx.joey.gen.command.rdb2java.standard.BasicBuilder;
    11  import org.asyrinx.joey.gen.model.rdb.xml.DatabasesLoaderImpl;
    12  import org.asyrinx.joey.gen.model.rdb.xml.XmlToRdbImpl;
    13  import org.seasar.framework.container.S2Container;
    14  import org.seasar.framework.container.impl.AspectDefImpl;
    15  import org.seasar.framework.container.impl.ComponentDefImpl;
    16  import org.seasar.framework.container.impl.PropertyDefImpl;
    17  import org.seasar.framework.container.impl.S2ContainerImpl;
    18
    19  /***
    20   * @author takeshi
    21   */
    22  public class S2ContainerLoader {
    23
    24      private static S2Container container = null;
    25
    26      public static S2Container getContainer() {
    27          if (container == null)
    28              container = initContainer();
    29          return container;
    30      }
    31
    32      /***
    33       * @return
    34       */
    35      private static S2Container initContainer() {
    36          //log.debug("JoeyGenerateTask#initContainer");
    37          //ClassLoaderがちゃんとdiconファイルやDTDを読んでくれないので、仕方なく自分でコンポーネント定義をコーディング
    38          //BrownieS2ContainerFactory.create("joey-gen.dicon",
    39          // this.getProject().getBaseDir().getAbsolutePath());
    40          final S2Container result = new S2ContainerImpl();
    41          result.register(XmlToRdbImpl.class);
    42          final ComponentDefImpl databasesLoaderDef = new ComponentDefImpl(DatabasesLoaderImpl.class);
    43          databasesLoaderDef.addAspectDef(new AspectDefImpl(new CacheInterceptor()));
    44          result.register(databasesLoaderDef);
    45          final ComponentDefImpl javaBuilderDef = new ComponentDefImpl(BasicBuilder.class);
    46          javaBuilderDef.addAspectDef(new AspectDefImpl(new CacheInterceptor()));
    47          result.register(javaBuilderDef);
    48          final ComponentDefImpl modelLoaderDef = new ComponentDefImpl(ModelLoaderImpl.class);
    49          result.register(modelLoaderDef);
    50          final ComponentDefImpl velocityGeneratorDef = new ComponentDefImpl(JoeyVelocityGeneratorImpl.class);
    51          velocityGeneratorDef.addPropertyDef(new PropertyDefImpl("query", GenerationQuery.DONT_OVERWRITE));
    52          result.register(velocityGeneratorDef);
    53          return result;
    54      }
    55
    56  }