Some reader favorites:
EJB fundamentals and session beans
Create a scrollable virtual desktop in Swing
More action with Struts 2
In a recent review of Struts 2 in Action, JW Blogger Oleg Mikheev notes that Struts 2 is "just a collection of extensions built upon WebWork, which is ultimately
the right thing to learn before starting a Struts 2 project." While Struts 2 has some architectural flaws, Oleg calls WebWork
well-designed, well-tested, and reliable. What are your experiences using Struts 2 and WebWork?
Also see "Hello World the WebWork way," a JavaWorld excerpt from WebWork in Action, by Patrick Lightbody and Jason Carreira.
| Memory Analysis in Eclipse |
| Enterprise AJAX - Transcend the Hype |
void decideUrl() {
DataBank.Region region = db.getRegion();
double limit = db.getLimit();
String id = db.getUserId();
if(region.equals(DataBank.EAST_REGION)) {
if(limit > db.LIMIT_THRESHOLD) {
setUrl(EAST_PRIVILEGED);
}
else {
setUrl(EAST_NOT_PRIVILEGED);
}
}
else if(region.equals(DataBank.WEST_REGION)) {
if(isMemberWestAlliance(id)) {
if(limit > db.LIMIT_THRESHOLD) {
setUrl(WEST_MEMBER_PRIVILEGED);
}
else {
setUrl(WEST_MEMBER_NOT_PRIVILEGED);
}
}
else {
if(limit > db.LIMIT_THRESHOLD) {
setUrl(WEST_NONMEMBER_PRIVILEGED);
}
else {
setUrl(WEST_NONMEMBER_NOT_PRIVILEGED);
}
}
}
else {
setUrl(OTHER_REGION);
}
}
TEXTBOX:
TEXTBOX_HEAD: Using the if-then-else framework: Read the whole series!
:END_TEXTBOX
Recall that for the sake of having runnable code, I have wrapped this version of the decideURL() method in a class URLProcessor_bad in the downloadable sample code. The implementation of the if-then-else framework in this example will result in a rewrite
of decideURL(). (This new version of the method appears in the class URLProcessor_good; see Resources.)
In Part 1, I outlined the main framework classes with which you will work and the four steps required to implement the framework, listed again here:
Condition (or possibly of a Condition subclass).
Action (or possibly of an Action subclass).
Updateable interface. Decide which object(s) should receive the actions implemented in Step 2 and make sure that it (they) implements the Updateable interface (which means you need to implement the doUpdate() method).
Invoker class. Create a concrete invoker subclass of Invoker and implement the loadConditions() and loadRules() methods.
By the end of Part 1, I completed the analysis of the conditions involved in rewriting the decideURL() method. Here is a quick review:
The code in Listing 1 involves three main conditions that must be evaluated for the main action -- setting the value of a
URL -- to be fired off: a location condition, a condition on the value of a limit, and a condition concerning membership to
"West Alliance." Since the possible values of location cannot be reduced to a single Boolean-valued condition, I broke down
the location condition into three finer-grained conditions: whether or not the specified region is EAST_REGION, whether or not it is WEST_REGION, and whether or not it is neither. The analysis of conditions resulted in the creation of five objects, which completed the
work for Step 1:
swingall.jar file for Swing 1.0.3 in your class path