Monday, May 14, 2007

JavaOne 2007 day 4, Hibernate Search

Hi this is the last day of JavaOne and my first session is Hibernate-Search, I was interrested in this due to the fact that it I normally have trouble using different advanced search-patterns in my apps and these tend to be slow(execution-time) and hard to develop.

The presentation covered all of this, and explained the problems with text-based search for a domainmodel. I feelt like i understood all of this and the problems with it, the solution for these mismatches between objectmodel and indexed-text-search was made available only for Hibernate users. This was my problem, i was hoping for something more generic that i could implement on the DAO model. I will mail and ask about this, or it might finnaly be time to Contribute something to a openproduct, who knows.

The needed frameworks for this to work is Hibernate, Hibernate-Serarch and Lucene (the searchengine).

The solution is this, its possible to markup our objectmodel with indexing annotations (yes another annotation). These indexes are then mapped to the objectmodel using the model keys. You then use the IndexedSearch (or what it was named) to execute the query to the Lucene index. The result is handeled in the same way as a normal Hibernate-query.

see Hibernate Search

My thought on this are, its really elegant, but lacks integration for non Hibernate users. I would use it if possible!

Friday, May 11, 2007

JavaOne 2007 day 3, Garbage Collection friendly coding.

This was i nice and fun session.

If you just want to remember one thing from this its: DONT use finalize method for anything in java. The other things are normal memmory misuse stuff.
1. Always declare an Collection(impl) to an approx size of what u want, it not as sheap as one thinks to resize collections.
2. Small, immutable objects are really fast for the GC. Dont be clever and create them outside the loop or the normal life scope of the variable. Do not create generic variables that are nullified and reused in a method or loop.
3. Be aware of actionlisteners these keep reference to our instance and can create memmory leaks. This kind of behaivure is not as uncommon as one might think, even others than the AWT-tam make these kinds of programs.
4. If unclear dont use finalize, ever. DONT use them. If something like this i really needed, no other way can solve the problem, then use Reference classes(java.lang.ref.PhantomReference) and wrap the instance that needs this.

There were more tips, but i cant remember them all.

JavaOne 2007 day 3, Project Phobos.

This is another new engine/framework for the java plattform. It is used so that programmers are able to run scripts on serverside and client side. Phobos supports any scripting language that the Script-engines for java does, but its created for javascript. The idea is to use javascript on the server aswell as one the client. This is suppose to be simpler, i dont agree. All the great things about java are all lost, this is just a runtime for the scripties, im not one of them.

The session showed how easy and fast it is to create and manipulate the client and the server. This problem is that i dont like the way the server "feels" like the client. Another thing is that i normally dislike weaktyped languages, the way i like it is on client where i just use it to present the alread trongtyped java-classes. The only framework for this that i have liked so far is DWR. That i like it dones not remove the good parts of java and replace them, it just extendes them and make them visible to javascript.

Phobos would not recommended by me to solve any level of software creation. Harch but its just my view of it.

JavaOne 2007 day 3, Seam and SOA.

Another session by Gavin King, i really like this guys ideas and energy. First of all there was a change of presentation, the SOA in seam did not work yet.

So instead we got Seam development using JBoss IDE(or some similar IDE). Gavin showed how to create a projekt using seam/facelets and some faces extensions, Richfaces and ajax4jsf. Really pointed to the ability to test things in the real context. This is part of seam.
The demo continued creating a application that used some UI:s from Richfaces and it showed how fast and easily u can create a interactive program today.

So what is seam?
I really dont know all yet but this is some of it.
  1. A way to get a faces/jpa and some application up and runnig requiring minimum configuration.
  2. Minimize the configuration to use jsf.
  3. Create a common plattform for the Bean-context. Supports a new scope called conversation. Conversation is something in between Session and request, but is more useful than session. It is useful for page-flows, tabs and similar parts of the application.
  4. A generation-tool that can easily create boiler-plate code for your new application.
  5. A way to get out of the configuration-hell of all the new frameworks, Seam uses anotations for most of this.
  6. A Security model implementated using anotations. Make it easy to use security on your application. Can be simple or advanced using roles etc.
  7. A validation support using Hibernate-validation through anotations.

There is propably more but i did not get it from this.

I later bumped into Gavin(or i walked to Jboss and there he was) at the Pavilion and asked about the validation support and if they have any plans to support validation depending on the state of the bean that is validated. For example if a IncidentReport is filed a title is all that is needed, later when a user works on the report it suddenly have specific data that might be required and before its closed some other data might be needed.

This gives a more complex usage for Validation, this is something that i usually have to do, i cant be alone!? A way to solve this could be to create a Validation typebound anotation. Like the one Bob Lee presented in the Webbeans session.

@Validation @IncidentReportValidation("#incidentState")
Date solutionDate;

The variable in the custom-validation-anotation is a instance variable in the current Bean.

JavaOne 2007 day 3, Glassfish V2

This was a presentation of the new stuff done in Glassfish V2. A big screwup from my side, i was looking for a session that demoed and used the Glassfish AS. This just explained the clustering(35mins) and touched other new integrations. Not what the doctor ordered...

JavaOne 2007 day 3, Superpackage

This day started with superpackages. This is a pretty interresting way to finally use the java-packages the way alot of people, me included, though it should work. The superpackage is suppose to hide your package from other "modules", and then you are suppose to make the ones u want "public" outside the superpackage. The proposal is that a file called is created in the classpath and this is then compiled into a sort of rights controller for your package. The package is then hidden/exported according to your wishes. The example is (cant remember syntax exactly)

superpackage jdk{


this includes the and in the superpackage and then exports the this means that any program that uses this module can only use the The is an internal packade, not possible to use for thirdparty products.

JavaOne 2007 day 2, part 2

The jMaki is a very interresting Ajax-portable/pluggable framework. It hides the underlying implementation of Dojo, Yahoo, and some. this makes really easy to create and change ajax features. It also has plugins for Netbeans and Eclipse. In short the jMaki is framework i would recommend for doing Ajax if you cant have the Ajax4jsf due to lack of JSF.

Spring/SCA (Service Component Architecture), this was semi-interresting. SCA is a large framework for creating really large applications. It now has integration with Spring so that different parts of an SCA application can be done using Spring. This only feels useful for really large applications with the need for rally clean separation between different parts. Not saying this is not a useful arhchitecture, just that its a LARGE one.

Thursday, May 10, 2007

JavaOne 2007 day 2, part 1

This day started out great, a nice showcase of the Oracle Middleware suit and some demos of the way Oracle is thi8nking about Web&JEE. The demos covered JSF(using ADF) and BPEL, the demo showed great stuff that can be made easily, but don't be fooled this still requires that you have a well defined architechture and that you create and upgrade old stuff accordingly.

The first session was WebBeans, this was done bye an overly active Gavin King and his spec-lead-teammate Bob Lee. This was some interresting work in progress, it addresses the problem of different Application Contexts in different frameworks, creating a new Application Context. But the idea is that this should replace the current ones used i Java, for example the JSF managed beans and the EJB3 beans. Thereby creating a common way of declaring contextual dependencies. Seams promising :)

To continue later... jMaki and Spring/SCA.

Wednesday, May 9, 2007

JavaOne 2007 day 1

The first day has finished. It been inspiring and i have been to some interresting sessions.
My schedule this day was
  • General-session, key-note.
  • Java-SE: present and future.
  • General session: Java platform, future.
  • Java-Puzzlers.
  • Closures.
  • JPA, tips and tricks.
The most compelling yet on my schedule was closures. Its a new java language-feature planed for SE-7, read more at here. The Java-SE session was nice and sadly most of it was duplicated in genereal-session, java platform. Java-puzzler was nice and fun. The JPA, tips and tricks was not really well done and i was slightly bored, this was common tips that can be found on any Hibernate-community. I did not learn anything new from this.

The key-note was really well done, some mishaps as always but all done with the style. Liked the idea of JavaFX, but really dont think that there exists anything at this moment, some Alpha libs and technerds that have a cool idea.

Was at the Pavilion getting free drinks and walked into the developers of JMaki, this is an interresting way of approaching Ajax, asked about plugability and ease of rendering changes. This was not a priority nore thought about yet.

That was it, im hoping for more stuff next day.. ce ya soon.