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: ServiceRefFinder.java 8254 2006-04-18 11:51:15Z sauthieg $
23: * --------------------------------------------------------------------------
24: */package org.objectweb.jonas_ws.wsgen.finder;
25:
26: import org.xml.sax.Attributes;
27: import org.xml.sax.SAXException;
28: import org.xml.sax.helpers.DefaultHandler;
29:
30: /**
31: * Specialized Finder for XML files.
32: * If one contains some service-ref elements, it will be marked has WS enabled.
33: *
34: * @author Guillaume Sauthier
35: */
36: public class ServiceRefFinder extends DefaultHandler implements
37: J2EEWebServicesFinder {
38:
39: /**
40: * J2EE Namespace URI.
41: */
42: private static final String J2EE_NS = "http://java.sun.com/xml/ns/j2ee";
43:
44: /**
45: * true if a service-ref element was found.
46: */
47: private boolean found = false;
48:
49: /**
50: * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
51: */
52: public void startElement(String uri, String localName,
53: String qName, Attributes attributes) throws SAXException {
54: super .startElement(uri, localName, qName, attributes);
55: if ("service-ref".equals(localName) && J2EE_NS.equals(uri)) {
56: // found a j2ee:service-ref element
57: // react in some way
58: found = true;
59: }
60: }
61:
62: /**
63: * @see org.objectweb.jonas_ws.wsgen.finder.J2EEWebServicesFinder#find()
64: */
65: public boolean find() {
66: return found;
67: }
68:
69: }
|