Software Engineering 30 May 2008 10:05 pm

Spring MVC+Custom Multy Action support.

Download projects

Test (default tomcat 6.0.14 install) - http://localhost:8080/eqs-pim-webapp-1.0.0/login.htm
Enter nothing on login.

This article tries to show how to put together relatively complex web application using Spring MVC and is an attempt to show some of the best practices of web application development and packaging.
To address some of the Java web development problems and to achieve simplicity of Ruby on Rails additional abstract classes and tag libraries have been introduce as part of this sample application.
You can use included source code as template for your future projects.

Continue Reading »

Software Engineering 28 Mar 2008 01:15 pm

CXF+SPRING+POJO

Full maven project can be downloaded from HERE.

This is a follow up article to XFIRE+EJB+POJO.
Here I show how to expose POJO using CXF project instead of XFire.
Setting up WebServices with CXF is very easy and consists of two steps:

Software Engineering 07 May 2007 02:10 pm

Mule+Maven+Eclipse

This article shows how to get Maven based Mule project to easily work within
Eclipse without the need of constant redeployment to mule lib/user directory.

I will use “hello” sample project from Mule installation.

hello.zip contains modified “hello” Mule project
where I removed “.bat” file, commented out “version” tag in pom.xml to make maven
build work, added dependency to vm and stream transports and put log4j.properties
for easy access.

Continue Reading »

Software Engineering 14 Dec 2006 10:46 pm

DOJO+DWR+SPRING+AUTHENTICATION

Intro:

Download project - dwr-test.zip
Download WAR - dwr-test-war-1.0.0.war
Test (default weblogic install) - http://localhost:7001/dwr-test-war-1.0.0/test.html
When promted type user name “weblogic” password “weblogic” for default weblogic install.


Screenshot.

This article shows how to implement pure AJAX application that does round trip
communication to Java back end using custom DOJO widgets for client,
DWR for JavaScript to Java communication and Spring that will manage
back end Java objects.
Full Maven2 project is provided for download.

There are two ways of building AJAX applications.

  • Single page approach where the AJAX application get loaded one into
    browser and all of subsequent server side communications are AJAX calls.
  • Multiage approach where it is more like MVC2 where each JSP page served
    back to browser contains AJAX components.

The approach I like and took is Single page (1) because its more natural to
client/server development where the only thing passed in-between is data.
But I wont be shy of using multi page approach if need arises.


Continue Reading »

Software Engineering 27 Sep 2006 09:38 pm

Maven Run/Build Plugin 2

maven-run-plugin-1.0.jar

This is a simplified and more flexible version of build plugin.

This plugin allows to execute specified goals on all project and sub projects
under current base directory.

The plugin is using “maven.multiproject.type” and “command” property to determine
project and command types in order to execure appropriate list of goals.

The plugin will append the value specified in “maven.multiproject.type” and
“command” properties to “.goals” to get list of maven goals to run.

Continue Reading »

Software Engineering 26 Aug 2006 01:04 am

XFIRE+EJB+POJO

Full Maven Project.

This article brings together Spring and XFire configuration examples to show how
to expose simple POJO into SOAP service with EJB façade in between.

Lets take a simple example of number add and subtract service.

Here is component diagram of what we are trying to achieve.



Continue Reading »

Software Engineering 16 Aug 2006 09:25 pm

Maven Build Plug-In

maven-build-plugin-1.0.jar

Please use improved version of this plugin from this post.

This pugin will allow to run single command on one or set of maven projects to build or deploy them instead of doing separate maven goals on each project. This will even work inside a single project as well as on root project containing sub-projects.
The only requirement is to have “maven.multiproject.type” property defined in each project.

Generic plugin which provides build and deploy goals that can be customized to
run list of maven goals across maven projects using maven:rector.
The plugin is using “maven.multiproject.type” property to determine
project type in roder to execure appropriate list of commands.
The plugin will append the value specified in “maven.multiproject.type”
to “.build.commands” and “.deploy.commands” to get list of maven goals to run.
For example here is the list of default goals to be run when doing build on
jar, ejb, war and ear:

jar.build.commands = clean,jar:jar,jar:install
ejb.build.commands = clean,ejb:ejb,ejb:install
war.build.commands = clean,war:war,war:install
ear.build.commands = clean,ear:ear,ear:install

The properties can be customized in project.properties to add/remove goals.

There are no deploy commands defined by default. The deploy goals are specific
to the project and need to be defined in build.properties or project.properties.
For example it would make sense to have ear.deploy.commands = weblogic:undeploy,weblogic:deploy
property ser in root project.properties.

  • build - will execute ${maven.multiproject.type}.build.commands on
    each project under base directory. Will stop on first build failure.
  • deploy - will execute ${maven.multiproject.type}.deploy.commands on
    each project under base directory. Wont stop on failure.
  • build-deploy - will execute ${maven.multiproject.type}.deploy.commands and
    ${maven.multiproject.type}.deploy.commands on
    each project under base directory. Will only stop on first build failure,
    deploy failures will be ignored.

Software Engineering 03 Aug 2006 08:34 pm

Map Object.

Have you wished you could attach arbitrary data to plain any Java object during the runtime? I have and not once or twice.

Something like adding these two methods “get(Object key)” and “put(Object key, Object data)”.

This often happens when objects, while interacting, need to associate arbitrary data with each other without having the appropriate get/set methods for that data.

During my past experience I have encountered quite a number of scenarios (some of which are described below) requiring that capability with the only solution of having custom sub type of object with addition of those two methods.

  • Caching. In high volume transaction environment where thousands of short lived event objects go thought the system components it might be best to have the components associate the data they retrieve for that event to the event itself instead of caching internally with the reference to that event and later going through the trouble of identifying dead events for cleanup.
  • Identification. Again instead of storing reference to the object internally for later identification the component can associate ID data to the object itself, something like passport in real life..

This has been partially influenced by Servlet API session/request objects with the similar functionalities (which are the most heavily relied upon methods in any Servlet based application written on the earth).
Like in case of Servlet session object it can also be misused.


Continue Reading »

Software Engineering 29 Jun 2006 11:17 am

Ruby Namespaces and source file size.

For Java programmer it will look at best a bad practice to include more than one class or module in a single source file.
Personally I think keeping code and source file at 1:1 ratio is much cleaner approach and is easier to manage for the following reasons:

  • You don’t have to guess which classes or modules are included in particular .rb file. The file name should tell what it class/module includes.
  • It is difficult to read a source file where it contains more than on class or module, unless the classes or module are small enough you soon will get confused which methods belong to which class or module.
  • We don’t want source files to be longer than lets say 1000 lines.
  • When used in source control repositories like CVS it will be a nightmare to have
    multiple developers work on the same physical file.
    This thought is problem as long as particular ruby file and included classes and
    modules are owned by one developer.

Ruby Namespace approach is another thing I don’t really like. To have classes/modules with the same name not to clash with each other during program load we need to declare them in different parent module, which means I have to include all classes/modules in one big file if I want them to have same Namespace.

Software Engineering 22 Feb 2006 12:59 am

Don’t draw yourself.

One of the first practices taught in CS on OO design is that objects should
encapsulate most of operation required by a system it is intended to run.
Thought this does make initial sense and has been a workable solution for
some time it simply does not scale and contradicts real world scenarios.
For example let’s take the same “draw yourself” scenario.


Continue Reading »