• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Peter Rooke
  • Himai Minh
Bartenders:
  • Piet Souris
  • Mikalai Zaikin

Question on SLSB Contract - SCBCD

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 856
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 270
Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 270
Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Get off me! Here, read this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic