Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/myeis/wsdl/extensions/j2c/myeis/MyEISBindingSerializer.java


1   /*
2    * The Apache Software License, Version 1.1
3    *
4    *
5    * Copyright (c) 2002 The Apache Software Foundation.  All rights 
6    * reserved.
7    *
8    * Redistribution and use in source and binary forms, with or without
9    * modification, are permitted provided that the following conditions
10   * are met:
11   *
12   * 1. Redistributions of source code must retain the above copyright
13   *    notice, this list of conditions and the following disclaimer. 
14   *
15   * 2. Redistributions in binary form must reproduce the above copyright
16   *    notice, this list of conditions and the following disclaimer in
17   *    the documentation and/or other materials provided with the
18   *    distribution.
19   *
20   * 3. The end-user documentation included with the redistribution,
21   *    if any, must include the following acknowledgment:  
22   *       "This product includes software developed by the
23   *        Apache Software Foundation (http://www.apache.org/)."
24   *    Alternately, this acknowledgment may appear in the software itself,
25   *    if and wherever such third-party acknowledgments normally appear.
26   *
27   * 4. The names "WSIF" and "Apache Software Foundation" must
28   *    not be used to endorse or promote products derived from this
29   *    software without prior written permission. For written 
30   *    permission, please contact apache@apache.org.
31   *
32   * 5. Products derived from this software may not be called "Apache",
33   *    nor may "Apache" appear in their name, without prior written
34   *    permission of the Apache Software Foundation.
35   *
36   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47   * SUCH DAMAGE.
48   * ====================================================================
49   *
50   * This software consists of voluntary contributions made by many
51   * individuals on behalf of the Apache Software Foundation and was
52   * originally based on software copyright (c) 2001, 2002, International
53   * Business Machines, Inc., http://www.apache.org.  For more
54   * information on the Apache Software Foundation, please see
55   * <http://www.apache.org/>.
56   */
57  
58  package com.myeis.wsdl.extensions.j2c.myeis;
59  
60  import java.io.*;
61  import java.util.*;
62  import javax.wsdl.*;
63  import javax.xml.namespace.*;
64  import javax.wsdl.extensions.*;
65  import com.ibm.wsdl.*;
66  import com.ibm.wsdl.util.xml.*;
67  
68  /**
69   * Insert the type's description here.
70   * Creation date: (5/21/2001 8:48:12 PM)
71   * @author: Administrator
72   */
73  public class MyEISBindingSerializer
74    implements
75      javax.wsdl.extensions.ExtensionDeserializer,
76      javax.wsdl.extensions.ExtensionSerializer,
77      java.io.Serializable {
78    /**
79     * ConnectorBindingSerializer constructor comment.
80     */
81    public MyEISBindingSerializer() {
82      super();
83    }
84  
85    /**
86      * 
87      */
88    public void marshall(
89      Class parentType,
90      javax.xml.namespace.QName extensionType,
91      javax.wsdl.extensions.ExtensibilityElement extension,
92      java.io.PrintWriter pw,
93      javax.wsdl.Definition def,
94      javax.wsdl.extensions.ExtensionRegistry extReg)
95      throws javax.wsdl.WSDLException {
96  
97      if (extension == null)
98        return;
99  
100     //Get the EIS namespace prefix from this definition  
101     String TPrefix = null;
102     Map nameSpaces = def.getNamespaces();
103     Iterator i = nameSpaces.keySet().iterator();
104 
105     while (i.hasNext()) {
106       String prefix = (String) i.next();
107       String namespaceURI = (String) nameSpaces.get(prefix);
108       if (namespaceURI.equals(MyEISBindingConstants.NS_URI)) {
109         TPrefix = prefix;
110         break;
111       }
112     }
113 
114     //Check if the namespace prefix was found. if not thrwo an exception
115     if (TPrefix == null)
116       throw new WSDLException(
117         "001",
118         "The EIS binding namespace was not found in the definition");
119 
120     if (extension instanceof MyEISBinding) {
121       MyEISBinding binding = (MyEISBinding) extension;
122       pw.print("      <" + TPrefix + ":binding");
123 
124       Boolean required = extension.getRequired();
125       if (required != null) {
126         DOMUtils.printQualifiedAttribute(
127           Constants.Q_ATTR_REQUIRED,
128           required.toString(),
129           def,
130           pw);
131       }
132 
133       pw.println("/>");
134     } else
135       if (extension instanceof MyEISOperation) {
136         MyEISOperation operation = (MyEISOperation) extension;
137         pw.print("      <" + TPrefix + ":operation");
138         
139         if (operation.getFunctionName() != null) {
140           DOMUtils.printAttribute("functionName", operation.getFunctionName(), pw);
141         }
142 
143         Boolean required = extension.getRequired();
144         if (required != null) {
145           DOMUtils.printQualifiedAttribute(
146             Constants.Q_ATTR_REQUIRED,
147             required.toString(),
148             def,
149             pw);
150         }
151 
152         pw.println("/>");
153       } else
154         if (extension instanceof MyEISAddress) {
155           MyEISAddress address = (MyEISAddress) extension;
156           pw.print("      <" + TPrefix + ":address");
157 
158           if (address.getRepositoryLocation() != null) {
159             DOMUtils.printAttribute("repositoryLocation", address.getRepositoryLocation(), pw);
160           }
161 
162           Boolean required = extension.getRequired();
163           if (required != null) {
164             DOMUtils.printQualifiedAttribute(
165               Constants.Q_ATTR_REQUIRED,
166               required.toString(),
167               def,
168               pw);
169           }
170           pw.println("/>");
171         }
172   }
173   /**
174    * unmarshall method comment.
175    */
176   public javax.wsdl.extensions.ExtensibilityElement unmarshall(
177     Class parentType,
178     javax.xml.namespace.QName elementType,
179     org.w3c.dom.Element el,
180     javax.wsdl.Definition def,
181     javax.wsdl.extensions.ExtensionRegistry extReg)
182     throws javax.wsdl.WSDLException {
183 
184     javax.wsdl.extensions.ExtensibilityElement returnValue = null;
185 
186     if (MyEISBindingConstants.Q_ELEM_BINDING.equals(elementType)) {
187       MyEISBinding binding = new MyEISBinding();
188 
189       return binding;
190     } else
191       if (MyEISBindingConstants.Q_ELEM_OPERATION.equals(elementType)) {
192         MyEISOperation operation = new MyEISOperation();
193             
194         String functionName = DOMUtils.getAttribute(el, "functionName");
195         if (functionName != null) {
196           operation.setFunctionName(functionName);
197         }
198         return operation;
199       } else
200         if (MyEISBindingConstants.Q_ELEM_ADDRESS.equals(elementType)) {
201           MyEISAddress address = new MyEISAddress();
202 
203           String repositoryLocation = DOMUtils.getAttribute(el, "repositoryLocation");
204           if (repositoryLocation != null) {
205             address.setRepositoryLocation(repositoryLocation);
206           }
207           return address;
208         }
209           
210     return returnValue;
211   }
212 }