01: /**
02: * JOnAS: Java(TM) Open Application Server
03: * Copyright (C) 2004 Bull S.A.
04: * Contact: jonas-team@objectweb.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * 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 5928 2004-12-13 16:27:33Z benoitf $
23: * --------------------------------------------------------------------------
24: */package org.objectweb.jonas_lib.genclientstub.modifier;
25:
26: import java.io.File;
27: import java.util.Iterator;
28: import java.util.List;
29:
30: import org.objectweb.jonas_lib.deployment.api.EjbRefDesc;
31: import org.objectweb.jonas_lib.genbase.GenBaseException;
32: import org.objectweb.jonas_lib.genbase.archive.Archive;
33: import org.objectweb.jonas_lib.genbase.archive.WebApp;
34: import org.objectweb.jonas_lib.genclientstub.generator.Generator;
35: import org.objectweb.jonas_lib.genclientstub.generator.GeneratorFactory;
36:
37: import org.objectweb.util.monolog.api.BasicLevel;
38:
39: /**
40: * Modify a given WebApp.
41: *
42: * @author Guillaume Sauthier
43: */
44: public class WebAppModifier extends AbsArchiveModifier {
45:
46: /** webapp */
47: private WebApp web;
48:
49: /**
50: * Creates a new WebAppModifier
51: *
52: * @param webapp
53: * the WebApp J2EE archive
54: */
55: public WebAppModifier(WebApp webapp) {
56: super (webapp);
57: web = webapp;
58: }
59:
60: /**
61: * Modify the current archive and return a modified archive.
62: *
63: * @return a modified archive.
64: *
65: * @throws GenBaseException
66: * When modification fails
67: */
68: public Archive modify() throws GenBaseException {
69:
70: getLogger().log(BasicLevel.INFO,
71: "Processing WebApp " + web.getName());
72:
73: GeneratorFactory gf = GeneratorFactory.getInstance();
74:
75: // Found automatically the stubs
76: generateFoundStubs(gf.getConfiguration(), web);
77:
78: // Ejb-Ref
79: List ejbRefs = web.getEjbRefDescs();
80: for (Iterator j = ejbRefs.iterator(); j.hasNext();) {
81: EjbRefDesc ejbRef = (EjbRefDesc) j.next();
82:
83: // launch generation
84: Generator g = new Generator(gf.getConfiguration(), ejbRef,
85: null, web);
86: g.generate();
87: g.compile();
88: // add files in web archive
89: g.addFiles(web);
90: }
91:
92: return save(gf.getConfiguration(), "webapps" + File.separator
93: + web.getName());
94: }
95: }
|