org.apache.servicemix.store.mongo
Class MongoStore

java.lang.Object
  extended by org.apache.servicemix.store.mongo.MongoStore
All Implemented Interfaces:
Store

public class MongoStore
extends java.lang.Object
implements Store

A store which uses MongoDB.

Author:
iocanel, jbonofre

Field Summary
 
Fields inherited from interface org.apache.servicemix.store.Store
CLUSTERED, PERSISTENT, TRANSACTIONAL
 
Constructor Summary
MongoStore(com.mongodb.DB db, java.lang.String collectionName)
           Constructor with the Mongo DB and collection name to use.
MongoStore(com.mongodb.DB db, java.lang.String collectionName, java.lang.Long timeout)
           Constructor with the Mongo DB and collection name to use.
 
Method Summary
protected  void evict()
           Removes objects that have been expired.
 boolean hasFeature(java.lang.String feature)
           Returns true if feature is provided by the store, false else.
 java.lang.Object load(java.lang.String id)
           Retrieves the data of the object with the given .
 java.lang.Object peek(java.lang.String id)
           Retrieves the data of the object with the given without removing it.
 java.lang.String store(java.lang.Object data)
           Stores to a DBObject and return the generated ID.
 void store(java.lang.String id, java.lang.Object data)
           Stores to a DBObject with the given .
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MongoStore

public MongoStore(com.mongodb.DB db,
                  java.lang.String collectionName)

Constructor with the Mongo DB and collection name to use.

Parameters:
db - the Mongo DB.
collectionName - the Mongo collection name.

MongoStore

public MongoStore(com.mongodb.DB db,
                  java.lang.String collectionName,
                  java.lang.Long timeout)

Constructor with the Mongo DB and collection name to use. This constructor defines a connection timeout too.

Parameters:
db - the Mongo DB.
collectionName - the Mongo collection name.
timeout - the connection timeout.
Method Detail

hasFeature

public boolean hasFeature(java.lang.String feature)

Returns true if feature is provided by the store, false else.

Specified by:
hasFeature in interface Store
Parameters:
feature - the feature.
Returns:
true if the given feature is provided by the store, false else.

store

public void store(java.lang.String id,
                  java.lang.Object data)
           throws java.io.IOException

Stores to a DBObject with the given .

Specified by:
store in interface Store
Parameters:
id - the id of the object to store
data - the object to store
Throws:
java.io.IOException

store

public java.lang.String store(java.lang.Object data)
                       throws java.io.IOException

Stores to a DBObject and return the generated ID.

Specified by:
store in interface Store
Parameters:
data - the object to store
Returns:
the generated ID.
Throws:
java.io.IOException

load

public java.lang.Object load(java.lang.String id)
                      throws java.io.IOException

Retrieves the data of the object with the given .

Specified by:
load in interface Store
Parameters:
id - the id of the object
Returns:
the data object
Throws:
java.io.IOException

peek

public java.lang.Object peek(java.lang.String id)
                      throws java.io.IOException

Retrieves the data of the object with the given without removing it.

Specified by:
peek in interface Store
Parameters:
id - the id of the object
Returns:
the data object
Throws:
java.io.IOException

evict

protected void evict()

Removes objects that have been expired.



Copyright © 2005-2011 FuseSource. All Rights Reserved.