Tabnine Logo
CollectionCallback
Code IndexAdd Tabnine to your IDE (free)

How to use
CollectionCallback
in
sockslib.utils.mongo

Best Java code snippets using sockslib.utils.mongo.CollectionCallback (Showing top 4 results out of 315)

origin: theotherp/nzbhydra2

public <T> T execute(String collectionName, CollectionCallback<T> callback) {
  MongoDatabase database = null;
  if (mongoClient == null) {
    mongoClient = getConnectedClient();
  }
  return callback.doInCollection(
      mongoClient.getDatabase(databaseName).getCollection(collectionName));
}
origin: fengyouchao/sockslib

public <T> T execute(String collectionName, CollectionCallback<T> callback) {
 MongoDatabase database = null;
 if (mongoClient == null) {
  mongoClient = getConnectedClient();
 }
 return callback.doInCollection(
   mongoClient.getDatabase(databaseName).getCollection(collectionName));
}
origin: theotherp/nzbhydra2

/**
 * Connect MongoDB and call callback, close connection at last.
 *
 * @param collectionName Collection name.
 * @param callback       Callback
 * @param <T>            The type of value which you want to return.
 * @return The value which callback returned.
 */
public <T> T connect(String collectionName, CollectionCallback<T> callback) {
  MongoClient client = null;
  T t = null;
  try {
    client = getConnectedClient();
    MongoDatabase database = client.getDatabase(databaseName);
    MongoCollection<Document> collection = database.getCollection(collectionName);
    t = callback.doInCollection(collection);
  } finally {
    if (client != null) {
      client.close();
    }
  }
  return t;
}
origin: fengyouchao/sockslib

/**
 * Connect MongoDB and call callback, close connection at last.
 *
 * @param collectionName Collection name.
 * @param callback       Callback
 * @param <T>            The type of value which you want to return.
 * @return The value which callback returned.
 */
public <T> T connect(String collectionName, CollectionCallback<T> callback) {
 MongoClient client = null;
 T t = null;
 try {
  client = getConnectedClient();
  MongoDatabase database = client.getDatabase(databaseName);
  MongoCollection<Document> collection = database.getCollection(collectionName);
  t = callback.doInCollection(collection);
 } finally {
  if (client != null) {
   client.close();
  }
 }
 return t;
}
sockslib.utils.mongoCollectionCallback

Javadoc

The interface CollectionCallback is a callback for MongoDBUtil#execute(String,CollectionCallback).

Most used methods

  • doInCollection
    This method is a callback method.

Popular in Java

  • Start an intent from android
  • setScale (BigDecimal)
  • getSystemService (Context)
  • getExternalFilesDir (Context)
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now