FileDocCategorySizeDatePackage
Listener.javaAPI DocExample2513Thu May 23 09:32:50 BST 2002 sample.timer

Listener

public class Listener extends Object implements NotificationListener

Fields Summary
private boolean
_traceOn
MessageLog
_logger
Constructors Summary
public Listener()
Creates new Listener


        
       
    
Methods Summary
public voidhandleNotification(javax.management.Notification notification, java.lang.Object obj)

        String type = notification.getType();
        if (notification instanceof TimerNotification) {
            TimerNotification notif = (TimerNotification)notification;
            if (type.equals(Controller.CONTROLLER_START)) {
                Properties props = (Properties)notif.getUserData();
                final String cwf = (String)props.getProperty("controller.consumer.workFactor");
                final String swf = (String)props.getProperty("controller.supplier.workFactor");
                trace("Listener.handleNotification(): INFO: " + "Controller starting at "
                        + new Date() + ", parameters = {" + cwf + ", " + swf
                        + "}");
                //
                // Start the controller on a thread other than the
                /// one in the timer that is invoking this method.
                /// Otherwise no other notifications can be sent
                /// because of the join() calls inside the controller.
                //
                Thread t = new Thread(new Runnable() {

                    /**
                     * put your documentation comment here
                     */
                    public void run () {
                        Controller.main(new String[] {
                            cwf, swf
                        });
                    }
                });
                t.start();
            }
        }
    
private booleanisTraceOn()

        return  _traceOn;
    
private voidtrace(java.lang.String message)

        if (isTraceOn()) {
            System.out.println(message);
        }
        traceLog(message);
    
private voidtrace(java.lang.Throwable t)

        traceLog(t);
    
private voidtraceLog(java.lang.Throwable t)

        if (isTraceOn()) {
            _logger.write(t);
        }
    
private voidtraceLog(java.lang.String message)


         
        if (isTraceOn()) {
            _logger.write(message);
        }