Monday, March 20, 2006

Java UK06

It was great to be there but in general, nothing new. The upcoming trends are well known:
  • EJB 3
  • JSF
  • JAXB
  • AJAX
    It means - everyone should pay attention to this topic if wants to be part of the main-stream.
    What surprised me at most was a fact, that the SOA seems to be dead. You probably remember the hype around SOA but when it comes to reality, there is a silence of the lambs ...
    Just a small example: at Java UK06 there was a track 3 and track 4. Track three objectives concerned the JSF and AJAX and took place at middle-size side-room. Track four was about SOA and took place at the main conference hall. And while track three was literally overcrowded, there were just about 10 people who waited for an SOA experience. And when I looked to the empty hall I spoke to myself - SOA is dead ...
  • Tuesday, March 14, 2006

    Java UK06 London

    I'm going to visit Java UK06 today. It will be my first pure java community experience and I just can't wait :-) I hope I'll find some of Glassfish guys out there. Anyway, the program looks pretty good (check it out). I'm interested especially in Java EE 5, but I'll certainly take on look on some SOA stuff (just because of the hype around)and Web development (it will be mostly about JSF however it is good to know my enemy :-))
    Finally, I'll be back on Thursday and I'll definitely write an article on my trip to London Java UK06

    Sunday, March 12, 2006

    Progress information

    Weekend is gone so here's the current status of my EJB3 vs. Wicket effort:
    Work on all parts is in progress ie. database is running, ejb tier basically works, wicker layer is working. More in-depth view on all technologies involved
  • Database: tables are ready and database generation script done as well.
  • EJB: persitent beans are finished, other beans basically works but there is still a lot of work ahead. Skeleton of webservice, which is just an interface between session beans and logic hidden behind, is completed.
  • Wicket: web layer is working too. Most of the panels are unfinished so the application could be rather called a torso application, however the main idea is already apparent.
    You can download tarball of the application from here and here. Note that required libraries (axis and wicket) are not supplied !
  • Saturday, March 11, 2006

    The easiest way to create a webservice in EJB3

    As you certainly already know, webservoces rules the world. You can call them from almost anywehere means any platform, any technology. To create a webservice in the world of EJB2.1 and related technologies used to be a tough task. The upcoming EJB3 is changing a lot in this area. From the developer's point of view, the main change is that to create a webservice he/she doesn't need to be a guru. For demostration purpose I've created a tiny Webservice. Actually it doesn't do anything useful just calls to underlaying EJB.
    The very basic principle of creation of webservice is to develop class that is an EJB (stateless or stateful) and mark it as a webservice. It means annotate class as @Stateless and @WebService. If you do that, you've got a webservice but unfortunetaly without any accessible method. To publish a method as a web method simply annotate a method with @WebMethod annotation. And here is the example of WebService:
    package org.defectus.ejb3.ws;

    import javax.ejb.Stateless;
    import javax.jws.WebMethod;
    import javax.jws.WebService;

    @Stateless
    @WebService(serviceName = "ResultService")
    public class Service {

    @WebMethod(operationName="TestResult")
    public long testResult (long id {
    return id;
    }

    @WebMethod(operationName="StringResult")
    public String stringResult (String id) {
    if (id == null)
    return "null";
    return id;
    }
    }
    The next step is to deploy such webservice. It should be an easy thing but for me it's not like that. I don't know why but to successfuly deploy webservice I have to call WSGEN manually. Manually in my particular case means to call an ant's task. For example like this:
    <target name="generate-wsdl" depends="compile-ejb">
    <mkdir dir="${build.dir}/generated/wsdl" />
    <mkdir dir="${build.dir}/service" />
    <exec executable="${appserver.dir}/bin/wsgen" failonerror="true">
    <arg line="-extension -cp ${build.dir} -d ${build.dir} -r ${build.dir}/generated/wsdl -wsdl org.defectus.ejb3.papp.ws.ResultService" />
    </exec>
    </target>

    After you deploy the webservice don't forget to use a nice feature of glassfish - webservice tester. Just locate the webservice in administration console adn click the Test button.
    And that's all for now. I'll try to find another feature to explain latter ...

    Thursday, March 09, 2006

    Several of links to opensource friendly corporate sites

    Logica
    IBM
    Thoughtworks
    I'll find more but these are good example of how even big corporations participate on open source and community initiative.

    Tuesday, March 07, 2006

    EJB3 and Wicket

    It's been a long time I posted something new to the blog you're reading and now it's finaly time to write about my progress on a technology field.
    First of all - my EJB 3.0 example in this blog was mentioned in official Glassfish blog. I was really surprised ! And I will proudly work hard to make a lot of new achievements that can be displayed on a frontpage of some well respected blogs.
    In EJB3 is still water mow - nothing revolutional is going on - everyone work hard to stabilized source code. I don't have any information that in near future there will be same major changes in specification and/or implementation of EJB 3.0. For myself I have to say I'm working on a new project - it would be some kind of time-tracker or something like that - I'm not sure if I will be able to finish this work but hopefuly I will ... If not, there will be another torso of example application .-)
    With Wicket I have no progress and it makes me unhappy. Wicket team have just announced version 1.2 beta so it's good time to restart my attempt to create something meaningful using the framework. Here is my idea (vision) from the used technologies point of view:
    Database is Oracle, actually without any logic in PL/SQL (would be added latter but it requires some kind of mapping tool - iBatis could fit my needs)
    Logic will be encapsulated in Glassfish. EJB3 persistence will handle database layer (there would be a number of native query as I really like SQL), above it will be a number of stateless beans acting as facade and even higher will be a webservice managing all the stuff.
    The client side would be done in Wicket. This application will run on Tomcat and using Apache Axis it will call Glassfish backend.
    Right now I have a database model, persitence layer without queries, sample facade bean and sample webservice. I also have a skeleton of Wicket app - means build.xml.
    In upcoming weeks I expect a significant progress because after that I have to prepare myself to another certification - and that costs time and huge amount of brain energy .-)

    Wednesday, March 01, 2006

    Don't use resource injection for anything stateful in Java EE 5 !

    EJB3 has an impressive feature - a resource injection. You can mark class attribute by annottation @Resource or @EJB and application server will inject requested resource at runtime. So far so good, but imagine servlet that uses stateful EJB. When you run this servlet in single-threaded model then there is only one instance of servlet with only one injected resource - so as the result, everyone who calls the servlet uses just one stateful bean ! And mostly, this is not what you want allow, mostly you want bind one servlet session to one stateful bean. The same trouble is for example with @PersistenceProvider. However in this case things are even complicated - your application should run smoothly but from time to time you'll experience serious troubles concerns threading and transactions. This is a side effect of fact that @PersitanceManager is not thread safe and can't manage multiply transactions.
    Do you want to know more ? Click here !