001: /**
002: * JOnAS : Java(TM) OpenSource Application Server
003: * Copyright (C) 2005 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: JOnASTypeWriter.java 6860 2005-05-27 15:01:25Z sauthieg $
023: * --------------------------------------------------------------------------
024: */package org.objectweb.jonas_ws.wsgen.generator.ews.wsdltoj2ee.writer;
025:
026: import java.io.IOException;
027: import java.util.Vector;
028:
029: import javax.xml.namespace.QName;
030:
031: import org.w3c.dom.Node;
032:
033: import org.apache.axis.wsdl.gen.Generator;
034: import org.apache.axis.wsdl.symbolTable.SchemaUtils;
035: import org.apache.axis.wsdl.symbolTable.SymbolTable;
036: import org.apache.axis.wsdl.symbolTable.Type;
037: import org.apache.axis.wsdl.symbolTable.TypeEntry;
038: import org.apache.axis.wsdl.toJava.Emitter;
039: import org.apache.axis.wsdl.toJava.JavaGeneratorFactory;
040: import org.apache.axis.wsdl.toJava.JavaTypeWriter;
041: import org.apache.axis.wsdl.toJava.Utils;
042:
043: /**
044: * This is Wsdl2java's Type Writer. It writes the following files, as appropriate:
045: * <typeName>.java, <typeName>Holder.java.
046: */
047: public class JOnASTypeWriter extends JavaTypeWriter implements
048: Generator {
049:
050: /** Field typeWriter */
051: private Generator jonasTypeWriter = null;
052:
053: /**
054: * Constructor.
055: *
056: * @param emitter the Emitter
057: * @param type Type to be generated
058: * @param symbolTable SymbolTable containing mapping informations
059: */
060: public JOnASTypeWriter(Emitter emitter, TypeEntry type,
061: SymbolTable symbolTable) {
062: super (emitter, type, symbolTable);
063: if (type.isReferenced() && !type.isOnlyLiteralReferenced()
064: && type instanceof Type) {
065:
066: // Determine what sort of type this is and instantiate
067: // the appropriate Writer.
068: Node node = type.getNode();
069:
070: boolean isSimpleList = SchemaUtils.isListWithItemType(node);
071: // If it's an array, don't emit a class
072: if (!type.getName().endsWith("[]") && !isSimpleList) {
073:
074: // Generate the proper class for either "complex" or "enumeration" types
075: Vector v = Utils.getEnumerationBaseAndValues(node,
076: symbolTable);
077:
078: if (v == null) {
079: // that's not an enumeration
080: TypeEntry base = SchemaUtils
081: .getComplexElementExtensionBase(node,
082: symbolTable);
083:
084: if (base == null) {
085: base = SchemaUtils
086: .getComplexElementRestrictionBase(node,
087: symbolTable);
088: }
089:
090: if (base == null) {
091: QName baseQName = SchemaUtils
092: .getSimpleTypeBase(node);
093:
094: if (baseQName != null) {
095: base = symbolTable.getType(baseQName);
096: }
097: }
098: Vector elements = type.getContainedElements();
099: Vector attributes = type.getContainedAttributes();
100:
101: // If this complexType is referenced in a
102: // fault context, emit a bean-like exception
103: // class
104: Boolean isComplexFault = (Boolean) type
105: .getDynamicVar(JavaGeneratorFactory.COMPLEX_TYPE_FAULT);
106:
107: if ((isComplexFault != null)
108: && isComplexFault.booleanValue()) {
109:
110: jonasTypeWriter = getBeanHelperWriter(emitter,
111: type, elements, base, attributes, true);
112: } else {
113: jonasTypeWriter = getBeanHelperWriter(emitter,
114: type, elements, base, attributes, false);
115: }
116: }
117: }
118: }
119: } // ctor
120:
121: /**
122: * Write all the service bindnigs: service and testcase.
123: *
124: * @throws IOException if generation of Helper fails
125: */
126: public void generate() throws IOException {
127:
128: if (jonasTypeWriter != null) {
129: jonasTypeWriter.generate();
130: }
131: }
132:
133: } // class JavaTypeWriter
|