01: /*
02: * JBoss, Home of Professional Open Source
03: * Copyright 2005, JBoss Inc., and individual contributors as indicated
04: * by the @authors tag. See the copyright.txt in the distribution for a
05: * full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * 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.metadata.serviceref;
23:
24: // $Id: ServiceRefObjectFactory.java 61248 2007-03-10 04:12:47Z thomas.diesler@jboss.com $
25:
26: import org.jboss.logging.Logger;
27: import org.jboss.ws.integration.ServiceRefElement;
28: import org.jboss.xb.binding.ObjectModelFactory;
29: import org.jboss.xb.binding.UnmarshallingContext;
30: import org.w3c.dom.DocumentType;
31: import org.w3c.dom.Element;
32: import org.xml.sax.Attributes;
33:
34: /**
35: * A object model factory for <service-ref>
36: *
37: * @author Thomas.Diesler@jboss.com
38: */
39: public abstract class ServiceRefObjectFactory implements
40: ObjectModelFactory {
41: // provide logging
42: private static Logger log = Logger
43: .getLogger(ServiceRefObjectFactory.class);
44:
45: public Object newChild(ServiceRefElement ref,
46: UnmarshallingContext navigator, String namespaceURI,
47: String localName, Attributes attrs) {
48: return new ServiceRefDelegate().newChild(ref, navigator,
49: namespaceURI, localName, attrs);
50: }
51:
52: public void setValue(ServiceRefElement ref,
53: UnmarshallingContext navigator, String namespaceURI,
54: String localName, String value) {
55: new ServiceRefDelegate().setValue(ref, navigator, namespaceURI,
56: localName, value);
57: }
58:
59: public static boolean isJ2EE14Descriptor(Element element) {
60: // Verify J2EE-1.4
61: String nsURI = element.getOwnerDocument().getDocumentElement()
62: .getNamespaceURI();
63: boolean isValid = "http://java.sun.com/xml/ns/j2ee"
64: .equals(nsURI);
65:
66: // Verify JBoss-4.0
67: DocumentType doctype = element.getOwnerDocument().getDoctype();
68: if (isValid == false && doctype != null) {
69: String publicId = doctype.getPublicId();
70: isValid |= "-//JBoss//DTD JBOSS 4.0//EN".equals(publicId);
71: isValid |= "-//JBoss//DTD JBOSS 4.2//EN".equals(publicId);
72: isValid |= "-//JBoss//DTD Web Application 2.4//EN"
73: .equals(publicId);
74: isValid |= "-//JBoss//DTD Application Client 4.0//EN"
75: .equals(publicId);
76: isValid |= "-//JBoss//DTD Application Client 4.2//EN"
77: .equals(publicId);
78: }
79:
80: if (isValid == false) {
81: String dtstr = (doctype != null ? "[public="
82: + doctype.getPublicId() + ",system="
83: + doctype.getSystemId() + "]" : null);
84: log.debug("Skip <service-ref> for: nsURI=" + nsURI
85: + ",doctype=" + dtstr);
86: }
87: return isValid;
88: }
89: }
|