Skip to content

Commit

Permalink
Merge pull request #779 from chickenlj:xml_config
Browse files Browse the repository at this point in the history
 Adjust some config properties
  • Loading branch information
chickenlj authored Oct 29, 2017
1 parent ee2aaf3 commit 50d4ddd
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public static URL mergeUrl(URL remoteUrl, Map<String, String> localMap) {

map.remove(Constants.ALIVE_KEY);
map.remove(Constants.DEFAULT_KEY_PREFIX + Constants.ALIVE_KEY);

map.remove(Constants.TRANSPORTER_KEY);
map.remove(Constants.DEFAULT_KEY_PREFIX + Constants.TRANSPORTER_KEY);
}

if (localMap != null && localMap.size() > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ protected static void appendProperties(AbstractConfig config) {
String name = method.getName();
if (name.length() > 3 && name.startsWith("set") && Modifier.isPublic(method.getModifiers())
&& method.getParameterTypes().length == 1 && isPrimitive(method.getParameterTypes()[0])) {
String property = StringUtils.camelToSplitName(name.substring(3, 4).toLowerCase() + name.substring(4), "-");
String property = StringUtils.camelToSplitName(name.substring(3, 4).toLowerCase() + name.substring(4), ".");

String value = null;
if (config.getId() != null && config.getId().length() > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,17 @@ 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 {
if ((monitorAddress == null || monitorAddress.length() == 0) && (monitorProtocol == null || monitorProtocol.length() == 0)) {
return null;
}

monitor = new MonitorConfig();
if (monitorAddress != null && monitorAddress.length() > 0) {
monitor.setAddress(monitorAddress);
}
if (monitorProtocol != null && monitorProtocol.length() > 0) {
monitor.setProtocol(monitorProtocol);
}
}
appendProperties(monitor);
Map<String, String> map = new HashMap<String, String>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ public abstract class AbstractServiceConfig extends AbstractInterfaceConfig {
// 是否注册
private Boolean register;

// 预热时间
private Integer warmup;

public String getVersion() {
return version;
}
Expand Down Expand Up @@ -122,6 +125,11 @@ public String getToken() {
return token;
}

public void setToken(String token) {
checkName("token", token);
this.token = token;
}

public void setToken(Boolean token) {
if (token == null) {
setToken((String) null);
Expand All @@ -130,11 +138,6 @@ public void setToken(Boolean token) {
}
}

public void setToken(String token) {
checkName("token", token);
this.token = token;
}

public Boolean isDeprecated() {
return deprecated;
}
Expand Down Expand Up @@ -172,6 +175,10 @@ public String getAccesslog() {
return accesslog;
}

public void setAccesslog(String accesslog) {
this.accesslog = accesslog;
}

public void setAccesslog(Boolean accesslog) {
if (accesslog == null) {
setAccesslog((String) null);
Expand All @@ -180,10 +187,6 @@ public void setAccesslog(Boolean accesslog) {
}
}

public void setAccesslog(String accesslog) {
this.accesslog = accesslog;
}

public Integer getExecutes() {
return executes;
}
Expand Down Expand Up @@ -218,4 +221,12 @@ public void setRegister(Boolean register) {
setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE));
}
}

public Integer getWarmup() {
return warmup;
}

public void setWarmup(Integer warmup) {
this.warmup = warmup;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Map;


/**
Expand Down Expand Up @@ -67,6 +68,12 @@ public class ApplicationConfig extends AbstractConfig {
// 是否为缺省
private Boolean isDefault;

// thread stack存储路径
private String dumpDirectory;

// 自定义参数
private Map<String, String> parameters;

public ApplicationConfig() {
}

Expand Down Expand Up @@ -160,14 +167,14 @@ public MonitorConfig getMonitor() {
return monitor;
}

public void setMonitor(String monitor) {
this.monitor = new MonitorConfig(monitor);
}

public void setMonitor(MonitorConfig monitor) {
this.monitor = monitor;
}

public void setMonitor(String monitor) {
this.monitor = new MonitorConfig(monitor);
}

public String getCompiler() {
return compiler;
}
Expand All @@ -194,4 +201,21 @@ public void setDefault(Boolean isDefault) {
this.isDefault = isDefault;
}

@Parameter(key = "dump.directory")
public String getDumpDirectory() {
return dumpDirectory;
}

public void setDumpDirectory(String dumpDirectory) {
this.dumpDirectory = dumpDirectory;
}

public Map<String, String> getParameters() {
return parameters;
}

public void setParameters(Map<String, String> parameters) {
checkParameterName(parameters);
this.parameters = parameters;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public class ConsumerConfig extends AbstractReferenceConfig {
// 是否为缺省
private Boolean isDefault;

// 网络通信框架的客户端类型: netty mina ...
private String client;

@Override
public void setTimeout(Integer timeout) {
super.setTimeout(timeout);
Expand All @@ -46,4 +49,11 @@ public void setDefault(Boolean isDefault) {
this.isDefault = isDefault;
}

public String getClient() {
return client;
}

public void setClient(String client) {
this.client = client;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.alibaba.dubbo.config.ArgumentConfig;
import com.alibaba.dubbo.config.ConsumerConfig;
import com.alibaba.dubbo.config.MethodConfig;
import com.alibaba.dubbo.config.MonitorConfig;
import com.alibaba.dubbo.config.ProtocolConfig;
import com.alibaba.dubbo.config.ProviderConfig;
import com.alibaba.dubbo.config.RegistryConfig;
Expand Down Expand Up @@ -197,11 +196,6 @@ private static BeanDefinition parse(Element element, ParserContext parserContext
ProtocolConfig protocol = new ProtocolConfig();
protocol.setName(value);
reference = protocol;
} else if ("monitor".equals(property)
&& (!parserContext.getRegistry().containsBeanDefinition(value)
|| !MonitorConfig.class.getName().equals(parserContext.getRegistry().getBeanDefinition(value).getBeanClassName()))) {
// 兼容旧版本配置
reference = convertMonitor(value);
} else if ("onreturn".equals(property)) {
int index = value.lastIndexOf(".");
String returnRef = value.substring(0, index);
Expand Down Expand Up @@ -249,29 +243,6 @@ private static BeanDefinition parse(Element element, ParserContext parserContext
return beanDefinition;
}

protected static MonitorConfig convertMonitor(String monitor) {
if (monitor == null || monitor.length() == 0) {
return null;
}
if (GROUP_AND_VERION.matcher(monitor).matches()) {
String group;
String version;
int i = monitor.indexOf(':');
if (i > 0) {
group = monitor.substring(0, i);
version = monitor.substring(i + 1);
} else {
group = monitor;
version = null;
}
MonitorConfig monitorConfig = new MonitorConfig();
monitorConfig.setGroup(group);
monitorConfig.setVersion(version);
return monitorConfig;
}
return null;
}

private static boolean isPrimitive(Class<?> cls) {
return cls.isPrimitive() || cls == Boolean.class || cls == Byte.class
|| cls == Character.class || cls == Short.class || cls == Integer.class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,20 @@
<xsd:documentation><![CDATA[ The service protocol. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="warmup" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ The warmup time in Milliseconds. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:anyAttribute namespace="##other" processContents="lax"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

<xsd:complexType name="applicationType">
<xsd:sequence minOccurs="0" maxOccurs="unbounded">
<xsd:element ref="parameter" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:ID">
<xsd:annotation>
<xsd:documentation><![CDATA[ The unique identifier for a bean. ]]></xsd:documentation>
Expand Down Expand Up @@ -677,13 +685,19 @@
<xsd:complexContent>
<xsd:extension base="abstractReferenceType">
<xsd:sequence minOccurs="0" maxOccurs="unbounded">
<xsd:element ref="reference" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element ref="parameter" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="default" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ Is default. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="client" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ Transporter layer framework: netty mina.... ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:anyAttribute namespace="##other" processContents="lax"/>
</xsd:extension>
</xsd:complexContent>
Expand Down

0 comments on commit 50d4ddd

Please sign in to comment.