Package com.helger.photon.audit
Class AsynchronousAuditor
- java.lang.Object
-
- com.helger.photon.audit.AbstractAuditor
-
- com.helger.photon.audit.AsynchronousAuditor
-
- All Implemented Interfaces:
IAuditor
@ThreadSafe public class AsynchronousAuditor extends AbstractAuditor
The class handles audit items asynchronously. If a new audit item is to be handled it is put into theIConcurrentPerformer's queue as provided in the constructor.
Please ensure to callstop()if this auditor is no longer used, so that the createdExecutorServicecan be gracefully shutdown.- Author:
- Philip Helger
-
-
Constructor Summary
Constructors Constructor Description AsynchronousAuditor(com.helger.security.authentication.subject.user.ICurrentUserIDProvider aUserIDProvider, com.helger.commons.concurrent.collector.IConcurrentPerformer<List<IAuditItem>> aPerformer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetQueueLength()protected voidhandleAuditItem(IAuditItem aAuditItem)Implement this method to handle the created audit items.com.helger.commons.state.EChangestop()When using this auditor, it is important to call thisstop()method before shutdown.-
Methods inherited from class com.helger.photon.audit.AbstractAuditor
createAuditItem, getActionStringProvider, getCurrentUserIDProvider, setActionStringProvider, setCurrentUserIDProvider
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.helger.photon.audit.IAuditor
onCreateFailure, onCreateSuccess, onDeleteFailure, onDeleteSuccess, onExecuteFailure, onExecuteFailure, onExecuteSuccess, onExecuteSuccess, onModifyFailure, onModifySuccess, onUndeleteFailure, onUndeleteSuccess
-
-
-
-
Constructor Detail
-
AsynchronousAuditor
public AsynchronousAuditor(@Nonnull com.helger.security.authentication.subject.user.ICurrentUserIDProvider aUserIDProvider, @Nonnull com.helger.commons.concurrent.collector.IConcurrentPerformer<List<IAuditItem>> aPerformer)
-
-
Method Detail
-
handleAuditItem
protected void handleAuditItem(@Nonnull IAuditItem aAuditItem)
Description copied from class:AbstractAuditorImplement this method to handle the created audit items.- Specified by:
handleAuditItemin classAbstractAuditor- Parameters:
aAuditItem- The audit item to handle. Nevernull.
-
getQueueLength
@Nonnegative public int getQueueLength()
-
stop
@Nonnull public com.helger.commons.state.EChange stop()
When using this auditor, it is important to call thisstop()method before shutdown. It avoids further queuing of objects and waits until all items are handled. This method blocks until all remaining objects are handled.- Returns:
EChange.CHANGEDif the shutdown was performed,EChange.UNCHANGEDif the auditor was already shut down.
-
-