Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EJB, JNDI & ENC - real life scenario

Tags:

ejb-3.1

I am preparing for the EJB certification and I am going thro the EJB 3.1 book (O'Reilly)

One of the chapters discusses about JNDI, ENC and the EJB connections

Can some of you give me a real life scenario of these so that I can get a better understandin

like image 789
siva Avatar asked Jul 28 '11 03:07

siva


1 Answers

JNDI in this scenario is used as a central location through which 'names' (a kind of URL) are routed to an EJB bean. Think of it how a Servlet is mapped to a URL.

If EJB beans are local to an application (e.g. they reside within the web module or within the EJB module of the same EAR), then you don't necessarily need to come into contact with JNDI. Namely, you'd probably use injection to get instances of your bean and no JNDI is needed then.

However, if you need to address an EJB bean in a remote server or if you want to lookup (a proxy to) a bean programmatically, you'd use its JNDI name and JNDI to get hold of it.

See this for some more info, including ENC: Declaring @Resource and @EJB at the class level in Java EE6

like image 146
Arjan Tijms Avatar answered Sep 22 '22 21:09

Arjan Tijms