View Javadoc

1   /*******************************************************************************
2    *  Copyright (c) 2005, 2006, 2007 Imola Informatica.
3    *  All rights reserved. This program and the accompanying materials
4    *  are made available under the terms of the LGPL License v2.1
5    *  which accompanies this distribution, and is available at
6    *  http://www.gnu.org/licenses/lgpl.html
7    *******************************************************************************/
8   package it.imolinfo.jbi4ejb.jbi.wsdl;
9   
10  import it.imolinfo.jbi4ejb.Logger;
11  import it.imolinfo.jbi4ejb.LoggerFactory;
12  
13  import javax.wsdl.Definition;
14  import javax.wsdl.WSDLException;
15  import javax.wsdl.extensions.ExtensibilityElement;
16  import javax.wsdl.extensions.ExtensionDeserializer;
17  import javax.wsdl.extensions.ExtensionRegistry;
18  import javax.xml.namespace.QName;
19  
20  import org.w3c.dom.Element;
21  
22  import com.ibm.wsdl.util.xml.DOMUtils;
23  import com.ibm.wsdl.util.xml.QNameUtils;
24  
25  /**
26   * Deserializer for the Jbi4Ejb WSDL Extension (Types element), according with JWSDL specs.
27   * See JSR 110.
28   *
29   * @author <a href="mailto:mpiraccini@imolinfo.it">Marco Piraccini</a>
30   */
31  public class Jbi4EjbTypesDeserializer implements ExtensionDeserializer {
32  
33      /**
34       * The logger for this class and its instances.
35       */
36      private static final Logger LOG
37              = LoggerFactory.getLogger(Jbi4EjbTypesDeserializer.class);
38          
39      /**
40       * Instantiates a new jbi4 ejb types deserializer.
41       */
42      public Jbi4EjbTypesDeserializer() {}
43  
44      /**
45       * Unmarshall the Jbi4EjbTypes extensibility element.
46       * 
47       * @param parentType
48       *            the parent type
49       * @param elementType
50       *            the element type
51       * @param el
52       *            the element
53       * @param def
54       *            the WSDL Definition
55       * @param extReg
56       *            the extension registry
57       * 
58       * @return the unmarhalled extensibility element
59       * 
60       * @throws WSDLException
61       *             if some problem occurs in unmarshalling
62       */
63      public ExtensibilityElement unmarshall(Class parentType, QName elementType,
64              Element el, Definition def, ExtensionRegistry extReg)
65      throws WSDLException {
66  
67          Jbi4EjbTypes jbi4EjbTypes = (Jbi4EjbTypes) extReg
68              .createExtension(parentType, elementType);
69  
70          Element element = DOMUtils.getFirstChildElement(el);
71          while (element != null) {
72  
73              // serialVersioneUID Element
74              if (QNameUtils.matches(Jbi4EjbExtension.Q_ELEM_JBI4EJB_SERIAL_VERSION_UID,
75                      element)) {                
76                  String className = DOMUtils.getAttribute(
77                          element, Jbi4EjbExtension.CLASSNAME_ATTRIBUTE);
78                  String uid = DOMUtils.getAttribute(element,
79                          Jbi4EjbExtension.UID_ATTRIBUTE);
80                  LOG.debug("Found uid for className " + className +": " + uid);
81   
82                  jbi4EjbTypes.getTypesSerialVersionUIDs().put(className, uid);
83              }
84              element = DOMUtils
85                  .getNextSiblingElement(element);
86  
87          }
88  
89          return jbi4EjbTypes;
90      }
91  }