View Javadoc

1   /*
2    * Copyright (C) The DNA Group. All rights reserved.
3    *
4    * This software is published under the terms of the DNA
5    * Software License version 1.1, a copy of which has been included
6    * with this distribution in the LICENSE.txt file.
7    */
8   package org.codehaus.dna;
9   
10  /***
11   * Utility class to signal to the container that
12   * a resource is no longer going to be used by
13   * the component.
14   *
15   * @version $Revision: 1.2 $ $Date: 2004/05/01 09:51:48 $
16   */
17  public class ReleaseUtil
18  {
19      /***
20       * Utility interface used to mark resources that
21       * can be released. Developers should never directly
22       * reference this class and never make a component
23       * implement this interface. Instead the container
24       * will choose to have the proxys of component implement
25       * the interface.
26       */
27      public interface Releaseable
28      {
29          /***
30           * Indicate to the container that component no
31           * longer needs resources.
32           */
33          void release();
34      }
35  
36      /***
37       * The component invokes this method to indicate to
38       * the container that it no longer needs specified
39       * resource.
40       *
41       * @param object the resource
42       */
43      public static void release( final Object object )
44      {
45          if( object instanceof Releaseable )
46          {
47              ( (Releaseable)object ).release();
48          }
49      }
50  }