You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/11/30 08:18:09 UTC
[GitHub] [shardingsphere] taotao365s opened a new issue #13865: what does PropertyUtil.v2 function mean?
taotao365s opened a new issue #13865:
URL: https://github.com/apache/shardingsphere/issues/13865
## Question
background: shardingsphere 5.0
- application.yml
````
spring.shardingsphere.rules.sharding.tables.t_dict.key-generate-strategy.column=id
spring.shardingsphere.rules.sharding.tables.t_dict.key-generate-strategy.key-generator-name=dict_primary_key
spring.shardingsphere.rules.sharding.key-generators.dict_primary_key.type=BIZ_PRIMARY_KEY
spring.shardingsphere.rules.sharding.key-generators.dict_primary_key.props.biz-type=dict
````
- BizPrimaryKeyGenerateAlgorithm.java
````
public final class BizPrimaryKeyGenerateAlgorithm implements KeyGenerateAlgorithm {
@Getter
@Setter
private Properties props = new Properties();
private String bizType;
@Override
public Comparable<?> generateKey() {
//TODO
}
@Override
public void init() {
this.bizType = props.getProperty("biz-type", "default");
log.info("init biz type={}", this.bizType);
}
@Override
public String getType() {
return "BIZ_PRIMARY_KEY";
}
}
````
- when I set `key-generator-name` is `dict_primary_key`, props is always null in BizPrimaryKeyGenerateAlgorithm.java
- then I debug it to `PropertyUtil.containPropertyPrefix --> v2`
````
@SneakyThrows(ReflectiveOperationException.class)
private static Object v2(final Environment environment, final String prefix, final Class<?> targetClass) {
Class<?> binderClass = Class.forName("org.springframework.boot.context.properties.bind.Binder");
Method getMethod = binderClass.getDeclaredMethod("get", Environment.class);
Method bindMethod = binderClass.getDeclaredMethod("bind", String.class, Class.class);
Object binderObject = getMethod.invoke(null, environment);
String prefixParam = prefix.endsWith(".") ? prefix.substring(0, prefix.length() - 1) : prefix;
Object bindResultObject = bindMethod.invoke(binderObject, prefixParam, targetClass);
Method resultGetMethod = bindResultObject.getClass().getDeclaredMethod("get");
return resultGetMethod.invoke(bindResultObject);
}
````
so what does v2 function mean?
when I change `key-generator-name` to `dict-primary-key`, props have values in BizPrimaryKeyGenerateAlgorithm.java
````
spring.shardingsphere.rules.sharding.tables.t_dict.key-generate-strategy.column=id
spring.shardingsphere.rules.sharding.tables.t_dict.key-generate-strategy.key-generator-name=dict-primary-key
spring.shardingsphere.rules.sharding.key-generators.dict-primary-key.type=BIZ_PRIMARY_KEY
spring.shardingsphere.rules.sharding.key-generators.dict-primary-key.props.biz-type=dict
````
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] taotao365s commented on issue #13865: what does PropertyUtil.v2 function mean?
Posted by GitBox <gi...@apache.org>.
taotao365s commented on issue #13865:
URL: https://github.com/apache/shardingsphere/issues/13865#issuecomment-982542719
> @taotao365s v2 are SpringBoot 2.x.
I know springboot2, what’s function doing?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] zjcnb commented on issue #13865: what does PropertyUtil.v2 function mean?
Posted by GitBox <gi...@apache.org>.
zjcnb commented on issue #13865:
URL: https://github.com/apache/shardingsphere/issues/13865#issuecomment-982600452
I think it 's read springboot application.properties configuration, What do you think?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] terrymanu closed issue #13865: what does PropertyUtil.v2 function mean?
Posted by GitBox <gi...@apache.org>.
terrymanu closed issue #13865:
URL: https://github.com/apache/shardingsphere/issues/13865
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] terrymanu commented on issue #13865: what does PropertyUtil.v2 function mean?
Posted by GitBox <gi...@apache.org>.
terrymanu commented on issue #13865:
URL: https://github.com/apache/shardingsphere/issues/13865#issuecomment-1046270006
I just close this issue because no response for long time.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] terrymanu commented on issue #13865: what does PropertyUtil.v2 function mean?
Posted by GitBox <gi...@apache.org>.
terrymanu commented on issue #13865:
URL: https://github.com/apache/shardingsphere/issues/13865#issuecomment-1046269952
I just close this issue because no response for long time.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] RaigorJiang commented on issue #13865: what does PropertyUtil.v2 function mean?
Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on issue #13865:
URL: https://github.com/apache/shardingsphere/issues/13865#issuecomment-988574646
Hi @taotao365s
If your question is solved, can we close this issue?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] zjcnb commented on issue #13865: what does PropertyUtil.v2 function mean?
Posted by GitBox <gi...@apache.org>.
zjcnb commented on issue #13865:
URL: https://github.com/apache/shardingsphere/issues/13865#issuecomment-982424320
@taotao365s v2 are SpringBoot 2.x.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org