KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas_lib > genclientstub > modifier > WebAppModifier


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 2004 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: WebAppModifier.java,v 1.2 2004/12/13 16:27:32 benoitf Exp $
23  * --------------------------------------------------------------------------
24  */

25
26
27 package org.objectweb.jonas_lib.genclientstub.modifier;
28
29 import java.io.File JavaDoc;
30 import java.util.Iterator JavaDoc;
31 import java.util.List JavaDoc;
32
33 import org.objectweb.jonas_lib.deployment.api.EjbRefDesc;
34 import org.objectweb.jonas_lib.genbase.GenBaseException;
35 import org.objectweb.jonas_lib.genbase.archive.Archive;
36 import org.objectweb.jonas_lib.genbase.archive.WebApp;
37 import org.objectweb.jonas_lib.genclientstub.generator.Generator;
38 import org.objectweb.jonas_lib.genclientstub.generator.GeneratorFactory;
39
40 import org.objectweb.util.monolog.api.BasicLevel;
41
42 /**
43  * Modify a given WebApp.
44  *
45  * @author Guillaume Sauthier
46  */

47 public class WebAppModifier extends AbsArchiveModifier {
48
49     /** webapp */
50     private WebApp web;
51
52     /**
53      * Creates a new WebAppModifier
54      *
55      * @param webapp
56      * the WebApp J2EE archive
57      */

58     public WebAppModifier(WebApp webapp) {
59         super(webapp);
60         web = webapp;
61     }
62
63     /**
64      * Modify the current archive and return a modified archive.
65      *
66      * @return a modified archive.
67      *
68      * @throws GenBaseException
69      * When modification fails
70      */

71     public Archive modify() throws GenBaseException {
72
73         getLogger().log(BasicLevel.INFO, "Processing WebApp " + web.getName());
74
75         GeneratorFactory gf = GeneratorFactory.getInstance();
76
77         // Found automatically the stubs
78
generateFoundStubs(gf.getConfiguration(), web);
79
80         // Ejb-Ref
81
List JavaDoc ejbRefs = web.getEjbRefDescs();
82         for (Iterator JavaDoc j = ejbRefs.iterator(); j.hasNext();) {
83             EjbRefDesc ejbRef = (EjbRefDesc) j.next();
84
85             // launch generation
86
Generator g = new Generator(gf.getConfiguration(), ejbRef, null, web);
87             g.generate();
88             g.compile();
89             // add files in web archive
90
g.addFiles(web);
91         }
92
93         return save(gf.getConfiguration(), "webapps" + File.separator
94                 + web.getName());
95     }
96 }
Popular Tags