Package java.util

Examples of java.util.Timer$TimerImpl$TimerTree


    return new FlatXmlDataSet(TestCrawlRssFeed.class
        .getResourceAsStream("/TestCrawlRssFeed-input.xml"));
  }

  public void testRun() throws Exception{
    Timer timer = new Timer();
    timer.schedule(crawlRssFeed,0);
    crawlRssFeed.awaitAndShutdown(60,TimeUnit.SECONDS);
       
    Folder folder66 = folderManager.getUserFolder(new User(2), "latest news");
    Folder folder67 = folderManager.getUserFolder(new User(2), "news2");
    assertTrue(folder66.getSize()>0);
View Full Code Here


  /**
   * Starts to update the values with the previously set period. Default is 1 second.
   */
  public void start() {
    if (isRunning()) return;
    timer = new Timer(true); // do not block the application on exit
    timer.scheduleAtFixedRate(new TimerTask() {
      public void run() {
        try {
          step();
        } catch (DataException e) {
View Full Code Here

    permanentBans = new LinkedList<InetAddressMask>();
    temporalBans = Collections.synchronizedList(new LinkedList<InetAddressMask>());

    /* read ban list from configuration */
    loadBannedIPNetworkListFromDB();
    timer = new Timer();
  }
View Full Code Here

     * Sets up a timer to check for hangs frequently.
     */
    private void initTimer() {
        final long initialDelayMs = 0;
        final boolean isDaemon = true;
        Timer timer = new Timer("EventDispatchThreadHangMonitor", isDaemon);
        timer.schedule(new HangChecker(), initialDelayMs, CHECK_INTERVAL_MS);
    }
View Full Code Here

     * Creates a timer for use by the Resource Adapter.
     * @return Timer object
     * @throws UnavailableException if a Timer instance is unavailable
     */
    public Timer createTimer() throws UnavailableException {
        return new Timer(true);
    }
View Full Code Here

      {
         return;
      }
     
      //Needs to be daemon
      timer = new Timer(true);
     
      //Add a random delay to prevent all timers starting at once
      long delay = (long)(period * Math.random());
     
      task = new SendStatsTimerTask();
View Full Code Here

     *
     * @see java.lang.Thread#run()
     */
    public void run()
    {
        Timer timer = null;

        this._readpool = ThreadPoolFactory.createFixedThreadPool( this._serverInfo.getMaxReadProcessors(),
                                                                  this._readGroup );
        // create a global ThreadPool for network write operations
        this._writePool = ThreadPoolFactory.createFixedThreadPool( this._serverInfo.getMaxWriteProcessors(),
                                                                   this._writeGroup );

        // shall we monitor the ThreadPools and resize them
        // according to server load (this will also recreate died worker
        // threads)
        if ( this._serverInfo.isAutomaticThreadPoolResize() )
        {
            timer = new Timer();

            // schedule a monitor task for the read-process-thread-pool
            timer.schedule( new ThreadPoolResizer( this._readpool, this._serverInfo.getMaxReadProcessors(),
                                                   EJConstants.EJOE_POOL_RESIZER_SHRINKWAIT ), this._serverInfo
                    .getPoolResizePeriod(), this._serverInfo.getPoolResizePeriod() );
            // schedule a monitor task for the writer-thread-pool
            timer.schedule( new ThreadPoolResizer( this._writePool, this._serverInfo.getMaxWriteProcessors(),
                                                   EJConstants.EJOE_POOL_RESIZER_SHRINKWAIT ), this._serverInfo
                    .getPoolResizePeriod(), this._serverInfo.getPoolResizePeriod() );
        }

        try
        {
            Iterator it;
            SocketChannel cChannel;
            SelectionKey selKey;
            ConnectionHeader clientInfo;
            Set keys;

            while ( !isInterrupted() )
            {
                this._load = 0;

                // (pre)register interested socket channels
                registerAspirants();

                // just try endless new selects until there are interested
                // socket channels
                if ( _selector.select() == 0 ) continue;

                keys = this._selector.selectedKeys();
                this._load = keys.size();
                it = this._selector.selectedKeys().iterator();

                // loop over all selected channels, just take care of thread
                // interruption
                while ( it.hasNext() && !isInterrupted() )
                {
                    selKey = (SelectionKey) it.next();
                    // remove the SelectionKey from the Iterator otherwise it
                    // will be lost
                    it.remove();

                    try
                    {
                        // validate the key
                        if ( !selKey.isValid() ) continue;

                        // at least our ConnectionAcceptor has created a client
                        // ConnectionHeader
                        clientInfo = (ConnectionHeader) selKey.attachment();

                        // first check read-availbility
                        if ( selKey.isReadable() )
                        {
                            // get the underlying socket channel
                            cChannel = (SocketChannel) selKey.channel();
                            // cancel the channels registration with our
                            // Selector
                            selKey.cancel();

                            // little bit paranoia
                            if ( cChannel != null && cChannel.isOpen() )
                            {
                                // don't we support NIO?
                                if ( !this._serverInfo.hasNonBlockingReadWrite() )
                                {
                                    logger.log( Level.FINEST,
                                                "Setting socket to blocking mode for further io operations..." );

                                    // prepare the channel for upcoming blocking
                                    // network operations
                                    cChannel.configureBlocking( true );
                                }

                                // schedule a asynchronious read-process operation
                                this._readpool.invokeLater( new ConnectionReader( this, this._serverInfo, clientInfo ) );
                            }
                        }
                        else if ( selKey.isWritable() )
                        {
                            // get the underlying socket channel
                            cChannel = (SocketChannel) selKey.channel();
                            // cancel the channels registration with our
                            // Selector
                            selKey.cancel();

                            // little bit paranoia
                            if ( cChannel != null && cChannel.isOpen() )
                            {
                                // don't we support NIO?
                                if ( !this._serverInfo.hasNonBlockingReadWrite() )
                                {
                                    if ( !clientInfo.hasAttachment() ) continue;
                                    // prepare the channel for upcoming blocking
                                    // network operations
                                    cChannel.configureBlocking( true );
                                }

                                // schedule a asynchronious socket-write
                                // operation
                                this._writePool
                                        .invokeLater( new ConnectionWriter( this, this._serverInfo, clientInfo ) );
                            }
                        }
                    }
                    catch ( CancelledKeyException cke )
                    {
                        logger.log( Level.WARNING, "Key cancelled!", cke );
                    }
                    finally
                    {
                        this._load--;
                    }
                }
            }
        }
        catch ( IOException e )
        {
            logger.log( Level.SEVERE, "!!! IOException occured !!! ", e );
            throw new RuntimeException( e );
        }
        finally
        {
            // kill our ThreadPool monitors if existent
            if ( timer != null ) timer.cancel();

            try
            {
                // shutdown the Read-Process-ThreadPool if existent
                if ( this._readpool != null )
View Full Code Here

  public void initialize() {
    // No operation.
  }

  public void startService(){
    mTimer = new Timer();
    mTimer.schedule(this, 200, 1000);
    mLog.info("Pulse service started");
//    addEverySecondListener(this);
//    addCustomTimeListener(this);   
  }
View Full Code Here

  private TimerTask monitorPathTask;
  private StatusUpdateTask statusUpdateTask;
 
  public NotificationTimer()
  {
    timer = new Timer();
  }
View Full Code Here

        addMouseListener(new MouseAdapter()
        {
            TimerTask timerTask;
            public void mousePressed(MouseEvent mouseevent)
            {
                Timer timer = new Timer();
                timerTask = new TimerTask()
                {
                    public void run()
                    {
                        showSliderMenu();
                    }
                };

                timer.schedule(timerTask, 1000);
            }

            public void mouseReleased(MouseEvent mouseevent)
            {
                if (!sliderMenuVisible)
View Full Code Here

TOP

Related Classes of java.util.Timer$TimerImpl$TimerTree

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.