org.canedata.provider.mongodb.entity.MongoEntityFactory Maven / Gradle / Ivy
/**
* Copyright 2011 CaneData.org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.canedata.provider.mongodb.entity;
import org.canedata.cache.Cache;
import org.canedata.core.intent.Intent;
import org.canedata.core.logging.LoggerFactory;
import org.canedata.core.util.StringUtils;
import org.canedata.entity.Entity;
import org.canedata.entity.EntityFactory;
import org.canedata.logging.Logger;
import org.canedata.provider.mongodb.MongoResource;
import org.canedata.provider.mongodb.MongoResourceProvider;
import org.canedata.provider.mongodb.intent.MongoIntent;
import org.canedata.resource.Resource;
import org.canedata.resource.ResourceProvider;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import java.util.HashMap;
import java.util.Map;
/**
*
* @author Sun Yat-ton
* @version 1.00.000 2011-8-1
*/
public abstract class MongoEntityFactory implements EntityFactory {
protected static final Logger logger = LoggerFactory
.getLogger(MongoEntityFactory.class);
abstract protected ResourceProvider getResourceProvider();
abstract protected String getDefaultSchema();
public Entity get(String name) {
return get(null, null, name);
}
public Entity get(String schema, String name) {
return get(null, schema, name);
}
public Entity get(Resource> res, String name) {
return get(res, null, name);
}
public Entity get(final Resource> res, final String schema,
final String name) {
MongoResource mres = (MongoResource) res;
if (null == mres) {
mres = (MongoResource) getResourceProvider().getResource();
}
final MongoResource cres = mres;
final String final_schema = StringUtils.isBlank(schema)?getDefaultSchema():schema;
return new MongoEntity() {
ThreadLocal
© 2015 - 2025 Weber Informatics LLC | Privacy Policy