public void injectMembers(T instance) {
    try {
      String collectionName = this.collectionName;
      Jongo jongo = provider.get().get();
      MongoCollection collection = jongo.getCollection(collectionName);

      field.set(instance, collection);
    } catch (IllegalAccessException e) {
      throw new RuntimeException(e);
    }
  }
Exemplo n.º 2
0
  @Override
  public void start(Stage stage) throws Exception {

    Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));
    Scene scene = new Scene(root);

    stage.setScene(scene);
    stage.show();

    try {
      DB db = new MongoClient("localhost", 27017).getDB("UchCentre");

      Jongo jongo = new Jongo(db);

      MongoCollection studentss = jongo.getCollection("students");
      System.out.println("Найдено объектов: " + studentss.count());

      MongoCursor<Student> all = studentss.find("{}").as(Student.class);
      Student one = studentss.findOne("{name: 'Nurbek'}").as(Student.class);

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 3
0
 /**
  * returns jongo collection used by this state factory.
  *
  * @return the collection
  */
 public MongoCollection getCollection() {
   return jongo.getCollection(collectionName);
 }
Exemplo n.º 4
0
 public MongoCollection GetMongoCollection(String dbType, String collection) {
   MongoDBConfig config = ConnectToMongoDB(dbType);
   MongoDBManager dbManager = new MongoDBManager(config);
   Jongo jongo = new Jongo(dbManager.db);
   return jongo.getCollection(collection);
 }