Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Custom audit rules in Jdeveloper extension


Published on

This presentation talk about how can create custom audit rules in jdeveloper.

Published in: Technology
  • Good one
    Are you sure you want to  Yes  No
    Your message goes here
  • You make me understand.thank you
    Are you sure you want to  Yes  No
    Your message goes here
  • Nice.Keep posting
    Are you sure you want to  Yes  No
    Your message goes here

Custom audit rules in Jdeveloper extension

  1. 1. Presented by Vinay Kumar SILBURY IT SOLUTION GMBH 10/04/2014 Custom Audit Rules in Jdeveloper 12c
  2. 2. • Audit in JDeveloper • Extension in Jdeveloper 12c • Set up extension environment • Creation Extension project • Create Audit Rule • Suppress Warning • Run Extension • Test Extension Agenda
  3. 3. • Audit is a planned and documented activity performed by qualified personnel to determine by investigation, examination, or evaluation of objective evidence, the adequacy and compliance with established procedures, or applicable documents, and the effectiveness of implementation • Analysis of code with set of metrics and guidelines . • Auditing in Jdeveloper- Auditing is the static analysis of code for adherence to rules and metrics that define programming standards. Auditing finds defects that make code difficult to improve and maintain. The JDeveloper auditing tools help you find and fix such defects. Code can be audited even when it is not compilable or executable. What is Audit
  4. 4. • JDeveloper has a built in Audit framework with lots of rules that you can turn on or off. • Also can create new custom audit rules . • Based on Visitor design pattern. • Able to create new Audit rules. • Rules can be configurable • Generate warning or error compile time. • Help in improving code quality. • Auditing finds defects that make code difficult to improve and maintain • JDeveloper auditing feature to analyze Java code for conformance to programming standards. Audit Framework in jdeveloper
  5. 5. .
  6. 6. .
  7. 7. • Install Extension SDK (Help- Check for updates) • Search for Extension SDK • Add this update in your Jdeveloper Setting up Extension workspace
  8. 8. Create New Extension project File -> New- Applications -> Extension Application extension.xml & Manifest.MF Bundled as .zip Distributed through Jdeveloper update center Or Drive
  9. 9. • ` New Extension Application
  10. 10. Application structure
  11. 11. Add Dependencies
  12. 12. Create new custom rule
  13. 13. .
  14. 14. Extension.xml Java Analyzer class mapping with rule Audit Hook display name Rule Id mapping Severity element can be set to one from these options. -Error -Warning -Incomplete -Advisory -Assist
  15. 15. Properties file Label definition file
  16. 16. . Rule Id mapped in extension.xml •. Class should extend analyzer
  17. 17. . Report violated rule to AuditContenxt
  18. 18. • A visitor over the Audit object models which verifies rules and/or computes metrics. • Analyzer subclass implements visitor methods which are invoked by the Audit framework as it traverses the Audit object models i.e. enter & exit • Visitor methods (enter & exit) report violations and measurements using the reporting methods of a context object passed to them. • getRules & getMetrics provide rules& metric of analyzer to framework . • Analyzers (classes) are registered with the AuditManager at startup by IDE extensions. oracle.jdeveloper.audit.analyzer.Analyzer
  19. 19. • Audit framework traverses the constructs of the object models corresponding to the nodes being audited and at each construct invokes the applicable enter and exit methods of each registered analyzer. • enter and exit methods accept two parameters, a context and a construct. • Visitor method called each workspace, source class, document, element, attribute, method. • Violations and measurements, suppression are reported by the visitor methods using the report method. • Setting attributes for child & parent construct. interface AuditContext Context, construct
  20. 20. • public void enter(AuditContext context, Workspace workspace) This methods contains the workspace (application) validation code. In our case we do not use it. • public void enter(AuditContext context, Project project) This methods contains the project validation code. In our case we do not use it. • public void enter(AuditContext context, Document document) This method contains the code to analyze and validate documents. • public void enter(AuditContext context, Element element) This method contains the code to analyze and validate individual element. .
  21. 21. Analyzers registered with Audit Manager on start up by IDE Each analyzer create instance and fetch rules using getRules method each construct invokes methods of registered analyzer Enter & exit method invoked as per match the construct Check/analyze information in visitor methods and report to context Audit framework flow
  22. 22. SuppressWarning Annotation • Indicate to suppress this warning in workspace for all elements.
  23. 23. • Suppressed warning in jdeveloper by annotation. SuppressWarning Annotation
  24. 24. • Make Extension.jpr • Deploy to Target Platform • Run Extension • New Jdevloper instance open • Tools -> Preferences -> Audit -> Profiles and find rule • Test rule. Run & Test Audit Rule Extension
  25. 25. Run & Test Audit Rule Extension
  26. 26. • Create bundle.xml in project • Create an extension package which consists of a JAR that is packaged in an extension bundle archive • Change extension JAR files into a .zip file for distribution Packaging Extension
  27. 27. .
  28. 28. • Analyzer Class-Oracle Documentation • Developing Extensions for Oracle Jdeveloper • blog on extension • blog by Richard References
  29. 29. .
  30. 30. Happy Auditing With Jdeveloper Thanks