KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > ejb > gen > BeanAssembler


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Scott Ferguson
28  */

29
30 package com.caucho.ejb.gen;
31
32 import com.caucho.bytecode.JClass;
33 import com.caucho.ejb.cfg.EjbBean;
34 import com.caucho.java.gen.BaseMethod;
35 import com.caucho.java.gen.ClassComponent;
36 import com.caucho.java.gen.DependencyComponent;
37 import com.caucho.java.gen.GenClass;
38 import com.caucho.util.L10N;
39 import com.caucho.vfs.PersistentDependency;
40
41 /**
42  * Assembles the generator structure.
43  */

44 abstract public class BeanAssembler {
45   private static final L10N L = new L10N(BeanAssembler.class);
46
47   private EjbBean _bean;
48   
49   protected GenClass _genClass;
50   protected GenClass _beanClass;
51
52   protected DependencyComponent _dependency;
53
54   public BeanAssembler(EjbBean bean,
55                String JavaDoc fullClassName)
56   {
57     _bean = bean;
58     _genClass = new GenClass(fullClassName);
59     _dependency = new DependencyComponent();
60     _genClass.addComponent(_dependency);
61   }
62
63   /**
64    * Returns the short classname.
65    */

66   public String JavaDoc getShortClassName()
67   {
68     return _genClass.getClassName();
69   }
70
71   /**
72    * Returns assembled class.
73    */

74   public GenClass getAssembledGenerator()
75   {
76     return _genClass;
77   }
78
79   /**
80    * Adds an import.
81    */

82   public void addImport(String JavaDoc importName)
83   {
84     _genClass.addImport(importName);
85   }
86
87   /**
88    * Adds the header component.
89    */

90   public void addHeaderComponent(JClass beanClass,
91                  String JavaDoc contextClassName,
92                  String JavaDoc implClassName)
93   {
94   }
95
96   /**
97    * Adds the bean method
98    */

99   public void addMethod(BaseMethod method)
100   {
101     addComponent(method);
102   }
103
104   /**
105    * Adds the bean method
106    */

107   public void addComponent(ClassComponent component)
108   {
109   }
110
111   /**
112    * Adds a dependency
113    */

114   public void addDependency(PersistentDependency depend)
115   {
116     _dependency.addDependency(depend);
117   }
118
119   /**
120    * Creates the home view.
121    */

122   abstract public ViewClass createHomeView(JClass homeClass,
123                        String JavaDoc fullClassName,
124                        String JavaDoc viewPrefix);
125
126   /**
127    * Creates the home view.
128    */

129   abstract public ViewClass createView(JClass homeClass,
130                        String JavaDoc fullClassName,
131                        String JavaDoc viewPrefix);
132
133   /**
134    * Checks for the existence of a method.
135    */

136   public static boolean hasMethod(JClass cl, String JavaDoc methodName, JClass []args)
137   {
138     return cl.getMethod(methodName, args) != null;
139   }
140 }
141
Popular Tags