View Javadoc

1   /*
2    * Copyright 2001-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  package org.apache.geronimo.ews.jaxrpcmapping;
18  
19  import org.apache.axis.wsdl.symbolTable.TypeEntry;
20  import org.apache.axis.wsdl.toJava.JavaWriter;
21  
22  import java.io.IOException;
23  import java.io.PrintWriter;
24  import java.util.Vector;
25  
26  /***
27   * This is Wsdl2java's Complex Fault Writer.
28   * It generates bean-like class for complexTypes used
29   * in a operation fault message.
30   *
31   * @author Ias (iasandcb@tmax.co.kr)
32   * @deprecated no more used by J2eeGeneratorFactory
33   */
34  public class J2eeBeanFaultWriter extends J2eeBeanWriter {
35      /***
36       * Constructor.
37       *
38       * @param emitter
39       * @param type       The type representing this class
40       * @param elements   Vector containing the Type and name of each property
41       * @param extendType The type representing the extended class (or null)
42       * @param attributes Vector containing the attribute types and names
43       * @param helper     Helper class writer
44       */
45      protected J2eeBeanFaultWriter(J2eeEmitter emitter,
46                                    TypeEntry type,
47                                    Vector elements,
48                                    TypeEntry extendType,
49                                    Vector attributes,
50                                    JavaWriter helper) {
51          super(emitter, type, elements,
52                  extendType, attributes, helper);
53  
54          // The Default Constructor is not JSR 101 v1.0 compliant, but
55          // is the only way that Axis can get something back over the wire.
56          // This will need to be changed when fault contents are supported
57          // over the wire.
58          enableDefaultConstructor = true;
59  
60          // JSR 101 v1.0 requires a full constructor
61          enableFullConstructor = true;
62  
63          // JSR 101 v1.0 does not support write access methods
64          enableSetters = true;
65      } // ctor
66  
67      /***
68       * Returns the appropriate extends text
69       *
70       * @return "" or " extends <class> "
71       */
72      protected String getExtendsText() {
73          // See if this class extends another class
74          String extendsText = super.getExtendsText();
75          if (extendsText.equals("")) {
76              // JSR 101 compliant code should extend java.lang.Exception!
77              //extendsText = " extends java.lang.Exception ";
78              extendsText = " extends org.apache.axis.AxisFault ";
79          }
80          return extendsText;
81      }
82  
83      /***
84       * Write the Exception serialization code
85       * NOTE: This function is written in JavaFaultWriter.java also.
86       */
87      protected void writeFileFooter(PrintWriter pw) throws IOException {
88          // We need to have the Exception class serialize itself
89          // with the correct namespace, which can change depending on which
90          // operation the exception is thrown from.  We therefore have the
91          // framework call this generated routine with the correct QName,
92          // and allow it to serialize itself.
93  
94          // method that serializes this exception (writeDetail)
95          pw.println();
96          pw.println("    /**");
97          pw.println("     * Writes the exception data to the faultDetails");
98          pw.println("     */");
99          pw.println("    public void writeDetails(javax.xml.namespace.QName qname, org.apache.axis.encoding.SerializationContext context) throws java.io.IOException {");
100         pw.println("        context.serialize(qname, null, this);");
101         pw.println("    }");
102         super.writeFileFooter(pw);
103     } // writeFileFooter
104 } // class JavaBeanFaultWriter