Re: [mdr-users] custom implementation recycling?

Martin Matula <[email protected]>
Newsgroups gmane.comp.java.netbeans.modules.mdr.user
Message-ID <[email protected]>
SainTiss wrote:

>Apparently, it's got more to do with garbage collection being handled differently on different systems, instead of different JDK's as I erroneously thought...
>
>Point is, I was trying to add an attribute to the custom implementation, which is not present in the MOF model... So obviously I would need the same custom implementation be associated with the same JMI object all the time, otherwise the value of my additional attribute wouldn't be preserved...
>
>Unfortunately, it seems that these custom implementation wrappers can be garbage collected when there is no reference to them or their wrapped JMI object in scope. If I keep a reference to the custom implementation wrapper, then it seems like the JMI object is assigned the same wrapper if it's fetched from MDR later on... But I'm not sure if I can count on that... 
>
Yes, you can count on that. This is how it works.

>Also, keeping references to these wrappers isn't the most pretty solution...
>
>Is there a solution/workaround here?
>  
>
A better solution would be to use getSlotX()/setSlotX() methods in the 
underlying storable object to store the value of the additional 
attribute - this way you can be sure the value is persisted with the 
values of other modeled attributes.
Your custom impl. code could look like this:

public void setAttribute(String value) {
    _getDelegate().setSlot1(value);
}

public String getAttribute() {
    return (String) _getDelegate().getSlot1();
}

Regards,
Martin
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.