Book Review: Processing XML documents with Oracle JDeveloper 11g

This is a new feature here on Java Hair, a book review. I was recently approached by the publisher of this book who asked if I would be interested in doing a review. The request was quite timely, I thought, since I have recently been working with XML Schema design (check out the XML category).

edfa

“Processing XML documents with Oracle JDeveloper 11g” seems more like the title to a whitepaper than a full-fledged book, but I found that the book actually covers a lot of topics that fall under the XML Processing umbrella.  That, and the fact that JDeveloper documentation can be difficult to come by makes this book a pretty handy addition to your library if you develop with JDeveloper 11g and you are working with XML.

Starting out, the book covers the parsing of XML documents using both the SAX API and the DOM API.  Information that you could get elsewhere, but as the book is JDeveloper 11g specific, it also includes information on how to set up your projects and which libraries you need to include that may or may not be included with your JDeveloper distribution.  Very handy information for someone using JDeveloper.

There is a chapter on using JDeveloper to design an XML Schema, something I could have used a few months ago, actually.  JDeveloper’s visual design feature for XML Schema’s is a great tool and comparable to anything I’ve used with Eclipse and NetBeans.  Following that is a chapter on validating your schema 3 different ways and how to create these projects in JDeveloper.

There are some chapters that I didn’t expect to see in this book, but were quite welcome.  A chapter devoted to transforming XML to PDF, another on transforming XML to MS Excel, storing XML in Oracle Berkeley DB XML and even a chapter on Oracle XML Publisher.

So all in all, despite the self-imposed limitation of XML and JDeveloper, the author, Deepak Vohra, has managed to cram in some very useful topics into his book.  Though some of it isn’t really JDeveloper specific, he does makes it relevant by walking thru setting up each project in JDeveloper as well as building and running the subsequent applications in JDeveloper.

The writing style is very dry, much like you’d probably expect from a reference book, and it should be treated as such, it isn’t something that you are going to want to sit down and read in one sitting.  However, if you have work to do in XML and you are considering using or already using JDeveloper as your IDE, I would definitely recommend picking it up.

You can find the book on virtually any online bookstore or on the publisher’s website: Packt Publishing.

Share/Save/Bookmark

Oracle acquires Sun: Who needs to look out now?

As a Java developer who does a lot of work with Oracle products including Jdeveloper and ADF, my head is still spinning a little from the news that Oracle is buying Sun Microsystems.

Oracle buying BEA hurt a little, though it was completely expected and a great move on Oracle’s part, I was a little sad to see the application server competition field drop by one but I was very happy that Oracle was smart enough to choose Weblogic.  At that point it was really the only the decision they could make.

With Oracle buying Sun there is a lot of synergy, there are many technologies that are duplicated among both companies.  Oracle owning both should make those technologies better and enable them to compete with the leaders in those respective areas.  The big ones that stick out for me:

!. Oracle’s JDeveloper and Sun’s NetBeans

Could they really afford to drop NetBeans, probably not, but can they afford to drop JDeveloper, no, not really.  Here the only thing that really makes sense is to merge the two, probably adding in the ADF wizards and goodies like that into NetBeans.  At least, that is what I hope they do.  JDeveloper isn’t bad, but I only ever use it to develop ADF projects and I bet many, many people are in that same boat.  Combining the two could end up giving Eclipse a run for it’s money, hopefully the competition just spurs both to be better.

2. Oracle’s Oracle VM and Sun’s Virtual Box

I haven’t had much experience with Oracle VM, but I have lately become a huge fan of Sun’s Virtual Box.  It’s a great product and it lets me do everything I want for free.  Will this continue to be the case?  I don’t know.  I’m not an expert on virtualization in the enterprise, I use it for desktop VMs, but I hadn’t seen much about Virtual Box working in that space.  I would imagine Oracle VM is all about virtualizing the network and competing with VMWare on that level.  With the two together VMWare’s got some competition.

3.  Oracle’s Unbreakable Linux and Sun Solaris

Oracle had a great jumpstart to their linux platform basing it on the RedHat codebase way back when.  Solaris was my first exposure to any type of Unix (Solaris and AIX, actually) and it has been around forever.  If the adoption of Linux has hurt anything, it’s probably been Solaris and through that, sales of Sun’s hardware.  Oracle says that their owning of Solaris will enable them to tune the Oracle Database software to run even better on it, and since according to Oracle, most of their database customers are using Solaris, I think they’ll probably do that.  I have no idea what will have to Unbreakable Linux though.  Who has to look out with this one?  I’d say IBM.  Buying Sun probably would have been good for them in the products space, I think the only area IBM is going to be competing in future is going to be services.  RedHat has Ubuntu to worry about on the desktop side and now a bigger threat from Oracle and Sun on the server-side, they have their work cut out for them.

4.  Oracle Database and Sun’s MySQL

MySQL has a huge customer base, most of them probably non-paying.  I think with this one, Oracle just adds it to their ever increasing repetoire of niche databases.  It won’t go away, but I see less adoption in the future, maybe a boost for PostgreSQL if they can get their act together.

5. Sun’s Java and Oracle’s ADF

Oracle has always been a big player in the specifications for the Java language.  I’m sure someone else will go into all the details, because I honestly don’t know them off the top of my head, but I do know that many technologies and ideas that ADF is based on where either approved JSR’s or close to approved JSR’s.  Does Oracle’s acquisition of Sun and Java mean that they will be better equipted to push trhough whatever they want to add to the language?  Well, I don’t think it will be quite that easy, but I’m sure it makes it easier.

I’ve always been a Java guy at heart, I work with Oracle technology sometimes, and I think they have really come a long way, but Oracle owning Java does kind of scare me a little.  One thing Oracle does really well, and JDeveloper is great at this, is making complex technologies easy to use.  It is what Microsoft does really well.  .NET makes easy the things that Java makes hard.  ADF actually does a lot of the same.  The combination of ADF and Java together could pose a big threat to Microsoft’s .NET if Oracle does it right.

My first thought about Oracle owning Java is that many developers are going to jump up and down about it and complain.  Some will probably jump ship, maybe to .NET but probably to Ruby or PHP or something else.  I don’t think many coroporations are going to change the direction of their IT departments though, so for them, it will be .NET or Java as it always has.  In the end, I thnk most Java developers are going to remain Java developers and hopefully Oracle’s backing of Java will just end up making it a better language to work with.

Microsoft might have more to worry about with Oracle owning Open Office now also.  I hope that Oracle continues to invest in it, or it’ll end up being Microsoft Office vs. Google Apps and that’s about it.  I’m all for cutting edge, but Gmail hasn’t come out of Beta yet and I’d like to see Microsoft have some competiion in this area.

So I wanted to get my thoughts out there while they were floating around in my head and hopefully yours so I could hear your opinions on the topic.  Please let me know what you think about this acquistion and what you think it means to the future of technology and competition in the field.

Share/Save/Bookmark

Speaking Engagement: Collaborate 09

It looks like my abstract was accepted to be presented at Collaborate 09 coming up in Orlando in May this year. As the schedule stands now my session will be first thing Monday morning (first thing being 10:45 thankfully!), which leaves me the rest of the time to see what’s new in the world of Oracle and Oracle Users.

In case you haven’t heard of it, as their website says: “COLLABORATE 09 helps users of the full family of Oracle business applications and database software gain greater value from their Oracle investments. Created by and for customers, COLLABORATE 09 offers an expert blend of customer-to-customer interaction and insights from technology visionaries and Oracle strategists. Expand your network of contacts by interacting with Oracle customers, solutions providers, consultants, developers and representatives from Oracle Corporation at COLLABORATE 09.”

So if you are going to be there, be sure to stop by my session and say hello.

Share/Save/Bookmark

Installing JDeveloper 11g on Ubuntu 8.10

I recently got a little annoyed at Vista and upgraded my desktop workstation to run Ubuntu Linux.  As it has been the holiday season and I’ve been busy modeling in XML (more on that later!), I hadn’t had the chance yet to install or run JDeveloper 11g on my newly configured desktop.  Today I decided as part of the new year, I’d take the plunge and give it a whirl.

Here are the steps I followed to install JDeveloper 11g on Ubuntu.

1.  First off, download the installer from Oracle here:http://www.oracle.com/technology/software/products/jdev/htdocs/soft11.html.  I downloaded the Linux install that includes JDK 6 as running java -version at a terminal in Ubuntu revealed that I was running 1.5.0.

2.  Change the permissions of the downloaded bin file to allow execute.  chmod +x jdev* if you are lazy like me.

3.  Open a terminal window and change directory to the directory where the downloaded file is.

4.  type ./jdev* to run the downloaded file, as long as there are no other files whose name begin with jdev in that folder, if there are, type the whole thing out.

5.  Choose complete install - you are going to need it all anyway.

6.  I allowed it to install under my home directory.

7.  After it installed and the Quickstart Launcer appeared, I chose to open JDeveloper Studio.

8.  Since the installer did not create a menu item for me in my Applications Menu, I did that manually.

9.  Right click on the Applications Menu and choose “Edit Menus”.

10.  Select the Menu you want to add the entry to, I chose “Programming”.

11.  Select “New Item”, for the Type choose “Application”, for the Name: “JDeveloper”, for the Command: “[Install Dir]/Oracle/Middleware/jdeveloper/jdev/bin/jdev” replacing [Install Dir] with the correct path.

And that’s all there is to it.  Probably not even worth a post at this point, but since I typed it while installing it and I didn’t realize it was going to be so painless, I might as well post it anyway.  I’ll post again about it if I run into any quirks using it, hopefully it’s as seamless as the installation was.

Share/Save/Bookmark

Webinar: Client/Server Oracle Forms Modernization with Oracle ADF 11g

You might thinnk I could have come up with a shorter or even catchier title by now, but I really haven’t.  Anyway, the point is that I will be hosting a webinar on modernizing Oracle Forms applications and why Oracle ADF 11g is a good platform for doing that.  If you have followed my blog, you’ll know that this is a topic near and dear to my company, Vgo Software.   You would also know that this is another variation of the presentation that I’ve done at ODTUG this year, at the Oracle Open World Unconference event, and at a couple user groups along the east coast of the U.S.

If you are interested in participating in the webinar, you can register at our site.  Stacey assures me that you can even ask a question when you register and if you do that, I’ll be sure to make sure I cover your question during the webinar.  The date is Noveber 12th, 2008 and the time is 11:00 a.m. EST.

The main difference between this one and the presentations at conferences I’ve done on the same topic is that this one will not include a demo of JDeveloper and instead I will add some more slides to cover more detailed content.

Share/Save/Bookmark

JDeveloper 11g Released

JDeveloper 11g is now available for download from Oracle.

What’s great about this release?  Well, in my opinion besides having some of the Tech Preview bugs fixed, having Weblogic embedded in JDeveloper is a great improvement over OC4J.

So what are you waiting for?  Go check it out!

Share/Save/Bookmark

Auditing Code in JDeveloper 11g

The 11g release of JDeveloper includes a utility to perform code audits without having to install additional plugins. While the information it provides out of the box is minimal, for some violations you can also ask JDeveloper to fix the code automatically.

The metrics it provides:

NOS: Number of Statements in the construct.
V(G): Cyclomatic Complexity, a metric that captures the number of branches that can be taken through a method.
DIT: Depth of Inheritance Tree, this metric describes how far a class is from it’s furthest ancestor, or really, how many classes has it inherited from.

You can run audit reports on your projects pretty easily.
1. Select the project node in the Application Navigator.

Select the Project to Audit

Select the Project to Audit

2. Select Run from the main menu bar.

3. Select Audit Project.jpr

4. Choose All Metrics

View Audit Reports in JDeveloper

View Audit Reports in JDeveloper

5. View the report in the log window

You can also run audit reports on rules violations. You can easily modify which rules you would like to include and which you wouldn’t along with which available metrics you’d like to include.

Change the Rules to Audit in JDeveloper

Change the Rules to Audit in JDeveloper

A couple things to keep in mind as you view the metrics:

1. The V(G) of RowImpl classes is going to be high because of the case statement within the getAttrInvokeAccessor method. This is normal for ADF.

2. The DIT is going to be above the default threshold for some of your Impl classes also, for instance, any Application Module Implementation. This is the class you need to extend is already so far down in the chain.

There are only a couple metrics that can be run from the audit tool built into JDeveloper and I’m sure there are ways to integrate other code auditing tools in JDev, but at least it’s a start.

One tool I was hoping to see which I imagine is a long way off is some type of auditing tool for ADF itself.  Since so much of it is declarative and new, no existing tools are going to work on it, but it’d be nice to be able to audit the declaritive part of ADF projects for best practices.

Share/Save/Bookmark

Oracle Open World Unconference - ADF as a Platform for Forms Migrations

I am going to be at OOW this year, as usual, and this time I will be presenting my talk on using ADF 11g as a platform for Oracle Form conversions.

My presentation outlines the use of 11g ADF Faces, ADF Business Components and JDeveloper as a target platform for applications that were previously written in Oracle Forms. The 11g version of ADF contains many new features that make it a much better framework for such conversions than others. These include the use of Task Flows and richer JSF components. . This presentation explores some of the difficulties in recreating such applications in a web environment and shows how ADF 11g can be used to alleviate some of those difficulties and what difficulties still remain.

I signed up for the Unconference early to reserver a spot, so right now it is scheduled for 11am on Tuesday morning in Overlook I. Hopefully when I get there to sign up, the slot will still be available, stop by the booth before then if you are interested in attending or check the schedule that will be posted there.

If you are going to be there, be sure to stop by!

Be sure to check out the rest of the Unconference Schedule.

Share/Save/Bookmark

ADF 11g: Using Custom Properties To Create Update-Only View Objects

One of the cool features of the ADF Business Components layer in 11g is the ability to add custom properties to Entity or View objects. It’s a neat feataure but up until this point I hadn’t really any need to use them.

Then, when I was trying to implement a View object as only allowing updates, not inserts or deletes, I learned that there isn’t really a way to declaritively do this in ADF 11g. It seemed like one of those things that should be available, but the help says this:
“Some 4GL tools like Oracle Forms provide declarative properties that control whether a given data collection allows inserts, updates, or deletes. While the view object does not yet support this as a built-in feature in the current release, it’s easy to add this facility using a framework extension class that exploits custom metadata properties as the developer-supplied flags to control insert, update, or delete on a view object.”

The above quote is from section 37.11 of the Fusion Developer’s Guide for Oracle ADF. The section is actually titled “Declaratively Preventing Insert, Update, and Delete” which sounded like exactly what I wanted, but when i read the section I found that little bit of discouraging news. The last few words were encouraging, I thought using custom proerties to control insert, update, or deletes would be perfect, then I read on.

The next couple paragraphs seem to indicate that it would be a good idea to create instances of the view object that are called ViewObjectInsert, ViewObjectUpdate, and ViewObjectDelete, generic framework code could be used to look for these View instances and based on if a custom property is set then blah, blah, blah. I think it actually said something about looking up the phase of the moon also.

I’m not sure why you would want to have custom instances to determine whether or not customer properties should be looked up or not, why not just use custom properties? Anyway, that is the route I decided to take and it turned out to be pretty simple.

Chirs Muir had written an article on using custom properties to automatically convert the case of input and I used his article along with the help section of the Fusion Developer’s guide to come up with this solution. Thanks Chris!

1. Create a custom ViewObject implementation class.
This is done by creating a class that extends the Oracle View Object.

Create a New Java Class

Create a New Java Class

1a. Right click on the package you would like your custom class to reside in.
1b. Click on Simple File in the left pane and Java Class on the right pane.
1c. Name the file and make sure it extends the ViewObjectImpl class.

2. Create a method to check the custom property.

     private boolean isAllowed(String action) {
         boolean result = true;
         if (getViewDef() != null) {
             if (getViewDef().getProperty(action) != null) {
                String actionProperty = (String) getViewDef().getProperty(action);
                if (actionProperty != null) {
                    if ("false".equals(actionProperty)) {
                        result = false;
                    }
                }
             }
         }
         return result;
     }

3. Override the appropriate methods.
3a. Override the createRow method to check if Create is allowed, and if it isn’t throw an exception.

    public Row createRow() {
        if (isAllowed("insert")) {
            return super.createRow();
         } else {
            throw new JboException("Create not allowed in this view");
         }
    }

3b. Override the removeCurrentRow method in the same way.

    public void removeCurrentRow() {
        if (isAllowed("delete")) {
             super.remove();
         } else {
            throw new JboException("Delete not allowed in this view");
         }
    }

4. Add the necessary declarations to the View Object you wish to have these features.
4a. Add the following line to the attributes of the View Object to have it implement the framework class.

	ComponentClass="com.vgo.demo.framework.MyCustomViewObjectImpl"
Add Custom View Properties

Add Custom View Properties


4b. Add the necessary custom properties to the View Ojbect. Click on the General section of the Overview tab of the view object. Open the section for Custom Properties and click the green plus. Change the name to “insert” and the value to “false”. Click on the green plus to add another cusom property, name this one “delete” and set the value to “false”.

5. That’s it, it is that simple. Now run an Application Module that contains that View and try to insert or delete, when you do, you should see the exception that is thrown to inform the user that the action is not permitted.

Error Message for Insert Shown

Error Message for Insert Shown

As you can see, custom properties in ADF 11g are sure to prove extremely useful in the future, I am sure this is but one potential use for them.

Share/Save/Bookmark

Using Conditional Breakpoints

Conditional breakpoints are a great way to reduce debugging time and one of those features you might not even have known existed. This article will cover how to use them in 3 different ide’s including NetBeans, Eclipse and JDeveloper.

Have you ever tried to debug a problem that only occurs somewhere in a list of 100 objects? It can be a bit of a hassle.

You could put in a breakpoint and hit continue each time that breakpoint is hit until you find the problem object. This is acceptable the first time, but often the first time isn’t going to cut it.

You could put an if statement in your code to check for the condition that is causing the problem, but then you need to remember to remove that if statement after you fix the problem. Often my if statements in the past would have looked like this:

i f (problem.exists()) {

System.out.println(”This is the problem.”);

}

And I’d set a breakpoint on the System.out.println line.

A much better approach is to make use of conditional breakpoints available in most modern IDE’s.

NetBeans Breakpoint Editor

In NetBeans, create a breakpoint, the right click on the little pink square that signifies the break. Click on “Customize”. When the customize dialog comes up, check “Condition” and fill in the condition. Above is an example of this dialog in NetBeans.

Eclipse Breakpoint Properties

To accomplish the same thing in Eclipse, create your breakpoint, then right-click on the little blue dot signifying the breakpoint and choose “Breakpoint Properties”. In the Properties window, check “Enable Condition” and then fill in your condition or conditions in the box provided. An example is shown above.

Finally, to accomplish the same in JDeveloper (TP4, anyway), set your breakpoint, right click on the little red circle that appears. Then click on “Edit Breakpoint” and in the dialog that pops up, move to the “Conditions” tab. You can set your conditions there as shown in the picture above.

So now that you know, from now on, no more useless breakpoints!

And if you’ve still been debugging using System.out’s, I’m sorry I wasted your time. I’m sure Vi is just sitting there flashing it’s cursor at you waiting for you to save those changes.

Share/Save/Bookmark