I have a Java application and I would like to make it extensible. To create an extension, developers within our company will write a Java class that implements a certain interface. They may also wish to write associated helper classes. I would like to load these extensions into the application without an outage.
I would like to limit what this class can do to the following:
- Call methods in the application's API (this will be a parameter to the constructor)
- Create instances of other objects within the same package (so the author of the extension class can use other classes to get the job done).
When the class is invoked the API object that is passed in will already have a "customer" defined and stored as a member variable. It will use this to limit access via the API to that customer's data.
I do not want these classes doing things such as accessing the database, writing to disk, or otherwise doing things etc. This is mostly an effort at dependency management and encapsulation as the same team of developers will have access to write both extensions and the core system.
Is there a pattern for this? Am I on the right track?