Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.1.0)

E17493-02

oracle.jdevimpl.audit.core
Class DefaultAuditor

java.lang.Object
  extended by oracle.jdeveloper.audit.service.Auditor
      extended by oracle.jdevimpl.audit.core.DefaultAuditor
All Implemented Interfaces:
java.lang.Runnable

public final class DefaultAuditor
extends Auditor
implements java.lang.Runnable

The default Auditor implementation.


Constructor Summary
DefaultAuditor(ModelTypeFactory factory, java.lang.Class<? extends Analyzer>... analyzers)
           
 
Method Summary
 void addAuditListener(AuditListener listener)
          Adds an audit listener to this auditor.
 boolean addConstruct(java.lang.Object construct, java.net.URL file, Project project, Workspace workspace)
          Adds the location corresponding to a construct to the set of locations to be audited.
 void addDependency(Dependency dependency)
           
 boolean addElement(Element element, Node node, Project project, Workspace workspace)
          Adds the location corresponding to an Element to the set of locations to be audited.
 boolean addElements(Element[] elements, Node node, Project project, Workspace workspace)
          Adds the locations corresponding to an array of Elements in a Node to the set of locations to be audited.
 boolean addNode(Node node, Project project, Workspace workspace)
          Adds the location corresponding to a Node to the set of locations to be audited.
 boolean addUrl(java.net.URL document, Project project, Workspace workspace)
          Adds the location corresponding to a URL to the set of locations to be audited.
 java.lang.Throwable applyDefaultTransforms(java.lang.String label)
          Audits the locations of this auditor in the current thread and applies all default transforms (see Transformer.applyDefaultTransforms(java.lang.String, java.util.Collection, oracle.jdeveloper.audit.service.TransformerListener, oracle.jdeveloper.audit.service.AuditModel).
 void audit()
          Audits the locations of this auditor in the current thread.
 boolean cancel()
          Cancel an executing audit.
 void cancelReport()
           
 void clear()
          Clears the results and locations from this auditor.
 void endReport()
           
 ModelFactory getFactory()
          Gets the factory used for this audit.
 long getMaximumFileSize()
          Gets the size of the largest file that can be audited, in Mb.
 Profile getProfile()
          Gets the profile for this audit.
 WorkingSet getWorkingSet()
          Gets the working set to use when filtering projects.
 boolean isAuditable(Element element, Node node, Project project, Workspace workspace)
          Gets whether an Element is auditable.
 boolean isAuditableType(java.net.URL url)
          Gets whether the element at an URL is of an auditable type.
 boolean isAuditing()
          Gets whether an audit is in progress.
 boolean isCancelled()
          Gets whether an audit in progress has been cancelled.
 boolean isIgnoreAssists()
          Gets whether to ignore issues corresponding to assists (severity ASSIST).
 boolean isVisitAncestors()
          Gets whether to visit ancestors of the locations to be audited.
 boolean isVisitDescendants()
          Gets whether to visit descendants of the locations to be audited.
 void removeAuditListener(AuditListener listener)
          Removes an audit listener from this auditor.
 ViolationReport report(AuditContext context, Rule rule, Location location, java.lang.Object construct)
           
 void report(Metric metric, Location location, java.lang.Object measurement)
           
 void run()
          Audits the locations of this auditor in the current thread.
 void runAsynchronously()
          Audits the locations of this auditor in a background thread.
 void runAsynchronously(java.lang.Thread.UncaughtExceptionHandler handler)
          Audits the locations of this auditor in a background thread.
 void setAttribute(java.lang.Object key, java.lang.Object value)
          Sets a configuration attribute for this auditor.
 void setDependencyCollector(CompositeDependency collector)
          Sets the collector of dependencies discovered when the audit is run, or null.
 void setIgnoreAssists(boolean ignore)
          Sets whether to ignore issues corresponding to assists (severity ASSIST).
 void setMaximumFileSize(long size)
          Sets the size of the largest auditable file.
 void setProfile(Profile profile)
          Sets the profile for this audit.
 void setVisitAncestors(boolean shallow)
          Sets whether to visit ancestors of the locations to be audited.
 void setVisitDescendants(boolean shallow)
          Sets whether to visit descendants of the locations to be audited.
 void setWorkingSet(WorkingSet workingSet)
          Sets the working set to use when filtering projects.
 void setWriteLockRequestListener(WriteLockRequestListener listener)
          Sets the listener to notify if a thread waits to acquire the write lock.
 void throwIfCancelled()
          Throw CancellationException if the last audit to execute was cancelled.
 void tryAudit()
          Audits the locations of this auditor in the current thread if the models for those locations are available without blocking.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultAuditor

public DefaultAuditor(ModelTypeFactory factory,
                      java.lang.Class<? extends Analyzer>... analyzers)
Method Detail

addAuditListener

public void addAuditListener(AuditListener listener)
Description copied from class: Auditor
Adds an audit listener to this auditor.

Specified by:
addAuditListener in class Auditor

removeAuditListener

public void removeAuditListener(AuditListener listener)
Description copied from class: Auditor
Removes an audit listener from this auditor.

Specified by:
removeAuditListener in class Auditor

isAuditable

public boolean isAuditable(Element element,
                           Node node,
                           Project project,
                           Workspace workspace)
Description copied from class: Auditor
Gets whether an Element is auditable. An element is auditable if is of an auditable type, and if the context represented by the node, project, workspace is adequate.

If the workspace is not null, it must be open; if the project is not null, it must be open; if the node is not null, it must be open. Since this is a new stipulation, only a warning is logged currently.

Specified by:
isAuditable in class Auditor
Parameters:
element - An Element corresponding to a construct in the Audit object model.
node - The Node containing the element. Ignored if element is a node.
project - The project containing the element. Ignored if element is a Workspace or Project.
workspace - The workspace containing the element. Ignored if element is a Workspace.

addElement

public boolean addElement(Element element,
                          Node node,
                          Project project,
                          Workspace workspace)
Description copied from class: Auditor
Adds the location corresponding to an Element to the set of locations to be audited. The location will not be added if the element is not auditable.

If the workspace is not null, it must be open; if the project is not null, it must be open; if the node is not null, it must be open. Since this is a new stipulation, only a warning is logged currently.

Specified by:
addElement in class Auditor
Parameters:
element - An Element corresponding to a construct in the Audit object model.
node - The Node containing the element. Ignored if element is a node.
project - The project containing the element. Ignored if element is a Workspace or Project.
workspace - The workspace containing the element. Ignored if element is a Workspace.
Returns:
True if the location was added.
See Also:
Auditor.isAuditable(oracle.ide.model.Element, oracle.ide.model.Node, oracle.ide.model.Project, oracle.ide.model.Workspace)

addElements

public boolean addElements(Element[] elements,
                           Node node,
                           Project project,
                           Workspace workspace)
Description copied from class: Auditor
Adds the locations corresponding to an array of Elements in a Node to the set of locations to be audited. Locations for elements which are not auditable will not be added.

If the workspace is not null, it must be open; if the project is not null, it must be open; if the node is not null, it must be open. Since this is a new stipulation, only a warning is logged currently.

Specified by:
addElements in class Auditor
Parameters:
elements - An array of Elements each corresponding to a construct in the Audit object model.
node - The Node containing the elements.
project - The project containing the elements. Ignored for any element which is a Workspace or Project.
workspace - The workspace containing the elements. Ignored for any element which is a Workspace.
Returns:
True if at least one location was added.
See Also:
Auditor.isAuditable(oracle.ide.model.Element, oracle.ide.model.Node, oracle.ide.model.Project, oracle.ide.model.Workspace)

addNode

public boolean addNode(Node node,
                       Project project,
                       Workspace workspace)
Description copied from class: Auditor
Adds the location corresponding to a Node to the set of locations to be audited. The location will not be added if the project is null, unless the node is a project or workspace; or if the workspace is null, unless the node is a workspace.

If the workspace is not null, it must be open; if the project is not null, it must be open. Since this is a new stipulation, only a warning is logged currently.

Specified by:
addNode in class Auditor
Parameters:
node - A Node in the Audit object model.
project - The project containing the node. Ignored if node is a Workspace or Project.
workspace - The workspace containing the node. Ignored if node is a Workspace.
Returns:
True if the location was added.

addConstruct

public boolean addConstruct(java.lang.Object construct,
                            java.net.URL file,
                            Project project,
                            Workspace workspace)
Description copied from class: Auditor
Adds the location corresponding to a construct to the set of locations to be audited. The location will not be added if the file, project, or workspace are null.

The workspace and project must be open. Since this is a new stipulation, only a warning is logged currently.

Specified by:
addConstruct in class Auditor
Parameters:
construct - A construct in the Audit object model (e.g., a Java object).
file - The URL of the file containing the construct.
project - The project containing the file.
workspace - The workspace containing the file.
Returns:
True if the location was added.

addUrl

public boolean addUrl(java.net.URL document,
                      Project project,
                      Workspace workspace)
Description copied from class: Auditor
Adds the location corresponding to a URL to the set of locations to be audited. The location will not be added if the project is null, unless the node is a project or workspace; or if the workspace is null, unless the node is a workspace. If the workspace is not null and not open, it will be opened. If the project is not null and not open, it will be scanned for technologies and the associated extensions will be loaded.

Specified by:
addUrl in class Auditor
Parameters:
document - The URL of a file or directory in the Audit object model.
project - The project containing the file.
workspace - The workspace containing the file.
Returns:
True if the location was added.

cancel

public boolean cancel()
Description copied from class: Auditor
Cancel an executing audit.

Specified by:
cancel in class Auditor
Returns:
true iff an audit is running and not already cancelled.

throwIfCancelled

public void throwIfCancelled()
Description copied from class: Auditor
Throw CancellationException if the last audit to execute was cancelled.

Specified by:
throwIfCancelled in class Auditor

clear

public void clear()
Description copied from class: Auditor
Clears the results and locations from this auditor. This auditor can be reused after a location is added.

Specified by:
clear in class Auditor

isAuditableType

public boolean isAuditableType(java.net.URL url)
Description copied from class: Auditor
Gets whether the element at an URL is of an auditable type.

Specified by:
isAuditableType in class Auditor

getFactory

public ModelFactory getFactory()
Gets the factory used for this audit.

Specified by:
getFactory in class Auditor

getProfile

public Profile getProfile()
Description copied from class: Auditor
Gets the profile for this audit.

Specified by:
getProfile in class Auditor

setProfile

public void setProfile(Profile profile)
Description copied from class: Auditor
Sets the profile for this audit.

Specified by:
setProfile in class Auditor

setAttribute

public void setAttribute(java.lang.Object key,
                         java.lang.Object value)
Description copied from class: Auditor
Sets a configuration attribute for this auditor. Configuration attributes are accessible to model adapters through the ModelFactory.getAttribute method and to analyzers through the AuditContext.getAttribute(oracle.jdeveloper.audit.analyzer.AuditContext.Key) method with a AuditContext.sharedKey(java.lang.Object)

Typically, configuration attributes are used to allow an IDE command that is implemented using Audit to provide command-specific attributes to a model adapter or analyzer.

Specified by:
setAttribute in class Auditor
Parameters:
key - An object, typically a java.lang.Class, which uniquely identifies the attribute, used to create the shared key.
value - The possibly null value of the attribute.
See Also:
AuditContext.sharedKey(java.lang.Object), AuditContext.getAttribute(oracle.jdeveloper.audit.analyzer.AuditContext.Key), ModelFactory.getAttribute(java.lang.Object)

isAuditing

public boolean isAuditing()
Description copied from class: Auditor
Gets whether an audit is in progress.

Specified by:
isAuditing in class Auditor

isCancelled

public boolean isCancelled()
Description copied from class: Auditor
Gets whether an audit in progress has been cancelled.

Specified by:
isCancelled in class Auditor

getMaximumFileSize

public long getMaximumFileSize()
Description copied from class: Auditor
Gets the size of the largest file that can be audited, in Mb.

Specified by:
getMaximumFileSize in class Auditor

setMaximumFileSize

public void setMaximumFileSize(long size)
Description copied from class: Auditor
Sets the size of the largest auditable file.

Specified by:
setMaximumFileSize in class Auditor
Parameters:
size - The size, in Mb, of the largest file that can be audited.

setWorkingSet

public void setWorkingSet(WorkingSet workingSet)
Description copied from class: Auditor
Sets the working set to use when filtering projects.

Specified by:
setWorkingSet in class Auditor

getWorkingSet

public WorkingSet getWorkingSet()
Description copied from class: Auditor
Gets the working set to use when filtering projects.

Specified by:
getWorkingSet in class Auditor

setIgnoreAssists

public void setIgnoreAssists(boolean ignore)
Description copied from class: Auditor
Sets whether to ignore issues corresponding to assists (severity ASSIST).

Specified by:
setIgnoreAssists in class Auditor

isIgnoreAssists

public boolean isIgnoreAssists()
Description copied from class: Auditor
Gets whether to ignore issues corresponding to assists (severity ASSIST).

Specified by:
isIgnoreAssists in class Auditor

setWriteLockRequestListener

public void setWriteLockRequestListener(WriteLockRequestListener listener)
Description copied from class: Auditor
Sets the listener to notify if a thread waits to acquire the write lock.

Specified by:
setWriteLockRequestListener in class Auditor
Parameters:
listener - The listener to notify if a thread waits to acquire the write lock, or null if none.

setDependencyCollector

public void setDependencyCollector(CompositeDependency collector)
Description copied from class: Auditor
Sets the collector of dependencies discovered when the audit is run, or null. By default, dependencies are not collected. The client must remove itself as a listener when it no longer needs the dependencies.

Specified by:
setDependencyCollector in class Auditor

setVisitDescendants

public void setVisitDescendants(boolean shallow)
Description copied from class: Auditor
Sets whether to visit descendants of the locations to be audited. By default, visitAncestors is true.

Specified by:
setVisitDescendants in class Auditor
See Also:
Auditor.setVisitAncestors(boolean)

isVisitDescendants

public boolean isVisitDescendants()
Description copied from class: Auditor
Gets whether to visit descendants of the locations to be audited.

Specified by:
isVisitDescendants in class Auditor
See Also:
Auditor.setVisitDescendants(boolean)

setVisitAncestors

public void setVisitAncestors(boolean shallow)
Description copied from class: Auditor
Sets whether to visit ancestors of the locations to be audited. By default, visitAncestors is true.

Specified by:
setVisitAncestors in class Auditor
See Also:
Auditor.setVisitAncestors(boolean)

isVisitAncestors

public boolean isVisitAncestors()
Description copied from class: Auditor
Gets whether to visit ancestors of the locations to be audited.

Specified by:
isVisitAncestors in class Auditor
See Also:
Auditor.setVisitAncestors(boolean)

run

public void run()
Description copied from class: Auditor
Audits the locations of this auditor in the current thread. The locations audited are those added to this auditor by Auditor.addElement(oracle.ide.model.Element, oracle.ide.model.Node, oracle.ide.model.Project, oracle.ide.model.Workspace), and Auditor.addConstruct(java.lang.Object, java.net.URL, oracle.ide.model.Project, oracle.ide.model.Workspace). The results of the audit are passed to the audit listeners added by Auditor.addAuditListener(oracle.jdeveloper.audit.service.AuditListener).

Specified by:
run in interface java.lang.Runnable
Specified by:
run in class Auditor

runAsynchronously

public void runAsynchronously()
Description copied from class: Auditor
Audits the locations of this auditor in a background thread. The locations audited are those added to this auditor by Auditor.addElement(oracle.ide.model.Element, oracle.ide.model.Node, oracle.ide.model.Project, oracle.ide.model.Workspace), and Auditor.addConstruct(java.lang.Object, java.net.URL, oracle.ide.model.Project, oracle.ide.model.Workspace). The results of the audit are passed to the audit listeners added by Auditor.addAuditListener(oracle.jdeveloper.audit.service.AuditListener).

Specified by:
runAsynchronously in class Auditor

runAsynchronously

public void runAsynchronously(java.lang.Thread.UncaughtExceptionHandler handler)
Description copied from class: Auditor
Audits the locations of this auditor in a background thread. The locations audited are those added to this auditor by Auditor.addElement(oracle.ide.model.Element, oracle.ide.model.Node, oracle.ide.model.Project, oracle.ide.model.Workspace), and Auditor.addConstruct(java.lang.Object, java.net.URL, oracle.ide.model.Project, oracle.ide.model.Workspace). The results of the audit are passed to the audit listeners added by Auditor.addAuditListener(oracle.jdeveloper.audit.service.AuditListener).

Specified by:
runAsynchronously in class Auditor

audit

public void audit()
Description copied from class: Auditor
Audits the locations of this auditor in the current thread. The locations audited are those added to this auditor by Auditor.addElement(oracle.ide.model.Element, oracle.ide.model.Node, oracle.ide.model.Project, oracle.ide.model.Workspace), and Auditor.addConstruct(java.lang.Object, java.net.URL, oracle.ide.model.Project, oracle.ide.model.Workspace). The results of the audit are passed to the audit listeners added by Auditor.addAuditListener(oracle.jdeveloper.audit.service.AuditListener).

Specified by:
audit in class Auditor

tryAudit

public void tryAudit()
Description copied from class: Auditor
Audits the locations of this auditor in the current thread if the models for those locations are available without blocking. The locations audited are those added to this auditor by Auditor.addElement(oracle.ide.model.Element, oracle.ide.model.Node, oracle.ide.model.Project, oracle.ide.model.Workspace), and Auditor.addConstruct(java.lang.Object, java.net.URL, oracle.ide.model.Project, oracle.ide.model.Workspace). The results of the audit are passed to the audit listeners added by Auditor.addAuditListener(oracle.jdeveloper.audit.service.AuditListener).

Specified by:
tryAudit in class Auditor

applyDefaultTransforms

public java.lang.Throwable applyDefaultTransforms(java.lang.String label)
Description copied from class: Auditor
Audits the locations of this auditor in the current thread and applies all default transforms (see Transformer.applyDefaultTransforms(java.lang.String, java.util.Collection, oracle.jdeveloper.audit.service.TransformerListener, oracle.jdeveloper.audit.service.AuditModel). The locations audited are those added to this auditor by Auditor.addElement(oracle.ide.model.Element, oracle.ide.model.Node, oracle.ide.model.Project, oracle.ide.model.Workspace), and Auditor.addConstruct(java.lang.Object, java.net.URL, oracle.ide.model.Project, oracle.ide.model.Workspace). The results of the audit are passed to the audit listeners added by Auditor.addAuditListener(oracle.jdeveloper.audit.service.AuditListener).

Specified by:
applyDefaultTransforms in class Auditor

addDependency

public void addDependency(Dependency dependency)

report

public ViolationReport report(AuditContext context,
                              Rule rule,
                              Location location,
                              java.lang.Object construct)

endReport

public void endReport()

cancelReport

public void cancelReport()

report

public void report(Metric metric,
                   Location location,
                   java.lang.Object measurement)

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.1.0)

E17493-02

Copyright © 1997, 2011, Oracle. All rights reserved.