XDoclet in Action

Free Download

Authors:

Edition: illustrated edition

Series: In Action series

ISBN: 9781932394054, 1-932394-05-2

Size: 6 MB (6265991 bytes)

Pages: 625/625

File format:

Language:

Publishing Year:

Craig Walls, Norman Richards9781932394054, 1-932394-05-2

A guide to the XDoclet development tool that eliminates programming busy work by automatically generating code and other deployment artifacts, this book enables developers who place meta-data in a single source code file, to use XDoclet to generate additional source code and other files that are required in a project. Using both smaller code examples and a full-scale J2EE examples, everything needed to employ XDoclet code generation into a development cycle is provided. In addition to the typical uses of XDoclet in J2EE development, also covered are other uses of XDoclet with non-J2EE technologies such as JDO, Hibernate, JMX, SOAP, and MockObjects. Also, if none of these out-of-the box XDoclet tasks meet the developer’s needs, information on how to extend XDoclet to generate practically any code your project requires is furnished.

Table of contents :
foreword……Page 18
preface……Page 22
acknowledgments……Page 24
How to read this book……Page 27
Typographical conventions……Page 29
About the authors……Page 30
about the title……Page 31
about the cover illustration……Page 32
Part 1 – The basics……Page 34
A gentle introduction to code generation……Page 36
1.1 What is XDoclet?……Page 37
1.2 Types of code generation……Page 38
1.2.2 Active style: integrated code generation……Page 39
1.3 Code generation input sources……Page 40
1.3.1 Models as an input source……Page 41
1.3.2 Data files as input……Page 42
1.4 How XDoclet fits in……Page 43
1.5.1 Should you generate code?……Page 46
1.5.2 Should you use a tool or build the generator yourself?……Page 48
1.6.1 Don’t generate what you don’t understand……Page 49
1.6.3 Don’t be afraid to change your design to accommodate generation……Page 50
1.6.4 Generate layer by layer, piece by piece……Page 51
1.6.5 Keep generated files out of the code repository……Page 52
1.7 Summary……Page 53
Getting started with XDoclet……Page 54
2.1.1 A common issue……Page 55
2.1.3 Integrating with Ant……Page 56
2.1.4 Generating a professional-looking todo list……Page 57
2.2.1 XDoclet tasks……Page 58
2.2.2 XDoclet subtasks……Page 59
2.3.1 Declaring tasks……Page 61
2.3.2 Using tasks……Page 62
2.4 Tagging your code with attributes……Page 63
2.4.1 The anatomy of an attribute……Page 64
2.5 Code generation patterns……Page 66
2.5.1 Template basics……Page 67
2.5.2 Template tags……Page 69
2.6 Customizing through merging……Page 70
2.7 The big picture……Page 72
2.8 Summary……Page 74
Part 2 – Using XDoclet with Enterprise Java……Page 76
XDoclet and Enterprise JavaBeans……Page 78
3.1 Building the web-log application……Page 79
3.1.2 Creating the EJB code generation build file……Page 80
3.2 Defining the EJBs……Page 83
3.3 Adding the subtasks for the EJB application……Page 84
3.3.2 Generating home and local home interfaces……Page 85
3.3.3 Generating remote and local interfaces……Page 86
3.3.4 Generating utility objects……Page 87
3.3.5 Generating concrete EJB implementation classes……Page 89
3.3.6 Including EJB references……Page 91
3.3.7 Including container-managed persistent fields……Page 92
3.3.8 Declaring relationships……Page 93
3.3.9 Generating value objects……Page 94
3.4.2 Bean-managed authorization……Page 99
3.5 Using query methods with entity beans……Page 101
3.5.2 Select methods……Page 102
3.6 How you’ve benefitted from XDoclet so far……Page 103
3.7 Managing transactions……Page 104
3.7.1 Container-managed transactions……Page 105
3.7.2 Bean-managed transactions……Page 107
3.8.1 Generating DAO interfaces……Page 108
3.8.2 Adding methods to the DAO interface……Page 110
3.9.1 Defining message selectors……Page 111
3.9.2 Setting an acknowledge mode……Page 112
3.9.3 Specifying destinations……Page 113
3.10 Summary……Page 114
XDoclet and the web-layer……Page 116
4.1 Adding web-layer generation to the build file……Page 117
4.2 Working with servlets……Page 119
4.2.1 Configuring servlets in web.xml……Page 121
4.3 Referencing EJBs……Page 124
4.4 Configuring servlet security……Page 127
4.4.1 Declaring security roles……Page 129
4.4.2 Programming security in servlets……Page 130
4.4.3 Propagating security roles……Page 131
4.5 Working with servlet filters……Page 132
4.5.1 Configuring filters in web.xml……Page 134
4.6 Applying XDoclet to listeners……Page 137
4.7 Writing custom JSP tags……Page 138
4.8 Summary……Page 141
XDoclet and web frameworks……Page 142
5.1 Merging framework servlets into web.xml……Page 143
5.1.2 Merging ServletDispatcher for WebWork……Page 145
5.2 Using XDoclet with Jakarta Struts……Page 146
5.2.1 Enabling Struts generation in the build files……Page 147
5.2.2 Implementing an Action……Page 150
5.2.3 Declaring the Struts Action……Page 152
5.2.4 Defining ActionForms……Page 154
5.3.1 Configuring Actions in actions.xml……Page 163
5.4 Summary……Page 166
XDoclet and application servers……Page 168
6.1.1 J2EE development roles……Page 169
6.1.2 J2EE application deployment……Page 170
6.1.3 Generating application server deployment descriptors……Page 171
6.2 Deploying on JBoss……Page 172
6.2.2 Specifying database schema……Page 173
6.2.3 Mapping foreign keys……Page 175
6.2.4 Handling relation tables……Page 176
6.2.5 Creating database tables……Page 178
6.2.6 Specifying physical JNDI names……Page 179
6.3.1 Setting a default web context……Page 182
6.3.3 Setting a virtual host……Page 183
6.4.1 Deploying an EJB JAR on WebLogic……Page 184
6.4.2 Specifying database mapping……Page 185
6.4.3 Managing tables……Page 186
6.4.4 Using WebLogic-specific features……Page 187
6.4.5 Deploying a WAR file on WebLogic……Page 188
6.5 Working with multiple application servers……Page 189
6.6 Working with multiple deployments……Page 191
6.7 Summary……Page 192
Part 3 – Other XDoclet applications……Page 194
XDoclet and data persistence……Page 196
7.1 Hibernating data……Page 197
7.1.1 Preparing the build for Hibernate……Page 198
7.1.2 Tagging classes for Hibernation……Page 199
7.1.3 Using the Hibernated classes……Page 208
7.2 Persisting data with JDO……Page 209
7.2.1 Adding JDO generation to the build……Page 210
7.2.2 Tagging classes for JDO persistence……Page 212
7.2.3 Using the JDO persistence-capable classes……Page 216
7.2.4 Working with vendor extensions……Page 220
7.3.1 Adding Castor generation to the build……Page 225
7.3.2 Persisting objects using Castor JDO……Page 226
7.3.3 Using objects persisted with Castor JDO……Page 232
7.3.4 Working with Castor XML……Page 235
7.4 Summary……Page 242
XDoclet and web services……Page 243
8.1 Generating deployment descriptors for Apache SOAP……Page 244
8.1.1 Writing simple Java web services for Apache SOAP……Page 245
8.1.2 Exposing EJBs as Apache SOAP web services……Page 248
8.1.3 Mapping custom types……Page 250
8.2 Generating deployment descriptors for Axis……Page 255
8.2.1 Writing simple Java web services for Axis……Page 256
8.2.2 Exposing EJBs as Axis web services……Page 259
8.2.3 Mapping custom types……Page 261
8.3 Summary……Page 264
XDoclet and JMX……Page 265
9.1 A quick JMX overview……Page 266
9.2 Preparing the build for JMX generation……Page 267
9.3 Generating MBean interfaces……Page 268
9.4 Generating mlet files……Page 272
9.4.1 Deploying the mlet using the mlet service……Page 276
9.5 Working with MBean services in JBossMX……Page 278
9.5.1 Creating JBossMX services……Page 279
9.5.2 Generating XML for JBossMX model MBeans……Page 282
9.6.1 Preparing the build for MX4J……Page 287
9.6.2 Tagging MBeans for MX4J……Page 288
9.6.3 Running the build……Page 289
9.6.4 Deploying the MBean into MX4J……Page 291
9.7 Summary……Page 294
XDoclet and mock objects……Page 295
10.1 What are mock objects?……Page 296
10.1.1 Knowing when to mock……Page 297
10.1.2 Testing from the inside out……Page 298
10.2.1 Adding mock-object generation to the build……Page 299
10.2.2 Tagging interfaces to generate mock implementations……Page 301
10.2.3 Testing FullServiceStation.java with mock objects……Page 302
10.3 Summary……Page 306
XDoclet and portlets……Page 308
11.1 Introducing JSR-168 (the portlet API)……Page 309
11.1.1 Writing a simple portlet……Page 310
11.1.2 Deploying a portlet……Page 311
11.2 Adding portlet.xml generation to the build file……Page 312
11.3 Writing a portlet……Page 313
11.3.1 Defining portlet basics……Page 315
11.3.2 Initializing portlets……Page 316
11.3.3 Supporting multiple display options……Page 317
11.3.4 Defining preferences……Page 318
11.3.5 Validating preferences……Page 319
11.4 Running the build……Page 321
11.5 Summary……Page 323
Part 4 – Extending XDoclet……Page 324
Custom code generation with XDoclet……Page 326
12.1 When should you bother with custom code generation?……Page 327
12.1.2 The rewards of custom generation……Page 328
12.1.3 Making the leap……Page 329
12.2.1 Using aggregate generation……Page 330
12.2.2 Using transformation generation……Page 332
12.3 Exploring design alternatives……Page 337
12.3.1 Registering commands……Page 338
12.3.2 Generating the command processor……Page 339
12.3.3 Generating a configuration file……Page 343
12.3.4 Choosing a generation method……Page 345
12.4.1 Block and content tags……Page 346
12.4.2 Tag namespaces……Page 347
12.4.3 Types of tags……Page 348
12.4.4 Using some basic template tags……Page 351
12.5 Creating custom template tags……Page 355
12.5.1 Creating a content tag……Page 357
12.5.2 Creating a body tag……Page 359
12.5.3 Refactoring common functionality into a tag……Page 361
12.6 Creating custom tasks……Page 362
12.6.2 Creating the subtask……Page 364
12.6.3 Distributing custom tasks……Page 366
12.7 Summary……Page 367
XDoclet extensions and tools……Page 368
13.1 The role of tools in XDoclet……Page 369
13.2.1 Helping IDEA find your generated classes……Page 370
13.2.2 Configuring IDEA to accept XDoclet tags……Page 371
13.2.3 Using IDEA’s live templates to generate XDoclet tags……Page 373
13.3 Eclipse……Page 375
13.3.1 Using JBoss IDE……Page 376
13.3.2 Generating an XDoclet build file……Page 377
13.4 AndroMDA……Page 379
13.5 Middlegen……Page 380
13.6 Summary……Page 382
Setting up Ant……Page 383
Installing XDoclet……Page 384
Task not found……Page 385
Deprecated tasks……Page 386
XDoclet task/subtask quick reference……Page 387
Template subtask attributes……Page 388
The task……Page 389
The task……Page 390
The task……Page 402
The task……Page 404
The task……Page 405
The task……Page 406
The task……Page 407
XDoclet tag quick reference……Page 415
Apache SOAP tags……Page 416
Borland Enterprise Server (BES) EJB tags……Page 417
Castor tags……Page 419
EJB tags……Page 422
Hibernate tags……Page 439
HP Application Server EJB tags……Page 448
JavaBean tags……Page 449
JBoss tags……Page 452
JDO tags……Page 463
JMX tags……Page 467
JOnAS tags……Page 471
Macromedia JRun tags……Page 474
Solarmetric’s Kodo tags……Page 477
i18n message bundle tags……Page 478
MVCSoft Persistence Manager tags……Page 479
Oracle Application Server tags……Page 484
Orion Application Server EJB tags……Page 487
Portlet tags……Page 490
Pramati Server tags……Page 491
Resin tags……Page 493
Jakarta Struts tags……Page 500
SunONE/iPlanet tags……Page 503
Triactive JDO tags……Page 507
Servlet and JSP tags……Page 509
WebLogic tags……Page 513
IBM’s WebSphere tags……Page 521
XDoclet tags……Page 522
Abstract program element namespaces……Page 524
Antdoc namespace……Page 525
BesEjbRel namespace……Page 526
Bsf namespace……Page 527
Class namespace……Page 528
Collection namespace……Page 533
Config namespace……Page 535
Constructor namespace……Page 537
Doc namespace……Page 541
Ejb namespace……Page 542
EjbBmp namespace……Page 543
EjbCmp namespace……Page 544
EjbDataObj namespace……Page 545
EjbEntity namespace……Page 546
EjbFacade namespace……Page 547
EjbHome namespace……Page 548
EjbIntf namespace……Page 550
EjbMdb namespace……Page 551
EjbPersistent namespace……Page 552
EjbPk namespace……Page 553
EjbRef namespace……Page 554
EjbRel namespace……Page 555
EjbSec namespace……Page 557
EjbSession namespace……Page 558
EjbValueObj namespace……Page 559
Externalizer namespace……Page 560
Field namespace……Page 561
Hibernate namespace……Page 563
I18n namespace……Page 564
Info namespace……Page 565
JBEjbRel namespace……Page 568
JBossWeb namespace……Page 571
Jdo namespace……Page 572
Jmx namespace……Page 573
MVCSoft namespace……Page 574
Mavenplugin namespace……Page 575
Method namespace……Page 576
MockObject namespace……Page 582
Module namespace……Page 583
Package namespace……Page 584
Parameter namespace……Page 585
Property namespace……Page 587
Resin namespace……Page 588
ResinEjb namespace……Page 589
Soap namespace……Page 590
SunONE namespace……Page 591
Type namespace……Page 592
Validator namespace……Page 594
Velocity namespace……Page 595
Web namespace……Page 596
WlEjbRel namespace……Page 597
Xml namespace……Page 598
The future of XDoclet……Page 599
XDoclet 2 and Generama……Page 600
Using the task……Page 601
Getting involved with XDoclet……Page 602
Subscribing to the mailing lists……Page 603
Building XDoclet……Page 604
Building only the modules……Page 605
Tracking issues in JIRA……Page 606
recommended reading……Page 608
B……Page 610
D……Page 611
E……Page 612
I……Page 614
J……Page 615
M……Page 617
P……Page 618
S……Page 619
T……Page 620
W……Page 621
X……Page 623

Reviews

There are no reviews yet.

Be the first to review “XDoclet in Action”
Shopping Cart
Scroll to Top