Spring WS client.

In my previous post I described how to create sample Spring Web Service.
In this article I am going to show how to write generic Web Services client for it (or for any other Web Services).

The idea here is to define java interface that will mirror WS request/response messages and have a Spring proxy to take care of WS calls and XML marshalling.
In previous article we defined SampleEndpoint that was Java back bone of our WS.
What we whould like to do is to have Java interface that will mimic SampleEndpoint public methods and have Spring create WS proxy for it to be injected into our WS clients.

Continue reading Spring WS client.

Spring WS+JAXB

Download projects

Here is sample Spring WS application that shows how to expose your bean method as WS service and handle XML marshaling using JAXB.

There are 4 major parts involved here.

Continue reading Spring WS+JAXB

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 Spring MVC+Custom Multy Action support.

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:

  • Setting up web.xml with CXFServlet.
  • Defining POJO endpoint.

Continue reading CXF+SPRING+POJO

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 Mule+Maven+Eclipse

DOJO+DWR+SPRING+AUTHENTICATION

Intro:

Download projectdwr-test.zip
Download WARdwr-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 DOJO+DWR+SPRING+AUTHENTICATION

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 Maven Run/Build Plugin 2

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 XFIRE+EJB+POJO

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 order to execute 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.

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 Map Object.