Yes, you're right Dave. But think about this situation:
- The singleton object is very large (about 500 Mb). So if it's
represented by an Entity Bean could be passivated (big delays writting in
database) or loaded from database (big delays again).
- Accessing data base is too slow for our purposes.
- Accessing this singleton object using RMI methods is too slow.
- We have better performance using this pattern instead of using
entity beans.
- The class "MySingleton" is not an EJB, so the restriction 18.1.2
a) of Specs. is not applicable here (I think, and I hope ;-) )
No problem if there is a singleton object in each JVM (I'm thinking about
clusters). So it's a little "exotic singleton", isn't it?
Could you say me some of those ClassLoaders and which containers use them? I
would want to test them with my code.
Thank you for your answer. Regards
-----Original Message-----
From: Dave Wolf [mailto:[EMAIL PROTECTED]]
Sent: martes, 26 de septiembre de 2000 12:36
To: [EMAIL PROTECTED]
Subject: Re: Using singleton from EJBs (not implementing singleton with
EJB!)
Seems to me that an entity bean is logically a singleton. Could you use an
entity bean?
A singleton pattern will not be very portable. Even if the static member
were portable which it is not, the use of custom ClassLoaders by most
containers will likely cause issues with your pattern.
Dave Wolf
Internet Applications Division
Sybase
> -----Original Message-----
> From: A mailing list for Enterprise JavaBeans development
> [mailto:[EMAIL PROTECTED]]On Behalf Of Luis Canals
> Sent: Tuesday, September 26, 2000 5:14 AM
> To: [EMAIL PROTECTED]
> Subject: Using singleton from EJBs (not implementing singleton with
> EJB!)
>
>
> Hi gurus,
>
> I have a little "phylosophical" question about using singletons from an
> application which has EJBs. I'll tell you my problem and my purpose
> solution:
> -Problem: We want (in each computer if there is a
> cluster, so there
> is no problem about this) an unique object (singleton). And we want to use
> EJBs to build our application.
> -Solution: Really, we can't use an EJB to implement the singleton
> pattern (see http://www.jguru.com/jguru/faq/view.jsp?EID=37838), so our
> singleton object must be implemented with "traditional" Java classes.
> Singleton looks like this code (see "Design patterns",
> Gamma/Helm/Johnson/Vlissides, Addsion Wesley)
> public class MySingleton {
> private static MySingleton instance;
> public static Singleton getInstance() {
> if(instance==null) instance = new MySingleton();
> return instance;
> }
> // Non-static methods...
> }
>
> Now, from our EJBs, we access to this singleton through this code:
> MySingleton the_instance =
> MySingleton.getInstance();
> the_instance.aMethod();
>
> The question for you is: what do you think about this? Is it good/ is it
> bad?
> Do you think this implementation is not compliant with EJB 1.1
> Specifications (which, in section 18.1.2 forbides the use of static fields
> inside EJBs?
> Which problems do you see?
>
> TIA and regards.
>
> Luis Canals
>
>
> This message and any files transmitted with it are confidential
> and intended
> solely for the use of the individual or entity to whom they are addressed.
> No confidentiality or privilege is waived or lost by any wrong
> transmission.
> If you have received this message in error, please immediately destroy it
> and kindly notify the sender by reply email.
> You must not, directly or indirectly, use, disclose, distribute, print, or
> copy any part of this message if you are not the intended recipient.
> Opinions, conclusions and other information in this message that do not
> relate to the official business of Newknow shall be understood as neither
> given nor endorsed by it.
>
> ==================================================================
> =========
> To unsubscribe, send email to [EMAIL PROTECTED] and include
> in the body
> of the message "signoff EJB-INTEREST". For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
>
>
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
This message and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
No confidentiality or privilege is waived or lost by any wrong transmission.
If you have received this message in error, please immediately destroy it
and kindly notify the sender by reply email.
You must not, directly or indirectly, use, disclose, distribute, print, or
copy any part of this message if you are not the intended recipient.
Opinions, conclusions and other information in this message that do not
relate to the official business of Newknow shall be understood as neither
given nor endorsed by it.
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".