Casper Bang

Subscribe to Casper Bang feed
This blog is about Oracle JDeveloper and its Application Development Framework (ADF) as well as related technologies such as Struts, BC4J and WebServices.Casper Banghttp://www.blogger.com/profile/10291818266461370018noreply@blogger.comBlogger2125
Updated: 5 hours 32 min ago

Inception of ADF NOOB

Thu, 2006-02-02 09:32
Welcome to my blog which will revolve primarily around real-word development issues using Oracle's JDeveloper IDE and their Application Development Framework (ADF). It is my attempt to communicate what I have learned to peers and in the process hopefully gain a better understanding myself.

What?
ADF is vastly different than traditional web application development as well as other 4/5GL frameworks. It introduces an enterprise development infrastructure unlike most other, with a shift towards a highly declerative paradigm which encapsulates all parts of a J2EE application. ADF and the associated IDE, JDeveloper, relies on a complex stack of associated tier technologies and as such, is not the easiest to get started on without feeling that you are drowning in complexity. This blog will deal primarily with Apache Struts as the controller tier and Oracle UIX as the view tier, running on top of Oracle 10g.

Why?
While ADF and its associated tier technologies are definately not as easy to get started on as classic server side scripting with embedded PL/SQL nor other frameworks (Rails, Spring etc.), it constitutes the higher learning curve in the long run by addressing application issues on a large scale such as maintenance, service orientation and rapid application development (RAD). In a testiment to this, in a recent development contest Oracle ADF took home the gold and silver medal for being the most productive RAD framework. While neither JDeveloper nor ADF is open source, it is completely free to use and applications can be deployed to any J2EE-compliant application server. On a personal note, ADF is about the only framework I've come across, which allows a composite/joined table view to get its related (detail) table updated as well as the primary (master) table by means of the framework!

Why not?
As already mentioned, in order to benefit from the ADF framework you really must be willing to put in a substantial amount of time before you can expect to develop any real-world applications. On a more subtle note, realize that while ADF is at a fairly mature state as of JDeveloper 10.1.2; tools, documentation and community support might be sub bar compared to what you are used to in other development environments and frameworks. And finally you should also be aware, that standards and next-generation technologies will append or replace ADF and currently associated tier technologies. For example, the next version of JDeveloper (10.1.3) introduces a new view and controller framework known as Java Server Faces (JSF). Developer Joel Spolsky has an entertaining analogy to the complexity of frameworks.

How?
ADF encapsulates many J2EE patterns within its framework, including the infamous MVC pattern. From top to buttom, a typical ADF application can be though of as having 4 tiers.



The view tier which is where all the UI rendering happens, a controller tier which handles navigational aspects and a model tier where data is bound to the final tier; the Business Service tier.
These Business Services are at the very core of ADF and this is where you will find the applications point of entry, known as the Application Module (AM). To uptain a detailed understanding of how the underlying binding layer works, Oracle publishes an up-to-date ADF Data Binding Primer.
Categories: Development

The Model: AM, Entities, Views etc.

Thu, 2006-02-02 09:27
As already mentioned in my first blog entry, ADF is composed by a multitude of layers within a large technology stack and these can be abstracted into the MVC pattern. In reality, the View and Controller layer in ADF is collapsed into the same layer and this is why most ADF applications actually consist of 2 independent projects within one ADF application, namely the Model and the ViewController. The following provides a quick and rudimentary explanation to what you will find in the Model part of such an application.

Application Module (AM)
This is your applications point-of-entry and essentially responsible for launching and managing the data-model beneith your applcation. Whichever Views and ViewLinks you may have created will not have any effect (be visible) before they are added to the AM. The default implementation of the AM is in ApplicationModuleImpl.java which will have a main method for launching a default Swing test application which can come in very handy when debugging and testing your model layer. You may extend the default implementation, as is often nessesary, in order to satisfy various pre-condtions such as user authorization etc. For example, to lock a specific view (E.g. UserView) to only show records with the users own initials (CLB in my case), the following could be done:

protected void prepareSession(Session session)
{
super.prepareSession(session);
this.getUserView().setWhereClause("UserView.initials = :initials");
this.getUserView().setWhereClauseParam(0, "CLB");
}


Whichever view is linked to the UserView, will "inherit" this limitation and thus provides an excellent way of ensuring users see only their related rows. This could not have been achieved by a pure static view since the view is dynamic by nature, adapting to whichever is signed in to the system.

Entity Objects
Entity objects are at the very heart of an ADF application and its responsibility is to encapsulate a database table (and its rows). The framework will require there be a primary key column before doing so, the reason for this will be obvious in a moment. A java representation instance is required in order to model layers on top and add business logic. ADF can overide the default Java representation for an Entity and expose type-safe accessor methods for
association attributes rather than the default getAttribute("
"). In JDeveloper an entity has both an instance (.java file) and related metadata (.xml file).

Associations
Handles relation and cardinality between two entity objects. These attributes allow you to navigate from one entity instance to either another entity instance or a collection of related instances, depending on the cardinality of the association in question. This can be done by using
getAttribute("
") where the framework will use the association to perform a findByPrimaryKey() on the related table and fetch the data for you. Associations are paramount to making views over multiple Entities, by using the association information to automatically construct the underlying join (WHERE clause). Associations are just metadata for the entities, stored in corresponding XML files.

View Objects
In the simplest sence, a view is nothing more than a SQL query. However, even if a view is composited over multiple Entity objects, it can be updated just as if it was an atomic table in the database. This is done providing the "reference" attributte for the Entity object is checked and is what distinquishes an ADF view from a database view.

ViewLinks
Handles relation and cardinality between two view objects. ViewLink's connect two views in a Master-Detail fashion, where the master view provides an overview og more detailed data, usually as a 1:* relation between views. When a ViewLink is created between two views, the newly linked attributtes become available to each view.

Categories: Development