KickJava   Java API By Example, From Geeks To Geeks.

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


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: ClientModifier.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.Client;
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 Client.
44  *
45  * @author Florent Benoit
46  */

47 public class ClientModifier extends AbsArchiveModifier {
48
49     /** client */
50     private Client client;
51
52     /**
53      * Creates a new ClientModifier object.
54      *
55      * @param client Client Archive
56      */

57     public ClientModifier(Client client) {
58         super(client);
59         this.client = client;
60     }
61
62     /**
63      * Modify the current archive and return a modified archive.
64      *
65      * @return a modified archive.
66      *
67      * @throws GenBaseException When Client Generation or storing phase fails.
68      */

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