Class Sweeper

  • All Implemented Interfaces:
    Runnable, LifeCycle

    public class Sweeper
    extends AbstractLifeCycle
    implements Runnable
    The Eclipse Jetty and Apache Felix Http Jetty packages are no longer supported.

    A utility class to perform periodic sweeping of resources.

    Sweeper.Sweepable resources may be added to or removed from a Sweeper and the resource implementation decides whether it should be swept or not.

    If a Sweeper.Sweepable resources is itself a container of other sweepable resources, it will forward the sweep operation to children resources, and so on recursively.

    Typical usage is to add Sweeper as a bean to an existing container:

      Server server = new Server();
      server.addBean(new Sweeper(), true);
    Code that knows it has sweepable resources can then lookup the Sweeper and offer the sweepable resources to it:
      class MyComponent implements Sweeper.Sweepable
          private final long creation;
          private volatile destroyed;
          MyComponent(Server server)
              this.creation = System.nanoTime();
              Sweeper sweeper = server.getBean(Sweeper.class);
          void destroy()
              destroyed = true;
          public boolean sweep()
              return destroyed;
    • Constructor Detail

      • Sweeper

        public Sweeper​(Scheduler scheduler,
                       long period)
    • Method Detail

      • getSize

        public int getSize()
      • run

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