01: /**
02: * JOnAS: Java(TM) Open Application Server
03: * Copyright (C) 2006 Bull S.A.S.
04: * Contact: jonas-team@objectweb.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * 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: WebServicesXmlFinder.java 8253 2006-04-18 11:40:19Z sauthieg $
23: * --------------------------------------------------------------------------
24: */package org.objectweb.jonas_ws.wsgen.finder;
25:
26: import java.util.Iterator;
27: import java.util.List;
28:
29: import org.objectweb.jonas_lib.genbase.archive.J2EEArchive;
30:
31: /**
32: * <code>WebServicesXmlFinder</code> finds out if there is any
33: * <code>webservices.xml</code> within the given {@link J2EEArchive}.
34: *
35: * @author Guillaume Sauthier
36: */
37: public class WebServicesXmlFinder implements J2EEWebServicesFinder {
38:
39: /**
40: * WebApp's webservices.xml.
41: */
42: private static final String WEBINF_WEBSERVICES_XML = "WEB-INF/webservices.xml";
43:
44: /**
45: * EjbJar's webservices.xml.
46: */
47: private static final String METAINF_WEBSERVICES_XML = "META-INF/webservices.xml";
48:
49: /**
50: * Archive to browse.
51: */
52: private J2EEArchive archive = null;
53:
54: /**
55: * Constructs a <code>WebServicesXmlFinder</code> that will
56: * explore the given {@link J2EEArchive}.
57: * @param archive archive to explore.
58: */
59: public WebServicesXmlFinder(J2EEArchive archive) {
60: this .archive = archive;
61: }
62:
63: /**
64: * @see org.objectweb.jonas_ws.wsgen.finder.J2EEWebServicesFinder#find()
65: */
66: public boolean find() {
67: List files = archive.getContainedFiles();
68: for (Iterator i = files.iterator(); i.hasNext();) {
69: String filename = (String) i.next();
70: if (WEBINF_WEBSERVICES_XML.equals(filename)
71: || METAINF_WEBSERVICES_XML.equals(filename)) {
72: return true;
73: }
74: }
75: return false;
76: }
77:
78: }
|