## org.jrobin.core
Class RrdOpener

    java.lang.Object
      org.jrobin.core.RrdOpener

Direct Known Subclasses:
  RrdGraph

public class RrdOpener
extends java.lang.Object

Class that represents an object that can be used to perform the actual opening and closing of RRD files, using different methods. Other objects like the FetchSourceList representing the Graph datasources (`FetchSourceList`) use a RrdOpener to retrieve the RrdDb instances of RRD datasources.

Overriding the RrdOpener class allows finetuned access on the level of RrdDb retrieval and release. An child class could for example add log or debug statements, gather statistics on RRD access, or provide a transparent way to to access RRD datasources in an alternative way like through a DBMS.

Field Summary
`protected RrdDbPool` `pool`
`protected boolean` `readOnly`
`protected boolean` `usePool`

Constructor Summary
`RrdOpener(boolean usePool)` Creates a new RrdOpener that will open RrdDb objects with read/write access.
`RrdOpener(boolean usePool, boolean readOnly)` Creates a new RrdOpener that will open RrdDb objects with read/write or read-only access, depending on the readOnly flag..

Method Summary
`RrdDb` `getRrd(java.lang.String rrdFile, RrdBackendFactory backendFactory)` Retrieves the RrdDb instance matching a specific RRD datasource name (usually a file name) and using a specified RrdBackendFactory.
`void` `releaseRrd(RrdDb rrdDb)` Releases an RrdDb instance.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### pool

    protected RrdDbPool pool

### readOnly

    protected boolean readOnly

### usePool

    protected boolean usePool

Constructor Detail

### RrdOpener

    public RrdOpener(boolean usePool)

  Creates a new RrdOpener that will open RrdDb objects with read/write access. If the usePool flag is set, the RrdOpener will use the RrdDbPool to retrieve RrdDb instances.

Parameters:
  `usePool` - True if the RrdOpener should use the RrdDbPool.

### RrdOpener

    public RrdOpener(boolean usePool,
                     boolean readOnly)

  Creates a new RrdOpener that will open RrdDb objects with read/write or read-only access, depending on the readOnly flag.. If the usePool flag is set, the RrdOpener will use the RrdDbPool to retrieve RrdDb instances.

Parameters:
  `usePool` - True if the RrdOpener should use the RrdDbPool.
  `readOnly` - True if the RrdOpener should open RrdDb objects as read-only.

Method Detail

### getRrd

    public RrdDb getRrd(java.lang.String rrdFile,
                        RrdBackendFactory backendFactory)
                 throws java.io.IOException,
                        RrdException

  Retrieves the RrdDb instance matching a specific RRD datasource name (usually a file name) and using a specified RrdBackendFactory.

  Parameters:
    `rrdFile` - Name of the RRD datasource.
    `backendFactory` - BackendFactory to use for retrieval.
  Returns:
    RrdDb instance of the datasource.
  Throws:
    `java.io.IOException` - Thrown in case of I/O error.
    `RrdException` - Thrown in case of a JRobin specific error.

### releaseRrd

    public void releaseRrd(RrdDb rrdDb)
                    throws java.io.IOException,
                           RrdException

  Releases an RrdDb instance. Depending on the settings of the RrdOpener, this either closes the RrdDb, or releases it back into the RrdDbPool.

  Parameters:
    `rrdDb` - RrdDb object that should be released.
  Throws:
    `java.io.IOException` - Thrown in case of I/O error.
    `RrdException` - Thrown in case of a JRobin specific error.