KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas_lib > genbase > modifier > AbsModifierFactory


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 2003-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: AbsModifierFactory.java,v 1.2 2004/10/12 13:46:42 sauthieg Exp $
23  * --------------------------------------------------------------------------
24  */

25
26
27 package org.objectweb.jonas_lib.genbase.modifier;
28
29 import java.io.File JavaDoc;
30 import java.util.jar.JarFile JavaDoc;
31
32
33 /**
34  * Used to create the right ArchiveModifier from a given filename (ear, jar,
35  * war, ...)
36  *
37  * @author Guillaume Sauthier
38  * @author Florent Benoit (make common class for client stubs and WsGen)
39  */

40 public abstract class AbsModifierFactory {
41
42      /**
43      * Application Archive mode
44      */

45     public static final int APPLICATION = 0;
46
47     /**
48      * EjbJar Archive mode
49      */

50     public static final int EJBJAR = 1;
51
52     /**
53      * WebApp Archive mode
54      */

55     public static final int WEBAPP = 2;
56
57     /**
58      * ApplicationClient Archive mode
59      */

60     public static final int CLIENT = 3;
61
62     /**
63      * Utility class (no default public constructor)
64      */

65     protected AbsModifierFactory() {
66
67     }
68
69     /**
70      * returns true if the file is an Application archive.
71      *
72      * @param jf JarFile to explore.
73      *
74      * @return true if the file is an Application archive.
75      */

76     protected static boolean isApplication(JarFile JavaDoc jf) {
77         return jf.getEntry("META-INF/application.xml") != null;
78     }
79
80     /**
81      * returns true if the file is an EjbJar archive.
82      *
83      * @param jf JarFile to explore.
84      *
85      * @return true if the file is an EjbJar archive.
86      */

87     protected static boolean isEjbJar(JarFile JavaDoc jf) {
88         return jf.getEntry("META-INF/ejb-jar.xml") != null;
89     }
90
91     /**
92      * returns true if the file is a WebApp archive.
93      *
94      * @param jf JarFile to explore.
95      *
96      * @return true if the file is a WebApp archive.
97      */

98     protected static boolean isWebApp(JarFile JavaDoc jf) {
99         return jf.getEntry("WEB-INF/web.xml") != null;
100     }
101
102     /**
103      * returns true if the file is a Client archive.
104      *
105      * @param jf JarFile to explore.
106      *
107      * @return true if the file is a Client archive.
108      */

109     protected static boolean isClient(JarFile JavaDoc jf) {
110         return jf.getEntry("META-INF/application-client.xml") != null;
111     }
112
113     /**
114      * returns true if the file is an Application archive.
115      *
116      * @param f Directory to explore.
117      *
118      * @return true if the file is an Application archive.
119      */

120     protected static boolean isApplication(File JavaDoc f) {
121         return new File JavaDoc(f, "META-INF" + File.separator + "application.xml").exists();
122     }
123
124     /**
125      * returns true if the file is an EjbJar archive.
126      *
127      * @param f Directory to explore.
128      *
129      * @return true if the file is an EjbJar archive.
130      */

131     protected static boolean isEjbJar(File JavaDoc f) {
132         return new File JavaDoc(f, "META-INF" + File.separator + "ejb-jar.xml").exists();
133     }
134
135     /**
136      * returns true if the file is a WebApp archive.
137      *
138      * @param f Directory to explore.
139      *
140      * @return true if the file is a WebApp archive.
141      */

142     protected static boolean isWebApp(File JavaDoc f) {
143         return new File JavaDoc(f, "WEB-INF" + File.separator + "web.xml").exists();
144     }
145
146     /**
147      * returns true if the file is a Client archive.
148      *
149      * @param f Directory to explore.
150      *
151      * @return true if the file is a Client archive.
152      */

153     protected static boolean isClient(File JavaDoc f) {
154         return new File JavaDoc(f, "META-INF" + File.separator + "application-client.xml").exists();
155     }
156 }
Popular Tags