-
Hi, For example: I have a custom Can someone give me a short code snipped how to fire a custom action event in GLSP Sever? The event is not consumed by the client. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 5 replies
-
Hi, you can define custom actions, register action handlers for them (ie for their type), and dispatch those actions via the action dispatcher that you can get injected in any class that is created by the DI framework.
I think there is more details on how to do all that in code in the documentation. Coincidentally there is also currently a PR open that adds, dispatches, and processes a server-to-server action (you can disregard that the handler is at the same time the action dispatcher): https://github.com/eclipse-glsp/glsp-server/pull/172/files
I'm not sure though this is the best approach for the use case you describe. I feel that for others to extend e.g. the properties of a GNode, dependency injection would be the better approach rather than sending actions and letting them register action handlers. You can for instance allow your clients to bind an implementation (or also multiple ones) against a certain interface that you then get injected as optional dependency in your GNodeBuilder. These injected implementations could then be required to implement a certain interface such as below and you invoke all registered implementations of that interface to add their properties if they want. public interface PropertyProvider {
void addProperties(GNode node);
} |
Beta Was this translation helpful? Give feedback.
-
@planger Thanks for your response. Yes I read the documentation but I was was not clear how to fire a Action. But now I think I understand the concept - injecting a GLSPActionDispatcher seems to be the trick. I will try out also your suggestion with the dependency injection of an interface. The funny development is, that I have completely distanced myself from the GNodes and mainly work now on the source model. The GModel only implements the BPMN standard elements. What I am currently doing is, that I define only the JSONForms Schemata holding the property information of a BPMN Element. The GNode does not know which properties are possible. On the client I just open a JSONForms panel in a very dynamic way displaying properties of the BPMN Element provided by the source model. In BPMN an Element can hold dozen of properties or only a few. The BPMN Extension mechanism just extends the properties processed by a workflow engine. The layout of a BPMN element is typically not affected from such extensions. This means, I just want to give a client the chance to describe which and how his own extensions should be handled by the property panel. This will become a super-generic approach which allows a very simple and powerful extension mechanism. Extending the GModel should not be necessary at all.... |
Beta Was this translation helpful? Give feedback.
-
@planger - I come back to your idea of using the Guice dependency mechanism for implementing a extension concept. I do not believe that this is working in a way I am thinking about. But my goal is, that a client will be able to run the OpenBPMN Modeller with a custom set of extensions. The client simply add Maven dependencies to build the OpenBPMN GLSP Server. He can add dependencies of multiple independent extension-providers. Of course he could now bind all the extensions, implemented by the different extension-providers. But this means, that he needs a deep knowledge about the extensions. At least he need to know the class names for the binding. In contrast, when I use a event/observer pattern like in JakartaEE, a extension-provider would implement a CDI observer bean in an independent Jar file. Adding the jar to some bigger implementation will ensure that the CDI observer bean is called when ever the main application fires the corresponding event type. In other words - my OpenBPMN GLSP Server module does not need to know the extension implementation. I know only the JakartaEE framework very well and not Guice. But I think the Guice Dependency mechanism is working like JakartaEE Bean Injection. The Injected CDI bean and the client know each other. In a Even/Observer pattern the two parts are more decoupled. And for now I understand that the ActionHandler concept is similar to this - at least I hope so |
Beta Was this translation helpful? Give feedback.
-
@planger - ok after digging deeper into guice I now understand that what I expected is not possible. Guice assumes that you bind your dependencies programmatically. This is, why I can add some maven dependencies from some external libraries to my Jakarta EE server app. This will provide new functionality without the need to register or configure this library in any way. And I expected the same magic in Guice. But Guice assumes that you know all implementations at compile time so you can programmatically bind your handlers and listeners. This is what we do in GLSP in the DiagramModule. So adding a external extension to my BPMN DiagramModule means I have to now the class at compile time (chicken and egg problem) But also with the GLSP Action Handler I run into the same problem. It looks to me that I always have to know the ActionHandler impl so that I can register it in my DiagramModule :-( So I came to the question: Is it possible to implement a independent module that simply listen to the GSLP server port (5007) for specific events? I guess this should be possible because the GLSP client does the same. Do you have already implemented something like this? |
Beta Was this translation helpful? Give feedback.
-
Yes, the OSGI approach seems a elegant solution. And I still can hold the door open for everyone who wants to extend the OpenBPMN Module directly with Guice dependencies. |
Beta Was this translation helpful? Give feedback.
@planger - ok after digging deeper into guice I now understand that what I expected is not possible.
Guice assumes that you bind your dependencies programmatically.
In JakartaEE we have this magic CDI Container which scans .jar files for CDI beans and binds them automatically.
This is, why I can add some maven dependencies from some external libraries to my Jakarta EE server app. This will provide new functionality without the need to register or configure this library in any way. And I expected the same magic in Guice. But Guice assumes that you know all implementations at compile time so you can programmatically bind your handlers and listeners. This is what we do in GLSP in the Diagram…