Monday, 15 September 2014

design patterns - How to make a Java project 'extendable' by developers? -


I am working on a server engine, and I'm not sure how to distribute it. It is quite modular and uses the interface / abstract classes.

  • New Server (.) SetSomeHandler (myHandler) .run () )

  • Config file with a binary (executable entry where you inject jar with handlers

  • Something else?

  • Basically, the developer should be able to completely expand or change the way the server works. I do not like the idea of ​​making this a library because it should be a platform in itself, a complete server system

    Providing programmatic methods is more versatile than simply executable. And both methods are not mutually exclusive after all, even if a developer provides a handler, internally you probably still need to make some calls like that example setter, which actually use that handler It should disclose that the API should not be very difficult. You can still provide a small launcher app that loads some config files and wraps it in some API calls, if it is needed.

    There will be more important questions, are there predefined points, where developers can plug in their own implementation or everything is completely modular and interchangeable?

    For a simple way to provide the implementation of the predefined interface, you can use the ServiceLoader / SPI mechanism to create an original plug-in system with it

    If you want to create a platform, then something better seems like OSGi. Here you can define the API / SPI for fine cane component / services. Developers can then provide their modules that extend the server or even change your default module.


    No comments:

    Post a Comment