使用泛化调用

    在 Spring 配置申明 generic="true"

    1. GenericService barService = (GenericService) applicationContext.getBean("barService");
    2. Object result = barService.$invoke("sayHello", new String[] { "java.lang.String" }, new Object[] { "World" });

    假设存在 POJO 如:

    1. package com.xxx;
    2. public class PersonImpl implements Person {
    3. private String name;
    4. private String password;
    5. public String getName() {
    6. return name;
    7. }
    8. public void setName(String name) {
    9. this.name = name;
    10. }
    11. public String getPassword() {
    12. public void setPassword(String password) {
    13. this.password = password;
    14. }
    15. }

    可用下面 Map 表示:

    1. Map<String, Object> map = new HashMap<String, Object>();
    2. // 注意:如果参数类型是接口,或者List等丢失泛型,可通过class属性指定类型。
    3. map.put("class", "com.xxx.PersonImpl");
    4. map.put("password", "yyy");