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: EarExploded.java 1970 2007-10-16 11:49:25Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.ant.archive.exploded;
025:
026: import java.io.File;
027: import java.util.List;
028:
029: import org.apache.tools.ant.Project;
030: import org.ow2.easybeans.ant.archive.AbsArchive;
031: import org.ow2.easybeans.ant.archive.Ejb;
032: import org.ow2.easybeans.ant.archive.War;
033: import org.ow2.easybeans.ant.archive.api.IEar;
034: import org.ow2.easybeans.ant.archive.info.EarInfo;
035:
036: /**
037: * Creates an EAR exploded archive.
038: * @author Florent Benoit
039: */
040: public class EarExploded extends AbsExplodedArchive implements IEar {
041:
042: /**
043: * Path to the Standard deployment descriptor.
044: */
045: private static final String DEPLOYMENT_DESCRIPTOR = "META-INF/application.xml";
046:
047: /**
048: * Ear info object.
049: */
050: private EarInfo earInfo = null;
051:
052: /**
053: * Creates an archive for the given project.
054: * @param p the given project
055: */
056: public EarExploded(final Project p) {
057: super (p);
058: }
059:
060: /**
061: * Sets the information about an EAR archive.
062: * @param earInfo the object that holds data information.
063: */
064: public void setEarInfo(final EarInfo earInfo) {
065: setArchiveInfo(earInfo);
066: this .earInfo = earInfo;
067: }
068:
069: /**
070: * Gets the path to the standard deployment descriptor.
071: * @return the path to the standard deployment descriptor.
072: */
073: @Override
074: public String getDDStandardName() {
075: return DEPLOYMENT_DESCRIPTOR;
076: }
077:
078: /**
079: * Execute the task.
080: */
081: @Override
082: public void execute() {
083: // create directory
084: earInfo.getDest().mkdirs();
085:
086: // Include the DD if any and initial fileset
087: super .execute();
088:
089: // Execute children by changing the destination directory
090: List<Ejb> ejbs = earInfo.getEjbs();
091: List<War> wars = earInfo.getWars();
092:
093: if (ejbs != null) {
094: for (Ejb ejb : ejbs) {
095: updateArchive(ejb);
096: ejb.execute();
097: }
098: }
099:
100: if (wars != null) {
101: for (War war : wars) {
102: updateArchive(war);
103: war.execute();
104: }
105: }
106: }
107:
108: /**
109: * Update the archive with some settings.
110: * @param archive the archive to update
111: */
112: void updateArchive(final AbsArchive archive) {
113: archive.setDest(new File(earInfo.getDest(), archive.getDest()
114: .getName()));
115: }
116:
117: }
|