de.nava.informa.utils.poller
Class PollerWorkerThread

java.lang.Object
  extended by java.lang.Thread
      extended by de.nava.informa.utils.toolkit.WorkerThread
          extended by de.nava.informa.utils.poller.PollerWorkerThread
All Implemented Interfaces:
Runnable

public class PollerWorkerThread
extends WorkerThread

Worker thread is the main processing unit. Worker thread is not dedicated to single channel, group or whatever else. It represents a single thread, which is capable of doing well-defined and unified job. WorkersManager submits jobs for free WorkerThread's. Workers simply do their jobs. This architecture allows to scale to as much threads as necessary.

Author:
Aleksey Gureev (spyromus@noizeramp.com)

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
static int POLICY_SCAN_ALL
          Scanning for new items performed fully.
static int POLICY_SKIP_AFTER_EXISTING
          Scanning for new items in channel finishes when existing item detected.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
PollerWorkerThread(PollerObserverIF observer, PollerApproverIF approver, int itemScanningPolicy, InputSourceProviderIF inputSourceProvider, InputStreamProviderIF inputStreamProvider)
          Creates worker thread for poller with given observer and approver.
 
Method Summary
(package private) static boolean channelHasChanged(ChannelIF o, ChannelIF n)
          Checks if channel has changed.
(package private)  void checkItems(ChannelIF newChannel, ChannelRecord record)
          Walks through the items and checks if new items present.
(package private) static boolean differ(Object a, Object b)
          Checks if two objects differ.
protected  void processRecord(ChannelRecord record)
          Processes record.
 void setUserAgent(String userAgent)
          Sets specific user-agent to use when using HTTP protocol.
 
Methods inherited from class de.nava.informa.utils.toolkit.WorkerThread
getChannelInProcess, run, setQueue, terminate
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

POLICY_SKIP_AFTER_EXISTING

public static final int POLICY_SKIP_AFTER_EXISTING
Scanning for new items in channel finishes when existing item detected.

See Also:
Constant Field Values

POLICY_SCAN_ALL

public static final int POLICY_SCAN_ALL
Scanning for new items performed fully.

See Also:
Constant Field Values
Constructor Detail

PollerWorkerThread

public PollerWorkerThread(PollerObserverIF observer,
                          PollerApproverIF approver,
                          int itemScanningPolicy,
                          InputSourceProviderIF inputSourceProvider,
                          InputStreamProviderIF inputStreamProvider)
Creates worker thread for poller with given observer and approver.

Parameters:
observer - observer object.
approver - approver object.
itemScanningPolicy - policy for item scanning.
inputSourceProvider - provider of InputSource for feeds' streams.
inputStreamProvider - provider of InputStream for feeds.
Method Detail

setUserAgent

public void setUserAgent(String userAgent)
Sets specific user-agent to use when using HTTP protocol.

Parameters:
userAgent - user agent or NULL to use default.

processRecord

protected final void processRecord(ChannelRecord record)
Processes record.

Specified by:
processRecord in class WorkerThread
Parameters:
record - record to process.

checkItems

final void checkItems(ChannelIF newChannel,
                      ChannelRecord record)
Walks through the items and checks if new items present.

Parameters:
newChannel - new channel taken from web.
record - record about currently existing channel to match against.

channelHasChanged

static boolean channelHasChanged(ChannelIF o,
                                 ChannelIF n)
Checks if channel has changed.

Parameters:
o - old channel.
n - new channel.
Returns:
result of the check.

differ

static boolean differ(Object a,
                      Object b)
Checks if two objects differ. NULL isn't different from other NULL.

Parameters:
a - object.
b - object.
Returns:
result of the check.


Copyright © 2002-2007 Niko Schmuck. All Rights Reserved.