Hi Leland,
I think in your scenario you can use a ClientService which is used to
- Let the first Executable store any kind of information
- Let other executables access that information
The needed steps are
- Define a java interface (e.g. MyClipboard) containing some kind of "clipboard" methods like "void storeInfo(SomeClass info)" and "SomeClass getInfo()". The "SomeClass" can be anything that suits your needs, and of course it can be just a String too.
- Create a class implementing that Interface, e.g. MyClipboardImpl
- Create a so called PermanentPlugin (e.g. MyPermanentPlugin) - in your case the CC version which is done by implementing the Interface WebeditPermanentPlugin. Add your MyPermanentPlugin class to the module.xml as PUBLIC component
- Inside the setUp method of your PermanentPlugin implementation, you create an instance of your clipboard class and register it as ClientService.
class MyPermanentPlugin implements WebeditPermanentPlugin {
@Override
public void setUp(BaseContext context){
MyClipboard clipboard = new MyClipboardImpl();
context.requireSpecialist(ClientServiceRegistryAgent.TYPE).registerClientService(MyClipboard.class, clipboard);
}
@Override
public void tearDown(){}
}
FirstSpirit makes sure that the PermanentPlugin is loaded before any other plugin type upon client session start.
(Personally I find the name "PermanentPlugin" a little misleading because in most cases the plugin itself does nothing permanent but is just called once per client start per user session ;-))
In this case, the PermanentPlugin just registers an implementation (MyClipboardImpl) by its interface (MyClipboard) to be able to access that object "later".
Important: The clipboard object will be bound to the user session - so that is exactly what you need.
In your Executables you can now access that one session specific clipboard instance using the ServicesBroker from a broker/context (the broker is the one you get from the Executable's parameter map using the key "context")
//first Executable: Store some info
MyClipboard clipboard = broker.requireSpecialist(ServicesBroker.Type).getService(MyClipboard.class);
clipboard.storeInfo(someInfo);
//Second Executable: Get the information stored before
MyClipboard clipboard = broker.requireSpecialist(ServicesBroker.Type).getService(MyClipboard.class);
SomeClass info = clipboard.getInfo();
By the way, the "PermanentPlugin/ClientService" mechanism is a quite general one. This means it has (technically speaking) no special connection to Executables. In fact, it can be used to "connect" any types of plugins where you have some kind of client context.
Another application is to "centralize" client functionality in such a ClientService to be able to call it from different plugin types, so you don't have to implement the same functionality twice. This way it allows to implement some kind of "central controller instance".
Michael