On Fri, 2003-11-21 at 21:13, Alexey Loubyansky wrote:
> You are doing it wrong. In ejbPassivate the flag should be set to false. 
> Please, read about activation/passivation in the spec.
> There is also a nice picture on this subject.
> 

Alexey,

I've read the EJB spec but I only found one error that happens when the
load is called on my entity bean. The load is always called before an
activate() even the entity bean isn't changed (read-only for instance),
which would always eliminates my cache effect.

So look at my sample below. First, the cache is false, and after the
first business method is called the cache is set. The cache will be
unset only when the load() is called that will be when the activate is
called. 

I could remove the unset code in the load() but if my entity bean change
(e.g. a store procedure) I won't be able to reload my entity bean data
ever.

Do you have any idea how to improve the cache effect here?

"
    private boolean cache;
    private String value;

    public String getValue() {
        if(cache){
            this.logger.info("cached sum is "+this.value);
        }
        else {
            this.logger.info("processing sum...");
            int sum=0;
            for(int i=0;i<10000;i++)
                sum+=i;
            this.value=String.valueOf(sum);
            this.logger.info("sum is "+this.value);
            this.cache=true;
        }
        return this.value;
    }

    public void ejbLoad() {
        if(logger.isDebugEnabled())
            logger.debug("Load Primitive ...");
        this.cache=false;
        this.value=null;
    }
"

regards,
Pedro Salazar.
-- 
-PS



-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to