But now you put the onus on the client code to know exactly how the server
bean works and depends.  Not a great MVC design, although it would work
around the limitation.  Its also not "interruption" but incremental
processing.  I just say this because I want ppl on the newsgroup to see EJB
is single threaded.

Dave Wolf
Internet Applications Division
Sybase


> -----Original Message-----
> From: A mailing list for Enterprise JavaBeans development
> [mailto:[EMAIL PROTECTED]]On Behalf Of Kristijan Cvetkovic
> Sent: Saturday, September 16, 2000 7:44 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Restarting facility in stateless bean
>
>
> Hello Dave,
>
>
> > But how would be interupt the running process?  In other words, he says
> that
> > another thread could set the boolean value to keep running to be false.
> > Since EJB forbids concurrent access to the bean, he can spawn all the
> client
> > threads he wants, but only one thread at a time can be running in the
> > session bean.  So its impossible to interrupt the process.
>
> The point is that the ejb processing is not interrupted by another thread.
> It's interrupting itself. The method executeRule() returns after let's say
> 10 cycles. Take a look at the (current%number != 0) in the while
> statement:
>
> <Bean code>
> ...
> private int number = 0;
> private int current = 1;
> ...
> public void ejbCreate(int n) {
>     number = n;
>     current = 1;
> }
>
> public boolean executeRule(){
>
>        while (EOF && (current%number != 0)){
>         read current record from file
>         process it
>         write back it to file
>         current++;
>        }
>
>         if (EOF) return true else return false;
> }
> </Bean code>
>
> A Client, e.g. java application, can now decide to reinvoke the
> method or to
> wait. Here you can use threads to implement a stop mechanism:
>
> <Client code NOT AN EJB>
> WorkingBean bean = WorkingBeanHome.create(10);
>
> boolean done = false;
>
> // another thread could set it to true, e.g. behind a stop button
> in a swing
> GUI
> boolean suspended = false;
>
> while (!done) {
>     (if !suspended) {
>         done = bean.executeRule();
>     } else {
>         this.wait();
>     }
> }
>
> bean.remove();
> </Client code NOT AN EJB>
>
> regards,
> --
> [EMAIL PROTECTED]
>
> MATHEMA Software GmbH
> N�gelsbachstra�e 25 b
> 91052 E r l a n g e n
> D e u t s c h l a n d
> Tel +49(0)9131/8903-0
> Fax +49(0)9131/8903-55
> http://www.mathema.de
>
> ==================================================================
> =========
> 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".

Reply via email to