En l'instant précis du 02/15/07 15:39, Caldarale, Charles R s'exprimait
en ces termes:
>> From: Angel Todorov [mailto:[EMAIL PROTECTED] 
>> Subject: Re: using JNDI to share object reference between two apps
>>
>> Does tomcat perform explicit serialization of everything, even if JNDI
>> is used locally on the same JVM ?
>>     
>
> This has nothing to do with serialization; no serialization is occuring
> - only references to objects are stored here.
>
>   
>> Sure the producer (bind) and the consumer (lookup) will
>> use the same interface, but the producer doesn't have to
>> care about the classes used "behind" that interface,
>>     
>
>   
My experience have shown that, if you only use interfaces and the
interfaces are in the same class loader, the actual classes do no matter.

Example (using classloader documentation):

          Bootstrap
              |
           System
              |
           Common
          /      \
     Catalina   Shared  <-- contains interface X
                 /   \
            Webapp1  Webapp2 ...  
              ^
              |
              --- contains implementation Y of interface X

Webapp2 can do safetly a
X sharedX = (X)objectGottenFromGlobalContext;

However, doing this will throw exception because different loaders

Y sharedY = (Y)objectGottenFromGlobalContext;

I have done a pretty similar operation here, except, in my case, interface X 
was in Common and the implementation was in Catalina 
(X was a subclass of Principal that stored user password, my Realm was 
producing it and my webapp was consuming it)
 


> The producer and consumer most definitely *DO* have to care about the
> classes used.  The same class loaded by the same classloader must be
> visible to both webapps.  Consequently, that class will have to reside
> in shared/lib, common/lib, or be one supplied by the JRE.  Classes
> inside WEB-INF/lib are only visible to that particular webapp, even if
> they have the same name as a class used in another webapp.
>
> Read the classloader doc:
> http://tomcat.apache.org/tomcat-5.5-doc/class-loader-howto.html
>
>  - Chuck
>
>
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you
> received this in error, please contact the sender and delete the e-mail
> and its attachments from all computers.
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>   


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to