Skip to content

Generation of Worker Functions

tuhin-github edited this page Dec 4, 2019 · 3 revisions

Why worker functions are not being generated in Papyrus?

The plugin extension shown below is declared in the "plugin.xml" file of the "com.zeligsoft.domain.dds4ccm" plugin. The editing domain id ("org.eclipse.gmf.runtime.emf.core.compatibility.MSLEditingDomain") used in this declaration represents an editing domain corresponds to the IBM UMLModeler class [2]. As the resource set listener class "DDS4CCMPortOperationsTrigger" is registered to this editing domain, it will receive notifications only for changes made to this editing domain.

<extension point="org.eclipse.emf.transaction.listeners">
   <listener class="com.zeligsoft.domain.dds4ccm.utils.DDS4CCMPortOperationsTrigger">
     <editingDomain id="org.eclipse.gmf.runtime.emf.core.compatibility.MSLEditingDomain">
     </editingDomain>
   </listener>
   <listener class="com.zeligsoft.domain.dds4ccm.utils.DDS4CCMMonolithicImplWFRepairer">
     <editingDomain id="org.eclipse.gmf.runtime.emf.core.compatibility.MSLEditingDomain">
     </editingDomain>
   </listener>
</extension>

For accessing the editing domain in RSA, we use the following line of code:

                    UMLModeler.getEditingDomain() 

Therefore, whenever any changes are made to this editing domain, a notification is sent to all the registered listeners and the actions defined in the listener class get executed. Worker functions get generated in this way whenever we create a new EObject. For example, whenever we create a new component, worker functions get generated for that component by calling appropriate methods in the "DDS4CCMPortOperationsTrigger" resource set listener class registered above.

In contrast, the editing domain we use in papyrus is created by the following line of code:

		TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(context); // 'context' is an EObject

As this editing domain is different from the UMLModeler editing domain, our resource set listener classes do not listen to any events triggered in this editing domain.

Suggestion to resolve the issue:

One way we can resolve this problem is by registering the editing domain we create with an ID and then use that ID to replace the UMLModeler editing domain ID, wherever it is used [1].

		TransactionalEditingDomain.Registry.INSTANCE.add("org.eclipse.papyrus.editingDomain", editingDomain);

With the registered editing domain in place, the extension point declaration shown above can be changed in the following way:

<extension point="org.eclipse.emf.transaction.listeners">
   <listener class="com.zeligsoft.domain.dds4ccm.utils.DDS4CCMPortOperationsTrigger">
     <editingDomain id="org.eclipse.papyrus.editingDomain">
     </editingDomain>
   </listener>
   <listener class="com.zeligsoft.domain.dds4ccm.utils.DDS4CCMMonolithicImplWFRepairer">
     <editingDomain id="org.eclipse.papyrus.editingDomain">
     </editingDomain>
   </listener>
</extension>

These changes allow the worker functions to be generated with the creation of a new CCMComponent.

References:
[1] Working with Transactional Editing Domains

[2] Declaring a Listener on a Registered Editing Domain


All the places in RSA code where editing domain with id "org.eclipse.gmf.runtime.emf.core.compatibility.MSLEditingDomain" is used are as follows:

  1. com.zeligsoft.base/plugin.xml
  • Listener class="com.zeligsoft.base.util.EMFNotificationBroker"
  1. com.zeligsoft.base.zdl/plugin.xml
  • Listener class="com.zeligsoft.base.zdl.listeners.ZDLElementTypeResourceSetListener"
  1. com.zeligsoft.cx.deployment.ui/plugin.xml
  • Listener class="com.zeligsoft.cx.deployment.ui.listeners.DeploymentEMFNotificationBroker"
  1. com.zeligsoft.domain.dds4ccm/plugin.xml
  • Listener class="com.zeligsoft.domain.dds4ccm.utils.DDS4CCMPortOperationsTrigger"
  • Listener class="com.zeligsoft.domain.dds4ccm.utils.DDS4CCMMonolithicImplWFRepairer"
  1. com.zeligsoft.domain.dds4ccm.ui/plugin.xml
  • Listener class="com.zeligsoft.domain.dds4ccm.ui.listeners.CCMPartMoveOperationListener"
  1. com.zeligsoft.domain.zml/plugin.xml
  • Listener class="com.zeligsoft.domain.zml.util.PortOperationsTrigger"
Clone this wiki locally