You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by ABOU LINA <am...@gmail.com> on 2006/05/24 12:26:09 UTC

Using two mapping file in the same project ?

Hi;

i have two mapping file : repository1.xml and repository2.xml.

the difference between these two file are the value of auto-*
[auto-retrieve, auto-update ..] ; at runtime sometimes i need to use
repository1.xml and somtimes the repository2.xml .

what is the best and optimal  solution  about this conf ???

thx in advance

Re: Using two mapping file in the same project ?

Posted by Armin Waibel <ar...@apache.org>.
Hi,

ABOU LINA wrote:
> It have a big impact !!! ; beacause in DTD they are lot of initialisation
> (default value)....
> 
> so here i tried all solutions :(
> 
> if you can send me a example that work , i will be greatfull
> 

I just checked in a test MetadataTest#testReadRepository() which use a 
InputStream to read a mapping file.

The class:
http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/metadata/MetadataTest.java?view=markup

The file to read:
http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/Test_ClassDescriptor.xml?view=markup

Did you check the used parser? Is it the same shipped with OJB?

regards,
Armin


> thx
> 
> On 5/31/06, ABOU LINA <am...@gmail.com> wrote:
>>
>> Hi,
>> i need to use InputStream so i tested a lot but i got the same error
>> repository.dtd not found. so i delete the DOCTYPE from the secondary
>> repository file it work without problem. In your opinion is that a good
>> things or this solution will have any impact on my application ..... ???
>>
>> thx
>>
>>
>>
>> On 5/25/06, Armin Waibel <ar...@apache.org> wrote:
>> >
>> > ABOU LINA wrote:
>> > > i tested the two way but i got the same problem : dtd not found .
>> > >
>> > >            InputStream input = this.getClass
>> > > ().getClassLoader().getResourceAsStream(descriptor2);
>> > >            MetadataManager mm = MetadataManager.getInstance();
>> > >            mm.setEnablePerThreadChanges(true);
>> > >            DescriptorRepository dr_1 = mm.readDescriptorRepository
>> > (input);
>> > >
>> > > at readDescriptorRepository(InputStream) i got the message error
>> > >
>> >
>> > Strange! If the DOCTYPE is set correctly in mapping.xml I would assume
>> > that it's a parser problem, because the .xml file was found.
>> > Did you try to read the second repository via relative/absolute path
>> > string?
>> > mm.readDescriptorRepository("mapping.xml");
>> > mm.readDescriptorRepository("c:/.../mapping.xml");
>> >
>> > regards,
>> > Armin
>> >
>> >
>> > >
>> > >
>> > >
>> > > On 5/24/06, Armin Waibel < arminw@apache.org> wrote:
>> > >>
>> > >> ABOU LINA wrote:
>> > >> > is in the same place :
>> > >> >
>> > >> > project-name/appli-conf  /  mappin2.xml , repository.dtd
>> > >> >
>> > >> > and the project-name/appli-conf is in the classpath.
>> > >> >
>> > >> > the mappin2.xml is retrieved with success but the dtd is not found
>> > and
>> > >> ojb
>> > >> > try
>> > >> > to found it from c:\eclipse\ the base directory. !!!
>> > >> >
>> > >>
>> > >> locally I setup a similar test. This test pass.
>> > >> Did you correctly set the doctype instruction in mapping2.xml (e.g.
>> > >> typo)?
>> > >>
>> > >> Both settings work for my local test:
>> > >>
>> > >> <?xml version="1.0" encoding="UTF-8"?>
>> > >> <!DOCTYPE descriptor-repository SYSTEM "repository.dtd">
>> > >> <descriptor-repository version=" 1.0"
>> > isolation-level="read-uncommitted"
>> > >> proxy-prefetching-limit="50">
>> > >>   ...
>> > >> />
>> > >>
>> > >> or
>> > >>
>> > >> <?xml version="1.0 " encoding="UTF-8"?>
>> > >> <!DOCTYPE descriptor-repository PUBLIC
>> > >>         "-//Apache Software Foundation//DTD OJB Repository//EN"
>> > >>         "repository.dtd"
>> > >> [
>> > >> ...
>> > >> ]>
>> > >> <descriptor-repository version="1.0"
>> > isolation-level="read-uncommitted"
>> > >>          proxy-prefetching-limit="50">
>> > >> ...
>> > >> />
>> > >>
>> > >> regards,
>> > >> Armin
>> > >>
>> > >>
>> > >> >
>> > >> >
>> > >> > On 5/24/06, Armin Waibel < arminw@apache.org> wrote:
>> > >> >>
>> > >> >> ABOU LINA wrote:
>> > >> >> > I have a problem to load the new profile :
>> > >> >> >
>> > >> >> > 1. i  put the mapping2.xml in the classpath of the project
>> > >> >> > 2. i use the mm.readDescriptorRepository(InputStream map)
>> > insteadof
>> > >> >> (String
>> > >> >> > map)
>> > >> >> >
>> > >> >> > i get : java.io.FileNoteFound : c:\eclipse\repository.dtd   ...
>> > !
>> > >> >> >
>> > >> >> > if i used InputStream is beacause i want to make access to the
>> > >> >> > mapping2.xmlfrom the classpath , but the parser used in ojb is
>> > >> looking
>> > >> >> > the dtd from a
>> > >> >> > base directory !!!
>> > >> >> >
>> > >> >> > any idea .
>> > >> >>
>> > >> >> Put the repository.dtd in the same place as mapping2.xml
>> > >> >>
>> > >> >> regards,
>> > >> >> Armin
>> > >> >>
>> > >> >>
>> > >> >> >
>> > >> >> > thx in advance
>> > >> >> >
>> > >> >> > On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
>> > >> >> >>
>> > >> >> >> ABOU LINA wrote:
>> > >> >> >> > That's very good idea using threadLocal :) , thx very much
>> > about
>> > >> >> these
>> > >> >> >> > informations :).
>> > >> >> >> >
>> > >> >> >>
>> > >> >> >> My pleasure!
>> > >> >> >> All code for "metadata profiles" (by using ThreadLocale) is
>> > handled
>> > >> by
>> > >> >> >> class MetadataManager. If you have problems using "metadata
>> > >> profiles"
>> > >> >> >> look at this class.
>> > >> >> >>
>> > >> >> >>
>> > >> >>
>> > >> 
>> http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/MetadataManager.java?view=markup 
>>
>> >
>> > >>
>> > >> >>
>> > >> >> >>
>> > >> >> >>
>> > >> >> >>
>> > >> >> >> In MetadataManager the use of metadata profiles is explained
>> > too
>> > >> >> >>
>> > >> >> >>
>> > >> >>
>> > >> 
>> http://db.apache.org/ojb/api/org/apache/ojb/broker/metadata/MetadataManager.html 
>>
>> >
>> > >>
>> > >> >>
>> > >> >> >>
>> > >> >> >>
>> > >> >> >>
>> > >> >> >> regards,
>> > >> >> >> Armin
>> > >> >> >>
>> > >> >> >> >
>> > >> >> >> >
>> > >> >> >> > On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
>> > >> >> >> >>
>> > >> >> >> >> ABOU LINA wrote:
>> > >> >> >> >> > thx for your reply .
>> > >> >> >> >> >
>> > >> >> >> >> > looking the example :
>> > >> >> >> >> >
>> > >> >> >> >> > // get MetadataManager instance
>> > >> >> >> >> (1) > MetadataManager mm = MetadataManager.getInstance();
>> > >> >> >> >> >
>> > >> >> >> >> > // enable per thread mode if not done before
>> > >> >> >> >> > mm.setEnablePerThreadChanges(true);
>> > >> >> >> >> >
>> > >> >> >> >> (2) > // Load additional object metadata by parsing an
>> > >> repository
>> > >> >> file
>> > >> >> >> >> > DescriptorRepository dr_1 =
>> > >> >> >> >> > mm.readDescriptorRepository("pathOrURLtoFile_1");
>> > >> >> >> >> > DescriptorRepository dr_2 =
>> > >> >> >> >> > mm.readDescriptorRepository ("pathOrURLtoFile_2");
>> > >> >> >> >> >
>> > >> >> >> >> (3) > // add  profiles
>> > >> >> >> >> > mm.addProfile("global", mm.copyOfGlobalRepository ());
>> > >> >> >> >> > mm.addProfile("guest", dr_1);
>> > >> >> >> >> > mm.addProfile("admin", dr_2);
>> > >> >> >> >> >
>> > >> >> >> >> (4) > // now load a specific profile
>> > >> >> >> >> > mm.loadProfile("admin");
>> > >> >> >> >> (5) > broker =
>> > PersistenceBrokerFactory.defaultPersistenceBroker
>> > >> ();
>> > >> >> >> >> >
>> > >> >> >> >> >
>> > >> >> >> >> > MetaManager is a singleton i think. so in this case we
>> > will
>> > >> >> have a
>> > >> >> >> >> > probleme with
>> > >> >> >> >> > concurence access. if user A loadProfile("guest") and 
>> just
>> > >> after
>> > >> >> >> >> > loading guest profile another user B (profile admin)
>> > >> >> >> >> > execute broker =
>> > >> >> >> PersistenceBrokerFactory.defaultPersistenceBroker();
>> > >> >> >> >> > so in this situation
>> > >> >> >> >> > B got a broker with profile admin because MetaManager 
>> is a
>> >
>> > >> >> >> singleton.
>> > >> >> >> >> >
>> > >> >> >> >> > is right ????
>> > >> >> >> >>
>> > >> >> >> >> If each user (thread) use a different broker instance no.
>> > All
>> > >> steps
>> > >> >> >> from
>> > >> >> >> >> (1) to (3) have to be done once at startup of your
>> > application.
>> > >> >> >> Thus no
>> > >> >> >> >> concurrency issues are expected.
>> > >> >> >> >>
>> > >> >> >> >> With step (4) the calling thread was associated with a
>> > specific
>> > >> >> >> profile
>> > >> >> >> >> (using ThreadLocale). This call have to be done for each
>> > thread
>> > >> to
>> > >> >> >> load
>> > >> >> >> >> the correct profile. Take care when using thread-pools
>> > (think
>> > >> e.g
>> > >> .
>> > >> >> >> >> Tomcat use it) to reassign the correct profile for each
>> > calling
>> > >> >> user.
>> > >> >> >> >> When OJB returns the broker instance (5) the profile for 
>> the
>> > >> >> current
>> > >> >> >> >> thread was associated.
>> > >> >> >> >>
>> > >> >> >> >> In OJB test-suite we test the use of different metadata
>> > profiles
>> > >> in
>> > >> >> >> >> MetadataMultithreadedTest and never detect problems with
>> > this
>> > >> >> feature.
>> > >> >> >> >>
>> > >> >> >> >> Again if user A and B (different threads) use different
>> > broker
>> > >> >> >> instances
>> > >> >> >> >> no concurrency issues are expected.
>> > >> >> >> >>
>> > >> >> >> >> regards,
>> > >> >> >> >> Armin
>> > >> >> >> >>
>> > >> >> >> >>
>> > >> >> >> >>
>> > >> >> >> >> >
>> > >> >> >> >> >
>> > >> >> >> >> >
>> > >> >> >> >> >
>> > >> >> >> >> >
>> > >> >> >> >> >
>> > >> >> >> >> > On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
>> > >> >> >> >> >>
>> > >> >> >> >> >> Hi,
>> > >> >> >> >> >>
>> > >> >> >> >> >> ABOU LINA wrote:
>> > >> >> >> >> >> > Hi;
>> > >> >> >> >> >> >
>> > >> >> >> >> >> > i have two mapping file : repository1.xml and
>> > >> repository2.xml.
>> > >> >> >> >> >> >
>> > >> >> >> >> >> > the difference between these two file are the value of
>> > >> auto-*
>> > >> >> >> >> >> > [auto-retrieve, auto-update ..] ; at runtime sometimes
>> > i
>> > >> need
>> > >> >> to
>> > >> >> >> use
>> > >> >> >> >> >> > repository1.xml and somtimes the repository2.xml .
>> > >> >> >> >> >> >
>> > >> >> >> >> >> > what is the best and optimal  solution  about this 
>> conf
>> > ???
>> > >> >> >> >> >> >
>> > >> >> >> >> >>
>> > >> >> >> >> >> You can use metadata profiles on per thread base.
>> > >> >> >> >> >>
>> > >> >> >> >> >>
>> > >> >> >> >>
>> > >> >> >>
>> > >> >>
>> > >>
>> > 
>> http://db.apache.org/ojb/docu/guides/metadata.html#Per+thread+metadata+changes 
>>
>> > >>
>> > >> >>
>> > >> >> >>
>> > >> >> >> >>
>> > >> >> >> >> >>
>> > >> >> >> >> >>
>> > >> >> >> >> >>
>> > >> >> >> >> >>
>> > >> >> >> >>
>> > >> >> >>
>> > >> >>
>> > >>
>> > 
>> http://db.apache.org/ojb/docu/guides/metadata.html#Object+metadata+profiles 
>>
>> > >>
>> > >> >>
>> > >> >> >>
>> > >> >> >> >>
>> > >> >> >> >> >>
>> > >> >> >> >> >>
>> > >> >> >> >> >> This way you can load a specific metadata profiles
>> > >> >> >> (repository1.xmlor
>> > >> >> >> >> >> repository2.xml) for the current thread.
>> > >> >> >> >> >>
>> > >> >> >> >> >> Take care of caching issues, e.g. obj1 from rep1 was 
>> used
>> > in
>> > >> >> rep2
>> > >> >> >> >> >> environment will cause undetermined behavior. Thus it's
>> > >> >> recommended
>> > >> >> >> to
>> > >> >> >> >> >> use the two-level cache or only a session based (per
>> > broker)
>> > >> >> cache.
>> > >> >> >> >> >>
>> > >> >> >> >> >> regards,
>> > >> >> >> >> >> Armin
>> > >> >> >> >> >>
>> > >> >> >> >> >>
>> > >> >> >> >> >> > thx in advance
>> > >> >> >> >> >> >
>> > >> >> >> >> >>
>> > >> >> >> >> >>
>> > >> >> >>
>> > >> 
>> ---------------------------------------------------------------------
>> >
>> > >> >> >> >> >> To unsubscribe, e-mail:
>> > ojb-user-unsubscribe@db.apache.org
>> > >> >> >> >> >> For additional commands, e-mail:
>> > ojb-user-help@db.apache.org
>> > >> >> >> >> >>
>> > >> >> >> >> >>
>> > >> >> >> >> >
>> > >> >> >> >>
>> > >> >> >> >>
>> > >> >>
>> > ---------------------------------------------------------------------
>> > >> >> >> >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> > >> >> >> >> For additional commands, e-mail: 
>> ojb-user-help@db.apache.org
>> > >> >> >> >>
>> > >> >> >> >>
>> > >> >> >> >
>> > >> >> >>
>> > >> >> >>
>> > >> 
>> ---------------------------------------------------------------------
>> > >> >> >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> > >> >> >> For additional commands, e-mail: ojb-user-help@db.apache.org
>> > >> >> >>
>> > >> >> >>
>> > >> >> >
>> > >> >>
>> > >> >>
>> > ---------------------------------------------------------------------
>> > >> >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> > >> >> For additional commands, e-mail: ojb-user-help@db.apache.org
>> > >> >>
>> > >> >>
>> > >> >
>> > >>
>> > >> 
>> ---------------------------------------------------------------------
>> > >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> > >> For additional commands, e-mail: ojb-user-help@db.apache.org
>> > >>
>> > >>
>> > >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> > For additional commands, e-mail: ojb-user-help@db.apache.org
>> >
>> >
>>
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Using two mapping file in the same project ?

Posted by ABOU LINA <am...@gmail.com>.
It have a big impact !!! ; beacause in DTD they are lot of initialisation
(default value)....

so here i tried all solutions :(

if you can send me a example that work , i will be greatfull

thx

On 5/31/06, ABOU LINA <am...@gmail.com> wrote:
>
> Hi,
> i need to use InputStream so i tested a lot but i got the same error
> repository.dtd not found. so i delete the DOCTYPE from the secondary
> repository file it work without problem. In your opinion is that a good
> things or this solution will have any impact on my application ..... ???
>
> thx
>
>
>
> On 5/25/06, Armin Waibel <ar...@apache.org> wrote:
> >
> > ABOU LINA wrote:
> > > i tested the two way but i got the same problem : dtd not found .
> > >
> > >            InputStream input = this.getClass
> > > ().getClassLoader().getResourceAsStream(descriptor2);
> > >            MetadataManager mm = MetadataManager.getInstance();
> > >            mm.setEnablePerThreadChanges(true);
> > >            DescriptorRepository dr_1 = mm.readDescriptorRepository
> > (input);
> > >
> > > at readDescriptorRepository(InputStream) i got the message error
> > >
> >
> > Strange! If the DOCTYPE is set correctly in mapping.xml I would assume
> > that it's a parser problem, because the .xml file was found.
> > Did you try to read the second repository via relative/absolute path
> > string?
> > mm.readDescriptorRepository("mapping.xml");
> > mm.readDescriptorRepository("c:/.../mapping.xml");
> >
> > regards,
> > Armin
> >
> >
> > >
> > >
> > >
> > > On 5/24/06, Armin Waibel < arminw@apache.org> wrote:
> > >>
> > >> ABOU LINA wrote:
> > >> > is in the same place :
> > >> >
> > >> > project-name/appli-conf  /  mappin2.xml , repository.dtd
> > >> >
> > >> > and the project-name/appli-conf is in the classpath.
> > >> >
> > >> > the mappin2.xml is retrieved with success but the dtd is not found
> > and
> > >> ojb
> > >> > try
> > >> > to found it from c:\eclipse\ the base directory. !!!
> > >> >
> > >>
> > >> locally I setup a similar test. This test pass.
> > >> Did you correctly set the doctype instruction in mapping2.xml (e.g.
> > >> typo)?
> > >>
> > >> Both settings work for my local test:
> > >>
> > >> <?xml version="1.0" encoding="UTF-8"?>
> > >> <!DOCTYPE descriptor-repository SYSTEM "repository.dtd">
> > >> <descriptor-repository version=" 1.0"
> > isolation-level="read-uncommitted"
> > >> proxy-prefetching-limit="50">
> > >>   ...
> > >> />
> > >>
> > >> or
> > >>
> > >> <?xml version="1.0 " encoding="UTF-8"?>
> > >> <!DOCTYPE descriptor-repository PUBLIC
> > >>         "-//Apache Software Foundation//DTD OJB Repository//EN"
> > >>         "repository.dtd"
> > >> [
> > >> ...
> > >> ]>
> > >> <descriptor-repository version="1.0"
> > isolation-level="read-uncommitted"
> > >>          proxy-prefetching-limit="50">
> > >> ...
> > >> />
> > >>
> > >> regards,
> > >> Armin
> > >>
> > >>
> > >> >
> > >> >
> > >> > On 5/24/06, Armin Waibel < arminw@apache.org> wrote:
> > >> >>
> > >> >> ABOU LINA wrote:
> > >> >> > I have a problem to load the new profile :
> > >> >> >
> > >> >> > 1. i  put the mapping2.xml in the classpath of the project
> > >> >> > 2. i use the mm.readDescriptorRepository(InputStream map)
> > insteadof
> > >> >> (String
> > >> >> > map)
> > >> >> >
> > >> >> > i get : java.io.FileNoteFound : c:\eclipse\repository.dtd   ...
> > !
> > >> >> >
> > >> >> > if i used InputStream is beacause i want to make access to the
> > >> >> > mapping2.xmlfrom the classpath , but the parser used in ojb is
> > >> looking
> > >> >> > the dtd from a
> > >> >> > base directory !!!
> > >> >> >
> > >> >> > any idea .
> > >> >>
> > >> >> Put the repository.dtd in the same place as mapping2.xml
> > >> >>
> > >> >> regards,
> > >> >> Armin
> > >> >>
> > >> >>
> > >> >> >
> > >> >> > thx in advance
> > >> >> >
> > >> >> > On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
> > >> >> >>
> > >> >> >> ABOU LINA wrote:
> > >> >> >> > That's very good idea using threadLocal :) , thx very much
> > about
> > >> >> these
> > >> >> >> > informations :).
> > >> >> >> >
> > >> >> >>
> > >> >> >> My pleasure!
> > >> >> >> All code for "metadata profiles" (by using ThreadLocale) is
> > handled
> > >> by
> > >> >> >> class MetadataManager. If you have problems using "metadata
> > >> profiles"
> > >> >> >> look at this class.
> > >> >> >>
> > >> >> >>
> > >> >>
> > >> http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/MetadataManager.java?view=markup
> >
> > >>
> > >> >>
> > >> >> >>
> > >> >> >>
> > >> >> >>
> > >> >> >> In MetadataManager the use of metadata profiles is explained
> > too
> > >> >> >>
> > >> >> >>
> > >> >>
> > >> http://db.apache.org/ojb/api/org/apache/ojb/broker/metadata/MetadataManager.html
> >
> > >>
> > >> >>
> > >> >> >>
> > >> >> >>
> > >> >> >>
> > >> >> >> regards,
> > >> >> >> Armin
> > >> >> >>
> > >> >> >> >
> > >> >> >> >
> > >> >> >> > On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
> > >> >> >> >>
> > >> >> >> >> ABOU LINA wrote:
> > >> >> >> >> > thx for your reply .
> > >> >> >> >> >
> > >> >> >> >> > looking the example :
> > >> >> >> >> >
> > >> >> >> >> > // get MetadataManager instance
> > >> >> >> >> (1) > MetadataManager mm = MetadataManager.getInstance();
> > >> >> >> >> >
> > >> >> >> >> > // enable per thread mode if not done before
> > >> >> >> >> > mm.setEnablePerThreadChanges(true);
> > >> >> >> >> >
> > >> >> >> >> (2) > // Load additional object metadata by parsing an
> > >> repository
> > >> >> file
> > >> >> >> >> > DescriptorRepository dr_1 =
> > >> >> >> >> > mm.readDescriptorRepository("pathOrURLtoFile_1");
> > >> >> >> >> > DescriptorRepository dr_2 =
> > >> >> >> >> > mm.readDescriptorRepository ("pathOrURLtoFile_2");
> > >> >> >> >> >
> > >> >> >> >> (3) > // add  profiles
> > >> >> >> >> > mm.addProfile("global", mm.copyOfGlobalRepository ());
> > >> >> >> >> > mm.addProfile("guest", dr_1);
> > >> >> >> >> > mm.addProfile("admin", dr_2);
> > >> >> >> >> >
> > >> >> >> >> (4) > // now load a specific profile
> > >> >> >> >> > mm.loadProfile("admin");
> > >> >> >> >> (5) > broker =
> > PersistenceBrokerFactory.defaultPersistenceBroker
> > >> ();
> > >> >> >> >> >
> > >> >> >> >> >
> > >> >> >> >> > MetaManager is a singleton i think. so in this case we
> > will
> > >> >> have a
> > >> >> >> >> > probleme with
> > >> >> >> >> > concurence access. if user A loadProfile("guest") and just
> > >> after
> > >> >> >> >> > loading guest profile another user B (profile admin)
> > >> >> >> >> > execute broker =
> > >> >> >> PersistenceBrokerFactory.defaultPersistenceBroker();
> > >> >> >> >> > so in this situation
> > >> >> >> >> > B got a broker with profile admin because MetaManager is a
> >
> > >> >> >> singleton.
> > >> >> >> >> >
> > >> >> >> >> > is right ????
> > >> >> >> >>
> > >> >> >> >> If each user (thread) use a different broker instance no.
> > All
> > >> steps
> > >> >> >> from
> > >> >> >> >> (1) to (3) have to be done once at startup of your
> > application.
> > >> >> >> Thus no
> > >> >> >> >> concurrency issues are expected.
> > >> >> >> >>
> > >> >> >> >> With step (4) the calling thread was associated with a
> > specific
> > >> >> >> profile
> > >> >> >> >> (using ThreadLocale). This call have to be done for each
> > thread
> > >> to
> > >> >> >> load
> > >> >> >> >> the correct profile. Take care when using thread-pools
> > (think
> > >> e.g
> > >> .
> > >> >> >> >> Tomcat use it) to reassign the correct profile for each
> > calling
> > >> >> user.
> > >> >> >> >> When OJB returns the broker instance (5) the profile for the
> > >> >> current
> > >> >> >> >> thread was associated.
> > >> >> >> >>
> > >> >> >> >> In OJB test-suite we test the use of different metadata
> > profiles
> > >> in
> > >> >> >> >> MetadataMultithreadedTest and never detect problems with
> > this
> > >> >> feature.
> > >> >> >> >>
> > >> >> >> >> Again if user A and B (different threads) use different
> > broker
> > >> >> >> instances
> > >> >> >> >> no concurrency issues are expected.
> > >> >> >> >>
> > >> >> >> >> regards,
> > >> >> >> >> Armin
> > >> >> >> >>
> > >> >> >> >>
> > >> >> >> >>
> > >> >> >> >> >
> > >> >> >> >> >
> > >> >> >> >> >
> > >> >> >> >> >
> > >> >> >> >> >
> > >> >> >> >> >
> > >> >> >> >> > On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
> > >> >> >> >> >>
> > >> >> >> >> >> Hi,
> > >> >> >> >> >>
> > >> >> >> >> >> ABOU LINA wrote:
> > >> >> >> >> >> > Hi;
> > >> >> >> >> >> >
> > >> >> >> >> >> > i have two mapping file : repository1.xml and
> > >> repository2.xml.
> > >> >> >> >> >> >
> > >> >> >> >> >> > the difference between these two file are the value of
> > >> auto-*
> > >> >> >> >> >> > [auto-retrieve, auto-update ..] ; at runtime sometimes
> > i
> > >> need
> > >> >> to
> > >> >> >> use
> > >> >> >> >> >> > repository1.xml and somtimes the repository2.xml .
> > >> >> >> >> >> >
> > >> >> >> >> >> > what is the best and optimal  solution  about this conf
> > ???
> > >> >> >> >> >> >
> > >> >> >> >> >>
> > >> >> >> >> >> You can use metadata profiles on per thread base.
> > >> >> >> >> >>
> > >> >> >> >> >>
> > >> >> >> >>
> > >> >> >>
> > >> >>
> > >>
> > http://db.apache.org/ojb/docu/guides/metadata.html#Per+thread+metadata+changes
> > >>
> > >> >>
> > >> >> >>
> > >> >> >> >>
> > >> >> >> >> >>
> > >> >> >> >> >>
> > >> >> >> >> >>
> > >> >> >> >> >>
> > >> >> >> >>
> > >> >> >>
> > >> >>
> > >>
> > http://db.apache.org/ojb/docu/guides/metadata.html#Object+metadata+profiles
> > >>
> > >> >>
> > >> >> >>
> > >> >> >> >>
> > >> >> >> >> >>
> > >> >> >> >> >>
> > >> >> >> >> >> This way you can load a specific metadata profiles
> > >> >> >> (repository1.xmlor
> > >> >> >> >> >> repository2.xml) for the current thread.
> > >> >> >> >> >>
> > >> >> >> >> >> Take care of caching issues, e.g. obj1 from rep1 was used
> > in
> > >> >> rep2
> > >> >> >> >> >> environment will cause undetermined behavior. Thus it's
> > >> >> recommended
> > >> >> >> to
> > >> >> >> >> >> use the two-level cache or only a session based (per
> > broker)
> > >> >> cache.
> > >> >> >> >> >>
> > >> >> >> >> >> regards,
> > >> >> >> >> >> Armin
> > >> >> >> >> >>
> > >> >> >> >> >>
> > >> >> >> >> >> > thx in advance
> > >> >> >> >> >> >
> > >> >> >> >> >>
> > >> >> >> >> >>
> > >> >> >>
> > >> ---------------------------------------------------------------------
> >
> > >> >> >> >> >> To unsubscribe, e-mail:
> > ojb-user-unsubscribe@db.apache.org
> > >> >> >> >> >> For additional commands, e-mail:
> > ojb-user-help@db.apache.org
> > >> >> >> >> >>
> > >> >> >> >> >>
> > >> >> >> >> >
> > >> >> >> >>
> > >> >> >> >>
> > >> >>
> > ---------------------------------------------------------------------
> > >> >> >> >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> > >> >> >> >> For additional commands, e-mail: ojb-user-help@db.apache.org
> > >> >> >> >>
> > >> >> >> >>
> > >> >> >> >
> > >> >> >>
> > >> >> >>
> > >> ---------------------------------------------------------------------
> > >> >> >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> > >> >> >> For additional commands, e-mail: ojb-user-help@db.apache.org
> > >> >> >>
> > >> >> >>
> > >> >> >
> > >> >>
> > >> >>
> > ---------------------------------------------------------------------
> > >> >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> > >> >> For additional commands, e-mail: ojb-user-help@db.apache.org
> > >> >>
> > >> >>
> > >> >
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> > >> For additional commands, e-mail: ojb-user-help@db.apache.org
> > >>
> > >>
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: ojb-user-help@db.apache.org
> >
> >
>

Re: Using two mapping file in the same project ?

Posted by ABOU LINA <am...@gmail.com>.
Hi,
i need to use InputStream so i tested a lot but i got the same error
repository.dtd not found. so i delete the DOCTYPE from the secondary
repository file it work without problem. In your opinion is that a good
things or this solution will have any impact on my application ..... ???

thx


On 5/25/06, Armin Waibel <ar...@apache.org> wrote:
>
> ABOU LINA wrote:
> > i tested the two way but i got the same problem : dtd not found .
> >
> >            InputStream input = this.getClass
> > ().getClassLoader().getResourceAsStream(descriptor2);
> >            MetadataManager mm = MetadataManager.getInstance();
> >            mm.setEnablePerThreadChanges(true);
> >            DescriptorRepository dr_1 = mm.readDescriptorRepository
> (input);
> >
> > at readDescriptorRepository(InputStream) i got the message error
> >
>
> Strange! If the DOCTYPE is set correctly in mapping.xml I would assume
> that it's a parser problem, because the .xml file was found.
> Did you try to read the second repository via relative/absolute path
> string?
> mm.readDescriptorRepository("mapping.xml");
> mm.readDescriptorRepository("c:/.../mapping.xml");
>
> regards,
> Armin
>
>
> >
> >
> >
> > On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
> >>
> >> ABOU LINA wrote:
> >> > is in the same place :
> >> >
> >> > project-name/appli-conf  /  mappin2.xml , repository.dtd
> >> >
> >> > and the project-name/appli-conf is in the classpath.
> >> >
> >> > the mappin2.xml is retrieved with success but the dtd is not found
> and
> >> ojb
> >> > try
> >> > to found it from c:\eclipse\ the base directory. !!!
> >> >
> >>
> >> locally I setup a similar test. This test pass.
> >> Did you correctly set the doctype instruction in mapping2.xml (e.g.
> >> typo)?
> >>
> >> Both settings work for my local test:
> >>
> >> <?xml version="1.0" encoding="UTF-8"?>
> >> <!DOCTYPE descriptor-repository SYSTEM "repository.dtd">
> >> <descriptor-repository version="1.0" isolation-level="read-uncommitted"
> >> proxy-prefetching-limit="50">
> >>   ...
> >> />
> >>
> >> or
> >>
> >> <?xml version="1.0" encoding="UTF-8"?>
> >> <!DOCTYPE descriptor-repository PUBLIC
> >>         "-//Apache Software Foundation//DTD OJB Repository//EN"
> >>         "repository.dtd"
> >> [
> >> ...
> >> ]>
> >> <descriptor-repository version="1.0" isolation-level="read-uncommitted"
> >>          proxy-prefetching-limit="50">
> >> ...
> >> />
> >>
> >> regards,
> >> Armin
> >>
> >>
> >> >
> >> >
> >> > On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
> >> >>
> >> >> ABOU LINA wrote:
> >> >> > I have a problem to load the new profile :
> >> >> >
> >> >> > 1. i  put the mapping2.xml in the classpath of the project
> >> >> > 2. i use the mm.readDescriptorRepository(InputStream map)
> insteadof
> >> >> (String
> >> >> > map)
> >> >> >
> >> >> > i get : java.io.FileNoteFound : c:\eclipse\repository.dtd   ... !
> >> >> >
> >> >> > if i used InputStream is beacause i want to make access to the
> >> >> > mapping2.xmlfrom the classpath , but the parser used in ojb is
> >> looking
> >> >> > the dtd from a
> >> >> > base directory !!!
> >> >> >
> >> >> > any idea .
> >> >>
> >> >> Put the repository.dtd in the same place as mapping2.xml
> >> >>
> >> >> regards,
> >> >> Armin
> >> >>
> >> >>
> >> >> >
> >> >> > thx in advance
> >> >> >
> >> >> > On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
> >> >> >>
> >> >> >> ABOU LINA wrote:
> >> >> >> > That's very good idea using threadLocal :) , thx very much
> about
> >> >> these
> >> >> >> > informations :).
> >> >> >> >
> >> >> >>
> >> >> >> My pleasure!
> >> >> >> All code for "metadata profiles" (by using ThreadLocale) is
> handled
> >> by
> >> >> >> class MetadataManager. If you have problems using "metadata
> >> profiles"
> >> >> >> look at this class.
> >> >> >>
> >> >> >>
> >> >>
> >>
> http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/MetadataManager.java?view=markup
> >>
> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >> In MetadataManager the use of metadata profiles is explained too
> >> >> >>
> >> >> >>
> >> >>
> >>
> http://db.apache.org/ojb/api/org/apache/ojb/broker/metadata/MetadataManager.html
> >>
> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >> regards,
> >> >> >> Armin
> >> >> >>
> >> >> >> >
> >> >> >> >
> >> >> >> > On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
> >> >> >> >>
> >> >> >> >> ABOU LINA wrote:
> >> >> >> >> > thx for your reply .
> >> >> >> >> >
> >> >> >> >> > looking the example :
> >> >> >> >> >
> >> >> >> >> > // get MetadataManager instance
> >> >> >> >> (1) > MetadataManager mm = MetadataManager.getInstance();
> >> >> >> >> >
> >> >> >> >> > // enable per thread mode if not done before
> >> >> >> >> > mm.setEnablePerThreadChanges(true);
> >> >> >> >> >
> >> >> >> >> (2) > // Load additional object metadata by parsing an
> >> repository
> >> >> file
> >> >> >> >> > DescriptorRepository dr_1 =
> >> >> >> >> > mm.readDescriptorRepository("pathOrURLtoFile_1");
> >> >> >> >> > DescriptorRepository dr_2 =
> >> >> >> >> > mm.readDescriptorRepository("pathOrURLtoFile_2");
> >> >> >> >> >
> >> >> >> >> (3) > // add  profiles
> >> >> >> >> > mm.addProfile("global", mm.copyOfGlobalRepository());
> >> >> >> >> > mm.addProfile("guest", dr_1);
> >> >> >> >> > mm.addProfile("admin", dr_2);
> >> >> >> >> >
> >> >> >> >> (4) > // now load a specific profile
> >> >> >> >> > mm.loadProfile("admin");
> >> >> >> >> (5) > broker =
> PersistenceBrokerFactory.defaultPersistenceBroker
> >> ();
> >> >> >> >> >
> >> >> >> >> >
> >> >> >> >> > MetaManager is a singleton i think. so in this case we will
> >> >> have a
> >> >> >> >> > probleme with
> >> >> >> >> > concurence access. if user A loadProfile("guest") and just
> >> after
> >> >> >> >> > loading guest profile another user B (profile admin)
> >> >> >> >> > execute broker =
> >> >> >> PersistenceBrokerFactory.defaultPersistenceBroker();
> >> >> >> >> > so in this situation
> >> >> >> >> > B got a broker with profile admin because MetaManager is a
> >> >> >> singleton.
> >> >> >> >> >
> >> >> >> >> > is right ????
> >> >> >> >>
> >> >> >> >> If each user (thread) use a different broker instance no. All
> >> steps
> >> >> >> from
> >> >> >> >> (1) to (3) have to be done once at startup of your
> application.
> >> >> >> Thus no
> >> >> >> >> concurrency issues are expected.
> >> >> >> >>
> >> >> >> >> With step (4) the calling thread was associated with a
> specific
> >> >> >> profile
> >> >> >> >> (using ThreadLocale). This call have to be done for each
> thread
> >> to
> >> >> >> load
> >> >> >> >> the correct profile. Take care when using thread-pools (think
> >> e.g
> >> .
> >> >> >> >> Tomcat use it) to reassign the correct profile for each
> calling
> >> >> user.
> >> >> >> >> When OJB returns the broker instance (5) the profile for the
> >> >> current
> >> >> >> >> thread was associated.
> >> >> >> >>
> >> >> >> >> In OJB test-suite we test the use of different metadata
> profiles
> >> in
> >> >> >> >> MetadataMultithreadedTest and never detect problems with this
> >> >> feature.
> >> >> >> >>
> >> >> >> >> Again if user A and B (different threads) use different broker
> >> >> >> instances
> >> >> >> >> no concurrency issues are expected.
> >> >> >> >>
> >> >> >> >> regards,
> >> >> >> >> Armin
> >> >> >> >>
> >> >> >> >>
> >> >> >> >>
> >> >> >> >> >
> >> >> >> >> >
> >> >> >> >> >
> >> >> >> >> >
> >> >> >> >> >
> >> >> >> >> >
> >> >> >> >> > On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
> >> >> >> >> >>
> >> >> >> >> >> Hi,
> >> >> >> >> >>
> >> >> >> >> >> ABOU LINA wrote:
> >> >> >> >> >> > Hi;
> >> >> >> >> >> >
> >> >> >> >> >> > i have two mapping file : repository1.xml and
> >> repository2.xml.
> >> >> >> >> >> >
> >> >> >> >> >> > the difference between these two file are the value of
> >> auto-*
> >> >> >> >> >> > [auto-retrieve, auto-update ..] ; at runtime sometimes i
> >> need
> >> >> to
> >> >> >> use
> >> >> >> >> >> > repository1.xml and somtimes the repository2.xml .
> >> >> >> >> >> >
> >> >> >> >> >> > what is the best and optimal  solution  about this conf
> ???
> >> >> >> >> >> >
> >> >> >> >> >>
> >> >> >> >> >> You can use metadata profiles on per thread base.
> >> >> >> >> >>
> >> >> >> >> >>
> >> >> >> >>
> >> >> >>
> >> >>
> >>
> http://db.apache.org/ojb/docu/guides/metadata.html#Per+thread+metadata+changes
> >>
> >> >>
> >> >> >>
> >> >> >> >>
> >> >> >> >> >>
> >> >> >> >> >>
> >> >> >> >> >>
> >> >> >> >> >>
> >> >> >> >>
> >> >> >>
> >> >>
> >>
> http://db.apache.org/ojb/docu/guides/metadata.html#Object+metadata+profiles
> >>
> >> >>
> >> >> >>
> >> >> >> >>
> >> >> >> >> >>
> >> >> >> >> >>
> >> >> >> >> >> This way you can load a specific metadata profiles
> >> >> >> (repository1.xmlor
> >> >> >> >> >> repository2.xml) for the current thread.
> >> >> >> >> >>
> >> >> >> >> >> Take care of caching issues, e.g. obj1 from rep1 was used
> in
> >> >> rep2
> >> >> >> >> >> environment will cause undetermined behavior. Thus it's
> >> >> recommended
> >> >> >> to
> >> >> >> >> >> use the two-level cache or only a session based (per
> broker)
> >> >> cache.
> >> >> >> >> >>
> >> >> >> >> >> regards,
> >> >> >> >> >> Armin
> >> >> >> >> >>
> >> >> >> >> >>
> >> >> >> >> >> > thx in advance
> >> >> >> >> >> >
> >> >> >> >> >>
> >> >> >> >> >>
> >> >> >>
> >> ---------------------------------------------------------------------
> >> >> >> >> >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >> >> >> >> >> For additional commands, e-mail:
> ojb-user-help@db.apache.org
> >> >> >> >> >>
> >> >> >> >> >>
> >> >> >> >> >
> >> >> >> >>
> >> >> >> >>
> >> >>
> ---------------------------------------------------------------------
> >> >> >> >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >> >> >> >> For additional commands, e-mail: ojb-user-help@db.apache.org
> >> >> >> >>
> >> >> >> >>
> >> >> >> >
> >> >> >>
> >> >> >>
> >> ---------------------------------------------------------------------
> >> >> >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >> >> >> For additional commands, e-mail: ojb-user-help@db.apache.org
> >> >> >>
> >> >> >>
> >> >> >
> >> >>
> >> >>
> ---------------------------------------------------------------------
> >> >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >> >> For additional commands, e-mail: ojb-user-help@db.apache.org
> >> >>
> >> >>
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >> For additional commands, e-mail: ojb-user-help@db.apache.org
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>

Re: Using two mapping file in the same project ?

Posted by Armin Waibel <ar...@apache.org>.
ABOU LINA wrote:
> i tested the two way but i got the same problem : dtd not found .
> 
>            InputStream input = this.getClass
> ().getClassLoader().getResourceAsStream(descriptor2);
>            MetadataManager mm = MetadataManager.getInstance();
>            mm.setEnablePerThreadChanges(true);
>            DescriptorRepository dr_1 = mm.readDescriptorRepository(input);
> 
> at readDescriptorRepository(InputStream) i got the message error
>

Strange! If the DOCTYPE is set correctly in mapping.xml I would assume 
that it's a parser problem, because the .xml file was found.
Did you try to read the second repository via relative/absolute path string?
mm.readDescriptorRepository("mapping.xml");
mm.readDescriptorRepository("c:/.../mapping.xml");

regards,
Armin


> 
> 
> 
> On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
>>
>> ABOU LINA wrote:
>> > is in the same place :
>> >
>> > project-name/appli-conf  /  mappin2.xml , repository.dtd
>> >
>> > and the project-name/appli-conf is in the classpath.
>> >
>> > the mappin2.xml is retrieved with success but the dtd is not found and
>> ojb
>> > try
>> > to found it from c:\eclipse\ the base directory. !!!
>> >
>>
>> locally I setup a similar test. This test pass.
>> Did you correctly set the doctype instruction in mapping2.xml (e.g. 
>> typo)?
>>
>> Both settings work for my local test:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <!DOCTYPE descriptor-repository SYSTEM "repository.dtd">
>> <descriptor-repository version="1.0" isolation-level="read-uncommitted"
>> proxy-prefetching-limit="50">
>>   ...
>> />
>>
>> or
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <!DOCTYPE descriptor-repository PUBLIC
>>         "-//Apache Software Foundation//DTD OJB Repository//EN"
>>         "repository.dtd"
>> [
>> ...
>> ]>
>> <descriptor-repository version="1.0" isolation-level="read-uncommitted"
>>          proxy-prefetching-limit="50">
>> ...
>> />
>>
>> regards,
>> Armin
>>
>>
>> >
>> >
>> > On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
>> >>
>> >> ABOU LINA wrote:
>> >> > I have a problem to load the new profile :
>> >> >
>> >> > 1. i  put the mapping2.xml in the classpath of the project
>> >> > 2. i use the mm.readDescriptorRepository(InputStream map) insteadof
>> >> (String
>> >> > map)
>> >> >
>> >> > i get : java.io.FileNoteFound : c:\eclipse\repository.dtd   ... !
>> >> >
>> >> > if i used InputStream is beacause i want to make access to the
>> >> > mapping2.xmlfrom the classpath , but the parser used in ojb is
>> looking
>> >> > the dtd from a
>> >> > base directory !!!
>> >> >
>> >> > any idea .
>> >>
>> >> Put the repository.dtd in the same place as mapping2.xml
>> >>
>> >> regards,
>> >> Armin
>> >>
>> >>
>> >> >
>> >> > thx in advance
>> >> >
>> >> > On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
>> >> >>
>> >> >> ABOU LINA wrote:
>> >> >> > That's very good idea using threadLocal :) , thx very much about
>> >> these
>> >> >> > informations :).
>> >> >> >
>> >> >>
>> >> >> My pleasure!
>> >> >> All code for "metadata profiles" (by using ThreadLocale) is handled
>> by
>> >> >> class MetadataManager. If you have problems using "metadata
>> profiles"
>> >> >> look at this class.
>> >> >>
>> >> >>
>> >>
>> http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/MetadataManager.java?view=markup 
>>
>> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >> In MetadataManager the use of metadata profiles is explained too
>> >> >>
>> >> >>
>> >>
>> http://db.apache.org/ojb/api/org/apache/ojb/broker/metadata/MetadataManager.html 
>>
>> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >> regards,
>> >> >> Armin
>> >> >>
>> >> >> >
>> >> >> >
>> >> >> > On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
>> >> >> >>
>> >> >> >> ABOU LINA wrote:
>> >> >> >> > thx for your reply .
>> >> >> >> >
>> >> >> >> > looking the example :
>> >> >> >> >
>> >> >> >> > // get MetadataManager instance
>> >> >> >> (1) > MetadataManager mm = MetadataManager.getInstance();
>> >> >> >> >
>> >> >> >> > // enable per thread mode if not done before
>> >> >> >> > mm.setEnablePerThreadChanges(true);
>> >> >> >> >
>> >> >> >> (2) > // Load additional object metadata by parsing an 
>> repository
>> >> file
>> >> >> >> > DescriptorRepository dr_1 =
>> >> >> >> > mm.readDescriptorRepository("pathOrURLtoFile_1");
>> >> >> >> > DescriptorRepository dr_2 =
>> >> >> >> > mm.readDescriptorRepository("pathOrURLtoFile_2");
>> >> >> >> >
>> >> >> >> (3) > // add  profiles
>> >> >> >> > mm.addProfile("global", mm.copyOfGlobalRepository());
>> >> >> >> > mm.addProfile("guest", dr_1);
>> >> >> >> > mm.addProfile("admin", dr_2);
>> >> >> >> >
>> >> >> >> (4) > // now load a specific profile
>> >> >> >> > mm.loadProfile("admin");
>> >> >> >> (5) > broker = PersistenceBrokerFactory.defaultPersistenceBroker
>> ();
>> >> >> >> >
>> >> >> >> >
>> >> >> >> > MetaManager is a singleton i think. so in this case we will
>> >> have a
>> >> >> >> > probleme with
>> >> >> >> > concurence access. if user A loadProfile("guest") and just
>> after
>> >> >> >> > loading guest profile another user B (profile admin)
>> >> >> >> > execute broker =
>> >> >> PersistenceBrokerFactory.defaultPersistenceBroker();
>> >> >> >> > so in this situation
>> >> >> >> > B got a broker with profile admin because MetaManager is a
>> >> >> singleton.
>> >> >> >> >
>> >> >> >> > is right ????
>> >> >> >>
>> >> >> >> If each user (thread) use a different broker instance no. All
>> steps
>> >> >> from
>> >> >> >> (1) to (3) have to be done once at startup of your application.
>> >> >> Thus no
>> >> >> >> concurrency issues are expected.
>> >> >> >>
>> >> >> >> With step (4) the calling thread was associated with a specific
>> >> >> profile
>> >> >> >> (using ThreadLocale). This call have to be done for each thread
>> to
>> >> >> load
>> >> >> >> the correct profile. Take care when using thread-pools (think 
>> e.g
>> .
>> >> >> >> Tomcat use it) to reassign the correct profile for each calling
>> >> user.
>> >> >> >> When OJB returns the broker instance (5) the profile for the
>> >> current
>> >> >> >> thread was associated.
>> >> >> >>
>> >> >> >> In OJB test-suite we test the use of different metadata profiles
>> in
>> >> >> >> MetadataMultithreadedTest and never detect problems with this
>> >> feature.
>> >> >> >>
>> >> >> >> Again if user A and B (different threads) use different broker
>> >> >> instances
>> >> >> >> no concurrency issues are expected.
>> >> >> >>
>> >> >> >> regards,
>> >> >> >> Armin
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >> >
>> >> >> >> >
>> >> >> >> >
>> >> >> >> >
>> >> >> >> >
>> >> >> >> >
>> >> >> >> > On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
>> >> >> >> >>
>> >> >> >> >> Hi,
>> >> >> >> >>
>> >> >> >> >> ABOU LINA wrote:
>> >> >> >> >> > Hi;
>> >> >> >> >> >
>> >> >> >> >> > i have two mapping file : repository1.xml and
>> repository2.xml.
>> >> >> >> >> >
>> >> >> >> >> > the difference between these two file are the value of
>> auto-*
>> >> >> >> >> > [auto-retrieve, auto-update ..] ; at runtime sometimes i
>> need
>> >> to
>> >> >> use
>> >> >> >> >> > repository1.xml and somtimes the repository2.xml .
>> >> >> >> >> >
>> >> >> >> >> > what is the best and optimal  solution  about this conf ???
>> >> >> >> >> >
>> >> >> >> >>
>> >> >> >> >> You can use metadata profiles on per thread base.
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >>
>> >> >>
>> >>
>> http://db.apache.org/ojb/docu/guides/metadata.html#Per+thread+metadata+changes 
>>
>> >>
>> >> >>
>> >> >> >>
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >>
>> >> >>
>> >>
>> http://db.apache.org/ojb/docu/guides/metadata.html#Object+metadata+profiles 
>>
>> >>
>> >> >>
>> >> >> >>
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >> This way you can load a specific metadata profiles
>> >> >> (repository1.xmlor
>> >> >> >> >> repository2.xml) for the current thread.
>> >> >> >> >>
>> >> >> >> >> Take care of caching issues, e.g. obj1 from rep1 was used in
>> >> rep2
>> >> >> >> >> environment will cause undetermined behavior. Thus it's
>> >> recommended
>> >> >> to
>> >> >> >> >> use the two-level cache or only a session based (per broker)
>> >> cache.
>> >> >> >> >>
>> >> >> >> >> regards,
>> >> >> >> >> Armin
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >> > thx in advance
>> >> >> >> >> >
>> >> >> >> >>
>> >> >> >> >>
>> >> >>
>> ---------------------------------------------------------------------
>> >> >> >> >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> >> >> >> >> For additional commands, e-mail: ojb-user-help@db.apache.org
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >
>> >> >> >>
>> >> >> >>
>> >> ---------------------------------------------------------------------
>> >> >> >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> >> >> >> For additional commands, e-mail: ojb-user-help@db.apache.org
>> >> >> >>
>> >> >> >>
>> >> >> >
>> >> >>
>> >> >>
>> ---------------------------------------------------------------------
>> >> >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> >> >> For additional commands, e-mail: ojb-user-help@db.apache.org
>> >> >>
>> >> >>
>> >> >
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> >> For additional commands, e-mail: ojb-user-help@db.apache.org
>> >>
>> >>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Using two mapping file in the same project ?

Posted by ABOU LINA <am...@gmail.com>.
i tested the two way but i got the same problem : dtd not found .

            InputStream input = this.getClass
().getClassLoader().getResourceAsStream(descriptor2);
            MetadataManager mm = MetadataManager.getInstance();
            mm.setEnablePerThreadChanges(true);
            DescriptorRepository dr_1 = mm.readDescriptorRepository(input);

at readDescriptorRepository(InputStream) i got the message error




On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
>
> ABOU LINA wrote:
> > is in the same place :
> >
> > project-name/appli-conf  /  mappin2.xml , repository.dtd
> >
> > and the project-name/appli-conf is in the classpath.
> >
> > the mappin2.xml is retrieved with success but the dtd is not found and
> ojb
> > try
> > to found it from c:\eclipse\ the base directory. !!!
> >
>
> locally I setup a similar test. This test pass.
> Did you correctly set the doctype instruction in mapping2.xml (e.g. typo)?
>
> Both settings work for my local test:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE descriptor-repository SYSTEM "repository.dtd">
> <descriptor-repository version="1.0" isolation-level="read-uncommitted"
> proxy-prefetching-limit="50">
>   ...
> />
>
> or
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE descriptor-repository PUBLIC
>         "-//Apache Software Foundation//DTD OJB Repository//EN"
>         "repository.dtd"
> [
> ...
> ]>
> <descriptor-repository version="1.0" isolation-level="read-uncommitted"
>          proxy-prefetching-limit="50">
> ...
> />
>
> regards,
> Armin
>
>
> >
> >
> > On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
> >>
> >> ABOU LINA wrote:
> >> > I have a problem to load the new profile :
> >> >
> >> > 1. i  put the mapping2.xml in the classpath of the project
> >> > 2. i use the mm.readDescriptorRepository(InputStream map) insteadof
> >> (String
> >> > map)
> >> >
> >> > i get : java.io.FileNoteFound : c:\eclipse\repository.dtd   ... !
> >> >
> >> > if i used InputStream is beacause i want to make access to the
> >> > mapping2.xmlfrom the classpath , but the parser used in ojb is
> looking
> >> > the dtd from a
> >> > base directory !!!
> >> >
> >> > any idea .
> >>
> >> Put the repository.dtd in the same place as mapping2.xml
> >>
> >> regards,
> >> Armin
> >>
> >>
> >> >
> >> > thx in advance
> >> >
> >> > On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
> >> >>
> >> >> ABOU LINA wrote:
> >> >> > That's very good idea using threadLocal :) , thx very much about
> >> these
> >> >> > informations :).
> >> >> >
> >> >>
> >> >> My pleasure!
> >> >> All code for "metadata profiles" (by using ThreadLocale) is handled
> by
> >> >> class MetadataManager. If you have problems using "metadata
> profiles"
> >> >> look at this class.
> >> >>
> >> >>
> >>
> http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/MetadataManager.java?view=markup
> >>
> >> >>
> >> >>
> >> >>
> >> >> In MetadataManager the use of metadata profiles is explained too
> >> >>
> >> >>
> >>
> http://db.apache.org/ojb/api/org/apache/ojb/broker/metadata/MetadataManager.html
> >>
> >> >>
> >> >>
> >> >>
> >> >> regards,
> >> >> Armin
> >> >>
> >> >> >
> >> >> >
> >> >> > On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
> >> >> >>
> >> >> >> ABOU LINA wrote:
> >> >> >> > thx for your reply .
> >> >> >> >
> >> >> >> > looking the example :
> >> >> >> >
> >> >> >> > // get MetadataManager instance
> >> >> >> (1) > MetadataManager mm = MetadataManager.getInstance();
> >> >> >> >
> >> >> >> > // enable per thread mode if not done before
> >> >> >> > mm.setEnablePerThreadChanges(true);
> >> >> >> >
> >> >> >> (2) > // Load additional object metadata by parsing an repository
> >> file
> >> >> >> > DescriptorRepository dr_1 =
> >> >> >> > mm.readDescriptorRepository("pathOrURLtoFile_1");
> >> >> >> > DescriptorRepository dr_2 =
> >> >> >> > mm.readDescriptorRepository("pathOrURLtoFile_2");
> >> >> >> >
> >> >> >> (3) > // add  profiles
> >> >> >> > mm.addProfile("global", mm.copyOfGlobalRepository());
> >> >> >> > mm.addProfile("guest", dr_1);
> >> >> >> > mm.addProfile("admin", dr_2);
> >> >> >> >
> >> >> >> (4) > // now load a specific profile
> >> >> >> > mm.loadProfile("admin");
> >> >> >> (5) > broker = PersistenceBrokerFactory.defaultPersistenceBroker
> ();
> >> >> >> >
> >> >> >> >
> >> >> >> > MetaManager is a singleton i think. so in this case we will
> >> have a
> >> >> >> > probleme with
> >> >> >> > concurence access. if user A loadProfile("guest") and just
> after
> >> >> >> > loading guest profile another user B (profile admin)
> >> >> >> > execute broker =
> >> >> PersistenceBrokerFactory.defaultPersistenceBroker();
> >> >> >> > so in this situation
> >> >> >> > B got a broker with profile admin because MetaManager is a
> >> >> singleton.
> >> >> >> >
> >> >> >> > is right ????
> >> >> >>
> >> >> >> If each user (thread) use a different broker instance no. All
> steps
> >> >> from
> >> >> >> (1) to (3) have to be done once at startup of your application.
> >> >> Thus no
> >> >> >> concurrency issues are expected.
> >> >> >>
> >> >> >> With step (4) the calling thread was associated with a specific
> >> >> profile
> >> >> >> (using ThreadLocale). This call have to be done for each thread
> to
> >> >> load
> >> >> >> the correct profile. Take care when using thread-pools (think e.g
> .
> >> >> >> Tomcat use it) to reassign the correct profile for each calling
> >> user.
> >> >> >> When OJB returns the broker instance (5) the profile for the
> >> current
> >> >> >> thread was associated.
> >> >> >>
> >> >> >> In OJB test-suite we test the use of different metadata profiles
> in
> >> >> >> MetadataMultithreadedTest and never detect problems with this
> >> feature.
> >> >> >>
> >> >> >> Again if user A and B (different threads) use different broker
> >> >> instances
> >> >> >> no concurrency issues are expected.
> >> >> >>
> >> >> >> regards,
> >> >> >> Armin
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >> >
> >> >> >> >
> >> >> >> >
> >> >> >> >
> >> >> >> >
> >> >> >> >
> >> >> >> > On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
> >> >> >> >>
> >> >> >> >> Hi,
> >> >> >> >>
> >> >> >> >> ABOU LINA wrote:
> >> >> >> >> > Hi;
> >> >> >> >> >
> >> >> >> >> > i have two mapping file : repository1.xml and
> repository2.xml.
> >> >> >> >> >
> >> >> >> >> > the difference between these two file are the value of
> auto-*
> >> >> >> >> > [auto-retrieve, auto-update ..] ; at runtime sometimes i
> need
> >> to
> >> >> use
> >> >> >> >> > repository1.xml and somtimes the repository2.xml .
> >> >> >> >> >
> >> >> >> >> > what is the best and optimal  solution  about this conf ???
> >> >> >> >> >
> >> >> >> >>
> >> >> >> >> You can use metadata profiles on per thread base.
> >> >> >> >>
> >> >> >> >>
> >> >> >>
> >> >>
> >>
> http://db.apache.org/ojb/docu/guides/metadata.html#Per+thread+metadata+changes
> >>
> >> >>
> >> >> >>
> >> >> >> >>
> >> >> >> >>
> >> >> >> >>
> >> >> >> >>
> >> >> >>
> >> >>
> >>
> http://db.apache.org/ojb/docu/guides/metadata.html#Object+metadata+profiles
> >>
> >> >>
> >> >> >>
> >> >> >> >>
> >> >> >> >>
> >> >> >> >> This way you can load a specific metadata profiles
> >> >> (repository1.xmlor
> >> >> >> >> repository2.xml) for the current thread.
> >> >> >> >>
> >> >> >> >> Take care of caching issues, e.g. obj1 from rep1 was used in
> >> rep2
> >> >> >> >> environment will cause undetermined behavior. Thus it's
> >> recommended
> >> >> to
> >> >> >> >> use the two-level cache or only a session based (per broker)
> >> cache.
> >> >> >> >>
> >> >> >> >> regards,
> >> >> >> >> Armin
> >> >> >> >>
> >> >> >> >>
> >> >> >> >> > thx in advance
> >> >> >> >> >
> >> >> >> >>
> >> >> >> >>
> >> >>
> ---------------------------------------------------------------------
> >> >> >> >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >> >> >> >> For additional commands, e-mail: ojb-user-help@db.apache.org
> >> >> >> >>
> >> >> >> >>
> >> >> >> >
> >> >> >>
> >> >> >>
> >> ---------------------------------------------------------------------
> >> >> >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >> >> >> For additional commands, e-mail: ojb-user-help@db.apache.org
> >> >> >>
> >> >> >>
> >> >> >
> >> >>
> >> >>
> ---------------------------------------------------------------------
> >> >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >> >> For additional commands, e-mail: ojb-user-help@db.apache.org
> >> >>
> >> >>
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >> For additional commands, e-mail: ojb-user-help@db.apache.org
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>

Re: Using two mapping file in the same project ?

Posted by Armin Waibel <ar...@apache.org>.
ABOU LINA wrote:
> is in the same place :
> 
> project-name/appli-conf  /  mappin2.xml , repository.dtd
> 
> and the project-name/appli-conf is in the classpath.
> 
> the mappin2.xml is retrieved with success but the dtd is not found and ojb
> try
> to found it from c:\eclipse\ the base directory. !!!
>

locally I setup a similar test. This test pass.
Did you correctly set the doctype instruction in mapping2.xml (e.g. typo)?

Both settings work for my local test:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE descriptor-repository SYSTEM "repository.dtd">
<descriptor-repository version="1.0" isolation-level="read-uncommitted"
proxy-prefetching-limit="50">
  ...
/>

or

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE descriptor-repository PUBLIC
        "-//Apache Software Foundation//DTD OJB Repository//EN"
        "repository.dtd"
[
...
]>
<descriptor-repository version="1.0" isolation-level="read-uncommitted"
         proxy-prefetching-limit="50">
...
/>

regards,
Armin


> 
> 
> On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
>>
>> ABOU LINA wrote:
>> > I have a problem to load the new profile :
>> >
>> > 1. i  put the mapping2.xml in the classpath of the project
>> > 2. i use the mm.readDescriptorRepository(InputStream map) insteadof
>> (String
>> > map)
>> >
>> > i get : java.io.FileNoteFound : c:\eclipse\repository.dtd   ... !
>> >
>> > if i used InputStream is beacause i want to make access to the
>> > mapping2.xmlfrom the classpath , but the parser used in ojb is looking
>> > the dtd from a
>> > base directory !!!
>> >
>> > any idea .
>>
>> Put the repository.dtd in the same place as mapping2.xml
>>
>> regards,
>> Armin
>>
>>
>> >
>> > thx in advance
>> >
>> > On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
>> >>
>> >> ABOU LINA wrote:
>> >> > That's very good idea using threadLocal :) , thx very much about
>> these
>> >> > informations :).
>> >> >
>> >>
>> >> My pleasure!
>> >> All code for "metadata profiles" (by using ThreadLocale) is handled by
>> >> class MetadataManager. If you have problems using "metadata profiles"
>> >> look at this class.
>> >>
>> >>
>> http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/MetadataManager.java?view=markup 
>>
>> >>
>> >>
>> >>
>> >> In MetadataManager the use of metadata profiles is explained too
>> >>
>> >>
>> http://db.apache.org/ojb/api/org/apache/ojb/broker/metadata/MetadataManager.html 
>>
>> >>
>> >>
>> >>
>> >> regards,
>> >> Armin
>> >>
>> >> >
>> >> >
>> >> > On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
>> >> >>
>> >> >> ABOU LINA wrote:
>> >> >> > thx for your reply .
>> >> >> >
>> >> >> > looking the example :
>> >> >> >
>> >> >> > // get MetadataManager instance
>> >> >> (1) > MetadataManager mm = MetadataManager.getInstance();
>> >> >> >
>> >> >> > // enable per thread mode if not done before
>> >> >> > mm.setEnablePerThreadChanges(true);
>> >> >> >
>> >> >> (2) > // Load additional object metadata by parsing an repository
>> file
>> >> >> > DescriptorRepository dr_1 =
>> >> >> > mm.readDescriptorRepository("pathOrURLtoFile_1");
>> >> >> > DescriptorRepository dr_2 =
>> >> >> > mm.readDescriptorRepository("pathOrURLtoFile_2");
>> >> >> >
>> >> >> (3) > // add  profiles
>> >> >> > mm.addProfile("global", mm.copyOfGlobalRepository());
>> >> >> > mm.addProfile("guest", dr_1);
>> >> >> > mm.addProfile("admin", dr_2);
>> >> >> >
>> >> >> (4) > // now load a specific profile
>> >> >> > mm.loadProfile("admin");
>> >> >> (5) > broker = PersistenceBrokerFactory.defaultPersistenceBroker();
>> >> >> >
>> >> >> >
>> >> >> > MetaManager is a singleton i think. so in this case we will 
>> have a
>> >> >> > probleme with
>> >> >> > concurence access. if user A loadProfile("guest") and just after
>> >> >> > loading guest profile another user B (profile admin)
>> >> >> > execute broker =
>> >> PersistenceBrokerFactory.defaultPersistenceBroker();
>> >> >> > so in this situation
>> >> >> > B got a broker with profile admin because MetaManager is a
>> >> singleton.
>> >> >> >
>> >> >> > is right ????
>> >> >>
>> >> >> If each user (thread) use a different broker instance no. All steps
>> >> from
>> >> >> (1) to (3) have to be done once at startup of your application.
>> >> Thus no
>> >> >> concurrency issues are expected.
>> >> >>
>> >> >> With step (4) the calling thread was associated with a specific
>> >> profile
>> >> >> (using ThreadLocale). This call have to be done for each thread to
>> >> load
>> >> >> the correct profile. Take care when using thread-pools (think e.g.
>> >> >> Tomcat use it) to reassign the correct profile for each calling
>> user.
>> >> >> When OJB returns the broker instance (5) the profile for the 
>> current
>> >> >> thread was associated.
>> >> >>
>> >> >> In OJB test-suite we test the use of different metadata profiles in
>> >> >> MetadataMultithreadedTest and never detect problems with this
>> feature.
>> >> >>
>> >> >> Again if user A and B (different threads) use different broker
>> >> instances
>> >> >> no concurrency issues are expected.
>> >> >>
>> >> >> regards,
>> >> >> Armin
>> >> >>
>> >> >>
>> >> >>
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> > On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
>> >> >> >>
>> >> >> >> Hi,
>> >> >> >>
>> >> >> >> ABOU LINA wrote:
>> >> >> >> > Hi;
>> >> >> >> >
>> >> >> >> > i have two mapping file : repository1.xml and repository2.xml.
>> >> >> >> >
>> >> >> >> > the difference between these two file are the value of auto-*
>> >> >> >> > [auto-retrieve, auto-update ..] ; at runtime sometimes i need
>> to
>> >> use
>> >> >> >> > repository1.xml and somtimes the repository2.xml .
>> >> >> >> >
>> >> >> >> > what is the best and optimal  solution  about this conf ???
>> >> >> >> >
>> >> >> >>
>> >> >> >> You can use metadata profiles on per thread base.
>> >> >> >>
>> >> >> >>
>> >> >>
>> >>
>> http://db.apache.org/ojb/docu/guides/metadata.html#Per+thread+metadata+changes 
>>
>> >>
>> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >>
>> >>
>> http://db.apache.org/ojb/docu/guides/metadata.html#Object+metadata+profiles 
>>
>> >>
>> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >> This way you can load a specific metadata profiles
>> >> (repository1.xmlor
>> >> >> >> repository2.xml) for the current thread.
>> >> >> >>
>> >> >> >> Take care of caching issues, e.g. obj1 from rep1 was used in 
>> rep2
>> >> >> >> environment will cause undetermined behavior. Thus it's
>> recommended
>> >> to
>> >> >> >> use the two-level cache or only a session based (per broker)
>> cache.
>> >> >> >>
>> >> >> >> regards,
>> >> >> >> Armin
>> >> >> >>
>> >> >> >>
>> >> >> >> > thx in advance
>> >> >> >> >
>> >> >> >>
>> >> >> >>
>> >> ---------------------------------------------------------------------
>> >> >> >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> >> >> >> For additional commands, e-mail: ojb-user-help@db.apache.org
>> >> >> >>
>> >> >> >>
>> >> >> >
>> >> >>
>> >> >>
>> ---------------------------------------------------------------------
>> >> >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> >> >> For additional commands, e-mail: ojb-user-help@db.apache.org
>> >> >>
>> >> >>
>> >> >
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> >> For additional commands, e-mail: ojb-user-help@db.apache.org
>> >>
>> >>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Using two mapping file in the same project ?

Posted by ABOU LINA <am...@gmail.com>.
is in the same place :

project-name/appli-conf  /  mappin2.xml , repository.dtd

and the project-name/appli-conf is in the classpath.

the mappin2.xml is retrieved with success but the dtd is not found and ojb
try
to found it from c:\eclipse\ the base directory. !!!



On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
>
> ABOU LINA wrote:
> > I have a problem to load the new profile :
> >
> > 1. i  put the mapping2.xml in the classpath of the project
> > 2. i use the mm.readDescriptorRepository(InputStream map) insteadof
> (String
> > map)
> >
> > i get : java.io.FileNoteFound : c:\eclipse\repository.dtd   ... !
> >
> > if i used InputStream is beacause i want to make access to the
> > mapping2.xmlfrom the classpath , but the parser used in ojb is looking
> > the dtd from a
> > base directory !!!
> >
> > any idea .
>
> Put the repository.dtd in the same place as mapping2.xml
>
> regards,
> Armin
>
>
> >
> > thx in advance
> >
> > On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
> >>
> >> ABOU LINA wrote:
> >> > That's very good idea using threadLocal :) , thx very much about
> these
> >> > informations :).
> >> >
> >>
> >> My pleasure!
> >> All code for "metadata profiles" (by using ThreadLocale) is handled by
> >> class MetadataManager. If you have problems using "metadata profiles"
> >> look at this class.
> >>
> >>
> http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/MetadataManager.java?view=markup
> >>
> >>
> >>
> >> In MetadataManager the use of metadata profiles is explained too
> >>
> >>
> http://db.apache.org/ojb/api/org/apache/ojb/broker/metadata/MetadataManager.html
> >>
> >>
> >>
> >> regards,
> >> Armin
> >>
> >> >
> >> >
> >> > On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
> >> >>
> >> >> ABOU LINA wrote:
> >> >> > thx for your reply .
> >> >> >
> >> >> > looking the example :
> >> >> >
> >> >> > // get MetadataManager instance
> >> >> (1) > MetadataManager mm = MetadataManager.getInstance();
> >> >> >
> >> >> > // enable per thread mode if not done before
> >> >> > mm.setEnablePerThreadChanges(true);
> >> >> >
> >> >> (2) > // Load additional object metadata by parsing an repository
> file
> >> >> > DescriptorRepository dr_1 =
> >> >> > mm.readDescriptorRepository("pathOrURLtoFile_1");
> >> >> > DescriptorRepository dr_2 =
> >> >> > mm.readDescriptorRepository("pathOrURLtoFile_2");
> >> >> >
> >> >> (3) > // add  profiles
> >> >> > mm.addProfile("global", mm.copyOfGlobalRepository());
> >> >> > mm.addProfile("guest", dr_1);
> >> >> > mm.addProfile("admin", dr_2);
> >> >> >
> >> >> (4) > // now load a specific profile
> >> >> > mm.loadProfile("admin");
> >> >> (5) > broker = PersistenceBrokerFactory.defaultPersistenceBroker();
> >> >> >
> >> >> >
> >> >> > MetaManager is a singleton i think. so in this case we will have a
> >> >> > probleme with
> >> >> > concurence access. if user A loadProfile("guest") and just after
> >> >> > loading guest profile another user B (profile admin)
> >> >> > execute broker =
> >> PersistenceBrokerFactory.defaultPersistenceBroker();
> >> >> > so in this situation
> >> >> > B got a broker with profile admin because MetaManager is a
> >> singleton.
> >> >> >
> >> >> > is right ????
> >> >>
> >> >> If each user (thread) use a different broker instance no. All steps
> >> from
> >> >> (1) to (3) have to be done once at startup of your application.
> >> Thus no
> >> >> concurrency issues are expected.
> >> >>
> >> >> With step (4) the calling thread was associated with a specific
> >> profile
> >> >> (using ThreadLocale). This call have to be done for each thread to
> >> load
> >> >> the correct profile. Take care when using thread-pools (think e.g.
> >> >> Tomcat use it) to reassign the correct profile for each calling
> user.
> >> >> When OJB returns the broker instance (5) the profile for the current
> >> >> thread was associated.
> >> >>
> >> >> In OJB test-suite we test the use of different metadata profiles in
> >> >> MetadataMultithreadedTest and never detect problems with this
> feature.
> >> >>
> >> >> Again if user A and B (different threads) use different broker
> >> instances
> >> >> no concurrency issues are expected.
> >> >>
> >> >> regards,
> >> >> Armin
> >> >>
> >> >>
> >> >>
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >> > On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
> >> >> >>
> >> >> >> Hi,
> >> >> >>
> >> >> >> ABOU LINA wrote:
> >> >> >> > Hi;
> >> >> >> >
> >> >> >> > i have two mapping file : repository1.xml and repository2.xml.
> >> >> >> >
> >> >> >> > the difference between these two file are the value of auto-*
> >> >> >> > [auto-retrieve, auto-update ..] ; at runtime sometimes i need
> to
> >> use
> >> >> >> > repository1.xml and somtimes the repository2.xml .
> >> >> >> >
> >> >> >> > what is the best and optimal  solution  about this conf ???
> >> >> >> >
> >> >> >>
> >> >> >> You can use metadata profiles on per thread base.
> >> >> >>
> >> >> >>
> >> >>
> >>
> http://db.apache.org/ojb/docu/guides/metadata.html#Per+thread+metadata+changes
> >>
> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> >>
> >>
> http://db.apache.org/ojb/docu/guides/metadata.html#Object+metadata+profiles
> >>
> >> >>
> >> >> >>
> >> >> >>
> >> >> >> This way you can load a specific metadata profiles
> >> (repository1.xmlor
> >> >> >> repository2.xml) for the current thread.
> >> >> >>
> >> >> >> Take care of caching issues, e.g. obj1 from rep1 was used in rep2
> >> >> >> environment will cause undetermined behavior. Thus it's
> recommended
> >> to
> >> >> >> use the two-level cache or only a session based (per broker)
> cache.
> >> >> >>
> >> >> >> regards,
> >> >> >> Armin
> >> >> >>
> >> >> >>
> >> >> >> > thx in advance
> >> >> >> >
> >> >> >>
> >> >> >>
> >> ---------------------------------------------------------------------
> >> >> >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >> >> >> For additional commands, e-mail: ojb-user-help@db.apache.org
> >> >> >>
> >> >> >>
> >> >> >
> >> >>
> >> >>
> ---------------------------------------------------------------------
> >> >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >> >> For additional commands, e-mail: ojb-user-help@db.apache.org
> >> >>
> >> >>
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >> For additional commands, e-mail: ojb-user-help@db.apache.org
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>

Re: Using two mapping file in the same project ?

Posted by Armin Waibel <ar...@apache.org>.
ABOU LINA wrote:
> I have a problem to load the new profile :
> 
> 1. i  put the mapping2.xml in the classpath of the project
> 2. i use the mm.readDescriptorRepository(InputStream map) insteadof (String
> map)
> 
> i get : java.io.FileNoteFound : c:\eclipse\repository.dtd   ... !
> 
> if i used InputStream is beacause i want to make access to the
> mapping2.xmlfrom the classpath , but the parser used in ojb is looking
> the dtd from a
> base directory !!!
> 
> any idea .

Put the repository.dtd in the same place as mapping2.xml

regards,
Armin


> 
> thx in advance
> 
> On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
>>
>> ABOU LINA wrote:
>> > That's very good idea using threadLocal :) , thx very much about these
>> > informations :).
>> >
>>
>> My pleasure!
>> All code for "metadata profiles" (by using ThreadLocale) is handled by
>> class MetadataManager. If you have problems using "metadata profiles"
>> look at this class.
>>
>> http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/MetadataManager.java?view=markup 
>>
>>
>>
>> In MetadataManager the use of metadata profiles is explained too
>>
>> http://db.apache.org/ojb/api/org/apache/ojb/broker/metadata/MetadataManager.html 
>>
>>
>>
>> regards,
>> Armin
>>
>> >
>> >
>> > On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
>> >>
>> >> ABOU LINA wrote:
>> >> > thx for your reply .
>> >> >
>> >> > looking the example :
>> >> >
>> >> > // get MetadataManager instance
>> >> (1) > MetadataManager mm = MetadataManager.getInstance();
>> >> >
>> >> > // enable per thread mode if not done before
>> >> > mm.setEnablePerThreadChanges(true);
>> >> >
>> >> (2) > // Load additional object metadata by parsing an repository file
>> >> > DescriptorRepository dr_1 =
>> >> > mm.readDescriptorRepository("pathOrURLtoFile_1");
>> >> > DescriptorRepository dr_2 =
>> >> > mm.readDescriptorRepository("pathOrURLtoFile_2");
>> >> >
>> >> (3) > // add  profiles
>> >> > mm.addProfile("global", mm.copyOfGlobalRepository());
>> >> > mm.addProfile("guest", dr_1);
>> >> > mm.addProfile("admin", dr_2);
>> >> >
>> >> (4) > // now load a specific profile
>> >> > mm.loadProfile("admin");
>> >> (5) > broker = PersistenceBrokerFactory.defaultPersistenceBroker();
>> >> >
>> >> >
>> >> > MetaManager is a singleton i think. so in this case we will have a
>> >> > probleme with
>> >> > concurence access. if user A loadProfile("guest") and just after
>> >> > loading guest profile another user B (profile admin)
>> >> > execute broker = 
>> PersistenceBrokerFactory.defaultPersistenceBroker();
>> >> > so in this situation
>> >> > B got a broker with profile admin because MetaManager is a 
>> singleton.
>> >> >
>> >> > is right ????
>> >>
>> >> If each user (thread) use a different broker instance no. All steps
>> from
>> >> (1) to (3) have to be done once at startup of your application. 
>> Thus no
>> >> concurrency issues are expected.
>> >>
>> >> With step (4) the calling thread was associated with a specific 
>> profile
>> >> (using ThreadLocale). This call have to be done for each thread to 
>> load
>> >> the correct profile. Take care when using thread-pools (think e.g.
>> >> Tomcat use it) to reassign the correct profile for each calling user.
>> >> When OJB returns the broker instance (5) the profile for the current
>> >> thread was associated.
>> >>
>> >> In OJB test-suite we test the use of different metadata profiles in
>> >> MetadataMultithreadedTest and never detect problems with this feature.
>> >>
>> >> Again if user A and B (different threads) use different broker
>> instances
>> >> no concurrency issues are expected.
>> >>
>> >> regards,
>> >> Armin
>> >>
>> >>
>> >>
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
>> >> >>
>> >> >> Hi,
>> >> >>
>> >> >> ABOU LINA wrote:
>> >> >> > Hi;
>> >> >> >
>> >> >> > i have two mapping file : repository1.xml and repository2.xml.
>> >> >> >
>> >> >> > the difference between these two file are the value of auto-*
>> >> >> > [auto-retrieve, auto-update ..] ; at runtime sometimes i need to
>> use
>> >> >> > repository1.xml and somtimes the repository2.xml .
>> >> >> >
>> >> >> > what is the best and optimal  solution  about this conf ???
>> >> >> >
>> >> >>
>> >> >> You can use metadata profiles on per thread base.
>> >> >>
>> >> >>
>> >>
>> http://db.apache.org/ojb/docu/guides/metadata.html#Per+thread+metadata+changes 
>>
>> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >>
>> http://db.apache.org/ojb/docu/guides/metadata.html#Object+metadata+profiles 
>>
>> >>
>> >> >>
>> >> >>
>> >> >> This way you can load a specific metadata profiles 
>> (repository1.xmlor
>> >> >> repository2.xml) for the current thread.
>> >> >>
>> >> >> Take care of caching issues, e.g. obj1 from rep1 was used in rep2
>> >> >> environment will cause undetermined behavior. Thus it's recommended
>> to
>> >> >> use the two-level cache or only a session based (per broker) cache.
>> >> >>
>> >> >> regards,
>> >> >> Armin
>> >> >>
>> >> >>
>> >> >> > thx in advance
>> >> >> >
>> >> >>
>> >> >>
>> ---------------------------------------------------------------------
>> >> >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> >> >> For additional commands, e-mail: ojb-user-help@db.apache.org
>> >> >>
>> >> >>
>> >> >
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> >> For additional commands, e-mail: ojb-user-help@db.apache.org
>> >>
>> >>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Using two mapping file in the same project ?

Posted by ABOU LINA <am...@gmail.com>.
I have a problem to load the new profile :

1. i  put the mapping2.xml in the classpath of the project
2. i use the mm.readDescriptorRepository(InputStream map) insteadof (String
map)

i get : java.io.FileNoteFound : c:\eclipse\repository.dtd   ... !

if i used InputStream is beacause i want to make access to the
mapping2.xmlfrom the classpath , but the parser used in ojb is looking
the dtd from a
base directory !!!

any idea .

thx in advance

On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
>
> ABOU LINA wrote:
> > That's very good idea using threadLocal :) , thx very much about these
> > informations :).
> >
>
> My pleasure!
> All code for "metadata profiles" (by using ThreadLocale) is handled by
> class MetadataManager. If you have problems using "metadata profiles"
> look at this class.
>
> http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/MetadataManager.java?view=markup
>
>
> In MetadataManager the use of metadata profiles is explained too
>
> http://db.apache.org/ojb/api/org/apache/ojb/broker/metadata/MetadataManager.html
>
>
> regards,
> Armin
>
> >
> >
> > On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
> >>
> >> ABOU LINA wrote:
> >> > thx for your reply .
> >> >
> >> > looking the example :
> >> >
> >> > // get MetadataManager instance
> >> (1) > MetadataManager mm = MetadataManager.getInstance();
> >> >
> >> > // enable per thread mode if not done before
> >> > mm.setEnablePerThreadChanges(true);
> >> >
> >> (2) > // Load additional object metadata by parsing an repository file
> >> > DescriptorRepository dr_1 =
> >> > mm.readDescriptorRepository("pathOrURLtoFile_1");
> >> > DescriptorRepository dr_2 =
> >> > mm.readDescriptorRepository("pathOrURLtoFile_2");
> >> >
> >> (3) > // add  profiles
> >> > mm.addProfile("global", mm.copyOfGlobalRepository());
> >> > mm.addProfile("guest", dr_1);
> >> > mm.addProfile("admin", dr_2);
> >> >
> >> (4) > // now load a specific profile
> >> > mm.loadProfile("admin");
> >> (5) > broker = PersistenceBrokerFactory.defaultPersistenceBroker();
> >> >
> >> >
> >> > MetaManager is a singleton i think. so in this case we will have a
> >> > probleme with
> >> > concurence access. if user A loadProfile("guest") and just after
> >> > loading guest profile another user B (profile admin)
> >> > execute broker = PersistenceBrokerFactory.defaultPersistenceBroker();
> >> > so in this situation
> >> > B got a broker with profile admin because MetaManager is a singleton.
> >> >
> >> > is right ????
> >>
> >> If each user (thread) use a different broker instance no. All steps
> from
> >> (1) to (3) have to be done once at startup of your application. Thus no
> >> concurrency issues are expected.
> >>
> >> With step (4) the calling thread was associated with a specific profile
> >> (using ThreadLocale). This call have to be done for each thread to load
> >> the correct profile. Take care when using thread-pools (think e.g.
> >> Tomcat use it) to reassign the correct profile for each calling user.
> >> When OJB returns the broker instance (5) the profile for the current
> >> thread was associated.
> >>
> >> In OJB test-suite we test the use of different metadata profiles in
> >> MetadataMultithreadedTest and never detect problems with this feature.
> >>
> >> Again if user A and B (different threads) use different broker
> instances
> >> no concurrency issues are expected.
> >>
> >> regards,
> >> Armin
> >>
> >>
> >>
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> > On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
> >> >>
> >> >> Hi,
> >> >>
> >> >> ABOU LINA wrote:
> >> >> > Hi;
> >> >> >
> >> >> > i have two mapping file : repository1.xml and repository2.xml.
> >> >> >
> >> >> > the difference between these two file are the value of auto-*
> >> >> > [auto-retrieve, auto-update ..] ; at runtime sometimes i need to
> use
> >> >> > repository1.xml and somtimes the repository2.xml .
> >> >> >
> >> >> > what is the best and optimal  solution  about this conf ???
> >> >> >
> >> >>
> >> >> You can use metadata profiles on per thread base.
> >> >>
> >> >>
> >>
> http://db.apache.org/ojb/docu/guides/metadata.html#Per+thread+metadata+changes
> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >>
> http://db.apache.org/ojb/docu/guides/metadata.html#Object+metadata+profiles
> >>
> >> >>
> >> >>
> >> >> This way you can load a specific metadata profiles (repository1.xmlor
> >> >> repository2.xml) for the current thread.
> >> >>
> >> >> Take care of caching issues, e.g. obj1 from rep1 was used in rep2
> >> >> environment will cause undetermined behavior. Thus it's recommended
> to
> >> >> use the two-level cache or only a session based (per broker) cache.
> >> >>
> >> >> regards,
> >> >> Armin
> >> >>
> >> >>
> >> >> > thx in advance
> >> >> >
> >> >>
> >> >>
> ---------------------------------------------------------------------
> >> >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >> >> For additional commands, e-mail: ojb-user-help@db.apache.org
> >> >>
> >> >>
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >> For additional commands, e-mail: ojb-user-help@db.apache.org
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>

Re: Using two mapping file in the same project ?

Posted by Armin Waibel <ar...@apache.org>.
ABOU LINA wrote:
> That's very good idea using threadLocal :) , thx very much about these
> informations :).
>

My pleasure!
All code for "metadata profiles" (by using ThreadLocale) is handled by 
class MetadataManager. If you have problems using "metadata profiles" 
look at this class.
http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/MetadataManager.java?view=markup


In MetadataManager the use of metadata profiles is explained too
http://db.apache.org/ojb/api/org/apache/ojb/broker/metadata/MetadataManager.html 


regards,
Armin

> 
> 
> On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
>>
>> ABOU LINA wrote:
>> > thx for your reply .
>> >
>> > looking the example :
>> >
>> > // get MetadataManager instance
>> (1) > MetadataManager mm = MetadataManager.getInstance();
>> >
>> > // enable per thread mode if not done before
>> > mm.setEnablePerThreadChanges(true);
>> >
>> (2) > // Load additional object metadata by parsing an repository file
>> > DescriptorRepository dr_1 =
>> > mm.readDescriptorRepository("pathOrURLtoFile_1");
>> > DescriptorRepository dr_2 =
>> > mm.readDescriptorRepository("pathOrURLtoFile_2");
>> >
>> (3) > // add  profiles
>> > mm.addProfile("global", mm.copyOfGlobalRepository());
>> > mm.addProfile("guest", dr_1);
>> > mm.addProfile("admin", dr_2);
>> >
>> (4) > // now load a specific profile
>> > mm.loadProfile("admin");
>> (5) > broker = PersistenceBrokerFactory.defaultPersistenceBroker();
>> >
>> >
>> > MetaManager is a singleton i think. so in this case we will have a
>> > probleme with
>> > concurence access. if user A loadProfile("guest") and just after
>> > loading guest profile another user B (profile admin)
>> > execute broker = PersistenceBrokerFactory.defaultPersistenceBroker();
>> > so in this situation
>> > B got a broker with profile admin because MetaManager is a singleton.
>> >
>> > is right ????
>>
>> If each user (thread) use a different broker instance no. All steps from
>> (1) to (3) have to be done once at startup of your application. Thus no
>> concurrency issues are expected.
>>
>> With step (4) the calling thread was associated with a specific profile
>> (using ThreadLocale). This call have to be done for each thread to load
>> the correct profile. Take care when using thread-pools (think e.g.
>> Tomcat use it) to reassign the correct profile for each calling user.
>> When OJB returns the broker instance (5) the profile for the current
>> thread was associated.
>>
>> In OJB test-suite we test the use of different metadata profiles in
>> MetadataMultithreadedTest and never detect problems with this feature.
>>
>> Again if user A and B (different threads) use different broker instances
>> no concurrency issues are expected.
>>
>> regards,
>> Armin
>>
>>
>>
>> >
>> >
>> >
>> >
>> >
>> >
>> > On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
>> >>
>> >> Hi,
>> >>
>> >> ABOU LINA wrote:
>> >> > Hi;
>> >> >
>> >> > i have two mapping file : repository1.xml and repository2.xml.
>> >> >
>> >> > the difference between these two file are the value of auto-*
>> >> > [auto-retrieve, auto-update ..] ; at runtime sometimes i need to use
>> >> > repository1.xml and somtimes the repository2.xml .
>> >> >
>> >> > what is the best and optimal  solution  about this conf ???
>> >> >
>> >>
>> >> You can use metadata profiles on per thread base.
>> >>
>> >>
>> http://db.apache.org/ojb/docu/guides/metadata.html#Per+thread+metadata+changes 
>>
>> >>
>> >>
>> >>
>> >>
>> http://db.apache.org/ojb/docu/guides/metadata.html#Object+metadata+profiles 
>>
>> >>
>> >>
>> >> This way you can load a specific metadata profiles (repository1.xml or
>> >> repository2.xml) for the current thread.
>> >>
>> >> Take care of caching issues, e.g. obj1 from rep1 was used in rep2
>> >> environment will cause undetermined behavior. Thus it's recommended to
>> >> use the two-level cache or only a session based (per broker) cache.
>> >>
>> >> regards,
>> >> Armin
>> >>
>> >>
>> >> > thx in advance
>> >> >
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> >> For additional commands, e-mail: ojb-user-help@db.apache.org
>> >>
>> >>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Using two mapping file in the same project ?

Posted by ABOU LINA <am...@gmail.com>.
That's very good idea using threadLocal :) , thx very much about these
informations :).



On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
>
> ABOU LINA wrote:
> > thx for your reply .
> >
> > looking the example :
> >
> > // get MetadataManager instance
> (1) > MetadataManager mm = MetadataManager.getInstance();
> >
> > // enable per thread mode if not done before
> > mm.setEnablePerThreadChanges(true);
> >
> (2) > // Load additional object metadata by parsing an repository file
> > DescriptorRepository dr_1 =
> > mm.readDescriptorRepository("pathOrURLtoFile_1");
> > DescriptorRepository dr_2 =
> > mm.readDescriptorRepository("pathOrURLtoFile_2");
> >
> (3) > // add  profiles
> > mm.addProfile("global", mm.copyOfGlobalRepository());
> > mm.addProfile("guest", dr_1);
> > mm.addProfile("admin", dr_2);
> >
> (4) > // now load a specific profile
> > mm.loadProfile("admin");
> (5) > broker = PersistenceBrokerFactory.defaultPersistenceBroker();
> >
> >
> > MetaManager is a singleton i think. so in this case we will have a
> > probleme with
> > concurence access. if user A loadProfile("guest") and just after
> > loading guest profile another user B (profile admin)
> > execute broker = PersistenceBrokerFactory.defaultPersistenceBroker();
> > so in this situation
> > B got a broker with profile admin because MetaManager is a singleton.
> >
> > is right ????
>
> If each user (thread) use a different broker instance no. All steps from
> (1) to (3) have to be done once at startup of your application. Thus no
> concurrency issues are expected.
>
> With step (4) the calling thread was associated with a specific profile
> (using ThreadLocale). This call have to be done for each thread to load
> the correct profile. Take care when using thread-pools (think e.g.
> Tomcat use it) to reassign the correct profile for each calling user.
> When OJB returns the broker instance (5) the profile for the current
> thread was associated.
>
> In OJB test-suite we test the use of different metadata profiles in
> MetadataMultithreadedTest and never detect problems with this feature.
>
> Again if user A and B (different threads) use different broker instances
> no concurrency issues are expected.
>
> regards,
> Armin
>
>
>
> >
> >
> >
> >
> >
> >
> > On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
> >>
> >> Hi,
> >>
> >> ABOU LINA wrote:
> >> > Hi;
> >> >
> >> > i have two mapping file : repository1.xml and repository2.xml.
> >> >
> >> > the difference between these two file are the value of auto-*
> >> > [auto-retrieve, auto-update ..] ; at runtime sometimes i need to use
> >> > repository1.xml and somtimes the repository2.xml .
> >> >
> >> > what is the best and optimal  solution  about this conf ???
> >> >
> >>
> >> You can use metadata profiles on per thread base.
> >>
> >>
> http://db.apache.org/ojb/docu/guides/metadata.html#Per+thread+metadata+changes
> >>
> >>
> >>
> >>
> http://db.apache.org/ojb/docu/guides/metadata.html#Object+metadata+profiles
> >>
> >>
> >> This way you can load a specific metadata profiles (repository1.xml or
> >> repository2.xml) for the current thread.
> >>
> >> Take care of caching issues, e.g. obj1 from rep1 was used in rep2
> >> environment will cause undetermined behavior. Thus it's recommended to
> >> use the two-level cache or only a session based (per broker) cache.
> >>
> >> regards,
> >> Armin
> >>
> >>
> >> > thx in advance
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >> For additional commands, e-mail: ojb-user-help@db.apache.org
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>

Re: Using two mapping file in the same project ?

Posted by Armin Waibel <ar...@apache.org>.
ABOU LINA wrote:
> thx for your reply .
> 
> looking the example :
> 
> // get MetadataManager instance
(1) > MetadataManager mm = MetadataManager.getInstance();
> 
> // enable per thread mode if not done before
> mm.setEnablePerThreadChanges(true);
> 
(2) > // Load additional object metadata by parsing an repository file
> DescriptorRepository dr_1 = 
> mm.readDescriptorRepository("pathOrURLtoFile_1");
> DescriptorRepository dr_2 = 
> mm.readDescriptorRepository("pathOrURLtoFile_2");
> 
(3) > // add  profiles
> mm.addProfile("global", mm.copyOfGlobalRepository());
> mm.addProfile("guest", dr_1);
> mm.addProfile("admin", dr_2);
> 
(4) > // now load a specific profile
> mm.loadProfile("admin");
(5) > broker = PersistenceBrokerFactory.defaultPersistenceBroker();
> 
> 
> MetaManager is a singleton i think. so in this case we will have a 
> probleme with
> concurence access. if user A loadProfile("guest") and just after
> loading guest profile another user B (profile admin)
> execute broker = PersistenceBrokerFactory.defaultPersistenceBroker();
> so in this situation
> B got a broker with profile admin because MetaManager is a singleton.
> 
> is right ????

If each user (thread) use a different broker instance no. All steps from
(1) to (3) have to be done once at startup of your application. Thus no 
concurrency issues are expected.

With step (4) the calling thread was associated with a specific profile 
(using ThreadLocale). This call have to be done for each thread to load 
the correct profile. Take care when using thread-pools (think e.g. 
Tomcat use it) to reassign the correct profile for each calling user.
When OJB returns the broker instance (5) the profile for the current 
thread was associated.

In OJB test-suite we test the use of different metadata profiles in 
MetadataMultithreadedTest and never detect problems with this feature.

Again if user A and B (different threads) use different broker instances 
no concurrency issues are expected.

regards,
Armin



> 
> 
> 
> 
> 
> 
> On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
>>
>> Hi,
>>
>> ABOU LINA wrote:
>> > Hi;
>> >
>> > i have two mapping file : repository1.xml and repository2.xml.
>> >
>> > the difference between these two file are the value of auto-*
>> > [auto-retrieve, auto-update ..] ; at runtime sometimes i need to use
>> > repository1.xml and somtimes the repository2.xml .
>> >
>> > what is the best and optimal  solution  about this conf ???
>> >
>>
>> You can use metadata profiles on per thread base.
>>
>> http://db.apache.org/ojb/docu/guides/metadata.html#Per+thread+metadata+changes 
>>
>>
>>
>> http://db.apache.org/ojb/docu/guides/metadata.html#Object+metadata+profiles 
>>
>>
>> This way you can load a specific metadata profiles (repository1.xml or
>> repository2.xml) for the current thread.
>>
>> Take care of caching issues, e.g. obj1 from rep1 was used in rep2
>> environment will cause undetermined behavior. Thus it's recommended to
>> use the two-level cache or only a session based (per broker) cache.
>>
>> regards,
>> Armin
>>
>>
>> > thx in advance
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Using two mapping file in the same project ?

Posted by ABOU LINA <am...@gmail.com>.
thx for your reply .

looking the example :

// get MetadataManager instance
MetadataManager mm = MetadataManager.getInstance();

// enable per thread mode if not done before
mm.setEnablePerThreadChanges(true);

// Load additional object metadata by parsing an repository file
DescriptorRepository dr_1 = mm.readDescriptorRepository("pathOrURLtoFile_1");
DescriptorRepository dr_2 = mm.readDescriptorRepository("pathOrURLtoFile_2");

// add  profiles
mm.addProfile("global", mm.copyOfGlobalRepository());
mm.addProfile("guest", dr_1);
mm.addProfile("admin", dr_2);

// now load a specific profile
mm.loadProfile("admin");
broker = PersistenceBrokerFactory.defaultPersistenceBroker();


MetaManager is a singleton i think. so in this case we will have a probleme with
concurence access. if user A loadProfile("guest") and just after
loading guest profile another user B (profile admin)
execute broker = PersistenceBrokerFactory.defaultPersistenceBroker();
so in this situation
B got a broker with profile admin because MetaManager is a singleton.

is right ????











On 5/24/06, Armin Waibel <ar...@apache.org> wrote:
>
> Hi,
>
> ABOU LINA wrote:
> > Hi;
> >
> > i have two mapping file : repository1.xml and repository2.xml.
> >
> > the difference between these two file are the value of auto-*
> > [auto-retrieve, auto-update ..] ; at runtime sometimes i need to use
> > repository1.xml and somtimes the repository2.xml .
> >
> > what is the best and optimal  solution  about this conf ???
> >
>
> You can use metadata profiles on per thread base.
>
> http://db.apache.org/ojb/docu/guides/metadata.html#Per+thread+metadata+changes
>
>
> http://db.apache.org/ojb/docu/guides/metadata.html#Object+metadata+profiles
>
> This way you can load a specific metadata profiles (repository1.xml or
> repository2.xml) for the current thread.
>
> Take care of caching issues, e.g. obj1 from rep1 was used in rep2
> environment will cause undetermined behavior. Thus it's recommended to
> use the two-level cache or only a session based (per broker) cache.
>
> regards,
> Armin
>
>
> > thx in advance
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>

Re: Using two mapping file in the same project ?

Posted by Armin Waibel <ar...@apache.org>.
Hi,

ABOU LINA wrote:
> Hi;
> 
> i have two mapping file : repository1.xml and repository2.xml.
> 
> the difference between these two file are the value of auto-*
> [auto-retrieve, auto-update ..] ; at runtime sometimes i need to use
> repository1.xml and somtimes the repository2.xml .
> 
> what is the best and optimal  solution  about this conf ???
>

You can use metadata profiles on per thread base.
http://db.apache.org/ojb/docu/guides/metadata.html#Per+thread+metadata+changes

http://db.apache.org/ojb/docu/guides/metadata.html#Object+metadata+profiles

This way you can load a specific metadata profiles (repository1.xml or 
repository2.xml) for the current thread.

Take care of caching issues, e.g. obj1 from rep1 was used in rep2 
environment will cause undetermined behavior. Thus it's recommended to 
use the two-level cache or only a session based (per broker) cache.

regards,
Armin


> thx in advance
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org