the overrided attach/detach methods of the extended class of the CDOResourceImpl class not be called [message #1446302] |
Thu, 16 October 2014 16:50 |
Nguyen Viet Hoa Messages: 5 Registered: August 2013 |
Junior Member |
|
|
Hi everyone,
Firstly, i would like to explain my problem:
1. Problem: i created a plugin the permits to import papyrus models into the papyrus cdo model repository. For the purpose of overriding the attach/detach methods, i created a class that extends the CDOResourceImpl class. The problem is that, the attach/detach methods of my created class were not called when i add/delete elements of the models (because the created resources on the repository are instanceof the classic CDOReousrceImpl but not instancesof my created class).
2. What i did:
I created a PapyrusCDOResourceImpl class that extends the CDOResourceImpl class, and a resouce factory class :
class PapyrusCDOResourceFactoryImpl extends CDOResourceFactoryImpl
and then i tried to both register the resource factory class to the registry by using the ecore.protocole_parser extension point, and also register the registry programmatically like this:
Registry cdoReg = cdoTransaction_p.getResourceSet()
.getResourceFactoryRegistry();
Map<String, Object> protocolToFactoryMap = registry_p
.getProtocolToFactoryMap();
protocolToFactoryMap.remove(CDOProtocolConstants.PROTOCOL_NAME);
protocolToFactoryMap.put(CDOProtocolConstants.PROTOCOL_NAME,
new PapyrusCDOResourceFactoryImpl());
Thanks in advance for your help,
Kind Regards,
Hoa
|
|
|
Re: the overrided attach/detach methods of the extended class of the CDOResourceImpl class not be ca [message #1446355 is a reply to message #1446302] |
Thu, 16 October 2014 18:30 |
|
Hi, Hoa,
Have you had a look at what the org.eclipse.papyrus.cdo.core.importer
package offers for importing resources from the workspace into a CDO
repository? Why do you need to change the behaviour of the attached()
and detached() methods? What specific problem is that trying to solve?
Perhaps there is already a solution available, or a better path to a
solution.
Cheers,
Christian
On 2014-10-16 16:50:10 +0000, Nguyen Viet Hoa said:
> Hi everyone,
> Firstly, i would like to explain my problem:
>
> 1. Problem: i created a plugin the permits to import papyrus models
> into the papyrus cdo model repository. For the purpose of overriding
> the attach/detach methods, i created a class that extends the
> CDOResourceImpl class. The problem is that, the attach/detach methods
> of my created class were not called when i add/delete elements of the
> models (because the created resources on the repository are instanceof
> the classic CDOReousrceImpl but not instancesof my created class).
>
> 2. What i did:
>
> I created a PapyrusCDOResourceImpl class that extends the
> CDOResourceImpl class, and a resouce factory class :
> class PapyrusCDOResourceFactoryImpl extends CDOResourceFactoryImpl
>
> and then i tried to both register the resource factory class to the
> registry by using the ecore.protocole_parser extension point, and also
> register the registry programmatically like this:
> Registry cdoReg = cdoTransaction_p.getResourceSet()
> .getResourceFactoryRegistry();
> Map<String, Object> protocolToFactoryMap = registry_p
> .getProtocolToFactoryMap();
> protocolToFactoryMap.remove(CDOProtocolConstants.PROTOCOL_NAME);
> protocolToFactoryMap.put(CDOProtocolConstants.PROTOCOL_NAME,
> new PapyrusCDOResourceFactoryImpl());
>
> Thanks in advance for your help,
>
> Kind Regards,
>
> Hoa
|
|
|
|
Re: the overrided attach/detach methods of the extended class of the CDOResourceImpl class not be ca [message #1446885 is a reply to message #1446720] |
Fri, 17 October 2014 13:02 |
|
Hi, Hoa,
I see. I'm not sure that will work as you expect. CDO objects don't
have IDs assigned until they are committed. While they are in the
"transient" state they have non-unique local IDs that bear no
resemblance to what their IDs would be once they are persisted in the
server.
You will have better luck with a CDOCommitListener to detect what new
objects have been added in the transaction and get their IDs at that
time. Then you won't have to worry about resource implementations.
HTH,
Christian
On 2014-10-17 07:51:33 +0000, Nguyen Viet Hoa said:
> Hi Christian,
> Thank you so much for your quick response. I'll look at the the
> org.eclipse.papyrus.cdo.core.importer package.
> The reason for changing behavior of the attach/detach methods is that,
> i have another resource that contains the "cdo id" of the imported
> papyrus elements and this resource refers directly to the papyrus
> elements. I have to override the attach/detach methods to update this
> resource as soon as the PapyrusCDOResource change.
> Cheers,
>
> Hoa
|
|
|
|
Powered by
FUDForum. Page generated in 0.03417 seconds