01: /**
02: * JOnAS: Java(TM) Open Application Server
03: * Copyright (C) 2003-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: ApplicationModifier.java 9457 2006-08-24 12:58:41Z sauthieg $
23: * --------------------------------------------------------------------------
24: */package org.objectweb.jonas_ws.wsgen.modifier;
25:
26: import java.util.Iterator;
27: import java.util.jar.Attributes;
28:
29: import org.objectweb.jonas_lib.genbase.GenBaseException;
30: import org.objectweb.jonas_lib.genbase.archive.Application;
31: import org.objectweb.jonas_lib.genbase.archive.Archive;
32: import org.objectweb.jonas_lib.genbase.archive.Client;
33: import org.objectweb.jonas_lib.genbase.archive.EjbJar;
34: import org.objectweb.jonas_lib.genbase.archive.WebApp;
35: import org.objectweb.jonas_lib.genbase.modifier.AbsApplicationModifier;
36: import org.objectweb.jonas_lib.version.Version;
37:
38: import org.objectweb.jonas_ws.wsgen.WsGenException;
39: import org.objectweb.jonas_ws.wsgen.generator.GeneratorFactory;
40:
41: /**
42: * Modify a given Application.
43: * @author Guillaume Sauthier
44: */
45: public class ApplicationModifier extends AbsApplicationModifier {
46:
47: /**
48: * Creates a new ApplicationModifier.
49: * @param archive the Application J2EE archive
50: * @throws WsGenException if the application modifier cannot be built
51: */
52: public ApplicationModifier(Application archive)
53: throws WsGenException {
54: super (archive, GeneratorFactory.getInstance()
55: .getConfiguration());
56: }
57:
58: /**
59: * initialize modifier
60: */
61: protected void init() {
62:
63: // fill ejbjar list
64: for (Iterator i = getApplication().getEjbJars(); i.hasNext();) {
65: EjbJar ejbjar = (EjbJar) i.next();
66: getEjbModifiers().add(new EjbJarModifier(ejbjar));
67: }
68:
69: // fill webapp list
70: for (Iterator i = getApplication().getWebApps(); i.hasNext();) {
71: WebApp webapp = (WebApp) i.next();
72: getWebModifiers().add(new WebAppModifier(webapp));
73: }
74:
75: // fill client list
76: for (Iterator i = getApplication().getClients(); i.hasNext();) {
77: Client client = (Client) i.next();
78: getCltModifiers().add(new ClientModifier(client));
79: }
80: }
81:
82: /**
83: * Update the Manifest of the Application before modifying it.
84: * @return Returns the modified Archive.
85: * @see org.objectweb.jonas_lib.genbase.modifier.AbsApplicationModifier#modify()
86: */
87: public Archive modify() throws GenBaseException {
88: // Update MANIFEST with Version Number
89: // used to say if WsGen has already been applied to this Module
90: Attributes main = this .getApplication().getManifest()
91: .getMainAttributes();
92: main.put(new Attributes.Name(
93: WsGenModifierConstants.WSGEN_JONAS_VERSION_ATTR),
94: Version.getNumber());
95:
96: return super.modify();
97: }
98:
99: }
|