1 25 package org.jrobin.core; 26 27 import java.io.IOException ; 28 29 43 public class RrdOpener 44 { 45 protected RrdDbPool pool; 49 50 protected boolean readOnly = false; 51 protected boolean usePool = false; 52 53 54 63 public RrdOpener( boolean usePool ) 64 { 65 this.usePool = usePool; 66 67 if ( usePool ) 68 pool = RrdDbPool.getInstance(); 69 } 70 71 79 public RrdOpener( boolean usePool, boolean readOnly ) 80 { 81 this( usePool ); 82 this.readOnly = readOnly; 83 } 84 85 86 99 public RrdDb getRrd( String rrdFile, RrdBackendFactory backendFactory ) throws IOException , RrdException 100 { 101 if ( pool != null ) 102 return pool.requestRrdDb( rrdFile ); 103 else 104 return new RrdDb( rrdFile, readOnly, backendFactory ); 105 } 106 107 114 public void releaseRrd(RrdDb rrdDb) throws IOException , RrdException 115 { 116 if ( pool != null ) 117 pool.release(rrdDb); 118 else 119 rrdDb.close(); 120 } 121 } 122 | Popular Tags |