Posts

Showing posts from March, 2007

Using Quartz Scheduler in a Java EE Web Application

Image
At times, you may have wanted to perform some action periodically in your web application. Quartz is an enterprise grade scheduler which can be used for such a task. Read here for the complete list of features of Quartz. For using the Quartz scheduler library in a Java EE web application, following needs to be done:
Include the quartz jars (quartz-all.jar and others in the lib path). In my case, some of the commons-xxx.jar files were already included in the project due to the dependency of another library (displaytag) on those jar files. So in my quartz setup i had to disinclude them. In the lib/build path, i only included, jta.jar and also everything which was not already there in the project from lib/optional path too (they are not many anyway).We then had to create the tables required by quartz for storing job details and triggers across restart of application. This is an optional feature but an important one (which made us decide to use quartz in the first place over the JDK Timer)…

Is it okay to put business logic in stored procedure?

In my experience, i have come across maintaining some software where the business logic was written in stored procedures (or functions/triggers). Recently i collected some points on why this is not such a good idea. The main reason for the use of stored procedures in one product was to have multiple client types to be able to invoke the same business logic. But then we can achieve the same effect applying MVC (model view controller) pattern and keeping the model/business logic in the application code rather than stored procedure. Here are some other reasons why its not a good idea to write BL in stored procedures:

NOTE: Most of the ideas presented below are excerpted from this article.

1. If there are more than one interfaces and the BL is part in stored procedure and part in presentation tier then it becomes a maintenance headache to keep the different presentation tiers in synch.

2. Stored procedures form an API by themselves. Adding new functionality or new procedures is the "bes…

An Events Browser - Using Displaytag and DWR

Image
Problem:
To view application-specific events in the web browser.

Requirements:
The implementation should satisfy the following requirements:
support viewing all the logged events (in a DB) with provision for specifying the number of rows per page to show in a data grid of event records.support pagination.support sorting on columns like event time, id, type etc.support exporting events data to CSV, excel etc formats.change row color to highlight rows based on severity of events.
enable viewing live events instantaneously as they occur.
Solution:
The first 5 requirements are easily met by Displaytag, an excellent JSP tag library for displaying data grids. We can also enable AJAX support for displaytag data grid pagination and sorting using ajaxtags library.

We did not like the live grid type views (which may be better suited to the search examples) for our requirement as we believe the pagination with Ajax support is more appealing and common experience for users.

The last requirement is met by

Started learning Kenpo Karate

Image
I have started attending Kenpo Karate (one of the forms of Karate martial arts) classes today at a local training institute. Today i attended the first class and learned about some basic stances and some ways to block an attack. The best part is the initial warm up exercise that we get to do in a group. It was very tiring for the first day and we did it for 30mins. There will 3 classes per week and 1.5hr per class.

It was in 1993 that i attended Taekwon-do martial art classes for 3 months but had to leave it because of the study pressure. I joined a gym when i got into engineering college in 1994 and for the first year i could go to the gym regularly but slowly with mounting study pressure i became irregular with gym too and though i continued on an irregular basis till i got my first job in 1999, i could not keep up with gyming once i was in Banglore in the winter of 2000. We had a gym in my Bangalore apartment too but i never could kindle the fire to exercise there. But it has been m…

Integrating Java and PHP: the Web Services way

Image
Recently on a project, we were faced with the question:
do we put the business logic in the web tier (which was written in PHP 4.7.3) ordo we write the business logic in Java (better tools for development, reliable libraries for some of the tasks we wanted to perform as a part of our business logic, better OO language features than PHP, easy to debug in an IDE, code hidden in class files).The first option was what we usually call the model 1 architecture, where business logic is written in the same script which serves the presentation code.

In the second approach, we were getting to the point of introducing the MVC pattern to our PHP based web tier by introducing a Java layer to play the model and let PHP scripts be controller and view. This had the added advantage that we could leverage the model written as Java web services in other clients (and we did have other clients than web interface too for our product which provided an alternate interface for user/program to interact with our …