View Javadoc

1   /*
2    * Copyright  1999-2004 The Apache Software Foundation.
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   *
16   */
17  
18  package org.apache.axis.message.addressing;
19  
20  import org.apache.axis.encoding.AnyContentType;
21  import org.apache.axis.message.MessageElement;
22  import org.apache.axis.types.URI;
23  import org.apache.axis.utils.XMLUtils;
24  
25  import java.io.Serializable;
26  
27  /***
28   * Java content class for EndpointReferenceType complex type.
29   * <p>The following schema fragment specifies the expected content contained within this java content object. (defined at http://schemas.xmlsoap.org/ws/2004/08/addressing line 46)
30   * <p>
31   * <pre>
32   * &lt;complexType name="EndpointReferenceType">
33   *   &lt;complexContent>
34   *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
35   *       &lt;sequence>
36   *         &lt;element name="Address" type="{http://schemas.xmlsoap.org/ws/2004/08/addressing}AttributedURI"/>
37   *         &lt;element name="ReferenceProperties" type="{http://schemas.xmlsoap.org/ws/2004/08/addressing}ReferencePropertiesType" minOccurs="0"/>
38   *         &lt;element name="ReferenceParameters" type="{http://schemas.xmlsoap.org/ws/2004/08/addressing}ReferenceParametersType" minOccurs="0"/>
39   *         &lt;element name="PortType" type="{http://schemas.xmlsoap.org/ws/2004/08/addressing}AttributedQName" minOccurs="0"/>
40   *         &lt;element name="ServiceName" type="{http://schemas.xmlsoap.org/ws/2004/08/addressing}ServiceNameType" minOccurs="0"/>
41   *         &lt;any/>
42   *       &lt;/sequence>
43   *     &lt;/restriction>
44   *   &lt;/complexContent>
45   * &lt;/complexType>
46   * </pre>
47   * 
48   * @author Davanum Srinivas (dims@yahoo.com)
49   */
50  public class EndpointReferenceType implements AnyContentType, Serializable {
51      /***
52       * Field address
53       */
54      private AttributedURI address;
55  
56      /***
57       * Field portType
58       */
59      private AttributedQName portType;
60  
61      /***
62       * Field serviceName
63       */
64      private ServiceNameType serviceName;
65  
66      /***
67       * Field properties
68       */
69      private ReferencePropertiesType properties = new ReferencePropertiesType();
70  
71      /***
72       * Field parameters
73       */
74      private ReferenceParametersType parameters = new ReferenceParametersType();
75  
76      /*
77       * Field extensibility elements
78       */
79      private MessageElement [] _any;
80  
81      /***
82       * Constructor EndpointReferenceType
83       */
84      public EndpointReferenceType() {
85      }
86  
87      /***
88       * Constructor EndpointReferenceType
89       * 
90       * @param address 
91       */
92      public EndpointReferenceType(URI address) {
93          this.address = new AttributedURI(address);
94      }
95  
96      /***
97       * Constructor EndpointReferenceType
98       * 
99       * @param address 
100      */
101     public EndpointReferenceType(Address address) {
102         this.address = address;
103     }
104 
105     /***
106      * Constructor EndpointReferenceType (performs shallow copy)
107      * 
108      * @param endpoint 
109      */
110     public EndpointReferenceType(EndpointReferenceType endpoint) {
111         this(endpoint, false);
112     }
113 
114     /***
115      * Constructor EndpointReferenceType
116      * 
117      * @param endpoint 
118      * @param deepCopy
119      */
120     public EndpointReferenceType(EndpointReferenceType endpoint,
121                                  boolean deepCopy) {
122         if (deepCopy) {
123             deepCopy(endpoint);
124         } else {
125             shallowCopy(endpoint);
126         }
127     }
128     
129     private void shallowCopy(EndpointReferenceType endpoint) {
130         setAddress(endpoint.getAddress());
131         setPortType(endpoint.getPortType());
132         setServiceName(endpoint.getServiceName());
133         ReferencePropertiesType properties = endpoint.getProperties();
134         if (properties != null) {
135             setProperties(new ReferencePropertiesType(properties, false));
136         }
137         ReferenceParametersType parameters = endpoint.getParameters();
138         if (parameters != null) {
139             setParameters(new ReferenceParametersType(parameters, false));
140         }
141         // handle extensibility
142         MessageElement [] any = endpoint.get_any();
143         if (any != null && any.length > 0) {
144             MessageElement [] newAny = new MessageElement[any.length];
145             System.arraycopy(any, 0, newAny, 0, any.length);
146             set_any(newAny);
147         }
148     }
149 
150     private void deepCopy(EndpointReferenceType endpoint) {
151         AttributedURI address = endpoint.getAddress();
152         if (address != null) {
153             setAddress(new AttributedURI(address));
154         }
155         AttributedQName port = endpoint.getPortType();
156         if (port != null) {
157             setPortType(new AttributedQName(port));
158         }
159         ServiceNameType serviceName = endpoint.getServiceName();
160         if (serviceName != null) {
161             setServiceName(new ServiceNameType(serviceName));
162         }
163         ReferencePropertiesType properties = endpoint.getProperties();
164         if (properties != null) {
165             setProperties(new ReferencePropertiesType(properties, true));
166         }
167         ReferenceParametersType parameters = endpoint.getParameters();
168         if (parameters != null) {
169             setParameters(new ReferenceParametersType(parameters, true));
170         }
171         // handle extensibility
172         MessageElement elem = null;
173         MessageElement [] any = endpoint.get_any();
174         if (any != null) {
175             MessageElement [] newAny = new MessageElement[any.length];
176             for (int i=0; i<any.length; i++) {
177                 elem = any[i];
178                 try {
179                     newAny[i] = new MessageElement(elem.getAsDOM());
180                 } catch (Exception e) {
181                     // if failed just copy reference
182                     newAny[i] = elem;
183                 }
184             }
185             set_any(newAny);
186         }
187     }
188     
189     /***
190      * Method getAddress
191      * 
192      * @return 
193      */
194     public AttributedURI getAddress() {
195         return address;
196     }
197 
198     /***
199      * Method setAddress
200      * 
201      * @param address 
202      */
203     public void setAddress(AttributedURI address) {
204         this.address = address;
205     }
206 
207     /***
208      * Method getPortType
209      * 
210      * @return 
211      */
212     public AttributedQName getPortType() {
213         return portType;
214     }
215 
216     /***
217      * Method setPortType
218      * 
219      * @param portType 
220      */
221     public void setPortType(AttributedQName portType) {
222         this.portType = portType;
223     }
224 
225     /***
226      * Method getProperties
227      * 
228      * @return 
229      */
230     public ReferencePropertiesType getProperties() {
231         return properties;
232     }
233 
234     /***
235      * Method setProperties
236      * 
237      * @param properties 
238      */
239     public void setProperties(ReferencePropertiesType properties) {
240         this.properties = properties;
241     }
242 
243     /***
244      * Method getParameters
245      * 
246      * @return 
247      */
248     public ReferenceParametersType getParameters() {
249         return parameters;
250     }
251 
252     /***
253      * Method setParameters
254      * 
255      * @param parameters 
256      */
257     public void setParameters(ReferenceParametersType parameters) {
258         this.parameters = parameters;
259     }
260 
261     /***
262      * Method getServiceName
263      * 
264      * @return 
265      */
266     public ServiceNameType getServiceName() {
267         return serviceName;
268     }
269 
270     /***
271      * Method setServiceName
272      * 
273      * @param serviceName 
274      */
275     public void setServiceName(ServiceNameType serviceName) {
276         this.serviceName = serviceName;
277     }
278 
279     /***
280      * Method get_any
281      * @return
282      */
283     public MessageElement[] get_any() {
284         return _any;
285     }
286     
287     /***
288      * Method set_any
289      * @param _any
290      */
291     public void set_any(MessageElement[] _any) {
292         this._any = _any;
293     }
294     
295     public String toString() {
296         StringBuffer buf = new StringBuffer();
297         if (this.address != null) {
298             buf.append("Address: " + this.address);
299             buf.append("\n");
300         }
301         if (this.portType != null) {
302             buf.append("Port Type: " + this.portType);
303             buf.append("\n");
304         }
305         if (this.serviceName != null) {
306             buf.append("Service Name: " + this.serviceName);
307             buf.append("\n");
308             if (this.serviceName.getPort() != null) {
309                 buf.append("Port Name: " + this.serviceName.getPort());
310                 buf.append("\n");
311             }
312         }
313         if (this.properties != null) {
314             buf.append(this.properties);
315         }
316         if (this._any != null) {
317             for (int i=0;i<this._any.length;i++) {
318                 buf.append("Extensibility Element[" + i + "]:\n");
319                 try {
320                     buf.append(XMLUtils.ElementToString(this._any[i].getAsDOM()));
321                 } catch (Exception e) {
322                     buf.append("<error converting: " + e.getMessage() + ">");
323                 }
324                 buf.append("\n");
325             }
326         }
327         return buf.toString();
328     }
329 
330     // Axis bits to serialize/deserialize the fields correctly
331     
332     // Type metadata
333     private static org.apache.axis.description.TypeDesc typeDesc =
334         new org.apache.axis.description.TypeDesc(EndpointReferenceType.class, true);
335 
336     static {
337         typeDesc.setXmlType(new javax.xml.namespace.QName(Constants.NS_URI_ADDRESSING_DEFAULT, "EndpointReferenceType"));
338         org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
339         elemField.setFieldName("address");
340         elemField.setXmlName(new javax.xml.namespace.QName(Constants.NS_URI_ADDRESSING_DEFAULT, "Address"));
341         elemField.setXmlType(new javax.xml.namespace.QName(Constants.NS_URI_ADDRESSING_DEFAULT, "AttributedURI"));
342         typeDesc.addFieldDesc(elemField);
343         elemField = new org.apache.axis.description.ElementDesc();
344         elemField.setFieldName("properties");
345         elemField.setXmlName(new javax.xml.namespace.QName(Constants.NS_URI_ADDRESSING_DEFAULT, "ReferenceProperties"));
346         elemField.setXmlType(new javax.xml.namespace.QName(Constants.NS_URI_ADDRESSING_DEFAULT, "ReferencePropertiesType"));
347         elemField.setMinOccurs(0);
348         typeDesc.addFieldDesc(elemField);
349         elemField = new org.apache.axis.description.ElementDesc();
350         elemField.setFieldName("parameters");
351         elemField.setXmlName(new javax.xml.namespace.QName(Constants.NS_URI_ADDRESSING_DEFAULT, "ReferenceParameters"));
352         elemField.setXmlType(new javax.xml.namespace.QName(Constants.NS_URI_ADDRESSING_DEFAULT, "ReferenceParametersType"));
353         elemField.setMinOccurs(0);
354         typeDesc.addFieldDesc(elemField);
355         elemField = new org.apache.axis.description.ElementDesc();
356         elemField.setFieldName("portType");
357         elemField.setXmlName(new javax.xml.namespace.QName(Constants.NS_URI_ADDRESSING_DEFAULT, "PortType"));
358         elemField.setXmlType(new javax.xml.namespace.QName(Constants.NS_URI_ADDRESSING_DEFAULT, "AttributedQName"));
359         elemField.setMinOccurs(0);
360         typeDesc.addFieldDesc(elemField);
361         elemField = new org.apache.axis.description.ElementDesc();
362         elemField.setFieldName("serviceName");
363         elemField.setXmlName(new javax.xml.namespace.QName(Constants.NS_URI_ADDRESSING_DEFAULT, "ServiceName"));
364         elemField.setXmlType(new javax.xml.namespace.QName(Constants.NS_URI_ADDRESSING_DEFAULT, "ServiceNameType"));
365         elemField.setMinOccurs(0);
366         typeDesc.addFieldDesc(elemField);
367     }
368 
369     /***
370      * Return type metadata object
371      */
372     public static org.apache.axis.description.TypeDesc getTypeDesc() {
373         return typeDesc;
374     }
375 
376 
377     /***
378      * Get Custom Serializer
379      */
380     public static org.apache.axis.encoding.Serializer getSerializer(
381            java.lang.String mechType, 
382            java.lang.Class _javaType,  
383            javax.xml.namespace.QName _xmlType) {
384         return 
385           new  org.apache.axis.encoding.ser.BeanSerializer(
386             _javaType, _xmlType, typeDesc);
387     }
388 
389     /***
390      * Get Custom Deserializer
391      */
392     public static org.apache.axis.encoding.Deserializer getDeserializer(
393            java.lang.String mechType, 
394            java.lang.Class _javaType,  
395            javax.xml.namespace.QName _xmlType) {
396         return 
397           new  org.apache.axis.encoding.ser.BeanDeserializer(
398             _javaType, _xmlType, typeDesc);
399     }
400 }
401 
402