com.day.cq.rewriter.linkchecker.impl
Class LinkCheckerTask

java.lang.Object
  extended by com.day.cq.rewriter.linkchecker.impl.LinkCheckerTask
All Implemented Interfaces:
ExternalLinkChecker, Runnable

public class LinkCheckerTask
extends Object
implements Runnable, ExternalLinkChecker

Asynchronous task used to check external links on a regular basis.


Field Summary
protected  int badLinkTestInterval
          The number of hours to wait until a bad link is checked again.
protected  int goodLinkTestInterval
          The number of hours to wait until a valid link is checked again.
protected  int linkUnusedInterval
          The number of hours after which validity information about a link is removed from the repository if the link is not used any more.
protected  LinkInfoStorage storage
           
 
Constructor Summary
LinkCheckerTask()
           
 
Method Summary
protected  void activate(org.osgi.service.component.ComponentContext context)
          Activates the LinkChecker service.
 boolean check(String url)
          Validates and updates the given external link.
 void checkLink(LinkInfo info)
           
protected  void deactivate(org.osgi.service.component.ComponentContext componentContext)
          Deactivates the LinkChecker service.
 boolean isValid(String url)
          Checks a link for validity (HTTP response code 2xx or 3xx)
 void run()
          Walks through the links stored in the repository and checks them for validity if necessary or removes them from the repository if they are no longer used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

storage

protected LinkInfoStorage storage

goodLinkTestInterval

protected int goodLinkTestInterval
The number of hours to wait until a valid link is checked again.


badLinkTestInterval

protected int badLinkTestInterval
The number of hours to wait until a bad link is checked again.


linkUnusedInterval

protected int linkUnusedInterval
The number of hours after which validity information about a link is removed from the repository if the link is not used any more.

Constructor Detail

LinkCheckerTask

public LinkCheckerTask()
Method Detail

activate

protected void activate(org.osgi.service.component.ComponentContext context)
                 throws RepositoryException
Activates the LinkChecker service.

Parameters:
context - The component context providing startup information
Throws:
RepositoryException

deactivate

protected void deactivate(org.osgi.service.component.ComponentContext componentContext)
Deactivates the LinkChecker service.

Parameters:
componentContext - The component context

run

public void run()
Walks through the links stored in the repository and checks them for validity if necessary or removes them from the repository if they are no longer used.

Specified by:
run in interface Runnable

check

public boolean check(String url)
Description copied from interface: ExternalLinkChecker
Validates and updates the given external link.

Specified by:
check in interface ExternalLinkChecker
Parameters:
url - external link

checkLink

public void checkLink(LinkInfo info)

isValid

public boolean isValid(String url)
Checks a link for validity (HTTP response code 2xx or 3xx)

Parameters:
url - The link to be checked
Returns:
true, if the link is valid


Copyright © 2008 Day Management AG. All Rights Reserved.