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: ClientModifier.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.Client;
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 Client.
41: *
42: * @author Florent Benoit
43: */
44: public class ClientModifier extends AbsArchiveModifier {
45:
46: /** client */
47: private Client client;
48:
49: /**
50: * Creates a new ClientModifier object.
51: *
52: * @param client Client Archive
53: */
54: public ClientModifier(Client client) {
55: super (client);
56: this .client = client;
57: }
58:
59: /**
60: * Modify the current archive and return a modified archive.
61: *
62: * @return a modified archive.
63: *
64: * @throws GenBaseException When Client Generation or storing phase fails.
65: */
66: public Archive modify() throws GenBaseException {
67:
68: getLogger().log(BasicLevel.INFO,
69: "Processing Client " + client.getName());
70:
71: GeneratorFactory gf = GeneratorFactory.getInstance();
72:
73: // Found automatically the stubs
74: generateFoundStubs(gf.getConfiguration(), client);
75:
76: // Ejb-Ref
77: List ejbRefs = client.getEjbRefDescs();
78: for (Iterator j = ejbRefs.iterator(); j.hasNext();) {
79: EjbRefDesc ejbRef = (EjbRefDesc) j.next();
80:
81: // launch generation
82: Generator g = new Generator(gf.getConfiguration(), ejbRef,
83: null, client);
84: g.generate();
85: g.compile();
86: // add files in web archive
87: g.addFiles(client);
88: }
89:
90: return save(gf.getConfiguration(), "clients" + File.separator
91: + client.getRootFile().getName());
92: }
93: }
|