org.norther.tammi.core.thread
Class DefaultSchedulable

java.lang.Object
  extended by org.norther.tammi.core.base.Adaptee
      extended by org.norther.tammi.core.thread.DefaultSchedulable
All Implemented Interfaces:
Serializable, Runnable, EventListener, NotificationBroadcaster, NotificationEmitter, NotificationListener, Manageable, MBeanDelegate, Startable, Schedulable

public class DefaultSchedulable
extends Adaptee
implements Schedulable, NotificationListener

A default implementation of Schedulable.

Version:
$Id: DefaultSchedulable.java,v 1.7 2009/09/28 15:08:43 cvsimp Exp $
Author:
Ilkka Priha
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.norther.tammi.core.base.Adaptee
ADAPTEE_NOTIF_DESCRIPTION, ADAPTEE_NOTIFICATIONS
 
Constructor Summary
DefaultSchedulable()
          Constructs a new schedulable.
DefaultSchedulable(boolean multiple)
          Constructs a new schedulable for multiple threads.
DefaultSchedulable(Runnable adaptee)
          Constructs a new schedulable adapter.
DefaultSchedulable(Runnable adaptee, boolean multiple)
          Constructs a new schedulable adapter for multiple threads.
 
Method Summary
 long getDelay()
          Gets the starting delay.
 long getPeriod()
          Gets the execution period.
 ObjectName getSchedulerName()
          Gets the the scheduler of the schedulable.
 void handleNotification(Notification notif, Object handback)
          Handles notifications from the scheduler.
 boolean isStarted()
          Checks whether the startable has been started.
 void postmanaged()
          This method is called when the implementing adaptee has been managed either during post-registration of the corresponding adapter MBean or just after it is explicitly added to the adapter MBean during run-time.
 void run()
           
 void setDelay(long delay)
          Sets the starting delay between start method invocation and actual execution.
 void setPeriod(long period)
          Sets the execution period.
 void setSchedulerName(ObjectName scheduler)
          Sets the scheduler of the schedulable.
 void setTime(long time)
          Sets the starting time of the first execution.
 void start()
          Starts the MBean.
 void stop()
          Stops the MBean.
 void unmanaged()
          This method is called when the implementing adaptee is unmanaged either during pre-deregistration of the corresponding adapter MBean or just before it is explicitly removed from the adapter MBean during run-time.
 
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, premanaged, removeNotificationListener, removeNotificationListener, sendNotification, sendNotification, sendNotification, sendNotification, unregister
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultSchedulable

public DefaultSchedulable()
Constructs a new schedulable.


DefaultSchedulable

public DefaultSchedulable(boolean multiple)
Constructs a new schedulable for multiple threads.

Parameters:
multiple - true to allow more than one threads.

DefaultSchedulable

public DefaultSchedulable(Runnable adaptee)
Constructs a new schedulable adapter.

Parameters:
adaptee - the adaptee.

DefaultSchedulable

public DefaultSchedulable(Runnable adaptee,
                          boolean multiple)
Constructs a new schedulable adapter for multiple threads.

Parameters:
adaptee - the adaptee.
multiple - true to allow more than one threads.
Method Detail

postmanaged

public void postmanaged()
Description copied from interface: Manageable
This method is called when the implementing adaptee has been managed either during post-registration of the corresponding adapter MBean or just after it is explicitly added to the adapter MBean during run-time.

Specified by:
postmanaged in interface Manageable
Overrides:
postmanaged in class Adaptee

unmanaged

public void unmanaged()
               throws Exception
Description copied from interface: Manageable
This method is called when the implementing adaptee is unmanaged either during pre-deregistration of the corresponding adapter MBean or just before it is explicitly removed from the adapter MBean during run-time.

Specified by:
unmanaged in interface Manageable
Overrides:
unmanaged in class Adaptee
Throws:
Exception - if the adaptee refused to be unmanaged.

getSchedulerName

public ObjectName getSchedulerName()
Description copied from interface: Schedulable
Gets the the scheduler of the schedulable.

Specified by:
getSchedulerName in interface Schedulable
Returns:
the object name of the scheduler or a query.

setSchedulerName

public void setSchedulerName(ObjectName scheduler)
Description copied from interface: Schedulable
Sets the scheduler of the schedulable. If it is not set, the default one will be used.

Note that it will be taken into use after next start.

Specified by:
setSchedulerName in interface Schedulable
Parameters:
scheduler - the object name of the scheduler or a query.

getPeriod

public long getPeriod()
Description copied from interface: Schedulable
Gets the execution period.

Specified by:
getPeriod in interface Schedulable
Returns:
the execution period in msecs.

setPeriod

public void setPeriod(long period)
Description copied from interface: Schedulable
Sets the execution period.

Note that it will be taken into use after next start.

Specified by:
setPeriod in interface Schedulable
Parameters:
period - the execution period in msecs.

getDelay

public long getDelay()
Description copied from interface: Schedulable
Gets the starting delay.

Specified by:
getDelay in interface Schedulable
Returns:
the starting delay in msecs.

setDelay

public void setDelay(long delay)
Description copied from interface: Schedulable
Sets the starting delay between start method invocation and actual execution.

Specified by:
setDelay in interface Schedulable
Parameters:
delay - the starting delay in msecs.

setTime

public void setTime(long time)
Description copied from interface: Schedulable
Sets the starting time of the first execution.

Specified by:
setTime in interface Schedulable
Parameters:
time - the starting time in msecs.

isStarted

public boolean isStarted()
Description copied from interface: Startable
Checks whether the startable has been started.

Specified by:
isStarted in interface Startable
Returns:
true if started, otherwise false.

start

public void start()
           throws Exception
Description copied from interface: Startable
Starts the MBean.

Specified by:
start in interface Startable
Throws:
Exception - if start fails.

stop

public void stop()
Description copied from interface: Startable
Stops the MBean.

Specified by:
stop in interface Startable

run

public void run()
Specified by:
run in interface Runnable

handleNotification

public void handleNotification(Notification notif,
                               Object handback)
Handles notifications from the scheduler.

Specified by:
handleNotification in interface NotificationListener
Parameters:
notif - the notification.
handback - not used.


Copyright © 2004 The Norther Organization. All rights reserved.