001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 2003-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: AbsModifierFactory.java 5600 2004-10-12 13:50:27Z sauthieg $
023: * --------------------------------------------------------------------------
024: */package org.objectweb.jonas_lib.genbase.modifier;
025:
026: import java.io.File;
027: import java.util.jar.JarFile;
028:
029: /**
030: * Used to create the right ArchiveModifier from a given filename (ear, jar,
031: * war, ...)
032: *
033: * @author Guillaume Sauthier
034: * @author Florent Benoit (make common class for client stubs and WsGen)
035: */
036: public abstract class AbsModifierFactory {
037:
038: /**
039: * Application Archive mode
040: */
041: public static final int APPLICATION = 0;
042:
043: /**
044: * EjbJar Archive mode
045: */
046: public static final int EJBJAR = 1;
047:
048: /**
049: * WebApp Archive mode
050: */
051: public static final int WEBAPP = 2;
052:
053: /**
054: * ApplicationClient Archive mode
055: */
056: public static final int CLIENT = 3;
057:
058: /**
059: * Utility class (no default public constructor)
060: */
061: protected AbsModifierFactory() {
062:
063: }
064:
065: /**
066: * returns true if the file is an Application archive.
067: *
068: * @param jf JarFile to explore.
069: *
070: * @return true if the file is an Application archive.
071: */
072: protected static boolean isApplication(JarFile jf) {
073: return jf.getEntry("META-INF/application.xml") != null;
074: }
075:
076: /**
077: * returns true if the file is an EjbJar archive.
078: *
079: * @param jf JarFile to explore.
080: *
081: * @return true if the file is an EjbJar archive.
082: */
083: protected static boolean isEjbJar(JarFile jf) {
084: return jf.getEntry("META-INF/ejb-jar.xml") != null;
085: }
086:
087: /**
088: * returns true if the file is a WebApp archive.
089: *
090: * @param jf JarFile to explore.
091: *
092: * @return true if the file is a WebApp archive.
093: */
094: protected static boolean isWebApp(JarFile jf) {
095: return jf.getEntry("WEB-INF/web.xml") != null;
096: }
097:
098: /**
099: * returns true if the file is a Client archive.
100: *
101: * @param jf JarFile to explore.
102: *
103: * @return true if the file is a Client archive.
104: */
105: protected static boolean isClient(JarFile jf) {
106: return jf.getEntry("META-INF/application-client.xml") != null;
107: }
108:
109: /**
110: * returns true if the file is an Application archive.
111: *
112: * @param f Directory to explore.
113: *
114: * @return true if the file is an Application archive.
115: */
116: protected static boolean isApplication(File f) {
117: return new File(f, "META-INF" + File.separator
118: + "application.xml").exists();
119: }
120:
121: /**
122: * returns true if the file is an EjbJar archive.
123: *
124: * @param f Directory to explore.
125: *
126: * @return true if the file is an EjbJar archive.
127: */
128: protected static boolean isEjbJar(File f) {
129: return new File(f, "META-INF" + File.separator + "ejb-jar.xml")
130: .exists();
131: }
132:
133: /**
134: * returns true if the file is a WebApp archive.
135: *
136: * @param f Directory to explore.
137: *
138: * @return true if the file is a WebApp archive.
139: */
140: protected static boolean isWebApp(File f) {
141: return new File(f, "WEB-INF" + File.separator + "web.xml")
142: .exists();
143: }
144:
145: /**
146: * returns true if the file is a Client archive.
147: *
148: * @param f Directory to explore.
149: *
150: * @return true if the file is a Client archive.
151: */
152: protected static boolean isClient(File f) {
153: return new File(f, "META-INF" + File.separator
154: + "application-client.xml").exists();
155: }
156: }
|