Hi Graham,

----- Original Message -----
From: "Graham Lounder" <[EMAIL PROTECTED]>
To: "OJB Users List" <[EMAIL PROTECTED]>
Sent: Friday, November 22, 2002 3:17 PM
Subject: Modifying ClassDescriptor


> I'm fairly new to This API and I have some questions regarding the
> ClassDescriptor.
>
> I'll first describe what I'm trying to achive ( if it's even possible
to do
> this)
>
> I've setup my repository_user.xml file to do cascade_delete = true for
most
> objects, but sometimes the user of the application may not want to
cascade
> delete.  I added a boolean variable to my methods to check if the user
wants
> to cascade delete or not.  If the user doesn't want to cascade delete,
I was
> pulling out the ClassDescriptor object from the instance of the broker
and
> modifying the ObjectReferenceDescriptors and the CollectionDescriptors
to
> cascade-delete=false.  Now once my operation is complete, I noticed
that the
> broker kept the modifications.  I tried to get a copy of the original
> ClassDescriptor to reset it on the broker before closing it but failed
this
> attempt.
>
> I'm not really sure at this point how the ClassDescriptor information
is
> stored in memory.

A few days ago, Thomas and I discuss (offline) the theme
"runtime repository changes" with the result that we have to do
a re-organistation of the repository stuff. We want to make it possible
to select between a 'perThread' and a 'global' modification of the
DescriptorRepository/ClassDescriptor/...
Any comments are welcome.

Currently each PBKey has a associated DescriptorRepository. All PB
with the same PBKey share the same DescriptorRepository. Thus if you
modify a ClassDescriptor, the changes take effect over all PB instances
with
the same PBKey, no good when run in multi-threaded environment.

A quick and dirty solution of your problem could be:
Add public method
DescriptorRepository#readFromRepository(PBKey pbKey)
This method returns a copy of the repository.
Extent PersistenceBrokerImpl and add method
setRepository(DescriptorRepository repository)
{
    this.descriptorRepository = repository;
}
Now you are able to change the repository of a single PB instance.
Get a copy, set the copy, modify the copy, do your work,
restore the old repository reference (for better performance:  undo
modification on copy, keep copy in memory).

HTH

I could add a public
DescriptorRepository#readFromRepository(PBKey pbKey)
method to CVS if you think this could be useful for you.

regards,
Armin

> I also tried for fun to create another instance of the
> broker inside this method and pull the ClassDescriptor as well to see
if it
> would be modified when I modified the other one and in deed it is
being
> modified.  This seems to tell me that all the brokers shared the safe
> reference to the ClassDescription object representing the mapping of
the xml
> file.
>
> I was able to reload the file and get the original version and set it
on the
> broker once I finished my operation.  But wouldn't this also modify
any
> other broker in progress and hence not give the user the results he is
> looking for in the end.
>
> I would really appreciate any help or information concerning this
issue.
>
> Thanks
>
> ============================================
>   Graham Lounder
>   Java Developer
>   Spatial Components Division
>   CARIS
>   264 Rookwood Ave
>   Fredericton NB E3B-2M2
>   Office 506 462-4263
>   Fax    506 459-3849
>   [EMAIL PROTECTED]
>   http://www.spatialcomponents.com
> ============================================
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to