|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.nava.informa.utils.cleaner.Cleaner
public class Cleaner
Cleaner is an utility class, which is intended to help applications with detection of unwanted (old, corrupted and etc) items.
Cleaner works in background. It accepts unlimited number of observers, objects of
CleanerObserverIF
type, that are notified each time main engine finds
unwanted items. In order to decide which item is unwanted engine uses matchers,
objects of CleanerMatcherIF
type. Each matcher is a rule. You can create
unlimited number of rules to match items and tell that they are unwanted in some way.
Engine accepts individual channels for registration. You can register channel either
with global or custom periods. Global period defaults to DEFAULT_CLEANING_PERIOD
right after creation and can be changed with call to setPeriod(long)
method.
At any time you can ask cleaner to unregister channel. After that it will never be cleaned by engine again and it's promised that all references to the object will be removed.
Cleaner uses WorkersManager
to maintain asynchronous processing. This means
that there will be several working threads in memory, which will be processing scheduled
requests for channel cleaning. At any time you can change number of running worker threads
starting from 1. If number of threads you require is less than current number of threads
extra threads will be marked for termination and will quit right after finishing their current
jobs.
Constructor Summary | |
---|---|
Cleaner()
Creates cleaner with default number of worker threads. |
|
Cleaner(int workerThreads)
Creates cleaner with specified number of worker threads. |
Method Summary | |
---|---|
void |
addMatcher(CleanerMatcherIF matcher)
Adds matcher to the list. |
void |
addObserver(CleanerObserverIF observer)
Adds observer to the list of interested parties. |
void |
cleanChannel(ChannelIF channel)
Performs immediate cleaning of the channel and reworks the schedule starting from current time. |
void |
registerChannel(ChannelIF channel)
Registers channel for scheduled cleaning with default period (1 hour). |
void |
registerChannel(ChannelIF channel,
long period)
Registers channel for scheduled cleaning with given period. |
void |
removeMatcher(CleanerMatcherIF matcher)
Removes matcher from the list. |
void |
removeObserver(CleanerObserverIF observer)
Removes observer from the list. |
void |
setPeriod(long period)
Sets global cleaning period to the specified value. |
void |
setWorkerThreads(int count)
Changes the number of worker threads. |
void |
unregisterChannel(ChannelIF channel)
Unregisters channel from cleaning. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Cleaner()
setWorkerThreads(int)
method.
public Cleaner(int workerThreads)
setWorkerThreads(int)
method.
workerThreads
- number of worker threads.Method Detail |
---|
public final void addObserver(CleanerObserverIF observer)
observer
- new observer.public final void addMatcher(CleanerMatcherIF matcher)
matcher
- new matcher.public final void removeObserver(CleanerObserverIF observer)
observer
- observer to remove.public final void removeMatcher(CleanerMatcherIF matcher)
matcher
- matcher to remove.public final void registerChannel(ChannelIF channel)
channel
- channel to schedule.public final void registerChannel(ChannelIF channel, long period)
channel
- channel to schedule.period
- period to use.public final void unregisterChannel(ChannelIF channel)
channel
- channel to unregister.public final void cleanChannel(ChannelIF channel)
channel
- channel to update.public final void setWorkerThreads(int count)
count
- new number of worker threads.public final void setPeriod(long period)
period
- period in millis.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |