Extending the BC4J Transaction
Monday 28 November 2005 @ 12:06 pm
Filed under:

One of the things we like about the Oracle Frameworks is open-ness and extensibility of the frameworks.

During our project we encountered the infamous web application problem of having two users edit the same data. The database and framework lead us to a few nice exceptions that resemble ‘RowInconsistentException’ or ‘RowAlreadyLockedException’.

The Oracle ADF Business Components framework gives us the possiblity of extending the transaction to catch this exception and do somethnig about it. We currently have decided that when these kind of exceptions are encountered that we want the transaction to be rolled back and a humanly readable exception to be displayed.

As an example we used the example of Steve Meunch (the Oracle ADF guru) and made this:


package nl.denhaag.grip.model;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import oracle.jbo.AlreadyLockedException;
import oracle.jbo.ApplicationModule;
import oracle.jbo.DeadEntityAccessException;
import oracle.jbo.DeadViewRowAccessException;
import oracle.jbo.JboException;
import oracle.jbo.Key;
import oracle.jbo.Row;
import oracle.jbo.RowAlreadyDeletedException;
import oracle.jbo.RowInconsistentException;
import oracle.jbo.ViewObject;
import oracle.jbo.server.DBTransactionImpl2;
import oracle.jbo.server.TransactionEvent;

/**
* Custom ADF DBTransaction implementation.
*
* Works in tandem with a custom DatabaseTransactionFactory implementation
* which returns instances of this subclass of DBTransactionImpl2
* instead of the default one.
*
*/
public class GRIPDBTransactionImpl extends DBTransactionImpl2 {

/**
* This framework method is called by clients to commit any pending
* changes in the transaction. It will first post any outstanding changes
* then issue the database commit to end the transaction.
*/
public void commit() {
try {
super.commit();
}
catch( JboException e ) {
handleException( e ) ;
}
}

/**
* This framework method is called by clients to validate all invalid
* objects in the transaction.
*/
public void validate() {
try {
super.validate();
}
catch( JboException e ) {
handleException( e ) ;
}
}

/**
* This framework method is invoked both by the postChanges()
* and by the commit() methods to post pending transaction changes.
*
* @param te TransactionEvent object
*/
protected void postChanges(TransactionEvent te) {

try {
super.postChanges(te);
}
catch( JboException e ) {
handleException( e ) ;
}
}

/**
* This framework method is called to actually issue the final
* 'COMMIT' statement to the database to end the transaction.
*/
protected void doCommit() {
try {
super.doCommit();
}
catch( JboException e ) {
handleException( e ) ;
}
}

private void handleException( JboException e ) throws JboException {
if( e instanceof RowInconsistentException
|| e instanceof RowAlreadyDeletedException
|| e instanceof AlreadyLockedException
|| e instanceof DeadEntityAccessException
|| e instanceof DeadViewRowAccessException
) {
rollback() ;
throw new JboException( "Een andere gebruiker heeft dezelfde gegevens ook gewijzigd. Uw wijzigingen zijn niet doorgevoerd, de nieuwe gegevens worden getoond." ) ;
}
else {
throw e ;
}
}

public void rollback() {
try {
// storeCurrencies
ApplicationModule appModule = this.getRootApplicationModule();

HashMap currencies = new HashMap() ;

String[] voNames = appModule.getViewObjectNames() ;

for( int voIndex = 0; voIndex < voNames.length; voIndex++ ) {
ViewObject vo = appModule.findViewObject( voNames[ voIndex ] ) ;

Row row = vo.getCurrentRow() ;

if( row != null ) {
Key key = row.getKey() ;
currencies.put( vo, key ) ;
}
}

super.rollback();

// reset Currencies
for( Iterator i = currencies.entrySet().iterator(); i.hasNext() ; ) {
Map.Entry entry = (Map.Entry)i.next() ;

ViewObject vo = (ViewObject)entry.getKey() ;
Key key = (Key)entry.getValue() ;

Row[] rows = vo.findByKey( key, 1 ) ;

if( rows != null && rows.length == 1 ) {
vo.setCurrentRow( rows[ 0 ] ) ;
}
}
}
catch (Exception e) {
if( e instanceof JboException ) {
throw (JboException)e ;
}
else {
throw new JboException(e) ;
}
}
}
}

It actually doesn’t do much. but enough for our purposes. For the framework you need to wrap this transaction implementation in a factory:


package nl.denhaag.grip.model ;

import oracle.jbo.server.DBTransactionImpl2;
import oracle.jbo.server.DatabaseTransactionFactory;

public class GRIPDBTransactionFactory extends DatabaseTransactionFactory {

public DBTransactionImpl2 create() {
return new GRIPDBTransactionImpl();
}
}

Even less code…

Now the magic to extend the framework: Open up your Configuration of your Application Module and goto the properties page. Scroll down all the way and find the ‘TransactionFactory’ property. Fill the with the complete classname of your own factory and presto….

Note: when using the BC tester to run your Application Module, make sure you choose the Configuration (at the top right of the screen where you select your connection) or your settigns won’t be loaded.

— By Robert Willems of Brilman   Comments (5)   PermaLink
Who needs an architect?
Tuesday 22 November 2005 @ 11:14 am
Filed under:

Who needs an architect? I came across this rather old article while I was searching for certifications that will lift my career, or the careers of my colleagues, into unexpected dimensions. We all know the Sun enterprise architect certification. We all also know the certification is nice as a piece of paper, a line in your curriculum, a commercial oriented added value but do we know the real value of such a certification? Does SCEA really take your career to the next level? The Sun variant is a vendor independent but technology driven approach to call yourself an architect. I was wondering, what other variants are there? And how do they compete or comply with SCEA?

Well, on one hand you can certify till the end of time, on the other hand finding a descent program seems to be a hell of a job. Every enterprise vendor has its own enterprise certification trail. Look at BEA, IBM and even JBoss. But what are these papers actually worth? And when going vendor, technology and even methodology independent, is it still possible to get you officially branded as an architect? My little research journey found exactly one organization that can act as a tattoo shop to get your certification logo’s : The OpenGroup, an ‘independent’ company running the Open Group IT Architect Program. This PDF describes how they think an architect should be skilled.

Back to the article. Let me quote a quote from the article: In most successful software projects, the expert developers working on that project have a shared understanding of the system design. This shared understanding is called ‘architecture’. and compare it with the OpenGroup definition: IT Architects develop architectures: the definition of the structures of an IT solution to a business problem. Is it me or can we call this slight difference of interpretation a gap?

Let’s map both definitions to SCEA: This certification is for enterprise architects responsible for architecting and designing Java 2 Platform, Enterprise Edition (J2EE) technology compliant applications, which are scalable, flexible and highly secure. I’m getting twisted. The shared understanding of system design, that has to meet certain criteria like being scalable (hey, my app will be used by only 10 designated users?), flexible (hey, may app is write once, run once, never touch it again?) and secure (hey, my app is for everyone, and I mean really everyone, who has spend time wasting energy to find my app?) needs to be defined in structures that solve a certain business problem! If this is the case, I’m out of it.

But still, the urge to re-dimension my career by certification is left unfilled. How do I become an architect who’s existence is not (explicitly) needed but who’s authority is branded in a simple shift of a t-shirts position showing an ugly painted tattoo telling yep this is an architect, look at the picture on his shoulder, who can help others solving problems by drawing (and setting-up/building in corporation with other expert developers!) the fundamentals of a solution? The OpenGroup approach gives a hint. Instead of way to many stupid multiple choice questions that need to be answered in order to get certified, their program is focused on proven experience and activities from the past. So, you can send them your track record, go through the process of certification, get weighted by all kind of committees, and become an architect. If they could only change their definition to get in line with Martin Fowlers article …..

So here’s what I did. On my left arm tattoo-bob has painted some nice looking tribals that are an Hawaiian translation of the definition of architecture, on my right arm tattoo-bob has painted every major vendor logo I could find and on my back tattoo-bob has written my curriculum. And whenever someone asks for my certifications, I take off my clothes and show them my ink. And if someone is asking which organization is behind my certification, all I have to do is point them to tattoo-bob!

— By Okke van 't Verlaat   Comments (14)   PermaLink
Websphere for free
Wednesday 16 November 2005 @ 5:50 pm
Filed under:

Indeed, IBM has released a free application server. They took Geronimo, branded it as Websphere and hope they can sell support services with it. Seems like a good deal? Might be. In case you’re not in the position to buy a way to expensive product like the real Websphere but you need an app server with support, WAS-CE might be the thing you’re looking for. Of course you can also use JBoss and trust on the support the open source community is giving you for free :-)

— By Okke van 't Verlaat   Comments (0)   PermaLink
The ever growing list of frameworks
Wednesday 16 November 2005 @ 5:14 pm
Filed under:

Via Matt Raibles weblog I found Simon Browns blog and this guy gave himself the impossible mission to compare the whole bunch of presentation frameworks that are currently available through the open source community. Colleague Rob de Jong already asked the question which framework to use and which not. Maybe Simon’s journey will useful answering this question but when looking at the ever growing list of frameworks, I’m more interested in the real drive behind these frameworks.

For example, I took a look at Mentawai (I won’t comment the name, promised :-) ). Not mentioned in Simon’s list but plugged into the comments section of his announcement blog. Beautiful, look ma, no XML! Completely in the style of better and lighter. But, except for the configuration approach, what does it better or faster or lighter than any other framework out there? No idea.

Another example, Stripes. Never heard of it and a quick walk through the wiki documentation showed me this framework also has some original approaches not found in other frameworks. Again, look ma, no XML! This time we have to deal with annotations hell. Okay, fine, don’t like it but can live with it. But still, I can not see a reason to select this particular framework for the applications I want to build.

Maybe, and simon’s journey might be useful, somewhere in the future my opinion will change and I will actually use or even promote these frameworks, but right now I can only conclude they are primary written to fill a gap in someone’s spare time and won’t help me finding a way to speed up development.

Personally, when looking at development speed (the number of hours a developer need to spend to get something done), I do not believe in frameworks solving trival issues like request dispatching or mark-up generation. I think we need to look at frameworks who do it all (maybe supported by frameworks focused on elementary aspects like O/R mapping, security or logging). And with all I realy mean all. The complete application. Top to bottom. The full monty. Like Rails for Ruby. Yep, I took a look at Trails and Grails and somehow both frameworks could not convince me: I do not care someone is ripping a great idea but at least rip the good things and do not introduce bad ideas like annotations (Trails is using them where Rails simply uses naming conventions (in combination with a very dynamic language :-) ) or an impossible code-deploy-test cycle (Testing Grails applications feels like waiting on a bus, step in, step out and wait for the next one). I wonder, is it me? do I miss the point? Or is it really true I’m looking for something that does not and will never exist in our world?

— By Okke van 't Verlaat   Comments (7)   PermaLink
Better, Faster, Lighter Java
Monday 14 November 2005 @ 11:22 am
Filed under:

Bruce TateBruce Tate, successful author of several books including the well known Better, Faster, Lighter Java, held a presentation during the Guru4Pro meetings in the Netherlands. The Guru4Pro meetings are organized to facilitate the exchange of idea’s and information between profesionals. This all in an informal atmosphere. Approximately 120 people attented the presentation and evaluation showed that all visitors were extremely satisfied. After the last presentation slide a lively discussion followed about the predictions that Bruce made.

  • The JCP becomes increasingly fragmented
  • Java slowly loses its leadership position
  • The JVM becomes more important to dynamic languages
  • We see a backlash against
    • Annotations
    • AOP
    • The backlash may or may not be warranted

You may agree or disagree with the predictions but they are surely food for thought.



Personally I totally agree with the predictions that “Java is going to lose its leadership position” and that the “JVM is becoming more and more important to dynamic languages“.

As coach of several junior programmers I often hear them complaining about:

  • things just being to complex
  • the total fragmentation of Java

A succesfull implementation of an entry level Java program such as a simple database driven website can already be damn complex. Using technologies like PHP, Ruby etc who enable me to implement the same functionality in a shorter timeperiod I start wondering why this cannot be done by using Java. Offcourse there are quickstarters like Appfuse etc. but again this is all not for the faint of hart.

Note that the presentation of Bruce is attached to this post :)

— By Marco Pas   Comments (4)   PermaLink
Sun Java Studio Creator & Sun Java Studio Enterprise 8 now free !!
Friday 11 November 2005 @ 9:11 am
Filed under:

At the last JavaOne held in Tokyo, Sun announced that it will make Sun Java Studio Creator & Sun Java Studio Enterprise 8 available for free. This opens a whole lot of possibilities for nada.. :) Use Creator for your JSF needs and the Enterprise version for developing J2EE including UML 2.0 modelling..

Java Studio Creator

Get it here :

— By Marco Pas   Comments (0)   PermaLink
Gates warns of ‘disruptive’ changes
Wednesday 9 November 2005 @ 8:24 pm
Filed under:

Today a memo from Bill Gates himself spread across the Internet. It talks about competitors that challenge Microsoft in the so called ‘online service’ age. Earlier memo’s from former Groove chief Ray Ozzie, talk about missed opportunities for Microsoft. Companies like Google, Adobe, Yahoo and Skype have met the growing need of speed, simplicity and loose coupling. In these
area’s Microsoft has not yet used its full potential and it is necessary to do this as it will change business as we know!

Some examples of missed opportunities:

  • Microsoft LiveMicrosoft knew that searching would be very important, but through Google’s focus they have gained a strong position despite the efforts of Microsoft.
  • Microsoft should dominate the AJAX space for their effort in OWA (Outlook Web Access), but again small players with more focus are in control.

Microsoft has a lot of opportunities if it can create a common succesfull service’s platform. The first efforts already look promising as Microsoft Live and Office Live have been announced and for some parts already are implemented.

We all like Microsoft bashing (why :? ) make sure and take a closer look, these guys are really putting out some nice stuff. Innovation is driven by companies and individuals with a strong focus. So let us focus on Java technology and keep innovating :) Maybe we will be ready to implement our own services! See you all in the service age :!:

>> Read the full article

— By Marco Pas   Comments (2)   PermaLink
Starting with Ruby
Tuesday 8 November 2005 @ 3:59 pm
Filed under:

I know it’s a bit off topic, this blogs main focus is Java, but hypes, rumours and a personal demonstration by Bruce Tate made me realize I should ‘do’ something with the scripting language called Ruby. I’m not going to write a lengthy blog about my initial impressions, instead I just provide a link to an excellent article not on the language itself but on how to get started. Really useful. Read and play ….

For those who can’t wait, here’s a link to download the ruby eclipse plugin and get started (assuming you’ve downloaded ruby itself from the ruby homepage, for windows users, this installer will save a lot of time).

— By Okke van 't Verlaat   Comments (7)   PermaLink
Guru4Pro met Bruce Tate
Thursday 3 November 2005 @ 5:00 pm

Java Guru4Pro.
Better, Faster, Lighter Java

Op donderdagavond 3 november heeft LogicaCMG Bruce Tate in Delft uitgenodigd om te spreken over een aantal basisprincipes die terugkomen in al onze werkzaamheden. Bruce Tate heeft zo�n vijftien jaar ervaring binnen het ICT vakgebied en is als onafhankelijk consultant de auteur van vijf boeken inclusief de bestsellers Bitter Java en Better, Faster, Lighter Java. Bij IBM heeft Bruce verschillende �Java� rollen vervuld en IBM heeft patenten aangevraagd voor acht van zijn oplossingen.

Op 3 november gaat Bruce Tate in op �Better, Faster,Lighter Java�.
In deze presentatie komt hij terug op een aantal basisprincipes die terugkomen in alle werkzaamheden:

  • Keep it simple � streef naar de meest simpele oplossing van het probleem
  • Do one thing. Do it well! � Complexe problemen oplossen door middel van een set van simpele oplossingen
  • Strive for transparancy � Generieke oplossingen voor veel voorkomende �crosscutting concerns� zoals logging, database persistentie etc.
  • You are what you eat � Weloverwogen keuze van basisset aan frameworks en tools die voor de klant worden ingezet.
  • Allow for extension � opgeleverde applicaties dienen uitbreidbaar en herbruikbaar te zijn
  • Voor meer informatie en inschrijving >> Beter, Faster, Lighter Java

— By Marco Pas   Comments (0)   PermaLink

Menu


Blog Categories

Browse by Date
November 2005
M T W T F S S
 123456
78910111213
14151617181920
21222324252627
282930EC

Upcoming Events

Monthly Archives

Recent Comments

Links


XML Feeds Option


Get Firefox  Powered by WordPress

code validations
Valid RSS 2.0  Valid Atom 0.3
Valid W3C XHTML 1.0  Valid W3C CSS