本文整理汇总了Java中com.alibaba.dubbo.common.utils.ConfigUtils.getProperty方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigUtils.getProperty方法的具体用法?Java ConfigUtils.getProperty怎么用?Java ConfigUtils.getProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.dubbo.common.utils.ConfigUtils
的用法示例。
在下文中一共展示了ConfigUtils.getProperty方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkApplication
import com.alibaba.dubbo.common.utils.ConfigUtils; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
protected void checkApplication() {
// 兼容旧版本
if (application == null) {
String applicationName = ConfigUtils.getProperty("dubbo.application.name");
if (applicationName != null && applicationName.length() > 0) {
application = new ApplicationConfig();
}
}
if (application == null) {
throw new IllegalStateException(
"No such application config! Please add <dubbo:application name=\"...\" /> to your spring config.");
}
appendProperties(application);
String wait = ConfigUtils.getProperty(Constants.SHUTDOWN_WAIT_KEY);
if (wait != null && wait.trim().length() > 0) {
System.setProperty(Constants.SHUTDOWN_WAIT_KEY, wait.trim());
} else {
wait = ConfigUtils.getProperty(Constants.SHUTDOWN_WAIT_SECONDS_KEY);
if (wait != null && wait.trim().length() > 0) {
System.setProperty(Constants.SHUTDOWN_WAIT_SECONDS_KEY, wait.trim());
}
}
}
示例2: doExport
import com.alibaba.dubbo.common.utils.ConfigUtils; //导入方法依赖的package包/类
@Override
/**
* dubbo spi bean 注册入口
* httpserver 绑定
*/
protected <T> Runnable doExport(T impl, Class<T> type, final URL url) throws RpcException {
String contextPath = ConfigUtils.getProperty("dubbo.protocol.restful.contextpath","/");
String addr = url.getIp() + ":" + url.getPort();
HttpServer server = SERVER_MAPPER.get(addr);
if (server == null) {
server = httpBinder.bind(url, new RestfulHandler(SERVICE_MAPPING_CONTAINER,contextPath));
SERVER_MAPPER.put(addr, server);
}
SERVICE_MAPPING_CONTAINER.registerService(url,type,impl);
return new Runnable() {
@Override
public void run() {
SERVICE_MAPPING_CONTAINER.unregisterService(url);
}
};
}
示例3: start
import com.alibaba.dubbo.common.utils.ConfigUtils; //导入方法依赖的package包/类
public void start() {
String file = ConfigUtils.getProperty(LOGBACK_FILE);
if (file != null && file.length() > 0) {
String level = ConfigUtils.getProperty(LOGBACK_LEVEL);
if (level == null || level.length() == 0) {
level = DEFAULT_LOGBACK_LEVEL;
}
// maxHistory=0 Infinite history
int maxHistory = StringUtils.parseInteger(ConfigUtils.getProperty(LOGBACK_MAX_HISTORY));
doInitializer(file, level, maxHistory);
}
}
示例4: start
import com.alibaba.dubbo.common.utils.ConfigUtils; //导入方法依赖的package包/类
public void start() {
String serverPort = ConfigUtils.getProperty(JETTY_PORT);
int port;
if (serverPort == null || serverPort.length() == 0) {
port = DEFAULT_JETTY_PORT;
} else {
port = Integer.parseInt(serverPort);
}
connector = new SelectChannelConnector();
connector.setPort(port);
ServletHandler handler = new ServletHandler();
String resources = ConfigUtils.getProperty(JETTY_DIRECTORY);
if (resources != null && resources.length() > 0) {
FilterHolder resourceHolder = handler.addFilterWithMapping(ResourceFilter.class, "/*", Handler.DEFAULT);
resourceHolder.setInitParameter("resources", resources);
}
ServletHolder pageHolder = handler.addServletWithMapping(PageServlet.class, "/*");
pageHolder.setInitParameter("pages", ConfigUtils.getProperty(JETTY_PAGES));
pageHolder.setInitOrder(2);
Server server = new Server();
server.addConnector(connector);
server.addHandler(handler);
try {
server.start();
} catch (Exception e) {
throw new IllegalStateException("Failed to start jetty server on " + NetUtils.getLocalHost() + ":" + port + ", cause: " + e.getMessage(), e);
}
}
示例5: loadMonitor
import com.alibaba.dubbo.common.utils.ConfigUtils; //导入方法依赖的package包/类
protected URL loadMonitor(URL registryURL) {
if (monitor == null) {
String monitorAddress = ConfigUtils.getProperty("dubbo.monitor.address");
String monitorProtocol = ConfigUtils.getProperty("dubbo.monitor.protocol");
if (monitorAddress != null && monitorAddress.length() > 0
|| monitorProtocol != null && monitorProtocol.length() > 0) {
monitor = new MonitorConfig();
} else {
return null;
}
}
appendProperties(monitor);
Map<String, String> map = new HashMap<String, String>();
map.put(Constants.INTERFACE_KEY, MonitorService.class.getName());
map.put("dubbo", Version.getVersion());
map.put(Constants.TIMESTAMP_KEY, String.valueOf(System.currentTimeMillis()));
if (ConfigUtils.getPid() > 0) {
map.put(Constants.PID_KEY, String.valueOf(ConfigUtils.getPid()));
}
appendParameters(map, monitor);
String address = monitor.getAddress();
String sysaddress = System.getProperty("dubbo.monitor.address");
if (sysaddress != null && sysaddress.length() > 0) {
address = sysaddress;
}
if (ConfigUtils.isNotEmpty(address)) {
if (! map.containsKey(Constants.PROTOCOL_KEY)) {
if (ExtensionLoader.getExtensionLoader(MonitorFactory.class).hasExtension("logstat")) {
map.put(Constants.PROTOCOL_KEY, "logstat");
} else {
map.put(Constants.PROTOCOL_KEY, "dubbo");
}
}
return UrlUtils.parseURL(address, map);
} else if (Constants.REGISTRY_PROTOCOL.equals(monitor.getProtocol()) && registryURL != null) {
return registryURL.setProtocol("dubbo").addParameter(Constants.PROTOCOL_KEY, "registry").addParameterAndEncoded(Constants.REFER_KEY, StringUtils.toQueryString(map));
}
return null;
}
示例6: start
import com.alibaba.dubbo.common.utils.ConfigUtils; //导入方法依赖的package包/类
public void start() {
String configPath = ConfigUtils.getProperty(SPRING_JAVACONFIG);
if (configPath == null || configPath.length() == 0) {
configPath = DEFAULT_SPRING_JAVACONFIG;
}
context = new AnnotationConfigApplicationContext(configPath);
context.start();
}
示例7: start
import com.alibaba.dubbo.common.utils.ConfigUtils; //导入方法依赖的package包/类
public void start() {
String configPath = ConfigUtils.getProperty(SPRING_CONFIG);
if (configPath == null || configPath.length() == 0) {
configPath = DEFAULT_SPRING_CONFIG;
}
context = new ClassPathXmlApplicationContext(configPath.split("[,\\s]+"));
context.start();
}
示例8: start
import com.alibaba.dubbo.common.utils.ConfigUtils; //导入方法依赖的package包/类
public void start() {
String file = ConfigUtils.getProperty(LOGBACK_FILE);
if (file != null && file.length() > 0) {
String level = ConfigUtils.getProperty(LOGBACK_LEVEL);
if (level == null || level.length() == 0) {
level = DEFAULT_LOGBACK_LEVEL;
}
// maxHistory=0 Infinite history
int maxHistory = StringUtils.parseInteger(ConfigUtils.getProperty(LOGBACK_MAX_HISTORY));
doInitializer(file, level, maxHistory);
}
}
示例9: start
import com.alibaba.dubbo.common.utils.ConfigUtils; //导入方法依赖的package包/类
public void start() {
String serverPort = ConfigUtils.getProperty(JETTY_PORT);
int port;
if (serverPort == null || serverPort.length() == 0) {
port = DEFAULT_JETTY_PORT;
} else {
port = Integer.parseInt(serverPort);
}
connector = new SelectChannelConnector();
connector.setPort(port);
ServletHandler handler = new ServletHandler();
String resources = ConfigUtils.getProperty(JETTY_DIRECTORY);
if (resources != null && resources.length() > 0) {
FilterHolder resourceHolder = handler.addFilterWithMapping(ResourceFilter.class, "/*", Handler.DEFAULT);
resourceHolder.setInitParameter("resources", resources);
}
ServletHolder pageHolder = handler.addServletWithMapping(PageServlet.class, "/*");
pageHolder.setInitParameter("pages", ConfigUtils.getProperty(JETTY_PAGES));
pageHolder.setInitOrder(2);
Server server = new Server();
server.addConnector(connector);
server.addHandler(handler);
try {
server.start();
} catch (Exception e) {
throw new IllegalStateException("Failed to start jetty server on " + NetUtils.getLocalHost() + ":" + port + ", cause: " + e.getMessage(), e);
}
}
示例10: start
import com.alibaba.dubbo.common.utils.ConfigUtils; //导入方法依赖的package包/类
public void start() {
// 获取Spring配置文件的地址
String configPath = ConfigUtils.getProperty(SPRING_CONFIG);
if (configPath == null || configPath.length() == 0) {
configPath = DEFAULT_SPRING_CONFIG;
}
context = new ClassPathXmlApplicationContext(configPath.split("[,\\s]+"));
// 启动
context.start();
}
示例11: start
import com.alibaba.dubbo.common.utils.ConfigUtils; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void start() {
String file = ConfigUtils.getProperty(LOG4J_FILE);
if (file != null && file.length() > 0) {
String level = ConfigUtils.getProperty(LOG4J_LEVEL);
if (level == null || level.length() == 0) {
level = DEFAULT_LOG4J_LEVEL;
}
Properties properties = new Properties();
properties.setProperty("log4j.rootLogger", level + ",application");
properties.setProperty("log4j.appender.application", "org.apache.log4j.DailyRollingFileAppender");
properties.setProperty("log4j.appender.application.File", file);
properties.setProperty("log4j.appender.application.Append", "true");
properties.setProperty("log4j.appender.application.DatePattern", "'.'yyyy-MM-dd");
properties.setProperty("log4j.appender.application.layout", "org.apache.log4j.PatternLayout");
properties.setProperty("log4j.appender.application.layout.ConversionPattern", "%d [%t] %-5p %C{6} (%F:%L) - %m%n");
PropertyConfigurator.configure(properties);
}
String subdirectory = ConfigUtils.getProperty(LOG4J_SUBDIRECTORY);
if (subdirectory != null && subdirectory.length() > 0) {
Enumeration<org.apache.log4j.Logger> ls = LogManager.getCurrentLoggers();
while (ls.hasMoreElements()) {
org.apache.log4j.Logger l = ls.nextElement();
if (l != null) {
Enumeration<Appender> as = l.getAllAppenders();
while (as.hasMoreElements()) {
Appender a = as.nextElement();
if (a instanceof FileAppender) {
FileAppender fa = (FileAppender)a;
String f = fa.getFile();
if (f != null && f.length() > 0) {
int i = f.replace('\\', '/').lastIndexOf('/');
String path;
if (i == -1) {
path = subdirectory;
} else {
path = f.substring(0, i);
if (! path.endsWith(subdirectory)) {
path = path + "/" + subdirectory;
}
f = f.substring(i + 1);
}
fa.setFile(path + "/" + f);
fa.activateOptions();
}
}
}
}
}
}
}
示例12: getRegistryAddress
import com.alibaba.dubbo.common.utils.ConfigUtils; //导入方法依赖的package包/类
/**
*
* 获取注册中心地址
*
* @author zhangshaobin
* @created 2013-4-9 下午12:32:38
*
* @return
*/
public static String getRegistryAddress() {
return ConfigUtils.getProperty("dubbo.registry.address");
}