net.sf.urlchecker.commands
Class CheckUrlsGeneric<T>

Package class diagram package CheckUrlsGeneric
java.lang.Object
  extended by net.sf.urlchecker.commands.AbstractCommand
      extended by net.sf.urlchecker.commands.CheckUrlsGeneric<T>
Type Parameters:
T - the generic type

$Id: CheckUrlsGeneric.java 180 2010-12-12 18:47:56Z georgosn $

All Implemented Interfaces:
Command
Direct Known Subclasses:
CheckUrlsCommand, CheckUrlsCommand

public abstract class CheckUrlsGeneric<T>
extends AbstractCommand

The Abstract Generic CheckUrls Command. It simply serves the purposes of this release and future releases of the library may not contain it. This class was needed to relieve the individual commands from carrying code that is common regardless of the client being used. Individual subclasses implement the methods that use the client and thus should do different things to ensure operation. immutable

Version:
$LastChangedRevision: 184 $
Author:
$LastChangedBy: georgosn $

Field Summary
protected  T client
          The client.
protected static org.apache.log4j.Logger LOGGER
          The Constant LOGGER.
protected static long TERMINATION_TIME_IN_SECONDS
          The Constant TERMINATION_TIME_IN_SECONDS.
protected  Long terminationTime
          The termination time.
 
Constructor Summary
CheckUrlsGeneric(Command successor, T newClient)
          Instantiates a new checkURLs generic command.
 
Method Summary
abstract  boolean isMultithreaded()
          Checks if the client is set up for multithreaded operation.
protected abstract  void multithreadedExecution(Context context, Iterator<Result> iter)
          Spawns threads to check individual URLs.
 Set<Result> process(Context context)
          This method processes the input Context and forwards the results on to the successor.
protected abstract  void singlethreadedExecution(Iterator<Result> iter)
          Executes checking using one thread for all URLs to check.
 
Methods inherited from class net.sf.urlchecker.commands.AbstractCommand
fireEvent, getSuccessor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TERMINATION_TIME_IN_SECONDS

protected static final long TERMINATION_TIME_IN_SECONDS
The Constant TERMINATION_TIME_IN_SECONDS.

See Also:
Constant Field Values

terminationTime

protected final Long terminationTime
The termination time.


LOGGER

protected static final org.apache.log4j.Logger LOGGER
The Constant LOGGER.


client

protected final T client
The client.

Constructor Detail

CheckUrlsGeneric

public CheckUrlsGeneric(Command successor,
                        T newClient)
Instantiates a new checkURLs generic command. Client cannot be null and must be of the same type declared for this Generic's subclass.

Type Parameters:
T - a T object.
Parameters:
successor - the successor command
newClient - the new client
Method Detail

isMultithreaded

public abstract boolean isMultithreaded()
Checks if the client is set up for multithreaded operation. It is left to the subclasses to define this method as different clients will provide different ways to determine the state of the ConnectionManager.

Returns:
if is multithreaded.

multithreadedExecution

protected abstract void multithreadedExecution(Context context,
                                               Iterator<Result> iter)
                                        throws org.apache.commons.configuration.ConfigurationException
Spawns threads to check individual URLs.

Parameters:
context - , the enginge's context
iter - , the valid context results iterator to check over the Internet.
Throws:
org.apache.commons.configuration.ConfigurationException - the configuration exception

process

public Set<Result> process(Context context)
                    throws org.apache.commons.configuration.ConfigurationException
This method processes the input Context and forwards the results on to the successor. This implementation of the method simply checks if there are any successors and passes the context. if no successor is registered for the command then it merely returns the results from the context. The method also fires a BasicChainEvent before sending the control to the successor command with an END Type. This behavior allows the subclasses to concentrate in processing the input while the rest of the package releases all the features of event firing and handling. Events can be fired from within subclasses but it is better not to fire END events as this is handled here. START events though, must be fired in the subclasses if they are needed.

Specified by:
process in interface Command
Overrides:
process in class AbstractCommand
Parameters:
context - the input
Returns:
the set
Throws:
org.apache.commons.configuration.ConfigurationException - the configuration exception

singlethreadedExecution

protected abstract void singlethreadedExecution(Iterator<Result> iter)
                                         throws org.apache.commons.configuration.ConfigurationException
Executes checking using one thread for all URLs to check.

Parameters:
iter - , the valid context results iterator to check over the Internet.
Throws:
org.apache.commons.configuration.ConfigurationException - the configuration exception.


Copyright © 2010 Nikolaos Georgosopoulos. All Rights Reserved.