|
Re: How can I force refresh Java service to reload it in Sirius? [message #1822540 is a reply to message #1822523] |
Mon, 09 March 2020 15:16 |
|
Hi Yufei,
As documented in https://www.eclipse.org/sirius/doc/specifier/general/Writing_Queries.html#service_methods, please remember that Quote:Java service methods should be stateless. There is no guarantee that two successive invocations of the same service method on two model elements (or even on the same one) will use the same instance of the service class.
You have no clue on when Sirius will call your constructor, so you should create a "configure" method that will be called by the constructor but also when your config model changes. For that you might put a listener to be notified on changes on this resource:
- Is this resource stored as an EMF model ? in this case it will be referenced from the session, and reloaded on changes by Sirius, then you would just have to provide a ResourceSyncClient for example to be notified from changes.
- If you file is a configuration file and not a model, you might add a org.eclipse.core.resources.IResourceChangeListener with ResourcesPlugin.getWorkspace().addResourceChangeListener(). If the org.eclipse.core.resources.IResourceChangeEvent comes from your resource, you will call your "configure" method
Regards
Maxime Porhel - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
|
Powered by
FUDForum. Page generated in 0.03352 seconds