當前位置: 首頁>>代碼示例>>Java>>正文


Java Morphia.mapPackage方法代碼示例

本文整理匯總了Java中org.mongodb.morphia.Morphia.mapPackage方法的典型用法代碼示例。如果您正苦於以下問題:Java Morphia.mapPackage方法的具體用法?Java Morphia.mapPackage怎麽用?Java Morphia.mapPackage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.mongodb.morphia.Morphia的用法示例。


在下文中一共展示了Morphia.mapPackage方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getDatastore

import org.mongodb.morphia.Morphia; //導入方法依賴的package包/類
public static synchronized  Datastore getDatastore() {
    if (Objects.isNull(datastore)) {
        Morphia morphia = new Morphia();
        morphia.mapPackage("com.ftt.elastic.match.beans");
        MongoClient mongoClient = new MongoClient(PropertiesRepo.get(Constants.Settings.MONGODB_HOST), PropertiesRepo.getInt(Constants.Settings.MONGODB_PORT));
        datastore = morphia.createDatastore(mongoClient, PropertiesRepo.get(Constants.Settings.MONGODB_SCHEMANAME));
    }
    return datastore;
}
 
開發者ID:nimesh-mittal,項目名稱:elastic-match,代碼行數:10,代碼來源:ConnectionFactory.java

示例2: MongoDbDao

import org.mongodb.morphia.Morphia; //導入方法依賴的package包/類
private MongoDbDao() {
    Morphia morphia = new Morphia();
    morphia.mapPackage("models");
    datastore = morphia.createDatastore(new MongoClient(MongoDbSetting.MONGODB_HOST,
            MongoDbSetting.MONGODB_PORT), MongoDbSetting.MONGODB_DB_NAME_SESSION);
    datastore.ensureIndexes();
}
 
開發者ID:shuza,項目名稱:Simple-RestFull-API,代碼行數:8,代碼來源:MongoDbDao.java

示例3: build

import org.mongodb.morphia.Morphia; //導入方法依賴的package包/類
public MongoDatastore build() {
    
    if(mongoClient == null)
        throw new IllegalArgumentException("Mongo client must not be null.");
    
    final Morphia morphia = new Morphia();
    morphia.mapPackage("com.crtomirmajer.wiki2mongo");
    datastore = (AdvancedDatastore) morphia.createDatastore(mongoClient, database);
    
    return new MongoDatastore(this);
}
 
開發者ID:crtomirmajer,項目名稱:wiki2mongo,代碼行數:12,代碼來源:MongoDatastore.java

示例4: shouldCreateNewObjectInEmbeddedMongoDb

import org.mongodb.morphia.Morphia; //導入方法依賴的package包/類
public void shouldCreateNewObjectInEmbeddedMongoDb() throws IOException {
    Morphia morphia = new Morphia();
    morphia.mapPackage("com.ftt.elastic.match.beans");
    MongoClient mongoClient = new MongoClient(host, port);
    Datastore datastore = morphia.createDatastore(mongoClient, DATABASE_NAME);

    EntityDAO<ARecord> entityDAO = new EntityDAO(datastore, ARecord.class);
    ARecord record = new ARecord();
    record.setDisplayId("myrecord");
    String id = (String) entityDAO.create(record);

    ARecord recordActual = entityDAO.getOne(id);
    Assert.assertEquals(recordActual.getDisplayId(), record.getDisplayId());
}
 
開發者ID:nimesh-mittal,項目名稱:elastic-match,代碼行數:15,代碼來源:EntityDaoTest.java

示例5: setUp

import org.mongodb.morphia.Morphia; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception
{
  Morphia morphia = new Morphia();
  morphia = morphia.mapPackage("es.um.nosql.schemainference.test2");
  new ValidationExtension(morphia);
  dbName = "test2";
  client = MongoDbAdapter.getMongoDbClient("localhost");
  datastore = morphia.createDatastore(client, dbName);
  datastore.ensureIndexes();
  validator = Validation.buildDefaultValidatorFactory().getValidator();
  //client.cleanDb(dbName);
}
 
開發者ID:catedrasaes-umu,項目名稱:NoSQLDataEngineering,代碼行數:14,代碼來源:MorphiaTestConfig.java

示例6: setUp

import org.mongodb.morphia.Morphia; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception
{
  Morphia morphia = new Morphia();
  morphia = morphia.mapPackage("es.um.nosql.schemainference.everypolitician");
  new ValidationExtension(morphia);
  dbName = "everypolitician";
  client = MongoDbAdapter.getMongoDbClient("localhost");
  datastore = morphia.createDatastore(client, dbName);
  validator = Validation.buildDefaultValidatorFactory().getValidator();
  newDbName = "neweverypolitician";
  newDatastore = morphia.createDatastore(client,  newDbName);
}
 
開發者ID:catedrasaes-umu,項目名稱:NoSQLDataEngineering,代碼行數:14,代碼來源:MorphiaEveryPolCloneTest.java

示例7: setUp

import org.mongodb.morphia.Morphia; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception
{
  Morphia morphia = new Morphia();
  morphia = morphia.mapPackage("es.um.nosql.schemainference.mongoMovies3");
  new ValidationExtension(morphia);
  dbName = "mongoMovies3";
  client = MongoDbAdapter.getMongoDbClient("localhost");
  datastore = morphia.createDatastore(client, dbName);
  validator = Validation.buildDefaultValidatorFactory().getValidator();
}
 
開發者ID:catedrasaes-umu,項目名稱:NoSQLDataEngineering,代碼行數:12,代碼來源:MorphiaMoviesValidationTest.java

示例8: setUp

import org.mongodb.morphia.Morphia; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception
{
  Morphia morphia = new Morphia();
  morphia = morphia.mapPackage("es.um.nosql.schemainference.opensanctions");
  new ValidationExtension(morphia);
  dbName = "opensanctions";
  client = MongoDbAdapter.getMongoDbClient("localhost");
  datastore = morphia.createDatastore(client, dbName);
  validator = Validation.buildDefaultValidatorFactory().getValidator();
  newDbName = "newopensanctions";
  newDatastore = morphia.createDatastore(client,  newDbName);
}
 
開發者ID:catedrasaes-umu,項目名稱:NoSQLDataEngineering,代碼行數:14,代碼來源:MorphiaOpenSanctionsCloneTest.java

示例9: setUp

import org.mongodb.morphia.Morphia; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception
{
  Morphia morphia = new Morphia();
  morphia = morphia.mapPackage("es.um.nosql.schemainference.everypolitician");
  new ValidationExtension(morphia);
  dbName = "everypolitician";
  client = MongoDbAdapter.getMongoDbClient("localhost");
  datastore = morphia.createDatastore(client, dbName);
  validator = Validation.buildDefaultValidatorFactory().getValidator();
}
 
開發者ID:catedrasaes-umu,項目名稱:NoSQLDataEngineering,代碼行數:12,代碼來源:MorphiaEveryPolValidationTest.java

示例10: setUp

import org.mongodb.morphia.Morphia; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception
{
  Morphia morphia = new Morphia();
  morphia = morphia.mapPackage("es.um.nosql.schemainference.opensanctions");
  new ValidationExtension(morphia);
  dbName = "opensanctions";
  client = MongoDbAdapter.getMongoDbClient("localhost");
  datastore = morphia.createDatastore(client, dbName);
  validator = Validation.buildDefaultValidatorFactory().getValidator();
}
 
開發者ID:catedrasaes-umu,項目名稱:NoSQLDataEngineering,代碼行數:12,代碼來源:MorphiaOpenSanctionsValidationTest.java

示例11: MongoDBUtil

import org.mongodb.morphia.Morphia; //導入方法依賴的package包/類
private MongoDBUtil() {
	try {
		mongo = new Mongo("rank.litpo.com", 27017);
	} catch (UnknownHostException e) {
		e.printStackTrace();
	}
	morphia = new Morphia();
	morphia.mapPackage("com.find1x.gpms.pojos");
	ds = morphia.createDatastore(mongo, DATABASE);
}
 
開發者ID:findix,項目名稱:GPMS,代碼行數:11,代碼來源:MongoDBUtil.java

示例12: getMorphia

import org.mongodb.morphia.Morphia; //導入方法依賴的package包/類
/**
 * Produces and returns a {@code Morphia} instance.
 *
 * @return a {@code Morphia} instance.
 */
@Produces @Singleton
public Morphia getMorphia() {
	Morphia morphia = new Morphia();
	// Mappings
	morphia.mapPackage("com.prodyna.pmu.cpa.domain.ejb.entity");
	// Extensions
	new ValidationExtension(morphia);
	// Done
	return morphia;
}
 
開發者ID:pd-pmueller,項目名稱:cpa,代碼行數:16,代碼來源:MorphiaProducer.java

示例13: createInstance

import org.mongodb.morphia.Morphia; //導入方法依賴的package包/類
@Override
protected Morphia createInstance() throws Exception {
	Morphia m = new Morphia();
	if (mapPackages != null) {
		for (String packageName : mapPackages) {
			m.mapPackage(packageName, ignoreInvalidClasses);
		}
	}
	if (mapClasses != null) {
		for (String entityClass : mapClasses) {
			m.map(Class.forName(entityClass));
		}
	}
	return m;
}
 
開發者ID:zdsiyan,項目名稱:watermelon,代碼行數:16,代碼來源:MorphiaFactoryBean.java

示例14: main

import org.mongodb.morphia.Morphia; //導入方法依賴的package包/類
public static void main(String[] args) {

		try {

			final Morphia morphia = new Morphia();
 
			morphia.mapPackage("com.boaglio.mongodb.dto");
 
			final Datastore datastore = morphia.createDatastore(new MongoClient(), "test");

			System.out.println("-------- MongoDB JUG List from REGION 4  (Morphia) ------------");

			final Query<Region> query = datastore.createQuery(Region.class).filter("region","Sudeste");
			final List<Region> regionList = query.asList();

			System.out.println("JSON = "+regionList);

			System.out.println("-------- List<JUG> ------------");
		    regionList.get(0).getJugs().stream().forEach(System.out::println);

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
 
開發者ID:boaglio,項目名稱:mongodb-java-examples,代碼行數:25,代碼來源:JUGsList.java

示例15: buildCrudService

import org.mongodb.morphia.Morphia; //導入方法依賴的package包/類
private void buildCrudService(Dictionary<String, ?> properties, String id) {
    try {
        if (!PropertiesUtil.toString(properties.get(UNITNAME_PROP), "").equals("")) {
            //Aboard in case of nothing provided in dbname.
            //Avoiding db connection creation with blank db name.
            if (PropertiesUtil.toString(properties.get("dbName"), "").equals("")) {
                throw new InvalidMongoDatabaseException("Invalid mongo database name. Provide a valid database name.");
            }
            MongoCredential credential = null;
            if (!PropertiesUtil.toString(properties.get("username"), "").equals("")) {
                credential = MongoCredential.createCredential(
                        PropertiesUtil.toString(properties.get("username"), ""),
                        PropertiesUtil.toString(properties.get("dbName"), ""),
                        PropertiesUtil.toString(properties.get("password"), "").toCharArray()
                );
            }

            Morphia morphia = new Morphia();
            if (!PropertiesUtil.toString(properties.get("mappablePackage"), "").equals("")) {
                morphia.mapPackage(properties.get("mappablePackage").toString());
            }

            //Adding bundle class loader to load entity classes from fragment bundle.
            morphia.getMapper().getOptions().setObjectFactory(new DefaultCreator() {
                @Override
                protected ClassLoader getClassLoaderForClass() {
                    return MongoConnectionProvider.class.getClassLoader();
                }
            });

            ServerAddress serverAddress = new ServerAddress(
                    PropertiesUtil.toString(properties.get("hostName"), ""),
                    PropertiesUtil.toInteger(properties.get("port"), 0)
            );

            MongoClient mongoClient = null;
            if (credential != null) {
                mongoClient = new MongoClient(
                        serverAddress,
                        Arrays.asList(credential),
                        this.buildMongoOptions(properties)
                );
            } else {
                mongoClient = new MongoClient(
                        serverAddress,
                        this.buildMongoOptions(properties)
                );
            }

            if (this.unitMapping.containsKey(id)) {
                this.destroy(id);
            }

            this.serviceContainer.put(
                    PropertiesUtil.toString(properties.get(UNITNAME_PROP), ""),
                    new MongoCrudRepositoryImpl(
                            morphia.createDatastore(
                                    mongoClient,
                                    PropertiesUtil.toString(properties.get("dbName"), "")
                            )
                    )
            );

            this.unitMapping.put(id,
                    PropertiesUtil.toString(properties.get(UNITNAME_PROP), ""));
        } else {
            throw new InvalidMongoUnitException("Invalid Unit name provided for mongo db configuration. Provide Valid and unique name for unit");
        }
    } catch (Exception ex) {
        LOGGER.error("Unable to create mongo crud service for config id {} full exception ", id, ex);
    }
}
 
開發者ID:AdeptJ,項目名稱:adeptj-modules,代碼行數:73,代碼來源:MongoConnectionProvider.java


注:本文中的org.mongodb.morphia.Morphia.mapPackage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。