001: /**
002: * EasyBeans
003: * Copyright (C) 2007 Bull S.A.S.
004: * Contact: easybeans@ow2.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: Ear.java 1970 2007-10-16 11:49:25Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.ant.archive;
025:
026: import java.util.ArrayList;
027: import java.util.List;
028:
029: import org.apache.tools.ant.Project;
030: import org.apache.tools.ant.Task;
031: import org.ow2.easybeans.ant.archive.api.IEar;
032: import org.ow2.easybeans.ant.archive.exploded.EarExploded;
033: import org.ow2.easybeans.ant.archive.file.EarFile;
034: import org.ow2.easybeans.ant.archive.info.EarInfo;
035:
036: /**
037: * Task that creates an Ear archive (.ear file or .ear directory).
038: * @author Florent Benoit
039: */
040: public class Ear extends AbsArchive {
041:
042: /**
043: * List of War to package in this EAR.
044: */
045: private List<War> wars = null;
046:
047: /**
048: * List of EJB to package in this EAR.
049: */
050: private List<Ejb> ejbs = null;
051:
052: /**
053: * Default constructor.
054: */
055: public Ear() {
056: super ();
057: this .wars = new ArrayList<War>();
058: this .ejbs = new ArrayList<Ejb>();
059: }
060:
061: /**
062: * Add a given war archive.
063: * @param war the given archive
064: */
065: public void addConfiguredWar(final War war) {
066: wars.add(war);
067: }
068:
069: /**
070: * Add a given Ejb archive.
071: * @param ejb the given archive
072: */
073: public void addConfiguredEjb(final Ejb ejb) {
074: ejbs.add(ejb);
075: }
076:
077: /**
078: * Execute the task.
079: */
080: @Override
081: public void execute() {
082:
083: log("Building Ear in '" + getDest() + "'.", Project.MSG_INFO);
084:
085: IEar ear = null;
086:
087: // 2 cases, exploded mode or not
088: if (isExploded()) {
089: ear = new EarExploded(getProject());
090: } else {
091: ear = new EarFile(getProject());
092: }
093:
094: // Set the name of the task
095: ((Task) ear).setTaskName(getTaskName());
096:
097: // Build the info object
098: EarInfo earInfo = new EarInfo();
099: ear.setEarInfo(earInfo);
100:
101: // Fill archive properties
102: updateArchiveInfo(earInfo);
103:
104: // set children
105: earInfo.setEjbs(ejbs);
106: earInfo.setWars(wars);
107:
108: // Execute the task
109: ear.execute();
110:
111: }
112:
113: }
|