Debian Codegraph @

docs/integration-guide.html

raw
1 <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5 <title>Axis System Integration Guide</title>
6 <link href="axis.css" rel=stylesheet type=text/css>
7 </head>
8 <body text="#000000" bgcolor="#FFFFFF">
9
10 <center>
11 <h1>
12 <img SRC="images/axis.jpg" height=96 width=176></h1></center>
13
14 <h1>
15 Axis System Integration Guide</h1>
16 <i>1.2 Version</i>
17 <br><i>Feedback: <a href="mailto:[email protected]">[email protected]</a></i>
18 <h3>
19 Table of Contents</h3>
20 <a href="#Introduction">Introduction</a>
21 <br><a href="#Pluggable APIs">Pluggable APIs</a>
22 <br>&nbsp; <a href="#Components">Components</a>
23 <!-- <br>&nbsp; <a href="#System Management Plug">System Management</a>
24 -->
25 <br>&nbsp; <a href="#Logging/Tracing Plug">Logging/Tracing</a>
26 <br>&nbsp; <a href="#Configuration Plug">Configuration</a>
27 <br>&nbsp; <a href="#Handlers Plug">Handlers</a>
28 <br>&nbsp; <a href="#Internationalization Plug">Internationalization</a>
29 <br>&nbsp; <a href="#Performance Monitoring Plug">Performance Monitoring</a>
30 <br>&nbsp; <a href="#Encoding Plug">Encoding</a>
31 <br>&nbsp; <a href="#WSDL plug">WSDL Parser and Code Generator Framework</a>
32 <br><a href="#Client SSL">Client SSL</a>
33
34 <h2>
35 <a NAME="Introduction"></a>Introduction</h2>
36 The primary purpose of this guide is
37 to present how Axis can be integrated into an existing web application
38 server, such as Tomcat or WebSphere, for example.&nbsp; Axis has a number
39 of Pluggable APIs that are necessary for such an integration.
40 <p>
41 The reader may find useful background information in the
42 <a href="architecture-guide.html">Architecture Guide</a>.
43
44 <h2>
45 <a NAME="Pluggable APIs"></a>Pluggable APIs</h2>
46 The following are the points that are pluggable in order to integrate Axis
47 into a web application server.
48 The first subsection details a number of pluggable components in general.
49 More details are provided for other components in the remaining
50 subsections.
51
52 <h3>
53 <a NAME="Components"></a>Components</h3>
54 This section describes in general how to plug specializations
55 of various components into Axis.
56
57 <h4>
58 General Strategy
59 </h4>
60 To override the default behavior for a pluggable component:
61 <ul>
62 <li>Develop implementation of components interface</li>
63 <br>&nbsp;
64 <li>Define the implementation class to Axis by either creating
65 a service definition file (prefered)
66 or by setting a system property.
67 <ul>
68 <br>
69 <li><strong>PREFERED:</strong> To create a service definition file:</li>
70 <ul>
71 <li>The name of the service definition file is derived from the interface
72 or abstract class which the service implements/extends:
73 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
74 <code>/META-INF/services/&lt;componentPackage&gt;.&lt;interfaceName&gt;</code>.</li>
75 <li>Put the fully qualified class name of the implementation class on a line by itself
76 in the service definition file.</li>
77 </ul>
78 <br>
79 <li>Set system property:
80 <ul>
81 <li>The name of the system property is the name of the interface.</li>
82 <li>The value of the system property is the name of the implementation.</li>
83 <li>The optional system property name (in table, below) may be also be used.</li>
84 <br>&nbsp;
85 <li>Setting a system property is not prefered, particularly in a J2EE or other application
86 hosting environment, because it imposes a directive across all applications.
87 This may or may not be appropriate behavior.
88 If it is to be done, it should never be done from within a Web Application at runtime.
89 </li>
90 </ul>
91 </li>
92 </ul>
93 <br>
94 <li>Package the implementation class and, if used,
95 the service definition file in a JAR file
96 and/or place it where it can be picked up by a class loader (CLASSPATH).</li>
97 </ul>
98
99 <h4>
100 Example 1
101 </h4>
102 To override the default behavior for the Java Compiler:
103 <ul>
104 <li>An implementation of the <code>Compiler</code> interface is already provided for the <code>Jikes</code> compiler.</li>
105 <br>&nbsp;
106 <li>Create the service definition file named:
107 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
108 <code>/META-INF/services/org.apache.axis.components.compiler.Compiler</code></li>
109 <br>&nbsp;
110 <li>Add the following line to the service definition file:
111 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
112 <code>org.apache.axis.components.compiler.Jikes</code></li>
113 <br>&nbsp;
114 <li>Since <code>org.apache.axis.components.compiler.Jikes</code>
115 is packaged with Axis, all that needs to be done is to ensure
116 that the service definition file is loadable by a class loader.
117 </li>
118 </ul>
119
120 <h4>
121 Example 2
122 </h4>
123 To override the default behavior for the SocketFactory
124 in an environment that does not allow resources to be
125 located/loaded appropriately, or where the behavior
126 needs to be forced to a specific implementation:
127 <ul>
128 <li>Provide an implementation of the <code>SocketFactory</code> interface,
129 for example <code>your.package.YourSocketFactory</code></li>
130 <br>&nbsp;
131 <li>Set the system property named
132 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
133 <code>org.apache.axis.components.net.SocketFactory</code>
134 <br>
135 to the value
136 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
137 <code>your.package.YourSocketFactory</code>
138 <br>
139 <p>This can be done by using the JVM commandline
140 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
141 <code>-Dorg.apache.axis.components.net.SocketFactory=your.package.YourSocketFactory</code>
142 <br>&nbsp;
143 </li>
144 <li>Ensure that the implementation class is loadable by a class loader.
145 </li>
146 </ul>
147
148 <h4>
149 Reference
150 </h4>
151
152 <table border="1">
153 <tr>
154 <th>Component/Package</th>
155 <th>Factory</th>
156 <th>Interface</th>
157 <th>Optional System Property</th>
158 <th>Default Implementation</th>
159 </tr>
160 <tr>
161 <td><code>org.apache.axis.components.compiler</code></td>
162 <td><code>CompilerFactory.getCompiler()</code></td>
163 <td><code>Compiler</code></td>
164 <td><code>axis.Compiler</code></td>
165 <td><code>Javac</code></td>
166 </tr>
167 <tr>
168 <td><code>org.apache.axis.components.image</code></td>
169 <td><code>ImageIOFactory.getImageIO()</code></td>
170 <td><code>ImageIO</code></td>
171 <td><code>axis.ImageIO</code></td>
172 <td><code>MerlinIO, JimiIO, JDK13IO</code></td>
173 </tr>
174 <tr>
175 <td><code>org.apache.axis.components.jms</code></td>
176 <td><code>JMSVendorAdapterFactory.getJMSVendorAdapter()</code></td>
177 <td><code>JMSVendorAdapter</code></td>
178 <td><code></code></td>
179 <td><code>JNDIVendorAdapter</code></td>
180 </tr>
181 <tr>
182 <td><code>org.apache.axis.components.net</code></td>
183 <td><code>SocketFactoryFactory.getFactory()</code></td>
184 <td><code>SocketFactory</code></td>
185 <td><code>axis.socketFactory</code></td>
186 <td><code>DefaultSocketFactory</code></td>
187 </tr>
188 <tr>
189 <td><code>org.apache.axis.components.net</code></td>
190 <td><code>SocketFactoryFactory.getSecureFactory()</code></td>
191 <td><code>SecureSocketFactory</code></td>
192 <td><code>axis.socketSecureFactory</code></td>
193 <td><code>JSSESocketFactory</code></td>
194 </tr>
195 </table>
196
197 <!--
198 <h3>
199 <a NAME="System Management Plug"></a>System Management</h3>
200 What points are necessary to manage Axis?
201 <ul>
202 <li>
203 Justification/Rationale - why is this plug point necessary?&nbsp; Spec
204 compliance?</li>
205
206 <li>
207 Interfaces</li>
208
209 <li>
210 Mechanism</li>
211
212 <ul>
213 <li>
214 Life cycle</li>
215
216 <li>
217 Exception handling - in general; plug-in shouldn't throw any exceptions
218 - does runtime ignore? Log?)</li>
219
220 <li>
221 Multiple thread support?&nbsp; Ie., is synchronization required?</li>
222 </ul>
223
224 <li>
225 Configuration/reconfiguration</li>
226
227 <li>
228 Default behavior if not plugged.</li>
229
230 <li>
231 Example</li>
232 </ul>
233 -->
234
235 <h3><a NAME="Logging/Tracing Plug"></a>Logging/Tracing</h3>
236 Axis logging and tracing is based on the Logging component of the
237 <a href="http://jakarta.apache.org/commons/index.html">Jakarta Commons</a>
238 project, or the Jakarta Commons Logging (JCL) SPI.
239 The JCL provides a Log interface with thin-wrapper implementations for
240 other logging tools, including
241 <a href="http://jakarta.apache.org/log4j/docs/index.html">Log4J</a>,
242 <a href="http://jakarta.apache.org/avalon/logkit/index.html">Avalon LogKit</a>,
243 and
244 <a>JDK 1.4</a>.
245 The interface maps closely to Log4J and LogKit.
246
247 <h4>Justification/Rationale</h4>
248 A pluggable logging/trace facility enables
249 Axis to direct logging/trace messages to a host web application server's
250 logging facility.
251 A central logging facility with a single point of configuration/control
252 is superior to distinct logging mechanisms for each of a multitude of
253 middleware components that are to be integrated into
254 a web application server.
255
256 <h4>Integration</h4>
257 The minimum requirement to integrate with another logger
258 is to provide an implementation of the
259 <code>org.apache.commons.logging.Log</code> interface.
260 In addition, an implementation of the
261 <code>org.apache.commons.logging.LogFactory</code> interface
262 can be provided to meet
263 specific requirements for connecting to, or instantiating, a logger.
264 <ul>
265 <li><h5>org.apache.commons.logging.Log</h5></li>
266 The <code>Log</code> interface defines the following methods for use
267 in writing log/trace messages to the log:
268 <ul>
269 <code>
270 <br>log.fatal(Object message);
271 <br>log.fatal(Object message, Throwable t);
272 <br>log.error(Object message);
273 <br>log.error(Object message, Throwable t);
274 <br>log.warn(Object message);
275 <br>log.warn(Object message, Throwable t);
276 <br>log.info(Object message);
277 <br>log.info(Object message, Throwable t);
278 <br>log.debug(Object message);
279 <br>log.debug(Object message, Throwable t);
280 <br>log.trace(Object message);
281 <br>log.trace(Object message, Throwable t);
282 <br>&nbsp;
283 <br>log.isFatalEnabled();
284 <br>log.isErrorEnabled();
285 <br>log.isWarnEnabled();
286 <br>log.isInfoEnabled();
287 <br>log.isDebugEnabled();
288 <br>log.isTraceEnabled();
289 <br>
290 </code>
291 </ul>
292 <p>
293 Semantics for these methods are such that it is expected
294 that the severity of messages is ordered, from highest to lowest:
295 <p>
296 <ul>
297 <li>fatal - Consider logging to console and system log.</li>
298 <li>error - Consider logging to console and system log.</li>
299 <li>warn - Consider logging to console and system log.</li>
300 <li>info - Consider logging to console and system log.</li>
301 <li>debug - Log to system log, if enabled.</li>
302 <li>trace - Log to system log, if enabled.</li>
303 </ul>
304
305 <br>&nbsp;
306 <li><h5>org.apache.commons.logging.LogFactory</h5></li>
307 If desired, the default implementation of the
308 <code>org.apache.commons.logging.LogFactory</code>
309 interface can be overridden,
310 allowing the JDK 1.3 Service Provider discovery process
311 to locate and create a LogFactory specific to the needs of the application.
312 Review the Javadoc for the <code>LogFactoryImpl.java</code>
313 for details.
314 </ul>
315
316 <h4>Mechanism</h4>
317 <ul>
318 <li><h5>Life cycle</h5></li>
319 The JCL LogFactory implementation must assume responsibility for
320 either connecting/disconnecting to a logging toolkit,
321 or instantiating/initializing/destroying a logging toolkit.
322 <br>&nbsp;
323 <li><h5>Exception handling</h5></li>
324 The JCL Log interface doesn't specify any exceptions to be handled,
325 the implementation must catch any exceptions.
326 <br>&nbsp;
327 <li><h5>Multiple threads</h5></li>
328 The JCL Log and LogFactory implementations must ensure
329 that any synchronization required by the logging toolkit
330 is met.
331 </ul>
332
333 <h4>Logger Configuration</h4>
334 <ul>
335 <li><h5>Log</h5></li>
336 The default <code>LogFactory</code> provided by JCL
337 can be configured to instantiate a specific implementation of the
338 <code>org.apache.commons.logging.Log</code> interface
339 by setting the property <code>org.apache.commons.logging.Log</code>.
340 This property can be specified as a system property,
341 or in the <code>commons-logging.properties</code> file,
342 which must exist in the CLASSPATH.
343 <br>&nbsp;
344 <li><h5>Default logger if not plugged</h5></li>
345 The Jakarta Commons Logging SPI uses the
346 implementation of the <code>org.apache.commons.logging.Log</code>
347 interface specified by the system property
348 <code>org.apache.commons.logging.Log</code>.
349 If the property is not specified or the class is not available then the JCL
350 provides access to a default logging toolkit by searching the CLASSPATH
351 for the following toolkits, in order of preference:
352 <ul>
353 <li><a href="http://jakarta.apache.org/log4j/docs/index.html">Log4J</a></li>
354 <li>JDK 1.4</li>
355 <li>JCL SimpleLog</li>
356 </ul>
357 </ul>
358
359 <h3>
360 <a NAME="Configuration Plug"></a>Configuration</h3>
361 <br>The internal data model used by Axis is based on
362 an Axis specific data model: Web Services Deployment Descriptor (WSDD).
363 Axis initially obtains the WSDD information for a
364 service from an instance of <code>org.apache.axis.EngineConfiguration</code>.
365
366 <p>The EngineConfiguration is provided by an implementation of
367 the interface <code>org.apache.axis.EngineConfigurationFactory</code>,
368 which currently provides methods that return client and server
369 configurations.
370
371 <p>Our focus will be how to define the implementation class for
372 <code>EngineConfigurationFactory</code>.
373
374 <ul>
375 <li>
376 Justification/Rationale</li>
377 <br>While the default behaviour is sufficient for general use of
378 Axis, integrating Axis into an existing application server may
379 require an alternate deployment model.
380 A customized implementation of the EngineConfigurationFactory
381 would map from the hosts deployment model to Axis's internal
382 deployment model.
383 <br>&nbsp;
384
385 <li>
386 Mechanism</li>
387 <br>The relevant sequence of instructions used to obtain
388 configuration information and initialize Axis is as follows:
389 <ul>
390 <br>
391 <code>EngineConfigurationFactory factory = EngineConfigurationFactoryFinder(someContext);</code>
392 <br>
393 <code>EngineCongfiguration config = factory.getClientEngineConfig();</code>
394 <br>
395 <code>AxisClient = new AxisClient(config);</code>
396 </ul>
397 <br>The details may vary (server versus client, whether other factories are involved, etc).
398 Regardless, the point is that integration code is responsible for
399 calling <code>EngineConfigurationFactoryFinder(someContext)</code>
400 and ensuring that the results are handed to Axis.&nbsp;
401 <code>someContext</code> is key to how the factory finder
402 locates the appropariate implementation of
403 EngineConfigurationFactory to be used, if any.
404
405 <p>EngineConfigurationFactoryFinder works as follows:
406 <br>&nbsp;
407 <ul>
408 <li>Obtain a list of classes that implement
409 <code>org.apache.axis.EngineConfigurationFactory</code>,
410 in the following order:
411 <ul>
412 <li>
413 The value of the system property <code>axis.EngineConfigFactory</code>.
414 </li>
415 <li>
416 The value of the system property
417 <code>org.apache.axis.EngineConfigurationFactory</code>.
418 </li>
419 <li>Locate all resources named
420 <code>META-INF/services/org.apache.axis.EngineConfigurationFactory</code>.
421 Each line of such a resource identifies the name of a class
422 implementing the interface ('#' comments, through end-of-line).
423 </li>
424 <li>
425 <code>org.apache.axis.configuration.EngineConfigurationFactoryServlet</code>
426 </li>
427 <li>
428 <code>org.apache.axis.configuration.EngineConfigurationFactoryDefault</code>
429 </li>
430 </ul>
431 </li>
432
433 <br>
434 <li>Classes implementing EngineConfigurationFactory are required to
435 provide the method
436 <br>&nbsp;
437 <ul>
438 <code>public static EngineConfigurationFactory newFactory(Object)</code>
439 </ul>
440 <br>
441 This method is called, passing <code>someContext</code> as the parameter.
442 </li>
443
444 <br>&nbsp;
445 <li>
446 The <code>newFactory</code> method
447 is required to check the <code>someContext</code> parameter to determine if
448 it is meaningfull to the class (at a minimum,
449 verify that it is of an expected type, or class)
450 and may, in addition, examine the overall runtime environment.
451 If the environment can provide information required by
452 an EngineConfigurationFactory,
453 then the <code>newFactory()</code> may return in instance of that factory.
454 Otherwise, <code>newFactory()</code> must return null.
455 </li>
456
457 <br>&nbsp;
458 <li>
459 EngineConfigurationFactoryFinder returns the first non-null
460 factory it obtains.
461 </li>
462 </ul>
463 <br>&nbsp;
464
465
466 <li>
467 Default behavior</li>
468 <br>The default behaviour is provided by the last two elements
469 of the list of implementing classes, as described above:
470 <ul>
471 <li>
472 <code>org.apache.axis.configuration.EngineConfigurationFactoryServlet</code>
473 <br><code>newFactory(obj)</code> is called.
474 If <code>obj instanceof javax.servlet.ServletContext</code> is true,
475 then an instance of this class is returned.
476 <p>The default Servlet factory is expected to function as a server
477 (as a client it will incorrectly attempt
478 to load the WSDD file <code>client-config.wsdd</code>
479 from the current working directory!).
480
481 <p>The default Servlet factory will open the Web Application resource
482 <code>/WEB-INF/server-config.wsdd</code>
483 (The name of this file may be changed using the
484 system property <code>axis.ServerConfigFile</code>):
485 <ul>
486 <li>
487 If it exists as an accessible file (i.e. not in a JAR/WAR file),
488 then it opens it as a file.
489 This allows changes to be saved,
490 if changes are allowed & made using the Admin tools.
491 </li>
492 <li>
493 If it does not exist as a file, then an attempt is made
494 to access it as a resource stream (getResourceAsStream),
495 which works for JAR/WAR file contents.
496 </li>
497 <li>
498 If the resource is simply not available,
499 an attempt is made to create it as a file.
500 </li>
501 <li>
502 If all above attempts fail, a final attempt is
503 made to access <code>org.apache.axis.server.server-config.wsdd</code>
504 as a data stream.
505 </li>
506 </ul>
507
508 </li>
509 <br>&nbsp;
510 <li>
511 <code>org.apache.axis.configuration.EngineConfigurationFactoryDefault</code>
512 <br><code>newFactory(obj)</code> is called.
513 If <code>obj</code> is null
514 then an instance of this class is returned.
515 A non-null <code>obj</code> is presumed to
516 require a non-default factory.
517
518 <p>The default factory will load the WSDD files
519 <code>client-config.wsdd</code> or <code>server-config.wsdd</code>,
520 as appropriate, from the current working directory.
521 The names of these files may be changed using the
522 system properties <code>axis.ClientConfigFile</code>
523 and <code>axis.ServerConfigFile</code>,
524 respectively.
525 </li>
526 </ul>
527
528 </ul>
529
530 <h3>
531 <a NAME="Handlers Plug"></a>Handlers</h3>
532 See the <a href="architecture-guide.html">Architecture
533 Guide</a> for current information on Handlers.
534
535 <h3>
536 <a NAME="Internationalization Plug"></a>Internationalization</h3>
537 Axis supports internationalization by providing
538 both a property file of the strings used in Axis,
539 and an extension mechanism that facilitates
540 accessing internal Axis messages and extending the messages
541 available to integration code based on existing Axis code.
542
543 <h4>
544 <a NAME="Translation"></a>Translation</h4>
545
546 <ul>
547 <li>
548 Justification/Rationale</li>
549
550 <br>
551 In order for readers of languages other than English
552 to be comfortable with Axis,
553 we provide a mechanism for the strings used in Axis to be translated.
554 We do not provide any translations in Axis;
555 we merely provide a means by which translators
556 can easily plug in their translations.
557 <br>&nbsp;
558
559 <li>
560 Mechanism</li>
561 <br>
562 Axis provides english messages in the
563 Java resource named
564 org.apache.axis.i18n.resource.properties
565 (in the source tree, the file is named
566 xml-axis/java/src/org/apache/axis/i18n/resource.properties).
567
568 <p>Axis makes use of the Java internationalization mechanism -
569 i.e., a java.util.ResourceBundle backed by a properties file -
570 and the java.text.MessageFormat class to substitute
571 parameters into the message text.
572
573 <ul>
574 <br>
575 <li>
576 java.util.ResourceBundle retrieves message text
577 from a property file using a key provided by the program.
578 Entries in a message resource file are of the form
579 &lt;key&gt;=&lt;message&gt;.
580 </li>
581
582 <br>&nbsp;
583 <li>
584 java.text.MessageFormat substitutes variables for
585 markers in the message text.
586 Markers use the syntax
587 <font face="Courier New,Courier">"{X}"</font>
588 where <code>X</code> is
589 the number of the variable, starting at 0.
590 </li>
591 </ul>
592
593 <p>For example: <code>myMsg00=My {0} is {1}.</code>
594
595 <p>Translation requires creating an
596 alternate version of the property file provided by Axis
597 for a target language.
598 The JavaDoc for <code>java.utils.ResourceBundle</code>
599 provides details on how to identify different property
600 files for different locales.
601
602 <p>For details on using Axis's internationalization tools,
603 see the <a href="developers-guide.html">Developer's Guide</a>.
604 <br>&nbsp;
605
606 <li>
607 Default behavior</li>
608
609 <br>The default behavior, meaning what happens when a translated file doesn't
610 exist for a given locale, is to fall back on the English-language properties
611 file.&nbsp; If that file doesn't exist (unlikely unless something is seriously
612 wrong), Axis will throw an exception with an English-language reason message.
613 <br>&nbsp;
614 </ul>
615
616 <h4>
617 <a NAME="Extending Message Files"></a>Extending Message Files</h4>
618 Axis provides a Message file extension mechanism
619 that allows Axis-based code to use Axis message keys,
620 as well as new message keys unique to the extended code.
621
622 <ul>
623 <li>
624 Justification/Rationale</li>
625 <br>
626 Axis provides pluggable interfaces for
627 various Axis entities, including EngineConfigurationFactory's,
628 Provides, and Handlers.
629 Axis also provides a variety of implementations
630 of these entities.
631 It is convenient to use Axis source code for
632 such implementations as starting points for developing
633 extentions and customizations that fulfill the unique needs
634 of the end user.
635 <br>&nbsp;
636
637 <li>
638 Procedure</li>
639 <br>To extend the Axis message file:
640 <br>&nbsp;
641 <ul>
642 <li>Copy the Axis source file
643 <code>java/src/org/apache/axis/i18n/Messages.java</code>
644 to your project/package, say
645 <code>my/project/package/path/Messages.java</code>.
646 </li>
647 <ul>
648 <li>Set the <code>package</code> declaration in the copied file
649 to the correct package name.
650 </li>
651 <li>Set the private attribute <code>projectName</code>
652 to <code>"my.project"</code>:
653 the portion of the package name that is common to your project.
654 <code>projectName</code> must be equal to or be a prefix of the
655 copied Messages package name.
656 </li>
657 </ul>
658 <br>&nbsp;
659 <li>Create the file
660 <code>my/project/package/path/resource.properties</code>.
661 Add new message key/value pairs to this file.
662 </li>
663 <br>&nbsp;
664 <li>As you copy Axis source files over to your project,
665 change the <code>import org.apache.axis.i18n.Messages</code>
666 statement to <code>import my.project.package.path.Messages</code>.
667 </li>
668 <li>Use the methods provided by the class Messages,
669 as discussed in the <a href="developers-guide.html">Developer's Guide</a>,
670 to access the new messages.
671 </li>
672 </ul>
673 <br>
674
675 <li>
676 Behavior</li>
677
678 <ul>
679 <li>
680 Local Search</li>
681 <br><code>Messages</code> begins looking for a key's value in
682 the <code>resources.properties</code>
683 resource in it's (Messages) package.
684 <br>&nbsp;
685
686 <li>
687 Hierarchical Search</li>
688 <br>If <code>Messages</code> cannot locate
689 either the key, or the resource file,
690 it walks up the package hierarchy until it finds it.
691 The top of the hierarchy, above which it will not search,
692 is defined by the <code>projectName</code> attribute,
693 set above.
694 <br>&nbsp;
695
696 <li>
697 Default behavior</li>
698 <br>If the key cannot be found in the package hierarchy
699 then a default resource is used.
700 The default behaviour is determined by
701 the <code>parent</code> attribute of the
702 <code>Messages</code> class copied to your extensions directory.
703 <p>Unless changed, the default behavior, meaning what happens when a key
704 isn't defined in the new properties file,
705 is to fall back to the Axis properties file
706 (org.apache.axis.i18n.resource.properties).
707 <br>&nbsp;
708 </ul>
709 </ul>
710
711 <h3>
712 <a NAME="Performance Monitoring Plug"></a>Performance Monitoring</h3>
713 Axis does not yet include specific Performance Monitoring Plugs.
714 <!--
715 <ul>
716 <li>
717 Justification/Rationale - why is this plug point necessary?&nbsp; Spec
718 compliance?</li>
719
720 <li>
721 Interfaces</li>
722
723 <li>
724 Mechanism</li>
725
726 <ul>
727 <li>
728 Life cycle</li>
729
730 <li>
731 Exception handling - in general; plug-in shouldn't throw any exceptions
732 - does runtime ignore? Log?)</li>
733
734 <li>
735 Multiple thread support?&nbsp; Ie., is synchronization required?</li>
736 </ul>
737
738 <li>
739 Configuration/reconfiguration</li>
740
741 <li>
742 Default behavior if not plugged.</li>
743
744 <li>
745 Example</li>
746 </ul>
747 -->
748
749 <h3>
750 <a NAME="Encoding Plug"></a>Encoding</h3>
751 Axis does not yet include an Encoding Plug.
752 <!--
753 How can a system integrator plug in other encoding mechanisms such as SOAP
754 1.2 or optimized XML-based encoding?
755 <ul>
756 <li>
757 Justification/Rationale - why is this plug point necessary?&nbsp; Spec
758 compliance?</li>
759
760 <li>
761 Interfaces</li>
762
763 <li>
764 Mechanism</li>
765
766 <ul>
767 <li>
768 Life cycle</li>
769
770 <li>
771 Exception handling - in general; plug-in shouldn't throw any exceptions
772 - does runtime ignore? Log?)</li>
773
774 <li>
775 Multiple thread support?&nbsp; Ie., is synchronization required?</li>
776 </ul>
777
778 <li>
779 Configuration/reconfiguration</li>
780
781 <li>
782 Default behavior if not plugged.</li>
783
784 <li>
785 Example</li>
786 </ul>
787 -->
788
789 <h3>
790 <a NAME="WSDL plug"></a>WSDL Parser and Code Generator Framework</h3>
791 WSDL2Java is Axis's tool to generate Java artifacts from WSDL.&nbsp; This
792 tool is extensible.&nbsp; If users of Axis wish to extend Axis, then they
793 may also need to extend or change the generated artifacts.&nbsp; For example,
794 if Axis is inserted into some product which has an existing deployment
795 model that's different than Axis's deployment model, then that product's
796 version of WSDL2Java will be required to generate deployment descriptors
797 other than Axis's deploy.wsdd.
798 <p>What follows immediately is a description of the framework.&nbsp; If
799 you would rather dive down into the dirt of <a href="#WSDL Examples">examples</a>,
800 you could learn a good deal just from them.&nbsp; Then you could come back
801 up here and learn the gory details.
802 <p>There are three parts to WSDL2Java:
803 <ol>
804 <li>
805 The symbol table</li>
806
807 <li>
808 The parser front end with a generator framework</li>
809
810 <li>
811 The code generator back end (WSDL2Java itself)</li>
812 </ol>
813
814 <h4>
815 Symbol Table</h4>
816 The symbol table, found in org.apache.axis.wsdl.symbolTable, will contain
817 all the symbols from a WSDL document, both the symbols from the WSDL constructs
818 themselves (portType, binding, etc), and also the XML schema types that
819 the WSDL refers to.
820 <p><font color="#FF0000">NOTE:&nbsp; Needs lots of description here.</font>
821 <p>The symbol table is not extensible, but you <b>can</b> add fields to
822 it by using the Dynamic Variables construct:
823 <ul>
824 <li>
825 You must have some constant object for a dynamic variable key.&nbsp; For
826 example:&nbsp; public static final String MY_KEY = "my key";</li>
827
828 <li>
829 You set the value of the variable in your GeneratorFactory.generatorPass:&nbsp;
830 entry.setDynamicVar(MY_KEY, myValue);</li>
831
832 <li>
833 You get the value of the variable in your generators:&nbsp; Object myValue
834 = entry.getDynamicVar(MY_KEY);</li>
835 </ul>
836
837 <h4>
838 Parser Front End and Generator Framework</h4>
839 The parser front end and generator framework is located in org.apache.axis.wsdl.gen.&nbsp;
840 The parser front end consists of two files:
841 <ul>
842 <li>
843 Parser</li>
844
845 <br><tt>public class Parser {</tt>
846 <br><tt>&nbsp;&nbsp;&nbsp; public Parser();</tt>
847 <br><tt>&nbsp;&nbsp;&nbsp; public boolean isDebug();</tt>
848 <br><tt>&nbsp;&nbsp;&nbsp; public void setDebug(boolean);</tt>
849 <br><tt>&nbsp;&nbsp;&nbsp; public boolean isImports();</tt>
850 <br><tt>&nbsp;&nbsp;&nbsp; public void setImports(boolean);</tt>
851 <br><tt>&nbsp;&nbsp;&nbsp; public boolean isVerbose();</tt>
852 <br><tt>&nbsp;&nbsp;&nbsp; public void setVerbose(boolean);</tt>
853 <br><tt>&nbsp;&nbsp;&nbsp; public long getTimeout();</tt>
854 <br><tt>&nbsp;&nbsp;&nbsp; public void setTimeout(long);</tt>
855 <br><tt>&nbsp;&nbsp;&nbsp; public java.lang.String getUsername();</tt>
856 <br><tt>&nbsp;&nbsp;&nbsp; public void setUsername(java.lang.String);</tt>
857 <br><tt>&nbsp;&nbsp;&nbsp; public java.lang.String getPassword();</tt>
858 <br><tt>&nbsp;&nbsp;&nbsp; public void setPassword(java.lang.String);</tt>
859 <br><tt>&nbsp;&nbsp;&nbsp; public GeneratorFactory getFactory();</tt>
860 <br><tt>&nbsp;&nbsp;&nbsp; public void setFactory(GeneratorFactory);</tt>
861 <br><tt>&nbsp;&nbsp;&nbsp; public org.apache.axis.wsdl.symbolTable.SymbolTable
862 getSymbolTable();</tt>
863 <br><tt>&nbsp;&nbsp;&nbsp; public javax.wsdl.Definition getCurrentDefinition();</tt>
864 <br><tt>&nbsp;&nbsp;&nbsp; public java.lang.String getWSDLURI();</tt>
865 <br><tt>&nbsp;&nbsp;&nbsp; public void run(String wsdl) throws java.lang.Exception;</tt>
866 <br><tt>&nbsp;&nbsp;&nbsp; public void run(String context, org.w3c.dom.Document
867 wsdlDoc) throws java.io.IOException, javax.wsdl.WSDLException;</tt>
868 <br><tt>}</tt>
869 <p>The basic behavior of this class is simple:&nbsp; you instantiate a
870 Parser, then you run it.
871 <ul><tt>Parser parser = new Parser();</tt>
872 <br><tt>parser.run("myfile.wsdl");</tt></ul>
873
874 <p><br>There are various options on the parser that have accessor methods:
875 <ul>
876 <li>
877 debug - default is false - dump the symbol table after the WSDL file has
878 been parsed</li>
879
880 <li>
881 imports - default is true - should imported files be visited?</li>
882
883 <li>
884 verbose - default is false - list each file as it is being parsed</li>
885
886 <li>
887 timeout - default is 45 - the number of seconds to wait before halting
888 the parse</li>
889
890 <li>
891 username - no default - needed for protected URI's</li>
892
893 <li>
894 password - no default - needed for protected URI's</li>
895 </ul>
896
897 <p><br>Other miscellaneous methods on the parser:
898 <ul>
899 <li>
900 get/setFactory - get or set the GeneratorFactory on this parser - see below
901 for details.&nbsp; The default generator factory is NoopFactory, which
902 generates nothing.</li>
903
904 <li>
905 getSymbolTable - once a run method is called, the symbol table will be
906 populated and can get queried.</li>
907
908 <li>
909 getCurrentDefinition - once a run method is called, the parser will contain
910 a Definition object which represents the given wsdl file.&nbsp; Definition
911 is a WSDL4J object.</li>
912
913 <li>
914 getWSDLURI - once the run method which takes a string is called, the parser
915 will contain the string representing the location of the WSDL file.&nbsp;
916 Note that the other run method - run(String context, Document wsdlDoc)
917 - does not provide a location for the wsdl file.&nbsp; If this run method
918 is used, getWSDLURI will be null.</li>
919
920 <li>
921 There are two run methods.&nbsp; The first, as shown above, takes a URI
922 string which represents the location of the WSDL file.&nbsp; If you've
923 already parsed the WSDL file into an XML Document, then you can use the
924 second run method, which takes a context and the WSDL Document.</li>
925 </ul>
926
927 <p><br>An extension of this class would ...
928 <br><br>
929 <font color="#FF0000">NOTE:&nbsp; continue this sentiment...</font>
930 <br>&nbsp;
931 <li>
932 WSDL2</li>
933
934 <br>Parser is the programmatic interface into the WSDL parser.&nbsp; WSDL2
935 is the command line tool for the parser.&nbsp; It provides an extensible
936 framework for calling the Parser from the command line.&nbsp; It is named
937 WSDL2 because extensions of it will likely begin with WSDL2:&nbsp; <b>WSDL2</b>Java,
938 <b>WSDL2</b>Lisp, <b>WSDL2</b>XXX.
939 <p><tt>public class WSDL2 {</tt>
940 <br><tt>&nbsp;&nbsp;&nbsp; protected WSDL2();</tt>
941 <br><tt>&nbsp;&nbsp;&nbsp; protected Parser createParser();</tt>
942 <br><tt>&nbsp;&nbsp;&nbsp; protected Parser getParser();</tt>
943 <br><tt>&nbsp;&nbsp;&nbsp; protected void addOptions(org.apache.axis.utils.CLOptionDescriptor[]);</tt>
944 <br><tt>&nbsp;&nbsp;&nbsp; protected void parseOption(org.apache.axis.utils.CLOption);</tt>
945 <br><tt>&nbsp;&nbsp;&nbsp; protected void validateOptions();</tt>
946 <br><tt>&nbsp;&nbsp;&nbsp; protected void printUsage();</tt>
947 <br><tt>&nbsp;&nbsp;&nbsp; protected void run(String[]);</tt>
948 <br><tt>&nbsp;&nbsp;&nbsp; public static void main(String[]);</tt>
949 <br><tt>}</tt>
950 <p>Like all good command line tools, it has a main method.&nbsp; Unlike
951 some command line tools, however, its methods are not static.&nbsp; Static
952 methods are not extensible.&nbsp; WSDL2's main method constructs an instance
953 of itself and calls methods on that instance rather than calling static
954 methods.&nbsp; These methods follow a behavior pattern.&nbsp; The main
955 method is very simple:
956 <br>&nbsp;
957 <ul><tt>&nbsp;&nbsp;&nbsp; public static void main(String[] args) {</tt>
958 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WSDL2 wsdl2 = new WSDL2();</tt>
959 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wsdl2.run(args);</tt>
960 <br><tt>&nbsp;&nbsp;&nbsp; }</tt></ul>
961
962 <p><br>The constructor calls createParser to construct a Parser or an extension
963 of Parser.
964 <p>run calls:
965 <ul>
966 <li>
967 parseOption to parse each command line option and call the appropriate
968 Parser accessor.&nbsp; For example, when this method parses --verbose,
969 it calls parser.setVerbose(true)</li>
970
971 <li>
972 validateOptions to make sure all the option values are consistent</li>
973
974 <li>
975 printUsage if the usage of the tool is in error</li>
976
977 <li>
978 parser.run(args);</li>
979 </ul>
980
981 <p><br>If an extension has additional options, then it is expected to call
982 addOptions before calling run.&nbsp; So extensions will call, as necessary,
983 getParser, addOptions, run.&nbsp; Extensions will override, as necessary,
984 createParser, parseOption, validateOptions, printUsage.
985 <br>&nbsp;
986 <p>The generator framework consists of 2 files:
987 <ul>
988 <li>
989 Generator</li>
990
991 <br>The Generator interface is very simple.&nbsp; It just defines a generate
992 method.
993 <p><tt>public interface Generator</tt>
994 <br><tt>{</tt>
995 <br><tt>&nbsp;&nbsp;&nbsp; public void generate() throws java.io.IOException;</tt>
996 <br><tt>}</tt>
997 <br>&nbsp;
998 <li>
999 GeneratorFactory</li>
1000
1001 <p><br><tt>public interface GeneratorFactory</tt>
1002 <br><tt>{</tt>
1003 <br><tt>&nbsp;&nbsp;&nbsp; public void generatorPass(javax.wsdl.Definition,
1004 SymbolTable);</tt>
1005 <br><tt>&nbsp;&nbsp;&nbsp; public Generator getGenerator(javax.wsdl.Message,
1006 SymbolTable);</tt>
1007 <br><tt>&nbsp;&nbsp;&nbsp; public Generator getGenerator(javax.wsdl.PortType,
1008 SymbolTable);</tt>
1009 <br><tt>&nbsp;&nbsp;&nbsp; public Generator getGenerator(javax.wsdl.Binding,
1010 SymbolTable);</tt>
1011 <br><tt>&nbsp;&nbsp;&nbsp; public Generator getGenerator(javax.wsdl.Service,
1012 SymbolTable);</tt>
1013 <br><tt>&nbsp;&nbsp;&nbsp; public Generator getGenerator(TypeEntry, SymbolTable);</tt>
1014 <br><tt>&nbsp;&nbsp;&nbsp; public Generator getGenerator(javax.wsdl.Definition,
1015 SymbolTable);</tt>
1016 <br><tt>&nbsp;&nbsp;&nbsp; public void setBaseTypeMapping(BaseTypeMapping);</tt>
1017 <br><tt>&nbsp;&nbsp;&nbsp; public BaseTypeMapping getBaseTypeMapping();</tt>
1018 <br><tt>}</tt>
1019 <p>The GeneratorFactory interface defines a set of methods that the parser
1020 uses to get generators.&nbsp; There should be a generator for each of the
1021 WSDL constructs (message, portType, etc - note that these depend on the
1022 WSDL4J classes:&nbsp; javax.xml.Message, javax.xml.PortType, etc); a generator
1023 for schema types; and a generator for the WSDL Definition itself.&nbsp;
1024 This last generator is used to generate anything that doesn't fit into
1025 the previous categories
1026 <p>In addition to the getGeneratorMethods, the GeneratorFactory defines
1027 a generatorPass method which provides the factory implementation a chance
1028 to walk through the symbol table to do any preprocessing before the actual
1029 generation begins.
1030 <p>Accessors for the base type mapping are also defined.&nbsp; These are
1031 used to translate QNames to base types in the given target mapping.
1032 <br>&nbsp;</ul>
1033 In addition to Parser, WSDL2, Generator, and GeneratorFactory, the org.apache.axis.wsdl.gen
1034 package also contains a couple of no-op classes:&nbsp; NoopGenerator and
1035 NoopFactory.&nbsp; NoopGenerator is a convenience class for extensions
1036 that do not need to generate artifacts for every WSDL construct.&nbsp;
1037 For example, WSDL2Java does not generate anything for messages, therefore
1038 its factory's getGenerator(Message, SymbolTable) method returns an instance
1039 of NoopGenerator.&nbsp; NoopFactory returns a NoopGenerator for all getGenerator
1040 methods.&nbsp; The default factory for Parser is the NoopFactory.</ul>
1041
1042 <h4>
1043 Code Generator Back End</h4>
1044 The meat of the WSDL2Java back end generators is in org.apache.axis.wsdl.toJava.&nbsp;
1045 Emitter extends Parser.&nbsp; org.apache.axis.wsdl.WSDL2Java extends WSDL2.&nbsp;
1046 JavaGeneratorFactory implements GeneratorFactory.&nbsp; And the various
1047 JavaXXXWriter classes implement the Generator interface.
1048 <p><font color="#FF0000">NOTE:&nbsp; Need lots more description here...</font>
1049 <h4>
1050 <a NAME="WSDL Examples"></a>WSDL Framework Extension Examples</h4>
1051 Everything above sounds rather complex.&nbsp; It is, but that doesn't mean
1052 your extension has to be.
1053 <h5>
1054 Example 1 - Simple extension of WSDL2Java - additional artifact</h5>
1055 The simplest extension of the framework is one which generates everything
1056 that WSDL2Java already generates, plus something new.&nbsp; Example 1 is
1057 such an extension.&nbsp; It's extra artifact is a file for each service
1058 that lists that service's ports.&nbsp; I don't know why you'd want to do
1059 this, but it makes for a good, simple example.&nbsp; See samples/integrationGuide/example1
1060 for the complete implementation of this example.
1061 <br>&nbsp;
1062 <ul>
1063 <li>
1064 First you must create your writer that writes the new artifact.&nbsp; This
1065 new class extends org.apache.axis.wsdl.toJava.JavaWriter.&nbsp; JavaWriter
1066 dictates behavior to its extensions; it calls writeFileHeader and writeFileBody.&nbsp;
1067 Since we don't care about a file header for this example, writeFileHeader
1068 is a no-op method.&nbsp; writeFileBody does the real work of this writer.</li>
1069
1070 <p><br><tt>public class MyListPortsWriter extends JavaWriter {</tt>
1071 <br><tt>&nbsp;&nbsp;&nbsp; private Service service;</tt>
1072 <br><tt>&nbsp;&nbsp;&nbsp; public MyListPortsWriter(</tt>
1073 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1074 Emitter emitter,</tt>
1075 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1076 ServiceEntry sEntry,</tt>
1077 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1078 SymbolTable symbolTable) {</tt>
1079 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; super(emitter,</tt>
1080 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1081 new QName(</tt>
1082 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1083 sEntry.getQName().getNamespaceURI(),</tt>
1084 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1085 sEntry.getQName().getLocalPart() + "Lst"),</tt>
1086 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1087 "", "lst", "Generating service port list file", "service list");</tt>
1088 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.service = sEntry.getService();</tt>
1089 <br><tt>&nbsp;&nbsp;&nbsp; }</tt>
1090 <br><tt>&nbsp;&nbsp;&nbsp; protected void writeFileHeader() throws IOException
1091 {</tt>
1092 <br><tt>&nbsp;&nbsp;&nbsp; }</tt>
1093 <br><tt>&nbsp;&nbsp;&nbsp; protected void writeFileBody() throws IOException
1094 {</tt>
1095 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Map portMap = service.getPorts();</tt>
1096 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Iterator portIterator
1097 = portMap.values().iterator();</tt><tt></tt>
1098 <p><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while (portIterator.hasNext())
1099 {</tt>
1100 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1101 Port p = (Port) portIterator.next();</tt>
1102 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1103 pw.println(p.getName());</tt>
1104 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</tt>
1105 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pw.close();</tt>
1106 <br><tt>&nbsp;&nbsp;&nbsp; }</tt>
1107 <br><tt>}</tt>
1108 <br>&nbsp;
1109 <li>
1110 Then you need a main program.&nbsp; This main program extends WSDL2Java
1111 so that it gets all the functionality of that tool.&nbsp; The main of this
1112 tool does 3 things:</li>
1113
1114 <ul>
1115 <li>
1116 instantiates itself</li>
1117
1118 <li>
1119 adds MyListPortsWriter to the list of generators for a WSDL service</li>
1120
1121 <li>
1122 calls the run method.</li>
1123 </ul>
1124 That's it!&nbsp; The base tool does all the rest of the work.
1125 <p><tt>public class MyWSDL2Java extends WSDL2Java {</tt><tt></tt>
1126 <p><tt>&nbsp;&nbsp;&nbsp; public static void main(String args[]) {</tt>
1127 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyWSDL2Java myWSDL2Java
1128 = new MyWSDL2Java();</tt><tt></tt>
1129 <p><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; JavaGeneratorFactory
1130 factory =</tt>
1131 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1132 (JavaGeneratorFactory) myWSDL2Java.getParser().getFactory();</tt>
1133 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; factory.addGenerator(Service.class,
1134 MyListPortsWriter.class);</tt><tt></tt>
1135 <p><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; myWSDL2Java.run(args);</tt>
1136 <br><tt>&nbsp;&nbsp;&nbsp; }</tt>
1137 <br><tt>}</tt></ul>
1138
1139 <h5>
1140 Example 2 - Not quite as simple an extension of WSDL2Java - change an artifact</h5>
1141 In this example, we'll replace deploy.wsdd with mydeploy.useless.&nbsp;
1142 For brevity, mydeploy.useless is rather useless.&nbsp; Making it useful
1143 is an exercise left to the reader.&nbsp; See samples/integrationGuide/example2
1144 for the complete implementation of this example.
1145 <ul>
1146 <li>
1147 First, here is the writer for the mydeploy.useless.&nbsp; This new class
1148 extends org.apache.axis.wsdl.toJava.JavaWriter.&nbsp; JavaWriter dictates
1149 behavior to its extensions; it calls writeFileHeader and writeFileBody.&nbsp;
1150 Since we don't care about a file header for this example, writeFileHeader
1151 is a no-op method.&nbsp; writeFileBody does the real work of this writer.&nbsp;
1152 It simply writes a bit of a song, depending on user input.</li>
1153
1154 <p><br>Note that we've also overridden the generate method.&nbsp; The parser
1155 always calls generate, but since this is a server-side artifact, we don't
1156 want to generate it unless we are generating server-side artifacts (in
1157 other words, in terms of the command line options, we've specified the
1158 --serverSide option).
1159 <p><tt>public class MyDeployWriter extends JavaWriter {</tt>
1160 <br><tt>&nbsp;&nbsp;&nbsp; public MyDeployWriter(Emitter emitter, Definition
1161 definition,</tt>
1162 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1163 SymbolTable symbolTable) {</tt>
1164 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; super(emitter,</tt>
1165 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1166 new QName(definition.getTargetNamespace(), "deploy"),</tt>
1167 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1168 "", "useless", "Generating deploy.useless", "deploy");</tt>
1169 <br><tt>&nbsp;&nbsp;&nbsp; }</tt>
1170 <br><tt>&nbsp;&nbsp;&nbsp; public void generate() throws IOException {</tt>
1171 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (emitter.isServerSide())
1172 {</tt>
1173 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1174 super.generate();</tt>
1175 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</tt>
1176 <br><tt>&nbsp;&nbsp;&nbsp; }</tt>
1177 <br><tt>&nbsp;&nbsp;&nbsp; protected void writeFileHeader() throws IOException
1178 {</tt>
1179 <br><tt>&nbsp;&nbsp;&nbsp; }</tt>
1180 <br><tt>&nbsp;&nbsp;&nbsp; protected void writeFileBody() throws IOException
1181 {</tt>
1182 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyEmitter myEmitter
1183 = (MyEmitter) emitter;</tt>
1184 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (myEmitter.getSong()
1185 == MyEmitter.RUM) {</tt>
1186 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1187 pw.println("Yo!&nbsp; Ho!&nbsp; Ho!&nbsp; And a bottle of rum.");</tt>
1188 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</tt>
1189 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if (myEmitter.getSong()
1190 == MyEmitter.WORK) {</tt>
1191 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1192 pw.println("Hi ho!&nbsp; Hi ho!&nbsp; It's off to work we go.");</tt>
1193 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</tt>
1194 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else {</tt>
1195 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1196 pw.println("Feelings...&nbsp; Nothing more than feelings...");</tt>
1197 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</tt>
1198 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pw.close();</tt>
1199 <br><tt>&nbsp;&nbsp;&nbsp; }</tt>
1200 <br><tt>}</tt>
1201 <br><tt></tt>&nbsp;
1202 <li>
1203 Since we're changing what WSDL2Java generates, rather than simply adding
1204 to it like the previous example did, calling addGenerator isn't good enough.&nbsp;
1205 In order to change what WSDL2Java generates, you have to create a generator
1206 factory and provide your own generators.&nbsp; Since we want to keep most
1207 of WSDL2Java's artifacts, we can simply extend WSDL2Java's factory - JavaGeneratorFactory
1208 - and override the addDefinitionGenerators method.</li>
1209
1210 <p><br><tt>public class MyGeneratorFactory extends JavaGeneratorFactory
1211 {</tt>
1212 <br><tt>&nbsp;&nbsp;&nbsp; protected void addDefinitionGenerators() {</tt>
1213 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; addGenerator(Definition.class,
1214 JavaDefinitionWriter.class); // WSDL2Java's JavaDefinitionWriter</tt>
1215 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; addGenerator(Definition.class,
1216 MyDeployWriter.class); // our DeployWriter</tt>
1217 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; addGenerator(Definition.class,
1218 JavaUndeployWriter.class); // WSDL2Java's JavaUndeployWriter</tt>
1219 <br><tt>&nbsp;&nbsp;&nbsp; }</tt>
1220 <br><tt>}</tt>
1221 <br>&nbsp;
1222 <li>
1223 Now we must write the API's to our tool.&nbsp; Since we've added an option
1224 - song - we need both the programmatic API - an extension of Parser (actually
1225 Emitter in this case since we're extending WSDL2Java and Emitter is WSDL2Java's
1226 parser extension) - and the command line API.</li>
1227
1228 <p><br>Here is our programmatic API.&nbsp; It adds song accessors to Emitter.&nbsp;
1229 It also, in the constructor, lets the factory know about the emitter and
1230 the emitter know about the factory.
1231 <p><tt>public class MyEmitter extends Emitter {</tt>
1232 <br><tt>&nbsp;&nbsp;&nbsp; public static final int RUM&nbsp; = 0;</tt>
1233 <br><tt>&nbsp;&nbsp;&nbsp; public static final int WORK = 1;</tt>
1234 <br><tt>&nbsp;&nbsp;&nbsp; private int song = -1;</tt><tt></tt>
1235 <p><tt>&nbsp;&nbsp;&nbsp; public MyEmitter() {</tt>
1236 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyGeneratorFactory factory
1237 = new MyGeneratorFactory();</tt>
1238 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setFactory(factory);</tt>
1239 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; factory.setEmitter(this);</tt>
1240 <br><tt>&nbsp;&nbsp;&nbsp; }</tt>
1241 <br><tt>&nbsp;&nbsp;&nbsp; public int getSong() {</tt>
1242 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return song;</tt>
1243 <br><tt>&nbsp;&nbsp;&nbsp; }</tt>
1244 <br><tt>&nbsp;&nbsp;&nbsp; public void setSong(int song) {</tt>
1245 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.song = song;</tt>
1246 <br><tt>&nbsp;&nbsp;&nbsp; }</tt>
1247 <br><tt>}</tt>
1248 <p>And here is our command line API.&nbsp; It's a bit more complex that
1249 our previous example's main program, but it does 2 extra things:
1250 <ol>
1251 <li>
1252 accept a new command line option:&nbsp; --song rum|work (this is the biggest
1253 chunk of the new work).</li>
1254
1255 <li>
1256 create a new subclass of Parser</li>
1257 </ol>
1258
1259 <p><br><tt>public class WSDL2Useless extends WSDL2Java {</tt>
1260 <br><tt>&nbsp;&nbsp;&nbsp; protected static final int SONG_OPT = 'g';</tt>
1261 <br><tt>&nbsp;&nbsp;&nbsp; protected static final CLOptionDescriptor[]
1262 options = new CLOptionDescriptor[]{</tt>
1263 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new CLOptionDescriptor("song",</tt>
1264 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1265 CLOptionDescriptor.ARGUMENT_REQUIRED,</tt>
1266 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1267 SONG_OPT,</tt>
1268 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1269 "Choose a song for deploy.useless:&nbsp; work or rum")</tt>
1270 <br><tt>&nbsp;&nbsp;&nbsp; };</tt><tt></tt>
1271 <p><tt>&nbsp;&nbsp;&nbsp; public WSDL2Useless() {</tt>
1272 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; addOptions(options);</tt>
1273 <br><tt>&nbsp;&nbsp;&nbsp; }</tt>
1274 <br><tt>&nbsp;&nbsp;&nbsp; protected Parser createParser() {</tt>
1275 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return new MyEmitter();</tt>
1276 <br><tt>&nbsp;&nbsp;&nbsp; }</tt>
1277 <br><tt>&nbsp;&nbsp;&nbsp; protected void parseOption(CLOption option)
1278 {</tt>
1279 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (option.getId() ==
1280 SONG_OPT) {</tt>
1281 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1282 String arg = option.getArgument();</tt>
1283 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1284 if (arg.equals("rum")) {</tt>
1285 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1286 ((MyEmitter) parser).setSong(MyEmitter.RUM);</tt>
1287 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1288 }</tt>
1289 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1290 else if (arg.equals("work")) {</tt>
1291 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1292 ((MyEmitter) parser).setSong(MyEmitter.WORK);</tt>
1293 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1294 }</tt>
1295 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</tt>
1296 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else {</tt>
1297 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1298 super.parseOption(option);</tt>
1299 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</tt>
1300 <br><tt>&nbsp;&nbsp;&nbsp; }</tt>
1301 <br><tt>&nbsp;&nbsp;&nbsp; public static void main(String args[]) {</tt>
1302 <br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WSDL2Useless useless
1303 = new WSDL2Useless();</tt><tt></tt>
1304 <p><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; useless.run(args);</tt>
1305 <br><tt>&nbsp;&nbsp;&nbsp; }</tt>
1306 <br><tt>}</tt>
1307 <p>Let's go through this one method at a time.
1308 <ul>
1309 <li>
1310 constructor - this constructor adds the new option --song rum|work.&nbsp;
1311 (the abbreviated version of this option is "-g", rather an odd abbreviation,
1312 but "-s" is the abbreviation for --serverSide and "-S" is the abbreviation
1313 for --skeletonDeploy.&nbsp; Bummer.&nbsp; I just picked some other letter.</li>
1314
1315 <li>
1316 createParser - we've got to provide a means by which the parent class can
1317 get our Parser extension.</li>
1318
1319 <li>
1320 parseOption - this method processes our new option.&nbsp; If the given
1321 option isn't ours, just let super.parseOption do its work.</li>
1322
1323 <li>
1324 main - this main is actually simpler than the first example's main.&nbsp;
1325 The first main had to add our generator to the list of generators.&nbsp;
1326 In this example, the factory already did that, so all that this main must
1327 do is instantiate itself and run itself.</li>
1328 </ul>
1329 </ul>
1330
1331 <h2>
1332 <a NAME="Client SSL"></a>Client SSL</h2>
1333 The default pluggable secure socket factory module
1334 (see <a href="#Pluggable APIs">Pluggable APIs</a>)
1335 uses JSSE security.
1336 Review the JSSE documentation for details on
1337 installing, registering, and configuring JSSE for your runtime environment.
1338
1339 </body>
1340 </html>