Thursday, December 28, 2006

Acegi 1.0.3 - security framework

Acegi is an open source security framework that allows us to keep business logic free from security code. Acegi Security provides comprehensive security services for J2EE-based enterprise software applications.

Recently we decided to move security part from SecurityFilter to Acegi. It took me 3 days to finish switch. Seems Acegi integrate to our current system pretty well.

Currently our environment is: Tomcat5.5, Spring2, mySQL5, Hibernate3, Java1.5. Following list some simple steps:

web.xml

security-acegi-security.xml
filterInvocationDefinitionSource - httpSessionContextIntegrationFilter, authenticationProcessingFilter, exceptionTranslationFilter, filterSecurityInterceptor

Sunday, December 03, 2006

BIRT v.s. JasperReport

BIRT is an Eclipse-based open source reporting system for web applications, especially those based on Java and J2EE.

Jasper Report is a powerful open source Java reporting tool that has the ability to deliver rich content onto the screen, to the printer or into PDF, HTML, XLS, CSV and XML files.

JasperReports
- Easiest integrate to application and flexible from a developers standpoint.
- Supports a large number of export formats.
- Do not have free report designer tool.

Eclipse BIRT
- Excellent report designer and charting support. I can get create reports in a matter of minutes with great ease.
- Great support for reports with multiple datasources. However, it is also tedious to maintain extra datasource just for report.
- Harder to integrate into currently application.

Currently, when I deploy report to BIRT under tomcat environment. I need deploy it to a separate application. This application is totally used to handle all reports. For small application, it makes things complex and I am strong worry about its security. I also try to integrate BIRT report to my application, however it makes my WAR file pretty big (20M more).

BIRT is still a relatively young project and there lots more work that needs to be done. Maybe I need wait for next BIRT release.

Because my application is using spring framework. It does support a view to pretty easy integrate my JasperReport. This allow me to focus on my report design instead of other stuff. At the same time, code is pretty small and clean. So I decide to choose JasperReport as my report engine temporary.

Pro Spring has a good example shows how to integrate JasperReport into your application.



The order of this configure file is pretty important. First, it should be general viewResolver, then comes japserReportViewResolver.

Friday, October 20, 2006

J2EE without EJB feature lists

Tomcat - Application Server
Spring 2.0 - J2EE framework
Hibernate/iBatis - ORM
JSF/Spring/WebWork - Multi-Action Web Framework
JSP - View Template
Dojo, YUI/Extension, Rico, Prototype - Rich Client Widgets
Acegi - Authentication and authorization.
SiteMesh - Web page layout and decoration framework.
Quartz - Enterprise job scheduler.
Log4j - Logging Tool
OSCache - Simple Cache and Web Cache solution
Jasper Report - Report Engine
Lucene - Search engine
ExtremeTable - JSP Table Tag Libraries.
Junit - unit test

Friday, September 15, 2006

AOP and OOP

AOP - Aspect Oriented Programming provides us the ability to interpose customer behavor before/after invocations on any object. This enable us to address crosscutting enterprise concerns that apply to multiple object.

OOP works well in general, AOP is a complementing rather than competing with OOP. For example, if we have to apply the same transactional behavior to multiple objects and methods, we need cut/paste the same code into each method. AOP give us a better way to pack such concerns into ASPECTS.

Tuesday, July 04, 2006

How to bind and validate in MultiActionController

In Spring framework, it provides several controller in MVC model. Personaly, I like the MultiActionController best. And I do not like SimpleFormController because it only one "onSubmit" method. For WEB page, I do not think any page just have one button, i.e: "Save" or "Update". However, SimpleFormController have strong validator ability. But I still hate lots of configure in SimpleFormController.

In Spring MultiActionController, it already provides bind method, however, this method just throws Exception when it find the invalidate error message. To catch this error, we need write a new method to override it.

The goal is to use both MultiActionController and SimpleFormController

Solution: bind and validate in MultiActionController.

In XML, you can write your MultiActionController as normal define.



Now we need bind the form and validator it.

I will use a save action as example:

First create a bindObject method in your BaseContoller (extends MultiActionController)

protected BindException bindObject(HttpServletRequest request,
Object command, Validator validator) throws Exception {
preBind(request, command);
ServletRequestDataBinder binder = createBinder(request, command);
binder.bind(request);

BindException errors = new BindException(command,
getCommandName(command));
if (validator.supports(command.getClass())) {
ValidationUtils.invokeValidator(validator, command, errors);
}

return errors;
}

Now in the save action, you can use this method as normal.

public ModelAndView save(HttpServletRequest request,
HttpServletResponse response, PhoneInfo command) throws Exception {
ModelAndView addPhoneView = new ModelAndView(LIST_VIEW, "phones",
phones);
addPhoneView.addObject("phoneInfo", command);

// add validator and call bindobject to get the result
BindException errors = super.bindObject(request, command, new PhoneInfoValidator());
if (errors.hasErrors()) {
addPhoneView.addAllObjects(errors.getModel());
return addPhoneView;
}

// otherwise --- save this object...
return addPhoneView;
}

In this way, I can easy to fix my problem when I use MultiActionController. I can bind and validate any object as I like.

Friday, June 30, 2006

Hibernate ?

Hibernate is a good ORM tool. However, there also have some issue in here:

1: Criteria API, QueryObject are not as strong as sql language.

2: Lazy load or not... only define one time in XML

3: POJO ? too much use ?

Friday, June 02, 2006

RIM Blackberry and J2ME

Programming the BlackBerry With J2ME

Thursday, May 18, 2006

Google Ajax

http://code.google.com/webtoolkit/

Some good tool for Ajax

prototype.js is a JavaScript library written by Sam Stephenson. This amazingly well thought and well written piece of standards-compliant code takes a lot of the burden associated with creating rich, highly interactive web pages that characterize the Web 2.0 off your back.

Thursday, April 20, 2006

Spring lightweight?

Today, indeed Spring cannot be considered as “lightweight” when comparing it to other light solutions out there. this is mainly due to the vast amount of solutions it provides in almost all aspects of enterprise development. I guess “lightweight”, when taking it by its literal meaning, is somewhat inappropriate nowadays… perhaps “simple and comprehensive” is more suitable to describe Spring. But this term (I think) is not interpreted by its literal meaning. I think it’s still associated with its original meaning when it was compared with the heavy EJB containers.

Wednesday, February 22, 2006

Jasper and Open Reports

In the end we compared Crystal reports with Jasper Reports, and Jasper was picked. Jasper is not only free, but also is proven in the Java world, and has a lot of users. It is customizable, since its Java and open source, and has support for using Collections or Lists of Business Objects, such as those populated via Hibernate.

Once Jasper was chosen, I tested several GUI’s to help build the reports instead of editing them strictly in their native XML. JasperAssistant was found to be the best of all of them, and integrates seamlessly with Eclipse. If you are an Eclipse fan as I am, then you’ll love using JasperAssistant. It even allows you to preview the report against your database right in Eclipse.

Monday, January 16, 2006

Connecting Apache's Web Server to Multiple Instances of Tomcat

Connecting Apache's Web Server to Multiple Instances of Tomcat

http://www.linuxjournal.com/node/8561/print

Thursday, January 12, 2006

Quick Reference Card

http://www.digilife.be/quickreferences/quickrefs.htm

Wednesday, January 11, 2006

Voice Application with J2EE

I'm convinced that J2EE lightweight container architecture is the right way to go for the majority of voice applications. However, there needs to be some tweaks in the way the UI tier utilizes it, compared to what we're used to seeing with HTML-based applications.

The standard platform architecture for Voice Application is to have 100 or so browser instances sitting on a server. The browser is not located on the client, because the client is a POT (Plain Old Telephone). The caller dials up a computer with a Dialogic or NMS card, or a SIP gateway, and the call is routed to one of the browser instances running on a server. This may be the same server that's running the app server, or it may just be on the same LAN.

So now the browser cache becomes much, much more important. If I have a few thousand phone calls coming in every hour to those 100 browsers, and they're all running the same application, the absolute worst thing I can do is a lot of dynamic page rendering. That would involve parsing the JSP into VoiceXML, and parsing the VoiceXML into runnable code, on every request.

So, component libraries like Tapestry or JSF are out. MVC frameworks like struts could be okay, as long as they're redirecting to static VoiceXML pages, instead of forwarding to JSPs.

Reusable Dialog Component (RDC) for voice application

A Reusable Dialog Component (RDC) is basically a JSP 2.0 tag, which generates VoiceXML at runtime. RDCs are part of the RDC Tag Library open source Jakarta project. Version 1.0 of the RDC Taglib was released in July 2005. The RDC Taglib projects implifies the development of server-side code in order to generate Voice XML. The RDC Taglib project includes a set of RDCs, which are a collection of JSP 2.0 tags that assist in the development of Voice applications. The RDC tags generate VoiceXML at runtime, which can execute on any VoiceXML 2.0 compliant platform. The RDC Taglib also provides a framework for implementing additional RDCs. The framework helps in orchestrating each individual RDC making sure the user data is collected, verified, and canonicalized. The collection of RDCs included in the Taglib project is made up of both, atomic and composite RDCs. Atomic RDCs collect a single piece of information from the user. For example, date, time, or zipCode are atomic RDCs. Composite RDCs collect multiple pieces of information from a user. These are usually done by using atomic RDCs or aggregating a composite with other atomic RDCs.