« May 2008 | Main | September 2008 »

July 2008 Archives

July 8, 2008

ADF in Action: Building the Model Layer with ADF BC (BC4J)

It has been a while. Being busy is a lame excuse, I was also investigating some other things and worked a lot with Oracle Application Diagnostics for Java (AD4J)...

Oracle ADF Business Components

The first version of Oracle ADF Business Components say the light of the world with JDeveloper 3. It was created to address the deficiencies of the EJB 1.1 specification. Although named Business Components this is a framework to create Business Components (for Java). ADF Business Components are usually referred ADF BC or BC4J. I will try be consistent but bear with me if I mix both.

Entities and Views and Application Modules

Like any other ORM framework ADF BC has its own names for the same concepts. The primary concepts are Entities, Views and Application Modules. Entities are usually considered as the representation of a table row in the database, while Views are manipulating the Entities (creating, updating, retrieving, and deleting). While Views work on Entities you need an Application Module to work with the Views and with the data in the database. The Application Module contains all the Views that are need for this module and the necessary information of the underlying database.

Implementing the ADF BC Model Layer

As in the two previous model layers we are reusing the data model created in the database. This is also a strength of ADF BC, working with existing database model instead of creating it from scratch. (As both approaches have their pros and cons, a seperate entry to show these is quite likely.) Like before we're following the same order of steps for JDeveloper 10.1.3 and 11g:

  • Create a Model Layer Project
  • Import the Database Objects

Steps for JDeveloper 10.1.3

Step 1: Create a Model Layer Project

  • To create a new Model Layer Project select OnlineSurvey in the Application Navigator, open the Context Menu and chose the New Project... menu entry.
  • In the New Gallery select an Empty Project and click on OK.
  • In the Create Project window set the Project Name to ModelBC and click on the OK button.
  • Select the newly created ModelBC project in the Application Navigator and open the Project Properties window with a double-click.
  • In the Project Properties window, check the values of Project Content and make sure that the Default Package is set to demo.survey.model.bc. Click OK to close this window.
  • Click on the Connections Navigator. Expand the Database folder, select the survey entry and open the Context Menu. From it select the Properties... entry to open the Edit Database Connection window. Click on the Authentication tab and check whether the Deploy Password check box is checked. If not, make sure that it is checked! ADF BC relies on it.

Step 2: Import Business Components from Tables

Select the ModelBC project in the Application Navigator. Open the New Gallery from the Context Menu -> New .... In the New Gallery expand the Business Tier and select ADF Business Components. On the right-hand side select Business Components From Tables and click on the OK button.

  • In the Initialize Business Components Project window select the survey connection and accept the default values for the SQL Flavor and Type Map (both should be Oracle). Click OK and the OK button on the Login window.
  • In the Create Business Components From Tables wizard step 1, click on the Query button to get all available tables. Once the table names appear, select all of them. Move all entries from Available to Selected, by clicking on the >> button. Like in the other model projects we change the names from plural to singular names. Best is to do it right now by selecting each line in the list and change the appearing value in the Entity Name text field, eg Answers to Answer.
  • Click Finish to end this wizard.

The wizard will now create the Entities and Association files in a single package. This is quite good at the first sight but really tedious if return to the project in three weeks. The naming for the Associations is hardly readable or memorable. Therefore we need to do two things:

  1. Move the Associations and the Entities in separate package.
  2. Rename the Associations with better readable names.

Move the files in separate packages is quite easy. Select all Entities, the ones without the Assoc suffix (Click on the file while holding the Ctrl-key). From the Context Menu select Refactor->Move... and type in the name demo.survey.model.bc.entities. After clicking on OK all files will be moved in the new package. You might be asked for creating the new package directory. This is perfectly OK. Repeat this for the Associations and move them into the package demo.survey.model.bc.links.

Warning! In JDeveloper 11g TP4 this might not finish. If this happens to you, the easiest bet is to kill JDeveloper 11g TP 4 and continue where it stopped.

Renaming the Associations to better readable names is as simple as moving the files. Only difference is that must do it file by file. In the demo.survey.model.bc.links package we select an Association, open the Context Menu, select Refactor, select Rename..., enter the new name and click on OK. We repeat this for all entries in the package and rename them according to the table below.

Old Name New Name
AnswersResponsesFKAssoc AnswersPerResponse
ItemsQuestionsFKAssoc ItemsPerQuestion
QuestionsSurveyFKAssoc QuestionsPerSurvey
RepsonseSurveysFKAssoc ResponsesPerSurvey
SurveysAuthorsFKAssoc SurveysPerAuthor

Steps for JDeveloper 11g

Note: During the course of this series a new version of the JDeveloper 11g has been released on OTN. I will follow every official release and you should do the same. If you've created the projects with an earlier version of JDeveloper 11g and reopen them in a newer release, it is possible that the project files have to be migrated. if JDeveloper asks you to do this, simply accept it.

Step 1: Create a Model Layer Project

  • To create a new Model Layer Project select OnlineSurvey in the Application Navigator, click on the Applications Menu on the right-hand side select the New Project... menu entry.
  • In the New Gallery select an Empty Project and click on OK.
  • In the Create Project window set the Project Name to ModelBC and click on the OK button.
  • Select the newly created ModelBC project in the Application Navigator and open the Project Properties window with a double-click.
  • In the Project Properties window, check the values of Project Content and make sure that the Default Package is set to demo.survey.model.bc. Click OK to close this window.
  • Expand the Application Resources accordion, expand the Connections folderm andexpand the Database folder, select the survey entry and open the Context Menu. From it select the Properties... entry to open the Edit Database Connection window. Check whether the Deploy Password check box is checked. If not, make sure that it is checked! ADF BC relies on it.

Step 2: Import Business Components from Tables

Select the ModelBC project in the Application Navigator. Open the New Gallery from the Context Menu -> New .... In the New Gallery expand the Business Tier and select ADF Business Components. On the right-hand side select Business Components From Tables and click on the OK button.

  • In the Initialize Business Components Project window select the survey connection and accept the default values for the SQL Flavor and Type Map (both should be Oracle). Click OK and the OK button on the Login window.
  • In the Create Business Components From Tables wizard step 1, click on the Query button to get all available tables. Once the table names appear, select all of them. Move all entries from Available to Selected, by clicking on the >> button. Like in the other model projects we change the names from plural to singular names. Best is to do it right now by selecting each line in the list and change the appearing value in the Entity Name text field, eg Answers to Answer.
  • Click Finish to end this wizard.

The wizard will now create the Entities and Association files in a single package. This is quite good at the first sight but really tedious if return to the project in three weeks. The naming for the Associations is hardly readable or memorable. Therefore we need to do two things:

  1. Move the Associations and the Entities in separate package.
  2. Rename the Associations with better readable names.

Move the files in separate packages is quite easy. Select all Entities, the ones without the Assoc suffix (Click on the file while holding the Ctrl-key). From the Context Menu select Refactor->Move... and type in the name demo.survey.model.bc.entities. After clicking on OK all files will be moved in the new package. You might be asked for creating the new package directory. This is perfectly OK. Repeat this for the Associations and move them into the package demo.survey.model.bc.links.

Renaming the Associations to better readable names is as simple as moving the files. Only difference is that must do it file by file. In the demo.survey.model.bc.links package we select an Association, open the Context Menu, select Refactor, select Rename..., enter the new name and click on OK. We repeat this for all entries in the package and rename them according to the table below.

Old Name New Name
AnswersResponsesFkAssoc AnswersPerResponse
ItemsQuestionsFkAssoc ItemsPerQuestion
QuestionsSurveyFkAssoc QuestionsPerSurvey
RepsonseSurveysFkAssoc ResponsesPerSurvey
SurveysAuthorsFkAssoc SurveysPerAuthor

The final step in JDeveloper 11g is click on the Save All button in the button bar to save all the modified files.

July 26, 2008

Book Review: Apache JMeter

Not necessarily part of the ADF in Action series, but we will see later how we can leverage the input from this book later...

Testing: The Missing Project Task

For many, testing is one of the most tedious and time consuming parts of software development. This is true and in many projects this will be the first victim to get more buffer time for the overdue development tasks. Any attempt to make it more comfortable and repeatable helps, to keep this task back on the project plan.

Apache JMeter: One of the Many Tools for the Trade

There are a number of tools, open-source, free, and commercial ones, available on the market to help each of us to lower the pain and reducing the time and need for manual testing. Apache JMeter is one of my all-time favourites and also an open-source and free tool. I have seen it in use in many projects, set to action by more or less skilled team members. Its usages are from load to functional testing during the developer and the user-acceptance tests also. JMeter's extensible architecture easily allows it to adopt recent trends in development and makes it even useful for Service-Oriented Architecture  that are implemented around SOAP, JMS, and HTTP.

The Author

Emily H. Halili works as a quality-assurance engineer in Malaysia and has a lot of hands-on experiences to guide the reader into the usefulness of testing in general and Apache JMeter in particular.

The Book

When I first had the book in my hands, I was a bit disappointed because I am used to those hefty 500+ page monsters that keep me awake for hours and days. This 140 pages and 8 chapters beauty is a very handy book for Apache JMeter beginners and for me to carry around. It is about the right amount of text and topics to get started with the topics of load testing and functional testing.

But before you can get your hands dirty with Apache JMeter, a short introductary chapter how automated testing pays off. This valuable chapter, at least when your project managers wants to cut the testing time again, is followed by a quick introduction to JMeter with all the tool specific concepts like Test Plan, ThreadGroup, Listeners, Controllers, Timers, Assertions, and Configuration Elements. As an experienced developer you might be able to install JMeter quickly, but for the beginner Chapter 3 Installing Apache JMeter is a quick and short one.

Having finished these three chapters, you are ready for prime time. Chapter 4, The Test Plan shows you all the parts of JMeter test plan. This is by far the most important chapter of the book. It sets the scene for the following chapters by explaining all parts of a good test plan and how they interact together. In Chapter 5, Load/Performance Testing of Websites you learn how to do a load test efficiently and how to avoid penalties for Denial of Service attacks while testing. In the Functional Testing chapter you get ideas what parts are needed and how to combine them for the formal tests.

If you think these three chapters are helpful for your next testing assignments you should also consider the Advanced Features chapter which tells you how to extend the Web test by using loops or how to reference variables from the configuration steps, as well as testing a Database or an FTP server.

Overall Impressions

The book is an easy read and you can do it in your lunch break or in the first few hours of your testing assignment. It is a perfect companion book for a pretty useful tool and a nice introduction for every Apache JMeter beginner. I wish this book was available years before I started to use JMeter. With the first chapter it should be on the desk of every test or quality assurance engineer. Personally I can not wait for the sequel: Apache JMeter: Advanced Techniques.

Book Details

Emily H. Halili
Apache JMeter
ISBN 978-1-847192-95-0
Packt Publishing

About July 2008

This page contains all entries posted to Olaf Heimburger's Blog in July 2008. They are listed from oldest to newest.

May 2008 is the previous archive.

September 2008 is the next archive.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type and Oracle