java - 能不能加入一种IOC的语法,比如new一个interface
黄舟
黄舟 2017-04-17 17:52:20
0
3
733

如题,开一下脑洞,各种开发语言能不能把接口变的可以new,实现IOC的效果,而具体实例化的类型是通过类似我们现在使用的IOC框架的注入方式来确定的。

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(3)
阿神

Since it is injected, why do you need new interface?

左手右手慢动作

new interface has no meaning

洪涛

Do you want to use IoC as a language feature, or native support?

For new Interface, custom language based on JVM implementation is actually possible.

In addition to the source code, add a configuration file control.
Configuration file as preprocessing control.
When compiling, first preprocess the pure source code file (the object has been injected).
Compile the preprocessed source code file afterwards.
The above is how static injection (compile-time injection) is handled.

In addition, obviously, from Spring, we can know that it is possible to use reflection to achieve the effect of dynamic injection, as long as we make corresponding changes in semantic analysis and write a usable IoC standard library.

It’s easy to say it, but it’s not easy to implement.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!