The UK Oracle User group (UKOUG) held their technology conference 2013 in Manchester.
Wilfred van der Deijl and Richard Olrichs had a very interesting presentation about extending the standard audit framework build in JDeveloper. The standard audit framework build in JDeveloper is a powerfull tool for you to check your project code against a set of rules and standards. The presentation showed how you can extend the Audit Framework. This allows you to create you own Audit rules and for instance enforce team (or even company) development standards.
This blog shows a summary of the UKOUG presentation, explains in short how you can extends the JDeveloper Audit Framework and shows the interesting audit framework extension the presenters are currently working on.
The audit framework
In daily development with jdeveloper we already get confronted with the audit framework without even fully realizing it. If we type in a duplicate id for a component in a jsf page, we get some red underlining of our code and a red little error balloon to generate a new unique id in a sec. If we are using an internal adf class we get a orange underlining and orange little warning balloon in our class. etc.
In the JDeveloper build menu there is the option to explicitly run an audit on the whole project. This will produce a nice overview of all failing checks.
In the jdeveloper preferences (tab’audit’) you have the option to automatically also run an audit during compilation.
Checking this option will abort the compilation if there are failing checks.
Underneath the Audit tab the tab ‘profiles’ shows the different default sets of rules (profiles) that exist in JDeveloper. You can even alter the profiles by turning checks on or of, changing their severity and more.
What you can’t do here though is create your own set of rules. It would be nice to check for specific standards of your own team for example.
Extending
There are already a couple of blogs on how to extend for different versions of JDeveloper.
To avoid repetition of existing material for a detailed explanation on how to extend, please have a look at for example
Write your own Audit Rule Extension in JDeveloper 12C
First make sure you have the Extension SDK for JDeveloper, which will enable you to write an extension for JDeveloper yourself.
Next thing to do is to write an audit extension by creating the following:
– class for your audit check
package nl.atb.audits; import oracle.jdeveloper.audit.analyzer.Analyzer; public class CheckSomethingAnalyzer extends Analyzer { . . . }
– optionally class for possible repairs when the audit check fail
package nl.atb.audits; import oracle.jdeveloper.audit.transform.Transform; public class CheckSomethingTransform extends Transform{ . . . }
– audit hook for you check and repair classes (for example one for business component files)
<trigger-hooks xmlns="http://xmlns.oracle.com/ide/extension"> <triggers> <audit-hook id="nl.atb.audits" xmlns="http://xmlns.oracle.com/ide/extension"> <category-definition id="myCat"> <rule-definition id="myRule"> <category>myCat</category> <enabled>true</enabled> <severity>warning</severity> <transform-binding> <transform>myTransform</transform> </transform-binding> </rule-definition> <analyzer-definition> <analyzer-class>nl.atb.audits.CheckSomethingAnalyzer</analyzer-class> </analyzer-definition> <transform-definition id="myTransform"> <transform-class>nl.atb.audits.CheckSomethingTransform</transform-class> </transform-definition> <trigger> <technology>ADFbc</technology> </trigger> </category-definition></audit-hook> </triggers> </trigger-hooks>
Your extension can be installed by going to JDevelopers “Check for update” dialog and choose to install by file, pointing to the zip with your custom audit extension.
ADF EMG Extension Project
The EMG has published a very usefull document with ADF coding guidelines at the ADF architecture square and Wilfred and Richard came up with the great idea to implement those in a JDeveloper audit extension.
They have started a project called ADF EMG Audit Rules
The extension is available as we speak, but you are also very welcome to contribute and discuss with them on the ADF EMG.
At the Manchester presentation they had a screenshot of their java project showing just 2 members. I guess I was not the only one eager to get started after their presentation because at this moment that number has already grown to 12 members!