Repository

Crear los repository:

  • ColorRepository.java

  • BodegaRepository.java

  • PaisRepository.java

BodegaRepository.java

import javax.ejb.Stateless;
import javax.ejb.EJB;
import com.avbravo.ejbjmoordb.mongodb.repository.Repository;
import com.avbravo.microtestingejb.entity.Bodega;
import com.avbravo.microtestingejb.provider.MongoClientProvider;
import com.mongodb.MongoClient;
/**
*
* @author avbravo
*/
@Stateless
public class BodegaRepository extends Repository<Bodega> {
@EJB
MongoClientProvider mongoClientProvider;
@Override
protected MongoClient getMongoClient() {
return mongoClientProvider.getMongoClient();
}
public BodegaRepository(){
super(Bodega.class,"microtesting","bodega");
}
}

ColorRepository.Java

import com.avbravo.ejbjmoordb.mongodb.repository.Repository;
import com.avbravo.microtestingejb.entity.Color;
import com.avbravo.microtestingejb.provider.MongoClientProvider;
import com.mongodb.MongoClient;
import javax.ejb.EJB;
import javax.ejb.Stateless;
/**
*
* @author avbravo
*/
@Stateless
public class ColorRepository extends Repository<Color> {
@EJB
MongoClientProvider mongoClientProvider;
public ColorRepository() {
super(Color.class, "microtesting", "color");
}
@Override
protected MongoClient getMongoClient() {
return mongoClientProvider.getMongoClient();
}
}

PaisRepository.java

import javax.ejb.Stateless;
import javax.ejb.EJB;
import com.avbravo.ejbjmoordb.mongodb.repository.Repository;
import com.avbravo.microtestingejb.entity.Pais;
import com.avbravo.microtestingejb.provider.MongoClientProvider;
import com.mongodb.MongoClient;
/**
*
* @author avbravo
*/
@Stateless
public class PaisRepository extends Repository<Pais> {
@EJB
MongoClientProvider mongoClientProvider;
@Override
protected MongoClient getMongoClient() {
return mongoClientProvider.getMongoClient();
}
public PaisRepository(){
super(Pais.class,"microtesting","pais");
}
}