KickJava   Java API By Example, From Geeks To Geeks.

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


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: EjbJarModifier.java,v 1.2 2004/12/13 16:27:32 benoitf Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas_lib.genclientstub.modifier;
27
28 import java.io.File JavaDoc;
29 import java.util.Iterator JavaDoc;
30 import java.util.List JavaDoc;
31
32 import org.objectweb.jonas_lib.deployment.api.EjbRefDesc;
33 import org.objectweb.jonas_lib.genbase.GenBaseException;
34 import org.objectweb.jonas_lib.genbase.archive.Archive;
35 import org.objectweb.jonas_lib.genbase.archive.Ejb;
36 import org.objectweb.jonas_lib.genbase.archive.EjbJar;
37 import org.objectweb.jonas_lib.genclientstub.ClientStubGenException;
38 import org.objectweb.jonas_lib.genclientstub.generator.Generator;
39 import org.objectweb.jonas_lib.genclientstub.generator.GeneratorFactory;
40
41 import org.objectweb.util.monolog.api.BasicLevel;
42
43 /**
44  * Modify a given EjbJar.
45  * @author Florent Benoit
46  */

47 public class EjbJarModifier extends AbsArchiveModifier {
48
49     /**
50      * Modified ejbjar
51      */

52     private EjbJar ejbjar = null;
53
54     /**
55      * Creates a new EjbJarModifier object.
56      * @param ejbjar EjbJar Archive
57      */

58     public EjbJarModifier(EjbJar ejbjar) {
59         super(ejbjar);
60         this.ejbjar = ejbjar;
61     }
62
63     /**
64      * modify the current EjbJar. If EjbJar is contained in not an application
65      * and have webservices endpoints, A DummyApplication is created and
66      * modification process launched against the newly created application. If
67      * EjbJar is contained in an application + webservices endpoints, a
68      * DummyWebApp is created to hold "facade" servlet managing SOAP processing.
69      * @return an EjbJar or an Application Archive
70      * @throws GenBaseException When generation or storing fails
71      * @throws ClientStubGenException When generation or storing fails
72      */

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