accessorKeys for EditModels [message #45760] |
Mon, 27 September 2004 10:33  |
Eclipse User |
|
|
|
Originally posted by: dave_gray.versata.com
In the IBM supplied web tools, access to EditModel objects now requires an
"accessorKey". This was not used in the WSAD 5.0 version of these classes.
I assume the key is needed for some sort of consistency control.
These keys are typed simply as Objects. Any advice on how they are
selected? How unique should they be?
|
|
|
Re: accessorKeys for EditModels [message #46972 is a reply to message #45760] |
Wed, 29 September 2004 14:52  |
Eclipse User |
|
|
|
Hi Dave,
"Accessor Keys" are used to track reference counts to Edit models.
Whenever you get an edit model for read or for write, the edit model will
save this "token" and remember where the edit model was accessed (e.g.
isolate the code path). We hold onto this accessor key in case you either
forget to release the edit model or you try to access the edit model again
when you have already accessed it.
You will see exceptions if you access the edit model again with the same
object (INVALID_ACCESS) or you fail to release the edit model and your
object is garbage collected (DANGLING_REFERENCE). You should always release
the edit model in a try ... finally block.
For example:
EJBEditModel ejbEditModel;
EJBNatureRuntime ejbNature;
...
try {
// create or get project
IProject ejbProject = ...;
// acquire the Nature
ejbNature = EJBNatureRuntime.getRuntime(ejbProject);
// an Accessor Key, "this", must be supplied to the Nature to access the
Edit Model
ejbEditModel = ejbNature.getEJBEditModelForWrite(this);
// work with Edit Model
...
} finally {
// the Accessor Key "this" must be used to release access to the Edit
Model
if(ejbEditModel != null)
ejbEditModel.releaseAccess(this);
}
In static contexts, you can create a simple new Object() reference, but be
sure that you release this or you will begin to see exceptions.
DANGLING_REFERENCE exceptions actually show you the code path (stack trace)
where the edit model was originally accessed.
Kind Regards,
Michael D. Elder
"Dave" <dave_gray@versata.com> wrote in message
news:cj98c1$t7m$1@eclipse.org...
> In the IBM supplied web tools, access to EditModel objects now requires an
> "accessorKey". This was not used in the WSAD 5.0 version of these classes.
> I assume the key is needed for some sort of consistency control.
>
> These keys are typed simply as Objects. Any advice on how they are
> selected? How unique should they be?
>
|
|
|
Powered by
FUDForum. Page generated in 0.04055 seconds