Sacha Labourey wrote:

>Could you please try the read-only tag at the method level, as described by
>Bill. It does work. If it doesn't, it is a bug and it would be good to know
>about it.
>
>Cheers,
>
>
>                       Sacha
>
>  
>
Well, I am confused now: are u sure <read-only> attribute can be applyed 
to EBs?
I use jboss-3.0.3

So I made a simple test (I will include here only significant code). I 
have a simple EB (UserBean) only with local interfaces (User and 
UserHome) and
a SLSB (facade) GatewayBean with only one business method 
addBalances(String uid1, String uid2), method that reads the 2 beans and 
return the added balances.

BUSINESS(method from the GatewayBean):
--------------------------------------------------------------------------
public int addBalances(String uid1, String uid2) {
        logger.info(uid1+","+uid2+" start");
        try {
            User user1 = userHome.findByPrimaryKey(new UserPK(uid1));
            int balance1 = user1.getModel().balance;
           
            User user2 = userHome.findByPrimaryKey(new UserPK(uid2));
            int balance2 = user2.getModel().balance;
           
            return (balance1 + balance2);
           
        } catch (Exception e) {
            logger.error(e);
            return 0;
        }    finally {
            logger.info(uid1+","+uid2+" end");
        }
}
--------------------------------------------------------------------------


CONFIGURATION(jboss.xml):
--------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
 
<!DOCTYPE jboss PUBLIC
   "-//JBoss//DTD JBOSS 3.0//EN"
   "http://www.jboss.org/j2ee/dtd/jboss_3_0.dtd";>

<jboss>
  <secure>false</secure>
  <container-configurations>
          <container-configuration>
                <container-name>Standard CMP 2.x 
EntityBean</container-name>              
                <commit-option>A</commit-option>
        </container-configuration>
       
        <container-configuration>
                <container-name>Instance Per Transaction CMP 2.x 
EntityBean</container-name>              
                <commit-option>A</commit-option>
        </container-configuration>
  </container-configurations>
 
  <resource-managers/>

  <enterprise-beans>
          <session>
              <ejb-name>GatewayBean</ejb-name>
              <jndi-name>ejb/Gateway</jndi-name>
        </session>

        <entity>
              <ejb-name>UserBean</ejb-name>
              <local-jndi-name>ejb/User</local-jndi-name>         
              <!--
              <configuration-name>Instance Per Transaction CMP 2.x 
EntityBean</configuration-name>                
              -->            
              <configuration-name>Standard CMP 2.x 
EntityBean</configuration-name>            
             
             
              <method-attibutes>
                      <method>
                              <method-name>getModel</method-name>
                              <read-only>true</read-only>
                      </method>
              </method-attibutes>
             
        </entity>
       
  </enterprise-beans>
</jboss>
--------------------------------------------------------------------------


THE SCENARIO (client side):
--------------------------------------------------------------------------
public void computeBalances(String args[]){
              try {
                int count = Integer.parseInt(args[0]);
                String uid1 = args[1];
                String uid2 = args[2];   
               
                Gateway gw = getHome().create();
                for (int i = 0; i < count; i++) {
                    logger.info("sum = "+gw.addBalances(uid1,uid2));   
                    Thread.sleep((long)(50*Math.random()));           
                }           
               
            } catch (Exception e) {
                logger.error(e);
            }       
}
--------------------------------------------------------------------------


THE RESULTS
--------------------------------------------------------------------------
"Standard CMP 2.x EntityBean" and NO <read-only> method level -> 
DEADLOCK ALWAYS
"Standard CMP 2.x EntityBean" and <read-only> method level -> DEADLOCK 
ALWAYS

"Instance Per Transaction CMP 2.x EntityBean" and NO <read-only> method 
level -> NO DEADLOCK
"Instance Per Transaction CMP 2.x EntityBean" and <read-only> method 
level -> NO DEADLOCK
--------------------------------------------------------------------------

So, what is the real semnification of the <read-only> tag applied at 
method level?
And BTW, what NoLock policy really does?

Thanks.




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to