Saturday, December 6, 2008

JWS

New spec of JWS uses JAXB 2.0 for JAVA/XML binding. The binding info can be provided in form of annotations on java classes or in external binding file. If annotations have this info then it will be used during deployment and run time. But if the binding information is in external file then it will be used only during deployment time and not during execution. 
One good feature of this JWS spec is that if some info is not provided on java classes for exposing them as web service then it will assume defaults. 

Friday, December 5, 2008

JPA One to Many query

Assume there is a parent entity and has one to many relationship with a child entity. We want to write a query where in a record of parent entity is comapred against each row of its children, we can IN operator.For example 

SELECT e.name, d.name from Department d, IN(d.employees) e where e.salary > 100000

Wednesday, December 3, 2008

Size in JPA

JPA has a very nice feature wherein we can get the size of rows in a child table.  The EJB QL will be something like this
Select r from Department d where size(d.employees)  > 100

 

Wednesday, May 21, 2008

Developer..




Copied from http://zuru.sufx.net/dev/developers.jpg

Choosing a technology for enterprise level application development

At the start of the many projects, the teams and business people face the problem of selecting the best technology for the project. There are various factors which need to be considered while selecting any technology. I had been part of many such teams.
Couple of teams decided to go for technology which I would never recommend .

In one such case, Oracle form was selected to develop the project. The only reason it was selected because it provides quickest way to develop UI. But that not the way to develop an enterprise level project. One has to see the maintenance cost, durability, support for the tech from the vendor, longevity of the project etc.

In another project HTML DB was selected. Everything works fine and application goes into production. But the nightmares start when customers start asking for changes, enhancements etc. Since in such tech. the code (mainly SQL and procedural code) is scattered all over the places the changes become headaches. One example is that the team needed to refactor(or normalize) the tables but this idea has to be dropped as the tables were used at many places in SQLs and SQLs were scattered all over the places. Even after changing the testing would have been almost impossible.

The solution is to develop the systems in OO languages and the one which provides total ecosystem (from ui, server code etc till deployment phase) for enterprise development.

J2EE (now JEE) perfectly fits the bill. Many advantages go in favor of JEE tech stack trace. First, it is based upon open standards. If you feel like improving something in it, you can be part of JCP. There is a huge open source community behind it along with well established vendors like IBM, Oracle, SUN etc. It is not dependent upon the whims of one big corporation which will do anything to kill the competition and then later will force its customer to pay heavy license fees and/or buy upgraded expensive versions. J2EE tech provides many frameworks to make the system stable, robust, easy to change,easy to monitor etc (junit, logging, continuous integration etc, mock objects etc). All this adds up to good ROI and feel good and confident factor for the customer.

Friday, May 9, 2008

Axis2 - Exposing an existing java service as web service using axis 2

1) set axis2 classes in the classpath. Copy jars from axis2-installation-directory/lib folder.
These jars will go in WEB-INF/lib folder
Can download axis2 from http://ws.apache.org/axis2/

2) Add the following, as shown in the picture in the web.xml of your web project
Click to enlarge below image



As per the last mappping if the URL contains /services/ it will be routed to the AxisServlet. Other servlet mappings need not be there, if not required.

So the end point address for the Web service will become
http://host:port/webcontext/services/webservicename


3. Create services folder(i.e. with name 'services') in the WEB-INF folder
4. Create new folder inside the services folder with the name same as the web service name e.g. DataService
5. Create META-INF folder inside the folder created above in step 4 .
DataService
--- META-INF
6. Create services.xml inside META-INF folder
DataService
--- META-INF
services.xml

Write info about your web services in the services.xml like in the picture.

Click to enlarge below image





Thats all...your web service is exposed to the world now.... :-). If you want to create wsdl of the web service and are using eclipse then can download axis2 eclipse plugings from http://ws.apache.org/axis2/tools/1_0/eclipse/wsdl2java-plugin.html

Caution - Please make sure the cases of the service names match in the service.xml and the folder which is created.

Next topic - Integration with spring