KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lateralnz > panther > deploy > SessionBeanTask


1 /* ====================================================================
2  * The LateralNZ Software License, Version 1.0
3  *
4  * Copyright (c) 2003 LateralNZ. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  *
18  * 3. The end-user documentation included with the redistribution,
19  * if any, must include the following acknowledgment:
20  * "This product includes software developed by
21  * LateralNZ (http://www.lateralnz.org/) and other third parties."
22  * Alternately, this acknowledgment may appear in the software itself,
23  * if and wherever such third-party acknowledgments normally appear.
24  *
25  * 4. The names "LateralNZ" must not be used to endorse or promote
26  * products derived from this software without prior written
27  * permission. For written permission, please
28  * contact oss@lateralnz.org.
29  *
30  * 5. Products derived from this software may not be called "Panther",
31  * or "Lateral" or "LateralNZ", nor may "PANTHER" or "LATERAL" or
32  * "LATERALNZ" appear in their name, without prior written
33  * permission of LateralNZ.
34  *
35  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
36  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
37  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
39  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
42  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
44  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
45  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
46  * SUCH DAMAGE.
47  * ====================================================================
48  *
49  * This software consists of voluntary contributions made by many
50  * individuals on behalf of LateralNZ. For more
51  * information on Lateral, please see http://www.lateralnz.com/ or
52  * http://www.lateralnz.org
53  *
54  */

55 package org.lateralnz.panther.deploy;
56
57 import java.io.File JavaDoc;
58 import java.io.FileWriter JavaDoc;
59 import java.io.IOException JavaDoc;
60 import java.lang.reflect.Method JavaDoc;
61 import java.util.ArrayList JavaDoc;
62 import java.util.Iterator JavaDoc;
63 import java.util.List JavaDoc;
64 import java.util.StringTokenizer JavaDoc;
65
66 import org.apache.tools.ant.BuildException;
67 import org.apache.tools.ant.Task;
68
69 import org.apache.velocity.app.VelocityEngine;
70 import org.apache.velocity.Template;
71 import org.apache.velocity.VelocityContext;
72
73 import org.w3c.dom.Document JavaDoc;
74
75 import org.lateralnz.common.util.Constants;
76 import org.lateralnz.common.util.ObjectUtils;
77 import org.lateralnz.common.util.StringUtils;
78 import org.lateralnz.common.util.XMLUtils;
79
80 import org.lateralnz.panther.util.EJBConstants;
81
82 /**
83  * an Ant task for generating wrapper classes for stateless session beans (currently). Simply calls the requisite
84  * methods of SessionBeanGenerator
85  * This can be used in ant by defining a 'panthertask' as follows:
86  * <pre>
87  * <taskdef name="panthertask" classname="org.lateralnz.panther.deploy.SessionBeanWrapperTask">
88  * <classpath>
89  * <pathelement location="${deploy}/panther-ant.jar"/>
90  * <pathelement location="${lib}/velocity.jar" />
91  * <pathelement location="${lib}/commons-collections.jar" />
92  * <pathelement location="${lib}/log4j.jar" />
93  * <pathelement location="${lib}/jboss-j2ee.jar" />
94  * <pathelement location="${classes}" />
95  * <pathelement location="${src}" />
96  * </classpath>
97  * </taskdef>
98  * </pre>
99  * Then in your target, include the task:
100  * <pre>
101  * <panthertask ejbjarXML="${src}/META-INF/ejb-jar.xml"
102  * tempdir="${temp}"
103  * classesdir="${classes}"
104  * wrapperTemplate="sessionbean.vm"
105  * homeWrapperTemplate="sessionbeanhome.vm"
106  * wrapperTemplateDir="${src}/org/lateralnz/panther/"
107  * logfile="/tmp/velocity.log" />
108  * </pre>
109  * @author J R Briggs
110  */

111 public class SessionBeanTask extends Task implements Constants {
112   SessionBeanGenerator sbg = new SessionBeanGenerator();
113
114  /**
115   * set the EJBJarXML property
116   */

117   public void setEJBJarXML(String JavaDoc ejbjarXML) {
118     sbg.setEJBJarXML(ejbjarXML);
119   }
120   
121  /**
122   * set the temporary/working directory
123   */

124   public void setTempDir(String JavaDoc tempdir) {
125     sbg.setTempDir(tempdir);
126   }
127   
128  /**
129   * set the directory where classes can be found
130   */

131   public void setClassesDir(String JavaDoc classesdir) {
132     sbg.setClassesDir(classesdir);
133   }
134
135  /**
136   * set the name of the sessionbean wrapper template
137   */

138   public void setWrapperTemplate(String JavaDoc wrapperTemplate) {
139     sbg.setWrapperTemplate(wrapperTemplate);
140   }
141   
142   public void setHomeWrapperTemplate(String JavaDoc homeWrapperTemplate) {
143     sbg.setHomeWrapperTemplate(homeWrapperTemplate);
144   }
145   
146  /**
147   * set the directory where we can find the template
148   */

149   public void setWrapperTemplateDir(String JavaDoc wrapperTemplateDir) {
150     sbg.setWrapperTemplateDir(wrapperTemplateDir);
151   }
152   
153   public void setLogFile(String JavaDoc logfile) {
154     sbg.setLogFile(logfile);
155   }
156
157  /**
158   * execute this task
159   */

160   public void execute() throws BuildException {
161     try {
162       sbg.execute();
163     }
164     catch (Exception JavaDoc e) {
165       e.printStackTrace();
166       throw new BuildException(e);
167     }
168   }
169
170 }
Popular Tags