org.apache.sling.nosql.generic.adapter

## Class MetricsNoSqlAdapterWrapper

- java.lang.Object
- - org.apache.sling.nosql.generic.adapter.MetricsNoSqlAdapterWrapper

All Implemented Interfaces:
  NoSqlAdapter

    public final class MetricsNoSqlAdapterWrapper
    extends Object
    implements NoSqlAdapter

Wrapper for `NoSqlAdapter` that enables logging and time counting for each call.

### Constructor Summary

Constructors
Constructor and Description
`MetricsNoSqlAdapterWrapper(NoSqlAdapter delegate, org.slf4j.Logger logger)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `checkConnection()` Checks whether the connection to the NoSQL database is possible
`void` `createIndexDefinitions()` Creates index definitions for accessing the NoSQL database.
`boolean` `deleteRecursive(String path)` Remove data including all path-related children from NoSQL database.
`NoSqlData` `get(String path)` Get data for a single resource from NoSQL database.
`Iterator<NoSqlData>` `getChildren(String parentPath)` Get data for all children of a resource from NoSQL database.
`Iterator<NoSqlData>` `query(String query, String language)` Query for data.
`boolean` `store(NoSqlData data)` Store data with the given path in NoSQL database.
`boolean` `validPath(String path)` True if the given path is valid and supported by the NoSQL database.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### MetricsNoSqlAdapterWrapper

    public MetricsNoSqlAdapterWrapper(NoSqlAdapter delegate,
                                      org.slf4j.Logger logger)

### Method Detail

#### validPath

    public boolean validPath(String path)

Description copied from interface: `NoSqlAdapter`
True if the given path is valid and supported by the NoSQL database.

Specified by:
  `validPath` in interface `NoSqlAdapter`
Parameters:
  `path` - Path
Returns:
  true if valid, false if invalid

#### get

    public NoSqlData get(String path)

Description copied from interface: `NoSqlAdapter`
Get data for a single resource from NoSQL database.

Specified by:
  `get` in interface `NoSqlAdapter`
Parameters:
  `path` - Path
Returns:
  Data or null if non exists

#### getChildren

    public Iterator<NoSqlData> getChildren(String parentPath)

Description copied from interface: `NoSqlAdapter`
Get data for all children of a resource from NoSQL database.

Specified by:
  `getChildren` in interface `NoSqlAdapter`
Parameters:
  `parentPath` - Parent path
Returns:
  List if child data or empty iterator

#### store

    public boolean store(NoSqlData data)

Description copied from interface: `NoSqlAdapter`
Store data with the given path in NoSQL database. It is guaranteed that the map of the NoSqlData object does only contain primitive value types String, Integer, Long, Double, Boolean or arrays of them.

Specified by:
  `store` in interface `NoSqlAdapter`
Parameters:
  `data` - Data with path
Returns:
  true if a new entry was created, false if an existing was overridden.

#### deleteRecursive

    public boolean deleteRecursive(String path)

Description copied from interface: `NoSqlAdapter`
Remove data including all path-related children from NoSQL database.

Specified by:
  `deleteRecursive` in interface `NoSqlAdapter`
Parameters:
  `path` - Path to remove
Returns:
  true if anything was removed

#### query

    public Iterator<NoSqlData> query(String query,
                                     String language)

Description copied from interface: `NoSqlAdapter`
Query for data.

Specified by:
  `query` in interface `NoSqlAdapter`
Parameters:
  `query` - Query
  `language` - Query language
Returns:
  Query result or null if query not supported

#### checkConnection

    public void checkConnection()
                         throws org.apache.sling.api.resource.LoginException

Description copied from interface: `NoSqlAdapter`
Checks whether the connection to the NoSQL database is possible

Specified by:
  `checkConnection` in interface `NoSqlAdapter`
Throws:
  `org.apache.sling.api.resource.LoginException` - in case of any errors

#### createIndexDefinitions

    public void createIndexDefinitions()

Description copied from interface: `NoSqlAdapter`
Creates index definitions for accessing the NoSQL database. This is called every time an adapter instances is created. If the indexes are already present it should do nothing. It is only called when the `NoSqlAdapter.checkConnection()` call succeeds.

Specified by:
  `createIndexDefinitions` in interface `NoSqlAdapter`