net.ymate.platform.module.ConfigModule Maven / Gradle / Ivy
/*
* Copyright 2007-2107 the original author or authors.
*
* 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 net.ymate.platform.module;
import java.util.Map;
import net.ymate.platform.base.AbstractModule;
import net.ymate.platform.commons.util.ClassUtils;
import net.ymate.platform.commons.util.RuntimeUtils;
import net.ymate.platform.configuration.Cfgs;
import net.ymate.platform.configuration.ICfgConfig;
import net.ymate.platform.configuration.provider.IConfigurationProvider;
import net.ymate.platform.configuration.provider.impl.JConfigProvider;
import org.apache.commons.lang.StringUtils;
/**
*
* ConfigModule
*
*
* 配置体系模块加载器接口实现类;
*
*
* @author 刘镇([email protected])
* @version 0.0.0
*
*
* 版本号 动作 修改人 修改时间
*
*
*
* 0.0.0
* 创建类
* 刘镇
* 2012-12-23下午6:58:07
*
*
*/
public class ConfigModule extends AbstractModule {
/* (non-Javadoc)
* @see net.ymate.platform.module.base.AbstractModule#initialize(java.util.Map)
*/
public void initialize(final Map moduleCfgs) throws Exception {
Cfgs.initialize(new ICfgConfig() {
public String getConfigHome() {
String _configHomeF = StringUtils.defaultIfEmpty(moduleCfgs.get("config_home"), "${root}");
if (_configHomeF.equalsIgnoreCase("${root}")) {
_configHomeF = RuntimeUtils.getRootPath();
}
return _configHomeF;
}
public String getProjectName() {
return moduleCfgs.get("project_name");
}
public String getModuleName() {
return moduleCfgs.get("module_name");
}
public IConfigurationProvider getConfigurationProviderClassImpl() {
IConfigurationProvider __provider = ClassUtils.impl(StringUtils.defaultIfEmpty(moduleCfgs.get("provider_impl_class"), JConfigProvider.class.getName()), IConfigurationProvider.class, ConfigModule.class);
return __provider;
}
});
}
}