* Note: It is safest to instantiate a fresh HrefValidationProgress * object for every invocation of updateHrefInfo(). */ public class HrefValidationProgress implements Serializable { private static final long serialVersionUID = 3031274879702889688L; private static Log log = LogFactory.getLog(HrefValidationProgress.class ); AtomicInteger webapp_update_count_; AtomicInteger dir_update_count_; AtomicInteger file_update_count_; AtomicInteger url_update_count_; AtomicBoolean is_done_; AtomicBoolean is_aborted_; public HrefValidationProgress() { webapp_update_count_ = new AtomicInteger(); dir_update_count_ = new AtomicInteger(); file_update_count_ = new AtomicInteger(); url_update_count_ = new AtomicInteger(); is_done_ = new AtomicBoolean( false ); is_aborted_ = new AtomicBoolean( false ); } /** * Returns the number of webapps that have been completely * URL-revalidated thus far by a call to updateHrefInfo(). * Note that it is possible to revalidate every webapp * in a store via updateHrefInfo(), so this value can * be greater than 1. */ public int getWebappUpdateCount() { return webapp_update_count_.intValue();} /** * Returns the number of directories that have been completely * URL-revalidated thus far by a call to updateHrefInfo(). */ public int getDirUpdateCount() { return dir_update_count_.intValue(); } /** * Tell the thread that is validating hrefs to abort its current * operation, and cause that operation to declare it "done" and throw * LinkValidationAbortedException. * * Thus, if you have an observer polling progress & checking isDone(), * they'll also see that things are "finished", and can check to see * whether it's because isAborted() is true. */ public void abort() { if(log.isDebugEnabled()) { log.debug( "Validation request aborted via: " + "HrefValidationProgress.abort()"); } is_aborted_.set( true ); setDone( true ); } /** * Indicates whether or not the validation operation was halted by abort(). */ public boolean isAborted() { return is_aborted_.get(); } /** * Returns the number of files that have been completely * URL-revalidated thus far by a call to updateHrefInfo(). */ public int getFileUpdateCount() { return file_update_count_.intValue();} /** * Returns the number of distinct URLs that have been * URL-revalidated thus far by a call to updateHrefInfo(). */ public int getUrlUpdateCount() { return url_update_count_.intValue(); } /** * Returns true if and only if the call to updateHrefInfo() has returned * (whether by a normal return or via an exception). */ public boolean isDone() { return is_done_.get(); } void init() { setDone( false ); // some defensive measures against datastructure recycling // webapp_update_count_.set(0); dir_update_count_.set(0); file_update_count_.set(0); url_update_count_.set(0); } int incrementWebappUpdateCount() { return webapp_update_count_.incrementAndGet(); } int incrementDirUpdateCount() {return dir_update_count_.incrementAndGet(); } int incrementFileUpdateCount(){return file_update_count_.incrementAndGet();} int incrementUrlUpdateCount() {return url_update_count_.incrementAndGet(); } void setDone(Boolean tf) { is_done_.set( tf ); } }