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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED]
>> >> For additional commands, e-mail: [EMAIL PROTECTED]
>> >>
>> >>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>

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




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

Reply via email to