KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > web > WebApplication


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.web;
23
24 import java.net.URL JavaDoc;
25 import java.util.HashMap JavaDoc;
26 import java.util.Map JavaDoc;
27 import java.util.Properties JavaDoc;
28
29 import org.jboss.metadata.WebMetaData;
30 import org.jboss.deployers.spi.deployer.DeploymentUnit;
31 import org.jboss.deployment.DeploymentInfo;
32
33 /** A WebApplication represents the information for a war deployment.
34
35  @see AbstractWebContainer
36
37  @author Scott.Stark@jboss.org
38  @version $Revision: 58292 $
39  */

40 public class WebApplication
41 {
42    /** */
43    private DeploymentUnit unit;
44    /** Class loader of this application */
45    protected ClassLoader JavaDoc classLoader = null;
46    /** name of this application */
47    protected String JavaDoc name = "";
48    protected String JavaDoc canonicalName;
49    /** URL where this application was deployed from */
50    protected URL JavaDoc url;
51    /** The web app metadata from the web.xml and jboss-web.xml descriptors */
52    protected WebMetaData metaData;
53    /** Arbitary data object for storing application specific data */
54    protected Object JavaDoc data;
55    /** The jmx domain of the web container */
56    protected String JavaDoc domain;
57    /**
58     * The parent class loader first model flag
59     */

60    protected boolean java2ClassLoadingCompliance = false;
61    /**
62     * A flag indicating if war archives should be unpacked
63     */

64    protected boolean unpackWars = true;
65    /**
66     * If true, ejb-links that don't resolve don't cause an error (fallback to
67     * jndi-name)
68     */

69    protected boolean lenientEjbLink = false;
70    /**
71     * The default security-domain name to use
72     */

73    protected String JavaDoc defaultSecurityDomain;
74    protected HashMap JavaDoc vhostToHostNames = new HashMap JavaDoc();
75    /** Deployer config bean */
76    protected Object JavaDoc deployerConfig;
77
78    /** Create an empty WebApplication instance
79     */

80    public WebApplication()
81    {
82    }
83
84    /** Create a WebApplication instance with with given web-app metadata.
85     @param metaData the web-app metadata containing the web.xml and
86     jboss-web.xml descriptor metadata.
87     */

88    public WebApplication(WebMetaData metaData)
89    {
90       this.metaData = metaData;
91    }
92
93    /** Create a WebApplication instance with with given name,
94     url and class loader.
95     @param name name of this application
96     @param url url where this application was deployed from
97     @param classLoader Class loader of this application
98     */

99    public WebApplication(String JavaDoc name, URL JavaDoc url, ClassLoader JavaDoc classLoader)
100    {
101       this.name = name;
102       this.url = url;
103       this.classLoader = classLoader;
104    }
105
106    public DeploymentUnit getDeploymentUnit()
107    {
108       return unit;
109    }
110    public void setDeploymentUnit(DeploymentUnit unit)
111    {
112       this.unit = unit;
113    }
114
115    /** Get the class loader of this WebApplication.
116     * @return The ClassLoader instance of the web application
117     */

118    public ClassLoader JavaDoc getClassLoader()
119    {
120       return classLoader;
121    }
122
123    /** Set the class loader of this WebApplication.
124     * @param classLoader The ClassLoader instance for the web application
125     */

126    public void setClassLoader(ClassLoader JavaDoc classLoader)
127    {
128       this.classLoader = classLoader;
129    }
130
131    /** Get the name of this WebApplication.
132     * @return String name of the web application
133     */

134    public String JavaDoc getName()
135    {
136       String JavaDoc n = name;
137       if (n == null)
138          n = url.getFile();
139       return n;
140    }
141
142    /** Set the name of this WebApplication.
143     * @param name of the web application
144     */

145    public void setName(String JavaDoc name)
146    {
147       this.name = name;
148    }
149
150    public String JavaDoc getCanonicalName()
151    {
152       return canonicalName;
153    }
154    public void setCanonicalName(String JavaDoc canonicalName)
155    {
156       this.canonicalName = canonicalName;
157    }
158
159    /** Get the URL from which this WebApplication was deployed
160     * @return URL where this application was deployed from
161     */

162    public URL JavaDoc getURL()
163    {
164       return url;
165    }
166
167    /** Set the URL from which this WebApplication was deployed
168     * @param url URL where this application was deployed from
169     */

170    public void setURL(URL JavaDoc url)
171    {
172       if (url == null)
173          throw new IllegalArgumentException JavaDoc("Null URL");
174       this.url = url;
175    }
176
177    /** Getter for property metaData.
178     * @return Value of property metaData.
179     */

180    public WebMetaData getMetaData()
181    {
182       return metaData;
183    }
184
185    /** Setter for property metaData.
186     * @param metaData New value of property metaData.
187     */

188    public void setMetaData(WebMetaData metaData)
189    {
190       this.metaData = metaData;
191    }
192
193    public Object JavaDoc getAppData()
194    {
195       return data;
196    }
197
198    public void setAppData(Object JavaDoc data)
199    {
200       this.data = data;
201    }
202
203
204    public String JavaDoc getDomain()
205    {
206       return domain;
207    }
208    public void setDomain(String JavaDoc domain)
209    {
210       this.domain = domain;
211    }
212    /**
213     * Get the flag indicating if the normal Java2 parent first class loading
214     * model should be used over the servlet 2.3 web container first model.
215     * @return true for parent first, false for the servlet 2.3 model
216     * @jmx.managed-attribute
217     */

218    public boolean getJava2ClassLoadingCompliance()
219    {
220       return java2ClassLoadingCompliance;
221    }
222
223    /**
224     * Set the flag indicating if the normal Java2 parent first class loading
225     * model should be used over the servlet 2.3 web container first model.
226     * @param flag true for parent first, false for the servlet 2.3 model
227     * @jmx.managed-attribute
228     */

229    public void setJava2ClassLoadingCompliance(boolean flag)
230    {
231       java2ClassLoadingCompliance = flag;
232    }
233
234    /**
235     * Get the flag indicating if war archives should be unpacked. This may need
236     * to be set to false as long extraction paths under deploy can show up as
237     * deployment failures on some platforms.
238     * @return true is war archives should be unpacked
239     * @jmx.managed-attribute
240     */

241    public boolean getUnpackWars()
242    {
243       return unpackWars;
244    }
245
246    /**
247     * Get the flag indicating if war archives should be unpacked. This may need
248     * to be set to false as long extraction paths under deploy can show up as
249     * deployment failures on some platforms.
250     * @param flag , true is war archives should be unpacked
251     * @jmx.managed-attribute
252     */

253    public void setUnpackWars(boolean flag)
254    {
255       this.unpackWars = flag;
256    }
257
258    /**
259     * Get the flag indicating if ejb-link errors should be ignored in favour of
260     * trying the jndi-name in jboss-web.xml
261     * @return a <code>boolean</code> value
262     * @jmx.managed-attribute
263     */

264    public boolean getLenientEjbLink()
265    {
266       return lenientEjbLink;
267    }
268
269    /**
270     * Set the flag indicating if ejb-link errors should be ignored in favour of
271     * trying the jndi-name in jboss-web.xml
272     * @jmx.managed-attribute
273     */

274    public void setLenientEjbLink(boolean flag)
275    {
276       lenientEjbLink = flag;
277    }
278
279    /**
280     * Get the default security domain implementation to use if a war does not
281     * declare a security-domain.
282     * @return jndi name of the security domain binding to use.
283     * @jmx.managed-attribute
284     */

285    public String JavaDoc getDefaultSecurityDomain()
286    {
287       return defaultSecurityDomain;
288    }
289
290    /**
291     * Set the default security domain implementation to use if a war does not
292     * declare a security-domain.
293     * @param defaultSecurityDomain - jndi name of the security domain binding to
294     * use.
295     * @jmx.managed-attribute
296     */

297    public void setDefaultSecurityDomain(String JavaDoc defaultSecurityDomain)
298    {
299       this.defaultSecurityDomain = defaultSecurityDomain;
300    }
301
302    public Map JavaDoc getVhostToHostNames()
303    {
304       return this.vhostToHostNames;
305    }
306    public void setVhostToHostNames(Map JavaDoc map)
307    {
308       this.vhostToHostNames.clear();
309       this.vhostToHostNames.putAll(map);
310    }
311
312    public Object JavaDoc getDeployerConfig()
313    {
314       return deployerConfig;
315    }
316    public void setDeployerConfig(Object JavaDoc config)
317    {
318       this.deployerConfig = config;
319    }
320
321    public String JavaDoc toString()
322    {
323       StringBuffer JavaDoc buffer = new StringBuffer JavaDoc("{WebApplication: ");
324       buffer.append(getName());
325       buffer.append(", URL: ");
326       buffer.append(url);
327       buffer.append(", classLoader: ");
328       buffer.append(classLoader);
329       buffer.append(':');
330       buffer.append(classLoader.hashCode());
331       buffer.append('}');
332       return buffer.toString();
333    }
334
335 }
336
Popular Tags