how do we create plugin / extensions in object oriented programming?
How does software allow developers to make a plugin / exte开发者_如何学JAVAnsions on top of its core? How is that related to object oriented programming? maybe with inheritance or interfaces? What kind of design pattern should one use?
For example, firefox extensions that enhance firefox, wordpress extensions, etc. Those systems sort of "recognize" plugins after being installed and work well and in some cases they perform safety checking, dependencies, and the like.
Anyone care to shed light on this?
Plugin models in real applications like firefox may be more complex than they are in general. In general you define some interface that a plugin should implement, and implement it in your plugins, that's it. Modern frameworks contain plugin development facilities like MEF in .NET, mojo in Java, etc.
Java supports a basic plug-in mechanism through its SPI (Service Provider Interface). The main mechanism revolves around discovery and binding of the new provider. Below two articles will get you started
- Replaceable Components and the Service Provider Interface
- Creating Extensible Java Applications
There are open source frameworks that are more powerful than provided by JDK
- JPF
- JSPF
But OSGi is the standard and mother of all plugin frameworks in my opinion.
精彩评论