KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > wsdl > toJava > Emitter


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 package org.apache.axis.wsdl.toJava;
17
18 import org.apache.axis.Constants;
19 import org.apache.axis.constants.Scope;
20 import org.apache.axis.description.ServiceDesc;
21 import org.apache.axis.encoding.TypeMapping;
22 import org.apache.axis.encoding.TypeMappingRegistryImpl;
23 import org.apache.axis.i18n.Messages;
24 import org.apache.axis.utils.ClassUtils;
25 import org.apache.axis.utils.JavaUtils;
26 import org.apache.axis.wsdl.gen.GeneratorFactory;
27 import org.apache.axis.wsdl.gen.Parser;
28 import org.apache.axis.wsdl.symbolTable.BaseTypeMapping;
29 import org.apache.axis.wsdl.symbolTable.SymTabEntry;
30 import org.apache.axis.wsdl.symbolTable.SymbolTable;
31 import org.w3c.dom.Document JavaDoc;
32 import org.xml.sax.SAXException JavaDoc;
33
34 import javax.wsdl.WSDLException;
35 import javax.xml.namespace.QName JavaDoc;
36 import javax.xml.parsers.ParserConfigurationException JavaDoc;
37
38 import java.io.FileInputStream JavaDoc;
39 import java.io.IOException JavaDoc;
40 import java.lang.reflect.Constructor JavaDoc;
41 import java.util.ArrayList JavaDoc;
42 import java.util.Enumeration JavaDoc;
43 import java.util.HashMap JavaDoc;
44 import java.util.Iterator JavaDoc;
45 import java.util.List JavaDoc;
46 import java.util.Properties JavaDoc;
47 import java.util.Vector JavaDoc;
48
49 /**
50  * This class produces java files for stubs, skeletons, and types from a
51  * WSDL document.
52  *
53  * @author Russell Butek (butek@us.ibm.com)
54  * @author Tom Jordahl (tjordahl@macromedia.com)
55  * @author Rich Scheuerle (scheu@us.ibm.com)
56  * @author Steve Graham (sggraham@us.ibm.com)
57  */

58 public class Emitter extends Parser {
59
60     /** Field DEFAULT_NSTOPKG_FILE */
61     public static final String JavaDoc DEFAULT_NSTOPKG_FILE = "NStoPkg.properties";
62
63     /** Field namespaceMap */
64     protected HashMap JavaDoc namespaceMap = new HashMap JavaDoc();
65
66     /** Field typeMappingVersion */
67     protected String JavaDoc typeMappingVersion = "1.2";
68
69     /** Field baseTypeMapping */
70     protected BaseTypeMapping baseTypeMapping = null;
71
72     /** Field namespaces */
73     protected Namespaces namespaces = null;
74
75     /** Field NStoPkgFilename */
76     protected String JavaDoc NStoPkgFilename = null;
77
78     /** Field bEmitServer */
79     private boolean bEmitServer = false;
80
81     /** Field bDeploySkeleton */
82     private boolean bDeploySkeleton = false;
83
84     /** Field bEmitTestCase */
85     private boolean bEmitTestCase = false;
86
87     /** Field bGenerateAll */
88     private boolean bGenerateAll = false;
89
90     /** Field bHelperGeneration */
91     private boolean bHelperGeneration = false;
92     
93     private boolean bBuildFileGeneration = false;
94
95     private boolean typeCollisionProtection = true;
96
97     /** Check if URL endpoints are valid or not */
98     private boolean allowInvalidURL = false;
99
100     /** Field packageName */
101     private String JavaDoc packageName = null;
102
103     /** Field scope */
104     private Scope scope = null;
105
106     /** Field fileInfo */
107     private GeneratedFileInfo fileInfo = new GeneratedFileInfo();
108
109     /** Field delayedNamespacesMap */
110     private HashMap JavaDoc delayedNamespacesMap = new HashMap JavaDoc();
111
112     /** Field outputDir */
113     private String JavaDoc outputDir = null;
114     
115     /** Field nsIncludes - defines a list of namespaces to specifically
116      * include in the generated source code. If non-empty, anything
117      * not in this list should be excluded. If empty, everything in this
118      * and not specifically excluded should be generated.
119      */

120     protected List JavaDoc nsIncludes = new ArrayList JavaDoc();
121     
122     /** Field nsIncludes - defines a list of namespaces to specifically
123      * exclude from generated source code. Any entry in this list that
124      * is in conflict with the includes list should be ignored and
125      * generated.
126      */

127     protected List JavaDoc nsExcludes = new ArrayList JavaDoc();
128     
129     /** Field properties - defines a set of general purpose properties
130      * that can be used by custom JavaGeneratorFactories.
131      */

132     protected List JavaDoc properties = new ArrayList JavaDoc();
133     
134     /**
135      * Field implementationClassName - defines a non default classname for the actual
136      * implementation class. Particularly useful when exporting a webservice directly
137      * from the java implementation.
138      */

139     private String JavaDoc implementationClassName = null;
140     
141     /** Field defaultTM */
142     private TypeMapping defaultTM = null; // Default TM
143

144     private TypeMappingRegistryImpl tmr = new TypeMappingRegistryImpl();
145     
146     /** The mapping of qname to its corresponding java type generated by Java2Wsdl emitter. For deploy mode roundtripping use. */
147     private HashMap JavaDoc qName2ClassMap;
148     
149     /** The ServiceDesc. For deploy mode roundtripping use. */
150     private ServiceDesc serviceDesc;
151     
152     /** The deploy mode flag */
153     private boolean isDeploy;
154
155     /**
156      * Default constructor.
157      */

158     public Emitter() {
159         setFactory(new JavaGeneratorFactory(this));
160     } // ctor
161

162     // /////////////////////////////////////////////////
163
//
164
// Command line switches
165
//
166

167     /**
168      * Turn on/off server skeleton creation
169      *
170      * @param value
171      */

172     public void setServerSide(boolean value) {
173         this.bEmitServer = value;
174     } // setServerSide
175

176     /**
177      * Indicate if we should be emitting server side code and deploy/undeploy
178      *
179      * @return
180      */

181     public boolean isServerSide() {
182         return bEmitServer;
183     } // isServerSide
184

185     /**
186      * Turn on/off server skeleton deploy
187      *
188      * @param value
189      */

190     public void setSkeletonWanted(boolean value) {
191         bDeploySkeleton = value;
192     } // setSkeletonWanted
193

194     /**
195      * Indicate if we should be deploying skeleton or implementation
196      *
197      * @return
198      */

199     public boolean isSkeletonWanted() {
200         return bDeploySkeleton;
201     } // isSkeletonWanted
202

203     /**
204      * Turn on/off Helper class generation
205      *
206      * @param value
207      */

208     public void setHelperWanted(boolean value) {
209         bHelperGeneration = value;
210     } // setHelperWanted
211

212     /**
213      * Indicate if we should be generating Helper classes
214      *
215      * @return
216      */

217     public boolean isHelperWanted() {
218         return bHelperGeneration;
219     } // isHelperWanted
220

221     /**
222      * Turn on/off test case creation
223      *
224      * @param value
225      */

226     public void setTestCaseWanted(boolean value) {
227         this.bEmitTestCase = value;
228     } // setTestCaseWanted
229

230     /**
231      * Method isTestCaseWanted
232      *
233      * @return
234      */

235     public boolean isTestCaseWanted() {
236         return bEmitTestCase;
237     } // isTestCaseWanted
238

239     /**
240      * get the build file genaeration state
241      * @return
242      */

243     public boolean isBuildFileWanted(){
244         return bBuildFileGeneration;
245     }
246     
247     /**
248      * turn the build file genaration ON
249      * @param value
250      */

251     public void setBuildFileWanted(boolean value){
252         bBuildFileGeneration = value;
253     }
254
255     /**
256      * By default, code is generated only for referenced elements.
257      * Call bGenerateAll(true) and WSDL2Java will generate code for all
258      * elements in the scope regardless of whether they are
259      * referenced. Scope means: by default, all WSDL files; if
260      * generateImports(false), then only the immediate WSDL file.
261      *
262      * @param all
263      */

264     public void setAllWanted(boolean all) {
265         bGenerateAll = all;
266     } // setAllWanted
267

268     /**
269      * Method isAllWanted
270      *
271      * @return
272      */

273     public boolean isAllWanted() {
274         return bGenerateAll;
275     } // isAllWanted
276

277     /**
278      * Method getNamespaces
279      *
280      * @return
281      */

282     public Namespaces getNamespaces() {
283         return namespaces;
284     } // getNamespaces
285

286     /**
287      * Set the output directory to use in emitted source files
288      *
289      * @param outputDir
290      */

291     public void setOutputDir(String JavaDoc outputDir) {
292         this.outputDir = outputDir;
293     }
294
295     /**
296      * Get the output directory to use for emitted source files
297      *
298      * @return
299      */

300     public String JavaDoc getOutputDir() {
301         return outputDir;
302     }
303
304     /**
305      * Get global package name to use instead of mapping namespaces
306      *
307      * @return
308      */

309     public String JavaDoc getPackageName() {
310         return packageName;
311     }
312
313     /**
314      * Set a global package name to use instead of mapping namespaces
315      *
316      * @param packageName
317      */

318     public void setPackageName(String JavaDoc packageName) {
319         this.packageName = packageName;
320     }
321
322     /**
323      * Set the scope for the deploy.xml file.
324      *
325      * @param scope One of 'null',
326      * Scope.APPLICATION, Scope.REQUEST, Scope.SESSION.
327      * Anything else is equivalent to 'null' null and no explicit
328      * scope tag will appear in deploy.xml.
329      */

330     public void setScope(Scope scope) {
331         this.scope = scope;
332     } // setScope
333

334     /**
335      * Get the scope for the deploy.xml file.
336      *
337      * @return
338      */

339     public Scope getScope() {
340         return scope;
341     } // getScope
342

343     /**
344      * Set the NStoPkg mappings filename.
345      *
346      * @param NStoPkgFilename
347      */

348     public void setNStoPkg(String JavaDoc NStoPkgFilename) {
349
350         if (NStoPkgFilename != null) {
351             this.NStoPkgFilename = NStoPkgFilename;
352         }
353     } // setNStoPkg
354

355     /**
356      * Set a map of namespace -> Java package names
357      *
358      * @param map
359      */

360     public void setNamespaceMap(HashMap JavaDoc map) {
361         delayedNamespacesMap = map;
362     }
363
364     /**
365      * Get the map of namespace -> Java package names
366      *
367      * @return
368      */

369     public HashMap JavaDoc getNamespaceMap() {
370         return delayedNamespacesMap;
371     }
372     
373     /** Sets the list of namespaces to specifically include
374      * in the generated code.
375      */

376     public void setNamespaceIncludes(List JavaDoc nsIncludes) {
377         this.nsIncludes = nsIncludes;
378     }
379
380     /** Returns the list of namespaces specifically excluded
381      * from the generated code.
382      */

383     public List JavaDoc getNamespaceIncludes() {
384         return this.nsIncludes;
385     }
386     
387     /** Sets the list of namespaces to specifically exclude
388      * from the generated source.
389      */

390     public void setNamespaceExcludes(List JavaDoc nsExcludes) {
391         this.nsExcludes = nsExcludes;
392     }
393     
394     /** Returns the list of excludes to specifically exclude
395      * from the generated source.
396      */

397     public List JavaDoc getNamespaceExcludes() {
398         return this.nsExcludes;
399     }
400     
401     /** Sets the list of extension properties for custom
402      * JavaGeneratorFactories.
403      */

404     public void setProperties(List JavaDoc properties) {
405         this.properties = properties;
406     }
407     
408     /** Gets the list of extension properties for custom
409      * JavaGeneratorFactories.
410      */

411     public List JavaDoc getProperties() {
412         return this.properties;
413     }
414
415     /**
416      * Returns the default <code>TypeMapping</code> used by the service
417      *
418      * @return the default <code>TypeMapping</code> used by the service
419      */

420     public TypeMapping getDefaultTypeMapping() {
421         if (defaultTM == null) {
422             defaultTM =
423                     (TypeMapping)tmr.getTypeMapping(Constants.URI_SOAP11_ENC);
424         }
425         return defaultTM;
426     }
427
428     /**
429      * Sets the default <code>TypeMapping</code> used by the service
430      *
431      * @param defaultTM the default <code>TypeMapping</code> used by the service
432      */

433     public void setDefaultTypeMapping(TypeMapping defaultTM) {
434         this.defaultTM = defaultTM;
435     }
436     
437     /**
438      * Sets the <code>WriterFactory Class</code> to use
439      *
440      * @param factory the name of the factory <code>Class</code>
441      */

442     public void setFactory(String JavaDoc factory) {
443
444         try {
445             Class JavaDoc clazz = ClassUtils.forName(factory);
446             GeneratorFactory genFac;
447             try {
448                 Constructor JavaDoc ctor = clazz.getConstructor(new Class JavaDoc[]{
449                     getClass()});
450
451                 genFac = (GeneratorFactory) ctor.newInstance(new Object JavaDoc[]{
452                     this});
453             } catch (NoSuchMethodException JavaDoc ex) {
454                 genFac = (GeneratorFactory) clazz.newInstance();
455             }
456
457             setFactory(genFac);
458         } catch (Exception JavaDoc ex) {
459             ex.printStackTrace();
460         }
461     } // setFactory
462

463     //
464
// Command line switches
465
//
466
// /////////////////////////////////////////////////
467

468     /**
469      * Returns an object which contains of information on all generated files
470      * including the class name, filename and a type string.
471      *
472      * @return An org.apache.axis.wsdl.toJava.GeneratedFileInfo object
473      * @see org.apache.axis.wsdl.toJava.GeneratedFileInfo
474      */

475     public GeneratedFileInfo getGeneratedFileInfo() {
476         return fileInfo;
477     }
478
479     /**
480      * This method returns a list of all generated class names.
481      *
482      * @return
483      */

484     public List JavaDoc getGeneratedClassNames() {
485         return fileInfo.getClassNames();
486     }
487
488     /**
489      * This method returns a list of all generated file names.
490      *
491      * @return
492      */

493     public List JavaDoc getGeneratedFileNames() {
494         return fileInfo.getFileNames();
495     }
496
497     /**
498      * Get the Package name for the specified namespace
499      *
500      * @param namespace
501      * @return
502      */

503     public String JavaDoc getPackage(String JavaDoc namespace) {
504         return namespaces.getCreate(namespace);
505     }
506
507     /**
508      * Get the Package name for the specified QName
509      *
510      * @param qName
511      * @return
512      */

513     public String JavaDoc getPackage(QName JavaDoc qName) {
514         return getPackage(qName.getNamespaceURI());
515     }
516
517     /**
518      * Convert the specified QName into a full Java Name.
519      *
520      * @param qName
521      * @return
522      */

523     public String JavaDoc getJavaName(QName JavaDoc qName) {
524
525         // If this is one of our special 'collection' qnames.
526
// get the element type and append []
527
if (qName.getLocalPart().indexOf("[") > 0) {
528             String JavaDoc localPart = qName.getLocalPart().substring(0,
529                     qName.getLocalPart().indexOf("["));
530             QName JavaDoc eQName = new QName JavaDoc(qName.getNamespaceURI(), localPart);
531
532             return getJavaName(eQName) + "[]";
533         }
534
535         // Handle the special "java" namespace for types
536
if (qName.getNamespaceURI().equalsIgnoreCase("java")) {
537             return qName.getLocalPart();
538         }
539
540         // The QName may represent a base java name, so check this first
541
String JavaDoc fullJavaName =
542                 getFactory().getBaseTypeMapping().getBaseName(qName);
543
544         if (fullJavaName != null) {
545             return fullJavaName;
546         }
547
548         fullJavaName = getJavaNameHook(qName);
549         if (fullJavaName != null) {
550             return fullJavaName;
551         }
552         // Use the namespace uri to get the appropriate package
553
String JavaDoc pkg = getPackage(qName.getNamespaceURI());
554
555         if (pkg != null && pkg.length() > 0) {
556             fullJavaName = pkg + "."
557                     + Utils.xmlNameToJavaClass(qName.getLocalPart());
558         } else {
559             fullJavaName = Utils.xmlNameToJavaClass(qName.getLocalPart());
560         }
561
562         return fullJavaName;
563     } // getJavaName
564

565     protected String JavaDoc getJavaNameHook(QName JavaDoc qname) { return null; }
566     
567     
568     /**
569      * @param typeQName QName for containing xml type
570      * @param xmlName QName for element
571      * @return
572      */

573     public String JavaDoc getJavaVariableName(QName JavaDoc typeQName, QName JavaDoc xmlName, boolean isElement) {
574         String JavaDoc javaName = getJavaVariableNameHook(typeQName, xmlName, isElement);
575         if (javaName == null) {
576             String JavaDoc elemName = Utils.getLastLocalPart(xmlName.getLocalPart());
577             javaName = Utils.xmlNameToJava(elemName);
578         }
579         return javaName;
580     }
581         
582     protected String JavaDoc getJavaVariableNameHook(QName JavaDoc typeQName, QName JavaDoc xmlName, boolean isElement) {
583         return null;
584     }
585         
586     
587
588     /**
589      * Emit appropriate Java files for a WSDL at a given URL.
590      * <p/>
591      * This method will time out after the number of milliseconds specified
592      * by our timeoutms member.
593      *
594      * @param wsdlURL
595      * @throws Exception
596      */

597     public void run(String JavaDoc wsdlURL) throws Exception JavaDoc {
598         setup();
599         super.run(wsdlURL);
600     } // run
601

602     /**
603      * Call this method if your WSDL document has already been
604      * parsed as an XML DOM document.
605      *
606      * @param context context This is directory context for the Document.
607      * If the Document were from file "/x/y/z.wsdl" then the context
608      * could be "/x/y" (even "/x/y/z.wsdl" would work).
609      * If context is null, then the context becomes the current directory.
610      * @param doc doc This is the XML Document containing the WSDL.
611      * @throws IOException
612      * @throws SAXException
613      * @throws WSDLException
614      * @throws ParserConfigurationException
615      */

616     public void run(String JavaDoc context, Document JavaDoc doc)
617             throws IOException JavaDoc, SAXException JavaDoc, WSDLException,
618             ParserConfigurationException JavaDoc {
619         setup();
620         super.run(context, doc);
621     } // run
622

623     /**
624      * Method setup
625      *
626      * @throws IOException
627      */

628     private void setup() throws IOException JavaDoc {
629
630         if (baseTypeMapping == null) {
631             setTypeMappingVersion(typeMappingVersion);
632         }
633
634         getFactory().setBaseTypeMapping(baseTypeMapping);
635
636         namespaces = new Namespaces(outputDir);
637
638         if (packageName != null) {
639             namespaces.setDefaultPackage(packageName);
640         } else {
641
642             // First, read the namespace mapping file - configurable, by default
643
// NStoPkg.properties - if it exists, and load the namespaceMap HashMap
644
// with its data.
645
getNStoPkgFromPropsFile(namespaces);
646
647             if (delayedNamespacesMap != null) {
648                 namespaces.putAll(delayedNamespacesMap);
649             }
650         }
651     } // setup
652

653     /**
654      * Method sanityCheck
655      *
656      * @param symbolTable
657      */

658     protected void sanityCheck(SymbolTable symbolTable) {
659
660         Iterator JavaDoc it = symbolTable.getHashMap().values().iterator();
661
662         while (it.hasNext()) {
663             Vector JavaDoc v = (Vector JavaDoc) it.next();
664
665             for (int i = 0; i < v.size(); ++i) {
666                 SymTabEntry entry = (SymTabEntry) v.elementAt(i);
667                 String JavaDoc namespace = entry.getQName().getNamespaceURI();
668                 String JavaDoc packageName =
669                         org.apache.axis.wsdl.toJava.Utils.makePackageName(
670                                 namespace);
671                 String JavaDoc localName = entry.getQName().getLocalPart();
672
673                 if (localName.equals(packageName)
674                         && packageName.equals(
675                                 namespaces.getCreate(namespace))) {
676                     packageName += "_pkg";
677
678                     namespaces.put(namespace, packageName);
679                 }
680             }
681         }
682     }
683
684     /**
685      * Tries to load the namespace-to-package mapping file.
686      * <ol>
687      * <li>if a file name is explicitly set using <code>setNStoPkg()</code>, tries
688      * to load the mapping from this file. If this fails, the built-in default
689      * mapping is used.
690      * <p/>
691      * <li>if no file name is set, tries to load the file <code>DEFAULT_NSTOPKG_FILE</code>
692      * as a java resource. If this fails, the built-in dfault mapping is used.
693      * </ol>
694      *
695      * @param namespaces a hashmap which is filled with the namespace-to-package mapping
696      * in this method
697      * @throws IOException
698      * @see #setNStoPkg(String)
699      * @see #DEFAULT_NSTOPKG_FILE
700      * @see org.apache.axis.utils.ClassUtils#getResourceAsStream(java.lang.Class,String)
701      */

702     private void getNStoPkgFromPropsFile(HashMap JavaDoc namespaces)
703             throws IOException JavaDoc {
704
705         Properties JavaDoc mappings = new Properties JavaDoc();
706
707         if (NStoPkgFilename != null) {
708             try {
709                 mappings.load(new FileInputStream JavaDoc(NStoPkgFilename));
710
711                 if (verbose) {
712                     System.out.println(
713                             Messages.getMessage(
714                                     "nsToPkgFileLoaded00", NStoPkgFilename));
715                 }
716             } catch (Throwable JavaDoc t) {
717
718                 // loading the custom mapping file failed. We do not try
719
// to load the mapping from a default mapping file.
720
throw new IOException JavaDoc(
721                         Messages.getMessage(
722                                 "nsToPkgFileNotFound00", NStoPkgFilename));
723             }
724         } else {
725             try {
726                 mappings.load(new FileInputStream JavaDoc(DEFAULT_NSTOPKG_FILE));
727
728                 if (verbose) {
729                     System.out.println(
730                             Messages.getMessage(
731                                     "nsToPkgFileLoaded00", DEFAULT_NSTOPKG_FILE));
732                 }
733             } catch (Throwable JavaDoc t) {
734                 try {
735                     mappings.load(ClassUtils.getResourceAsStream(Emitter.class,
736                             DEFAULT_NSTOPKG_FILE));
737
738                     if (verbose) {
739                         System.out.println(
740                                 Messages.getMessage(
741                                         "nsToPkgDefaultFileLoaded00",
742                                         DEFAULT_NSTOPKG_FILE));
743                     }
744                 } catch (Throwable JavaDoc t1) {
745
746                     // loading the default mapping file failed.
747
// The built-in default mapping is used
748
// No message is given, since this is generally what happens
749
}
750             }
751         }
752
753         Enumeration JavaDoc keys = mappings.propertyNames();
754
755         while (keys.hasMoreElements()) {
756             String JavaDoc key = (String JavaDoc) keys.nextElement();
757
758             namespaces.put(key, mappings.getProperty(key));
759         }
760     } // getNStoPkgFromPropsFile
761

762     /**
763      * Get the typemapping version
764      */

765     public String JavaDoc getTypeMappingVersion() {
766         return typeMappingVersion;
767     }
768     
769     /**
770      * Method setTypeMappingVersion
771      *
772      * @param typeMappingVersion
773      */

774     public void setTypeMappingVersion(String JavaDoc typeMappingVersion) {
775         this.typeMappingVersion = typeMappingVersion;
776         tmr.doRegisterFromVersion(typeMappingVersion);
777         baseTypeMapping = new BaseTypeMapping() {
778
779             final TypeMapping defaultTM = getDefaultTypeMapping();
780
781             public String JavaDoc getBaseName(QName JavaDoc qNameIn) {
782
783                 javax.xml.namespace.QName JavaDoc qName =
784                         new javax.xml.namespace.QName JavaDoc(qNameIn.getNamespaceURI(),
785                                 qNameIn.getLocalPart());
786                 Class JavaDoc cls =
787                         defaultTM.getClassForQName(qName);
788
789                 if (cls == null) {
790                     return null;
791                 } else {
792                     return JavaUtils.getTextClassName(cls.getName());
793                 }
794             }
795         };
796     }
797
798     // The remainder are deprecated methods.
799

800     /**
801      * Get the GeneratorFactory.
802      *
803      * @return
804      * @deprecated Call getFactory instead. This doesn't return
805      * a WriterFactory, it returns a GeneratorFactory.
806      */

807     public GeneratorFactory getWriterFactory() {
808         return getFactory();
809     } // getWriterFactory
810

811     /**
812      * Call this method if you have a uri for the WSDL document
813      *
814      * @param uri wsdlURI the location of the WSDL file.
815      * @throws Exception
816      * @deprecated Call run(uri) instead.
817      */

818     public void emit(String JavaDoc uri) throws Exception JavaDoc {
819         run(uri);
820     } // emit
821

822     /**
823      * Call this method if your WSDL document has already been
824      * parsed as an XML DOM document.
825      *
826      * @param context context This is directory context for the Document.
827      * If the Document were from file "/x/y/z.wsdl" then the context could be "/x/y"
828      * (even "/x/y/z.wsdl" would work). If context is null, then the context
829      * becomes the current directory.
830      * @param doc doc This is the XML Document containing the WSDL.
831      * @throws IOException
832      * @throws SAXException
833      * @throws WSDLException
834      * @throws ParserConfigurationException
835      * @deprecated Call run(context, doc) instead.
836      */

837     public void emit(String JavaDoc context, Document JavaDoc doc)
838             throws IOException JavaDoc, SAXException JavaDoc, WSDLException,
839             ParserConfigurationException JavaDoc {
840         run(context, doc);
841     } // emit
842

843     /**
844      * Turn on/off server-side binding generation
845      *
846      * @param value
847      * @deprecated Use setServerSide(value)
848      */

849     public void generateServerSide(boolean value) {
850         setServerSide(value);
851     }
852
853     /**
854      * Indicate if we should be emitting server side code and deploy/undeploy
855      *
856      * @return
857      * @deprecated Use isServerSide()
858      */

859     public boolean getGenerateServerSide() {
860         return isServerSide();
861     }
862
863     /**
864      * Turn on/off server skeleton deploy
865      *
866      * @param value
867      * @deprecated Use setSkeletonWanted(value)
868      */

869     public void deploySkeleton(boolean value) {
870         setSkeletonWanted(value);
871     }
872
873     /**
874      * Indicate if we should be deploying skeleton or implementation
875      *
876      * @return
877      * @deprecated Use isSkeletonWanted()
878      */

879     public boolean getDeploySkeleton() {
880         return isSkeletonWanted();
881     }
882
883     /**
884      * Turn on/off Helper class generation
885      *
886      * @param value
887      * @deprecated Use setHelperWanted(value)
888      */

889     public void setHelperGeneration(boolean value) {
890         setHelperWanted(value);
891     }
892
893     /**
894      * Indicate if we should be generating Helper classes
895      *
896      * @return
897      * @deprecated Use isHelperWanted()
898      */

899     public boolean getHelperGeneration() {
900         return isHelperWanted();
901     }
902
903     /**
904      * Turn on/off generation of elements from imported files.
905      *
906      * @param generateImports
907      * @deprecated Use setImports(generateImports)
908      */

909     public void generateImports(boolean generateImports) {
910         setImports(generateImports);
911     } // generateImports
912

913     /**
914      * Turn on/off debug messages.
915      *
916      * @param value
917      * @deprecated Use setDebug(value)
918      */

919     public void debug(boolean value) {
920         setDebug(value);
921     } // debug
922

923     /**
924      * Return the status of the debug switch.
925      *
926      * @return
927      * @deprecated Use isDebug()
928      */

929     public boolean getDebug() {
930         return isDebug();
931     } // getDebug
932

933     /**
934      * Turn on/off verbose messages
935      *
936      * @param value
937      * @deprecated Use setVerbose(value)
938      */

939     public void verbose(boolean value) {
940         setVerbose(value);
941     }
942
943     /**
944      * Return the status of the verbose switch
945      *
946      * @return
947      * @deprecated Use isVerbose()
948      */

949     public boolean getVerbose() {
950         return isVerbose();
951     }
952
953     /**
954      * Turn on/off test case creation
955      *
956      * @param value
957      * @deprecated Use setTestCaseWanted()
958      */

959     public void generateTestCase(boolean value) {
960         setTestCaseWanted(value);
961     }
962
963     /**
964      * @param all
965      * @deprecated Use setAllWanted(all)
966      */

967     public void generateAll(boolean all) {
968         setAllWanted(all);
969     } // generateAll
970

971     /**
972      * Get the type collision protection setting
973      * @return
974      */

975     public boolean isTypeCollisionProtection(){
976         return this.typeCollisionProtection;
977     }
978     
979     /**
980      * Enable/disable type collision protection
981      * @param value
982      */

983     public void setTypeCollisionProtection(boolean value){
984         this.typeCollisionProtection = value;
985     }
986     
987     /**
988      * Get an implementation classname to use instead of the default.
989      * @return
990      */

991     public String JavaDoc getImplementationClassName() {
992         return implementationClassName;
993     }
994
995     /**
996      * Set an implementation classname to use instead of the default.
997      *
998      * @param implementationClassName
999      */

1000    public void setImplementationClassName(String JavaDoc implementationClassName) {
1001        this.implementationClassName = implementationClassName;
1002    }
1003          
1004    /**
1005     * @return Returns the allowInvalidURL.
1006     */

1007    public boolean isAllowInvalidURL() {
1008        return allowInvalidURL;
1009    }
1010
1011    /**
1012     * @param allowInvalidURL The allowInvalidURL to set.
1013     */

1014    public void setAllowInvalidURL(boolean allowInvalidURL) {
1015        this.allowInvalidURL = allowInvalidURL;
1016    }
1017    
1018    /**
1019     * Set the type qname to java class map
1020     * @param map a type qname to javaclass map (from Java2Wsdl emitter)
1021     */

1022    public void setQName2ClassMap(HashMap JavaDoc map) {
1023        qName2ClassMap = map;
1024    }
1025
1026    /**
1027     * Get the type qname to java class map
1028     * @return the type qname to java class map
1029     */

1030    public HashMap JavaDoc getQName2ClassMap() {
1031        return qName2ClassMap;
1032    }
1033    
1034    /**
1035     * Retruns the SericeDesc object
1036     * @return
1037     */

1038    public ServiceDesc getServiceDesc() {
1039        return serviceDesc;
1040    }
1041    
1042    /**
1043     * Sets the ServicdDesc object
1044     * @param serviceDesc ServiceDesc to set
1045     */

1046    public void setServiceDesc(ServiceDesc serviceDesc) {
1047        this.serviceDesc = serviceDesc;
1048    }
1049    
1050    /**
1051     * Returns the deploy mode flag
1052     * @return
1053     */

1054    public boolean isDeploy() {
1055        return isDeploy;
1056    }
1057    
1058    /**
1059     * Sets the deploy mode flag
1060     * @param isDeploy deploy mode flag
1061     */

1062    public void setDeploy(boolean isDeploy) {
1063        this.isDeploy = isDeploy;
1064    }
1065    
1066    /**
1067     * Check if the className exists.
1068     *
1069     * @param className className to check
1070     * @return true if exists, false if not
1071     */

1072    protected boolean doesExist(String JavaDoc className) {
1073        try {
1074            ClassUtils.forName(className);
1075        } catch (ClassNotFoundException JavaDoc e) {
1076            return false;
1077        }
1078        
1079        return true;
1080    }
1081
1082    public void setWrapArrays(boolean wrapArrays) {
1083        this.wrapArrays = wrapArrays;
1084    }
1085}
1086
Popular Tags