kwaff 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. data/COPYING +340 -0
  2. data/ChangeLog.txt +118 -0
  3. data/README.txt +96 -0
  4. data/bin/kwaff +131 -0
  5. data/doc/docstyle.css +307 -0
  6. data/doc/examples.html +1283 -0
  7. data/doc/users-guide.html +395 -0
  8. data/examples/Makefile +17 -0
  9. data/examples/ant/Makefile +7 -0
  10. data/examples/ant/build.kwaff +57 -0
  11. data/examples/hibernate/AuctionItem.hbm.kwaff +45 -0
  12. data/examples/hibernate/Bid.hbm.kwaff +42 -0
  13. data/examples/hibernate/Makefile +9 -0
  14. data/examples/hibernate/User.hbm.kwaff +65 -0
  15. data/examples/hibernate/hibernate.cfg.kwaff +17 -0
  16. data/examples/seasar2/Makefile +9 -0
  17. data/examples/seasar2/seasar2.kwaff +62 -0
  18. data/examples/servlet/Makefile +9 -0
  19. data/examples/servlet/web.kwaff +37 -0
  20. data/examples/spring/Makefile +9 -0
  21. data/examples/spring/applicationContext.kwaff +147 -0
  22. data/examples/xhtml/Makefile +9 -0
  23. data/examples/xhtml/README.kwaff +84 -0
  24. data/examples/xi/Makefile +9 -0
  25. data/examples/xi/bbs.kwaff +58 -0
  26. data/lib/kwaff.rb +85 -0
  27. data/lib/kwaff/doctype.rb +124 -0
  28. data/lib/kwaff/doctypes.yaml +138 -0
  29. data/lib/kwaff/errors.rb +26 -0
  30. data/lib/kwaff/node.rb +101 -0
  31. data/lib/kwaff/optparse.rb +101 -0
  32. data/lib/kwaff/orderedhash.rb +56 -0
  33. data/lib/kwaff/parser.rb +342 -0
  34. data/lib/kwaff/rexml.rb +394 -0
  35. data/lib/kwaff/translator.rb +275 -0
  36. data/setup.rb +1331 -0
  37. data/test/ex101.exp +10 -0
  38. data/test/ex101.in +8 -0
  39. data/test/ex102.exp +14 -0
  40. data/test/ex102.in +16 -0
  41. data/test/ex103.exp +13 -0
  42. data/test/ex103.in +13 -0
  43. data/test/ex104.exp +24 -0
  44. data/test/ex104.in +24 -0
  45. data/test/ex105.exp +12 -0
  46. data/test/ex105.in +18 -0
  47. data/test/ex106.exp +22 -0
  48. data/test/ex106.in +21 -0
  49. data/test/ex107.exp +14 -0
  50. data/test/ex107.in +14 -0
  51. data/test/ex111.exp +7 -0
  52. data/test/ex111.in +13 -0
  53. data/test/ex112.exp +15 -0
  54. data/test/ex112.in +16 -0
  55. data/test/ex113.exp +23 -0
  56. data/test/ex113.in +22 -0
  57. data/test/ex114.exp +12 -0
  58. data/test/ex114.in +17 -0
  59. data/test/ex115.exp +9 -0
  60. data/test/ex115.in +12 -0
  61. data/test/ex121.exp +10 -0
  62. data/test/ex121.in +8 -0
  63. data/test/ex122.exp +10 -0
  64. data/test/ex122.in +8 -0
  65. data/test/ex301.exp +13 -0
  66. data/test/ex301.in +14 -0
  67. data/test/ex302.exp +15 -0
  68. data/test/ex302.in +18 -0
  69. data/test/ex303.exp +15 -0
  70. data/test/ex303.in +16 -0
  71. data/test/ex304.exp +17 -0
  72. data/test/ex304.in +15 -0
  73. data/test/ex311.exp +18 -0
  74. data/test/ex311.in +32 -0
  75. data/test/ex312.exp +21 -0
  76. data/test/ex312.in +18 -0
  77. data/test/ex313.exp +20 -0
  78. data/test/ex313.in +33 -0
  79. data/test/ex314.exp +34 -0
  80. data/test/ex314.in +24 -0
  81. data/test/ex801.exp +16 -0
  82. data/test/ex801.in +15 -0
  83. data/test/test.rb +273 -0
  84. data/todo.txt +1 -0
  85. metadata +132 -0
@@ -0,0 +1,1283 @@
1
+ <?xml version="1.0"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
4
+ <html xmlns="http://www.w3.org/1999/xhtml">
5
+ <head>
6
+ <meta http-equiv="Content-Type" content="text/xhtml" />
7
+ <title>Kwaff Examples</title>
8
+ <meta name="generator" content="kwaser" />
9
+ <link rel="stylesheet" href="docstyle.css" type="text/css" />
10
+ <meta http-equiv="Content-Style-Type" content="text/css" />
11
+ </head>
12
+ <body>
13
+
14
+ <div id="mainbody">
15
+
16
+ <!-- BeginEditable "doc_content" -->
17
+ <div id="doc_content">
18
+ <h1 id="doc_title">Kwaff Examples</h1>
19
+ <div id="doc_author">
20
+ last update: $Date: 2005-06-17 12:23:47 +0900 (Fri, 17 Jun 2005) $<br />
21
+ </div>
22
+
23
+ <div class="toc">
24
+ <span>Table of Contents:</span>
25
+ <ul>
26
+ <li><a href="#XHTML">XHTML</a>
27
+ </li>
28
+ <li><a href="#Servlet">Servlet</a>
29
+ </li>
30
+ <li><a href="#Ant">Ant</a>
31
+ </li>
32
+ <li><a href="#Spring">Spring</a>
33
+ </li>
34
+ <li><a href="#Hibernate">Hibernate</a>
35
+ </li>
36
+ <li><a href="#Seasar2">Seasar2</a>
37
+ </li>
38
+ <li><a href="#Xi">Xi</a>
39
+ </li>
40
+ </ul>
41
+ </div>
42
+ <a name="XHTML"></a>
43
+ <h2 class="section1">XHTML</h2>
44
+ <p>README.kwaff
45
+ </p>
46
+ <pre class="program">? encoding = UTF-8
47
+ ? doctype = @xhtml
48
+
49
+ * html
50
+ - lang = en
51
+
52
+ * head
53
+
54
+ * title = README
55
+ * meta
56
+ - http-equiv = Content-Type
57
+ - content = text/xhtml
58
+
59
+ * body
60
+
61
+ * h1 = What is Kwaff?
62
+ * p
63
+ . Kwaff is a simplified and structured data format.
64
+ . See examples directory for detail.
65
+ * p
66
+ . Name of 'Kwaff' is derived from "kwa's friendly formatter".
67
+
68
+ * h1 = Installation
69
+ * p
70
+ . There are two ways to install Kwaff.
71
+ * dl
72
+ * dt = If you can be root user:
73
+ * dd
74
+ * pre = &lt;&lt;&lt;END
75
+ $ ruby setup.rb config
76
+ $ ruby setup.rb setup
77
+ $ su
78
+ # ruby setup.rb install
79
+ END
80
+ * dt = If you cannot be root user:
81
+ * dd
82
+ * pre = &lt;&lt;&lt;END
83
+ ### copy command file to appropriate directory.
84
+ $ cp bin/kwaff $HOME/bin/
85
+ ### copy library files to appropriate directory.
86
+ $ mkdir -p $HOME/lib/ruby
87
+ $ cp -r lib/kwaff* $HOME/lib/ruby
88
+ ### set environment variable RUBYLIB
89
+ $ export RUBYLIB=$HOME/lib/ruby
90
+ END
91
+
92
+ * h1 = Usage
93
+ * p
94
+ . You can convert Kwaff document into XML document.
95
+ * pre
96
+ . $ kwaff example.kwaff &gt; example.xml
97
+ * p
98
+ . You can also convert XML document into Kwaff document.
99
+ * pre
100
+ . $ kwaff -r example.xml &gt; example.kwaff
101
+ * p
102
+ . Type `kwaff -h' for detail.
103
+
104
+ * h1 = Manifest
105
+ * dl
106
+ * dt = README.txt
107
+ * dd = This file.
108
+ * dt = COPYING
109
+ * dd = GPL file.
110
+ * dt = CangeLog.txt
111
+ * dd = Change log file.
112
+ * dt = setup.rb
113
+ * dd = Setup file for installation.
114
+ * dt = bin/kwaff
115
+ * dd = Command file.
116
+ * dt = lib/kwaff.rb, lib/kwaff/*.rb
117
+ * dd = Library file.
118
+ * dt = examples/*
119
+ * dd = Examples of Kwaff.
120
+ * dt = doc/users-guide.html
121
+ * dd = Users' Guide.
122
+ * dt = test/test.rb, test/ex*.*
123
+ * dd = Unit test script and test data.
124
+
125
+ * h1 = License
126
+ * p = GPL (GNU General Public License) ver 2.
127
+
128
+ * h1 = Author
129
+ * p = kwatch &lt;kwa.at.kuwata-lab.com&gt;
130
+ </pre>
131
+ <p>convert:
132
+ </p>
133
+ <pre class="terminal">$ kwaff README.kwaff &gt; README.xhtml
134
+ </pre>
135
+ <p>README.xhtml
136
+ </p>
137
+ <pre class="program">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
138
+ &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
139
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
140
+ &lt;html lang="en"&gt;
141
+
142
+ &lt;head&gt;
143
+
144
+ &lt;title&gt;README&lt;/title&gt;
145
+ &lt;meta http-equiv="Content-Type" content="text/xhtml"/&gt;
146
+
147
+ &lt;/head&gt;
148
+
149
+ &lt;body&gt;
150
+
151
+ &lt;h1&gt;What is Kwaff?&lt;/h1&gt;
152
+ &lt;p&gt;Kwaff is a simplified and structured data format.
153
+ See examples directory for detail.&lt;/p&gt;
154
+ &lt;p&gt;Name of 'Kwaff' is derived from "kwa's friendly formatter".&lt;/p&gt;
155
+
156
+ &lt;h1&gt;Installation&lt;/h1&gt;
157
+ &lt;p&gt;There are two ways to install Kwaff.&lt;/p&gt;
158
+ &lt;dl&gt;
159
+ &lt;dt&gt;If you can be root user:&lt;/dt&gt;
160
+ &lt;dd&gt;
161
+ &lt;pre&gt;$ ruby setup.rb config
162
+ $ ruby setup.rb setup
163
+ $ su
164
+ # ruby setup.rb install&lt;/pre&gt;
165
+ &lt;/dd&gt;
166
+ &lt;dt&gt;If you cannot be root user:&lt;/dt&gt;
167
+ &lt;dd&gt;
168
+ &lt;pre&gt;### copy command file to appropriate directory.
169
+ $ cp bin/kwaff $HOME/bin/
170
+ ### copy library files to appropriate directory.
171
+ $ mkdir -p $HOME/lib/ruby
172
+ $ cp -r lib/kwaff* $HOME/lib/ruby
173
+ ### set environment variable RUBYLIB
174
+ $ export RUBYLIB=$HOME/lib/ruby&lt;/pre&gt;
175
+ &lt;/dd&gt;
176
+ &lt;/dl&gt;
177
+
178
+ &lt;h1&gt;Usage&lt;/h1&gt;
179
+ &lt;p&gt;You can convert Kwaff document into XML document.&lt;/p&gt;
180
+ &lt;pre&gt;$ kwaff example.kwaff &amp;gt; example.xml&lt;/pre&gt;
181
+ &lt;p&gt;You can also convert XML document into Kwaff document.&lt;/p&gt;
182
+ &lt;pre&gt;$ kwaff -r example.xml &amp;gt; example.kwaff&lt;/pre&gt;
183
+ &lt;p&gt;Type `kwaff -h' for detail.&lt;/p&gt;
184
+
185
+ &lt;h1&gt;Manifest&lt;/h1&gt;
186
+ &lt;dl&gt;
187
+ &lt;dt&gt;README.txt&lt;/dt&gt;
188
+ &lt;dd&gt;This file.&lt;/dd&gt;
189
+ &lt;dt&gt;COPYING&lt;/dt&gt;
190
+ &lt;dd&gt;GPL file.&lt;/dd&gt;
191
+ &lt;dt&gt;CangeLog.txt&lt;/dt&gt;
192
+ &lt;dd&gt;Change log file.&lt;/dd&gt;
193
+ &lt;dt&gt;setup.rb&lt;/dt&gt;
194
+ &lt;dd&gt;Setup file for installation.&lt;/dd&gt;
195
+ &lt;dt&gt;bin/kwaff&lt;/dt&gt;
196
+ &lt;dd&gt;Command file.&lt;/dd&gt;
197
+ &lt;dt&gt;lib/kwaff.rb, lib/kwaff/*.rb&lt;/dt&gt;
198
+ &lt;dd&gt;Library file.&lt;/dd&gt;
199
+ &lt;dt&gt;examples/*&lt;/dt&gt;
200
+ &lt;dd&gt;Examples of Kwaff.&lt;/dd&gt;
201
+ &lt;dt&gt;doc/users-guide.html&lt;/dt&gt;
202
+ &lt;dd&gt;Users' Guide.&lt;/dd&gt;
203
+ &lt;dt&gt;test/test.rb, test/ex*.*&lt;/dt&gt;
204
+ &lt;dd&gt;Unit test script and test data.&lt;/dd&gt;
205
+ &lt;/dl&gt;
206
+
207
+ &lt;h1&gt;License&lt;/h1&gt;
208
+ &lt;p&gt;GPL (GNU General Public License) ver 2.&lt;/p&gt;
209
+
210
+ &lt;h1&gt;Author&lt;/h1&gt;
211
+ &lt;p&gt;kwatch &amp;lt;kwa.at.kuwata-lab.com&amp;gt;&lt;/p&gt;
212
+
213
+ &lt;/body&gt;
214
+
215
+ &lt;/html&gt;
216
+ </pre>
217
+
218
+
219
+
220
+ <a name="Servlet"></a>
221
+ <h2 class="section1">Servlet</h2>
222
+ <p>web.kwaff
223
+ </p>
224
+ <pre class="program">//
225
+ // example for web.xml of J2EE Application
226
+ //
227
+ ? encoding = ISO-8859-1
228
+ ? doctype = @web-app23
229
+
230
+ * web-app
231
+
232
+ # Servlet Definition
233
+ * servlet
234
+ * servlet-name = Hello
235
+ * servlet-class = my.HelloServlet
236
+ * init-param
237
+ * param-name = request.encoding
238
+ * param-value = Windows-31J
239
+ * description = encoding of http request
240
+ * servlet
241
+ * servlet-name = action
242
+ * servlet-class = org.apache.struts.action.ActionServlet
243
+ * load-on-startup = 2
244
+
245
+ # Servlet Mappings
246
+ * servlet-mapping
247
+ * servlet-name = Hello
248
+ * url-pattern = /hello
249
+ * servlet-maping
250
+ * servlet-name = action
251
+ * url-pattern = *.do
252
+
253
+ # Taglib
254
+ * taglib
255
+ * taglib-uri = /tags/struts-bean
256
+ * taglib-location = /WEB-INF/struts-bean.tld
257
+ * taglib
258
+ * taglib-uri = /tags/struts-tiles
259
+ * taglib-location = /WEB-INF/struts-tiles.tld
260
+
261
+ </pre>
262
+ <p>convert:
263
+ </p>
264
+ <pre class="terminal">$ kwaff web.kwaff &gt; web.xml
265
+ </pre>
266
+ <p>web.xml
267
+ </p>
268
+ <pre class="program">&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
269
+ &lt;!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
270
+ "http://java.sun.com/dtd/web-app_2_3.dtd"&gt;
271
+ &lt;web-app&gt;
272
+
273
+ &lt;!-- Servlet Definition --&gt;
274
+ &lt;servlet&gt;
275
+ &lt;servlet-name&gt;Hello&lt;/servlet-name&gt;
276
+ &lt;servlet-class&gt;my.HelloServlet&lt;/servlet-class&gt;
277
+ &lt;init-param&gt;
278
+ &lt;param-name&gt;request.encoding&lt;/param-name&gt;
279
+ &lt;param-value&gt;Windows-31J&lt;/param-value&gt;
280
+ &lt;description&gt;encoding of http request&lt;/description&gt;
281
+ &lt;/init-param&gt;
282
+ &lt;/servlet&gt;
283
+ &lt;servlet&gt;
284
+ &lt;servlet-name&gt;action&lt;/servlet-name&gt;
285
+ &lt;servlet-class&gt;org.apache.struts.action.ActionServlet&lt;/servlet-class&gt;
286
+ &lt;load-on-startup&gt;2&lt;/load-on-startup&gt;
287
+ &lt;/servlet&gt;
288
+
289
+ &lt;!-- Servlet Mappings --&gt;
290
+ &lt;servlet-mapping&gt;
291
+ &lt;servlet-name&gt;Hello&lt;/servlet-name&gt;
292
+ &lt;url-pattern&gt;/hello&lt;/url-pattern&gt;
293
+ &lt;/servlet-mapping&gt;
294
+ &lt;servlet-maping&gt;
295
+ &lt;servlet-name&gt;action&lt;/servlet-name&gt;
296
+ &lt;url-pattern&gt;*.do&lt;/url-pattern&gt;
297
+ &lt;/servlet-maping&gt;
298
+
299
+ &lt;!-- Taglib --&gt;
300
+ &lt;taglib&gt;
301
+ &lt;taglib-uri&gt;/tags/struts-bean&lt;/taglib-uri&gt;
302
+ &lt;taglib-location&gt;/WEB-INF/struts-bean.tld&lt;/taglib-location&gt;
303
+ &lt;/taglib&gt;
304
+ &lt;taglib&gt;
305
+ &lt;taglib-uri&gt;/tags/struts-tiles&lt;/taglib-uri&gt;
306
+ &lt;taglib-location&gt;/WEB-INF/struts-tiles.tld&lt;/taglib-location&gt;
307
+ &lt;/taglib&gt;
308
+
309
+ &lt;/web-app&gt;
310
+ </pre>
311
+
312
+
313
+
314
+ <a name="Ant"></a>
315
+ <h2 class="section1">Ant</h2>
316
+ <p>build.kwaff
317
+ </p>
318
+ <pre class="program">//
319
+ // from http://ant.apache.org/manual/using.html#example
320
+ //
321
+ * project
322
+ - name = MyProject
323
+ - default = dist
324
+ - basedir = .
325
+ * description = simple example build file
326
+
327
+ # set global properties for this build
328
+ * property
329
+ - name = src
330
+ - location = src
331
+ * property
332
+ - name = build
333
+ - location = build
334
+ * property
335
+ - name = dist
336
+ - location = dist
337
+
338
+ * target
339
+ - name = init
340
+ # Create the time stamp
341
+ * tstamp
342
+ # Create the build directory structure used by compile
343
+ * mkdir
344
+ - dir = ${build}
345
+
346
+ * target
347
+ - name = compile
348
+ - depends = init
349
+ - description = compile the source
350
+ # Compile the java code from ${src} into ${build}
351
+ * javac
352
+ - srcdir = ${src}
353
+ - destdir = ${build}
354
+
355
+ * target
356
+ - name = dist
357
+ - depends = compile
358
+ - description = generate the distribution
359
+ # Create the distribution directory
360
+ * mkdir
361
+ - dir = ${dist}/lib
362
+ # Put everything in ${build} into the MyProject-${DSTAMP}.jar file
363
+ * jar
364
+ - jarfile = ${dist}/lib/MyProject-${DSTAMP}.jar
365
+ - basedir = ${build}
366
+
367
+ * target
368
+ - name = clean
369
+ - description = clean up
370
+ # Delete the ${build} and ${dist} directory trees
371
+ * delete
372
+ - dir = ${build}
373
+ * delete
374
+ - dir = ${dist}
375
+ </pre>
376
+ <p>convert:
377
+ </p>
378
+ <pre class="terminal">$ kwaff build.kwaff &gt; build.xml
379
+ </pre>
380
+ <p>build.xml
381
+ </p>
382
+ <pre class="program">&lt;?xml version="1.0"?&gt;
383
+ &lt;project name="MyProject" default="dist" basedir="."&gt;
384
+ &lt;description&gt;simple example build file&lt;/description&gt;
385
+
386
+ &lt;!-- set global properties for this build --&gt;
387
+ &lt;property name="src" location="src"/&gt;
388
+ &lt;property name="build" location="build"/&gt;
389
+ &lt;property name="dist" location="dist"/&gt;
390
+
391
+ &lt;target name="init"&gt;
392
+ &lt;!-- Create the time stamp --&gt;
393
+ &lt;tstamp/&gt;
394
+ &lt;!-- Create the build directory structure used by compile --&gt;
395
+ &lt;mkdir dir="${build}"/&gt;
396
+ &lt;/target&gt;
397
+
398
+ &lt;target name="compile" depends="init" description="compile the source"&gt;
399
+ &lt;!-- Compile the java code from ${src} into ${build} --&gt;
400
+ &lt;javac srcdir="${src}" destdir="${build}"/&gt;
401
+ &lt;/target&gt;
402
+
403
+ &lt;target name="dist" depends="compile" description="generate the distribution"&gt;
404
+ &lt;!-- Create the distribution directory --&gt;
405
+ &lt;mkdir dir="${dist}/lib"/&gt;
406
+ &lt;!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file --&gt;
407
+ &lt;jar jarfile="${dist}/lib/MyProject-${DSTAMP}.jar" basedir="${build}"/&gt;
408
+ &lt;/target&gt;
409
+
410
+ &lt;target name="clean" description="clean up"&gt;
411
+ &lt;!-- Delete the ${build} and ${dist} directory trees --&gt;
412
+ &lt;delete dir="${build}"/&gt;
413
+ &lt;delete dir="${dist}"/&gt;
414
+ &lt;/target&gt;
415
+ &lt;/project&gt;
416
+ </pre>
417
+
418
+
419
+
420
+ <a name="Spring"></a>
421
+ <h2 class="section1">Spring</h2>
422
+ <p>applicationContext.kwaff
423
+ </p>
424
+ <pre class="program">//
425
+ // from spring-framework-1.2.1/samples/jpetstore/war/WEB-INF/applicationContext.xml
426
+ //
427
+ ? encoding = UTF-8
428
+ ? doctype = @spring-beans
429
+
430
+ * beans
431
+
432
+ # Application context definition for JPetStore's business layer.
433
+ # Contains bean references to the transaction manager and to the DAOs in
434
+ # dataAccessContext-local/jta.xml (see web.xml's "contextConfigLocation").
435
+
436
+
437
+ # ========================= GENERAL DEFINITIONS =========================
438
+
439
+ # Configurer that replaces ${...} placeholders with values from properties files
440
+ # (in this case, mail and JDBC related properties)
441
+ * bean
442
+ - id = propertyConfigurer
443
+ - class = org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
444
+ * property
445
+ - name = locations
446
+ * list
447
+ * value = WEB-INF/mail.properties
448
+ * value = WEB-INF/jdbc.properties
449
+
450
+ # MailSender used by EmailAdvice
451
+ * bean
452
+ - id = mailSender
453
+ - class = org.springframework.mail.javamail.JavaMailSenderImpl
454
+ * property
455
+ - name = host
456
+ - value = ${mail.host}
457
+
458
+
459
+ # ========================= BUSINESS OBJECT DEFINITIONS ========================
460
+
461
+ # Generic validator for Account objects, to be used for example by the Spring web tier
462
+ * bean
463
+ - id = accountValidator
464
+ - class = org.springframework.samples.jpetstore.domain.logic.AccountValidator
465
+
466
+ # Generic validator for Order objects, to be used for example by the Spring web tier
467
+ * bean
468
+ - id = orderValidator
469
+ - class = org.springframework.samples.jpetstore.domain.logic.OrderValidator
470
+
471
+ # AOP advice used to send confirmation email after order has been submitted
472
+ * bean
473
+ - id = emailAdvice
474
+ - class = org.springframework.samples.jpetstore.domain.logic.SendOrderConfirmationEmailAdvice
475
+ * property
476
+ - name = mailSender
477
+ * ref
478
+ - local = mailSender
479
+
480
+ # Advisor encapsulating email advice
481
+ * bean
482
+ - id = emailAdvisor
483
+ - class = org.springframework.aop.support.RegexpMethodPointcutAdvisor
484
+ * constructor-arg
485
+ * ref
486
+ - local = emailAdvice
487
+ * property
488
+ - name = pattern
489
+ * value = .*insertOrder.*
490
+
491
+ # A parent bean definition which is a base definition for transaction proxies.
492
+ # It's marked as abstract, since it's not supposed to be instantiated itself.
493
+ # We set shared transaction attributes here, following our naming patterns.
494
+ # The attributes can still be overridden in child bean definitions.
495
+ * bean
496
+ - id = baseTransactionProxy
497
+ - class = org.springframework.transaction.interceptor.TransactionProxyFactoryBean
498
+ - abstract = true
499
+ * property
500
+ - name = transactionManager
501
+ * ref
502
+ - bean = transactionManager
503
+ * property
504
+ - name = transactionAttributes
505
+ * props
506
+ * prop = PROPAGATION_REQUIRED
507
+ - key = insert*
508
+ * prop = PROPAGATION_REQUIRED
509
+ - key = update*
510
+ * prop = PROPAGATION_REQUIRED,readOnly
511
+ - key = *
512
+
513
+ # JPetStore primary business object (default implementation), as an inner bean wrapped
514
+ # by an outer transactional proxy. The two bean definitions could have been separate,
515
+ # but this is cleaner as there is no need to ever access the unwrapped object.
516
+ * bean
517
+ - id = petStore
518
+ - parent = baseTransactionProxy
519
+ * property
520
+ - name = target
521
+ * bean
522
+ - class = org.springframework.samples.jpetstore.domain.logic.PetStoreImpl
523
+ * property
524
+ - name = accountDao
525
+ * ref
526
+ - bean = accountDao
527
+ * property
528
+ - name = categoryDao
529
+ * ref
530
+ - bean = categoryDao
531
+ * property
532
+ - name = productDao
533
+ * ref
534
+ - bean = productDao
535
+ * property
536
+ - name = itemDao
537
+ * ref
538
+ - bean = itemDao
539
+ * property
540
+ - name = orderDao
541
+ * ref
542
+ - bean = orderDao
543
+ # Uncomment the following in order to enable mail sending aspect
544
+ * property
545
+ - name = postInterceptors
546
+ * list
547
+ * ref
548
+ - local = emailAdvisor
549
+
550
+
551
+ # ========================= REMOTE EXPORTER DEFINITIONS ========================
552
+
553
+ # RMI exporter for the JPetStore OrderService
554
+ # Commented out by default to avoid conflicts with EJB containers
555
+ * bean
556
+ - id = order-rmi
557
+ - class = org.springframework.remoting.rmi.RmiServiceExporter
558
+ * property
559
+ - name = service
560
+ * ref
561
+ - local = petStore
562
+ * property
563
+ - name = serviceInterface
564
+ * value = org.springframework.samples.jpetstore.domain.logic.OrderService
565
+ * property
566
+ - name = serviceName
567
+ * value = order
568
+ * property
569
+ - name = registryPort
570
+ * value = 1099
571
+ </pre>
572
+ <p>convert:
573
+ </p>
574
+ <pre class="terminal">$ kwaff applicationContext.kwaff &gt; applicationContext.xml
575
+ </pre>
576
+ <p>applicationContext.xml
577
+ </p>
578
+ <pre class="program">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
579
+ &lt;!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
580
+ "http://www.springframework.org/dtd/spring-beans.dtd"&gt;
581
+ &lt;beans&gt;
582
+
583
+ &lt;!-- Application context definition for JPetStore's business layer. --&gt;
584
+ &lt;!-- Contains bean references to the transaction manager and to the DAOs in --&gt;
585
+ &lt;!-- dataAccessContext-local/jta.xml (see web.xml's "contextConfigLocation"). --&gt;
586
+
587
+
588
+ &lt;!-- ========================= GENERAL DEFINITIONS ========================= --&gt;
589
+
590
+ &lt;!-- Configurer that replaces ${...} placeholders with values from properties files --&gt;
591
+ &lt;!-- (in this case, mail and JDBC related properties) --&gt;
592
+ &lt;bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;
593
+ &lt;property name="locations"&gt;
594
+ &lt;list&gt;
595
+ &lt;value&gt;WEB-INF/mail.properties&lt;/value&gt;
596
+ &lt;value&gt;WEB-INF/jdbc.properties&lt;/value&gt;
597
+ &lt;/list&gt;
598
+ &lt;/property&gt;
599
+ &lt;/bean&gt;
600
+
601
+ &lt;!-- MailSender used by EmailAdvice --&gt;
602
+ &lt;bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"&gt;
603
+ &lt;property name="host" value="${mail.host}"/&gt;
604
+ &lt;/bean&gt;
605
+
606
+
607
+ &lt;!-- ========================= BUSINESS OBJECT DEFINITIONS ======================== --&gt;
608
+
609
+ &lt;!-- Generic validator for Account objects, to be used for example by the Spring web tier --&gt;
610
+ &lt;bean id="accountValidator" class="org.springframework.samples.jpetstore.domain.logic.AccountValidator"/&gt;
611
+
612
+ &lt;!-- Generic validator for Order objects, to be used for example by the Spring web tier --&gt;
613
+ &lt;bean id="orderValidator" class="org.springframework.samples.jpetstore.domain.logic.OrderValidator"/&gt;
614
+
615
+ &lt;!-- AOP advice used to send confirmation email after order has been submitted --&gt;
616
+ &lt;bean id="emailAdvice" class="org.springframework.samples.jpetstore.domain.logic.SendOrderConfirmationEmailAdvice"&gt;
617
+ &lt;property name="mailSender"&gt;
618
+ &lt;ref local="mailSender"/&gt;
619
+ &lt;/property&gt;
620
+ &lt;/bean&gt;
621
+
622
+ &lt;!-- Advisor encapsulating email advice --&gt;
623
+ &lt;bean id="emailAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor"&gt;
624
+ &lt;constructor-arg&gt;
625
+ &lt;ref local="emailAdvice"/&gt;
626
+ &lt;/constructor-arg&gt;
627
+ &lt;property name="pattern"&gt;
628
+ &lt;value&gt;.*insertOrder.*&lt;/value&gt;
629
+ &lt;/property&gt;
630
+ &lt;/bean&gt;
631
+
632
+ &lt;!-- A parent bean definition which is a base definition for transaction proxies. --&gt;
633
+ &lt;!-- It's marked as abstract, since it's not supposed to be instantiated itself. --&gt;
634
+ &lt;!-- We set shared transaction attributes here, following our naming patterns. --&gt;
635
+ &lt;!-- The attributes can still be overridden in child bean definitions. --&gt;
636
+ &lt;bean id="baseTransactionProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true"&gt;
637
+ &lt;property name="transactionManager"&gt;
638
+ &lt;ref bean="transactionManager"/&gt;
639
+ &lt;/property&gt;
640
+ &lt;property name="transactionAttributes"&gt;
641
+ &lt;props&gt;
642
+ &lt;prop key="insert*"&gt;PROPAGATION_REQUIRED&lt;/prop&gt;
643
+ &lt;prop key="update*"&gt;PROPAGATION_REQUIRED&lt;/prop&gt;
644
+ &lt;prop key="*"&gt;PROPAGATION_REQUIRED,readOnly&lt;/prop&gt;
645
+ &lt;/props&gt;
646
+ &lt;/property&gt;
647
+ &lt;/bean&gt;
648
+
649
+ &lt;!-- JPetStore primary business object (default implementation), as an inner bean wrapped --&gt;
650
+ &lt;!-- by an outer transactional proxy. The two bean definitions could have been separate, --&gt;
651
+ &lt;!-- but this is cleaner as there is no need to ever access the unwrapped object. --&gt;
652
+ &lt;bean id="petStore" parent="baseTransactionProxy"&gt;
653
+ &lt;property name="target"&gt;
654
+ &lt;bean class="org.springframework.samples.jpetstore.domain.logic.PetStoreImpl"&gt;
655
+ &lt;property name="accountDao"&gt;
656
+ &lt;ref bean="accountDao"/&gt;
657
+ &lt;/property&gt;
658
+ &lt;property name="categoryDao"&gt;
659
+ &lt;ref bean="categoryDao"/&gt;
660
+ &lt;/property&gt;
661
+ &lt;property name="productDao"&gt;
662
+ &lt;ref bean="productDao"/&gt;
663
+ &lt;/property&gt;
664
+ &lt;property name="itemDao"&gt;
665
+ &lt;ref bean="itemDao"/&gt;
666
+ &lt;/property&gt;
667
+ &lt;property name="orderDao"&gt;
668
+ &lt;ref bean="orderDao"/&gt;
669
+ &lt;/property&gt;
670
+ &lt;/bean&gt;
671
+ &lt;/property&gt;
672
+ &lt;!-- Uncomment the following in order to enable mail sending aspect --&gt;
673
+ &lt;property name="postInterceptors"&gt;
674
+ &lt;list&gt;
675
+ &lt;ref local="emailAdvisor"/&gt;
676
+ &lt;/list&gt;
677
+ &lt;/property&gt;
678
+ &lt;/bean&gt;
679
+
680
+
681
+ &lt;!-- ========================= REMOTE EXPORTER DEFINITIONS ======================== --&gt;
682
+
683
+ &lt;!-- RMI exporter for the JPetStore OrderService --&gt;
684
+ &lt;!-- Commented out by default to avoid conflicts with EJB containers --&gt;
685
+ &lt;bean id="order-rmi" class="org.springframework.remoting.rmi.RmiServiceExporter"&gt;
686
+ &lt;property name="service"&gt;
687
+ &lt;ref local="petStore"/&gt;
688
+ &lt;/property&gt;
689
+ &lt;property name="serviceInterface"&gt;
690
+ &lt;value&gt;org.springframework.samples.jpetstore.domain.logic.OrderService&lt;/value&gt;
691
+ &lt;/property&gt;
692
+ &lt;property name="serviceName"&gt;
693
+ &lt;value&gt;order&lt;/value&gt;
694
+ &lt;/property&gt;
695
+ &lt;property name="registryPort"&gt;
696
+ &lt;value&gt;1099&lt;/value&gt;
697
+ &lt;/property&gt;
698
+ &lt;/bean&gt;
699
+
700
+ &lt;/beans&gt;
701
+ </pre>
702
+
703
+
704
+
705
+ <a name="Hibernate"></a>
706
+ <h2 class="section1">Hibernate</h2>
707
+ <p>hibernate.cfg.kwaff
708
+ </p>
709
+ <pre class="program">//
710
+ // source: hibernate-3.0/etc/hibernate.cfg.xml
711
+ //
712
+ ?doctype = @hibernate-configuration30
713
+
714
+ * hibernate-configuration
715
+
716
+ * session-factory
717
+ - name = foo
718
+ * property = true
719
+ - name = show_sql
720
+ * mapping
721
+ - resource = org/hibernate/test/Simple.hbm.xml
722
+ * class-cache
723
+ - usage = read-write
724
+ - class = org.hibernate.test.Simple
725
+ - region = Simple
726
+ </pre>
727
+ <p>User.hbm.kwaff
728
+ </p>
729
+ <pre class="program">//
730
+ // source: hibernate-3.0/eg/org/hibernate/auction/User.hbm.xml
731
+ //
732
+ ? doctype = @hibernate-mapping30
733
+
734
+ * hibernate-mapping
735
+ - package = org.hibernate.auction
736
+
737
+ * class
738
+ - name = User
739
+ - table = AuctionUser
740
+ - lazy = true
741
+ * comment = Users may bid for or sell auction items.
742
+
743
+ * id
744
+ - name = id
745
+ * generator
746
+ - class = native
747
+
748
+ * natural-id
749
+ - mutable = true
750
+ * property
751
+ - name = userName
752
+ - length = 10
753
+
754
+ * property
755
+ - name = password
756
+ - not-null = true
757
+ - length = 15
758
+ - column = `password`
759
+
760
+ * property
761
+ - name = email
762
+
763
+ * component
764
+ - name = name
765
+ * property
766
+ - name = firstName
767
+ - length = 50
768
+ - not-null = true
769
+ * property
770
+ - name = initial
771
+ - column = `initial`
772
+ * property
773
+ - name = lastName
774
+ - length = 50
775
+ - not-null = true
776
+
777
+ * bag
778
+ - name = bids
779
+ - inverse = true
780
+ - cascade = save-update,lock
781
+ * key
782
+ - column = bidder
783
+ * one-to-many
784
+ - class = Bid
785
+
786
+ * bag
787
+ - name = auctions
788
+ - inverse = true
789
+ - cascade = save-update,lock
790
+ * key
791
+ - column = seller
792
+ * one-to-many
793
+ - class = AuctionItem
794
+ </pre>
795
+ <p>Bid.hbm.kwaff
796
+ </p>
797
+ <pre class="program">//
798
+ // source: hibernate-3.0/eg/org/hibernate/auction/Bid.hbm.xml
799
+ //
800
+ ?doctype = @hibernate-mapping30
801
+
802
+ * hibernate-mapping
803
+ - package = org.hibernate.auction
804
+
805
+ * class
806
+ - name = Bid
807
+ - discriminator-value = N
808
+ * comment = A bid or "buy now" for an item.
809
+
810
+ * id
811
+ - name = id
812
+ * generator
813
+ - class = native
814
+
815
+ * discriminator
816
+ - type = char
817
+ * column
818
+ - name = isBuyNow
819
+ * comment = Y if a "buy now", N if a regular bid.
820
+
821
+ * natural-id
822
+ * many-to-one
823
+ - name = item
824
+ * property
825
+ - name = amount
826
+
827
+ * property
828
+ - name = datetime
829
+ - not-null = true
830
+ - column = `datetime`
831
+
832
+ * many-to-one
833
+ - name = bidder
834
+ - not-null = true
835
+
836
+ * subclass
837
+ - name = BuyNow
838
+ - discriminator-value = Y
839
+ </pre>
840
+ <p>AuctionItem.hbm.kwaff
841
+ </p>
842
+ <pre class="program">//
843
+ // source: hibernate-3.0/eg/org/hibernate/auction/AuctionItem.hbm.xml
844
+ //
845
+ ?doctype = @hibernate-mapping30
846
+
847
+ * hibernate-mapping
848
+ - package = org.hibernate.auction
849
+
850
+ * import
851
+ - class = AuctionInfo
852
+
853
+ * class
854
+ - name = AuctionItem
855
+ * comment = An item that is being auctioned.
856
+
857
+ * id
858
+ - name = id
859
+ * generator
860
+ - class = native
861
+
862
+ * natural-id
863
+ * many-to-one
864
+ - name = seller
865
+ * property
866
+ - name = description
867
+ - length = 200
868
+
869
+ * property
870
+ - name = ends
871
+
872
+ * property
873
+ - name = condition
874
+
875
+ * many-to-one
876
+ - name = successfulBid
877
+ - outer-join = false
878
+
879
+ * bag
880
+ - name = bids
881
+ - cascade = all
882
+ - inverse = true
883
+ * key
884
+ - column = item
885
+ * one-to-many
886
+ - class = Bid
887
+ </pre>
888
+ <p>convert:
889
+ </p>
890
+ <pre class="terminal">$ kwaff hibernate.cfg.kwaff &gt; hibernate.cfg.xml
891
+ $ kwaff User.hbm.kwaff &gt; User.hbm.xml
892
+ $ kwaff Bid.hbm.kwaff &gt; Bid.hbm.xml
893
+ $ kwaff AuctionItem.hbm.kwaff &gt; AuctionItem.hbm.xml
894
+ </pre>
895
+ <p>hibernate.cfg.xml
896
+ </p>
897
+ <pre class="program">&lt;?xml version="1.0"?&gt;
898
+ &lt;!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
899
+ "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt;
900
+ &lt;hibernate-configuration&gt;
901
+
902
+ &lt;session-factory name="foo"&gt;
903
+ &lt;property name="show_sql"&gt;true&lt;/property&gt;
904
+ &lt;mapping resource="org/hibernate/test/Simple.hbm.xml"/&gt;
905
+ &lt;class-cache usage="read-write" class="org.hibernate.test.Simple" region="Simple"/&gt;
906
+ &lt;/session-factory&gt;
907
+
908
+ &lt;/hibernate-configuration&gt;
909
+ </pre>
910
+ <p>User.hbm.xml
911
+ </p>
912
+ <pre class="program">&lt;?xml version="1.0"?&gt;
913
+ &lt;!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
914
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"&gt;
915
+ &lt;hibernate-mapping package="org.hibernate.auction"&gt;
916
+
917
+ &lt;class name="User" table="AuctionUser" lazy="true"&gt;
918
+ &lt;comment&gt;Users may bid for or sell auction items.&lt;/comment&gt;
919
+
920
+ &lt;id name="id"&gt;
921
+ &lt;generator class="native"/&gt;
922
+ &lt;/id&gt;
923
+
924
+ &lt;natural-id mutable="true"&gt;
925
+ &lt;property name="userName" length="10"/&gt;
926
+ &lt;/natural-id&gt;
927
+
928
+ &lt;property name="password" not-null="true" length="15" column="`password`"/&gt;
929
+
930
+ &lt;property name="email"/&gt;
931
+
932
+ &lt;component name="name"&gt;
933
+ &lt;property name="firstName" length="50" not-null="true"/&gt;
934
+ &lt;property name="initial" column="`initial`"/&gt;
935
+ &lt;property name="lastName" length="50" not-null="true"/&gt;
936
+ &lt;/component&gt;
937
+
938
+ &lt;bag name="bids" inverse="true" cascade="save-update,lock"&gt;
939
+ &lt;key column="bidder"/&gt;
940
+ &lt;one-to-many class="Bid"/&gt;
941
+ &lt;/bag&gt;
942
+
943
+ &lt;bag name="auctions" inverse="true" cascade="save-update,lock"&gt;
944
+ &lt;key column="seller"/&gt;
945
+ &lt;one-to-many class="AuctionItem"/&gt;
946
+ &lt;/bag&gt;
947
+ &lt;/class&gt;
948
+
949
+ &lt;/hibernate-mapping&gt;
950
+ </pre>
951
+ <p>Bid.hbm.xml
952
+ </p>
953
+ <pre class="program">&lt;?xml version="1.0"?&gt;
954
+ &lt;!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
955
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"&gt;
956
+ &lt;hibernate-mapping package="org.hibernate.auction"&gt;
957
+
958
+ &lt;class name="Bid" discriminator-value="N"&gt;
959
+ &lt;comment&gt;A bid or "buy now" for an item.&lt;/comment&gt;
960
+
961
+ &lt;id name="id"&gt;
962
+ &lt;generator class="native"/&gt;
963
+ &lt;/id&gt;
964
+
965
+ &lt;discriminator type="char"&gt;
966
+ &lt;column name="isBuyNow"&gt;
967
+ &lt;comment&gt;Y if a "buy now", N if a regular bid.&lt;/comment&gt;
968
+ &lt;/column&gt;
969
+ &lt;/discriminator&gt;
970
+
971
+ &lt;natural-id&gt;
972
+ &lt;many-to-one name="item"/&gt;
973
+ &lt;property name="amount"/&gt;
974
+ &lt;/natural-id&gt;
975
+
976
+ &lt;property name="datetime" not-null="true" column="`datetime`"/&gt;
977
+
978
+ &lt;many-to-one name="bidder" not-null="true"/&gt;
979
+
980
+ &lt;subclass name="BuyNow" discriminator-value="Y"/&gt;
981
+ &lt;/class&gt;
982
+
983
+ &lt;/hibernate-mapping&gt;
984
+ </pre>
985
+ <p>AuctionItem.hbm.xml
986
+ </p>
987
+ <pre class="program">&lt;?xml version="1.0"?&gt;
988
+ &lt;!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
989
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"&gt;
990
+ &lt;hibernate-mapping package="org.hibernate.auction"&gt;
991
+
992
+ &lt;import class="AuctionInfo"/&gt;
993
+
994
+ &lt;class name="AuctionItem"&gt;
995
+ &lt;comment&gt;An item that is being auctioned.&lt;/comment&gt;
996
+
997
+ &lt;id name="id"&gt;
998
+ &lt;generator class="native"/&gt;
999
+ &lt;/id&gt;
1000
+
1001
+ &lt;natural-id&gt;
1002
+ &lt;many-to-one name="seller"/&gt;
1003
+ &lt;property name="description" length="200"/&gt;
1004
+ &lt;/natural-id&gt;
1005
+
1006
+ &lt;property name="ends"/&gt;
1007
+
1008
+ &lt;property name="condition"/&gt;
1009
+
1010
+ &lt;many-to-one name="successfulBid" outer-join="false"/&gt;
1011
+
1012
+ &lt;bag name="bids" cascade="all" inverse="true"&gt;
1013
+ &lt;key column="item"/&gt;
1014
+ &lt;one-to-many class="Bid"/&gt;
1015
+ &lt;/bag&gt;
1016
+ &lt;/class&gt;
1017
+
1018
+ &lt;/hibernate-mapping&gt;
1019
+ </pre>
1020
+
1021
+
1022
+
1023
+ <a name="Seasar2"></a>
1024
+ <h2 class="section1">Seasar2</h2>
1025
+ <p>seasar2.kwaff
1026
+ </p>
1027
+ <pre class="program">//
1028
+ // from http://www.seasar.org/DIContainer.html#Example
1029
+ //
1030
+ ? encoding = Shift_JIS
1031
+ ? doctype = @seasar2
1032
+
1033
+ * components
1034
+
1035
+ # constructor injection
1036
+ * component
1037
+ - name = hello
1038
+ - class = examples.dicon.HelloConstructorInjection
1039
+ * arg = "Hello World!"
1040
+
1041
+ # setter injection
1042
+ * component
1043
+ - class = examples.dicon.HelloSetterInjection
1044
+ * property = "Hello World!"
1045
+ - name = message
1046
+
1047
+ # method injection
1048
+ * component
1049
+ - class = examples.dicon.HelloMethodInjection
1050
+ * initMethod
1051
+ - name = addMessage
1052
+ * arg = "Hello "
1053
+ * initMethod = #self.addMessage("World!")
1054
+
1055
+ # auto binding with constructor injection
1056
+ * component
1057
+ - class = java.util.HashMap
1058
+ * initMethod
1059
+ - name = put
1060
+ * arg = "hello"
1061
+ * arg = "Hello World!"
1062
+ * component
1063
+ - autoBinding = auto
1064
+ - class = examples.dicon.autobinding.AutoHelloConstructorInjection
1065
+
1066
+ # auto binding with setter injection
1067
+ * component
1068
+ - class = java.util.HashMap
1069
+ * initMethod
1070
+ - name = put
1071
+ * arg = "hello"
1072
+ * arg = "Hello World!"
1073
+ * component
1074
+ - autoBinding = auto
1075
+ - class = examples.dicon.autobinding.AutoHelloSetterInjection
1076
+
1077
+ # AOP
1078
+ * component
1079
+ - name = traceInterceptor
1080
+ - class = org.seasar.framework.aop.interceptors.TraceInterceptor
1081
+ * component
1082
+ - class = java.util.ArrayList
1083
+ * aspect = traceInterceptor
1084
+ * component
1085
+ - class = java.util.Date
1086
+ * arg = 0
1087
+ * aspect = traceInterceptor
1088
+ - pointcut = getTime, hashCode
1089
+ </pre>
1090
+ <p>convert:
1091
+ </p>
1092
+ <pre class="terminal">$ kwaff seasar2.kwaff &gt; seasar2.dicon
1093
+ </pre>
1094
+ <p>seasar2.dicon
1095
+ </p>
1096
+ <pre class="program">&lt;?xml version="1.0" encoding="Shift_JIS"?&gt;
1097
+ &lt;!DOCTYPE components PUBLIC "-//SEASAR2.1//DTD S2Container//EN"
1098
+ "http://www.seasar.org/dtd/components21.dtd"&gt;
1099
+ &lt;components&gt;
1100
+
1101
+ &lt;!-- constructor injection --&gt;
1102
+ &lt;component name="hello" class="examples.dicon.HelloConstructorInjection"&gt;
1103
+ &lt;arg&gt;"Hello World!"&lt;/arg&gt;
1104
+ &lt;/component&gt;
1105
+
1106
+ &lt;!-- setter injection --&gt;
1107
+ &lt;component class="examples.dicon.HelloSetterInjection"&gt;
1108
+ &lt;property name="message"&gt;"Hello World!"&lt;/property&gt;
1109
+ &lt;/component&gt;
1110
+
1111
+ &lt;!-- method injection --&gt;
1112
+ &lt;component class="examples.dicon.HelloMethodInjection"&gt;
1113
+ &lt;initMethod name="addMessage"&gt;
1114
+ &lt;arg&gt;"Hello "&lt;/arg&gt;
1115
+ &lt;/initMethod&gt;
1116
+ &lt;initMethod&gt;#self.addMessage("World!")&lt;/initMethod&gt;
1117
+ &lt;/component&gt;
1118
+
1119
+ &lt;!-- auto binding with constructor injection --&gt;
1120
+ &lt;component class="java.util.HashMap"&gt;
1121
+ &lt;initMethod name="put"&gt;
1122
+ &lt;arg&gt;"hello"&lt;/arg&gt;
1123
+ &lt;arg&gt;"Hello World!"&lt;/arg&gt;
1124
+ &lt;/initMethod&gt;
1125
+ &lt;/component&gt;
1126
+ &lt;component autoBinding="auto" class="examples.dicon.autobinding.AutoHelloConstructorInjection"/&gt;
1127
+
1128
+ &lt;!-- auto binding with setter injection --&gt;
1129
+ &lt;component class="java.util.HashMap"&gt;
1130
+ &lt;initMethod name="put"&gt;
1131
+ &lt;arg&gt;"hello"&lt;/arg&gt;
1132
+ &lt;arg&gt;"Hello World!"&lt;/arg&gt;
1133
+ &lt;/initMethod&gt;
1134
+ &lt;/component&gt;
1135
+ &lt;component autoBinding="auto" class="examples.dicon.autobinding.AutoHelloSetterInjection"/&gt;
1136
+
1137
+ &lt;!-- AOP --&gt;
1138
+ &lt;component name="traceInterceptor" class="org.seasar.framework.aop.interceptors.TraceInterceptor"/&gt;
1139
+ &lt;component class="java.util.ArrayList"&gt;
1140
+ &lt;aspect&gt;traceInterceptor&lt;/aspect&gt;
1141
+ &lt;/component&gt;
1142
+ &lt;component class="java.util.Date"&gt;
1143
+ &lt;arg&gt;0&lt;/arg&gt;
1144
+ &lt;aspect pointcut="getTime, hashCode"&gt;traceInterceptor&lt;/aspect&gt;
1145
+ &lt;/component&gt;
1146
+
1147
+ &lt;/components&gt;
1148
+ </pre>
1149
+
1150
+
1151
+
1152
+ <a name="Xi"></a>
1153
+ <h2 class="section1">Xi</h2>
1154
+ <p>bbs.kwaff
1155
+ </p>
1156
+ <pre class="program">//
1157
+ // from http://dock.baykit.org/xi13?Tutorial
1158
+ //
1159
+
1160
+ * xi:program
1161
+ - xmlns:xi = http://www.baykit.org/Xi/1.1
1162
+
1163
+ # declare variable 'BBS-DATA' with initial data
1164
+ * xi:variable
1165
+ - name = BBS-DATA
1166
+ * bbs
1167
+ * message = Welcom to mini-bbs
1168
+
1169
+ # if file 'bbs.xml' is exists, then load it into 'BBS-DATA'
1170
+ * xi:if
1171
+ - test = $FS.exists('bbs.xml')
1172
+ * xi:set
1173
+ - out = $BBS-DATA
1174
+ - select = $IO.loadXml('bbs.xml')
1175
+
1176
+ # if new_message is on param, add it to end of BBS-DATA
1177
+ * xi:if
1178
+ - test = $Web.parameters.new_message != ''
1179
+ * xi:set
1180
+ - out = $BBS-DATA
1181
+ * bbs
1182
+ * xi:copy-of
1183
+ - select = $BBS-DATA/bbs/*
1184
+ * message
1185
+ * xi:value-of
1186
+ - select = $Web.parameters.new_message
1187
+ * xi:exec
1188
+ - select = $IO.saveXml('bbs.xml', $BBS-DATA)
1189
+
1190
+ * HTML
1191
+ * BODY
1192
+
1193
+ # display bbs message.
1194
+ * UL
1195
+ * xi:for-each
1196
+ - item = message
1197
+ - select = $BBS-DATA/bbs/*
1198
+ * LI
1199
+ * xi:value-of
1200
+ - select = $message
1201
+
1202
+ # FORM for posting bbs message.
1203
+ * HR
1204
+ * FORM
1205
+ - METHOD = post
1206
+ - ACTION = bbs.xi
1207
+ .
1208
+ . Message to post:
1209
+ * BR
1210
+ * TEXTAREA
1211
+ - NAME = new_message
1212
+ * INPUT
1213
+ - TYPE = submit
1214
+ </pre>
1215
+ <p>convert:
1216
+ </p>
1217
+ <pre class="terminal">$ kwaff bbs.kwaff &gt; bbs.xi
1218
+ </pre>
1219
+ <p>bbs.xi
1220
+ </p>
1221
+ <pre class="program">&lt;?xml version="1.0"?&gt;
1222
+ &lt;xi:program xmlns:xi="http://www.baykit.org/Xi/1.1"&gt;
1223
+
1224
+ &lt;!-- declare variable 'BBS-DATA' with initial data --&gt;
1225
+ &lt;xi:variable name="BBS-DATA"&gt;
1226
+ &lt;bbs&gt;
1227
+ &lt;message&gt;Welcom to mini-bbs&lt;/message&gt;
1228
+ &lt;/bbs&gt;
1229
+ &lt;/xi:variable&gt;
1230
+
1231
+ &lt;!-- if file 'bbs.xml' is exists, then load it into 'BBS-DATA' --&gt;
1232
+ &lt;xi:if test="$FS.exists('bbs.xml')"&gt;
1233
+ &lt;xi:set out="$BBS-DATA" select="$IO.loadXml('bbs.xml')"/&gt;
1234
+ &lt;/xi:if&gt;
1235
+
1236
+ &lt;!-- if new_message is on param, add it to end of BBS-DATA --&gt;
1237
+ &lt;xi:if test="$Web.parameters.new_message != ''"&gt;
1238
+ &lt;xi:set out="$BBS-DATA"&gt;
1239
+ &lt;bbs&gt;
1240
+ &lt;xi:copy-of select="$BBS-DATA/bbs/*"/&gt;
1241
+ &lt;message&gt;
1242
+ &lt;xi:value-of select="$Web.parameters.new_message"/&gt;
1243
+ &lt;/message&gt;
1244
+ &lt;/bbs&gt;
1245
+ &lt;/xi:set&gt;
1246
+ &lt;xi:exec select="$IO.saveXml('bbs.xml', $BBS-DATA)"/&gt;
1247
+ &lt;/xi:if&gt;
1248
+
1249
+ &lt;HTML&gt;
1250
+ &lt;BODY&gt;
1251
+
1252
+ &lt;!-- display bbs message. --&gt;
1253
+ &lt;UL&gt;
1254
+ &lt;xi:for-each item="message" select="$BBS-DATA/bbs/*"&gt;
1255
+ &lt;LI&gt;
1256
+ &lt;xi:value-of select="$message"/&gt;
1257
+ &lt;/LI&gt;
1258
+ &lt;/xi:for-each&gt;
1259
+ &lt;/UL&gt;
1260
+
1261
+ &lt;!-- FORM for posting bbs message. --&gt;
1262
+ &lt;HR/&gt;
1263
+ &lt;FORM METHOD="post" ACTION="bbs.xi"&gt;
1264
+ Message to post: &lt;BR/&gt;
1265
+ &lt;TEXTAREA NAME="new_message"/&gt;
1266
+ &lt;INPUT TYPE="submit"/&gt;
1267
+ &lt;/FORM&gt;
1268
+
1269
+ &lt;/BODY&gt;
1270
+ &lt;/HTML&gt;
1271
+
1272
+ &lt;/xi:program&gt;
1273
+ </pre>
1274
+
1275
+
1276
+
1277
+
1278
+ </div>
1279
+ <!-- EndEditable "doc_content" -->
1280
+ </div>
1281
+
1282
+ </body>
1283
+ </html>