I'm designing an extension package for a managed package to add different integrations to the main package. The objective is to install a specific extension package to enable integration between our main package and another vendors installed managed package. No more than one of our extensions would be installed at once, and it's possible the customer wouldn't have any integration extension installed.
From what I've read the primary issue with using Interfaces in a managed package is that the Global Interface class cannot be modified once added to the package. That would limit flexibility going forward as we build additional integrations that could possibly require other methods/parameter types.
My solution to this is to create a single method in the Interface for Process() that accepts two parameters:
- String action: Some extension-specific action to take (ex: "post", "retreive", etc.)
- String jsonParms: A JSON serialized string with the unique parameters specific to the action.
Using the above design, my expectation is that the Global Interface in the main package can be built and (for the most part) not need to be modified going forward if new Extension Package methods are required. In this particular use case, I've only come up with a couple of actions - Post and Unpost - but I can see possibilities where there may be others. The return set in this case is limited as well, given that the extension's purpose is very specific, but I can see where I may need to build a method into the Services class that inherits from the Interface that returns something different. I'm considering a few generic Interface methods for this, such as processReturnString(), processReturnSObjects() and maybe processReturnBoolean() - all accepting the same String action and JSON serialized parameters, and each returning a different type.
The real question here is - will this architecture work and be flexible enough given Salesforce's rather strict rules in Managed Packages?