Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why CMT session bean must specify for all business methods in the component interface

 
Steven Gao Song
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, everyone,

HFEJB Page 509, it says that A CMT session bean must specify attributes for all business methods in the component interface. I am confused.

For example, I have a business method advice() in the component interface, it just returns a piece of advice generated by the session bean, why it MUST be specified a transaction attribute? Who could explain for me? Thank you very much.
 
Mikalai Zaikin
Ranch Hand
Posts: 3367
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Steven Gao Song:
Hi, everyone,

HFEJB Page 509, it says that A CMT session bean must specify attributes for all business methods in the component interface. I am confused.

For example, I have a business method advice() in the component interface, it just returns a piece of advice generated by the session bean, why it MUST be specified a transaction attribute? Who could explain for me? Thank you very much.


Hello, this is a requirement of EJB 2.0 (ejb-2_0-fr2-spec.pdf):

Please look at page 351 of EJB 2.0 (section 17.4.1) :


The transaction attribute must be specified for the following methods:

� For a session bean, the transaction attributes must be specified for the methods defined in the
bean�s component interface and all the direct and indirect superinterfaces of the component
interface, excluding the methods of the javax.ejb.EJBObject or
javax.ejb.EJBLocalObject interface. Transaction attributes must not be specified for
the methods of a session bean�s home interface.
...


They (attributes) must be defined either by Application Assembler or Deployer.

regards,
MZ
 
Steven Gao Song
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, Mikalai.

But I have another question.

Transaction attributes are used to specify the bean methods, right?

However, the spec says "the methods defined in the bean�s component interface". Tran-attributes are used to specify the bean methods, or
the methods in client-view?
 
chao cai
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the container will invoke the ejbLoad and ejbStore to synchronize the data ,so when client invoke the biz method,the container will synchronize the data,so require transcation.
 
Mikalai Zaikin
Ranch Hand
Posts: 3367
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Steven Gao Song:
Thank you, Mikalai.

But I have another question.

Transaction attributes are used to specify the bean methods, right?

However, the spec says "the methods defined in the bean�s component interface". Tran-attributes are used to specify the bean methods, or
the methods in client-view?


Howdy !

Specification says about only methods from bean�s component interface.
So, they are (1) declared in component interface (2) implemented in bean class. 8-)

You may add as many as you want helper methods in bean [implementation] class, but they should not have transaction attribute in DD.

regards,
MZ
 
Steven Gao Song
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. I got it. Thank you all.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic