Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

对于Router类里面,services字段的建议 #102

Open
mengxin1995 opened this issue Apr 12, 2018 · 0 comments
Open

对于Router类里面,services字段的建议 #102

mengxin1995 opened this issue Apr 12, 2018 · 0 comments

Comments

@mengxin1995
Copy link

private HashMap<String, Object> services = new HashMap<>();

这个services能不能存一个 名字加一个class对象,在宿主那边调用的时候直接通过这样的方式获得对象
比如

<xxxx, ReadObject.class>
try {
    Object o = Class.forName(aClass.getName()).newInstance();
} catch (ClassNotFoundException e) {
    e.printStackTrace();
} catch (IllegalAccessException e) {
    e.printStackTrace();
} catch (InstantiationException e) {
    e.printStackTrace();
}

这个object再强转成接口对象
这样主要想解决不用花那么大的内存去存储提供服务的对象

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant