Wednesday Mar 27, 2013

ADF Mobile: Working with Contacts (new video)

I'm happy to announce the final video in the ADF Mobile series of "Integrating Device Services", this time looking at working with the device's contacts (aka. address book).

The complete set of videos includes integrating email, SMS, contacts, GPS and pictures. A YouTube playlist can be found here.  I recommend subscribing to the ADF Insider Essentials YouTube channel so you receive notification of all the videos we make available to assist your learning of ADF Mobile and it's big-brother ADF.

Friday Mar 22, 2013

ADF Mobile: Integrating the Camera (new video)

You guessed it, yet another video in the ADF Mobile series on integrating the device services, this time on the camera.

The complete set of videos includes integrating email, SMS, contacts, GPS and pictures. A YouTube playlist can be found here.  I recommend subscribing to the ADF Insider Essentials YouTube channel so you receive notification of all the videos we make available to assist your learning of ADF Mobile and it's big-brother ADF.

ADF Mobile: Integrating SMS (new video)

We released yet another video in our series of integrating services into ADF Mobile today, this time how to use SMS.

The complete set of videos includes integrating email, SMS, contacts, GPS and pictures. A YouTube playlist can be found here.  I recommend subscribing to the ADF Insider Essentials YouTube channel so you receive notification of all the videos we make available to assist your learning of ADF Mobile and it's big-brother ADF.

Book review - SOA Made Simple

A few weeks ago Packt Publishing asked would I review SOA Made Simple, written by Lonneke Dikmans & Ronald van Luttikhuizen. Being a so called FMW expert, but (self-induced) pigeon holed in the ADF space I always take these offers, a good book provides an opportunity to widen my understanding of the topics & keep up with trends. Besides I know Lonneke & Ronald personally from my time as part of the Oracle ACE Directorship before I joined Oracle & they've always impressed me as knowledgeable and down to earth people (and this also declares my bias in reviewing their new book). 

Now I must admit I started reading this book & by the end of chapter one I was concerned the book was going to be an overall dry read, the opening chapter discusses architecture "ontologies", a word that required a careful check of the dictionary on my part.  But with some perseverance & completing chapter two, in fact I completed the rest of the book in one sitting.  Somehow the ontologies grabbed me ;-) 

So where this book makes it, is, to carry the joke forward is in its focus on SOA ontologies, with a careful if not methodical consideration of what makes a SOA project and services and how to proceed.  In less than 300 pages it covers many of the basic SOA concepts you need to know to understand SOA, and also what you'll need to do as part of a SOA project, without getting bogged down in detail. Thus the title SOA Made Simple I guess.

Frank's already given a good run down of the chapters, but to summarize the book first introduces you to different IT architectures and where SOA fits in, then what is a service, the cornerstone of SOA projects. Next how to identify & classify services, & only then are you introduced to the SOA platform, that is the different vendor solutions and their capabilities.  What's a winner at the end of this book is the two chapters entitled "How to Spend Your Money and When" and "Pick your Battles", which seems a delightfully down to earth and pragmatic approach to SOA projects.

Definitely this isn't a book that discusses how to use the SOA tooling from different vendors including Oracle, so don't pick this book up expecting to learn Oracle SOA Suite.  But conversely if you're looking for a concise text to articulate defining and progressing with a SOA project, this is for you.

One other comment I wasn't quite sure where to put in my brief review, is, the book is littered with references to other key SOA and computing texts and papers.  Let's just say for a SOA text this was brilliant idea, because it keeps the overall book digestibly small by not trying to cover all the same information again, but you're free to go read more on the referenced topics if it takes your fancy.

Overall a recommended read for anyone starting out with a SOA project, and for me, a good refresher on the SOA concepts and a concise list of what needs to be done over a SOA project's lifecycle. 

Friday Mar 15, 2013

ADF Mobile: Integrating the GPS (new video)

A quick note to say the ADF product management team has released a new video showing how to integrate the GPS into your ADF Mobile apps.

The complete set of videos includes integrating email, SMS, contacts, GPS and pictures. A YouTube playlist can be found here.  I recommend subscribing to the ADF Insider Essentials YouTube channel so you receive notification of all the videos we make available to assist your learning of ADF Mobile and it's big-brother ADF.

Wednesday Mar 06, 2013

ADF Mobile: Avoiding the Android Emulator with AndroVM

If you've had a chance to use ADF Mobile since its release and you're developing for Android, you will have been unlucky to encounter a small issue with Google's Android Emulator, it's incredibly, painfully, excruciatingly slow.   It really is an annoyance as the iOS Simulator on Macs runs lighting quick.  Oh the woes of developing for the Android platform, who would of thought this was the developer friendly platform?! ;-)

Mind you the problem isn't particular to ADF Mobile, just a generic issue with Google's software which all Android programmers have to deal with.  This means of course you can search for solutions on the internet, and between the hundreds if not thousands of posts detailing requests on "how do I make the Android Emulator faster" you will find the occasional very useful answer.  The most common one is "test on an actual device".  However there are some alternatives, of which one I've been recently exploring and I'd like to mention here in order to make ADF Mobile Android testing slightly less painful.

Before I do, I must clearly note this option is not supported by Oracle at all, and, via my testing it doesn't 100% work with all ADF Mobile's features.  But given the woeful state of the Android Emulator it at least gives you an option to work with.

AndroVM is a project dedicated to providing a working Android VM client for VirtualBox.  Of significance for ADF Mobile unlike other efforts such as Android-x86 project, AndroVM attempts to mimic the ARM architecture under the covers with an ARM instruction set translator called Houdini.  Why is this important?  If you can imagine Oracle has written a mini JVM for the iOS and Android platforms which sits above the hardware layer.  If the underlying chip architectures are wrong, this is going to cause the JVM grief.

Installing AndroVM is a fairly easy affair, you download and import the VirtualBox OVA file.  Ensure to download an OVA with Houdini included.  Beyond here it takes 14 seconds to boot to the Android home screen on my Mac.  Take that with the 38 seconds it takes to boot the Android Emulator on the same machine even while hot restarting, that's a big difference.

The AndroVM documentation pages have plenty of useful installation notes which are worth checking out.  One important point, the Escape key on your keyboard is mapped to the Android back button.

From here the most important bit to configure correctly is the VM network settings.  At the time of writing the androVM-4.1.1_r6.1-20130222 release comes with two network settings, the first (eth0) is a null (disabled) connection, and the second (eth1) is a NAT connection to emulate a wifi connection.  The documentation states you need to set the first connection as a "host only network" and attach it to a "DHCP-enabled network".  For whatever reason I couldn't get this to work so instead I configured a "bridged network" as follows: 


Note this connects to my Mac "en1: Wi-Fi (AirPort)" connection which in turn connects to my local router which serves an IP for the Android VM.  If you decide to go this same path, you'll need to pick an appropriate connection on your local machine to bridge the network connection.

To use AndroVM from here, what we're going to do is use the Android SDK adb command line tool to manually deploy an Android .apk file generated by ADF Mobile to the VM.  Before we can do this we need to know the IP address the VM has started with.  You can obtain this by logging in, opening Apps then androVO Configuration which will show you the IP address top left:


If you can't see this it means you haven't configured the network settings on the VM correctly.  You wont be able to proceed without this so take a step back and get that working correctly.  There's an excellent explanation of the different VirtualBox network types here.

Once you know the IP of the VM, open a terminal window, cd to your Android sdk install directory then cd to platform-tools:

cd <sdk dir>/platform-tools

From we'll use adb to connect to the VM by issuing the following command to connect to the IP address we revealed a few steps ago:

adb connect <ip address>

...and if you've set up the network connections properly you should hopefully see:


At this point you need to return to JDeveloper and generate the .apk package.  As such we cannot deploy directly from JDeveloper at this stage (though you could easily setup an extension to do this), rather we'll manually deploy the .apk via adb into the VM.  Upon generating the .apk make sure you understand where the file was generated as it will be used in the next command.

Returning to the terminal once the .apk has been successfully generated, you need to issue the following command in the terminal:

adb install <path to apk>/<apk file name>.apk

(Note it's worth reading the documentation on using adb, it's a very handy little utility)

In the example below you can see I've successfully installed the DeviceDemo sample application supplied with ADF Mobile:

Note that blindingly fast <2 second deployment time!


From here you're ready to test the application, and just like the regular emulator the application will be available from the Apps window:


And from there you can start the application, here's the Device Demo running, and it only took 3 seconds to start:

Now I've deliberately led us down the garden path here with the Device Demo, because it reveals limitations in the solution.  The Android Emulator allows us to connect up PC services like the webcam so we can take pictures as if were using a real device.  Via AndroVM we're not going to have the same facilities.  So while it's great that we've massively cut the deployment times, it's not going to be suitable for all our needs.

Beyond this from my testing it seems to run most (not all) applications fine.  I took all of the ADF Mobile sample applications (CompGallery, DeviceDemo, GestureDemo, HelloWorld, JavaDemo, LayoutDemo, LifecycleEvents, Navigation, PrefDemo, SkinningDemo, StockTracker) and they all appeared to work with some rudimentary testing.  However the HR application did crash at the beginning.  I suspect this might be because it's the only application that uses the SQLite database though when I have time I'll need to investigate this further.

Be it as it may, this is not a supported platform for ADF Mobile so you'll need to live with its issues.  However the speed benefits are I'm willing to bet enticing.

I'm going to leave the Comments for this blog post open.  Please do not post any "it doesn't work" or "how do I get this to work" type comments as I will delete them, as I said it's not supported.  However if you do happen to find a problem and solve it, it would be good if you could share it here.

One final note, remember, your company, such as Oracle, may have a policy restricting you from installing third party software which is not official approved. You should check before proceeding with this installation.

Wednesday Feb 06, 2013

ADF Essentials meets the Raspberry Pi

Summer holidays in Australia always has me searching for a new project to keep me from annoying the kids by stealing their Lego. This year I was introduced to the Raspberry Pi and set myself a goal of installing and running ADF Essentials on this miniature computer.

So what's a Raspberry Pi?

The Raspberry Pi, or Raspi or Pi for short is a credit card sized computer that was designed to teach the "real" basics of computers to kids.  The story goes a "bunch of old computer hacks" recognized that kids today are far removed from the electronics side of computing and as a result we're losing kids with an interest in the fundamentals of what makes computing tick.  As such the team had a brilliant idea of creating a small and cheap Linux driven computer with the usual standard connectors (HDMI, USBs etc), but also importantly a set of GPIO pins which allow the Pi to connect a traditional old electronics kit to controls LEDs, switches, sensors and more.

The specs of the Model B Raspberry Pi (there's two models, A and B) are deliberately minimal, running on a 700MHZ ARM processor, 512MB RAN (shared with the GPU), and it doesn't even have a harddrive, but rather uses a SD card for storage.  The neat part is the base price for the Model B is only US$35!

If you're exceptional underwhelmed by the specs of the Pi, you might not be understanding the point.  This isn't meant to be a highpowered Intel quad-duo-core thing, but a small lightweight computer to learn from, or run exactly one task.

Many people have "got it", and as a result the Pi has reportedly seen huge success in just the last year selling over a million units.  The Pi has found itself not only supporting the important role of teaching kids electronics and computer science, but it has also established itself into the hacker space with people declaring successful projects in robotics, home media centers, and lighting a humble LED when you receive an email.

What's this got to do with ADF Essentials?

The Pi is capable of running different Linux distributions, with a Debian distribution known as Raspbian "wheezy".  Instantly this peaked my interest, as where Linux goes, a JVM often follows, followed by Java EE servers such as Tomcat, and ha! Doesn't ADF Essentials run on Tomcat?!

So one 38C (100F) summer Perth day while hiding in the airconditioning I set myself a goal of seeing if I could get ADF to run on the Pi.  Why?  Why not?  I knew it wasn't going to run well, a full blown server solution on only 512MB of memory is pushing the limits, but would it actually run at all?

I'm happy to declare with a few hours to spare and a great amount of patience, a world record was declared on 27th January 2013:



From here on in I'd like to describe the steps to build the ADF Essentials Pi from scratch, for all those ADF hackers out there ;-)

Base Pi Specs and Basic Setup 

For this setup I worked with a Model B Raspberry Pi with 512MB RAM and a 4GB SD card.  By chance the Model A was released today with just 256MB RAM, possibly a challenge too far for ADF Essentials!

The SD card needs to have a preinstalled Linux of which Raspbian "wheezy" is a Debian distro built specifically for the Pi.  For purposes of my tests I used the 2012-12-16 wheezy img/zip available via the Raspberry Pi main website.

You can purchase the SD card preinstalled or burn your own installation via your PC/Mac onto the card.  The Raspberry Pi wiki has a good set of instructions on how to do this and I used the RPi-sd v1.2 card builder for the Mac to assist the process.  If you happen to take the RPI-sd route ensure that both the .app and .img files are located in a directory without spaces otherwise you'll hit errors.

After the installation of the base SD, I did hit a problem in getting the HDMI output to work.  The fix was via my Mac to edit the config.txt file on the SD card to include the following line:

hdmi_drive=2

Upon the first boot of the Pi you're presented with the Raspi-config screen, of which I changed the following options:
  • expand_rootfs  - invoked
  • change_locale - selected an Aussie locale en_AU.UTF-8
  • change_timezone - Australia/Perth
  • ssh - enabled
  • boot_behaviour - Start desktop
There is also an update command.  As I live behind the Oracle proxy this didn't work for me, but it's worthwhile to run if you've a normal internet connection to update your Pi with the latest software.

Once rebooted you're greeted with the Raspberry Pi desktop:



Due to the proxy issue above, I opened a terminal, configured apt-get to work with the Oracle proxy:

sudo nano /etc/apt/apt.conf.d/01proxy

..with the following line:

Acquire::http::Proxy "http://supersecretoracleproxy:80";

..and on returning to the terminal executed the following 2 lines to update my Pi installation with the latest software:

sudo apt-get update
sudo apt-get upgrade

This will take sometime to complete, time for a nice cup of raspberry tea while you wait.

As connecting the Pi to a dedicated monitor becomes a bit tedious, you can configure SSH and a VNC server so you can maintain the Pi remotely.  Firstly you'll need to know the IP address of the Pi through executing ifconfig in the terminal so you can connect via SSH/VNC.  Remember that by default the Pi uses dynamic IP (DHCP) so this may change on each boot.  I'll assume 10.1.1.2 from here on in.

To use and setup SSH and a VNC server, Adafruit provides good instructions on how to do this.  Ensure to remember the password you define for the VNC server.

From a Mac accessing the Pi via SSH is easy as it's supported through the terminal/Mac OSX.  On Windows you'll need to install a dedicated SSH client.

Also from a Mac accessing the Pi via a VNC client is easy as it comes with a ready made VNC client "Screen Sharing.app" located under /System/Library/CoreServices in OSX Mountain Lion.  Remember the user id/password combo is that you specified when setting up the VNC server, and the password is a maximum 8 characters long.

On accessing the Pi you'll need to enter the IP address you discovered before and the port number.  Note if you started the VNC server on the Pi using something like "vncserver :1", the port number you must access is 590 + the digit you started the vncserver, 1 in this example, along the lines of 10.1.1.2:5901.

On accessing the Pi from VNC for the first time I did hit the following error:

"GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: An authentication agent already exists for the given subject"

..and a fix is suggested here.

It's also worthwhile installing the Chromium browser and an FTP server such as proftpd.

Setting up the ADF Environment

Once we have the basic Pi up and running, we're now ready to install the infrastructure and software required for ADF Essentials.  In brief this includes:
  • JDK 1.6 SE
  • Apache Tomcat 7
  • jsf-api.jar + jsf-impl.jar + glassfish.jstl_1.2.0.1.jar
  • Oracle ADF Essentials
  • Oracle ADF Component Demo
The following instructions are mostly derived from Raphael Rodrigues's blog with a couple of twists.

At the time of writing this article there was some "hoohaw" over Java security and a rapid release of JDKs from Oracle to patch security holes.  As such an ARM distribution from Oracle of the JDK wasn't yet available.  To give myself the chance of finishing this blog post I went with installing the OpenJDK.  Warning: I've no idea if the current distribution includes all the security patches necessary.  However somehow I don't think security is a primary concern for most Pi uses:

sudo apt-get install openjdk-6-jdk

Installing Tomcat is also a fairly painless task.  First visit the Tomcat 7 download page and determine which is the latest version.  At the time of writing this was 7.0.35 for me.  In addition locate the tar.gz link and note the URL.  This will automatically be pointing at a mirror close to your location.

Return to the Pi terminal, ensure you're in the home directory and execute the following command, but change the URL to suit the one presented in the previous step:

wget http://mirror.mel.bkb.net.au/pub/apache/tomcat/tomcat-7/v7.0.35/bin/apache-tomcat-7.0.35.tar.gz

Once downloaded, execute the following command to explode the tar to your home directory:

tar zxf apache-7.0.35.tar.gz

You can then start and stop the tomcat server by executing one of the following 2 commands after issuing the cd command:

cd ~/apache-tomcat-7.0.35/bin

sudo sh startup.sh
sudo sh shutdown.sh

Via the Pi desktop if you open the Chromium browser, you should be able to access the Tomcat console by going to http://localhost:8080, or remotely via the ip address such as http://10.1.1.2:8080.  Be patient for the server to start.

At this point shutdown the Tomcat server.

Next we need to install the jsf-api.jar, jsf-impl.jar and glassfish.jstl_1.2.0.1 jar files into the TOMCAT_HOME/lib directory.  These are best borrowed from an existing JDev 11.1.2.3.0 installation on your local PC/Mac and ftp'ed across from JDEV_HOME/oracle_common/modules/oracle.jsf_2.0

Finally we're ready for some ADF setup!

We need to install the ADF Essentials runtime libraries into Tomcat.  Officially Oracle doesn't support Tomcat (at least currently) against ADF Essentials, but this doesn't mean ADF doesn't run on Tomcat.

As ADF Essentials requires you accept the license conditions on Oracle's website before you download it, you cannot use wget to do this.  In addition attempting to download this via the Chromium browser isn't that easy as it's chews so much CPU that often it times-out before it has a chance to download any file.  As such the easiest solution seems to be to download the 11.1.2.3.0 ADF Essentials file on your PC/Mac and then ftp it across to your Pi.  While you're at the same site, also download the Oracle ADF Faces Components Demo 11.1.2.3.

Move the ADF Essentials zip file to the TOMCAT_HOME/lib, and extract it using the following command:

unzip -j adf-essentials.zip

The -j option here flattens the directory structure within the zip such that all JARs included are placed in the Tomcat lib directory directly, not a subdirectory there of.

The final part of the install is we need to deploy the ADF Component Demo.  There is a number of different deployments options to take, but the easiest is to place the associated .war file in the TOMCAT_HOME/webapps directory.  However the file is a rather large and chunky application of over 100MB of source code.  Tomcat's default behavior at runtime is to explode the war into a directory of the same name at startup, and given the resources of Pi this is going to take a long time.

Best solution is to preexplode the file for Tomcat, by making a directory, say TOMCAT_HOME/webapps/rcf-dvt-demo, copy the war into this new directory and execute unzip on the zip file.  Remember to delete the zip file once done.

One last fix.  From experimentation Tomcat 7 on starting will attempt to scan all the source code for annotations to execute.  To stop it doing this we can modify the WEB-INF/web.xml file of the demo we just exploded, and add the attribute metadata-complete="true" to the <web-app> node.  As you're about to see starting the Tomcat server with all the preconfigured ADF software is a *really* long process.

Drum Roll: Voila! ADF Essentials on the Raspberry Pi

So the big drum roll moment is to again start Tomcat and then access the application via a browser.  Just starting the Tomcat server is now going to consume a vast amount of CPU.  In fact 2984981 ms at 100% CPU on my Pi! Phew.

What you can do while the server starts up is execute "tail -f" on the catalina.log file found under the TOMCAT_HOME/logs.  Very very slowly you'll see the server start up.  You might note the server seems to start 1 or two apps that aren't possibly needed and this could be something we could eliminate to speed the startup process later.

Finally once up and running, open the browser and access http://10.1.1.2:8080/rcf-dvt-home/faces/index.jspx. Once again it will take sometime to start and load, but eventually you'll see the component demo running.  If you attempt to open another session to the same page (say from your PC/Mac) you will see it's an order of magnitude faster.  But it does run!

 "But Chris, it runs so slowly it's near useless!"

Ya, I did set expectations early on that it would run slowly, and you weren't seriously going to run an enterprise framework on a Raspberry Pi were you?  The goal here has been to see if it will just run, and it does.

"But Chris, what about ADF BC/EJB/my favorite part of ADF?"

Indeed, I didn't make any claims of exercising the entire ADF stack.  Though it would be fun to try.  The component demo is a good exercise in that it's a very large JSF application.  I'd love to see somebody try to get ADF BC running by seriously throttling back the AM and connection pool.  Could you even install MySQL on the same Pi to be fully contained?  Hmmm, sounds like a cool hacking opportunity!

"But Chris, did you try X/Y/Z to speed up deployment?"

Awesome, you've got some hacking ideas!  Let's start an ADF Pi community and take this further for the fun of it  :-)

In summary the Raspberry Pi provides an awesome learning environment for kids to learn about computer science, but also a great playground for old fellas like me to see if we can get our favourite technologies to work on this mini computer.  I look forward to reading your Raspberry Pi ADF stories soon.

Monday Feb 04, 2013

Australia AUSOUG Roadshow - ADF Mobile - April/May

It's a tad early to advertise this, but as I'm receiving a few enquiries are we looking to run any ADF Mobile workshops in Australia anytime soon, I'd like announce yes indeed, we've a series of workshops planned with the Australian Oracle User Group (AUSOUG) in late April/May.

This 1 day ADF Mobile workshop will give you the opportunity to learn how to create on-device mobile applications that run on both iOS and Android.  This workshop will explain the unique challenges and common use cases of mobile applications and then dive into possible mobile architectures. The workshop will walk you through developing mobile applications that install and run on the device and are able to leverage device-specific features - all with the new Oracle ADF Mobile solution. No previous knowledge of Oracle ADF is needed!

The schedule is follows for the following Aussie cities.  Follow the links to register separately for each city:

If you're in New Zealand we'll also be running a workshop in Wellington as part of the NZOUG conference.  The conference is on 18th/19th March, and the workshop follows on the 20th March.

We look forward to seeing you there.

NZOUG - ADF Mobile workshop - Wed 20th March

Are you interested in developing for the mobile platform but not sure where to start?

The ADF product management team is happy to announce we've joined with the NZOUG conference on the 18th/19th March to add an a bonus ADF Mobile workshop on Wednesday 20th in Wellington where you can learn how to create on-device mobile applications that run on both iOS and Android.

This workshop will explain the unique challenges and common use cases of mobile applications and then dive into possible mobile architectures. The workshop will walk you through developing mobile applications that install and run on the device and are able to leverage device-specific features - all with the new Oracle ADF Mobile solution. No previous knowledge of Oracle ADF is needed!

If you're interested in attending the workshop, you can register for the workshop here, and alternatively if you'd also like to attend the NZOUG conference, you can register here.

We look forward to seeing you in Wellington. 

Wednesday Jan 16, 2013

ADF Naming and Project Layout Guidelines

In 2012 the Oracle ADF enablement product management team announced a new OTN website the ADF Architecture Square which includes the ADF Code Guidelines paper.  This paper before it was originally published not only considered ADF best practices, but also suggestions for ADF naming conventions and guidelines for project layouts.  However it was quickly realized the document was going to become too large and unwieldy, so we split it.

Today the ADF PM team is happy to announce the publication of the resulting second document the ADF Naming and Project Layout Guidelines.  Just like its sister publication, besides giving you guidelines on ADF naming conventions and project layouts,  the document has been produced to allow new ADF development teams a shortcut in writing their own such document.  If you've already got your own, good for you, dont change.

Having been embroiled in bipolar arguments with developers in the past about their preference for naming standards (I might have been one of the developers ;-), of the two documents I do expect this document to be more contentious than the sister publication.  And indeed there was a few debates inside Oracle in producing this document about the use (or not!) of Hungarian notation in ADF.  Yet the thing to realize is in many cases naming conventions are a personal preference.  And as the document clearly tries to state, if you don't like the guidelines, one size doesn't fit all, change them!

Like the previous document this paper has been designed to be a living document that will change and evolve over time. We encourage customers to discuss these guidelines on the ADF EMG, and log any issues on the ADF EMG Issue Tracker so we can continue to improve them.

Friday Jan 11, 2013

Making use of multiple independent ADF BC data sources

An uncommon but valid customer use case for ADF BC is to have two root AMs that point at entirely two different connections/data sources/JNDIs within the same Model project.  For example maybe you need to connect to both an Oracle and SQL-Server database to show data from two different database systems.  Or maybe you even need to connect to the same Oracle database but two different schemas.

Now one solution to this problem is to solve it at the database level.  This really is the preferred route as the database has some awesome tools for solving these sorts of issues such as database links, gateways and more.  Remember that the database and these tools have all sorts of supports for tricky database issues such as distribution, 2 phase commits, all the sort of tricky issues that years of effort have gone into solving which to be basic, a normal Java programming team wont be able replicate.

However sometimes we're simply not going to be able to use those tools or we just want a simple ADF solution for getting data from two databases.

So how do we do this in ADF?

The solution is fairly simple, we need:

a) 2 separate database connections
b) 2 separate root AMs and associated VOs/EOs
c) Any page/fragment we drop the VOs/EOs, for the relating task flow we *must* use the <No Controller Transaction> option

In considering each of these parts to our solution:

a) It's not immediately obvious but we are free to use more than one database connection in our application as the following picture demonstrates:



When you have more than 1 database connection you must be mindful that via the Model project properties, the ADF Business Components options has a Connection poplist that defines the default database connection for the project to use at design time as can be seen here:



It's up to you when you run the various ADF BC wizards to ensure you have the right database connection selected.  

b) Once you've defined your two connections, you're now in a position to use the associated ADF BC wizards to create your various ADF BC components.  You will need to return and manage the default database connection at the Model -> ADF Business Components -> Connection project property to ensure you are connecting to the right database each time you run the wizards.  JDev wont give you any help here, so be careful!

In the following picture it shows the end results of creating a Model project, with a Regions EO/VO exposed via the HrAppModule connecting to the HR Oracle database schema, and another EO/VO Customers exposed via the OeAppModule connecting to the OE Oracle database schema:



Note there's an IDE bug 16032880 we need to be wary of here and double check the IDE hasn't introduced an error with the associated JNDI data sources for the AMs. Each change to the Connection option at the Model ADF BC project properties level, it will override all the data sources of the root AMs with the one you just picked.  If you locate the bc4j.xcfg file that holds the JNDIs, check that the data sources for the associated AM configurations are correct.  For example for the two AMs, I expect to see the following <Custom JDBCDataSource> entries for each configuration:

HrAppModuleLocal <Custom JDBCDataSource="java:comp/env/jdbc/HrConnDS"/>
HrAppModuleShared <Custom JDBCDataSource="java:comp/env/jdbc/HrConnDS"/>
OeAppModuleLocal <Custom JDBCDataSource="java:comp/env/jdbc/OeConnDS"/>
OeAppModuleShared <Custom JDBCDataSource="java:comp/env/jdbc/OeConnDS"/>

If you do discover an error simply repair this in the file, save all, and the issue will go away.  Ensure to test in the Business Component Browser to make sure the AMs are configured correctly and you can see data from both VOs.

c) Having sorted out the Model layer you can now move to the ViewController layer.  Typically you'll start creating pages and fragments in your unbounded task flow (UTF) and bounded task flows (BTF) making use of the VOs you've just exposed through the separate AMs.

In doing so you must be aware that the transaction options you pick for your BTFs can change the connection behaviour of your AMs you have just setup.  Here are the bounded task flows supported 4 transaction options:



Strictly speaking it's 3 options that are related, that being Always Begin New Transaction, Always Use Existing Transaction and Use Existing Transaction if Possible, plus the ability to turn this feature off known as <No Controller Transaction>.  You can read more about these options here (see the Task Flow Transaction Fundamentals paper).

There's a back end feature built into the task flow transaction management where if your application makes use of multiple ADF BC data controls mapping to separate root AMs, at runtime ADF BC will try to share connections amongst the root AMs at runtime.  While this may seem disastrous to what we're attempting to achieve here, this feature is very important for creating scalable applications where our architecture has forced us to create separate root AMs, typically we don't want one user to take out several database connections.

Luckily task flows still provide a solution for our use case that is counter to this described functionality.  Rather than picking one of the BTF transaction options, that being Always Begin New Transaction, Always Use Existing Transaction and Use Existing Transaction if Possible, instead pick the <No Controller Transaction> option.  The <No Controller Transaction> option doesn't override the connections of the root AMs and allows them to connect to any JNDI they define at runtime.

And that's all there really is to the solution.  You just need to make sure you have the right configurations for your root AMs, the Model project ADF BC connection, and the task flow transaction options.

Questionably what about the unbounded task flow?  It doesn't allow us to define any transaction options, what do we do if we use our VOs in pages/fragments of the UTF?  For all intent and purposes you can treat the UTF as using the <No Controller Transaction> option.

What about the task flow Share Data Controls with Calling Task Flow option?  What do we set that to?  The previous Task Flow Transaction Fundamentals paper details that in full, but to say, if you untick that option (known as an isolated data control scope) for the current BTF, a brand new instance of the current root AM and relating VOs/EOs will be instantiated for the current user for the life of the BTF.  If you select the check box (known as a shared data control scope), if an instance of the ADF BC AM is already being used in a previous BTF that called this BTF, simple the ADF BC AM data control will be shared.  If it doesn't yet exist it will be created for the first time.

Sample App

I've provided a sample application for you to see this behaviour based on the scenario described above.  It requires access to both the HR and OE sample Oracle database schemas.

When you run the app via the Splash.jsf page and navigate to the CombinedTaskFlow, back in JDev open the database navigator and locate both tables in the separate schemas, and the associated records that are currently showing in the app.  Now in the app you can change and commit each VO and watch the changes independently saved to the corresponding records in the separate schemas in the database.  Note you can change and commit the records independently, committing one will not commit the other.

Troubleshooting

It's worth while having a look at how things break too.  If you open the CombinedTaskFlow.xml in JDeveloper and change the BTF transaction options to Always Begin New Transaction, rerun the app, you'll notice on arriving at the CombinedTaskFlow you'll receive a database error "ORA-00942: table or view does not exist".  As described previously the other BTF transaction options combine/share the connection of the first root AM at runtime, in this case the HrConn.  As such as soon as the CustomersView attempts to query from the CUSTOMERS table in the database, as its root AM is now sharing the connection of the HR root AM it can't see the required tables.

Alternatively if you fix this change and return to the ADF Business Components Connection option under the Model project properties, and switch the connection to OeConn, this will modify all the JNDI connections in the relating bc4j.xcfg file to point at the OE schema.  On rerunning your app you'll again see "ORA-00942: table or view does not exist".  Again in this case be cognizant of bug 16032880 described earlier and how to fix the problem.

Wednesday Jan 02, 2013

JDeveloper and ADF does Google+

Are you an ADF developer who uses Google+?  The Oracle ADF product management team has recently extended our Google+ page with a Google+ JDeveloper and ADF Community. If you're keen head on over and subscribe to receive updates and news about JDeveloper and ADF, as well participate in discussions in the ADF community.  In particular if you want to become an ADF community leader, it's a great opportunity to make a name for yourself in this virgin Google+ community.

Along with Google+ this gives you a fair amount of choice on the social media services you can participate in.  For reference here's a few more:

With this many choices hopefully this will give you an option if your evil firewall administrator has limited your access to some of these ;-)

We look forward to seeing you on Google+ soon.

Thursday Dec 20, 2012

Working with EO composition associations via ADF BC SDO web services

ADF Business Components support the ability to publish the underlying Application Modules (AMs) and View Objects (VOs) as web services through Service Data Objects (SDOs).  This blog post looks at a minor challenge to overcome when using SDOs and Entity Objects (EOs) that use a composition association.

Using the default ADF BC EO association behaviour

ADF BC components allow you to work with VOs that are based on EOs that are a part of a parent-child composition association.  A composition association enforces that you cannot create records for the child outside the context of the parent.  As example when creating invoice-lines you want to enforce the individual lines have a relating parent invoice record, it just simply doesn't make sense to save invoice-lines without their parent invoice record.

In the following screenshot using the ADF BC Tester it demonstrates the correct way to create a child Employees record as part of a composition association with Departments:


And the following screenshot shows you the wrong way to create an Employee record:


Note the error which is enforced by the composition association:

(oracle.jbo.InvalidOwnerException) JBO-25030: Detail entity Employees with row key null cannot find or invalidate its owning entity. 

Working with composition associations via the SDO web services 

Shay Shmeltzer recently recorded a good video which demonstrates how to expose your ADF Business Components through the SDO interface.

On exposing the VOs you get a choice of operation to publish including create, update, delete and more:

For example through the SDO test interface we can see that the create operation will request the attributes for the VO exposed, in this case EmployeesView1:


In this specific case though, just like the ADF BC Tester, an attempt to create this record will fail with JBO-25030, the composition association is still enforced:


The correct way to to do this is through the create operation on the DepartmentsView1 which also lets you create employees record in context of the parent, thus satisfying the composition association rule:


Yet at issue here is the create operation will always create both the parent Departments and Employees records.  What do we do if we've already previously created the parent Departments records, and we just want to create additional Employees records for that Department?  The create method of the EmployeeView1 as we saw previously doesn't allow us to do that, the JBO-3050 error will be raised.

The solution is the "merge" operation on the parent Departments record:


In this case for the Departments record you just need to supply the DepartmentId of the Department you want the Employees record to be associated with, as well as the new Employees record.  When invoked only the Employees record is created, and the supply of the DepartmentId of the Departments record satisfies the composition association without actually creating or updating the associated Department record that already exists in the database.

Be warned however if you supply any more attributes for the Department record, it will result in a merge (update) of the associated Departments record too. 

Friday Oct 26, 2012

Yet another ADF book - Oracle ADF Real World Developer’s Guide

I'm happy to report that the number of ADF published books is expanding yet again, with this time Oracle's own Jobinesh Purushothaman publishing the Oracle ADF Real World Developer’s Guide.  I can remember the dim dark days when there was but just 1 Oracle book besides the documentation, so today it's great to have what I think might be the 7 or 8th ADF book publicly available, and not to forgot all our other technical docs too.

Jobinesh has even published some extra chapters online that will give you a good taste of what to expect. 

If you're interested in positive reviews, the ADF EMG already has it's first happy customer.

Now to see if I can get Oracle to expense me a copy.

--

Post edit: Kindly Packt Publishing supplied a copy giving me a chance to review the book.  My review comments follow, also published on Amazon:

--

As part of my regular job I've read *every* book on ADF. Given there's now several ADF beginners' books I thought the introductory level to ADF area was already amply covered, and I didn't know what Jobinesh's latest ADF text could add. However I must admit I was pleasantly surprised, as even though this book obviously covers many beginners topics, it also covers topics the others haven't making it another valuable addition to the ADF textbooks currently available.

Of particular interest to me was the introduction of:

1) Framework class diagrams - explaining for example how the ADF BC and binding layer classes relate to each other, therefore giving insight into what objects you actually work with programmatically when you drop to code in ADF

2) JSF Servlet, ADF Servlet & Filter lifecycle - a soup-to-nuts discussion starting at the configuration of the web.xml, the importance of the order of the filters, and the overall lifecycle of the framework

3) Application Module scenario diagrams - what objects and methods get called when an Application Module is instantiated so not only do you get an abstract discussion of the AM lifecycle, but how it relates to actual code.

Don't get me wrong, Jobinesh covers all the usual beginner topics, ADF Business Components, task flows, ADF Faces and more, but the fact that he's focused on the Java and Java EE side of ADF brings two very useful discussions on the framework together, which I believe creates a good learning opportunity.

A recommended read for beginners.

Wednesday Oct 17, 2012

ADF Code Guidelines

During Oracle Open World 2012 the ADF Product Management team announced a new OTN website, the ADF Architecture Square.  While OOW represents a great opportunity to let customers know about new and exciting developments, the problem with making announcements during OOW however is customers are bombarded with so many messages that it's easy to miss something important.

So in this blog post I'd like to highlight as part of the ADF Architecture Square website, one of the initial core offerings is a new document entitled ADF Code Guidelines.

Now the title of this document should hopefully make it obvious what the document contains, but what's the purpose of the document, why did Oracle create it?

Personally having worked as an ADF consultant before joining Oracle, one thing I noted amongst ADF customers who had successfully deployed production systems, that they all approached software development in a professional and engineered way, and all of these customers had their own guideline documents on ADF best practices, conventions and recommendations.  These documents designed to be consumed by their own staff to ensure ADF applications were "built right", typically sourced their guidelines from their team's own expert learnings, and the huge amount of ADF technical collateral that is publicly available.  Maybe from manuals and whitepapers, presentations and blog posts, some written by Oracle and some written by independent sources.

Now this is all good and well for the teams that have gone through this effort, gathering all the information and putting it into structured documents, kudos to them.  But for new customers who want to break into the ADF space, who have project pressures to deliver ADF solutions without necessarily working on assembling best practices, creating such a document is understandably (regrettably?) a low priority. 

So in recognising this hurdle, at Oracle we've devised the ADF Code Guidelines.  This document sets out ADF code guidelines, practices and conventions for applications built using ADF Business Components and ADF Faces Rich Client (release 11g and greater).  The guidelines are summarized from a number of Oracle documents and other 3rd party collateral, with the goal of giving developers and development teams a short circuit on producing their own best practices collateral.

The document is not a final production, but a living document that will be extended to cover new information as discovered or as the ADF framework changes.

Readers are encouraged to discuss the guidelines on the ADF EMG and provide constructive feedback to me (Chris Muir) via the ADF EMG Issue Tracker.

We hope you'll find the ADF Code Guidelines useful and look forward to providing updates in the near future.

Image courtesy of paytai / FreeDigitalPhotos.net

About

Chris Muir - Oracle ADF Product Manager - The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today