org.norther.tammi.spray.loader
Class DefaultTaskLoader

java.lang.Object
  extended by org.norther.tammi.core.base.Adaptee
      extended by org.norther.tammi.spray.loader.DefaultTaskLoader
All Implemented Interfaces:
Serializable, NotificationBroadcaster, NotificationEmitter, Manageable, MBeanDelegate, Refreshable, CacheClient, TaskLoader

public class DefaultTaskLoader
extends Adaptee
implements TaskLoader

A default implementation TaskLoader.

Based on ModuleLoader in the Apache Jakarta Turbine project.

Author:
Jason van Zyl, Ilkka Priha
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.norther.tammi.core.base.Adaptee
ADAPTEE_NOTIF_DESCRIPTION, ADAPTEE_NOTIFICATIONS
 
Fields inherited from interface org.norther.tammi.core.base.MBeanDelegate
ARRAY_TYPE, OBJECT_TYPE, PRIMITIVE_TYPE, STRING_TYPE
 
Constructor Summary
DefaultTaskLoader()
          Contructs a new loader.
 
Method Summary
 void addPackageName(int index, String pckage)
          Adds a package name to the specified location of the task search list.
 void addPackageName(String pckage)
          Adds a package name to the task search list.
 void clearCached()
          Clears all cached entries without notifying.
 void clearPackageNames()
          Clears all package name from the task search list.
 void execute(String name, ServletRequest request, ServletResponse response, FilterChain chain, Object context)
          Executes an instance of a task
 void expireCached(long timestamp)
          Expires all cached entries notifying them about expiration.
 void expireFraction(long timestamp, float fraction)
          Expires the specified fraction of cached entries notifying them about expiration.
 ConcurrentMap getCache(boolean create)
          Gets and optionally creates the cache.
 String[] getPackageNames()
          Gets package names in the task search list.
 long getRefreshed()
          Gets the last refresh timestamp.
 boolean initialize(String name, ServletRequest request, ServletResponse response, FilterChain chain, Object context)
          Initializes an instance of a task without execution.
 boolean isCachingDisabled()
          Checks whether the caching is disabled.
 boolean isScriptingEnabled()
          Checks whether scripting is enabled.
protected  Task load(String name, ServletRequest request, ServletResponse response, FilterChain chain, Object context)
          Loads an instance of a task.
 void refresh()
          Refreshes the MBean.
 void removeCache()
          Removes the cache.
 void removePackageName(String pckage)
          Removes a package name from the task search list.
 void setCachingDisabled(boolean flag)
          Sets the caching disabled flag.
 void setPackageNames(String[] pckages)
          Sets package names in the task search list.
 void setScriptingEnabled(boolean flag)
          Sets the scripting enabled flag.
 
Methods inherited from class org.norther.tammi.core.base.Adaptee
addAdaptee, addNotificationListener, getAttributeSupport, getBroker, getCanonicalName, getDomain, getFactory, getLoader, getLog, getLog, getMBean, getMBeanServer, getNotificationInfo, getObjectName, getRegistrationTime, getSequenceNumber, hasListeners, isRegistered, postmanaged, premanaged, removeNotificationListener, removeNotificationListener, sendNotification, sendNotification, sendNotification, sendNotification, unmanaged, unregister
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultTaskLoader

public DefaultTaskLoader()
Contructs a new loader.

Method Detail

isCachingDisabled

public boolean isCachingDisabled()
Description copied from interface: CacheClient
Checks whether the caching is disabled.

Specified by:
isCachingDisabled in interface CacheClient
Returns:
true if the caching is disabled, true otherwise.

setCachingDisabled

public void setCachingDisabled(boolean flag)
Description copied from interface: CacheClient
Sets the caching disabled flag.

Specified by:
setCachingDisabled in interface CacheClient
Parameters:
flag - the caching disabled flag.

expireCached

public void expireCached(long timestamp)
Description copied from interface: CacheClient
Expires all cached entries notifying them about expiration.

Specified by:
expireCached in interface CacheClient
Parameters:
timestamp - the timestamp of the expiration.

expireFraction

public void expireFraction(long timestamp,
                           float fraction)
Description copied from interface: CacheClient
Expires the specified fraction of cached entries notifying them about expiration.

Specified by:
expireFraction in interface CacheClient
Parameters:
timestamp - the timestamp of the expiration.
fraction - the fraction of entries to expire (0.0..1.0).

clearCached

public void clearCached()
Description copied from interface: CacheClient
Clears all cached entries without notifying.

Specified by:
clearCached in interface CacheClient

getCache

public ConcurrentMap getCache(boolean create)
Description copied from interface: CacheClient
Gets and optionally creates the cache.

Specified by:
getCache in interface CacheClient
Parameters:
create - true to create a missing cache.
Returns:
the cache or null if disabled.

removeCache

public void removeCache()
Description copied from interface: CacheClient
Removes the cache.

Specified by:
removeCache in interface CacheClient

refresh

public void refresh()
Description copied from interface: Refreshable
Refreshes the MBean.

Specified by:
refresh in interface Refreshable

getRefreshed

public long getRefreshed()
Description copied from interface: Refreshable
Gets the last refresh timestamp.

Specified by:
getRefreshed in interface Refreshable
Returns:
the timestamp of the last refresh.

isScriptingEnabled

public boolean isScriptingEnabled()
Description copied from interface: TaskLoader
Checks whether scripting is enabled.

Specified by:
isScriptingEnabled in interface TaskLoader
Returns:
true, if the scripting is enabled.

setScriptingEnabled

public void setScriptingEnabled(boolean flag)
Description copied from interface: TaskLoader
Sets the scripting enabled flag.

Specified by:
setScriptingEnabled in interface TaskLoader
Parameters:
flag - the scripting enabled flag.

getPackageNames

public String[] getPackageNames()
Description copied from interface: TaskLoader
Gets package names in the task search list.

Specified by:
getPackageNames in interface TaskLoader
Returns:
an array of package names.

setPackageNames

public void setPackageNames(String[] pckages)
Description copied from interface: TaskLoader
Sets package names in the task search list.

Specified by:
setPackageNames in interface TaskLoader
Parameters:
pckages - an array of package names.

addPackageName

public void addPackageName(String pckage)
Description copied from interface: TaskLoader
Adds a package name to the task search list.

Specified by:
addPackageName in interface TaskLoader
Parameters:
pckage - the package name to add.

addPackageName

public void addPackageName(int index,
                           String pckage)
Description copied from interface: TaskLoader
Adds a package name to the specified location of the task search list.

Specified by:
addPackageName in interface TaskLoader
Parameters:
index - an index in the list.
pckage - the package name to add.

removePackageName

public void removePackageName(String pckage)
Description copied from interface: TaskLoader
Removes a package name from the task search list.

Specified by:
removePackageName in interface TaskLoader
Parameters:
pckage - the package name to remove.

clearPackageNames

public void clearPackageNames()
Description copied from interface: TaskLoader
Clears all package name from the task search list.

Specified by:
clearPackageNames in interface TaskLoader

initialize

public boolean initialize(String name,
                          ServletRequest request,
                          ServletResponse response,
                          FilterChain chain,
                          Object context)
Description copied from interface: TaskLoader
Initializes an instance of a task without execution. If caching is enabled, the initialized task is cached. If an initialized task is already in the cache, the method does nothing.

Specified by:
initialize in interface TaskLoader
Parameters:
name - the name of the task.
request - the request.
response - the response.
chain - the filter chain.
context - a task specific context.
Returns:
true if initialized, false if not found.

execute

public void execute(String name,
                    ServletRequest request,
                    ServletResponse response,
                    FilterChain chain,
                    Object context)
             throws ExecutionException,
                    InterruptedException
Description copied from interface: TaskLoader
Executes an instance of a task

Specified by:
execute in interface TaskLoader
Parameters:
name - the name of the task.
request - the request.
response - the response.
chain - the filter chain.
context - a task specific context.
Throws:
ExecutionException - for execution errors.
InterruptedException - if a task is interrupted.

load

protected Task load(String name,
                    ServletRequest request,
                    ServletResponse response,
                    FilterChain chain,
                    Object context)
Loads an instance of a task.

Parameters:
name - the name of the task.
request - the request.
response - the response.
chain - the filter chain.
context - a task specific context.
Returns:
the loaded task or null if not found.


Copyright © 2004 The Norther Organization. All rights reserved.