1   
2   
3   
4   
5   
6   
7   
8   package it.imolinfo.jbi4ejb.jbi.wsdl;
9   
10  import it.imolinfo.jbi4ejb.Logger;
11  import it.imolinfo.jbi4ejb.LoggerFactory;
12  
13  import java.util.Properties;
14  
15  import javax.wsdl.Definition;
16  import javax.wsdl.WSDLException;
17  import javax.wsdl.extensions.ExtensibilityElement;
18  import javax.wsdl.extensions.ExtensionDeserializer;
19  import javax.wsdl.extensions.ExtensionRegistry;
20  import javax.xml.namespace.QName;
21  
22  import org.w3c.dom.Element;
23  
24  import com.ibm.wsdl.util.xml.DOMUtils;
25  import com.ibm.wsdl.util.xml.QNameUtils;
26  
27  
28  
29  
30  
31  
32  
33  public class Jbi4EjbBindingDeserializer implements ExtensionDeserializer {
34  
35      
36  
37  
38      private static final Logger LOG
39              = LoggerFactory.getLogger(Jbi4EjbBindingDeserializer.class);
40  
41      
42      
43  
44  
45      public Jbi4EjbBindingDeserializer() {}
46      
47      
48  
49  
50  
51  
52  
53  
54      
55      
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72      @SuppressWarnings("unchecked")
73      public ExtensibilityElement unmarshall(Class parentType, QName elementType,
74              Element el, Definition def, ExtensionRegistry extReg)
75      throws WSDLException {
76  
77          Jbi4EjbBinding jbi4EjbBinding = (Jbi4EjbBinding) extReg
78          .createExtension(parentType, elementType);
79  
80          Element tempEl = DOMUtils.getFirstChildElement(el);
81          while (tempEl != null) {
82  
83              
84              if (QNameUtils.matches(Jbi4EjbExtension.Q_ELEM_JBI4EJB_ORB,
85                      tempEl)) {
86  
87                  
88                  Properties orbProperties = new Properties();
89  
90                  Element propertyElement = DOMUtils.getFirstChildElement(tempEl);
91  
92                  while (propertyElement != null) {
93                      String propertyName = DOMUtils.getAttribute(
94                              propertyElement, Jbi4EjbExtension.NAME_ATTRIBUTE);
95                      String propertyValue = DOMUtils
96                      .getAttribute(propertyElement,
97                              Jbi4EjbExtension.VALUE_ATTRIBUTE);
98                      orbProperties.put(propertyName, propertyValue);
99                      LOG.debug("Read ORB properties: [" + propertyName + "] "
100                             + " [" + propertyValue + "]");
101                     propertyElement = DOMUtils
102                     .getNextSiblingElement(propertyElement);
103                 }
104 
105                 
106                 LOG.debug("Read orb properties: " + orbProperties);
107                 jbi4EjbBinding.setOrbProperties(orbProperties);
108             }
109 
110             
111             if (QNameUtils.matches(Jbi4EjbExtension.Q_ELEM_JBI4EJB_JNDI,
112                     tempEl)) {
113 
114                 
115                 Properties jndiProperties = new Properties();
116 
117                 Element propertyElement = DOMUtils.getFirstChildElement(tempEl);
118 
119                 while (propertyElement != null) {
120                     String propertyName = DOMUtils.getAttribute(
121                             propertyElement, Jbi4EjbExtension.NAME_ATTRIBUTE);
122                     String propertyValue = DOMUtils
123                     .getAttribute(propertyElement,
124                             Jbi4EjbExtension.VALUE_ATTRIBUTE);
125                     jndiProperties.put(propertyName, propertyValue);
126                     LOG.debug("Read ORB properties: [" + propertyName + "] "
127                             + " [" + propertyValue + "]");
128                     propertyElement = DOMUtils
129                     .getNextSiblingElement(propertyElement);
130                 }
131 
132                 
133                 LOG.debug("Read jndi properties: " + jndiProperties);
134                 jbi4EjbBinding.setOrbProperties(jndiProperties);
135             }
136 
137             tempEl = DOMUtils.getNextSiblingElement(tempEl);
138         }
139 
140         return jbi4EjbBinding;
141     }
142 }