Skip to Content
Java Extreme Programming Cookbook
book

Java Extreme Programming Cookbook

by Eric M. Burke, Brian M. Coyner
March 2003
Intermediate to advanced
288 pages
7h 4m
English
O'Reilly Media, Inc.
Content preview from Java Extreme Programming Cookbook

Creating a Template File

Problem

You want to create a new template file (.xdt) that uses the JUnitPerfTagHandler class created in the previous recipe.

Solution

Create a template file called junitperf.xdt.

Discussion

XDoclet template files mix snippets of Java code and XML-style tags. These tags refer to XDoclet tag handler classes.

Instead of jumping directly into the completed example, it is best if we walk through each step of how the example template file is created. This example can be modified if your coding conventions differ or if you want to add extra functionality.

First, the template creates the package statement:

package <XDtPackage:packageName/>;

Tip

XDoclet prefixes all namespaces with “XDt”, and is not part of the actual namespace specified in the xdoclet.xml file. In order to reference the “Perf” namespace, you would use “XDtPerf”. This is simply a convention that XDoclet uses.

Next, we add the import statements.

import com.clarkware.junitperf.*;
import junit.framework.*;

These are the only import statements that we need. Here is how to include import statements from the class being parsed (if you need them):

<XDtClass:importedList currentClass="&lt;XDtClass:className/&gt;"/>

Tip

It’s not a strict requirement to use entity references such as &lt; and &gt; when nesting greater-than and less-than symbols, but it does make the file easier to read, in our opinion. You are free to write this too: currentClass="<XDtClass:className/>"

For fun, any class comments are copied from the JUnit ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Java Thread Programming

Java Thread Programming

Paul Hyde
Mastering Java 11 - Second Edition

Mastering Java 11 - Second Edition

Dr. Edward Lavieri Jr., Mandar Jog
Distributed Computing in Java 9

Distributed Computing in Java 9

Raja Malleswara Rao Malleswara Rao Pattamsetti
Java 9 Dependency Injection

Java 9 Dependency Injection

Nilang Patel, Krunal Patel

Publisher Resources

ISBN: 0596003870Catalog PageErrata