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.
- data/COPYING +340 -0
- data/ChangeLog.txt +118 -0
- data/README.txt +96 -0
- data/bin/kwaff +131 -0
- data/doc/docstyle.css +307 -0
- data/doc/examples.html +1283 -0
- data/doc/users-guide.html +395 -0
- data/examples/Makefile +17 -0
- data/examples/ant/Makefile +7 -0
- data/examples/ant/build.kwaff +57 -0
- data/examples/hibernate/AuctionItem.hbm.kwaff +45 -0
- data/examples/hibernate/Bid.hbm.kwaff +42 -0
- data/examples/hibernate/Makefile +9 -0
- data/examples/hibernate/User.hbm.kwaff +65 -0
- data/examples/hibernate/hibernate.cfg.kwaff +17 -0
- data/examples/seasar2/Makefile +9 -0
- data/examples/seasar2/seasar2.kwaff +62 -0
- data/examples/servlet/Makefile +9 -0
- data/examples/servlet/web.kwaff +37 -0
- data/examples/spring/Makefile +9 -0
- data/examples/spring/applicationContext.kwaff +147 -0
- data/examples/xhtml/Makefile +9 -0
- data/examples/xhtml/README.kwaff +84 -0
- data/examples/xi/Makefile +9 -0
- data/examples/xi/bbs.kwaff +58 -0
- data/lib/kwaff.rb +85 -0
- data/lib/kwaff/doctype.rb +124 -0
- data/lib/kwaff/doctypes.yaml +138 -0
- data/lib/kwaff/errors.rb +26 -0
- data/lib/kwaff/node.rb +101 -0
- data/lib/kwaff/optparse.rb +101 -0
- data/lib/kwaff/orderedhash.rb +56 -0
- data/lib/kwaff/parser.rb +342 -0
- data/lib/kwaff/rexml.rb +394 -0
- data/lib/kwaff/translator.rb +275 -0
- data/setup.rb +1331 -0
- data/test/ex101.exp +10 -0
- data/test/ex101.in +8 -0
- data/test/ex102.exp +14 -0
- data/test/ex102.in +16 -0
- data/test/ex103.exp +13 -0
- data/test/ex103.in +13 -0
- data/test/ex104.exp +24 -0
- data/test/ex104.in +24 -0
- data/test/ex105.exp +12 -0
- data/test/ex105.in +18 -0
- data/test/ex106.exp +22 -0
- data/test/ex106.in +21 -0
- data/test/ex107.exp +14 -0
- data/test/ex107.in +14 -0
- data/test/ex111.exp +7 -0
- data/test/ex111.in +13 -0
- data/test/ex112.exp +15 -0
- data/test/ex112.in +16 -0
- data/test/ex113.exp +23 -0
- data/test/ex113.in +22 -0
- data/test/ex114.exp +12 -0
- data/test/ex114.in +17 -0
- data/test/ex115.exp +9 -0
- data/test/ex115.in +12 -0
- data/test/ex121.exp +10 -0
- data/test/ex121.in +8 -0
- data/test/ex122.exp +10 -0
- data/test/ex122.in +8 -0
- data/test/ex301.exp +13 -0
- data/test/ex301.in +14 -0
- data/test/ex302.exp +15 -0
- data/test/ex302.in +18 -0
- data/test/ex303.exp +15 -0
- data/test/ex303.in +16 -0
- data/test/ex304.exp +17 -0
- data/test/ex304.in +15 -0
- data/test/ex311.exp +18 -0
- data/test/ex311.in +32 -0
- data/test/ex312.exp +21 -0
- data/test/ex312.in +18 -0
- data/test/ex313.exp +20 -0
- data/test/ex313.in +33 -0
- data/test/ex314.exp +34 -0
- data/test/ex314.in +24 -0
- data/test/ex801.exp +16 -0
- data/test/ex801.in +15 -0
- data/test/test.rb +273 -0
- data/todo.txt +1 -0
- metadata +132 -0
data/doc/examples.html
ADDED
@@ -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 = <<<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 = <<<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 > example.xml
|
97
|
+
* p
|
98
|
+
. You can also convert XML document into Kwaff document.
|
99
|
+
* pre
|
100
|
+
. $ kwaff -r example.xml > 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 <kwa.at.kuwata-lab.com>
|
130
|
+
</pre>
|
131
|
+
<p>convert:
|
132
|
+
</p>
|
133
|
+
<pre class="terminal">$ kwaff README.kwaff > README.xhtml
|
134
|
+
</pre>
|
135
|
+
<p>README.xhtml
|
136
|
+
</p>
|
137
|
+
<pre class="program"><?xml version="1.0" encoding="UTF-8"?>
|
138
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
139
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
140
|
+
<html lang="en">
|
141
|
+
|
142
|
+
<head>
|
143
|
+
|
144
|
+
<title>README</title>
|
145
|
+
<meta http-equiv="Content-Type" content="text/xhtml"/>
|
146
|
+
|
147
|
+
</head>
|
148
|
+
|
149
|
+
<body>
|
150
|
+
|
151
|
+
<h1>What is Kwaff?</h1>
|
152
|
+
<p>Kwaff is a simplified and structured data format.
|
153
|
+
See examples directory for detail.</p>
|
154
|
+
<p>Name of 'Kwaff' is derived from "kwa's friendly formatter".</p>
|
155
|
+
|
156
|
+
<h1>Installation</h1>
|
157
|
+
<p>There are two ways to install Kwaff.</p>
|
158
|
+
<dl>
|
159
|
+
<dt>If you can be root user:</dt>
|
160
|
+
<dd>
|
161
|
+
<pre>$ ruby setup.rb config
|
162
|
+
$ ruby setup.rb setup
|
163
|
+
$ su
|
164
|
+
# ruby setup.rb install</pre>
|
165
|
+
</dd>
|
166
|
+
<dt>If you cannot be root user:</dt>
|
167
|
+
<dd>
|
168
|
+
<pre>### 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</pre>
|
175
|
+
</dd>
|
176
|
+
</dl>
|
177
|
+
|
178
|
+
<h1>Usage</h1>
|
179
|
+
<p>You can convert Kwaff document into XML document.</p>
|
180
|
+
<pre>$ kwaff example.kwaff &gt; example.xml</pre>
|
181
|
+
<p>You can also convert XML document into Kwaff document.</p>
|
182
|
+
<pre>$ kwaff -r example.xml &gt; example.kwaff</pre>
|
183
|
+
<p>Type `kwaff -h' for detail.</p>
|
184
|
+
|
185
|
+
<h1>Manifest</h1>
|
186
|
+
<dl>
|
187
|
+
<dt>README.txt</dt>
|
188
|
+
<dd>This file.</dd>
|
189
|
+
<dt>COPYING</dt>
|
190
|
+
<dd>GPL file.</dd>
|
191
|
+
<dt>CangeLog.txt</dt>
|
192
|
+
<dd>Change log file.</dd>
|
193
|
+
<dt>setup.rb</dt>
|
194
|
+
<dd>Setup file for installation.</dd>
|
195
|
+
<dt>bin/kwaff</dt>
|
196
|
+
<dd>Command file.</dd>
|
197
|
+
<dt>lib/kwaff.rb, lib/kwaff/*.rb</dt>
|
198
|
+
<dd>Library file.</dd>
|
199
|
+
<dt>examples/*</dt>
|
200
|
+
<dd>Examples of Kwaff.</dd>
|
201
|
+
<dt>doc/users-guide.html</dt>
|
202
|
+
<dd>Users' Guide.</dd>
|
203
|
+
<dt>test/test.rb, test/ex*.*</dt>
|
204
|
+
<dd>Unit test script and test data.</dd>
|
205
|
+
</dl>
|
206
|
+
|
207
|
+
<h1>License</h1>
|
208
|
+
<p>GPL (GNU General Public License) ver 2.</p>
|
209
|
+
|
210
|
+
<h1>Author</h1>
|
211
|
+
<p>kwatch &lt;kwa.at.kuwata-lab.com&gt;</p>
|
212
|
+
|
213
|
+
</body>
|
214
|
+
|
215
|
+
</html>
|
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 > web.xml
|
265
|
+
</pre>
|
266
|
+
<p>web.xml
|
267
|
+
</p>
|
268
|
+
<pre class="program"><?xml version="1.0" encoding="ISO-8859-1"?>
|
269
|
+
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
|
270
|
+
"http://java.sun.com/dtd/web-app_2_3.dtd">
|
271
|
+
<web-app>
|
272
|
+
|
273
|
+
<!-- Servlet Definition -->
|
274
|
+
<servlet>
|
275
|
+
<servlet-name>Hello</servlet-name>
|
276
|
+
<servlet-class>my.HelloServlet</servlet-class>
|
277
|
+
<init-param>
|
278
|
+
<param-name>request.encoding</param-name>
|
279
|
+
<param-value>Windows-31J</param-value>
|
280
|
+
<description>encoding of http request</description>
|
281
|
+
</init-param>
|
282
|
+
</servlet>
|
283
|
+
<servlet>
|
284
|
+
<servlet-name>action</servlet-name>
|
285
|
+
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
|
286
|
+
<load-on-startup>2</load-on-startup>
|
287
|
+
</servlet>
|
288
|
+
|
289
|
+
<!-- Servlet Mappings -->
|
290
|
+
<servlet-mapping>
|
291
|
+
<servlet-name>Hello</servlet-name>
|
292
|
+
<url-pattern>/hello</url-pattern>
|
293
|
+
</servlet-mapping>
|
294
|
+
<servlet-maping>
|
295
|
+
<servlet-name>action</servlet-name>
|
296
|
+
<url-pattern>*.do</url-pattern>
|
297
|
+
</servlet-maping>
|
298
|
+
|
299
|
+
<!-- Taglib -->
|
300
|
+
<taglib>
|
301
|
+
<taglib-uri>/tags/struts-bean</taglib-uri>
|
302
|
+
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
|
303
|
+
</taglib>
|
304
|
+
<taglib>
|
305
|
+
<taglib-uri>/tags/struts-tiles</taglib-uri>
|
306
|
+
<taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
|
307
|
+
</taglib>
|
308
|
+
|
309
|
+
</web-app>
|
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 > build.xml
|
379
|
+
</pre>
|
380
|
+
<p>build.xml
|
381
|
+
</p>
|
382
|
+
<pre class="program"><?xml version="1.0"?>
|
383
|
+
<project name="MyProject" default="dist" basedir=".">
|
384
|
+
<description>simple example build file</description>
|
385
|
+
|
386
|
+
<!-- set global properties for this build -->
|
387
|
+
<property name="src" location="src"/>
|
388
|
+
<property name="build" location="build"/>
|
389
|
+
<property name="dist" location="dist"/>
|
390
|
+
|
391
|
+
<target name="init">
|
392
|
+
<!-- Create the time stamp -->
|
393
|
+
<tstamp/>
|
394
|
+
<!-- Create the build directory structure used by compile -->
|
395
|
+
<mkdir dir="${build}"/>
|
396
|
+
</target>
|
397
|
+
|
398
|
+
<target name="compile" depends="init" description="compile the source">
|
399
|
+
<!-- Compile the java code from ${src} into ${build} -->
|
400
|
+
<javac srcdir="${src}" destdir="${build}"/>
|
401
|
+
</target>
|
402
|
+
|
403
|
+
<target name="dist" depends="compile" description="generate the distribution">
|
404
|
+
<!-- Create the distribution directory -->
|
405
|
+
<mkdir dir="${dist}/lib"/>
|
406
|
+
<!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
|
407
|
+
<jar jarfile="${dist}/lib/MyProject-${DSTAMP}.jar" basedir="${build}"/>
|
408
|
+
</target>
|
409
|
+
|
410
|
+
<target name="clean" description="clean up">
|
411
|
+
<!-- Delete the ${build} and ${dist} directory trees -->
|
412
|
+
<delete dir="${build}"/>
|
413
|
+
<delete dir="${dist}"/>
|
414
|
+
</target>
|
415
|
+
</project>
|
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 > applicationContext.xml
|
575
|
+
</pre>
|
576
|
+
<p>applicationContext.xml
|
577
|
+
</p>
|
578
|
+
<pre class="program"><?xml version="1.0" encoding="UTF-8"?>
|
579
|
+
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
|
580
|
+
"http://www.springframework.org/dtd/spring-beans.dtd">
|
581
|
+
<beans>
|
582
|
+
|
583
|
+
<!-- Application context definition for JPetStore's business layer. -->
|
584
|
+
<!-- Contains bean references to the transaction manager and to the DAOs in -->
|
585
|
+
<!-- dataAccessContext-local/jta.xml (see web.xml's "contextConfigLocation"). -->
|
586
|
+
|
587
|
+
|
588
|
+
<!-- ========================= GENERAL DEFINITIONS ========================= -->
|
589
|
+
|
590
|
+
<!-- Configurer that replaces ${...} placeholders with values from properties files -->
|
591
|
+
<!-- (in this case, mail and JDBC related properties) -->
|
592
|
+
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
593
|
+
<property name="locations">
|
594
|
+
<list>
|
595
|
+
<value>WEB-INF/mail.properties</value>
|
596
|
+
<value>WEB-INF/jdbc.properties</value>
|
597
|
+
</list>
|
598
|
+
</property>
|
599
|
+
</bean>
|
600
|
+
|
601
|
+
<!-- MailSender used by EmailAdvice -->
|
602
|
+
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
|
603
|
+
<property name="host" value="${mail.host}"/>
|
604
|
+
</bean>
|
605
|
+
|
606
|
+
|
607
|
+
<!-- ========================= BUSINESS OBJECT DEFINITIONS ======================== -->
|
608
|
+
|
609
|
+
<!-- Generic validator for Account objects, to be used for example by the Spring web tier -->
|
610
|
+
<bean id="accountValidator" class="org.springframework.samples.jpetstore.domain.logic.AccountValidator"/>
|
611
|
+
|
612
|
+
<!-- Generic validator for Order objects, to be used for example by the Spring web tier -->
|
613
|
+
<bean id="orderValidator" class="org.springframework.samples.jpetstore.domain.logic.OrderValidator"/>
|
614
|
+
|
615
|
+
<!-- AOP advice used to send confirmation email after order has been submitted -->
|
616
|
+
<bean id="emailAdvice" class="org.springframework.samples.jpetstore.domain.logic.SendOrderConfirmationEmailAdvice">
|
617
|
+
<property name="mailSender">
|
618
|
+
<ref local="mailSender"/>
|
619
|
+
</property>
|
620
|
+
</bean>
|
621
|
+
|
622
|
+
<!-- Advisor encapsulating email advice -->
|
623
|
+
<bean id="emailAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
|
624
|
+
<constructor-arg>
|
625
|
+
<ref local="emailAdvice"/>
|
626
|
+
</constructor-arg>
|
627
|
+
<property name="pattern">
|
628
|
+
<value>.*insertOrder.*</value>
|
629
|
+
</property>
|
630
|
+
</bean>
|
631
|
+
|
632
|
+
<!-- A parent bean definition which is a base definition for transaction proxies. -->
|
633
|
+
<!-- It's marked as abstract, since it's not supposed to be instantiated itself. -->
|
634
|
+
<!-- We set shared transaction attributes here, following our naming patterns. -->
|
635
|
+
<!-- The attributes can still be overridden in child bean definitions. -->
|
636
|
+
<bean id="baseTransactionProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true">
|
637
|
+
<property name="transactionManager">
|
638
|
+
<ref bean="transactionManager"/>
|
639
|
+
</property>
|
640
|
+
<property name="transactionAttributes">
|
641
|
+
<props>
|
642
|
+
<prop key="insert*">PROPAGATION_REQUIRED</prop>
|
643
|
+
<prop key="update*">PROPAGATION_REQUIRED</prop>
|
644
|
+
<prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
|
645
|
+
</props>
|
646
|
+
</property>
|
647
|
+
</bean>
|
648
|
+
|
649
|
+
<!-- JPetStore primary business object (default implementation), as an inner bean wrapped -->
|
650
|
+
<!-- by an outer transactional proxy. The two bean definitions could have been separate, -->
|
651
|
+
<!-- but this is cleaner as there is no need to ever access the unwrapped object. -->
|
652
|
+
<bean id="petStore" parent="baseTransactionProxy">
|
653
|
+
<property name="target">
|
654
|
+
<bean class="org.springframework.samples.jpetstore.domain.logic.PetStoreImpl">
|
655
|
+
<property name="accountDao">
|
656
|
+
<ref bean="accountDao"/>
|
657
|
+
</property>
|
658
|
+
<property name="categoryDao">
|
659
|
+
<ref bean="categoryDao"/>
|
660
|
+
</property>
|
661
|
+
<property name="productDao">
|
662
|
+
<ref bean="productDao"/>
|
663
|
+
</property>
|
664
|
+
<property name="itemDao">
|
665
|
+
<ref bean="itemDao"/>
|
666
|
+
</property>
|
667
|
+
<property name="orderDao">
|
668
|
+
<ref bean="orderDao"/>
|
669
|
+
</property>
|
670
|
+
</bean>
|
671
|
+
</property>
|
672
|
+
<!-- Uncomment the following in order to enable mail sending aspect -->
|
673
|
+
<property name="postInterceptors">
|
674
|
+
<list>
|
675
|
+
<ref local="emailAdvisor"/>
|
676
|
+
</list>
|
677
|
+
</property>
|
678
|
+
</bean>
|
679
|
+
|
680
|
+
|
681
|
+
<!-- ========================= REMOTE EXPORTER DEFINITIONS ======================== -->
|
682
|
+
|
683
|
+
<!-- RMI exporter for the JPetStore OrderService -->
|
684
|
+
<!-- Commented out by default to avoid conflicts with EJB containers -->
|
685
|
+
<bean id="order-rmi" class="org.springframework.remoting.rmi.RmiServiceExporter">
|
686
|
+
<property name="service">
|
687
|
+
<ref local="petStore"/>
|
688
|
+
</property>
|
689
|
+
<property name="serviceInterface">
|
690
|
+
<value>org.springframework.samples.jpetstore.domain.logic.OrderService</value>
|
691
|
+
</property>
|
692
|
+
<property name="serviceName">
|
693
|
+
<value>order</value>
|
694
|
+
</property>
|
695
|
+
<property name="registryPort">
|
696
|
+
<value>1099</value>
|
697
|
+
</property>
|
698
|
+
</bean>
|
699
|
+
|
700
|
+
</beans>
|
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 > hibernate.cfg.xml
|
891
|
+
$ kwaff User.hbm.kwaff > User.hbm.xml
|
892
|
+
$ kwaff Bid.hbm.kwaff > Bid.hbm.xml
|
893
|
+
$ kwaff AuctionItem.hbm.kwaff > AuctionItem.hbm.xml
|
894
|
+
</pre>
|
895
|
+
<p>hibernate.cfg.xml
|
896
|
+
</p>
|
897
|
+
<pre class="program"><?xml version="1.0"?>
|
898
|
+
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
|
899
|
+
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
|
900
|
+
<hibernate-configuration>
|
901
|
+
|
902
|
+
<session-factory name="foo">
|
903
|
+
<property name="show_sql">true</property>
|
904
|
+
<mapping resource="org/hibernate/test/Simple.hbm.xml"/>
|
905
|
+
<class-cache usage="read-write" class="org.hibernate.test.Simple" region="Simple"/>
|
906
|
+
</session-factory>
|
907
|
+
|
908
|
+
</hibernate-configuration>
|
909
|
+
</pre>
|
910
|
+
<p>User.hbm.xml
|
911
|
+
</p>
|
912
|
+
<pre class="program"><?xml version="1.0"?>
|
913
|
+
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
914
|
+
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
915
|
+
<hibernate-mapping package="org.hibernate.auction">
|
916
|
+
|
917
|
+
<class name="User" table="AuctionUser" lazy="true">
|
918
|
+
<comment>Users may bid for or sell auction items.</comment>
|
919
|
+
|
920
|
+
<id name="id">
|
921
|
+
<generator class="native"/>
|
922
|
+
</id>
|
923
|
+
|
924
|
+
<natural-id mutable="true">
|
925
|
+
<property name="userName" length="10"/>
|
926
|
+
</natural-id>
|
927
|
+
|
928
|
+
<property name="password" not-null="true" length="15" column="`password`"/>
|
929
|
+
|
930
|
+
<property name="email"/>
|
931
|
+
|
932
|
+
<component name="name">
|
933
|
+
<property name="firstName" length="50" not-null="true"/>
|
934
|
+
<property name="initial" column="`initial`"/>
|
935
|
+
<property name="lastName" length="50" not-null="true"/>
|
936
|
+
</component>
|
937
|
+
|
938
|
+
<bag name="bids" inverse="true" cascade="save-update,lock">
|
939
|
+
<key column="bidder"/>
|
940
|
+
<one-to-many class="Bid"/>
|
941
|
+
</bag>
|
942
|
+
|
943
|
+
<bag name="auctions" inverse="true" cascade="save-update,lock">
|
944
|
+
<key column="seller"/>
|
945
|
+
<one-to-many class="AuctionItem"/>
|
946
|
+
</bag>
|
947
|
+
</class>
|
948
|
+
|
949
|
+
</hibernate-mapping>
|
950
|
+
</pre>
|
951
|
+
<p>Bid.hbm.xml
|
952
|
+
</p>
|
953
|
+
<pre class="program"><?xml version="1.0"?>
|
954
|
+
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
955
|
+
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
956
|
+
<hibernate-mapping package="org.hibernate.auction">
|
957
|
+
|
958
|
+
<class name="Bid" discriminator-value="N">
|
959
|
+
<comment>A bid or "buy now" for an item.</comment>
|
960
|
+
|
961
|
+
<id name="id">
|
962
|
+
<generator class="native"/>
|
963
|
+
</id>
|
964
|
+
|
965
|
+
<discriminator type="char">
|
966
|
+
<column name="isBuyNow">
|
967
|
+
<comment>Y if a "buy now", N if a regular bid.</comment>
|
968
|
+
</column>
|
969
|
+
</discriminator>
|
970
|
+
|
971
|
+
<natural-id>
|
972
|
+
<many-to-one name="item"/>
|
973
|
+
<property name="amount"/>
|
974
|
+
</natural-id>
|
975
|
+
|
976
|
+
<property name="datetime" not-null="true" column="`datetime`"/>
|
977
|
+
|
978
|
+
<many-to-one name="bidder" not-null="true"/>
|
979
|
+
|
980
|
+
<subclass name="BuyNow" discriminator-value="Y"/>
|
981
|
+
</class>
|
982
|
+
|
983
|
+
</hibernate-mapping>
|
984
|
+
</pre>
|
985
|
+
<p>AuctionItem.hbm.xml
|
986
|
+
</p>
|
987
|
+
<pre class="program"><?xml version="1.0"?>
|
988
|
+
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
989
|
+
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
990
|
+
<hibernate-mapping package="org.hibernate.auction">
|
991
|
+
|
992
|
+
<import class="AuctionInfo"/>
|
993
|
+
|
994
|
+
<class name="AuctionItem">
|
995
|
+
<comment>An item that is being auctioned.</comment>
|
996
|
+
|
997
|
+
<id name="id">
|
998
|
+
<generator class="native"/>
|
999
|
+
</id>
|
1000
|
+
|
1001
|
+
<natural-id>
|
1002
|
+
<many-to-one name="seller"/>
|
1003
|
+
<property name="description" length="200"/>
|
1004
|
+
</natural-id>
|
1005
|
+
|
1006
|
+
<property name="ends"/>
|
1007
|
+
|
1008
|
+
<property name="condition"/>
|
1009
|
+
|
1010
|
+
<many-to-one name="successfulBid" outer-join="false"/>
|
1011
|
+
|
1012
|
+
<bag name="bids" cascade="all" inverse="true">
|
1013
|
+
<key column="item"/>
|
1014
|
+
<one-to-many class="Bid"/>
|
1015
|
+
</bag>
|
1016
|
+
</class>
|
1017
|
+
|
1018
|
+
</hibernate-mapping>
|
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 > seasar2.dicon
|
1093
|
+
</pre>
|
1094
|
+
<p>seasar2.dicon
|
1095
|
+
</p>
|
1096
|
+
<pre class="program"><?xml version="1.0" encoding="Shift_JIS"?>
|
1097
|
+
<!DOCTYPE components PUBLIC "-//SEASAR2.1//DTD S2Container//EN"
|
1098
|
+
"http://www.seasar.org/dtd/components21.dtd">
|
1099
|
+
<components>
|
1100
|
+
|
1101
|
+
<!-- constructor injection -->
|
1102
|
+
<component name="hello" class="examples.dicon.HelloConstructorInjection">
|
1103
|
+
<arg>"Hello World!"</arg>
|
1104
|
+
</component>
|
1105
|
+
|
1106
|
+
<!-- setter injection -->
|
1107
|
+
<component class="examples.dicon.HelloSetterInjection">
|
1108
|
+
<property name="message">"Hello World!"</property>
|
1109
|
+
</component>
|
1110
|
+
|
1111
|
+
<!-- method injection -->
|
1112
|
+
<component class="examples.dicon.HelloMethodInjection">
|
1113
|
+
<initMethod name="addMessage">
|
1114
|
+
<arg>"Hello "</arg>
|
1115
|
+
</initMethod>
|
1116
|
+
<initMethod>#self.addMessage("World!")</initMethod>
|
1117
|
+
</component>
|
1118
|
+
|
1119
|
+
<!-- auto binding with constructor injection -->
|
1120
|
+
<component class="java.util.HashMap">
|
1121
|
+
<initMethod name="put">
|
1122
|
+
<arg>"hello"</arg>
|
1123
|
+
<arg>"Hello World!"</arg>
|
1124
|
+
</initMethod>
|
1125
|
+
</component>
|
1126
|
+
<component autoBinding="auto" class="examples.dicon.autobinding.AutoHelloConstructorInjection"/>
|
1127
|
+
|
1128
|
+
<!-- auto binding with setter injection -->
|
1129
|
+
<component class="java.util.HashMap">
|
1130
|
+
<initMethod name="put">
|
1131
|
+
<arg>"hello"</arg>
|
1132
|
+
<arg>"Hello World!"</arg>
|
1133
|
+
</initMethod>
|
1134
|
+
</component>
|
1135
|
+
<component autoBinding="auto" class="examples.dicon.autobinding.AutoHelloSetterInjection"/>
|
1136
|
+
|
1137
|
+
<!-- AOP -->
|
1138
|
+
<component name="traceInterceptor" class="org.seasar.framework.aop.interceptors.TraceInterceptor"/>
|
1139
|
+
<component class="java.util.ArrayList">
|
1140
|
+
<aspect>traceInterceptor</aspect>
|
1141
|
+
</component>
|
1142
|
+
<component class="java.util.Date">
|
1143
|
+
<arg>0</arg>
|
1144
|
+
<aspect pointcut="getTime, hashCode">traceInterceptor</aspect>
|
1145
|
+
</component>
|
1146
|
+
|
1147
|
+
</components>
|
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 > bbs.xi
|
1218
|
+
</pre>
|
1219
|
+
<p>bbs.xi
|
1220
|
+
</p>
|
1221
|
+
<pre class="program"><?xml version="1.0"?>
|
1222
|
+
<xi:program xmlns:xi="http://www.baykit.org/Xi/1.1">
|
1223
|
+
|
1224
|
+
<!-- declare variable 'BBS-DATA' with initial data -->
|
1225
|
+
<xi:variable name="BBS-DATA">
|
1226
|
+
<bbs>
|
1227
|
+
<message>Welcom to mini-bbs</message>
|
1228
|
+
</bbs>
|
1229
|
+
</xi:variable>
|
1230
|
+
|
1231
|
+
<!-- if file 'bbs.xml' is exists, then load it into 'BBS-DATA' -->
|
1232
|
+
<xi:if test="$FS.exists('bbs.xml')">
|
1233
|
+
<xi:set out="$BBS-DATA" select="$IO.loadXml('bbs.xml')"/>
|
1234
|
+
</xi:if>
|
1235
|
+
|
1236
|
+
<!-- if new_message is on param, add it to end of BBS-DATA -->
|
1237
|
+
<xi:if test="$Web.parameters.new_message != ''">
|
1238
|
+
<xi:set out="$BBS-DATA">
|
1239
|
+
<bbs>
|
1240
|
+
<xi:copy-of select="$BBS-DATA/bbs/*"/>
|
1241
|
+
<message>
|
1242
|
+
<xi:value-of select="$Web.parameters.new_message"/>
|
1243
|
+
</message>
|
1244
|
+
</bbs>
|
1245
|
+
</xi:set>
|
1246
|
+
<xi:exec select="$IO.saveXml('bbs.xml', $BBS-DATA)"/>
|
1247
|
+
</xi:if>
|
1248
|
+
|
1249
|
+
<HTML>
|
1250
|
+
<BODY>
|
1251
|
+
|
1252
|
+
<!-- display bbs message. -->
|
1253
|
+
<UL>
|
1254
|
+
<xi:for-each item="message" select="$BBS-DATA/bbs/*">
|
1255
|
+
<LI>
|
1256
|
+
<xi:value-of select="$message"/>
|
1257
|
+
</LI>
|
1258
|
+
</xi:for-each>
|
1259
|
+
</UL>
|
1260
|
+
|
1261
|
+
<!-- FORM for posting bbs message. -->
|
1262
|
+
<HR/>
|
1263
|
+
<FORM METHOD="post" ACTION="bbs.xi">
|
1264
|
+
Message to post: <BR/>
|
1265
|
+
<TEXTAREA NAME="new_message"/>
|
1266
|
+
<INPUT TYPE="submit"/>
|
1267
|
+
</FORM>
|
1268
|
+
|
1269
|
+
</BODY>
|
1270
|
+
</HTML>
|
1271
|
+
|
1272
|
+
</xi:program>
|
1273
|
+
</pre>
|
1274
|
+
|
1275
|
+
|
1276
|
+
|
1277
|
+
|
1278
|
+
</div>
|
1279
|
+
<!-- EndEditable "doc_content" -->
|
1280
|
+
</div>
|
1281
|
+
|
1282
|
+
</body>
|
1283
|
+
</html>
|