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 Question on SLSB Contract - SCBCD Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Question on SLSB Contract - SCBCD" Watch "Question on SLSB Contract - SCBCD" New topic
Author

Question on SLSB Contract - SCBCD

Ravi Narala
Greenhorn

Joined: Oct 23, 2007
Posts: 16
Hello,
I am preparing for SCBCD. I have a doubt in regards to the question below. I was choosing B and D. Please correct me if I am wrong. I would appreciate if someone could shed some light on this.

public interface B1 {}
public interface B2 {}


A java class is defined as:

@Stateless
public class Bean implements B1 ,B2


Which two statements are correct for making this code work as a stateless session bean, considering that this session bean is NOT defined in a deployment descriptor and the interfaces do NOT have annotations? (Choose two.)

A - Only the interface for remote usage must be annotated.
B - The interfaces B1 and B2 can only be used locally without changing the code.
C - Both interfaces B1 and B2 must be annotated to make this a working stateless session bean.
D - The interfaces B1 and B2 can be annotated differently, one with @Local and the other with @Remote.

regards,
Ravi


SCJP, SCWCD5, SCBCD5, SCDJWS
IBM Certified Websphere 6.1 Core Admin
IBM Certified SOA Solution Designer
SCEA Part 1
Amandeep Singh
Ranch Hand

Joined: Jul 17, 2008
Posts: 845
Ravi,

Please let us know why you are chossing B & D. what are the correct answer.

My choice would go with A and B answer.


SCJP 1.4, SCWCD 5, SCBCD 5, OCPJWSD 5,SCEA-1, Started Assignment Part 2
My blog- http://rkydesigns.blogspot.com
Graeme Jenkinson
Greenhorn

Joined: Sep 08, 2008
Posts: 27
Hi,

I would answer C and D. I think C is correct because my understanding is that if a sesssion bean implements a single interface then it defaults to Local whereas if a session bean implements two (or more) interfaces there must be explicitly annotated or defined in the deployment descriptor. I think D is correct beacuse I can't see any issue with a seesion bean implementing both Local and Remote interfaces (I'm sure that the O'Reilly EJB 3.0 gives an example of this in Chapter 11).

I'll take a look at the spec to see whether my understanding is correct. Meanwhile if anybody knows for sure I'd be interested in the answer and the reasoning.

thanks,

Graeme
Karnati Sudhakar
Ranch Hand

Joined: Aug 26, 2008
Posts: 270

I think correct answers are A,B and D.

I verified with the following code:

Bean interfaces similar to B1 and B2 in your case:

StatelessSession1.java



StatelessSession2.java




Bean class implementing bean interfaces

StatelessSessionBean.java




Accessing them from servlet to verify.

Servlet2Stateless.java




I am getting the output as :

Greeting from StatelessSessionBean1: Hello1,Dieter!
Greeting from StatelessSessionBean2: Hello2,Dieter!



Please correct me if i am wrong.

Regards
Sudhakar


Regards
Sudhakar
Chaminda Amarasinghe
Ranch Hand

Joined: May 17, 2006
Posts: 402
Answer is very clear

See this quote of spec

• If bean class implements a single interface, that interface is assumed to be the business interface of the bean. This business interface will be a local interface unless the interface is designated as a remote business interface by use of the Remote annotation on the bean class or interface or by means of the deployment descriptor.

• A bean class is permitted to have more than one interface. If a bean class has more than one interface excluding the interfaces listed below—any business interface of the bean class must be explicitly designated as a business interface of the bean by means of the Local or Remote annotation on the bean class or interface or in the deployment descriptor.
Chaminda Amarasinghe
Ranch Hand

Joined: May 17, 2006
Posts: 402
Hi Karnati Sudhakar,

Keep in mind that this behavior may be specific to a App Server (I guess this is jboss) . So be careful in the exam. exam totally focuses on the spec.

Karnati Sudhakar
Ranch Hand

Joined: Aug 26, 2008
Posts: 270

Chaminda,

I verified the above code in Glassfish App server.I remember there is one question in Enthuware similar to this:

Consider the following interfaces and bean code:


Assuming appropriate package and import statements, what should the developer do to make sure that the bean exposes two local and one remote interfaces?

1) Add the following to XYBean before class declaration:
@Local(XLocal.class)
@Local(YLocal.class)
@Remote(XRemote.class)

2) Add the following to XLocal, YLocal, and XRemote interfaces respectively:
@Local, @Local, @Remote

3) The developer can add @Local to either of the local interfaces but not both and @Remote to the remote interface.

4) This cannot be done.

5) This can only be done through deployment descriptor.

6) Only add @Remote to the remote interface. No need to do anything for the local interfaces.

Suppose if the question was asked as to expose three interfaces as Local what would be the answer for this question?


Why my codre is behainv differently as stated in the specs.

Regards
Sudhakar
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question on SLSB Contract - SCBCD