@ SuppressWarnings ( "PMD.ConfusingTernary" ) private void initAudit ( final CommonProperties commonProps ) { try { final String auditClassName = commonProps . getAuditClassName ( ) ; // this would be harder to read when following PMD's advice - ignoring the PMD warning if ( ! commonProps . isAuditEnabled ( ) ) { final String error = "Auditing has been disabled in the JAAS configuration" ; LOG . info ( error ) ; } else if ( auditClassName == null ) { final String error = "Auditing has been enabled in the JAAS configuration, but no audit class has been configured" ; LOG . error ( error ) ; throw new IllegalStateException ( error ) ; } else { if ( commonProps . isAuditSingleton ( ) ) { LOG . debug ( "Requesting singleton audit class instance of '" + auditClassName + "' from the audit factory" ) ; this . audit = AuditFactory . getSingleton ( auditClassName , commonProps ) ; } else { LOG . debug ( "Requesting non-singleton audit class instance of '" + auditClassName + "' from the audit factory" ) ; this . audit = AuditFactory . getInstance ( auditClassName , commonProps ) ; } } } catch ( FactoryException e ) { final String error = "The audit class cannot be instantiated. This is most likely a configuration" + " problem. Is the configured class available in the classpath?" ; LOG . error ( error , e ) ; throw new IllegalStateException ( error , e ) ; } }
Initialize the instance - global audit object