KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas_ws > wsgen > modifier > ClientModifier


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 2003-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.5 2004/10/11 13:16:14 benoitf Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas_ws.wsgen.modifier;
27
28 import java.io.File JavaDoc;
29 import java.util.Iterator JavaDoc;
30 import java.util.List JavaDoc;
31
32 import org.w3c.dom.Document JavaDoc;
33 import org.w3c.dom.Element JavaDoc;
34
35 import org.objectweb.jonas_lib.genbase.GenBaseException;
36 import org.objectweb.jonas_lib.genbase.archive.Archive;
37 import org.objectweb.jonas_lib.genbase.archive.Client;
38 import org.objectweb.jonas_lib.genbase.modifier.ArchiveModifier;
39
40 import org.objectweb.jonas_ws.deployment.api.ServiceRefDesc;
41 import org.objectweb.jonas_ws.wsgen.ddmodifier.WsClientDDModifier;
42 import org.objectweb.jonas_ws.wsgen.generator.Generator;
43 import org.objectweb.jonas_ws.wsgen.generator.GeneratorFactory;
44
45 import org.objectweb.util.monolog.api.BasicLevel;
46
47 /**
48  * Modify a given Client.
49  *
50  * @author Guillaume Sauthier
51  */

52 public class ClientModifier extends ArchiveModifier {
53
54     /** client */
55     private Client client;
56
57     /**
58      * Creates a new ClientModifier object.
59      *
60      * @param client Client Archive
61      */

62     public ClientModifier(Client client) {
63         super(client);
64         this.client = client;
65     }
66
67     /**
68      * Modify the current archive and return a modified archive.
69      *
70      * @return a modified archive.
71      *
72      * @throws GenBaseException When Client Generation or storing phase fails.
73      */

74     public Archive modify() throws GenBaseException {
75
76         getLogger().log(BasicLevel.INFO, "Processing Client " + client.getName());
77
78         GeneratorFactory gf = GeneratorFactory.getInstance();
79         Document JavaDoc jclient = client.getJonasClientDoc();
80
81         List JavaDoc refs = client.getServiceRefDescs();
82         for (Iterator JavaDoc i = refs.iterator(); i.hasNext();) {
83             ServiceRefDesc ref = (ServiceRefDesc) i.next();
84
85             // create dd modifier
86
Element JavaDoc base = null;
87             if (jclient != null) {
88                 base = jclient.getDocumentElement();
89             }
90             WsClientDDModifier ddm = new WsClientDDModifier(ref.getServiceRefName(), jclient, base);
91
92             // launch generation
93
Generator g = gf.newGenerator(ref, ddm, client);
94             g.generate();
95             g.compile();
96             // add files in web archive
97
g.addFiles(client);
98         }
99
100         return save(gf.getConfiguration(), "clients" + File.separator + client.getRootFile().getName());
101     }
102 }
Popular Tags