001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 2004 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: EjbJarModifier.java 5928 2004-12-13 16:27:33Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.objectweb.jonas_lib.genclientstub.modifier;
025:
026: import java.io.File;
027: import java.util.Iterator;
028: import java.util.List;
029:
030: import org.objectweb.jonas_lib.deployment.api.EjbRefDesc;
031: import org.objectweb.jonas_lib.genbase.GenBaseException;
032: import org.objectweb.jonas_lib.genbase.archive.Archive;
033: import org.objectweb.jonas_lib.genbase.archive.Ejb;
034: import org.objectweb.jonas_lib.genbase.archive.EjbJar;
035: import org.objectweb.jonas_lib.genclientstub.ClientStubGenException;
036: import org.objectweb.jonas_lib.genclientstub.generator.Generator;
037: import org.objectweb.jonas_lib.genclientstub.generator.GeneratorFactory;
038:
039: import org.objectweb.util.monolog.api.BasicLevel;
040:
041: /**
042: * Modify a given EjbJar.
043: * @author Florent Benoit
044: */
045: public class EjbJarModifier extends AbsArchiveModifier {
046:
047: /**
048: * Modified ejbjar
049: */
050: private EjbJar ejbjar = null;
051:
052: /**
053: * Creates a new EjbJarModifier object.
054: * @param ejbjar EjbJar Archive
055: */
056: public EjbJarModifier(EjbJar ejbjar) {
057: super (ejbjar);
058: this .ejbjar = ejbjar;
059: }
060:
061: /**
062: * modify the current EjbJar. If EjbJar is contained in not an application
063: * and have webservices endpoints, A DummyApplication is created and
064: * modification process launched against the newly created application. If
065: * EjbJar is contained in an application + webservices endpoints, a
066: * DummyWebApp is created to hold "facade" servlet managing SOAP processing.
067: * @return an EjbJar or an Application Archive
068: * @throws GenBaseException When generation or storing fails
069: * @throws ClientStubGenException When generation or storing fails
070: */
071: public Archive modify() throws GenBaseException,
072: ClientStubGenException {
073:
074: getLogger().log(BasicLevel.INFO,
075: "Processing EjbJar " + ejbjar.getName());
076:
077: GeneratorFactory gf = GeneratorFactory.getInstance();
078:
079: // Found automatically the stubs
080: generateFoundStubs(gf.getConfiguration(), ejbjar);
081:
082: // Ejb-Ref
083: List ejbs = ejbjar.getEjbs();
084: for (Iterator i = ejbs.iterator(); i.hasNext();) {
085: Ejb ejb = (Ejb) i.next();
086: List ejbRefs = ejb.getEjbRefDescs();
087: for (Iterator j = ejbRefs.iterator(); j.hasNext();) {
088: EjbRefDesc ejbRef = (EjbRefDesc) j.next();
089:
090: // launch generation
091: Generator g = new Generator(gf.getConfiguration(),
092: ejbRef, null, ejbjar);
093: g.generate();
094: g.compile();
095: // add files in web archive
096: g.addFiles(ejbjar);
097: }
098: }
099:
100: return save(gf.getConfiguration(), "ejbjars" + File.separator
101: + ejbjar.getRootFile().getName());
102:
103: }
104: }
|