File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Why CMT session bean must specify for all business methods in the component interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Why CMT session bean must specify for all business methods in the component interface" Watch "Why CMT session bean must specify for all business methods in the component interface" New topic
Author

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

Steven Gao Song
Ranch Hand

Joined: Oct 02, 2006
Posts: 78
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

Joined: Jun 04, 2002
Posts: 3178
    
    3
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


Free SCDJWS 5.0 Study Guide - SCDJWS 5.0 Quiz (How to get SCDJWS 5.0 Quiz)
Java Platform, Enterprise Edition 6 Web Services Developer Certified Expert Exam Study Guide and Quiz
Steven Gao Song
Ranch Hand

Joined: Oct 02, 2006
Posts: 78
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

Joined: May 26, 2005
Posts: 154
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.


SCEA<br />SCJP 1.2<br />SCBCD<br />MCSD<br />IBM Certified Specialist RUP v2003<br />IBM Certified Solution Designer OOAD vUML2<br /> <br />Phone Number:86-010-82776427
Mikalai Zaikin
Ranch Hand

Joined: Jun 04, 2002
Posts: 3178
    
    3
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

Joined: Oct 02, 2006
Posts: 78
Ok. I got it. Thank you all.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Why CMT session bean must specify for all business methods in the component interface
 
Similar Threads
stateless bean component interface question
Bean implementing the component interface
Transaction attribute with EJB methods
HFEJP p.520 Q3: Why MUST every business method have a transaction attribute?
SessionSynchronization