> -----Original Message-----
> From: Chantale Caron [mailto:[EMAIL PROTECTED]]
> Sent: November 22, 2002 1:52 PM
> To: Graham Lounder
> Subject: Re: FW: Modifying ClassDescriptor
>
>
> Could you send this on the mailing list for me
> Thanks
>
> Thank you very much Armin, your suggestion was a great help to me. I
> still have to test my new code
> to make sure that everything works great though. Just to make sure
that
> I'm loading the repository correctly is this something like what you
had
> in mind for the readFromRepository method?
Exactly!
I did some minor changes. See my code below.
Please tell me if your test pass through, if so I
will check in this stuff in CVS.
Armin
public static DescriptorRepository readFromRepository(PBKey pbKey)
throws MetadataException
{
DescriptorRepository desRep = null;
RepositoryPersistor persistor = new RepositoryPersistor();
try
{
desRep = persistor.readFromFile(pbKey.getRepositoryFile());
prepareJdbcConnectionDescriptor(pbKey,
desRep.getDefaultJdbcConnection());
desRep.setPBKey(pbKey);
}
catch (Exception e)
{
LoggerFactory.getDefaultLogger().error(e);
throw new MetadataException(e);
}
return desRep;
}
/**
* Helper method: Because it's allowed to pass user/password with
the PBKey
* without declare it in the repository file, we had take care of it
* and replace the dummies from the repository.
*/
private static void prepareJdbcConnectionDescriptor(PBKey key,
JdbcConnectionDescriptor jcd)
{
if (key.getUser() != null)
{
jcd.setUserName(key.getUser());
jcd.setPassWord(key.getPassword());
}
}
>
> public DescriptorRepository readFromRepository(PBKey pbKey)
> {
> DescriptorRepository descriptor = null;
> try{
> RepositoryPersistor persistor = new RepositoryPersistor();
> descriptor =
> persistor.readFromFile(pbKey.getRepositoryFile());
> }catch(Exception exc){
> }
> return descriptor;
> }
>
> Thanks
>
>
> Graham Lounder wrote:
> >
> > -----Original Message-----
> > From: Armin Waibel [mailto:[EMAIL PROTECTED]]
> > Sent: November 22, 2002 11:22 AM
> > To: OJB Users List
> > Subject: Re: Modifying ClassDescriptor
> >
> > 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]>
>
> --
> Chantale Caron
> Java Developer
> Caris Spatial Components
> Tel: (506)462-4273
> Fax: (506)459-3849
> email: [EMAIL PROTECTED]
>
>
> --
> 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]>