Suppose I am developing a managed package and I want to build some additional packages that can integrate to it. Let's call the main package Package A.
I want to create a separate package (Package B). When Package B is installed in an org where Package A is deployed, I'd like to build "awareness" into Pacakage A so that it knows that Package B is installed. This shouldn't be to difficult since I can do some describes and look for the SObjects in Package B to know if it's installed.
IMPORTANT NOTE: Package B should NOT require that Package A is installed. Package B can be used on its own without Package A.
Now the tricky (maybe impossible) part...
I'd like for Package B to expose an API for integration to Package A or any other application in the future. Ideally, Package A would be able to access the global classes to provide the integration. For example, maybe one of the triggers in Package A would call a static method from Package B like PackageBClass.doSomething();
Is there any way to do this? I thinks not. I can't build Package B references into Package A or it would create a dependency (extension). I also can't do the reverse for the same reason. They need to be two independent packages that can work together if need be. I looked at the new Apex Type Methods but this wouldn't work because there would have to be a dependency between the apps for a shared Interface.
The only thing that I can think of that might work is a third package that depends on both Package A and Package B that acts like a proxy. This is less than ideal though.
Any thoughts or suggestions?
Schedulable
orProcess.Plugin
as a common interface. I think this would work pretty well, actually --- I've done dynamic instantiation of classes that implement Schedulable many times and it works great, and I betProcess.Plugin
would work just as well. You're right about theSystem.Type
methods not being sufficient yet --- until we have dynamic method calling (e.g. withSystem.Method.invoke(methodName)
), you have to rely on a common interface being present.