Re: AW: Synchronizing ejb method
Tareq Ayub <[email protected]> Thu, 18 May 2006 21:24:42 -0500
| Newsgroups | gmane.comp.java.sun.ejb.general |
|---|---|
| Message-ID | <[email protected]> |
--Apple-Mail-14-47074737
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=ISO-8859-1;
delsp=yes;
format=flowed
Refer to the EJB spec. The container will not allow multiple threads =20
to use the same instance of an SLSB. =46rom the spec - "The container =20=
must ensure that only one thread can be executing an instance at any =20
time". Given that, why would you want to synchronize on an EJB method =20=
anyways ? Also, SLSB have no state (no instance variables). The same =20=
principle applies to SFSB in addition to the fact an instance is tied =20=
to a single client.
Tareq
On May 15, 2006, at 2:40 AM, Andreas Berg wrote:
> You shouldn't. The only reason to synchronize a stateless session =20
> bean is if your bean is not stateless. Then ask yourself why you =20
> chose a stateless bean for some stateful purpose.
>
> If you really want to synchronize your SLSB you need to think about =20=
> the runtime environment. If all the instances of the SLSB run in a =20
> single JVM, you can use the standard Java synchronization features =20
> inside the bean to synchronize. But this doesn't work with a =20
> clustered environment. AFAIK there is no standard approach to solve =20=
> this.
>
> Kind regards,
>
> Andreas.
>
>
> Andreas Berg
> Zelfi AG
> Hechtsheimer Stra=DFe 33
> 55131 Mainz
> Telefon: 06131-9064850
> Telefax: 06131-9064853
> [email protected]
> http://www.zelfi.com/
>
>
> Von: A mailing list for Enterprise JavaBeans development =20
> [mailto:[email protected]] Im Auftrag von Kalra, Ashwani
> Gesendet: Montag, 15. Mai 2006 06:42
> An: [email protected]
> Betreff: Synchronizing ejb method
>
> Hi,
> The client of my ejb can be an jsp or standalone java class. How =20
> can I synchronize access to the SLSB ejb method? I am using ejb2.0 =20
> version
>
>
> __________________
> Regards
> Ashwani Kalra
>
>
> This message contains information that may be privileged or =20
> confidential and is the property of the Capgemini Group. It is =20
> intended only for the person to whom it is addressed. If you are =20
> not the intended recipient, you are not authorized to read, print, =20
> retain, copy, disseminate, distribute, or use this message or any =20
> part thereof. If you receive this message in error, please notify =20
> the sender immediately and delete all copies of this message.
>
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=20
> =3D=3D=3D=3D=3D To unsubscribe, send email to [email protected] =
and =20
> include in the body of the message "signoff EJB-INTEREST". For =20
> general help, send email to [email protected] and include in =20
> the body of the message "help".
>
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=20
> =3D=3D=3D=3D=3D To unsubscribe, send email to [email protected] =
and =20
> include in the body of the message "signoff EJB-INTEREST". For =20
> general help, send email to [email protected] and include in =20
> the body of the message "help".
>
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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".
--Apple-Mail-14-47074737
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
charset=ISO-8859-1
<HTML><BODY style=3D"word-wrap: break-word; -khtml-nbsp-mode: space; =
-khtml-line-break: after-white-space; ">Refer to the EJB spec. The =
container will not allow multiple threads to use the same instance of an =
SLSB. =46rom the spec - "<FONT class=3D"Apple-style-span" face=3D"Verdana"=
size=3D"3"><SPAN class=3D"Apple-style-span" style=3D"font-size: =
13px;">The container must ensure that only one thread can be executing =
an instance at any time". Given that, why would you want to synchronize =
on an EJB method anyways ? Also, SLSB have no state (no instance =
variables).=A0 The same principle applies to SFSB in addition to the =
fact an instance is tied to a single client.</SPAN></FONT><DIV><BR =
class=3D"khtml-block-placeholder"></DIV><DIV><FONT =
class=3D"Apple-style-span" face=3D"Verdana" size=3D"3"><SPAN =
class=3D"Apple-style-span" style=3D"font-size: =
13px;"></SPAN></FONT>Tareq<DIV><FONT class=3D"Apple-style-span" =
face=3D"Verdana" size=3D"3"><SPAN class=3D"Apple-style-span" =
style=3D"font-size: 13px;"><BR></SPAN></FONT><DIV><DIV>On May 15, 2006, =
at 2:40 AM, Andreas Berg wrote:</DIV><BR =
class=3D"Apple-interchange-newline"><BLOCKQUOTE type=3D"cite"> <DIV =
dir=3D"ltr" align=3D"left"><FONT face=3D"Arial" color=3D"#0000ff" =
size=3D"2"><SPAN class=3D"265003407-15052006">You shouldn't.=A0The only =
reason=A0to synchronize a stateless session bean is if your bean is not =
stateless. Then ask yourself why you chose a stateless bean for some =
stateful purpose.</SPAN></FONT></DIV> <DIV dir=3D"ltr" =
align=3D"left"><FONT face=3D"Arial" color=3D"#0000ff" size=3D"2"><SPAN =
class=3D"265003407-15052006"></SPAN></FONT>=A0</DIV> <DIV dir=3D"ltr" =
align=3D"left"><FONT face=3D"Arial" color=3D"#0000ff" size=3D"2"><SPAN =
class=3D"265003407-15052006">If you really want to synchronize your SLSB =
you need to think about the runtime environment. If all the instances of =
the SLSB run in a single JVM, you can use the standard Java =
synchronization features inside the bean to synchronize. But this =
doesn't work with a clustered environment. AFAIK there is no standard =
approach to solve this.</SPAN></FONT></DIV> <DIV dir=3D"ltr" =
align=3D"left"><FONT face=3D"Arial" color=3D"#0000ff" size=3D"2"><SPAN =
class=3D"265003407-15052006"></SPAN></FONT>=A0</DIV> <DIV dir=3D"ltr" =
align=3D"left"><FONT face=3D"Arial" color=3D"#0000ff" size=3D"2"><SPAN =
class=3D"265003407-15052006">Kind regards,</SPAN></FONT></DIV> <DIV =
dir=3D"ltr" align=3D"left"><FONT face=3D"Arial" color=3D"#0000ff" =
size=3D"2"><SPAN class=3D"265003407-15052006"></SPAN></FONT>=A0</DIV> =
<DIV dir=3D"ltr" align=3D"left"><FONT face=3D"Arial" color=3D"#0000ff" =
size=3D"2"><SPAN class=3D"265003407-15052006">Andreas.</SPAN></FONT></DIV>=
<DIV>=A0</DIV> <DIV align=3D"left"><FONT face=3D"Arial" color=3D"#000000"=
size=3D"2"></FONT>=A0</DIV> <DIV align=3D"left"><FONT face=3D"Arial" =
color=3D"#808000" size=3D"1">Andreas Berg<BR>Zelfi AG<BR>Hechtsheimer =
Stra=DFe 33<BR>55131 Mainz<BR>Telefon: =
06131-9064850<BR>Telefax:=A006131-9064853</FONT></DIV> <DIV =
align=3D"left"><FONT face=3D"Arial" color=3D"#808000" size=3D"1"><A =
href=3D"mailto:[email protected]">[email protected]</A></FONT></=
DIV> <DIV align=3D"left"><FONT face=3D"Arial" color=3D"#808000" =
size=3D"1"><A =
href=3D"http://www.zelfi.com/">http://www.zelfi.com/</A></FONT></DIV> =
<DIV>=A0</DIV><BR> <DIV class=3D"OutlookMessageHeader" lang=3D"de" =
dir=3D"ltr" align=3D"left"> <HR tabindex=3D"-1"> <FONT face=3D"Tahoma" =
size=3D"2"><B>Von:</B> A mailing list for Enterprise JavaBeans =
development [<A =
href=3D"mailto:[email protected]">mailto:[email protected]=
</A>] <B>Im Auftrag von </B>Kalra, Ashwani<BR><B>Gesendet:</B> Montag, =
15. Mai 2006 06:42<BR><B>An:</B> <A =
href=3D"mailto:[email protected]">[email protected]</A><BR=
><B>Betreff:</B> Synchronizing ejb method<BR></FONT><BR></DIV> =
<DIV></DIV> <DIV><SPAN class=3D"087493904-15052006"><FONT face=3D"Arial" =
size=3D"2">Hi,</FONT></SPAN></DIV> <DIV><SPAN =
class=3D"087493904-15052006"><FONT face=3D"Arial" size=3D"2">The client =
of my ejb can be an jsp or standalone java class.=A0 How can I =
synchronize access to the SLSB ejb method? I am using ejb2.0 =
version</FONT></SPAN></DIV> <DIV><SPAN class=3D"087493904-15052006"><FONT =
face=3D"Arial" size=3D"2"></FONT></SPAN>=A0</DIV> <DIV>=A0</DIV><P><SPAN =
lang=3D"en-us"><FONT face=3D"Arial" =
size=3D"2">__________________</FONT></SPAN> <BR><SPAN lang=3D"en-us"><FONT=
face=3D"Tahoma" size=3D"2">Regards</FONT></SPAN> <BR><SPAN =
lang=3D"en-us"><B><FONT face=3D"Tahoma" size=3D"2">Ashwani =
Kalra</FONT></B></SPAN> <BR></P> <DIV>=A0</DIV> <TABLE> <TBODY><TR><TD =
bgcolor=3D"#ffffff"><FONT color=3D"#000000">This message contains =
information that may be privileged or confidential and is the =
property of the Capgemini Group. It is intended only for the =
person to whom it is addressed. If you are not the intended =
recipient, you are not authorized to read, print, retain, copy, =
disseminate, distribute, or use this message or any part thereof. =
If you receive this message in error, please notify the sender =
immediately and delete all copies of this =
message.<BR><BR></FONT></TD></TR></TBODY></TABLE>=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D To unsubscribe, send =
email to <A =
href=3D"mailto:[email protected]">[email protected]</A> and =
include in the body of the message "signoff EJB-INTEREST". For general =
help, send email to <A =
href=3D"mailto:[email protected]">[email protected]</A> and =
include in the body of the message "help". <DIV><BR =
class=3D"khtml-block-placeholder"></DIV> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
To unsubscribe, send email to <A =
href=3D"mailto:[email protected]">[email protected]</A> and =
include in the body of the message "signoff EJB-INTEREST". For general =
help, send email to <A =
href=3D"mailto:[email protected]">[email protected]</A> and =
include in the body of the message "help". <DIV><BR =
class=3D"khtml-block-placeholder"></DIV></BLOCKQUOTE></DIV><BR></DIV></DIV=
></BODY></HTML>=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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".
<p>
--Apple-Mail-14-47074737--