• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Clarification on a mock question about Session Bean

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is the question (from Enthuware):

A stateless session bean S1 uses another stateless session bean S2 and requests a dependency injection using the following statement (contained in S1's code):
@EJB(name="ejb/S2", beanInterface=S2Local.class)

S2Local interface is as follows:

package com.enthu.ejbplus;
import javax.ejb.Local;
@Local
public interface SLocal {
String m1();
}

Given the above, complete the following S2Bean's code so that bean S1 will work as expected.

package com.enthu.ejbplus;
import javax.annotation.*;
import javax.ejb.*;

// insert lines here...

@Resource
SessionContext sctx;

public String m1(){ return "hello!"; }
}

And this are the answers:

1.
@Stateless
public class S2Bean implements S2Local {

2.
@Stateless(name="ejb/S2")
public class S2Bean implements S2Local {

3.
@Stateless
@Local(S2Local.class)
public class S2Bean {

4.
@Stateless(name="ejb/S2")
public class S2Bean {

5.
None of these.


Enthuware says that the correct answer is 2.

My dubt is for number 1, that is excluded with this reason:
This will not work because in the absence of 'name' in @Stateless, this bean will be associated with the name of S2Bean but S1 bean is looking for ejb/S2.

Binding the injected ejb by name, isn't done with beanName attribute??
The name attribut isn't used to bind an ejb reference to ENC entry name??


Thanks.

Germano
 
reply
    Bookmark Topic Watch Topic
  • New Topic