permaculture playing cards*
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes Dependecy injection EJB3 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "Dependecy injection EJB3" Watch "Dependecy injection EJB3" New topic
Author

Dependecy injection EJB3

Nps Ferreira
Greenhorn

Joined: Nov 22, 2002
Posts: 9

Hi all,

I´m doing the assignment of the SCEA certification and i have a doubt:

How to use dependency injection in a session bean (EJB3) calling another session bean, how to represent this action in a Sequence diagram?

cheers,

Nuno Ferreira
John Wenn
Ranch Hand

Joined: Mar 03, 2008
Posts: 31
Nps Ferreira wrote:
Hi all,

I´m doing the assignment of the SCEA certification and i have a doubt:

How to use dependency injection in a session bean (EJB3) calling another session bean, how to represent this action in a Sequence diagram?

cheers,

Nuno Ferreira


Actually there are two ways of calling another bean form a bean one way is through JNDI
and other way is using dependency injection You can do it by specifying.

dependency injection way



JNDI way (Assume you have a bean called TestBean)



The point that you have to remember when calling a bean using JNDI is, when you looking up and bean you dont
need to specify an JNDI initialization parameter, you can use the default initial context.
Dmitri Ericsson
Ranch Hand

Joined: Feb 16, 2010
Posts: 109
You can draw just and arrow from one bean instance to another with "dependency injection" on it. This is how it's done when injecting EntityManager in Humphrey Sheil's book


SCEA 5, SCJP 6 My SCEA Experience
Marco Elb
Greenhorn

Joined: Feb 22, 2010
Posts: 4
Hi,

that's true for diagram 9-8 but in diagram 9-7 there is not dependency injection arrow. I would not introduce depandency injection in my sequence diagram. I think dependancy injection is an implementation detail and a base of ejb 3. In the class diagram 9-3 he introduced a package App Framework. For me this technical package would be the right place for dependency injection.

Regards
Marco
Nps Ferreira
Greenhorn

Joined: Nov 22, 2002
Posts: 9

Thanks for your replies.

The question remains, how can i represent a call in a sequence diagram assuming that i´m using dependency injection. I´m not aware of any arrow with dependency injection on it.
Can anyone point to any examples?

cheers,

Nuno Ferreira
J J Wright
Ranch Hand

Joined: Jul 02, 2008
Posts: 254
The question remains, how can i represent a call in a sequence diagram assuming that i´m using dependency injection


I don't see your problem here. The fact of the matter is, you're not using dependency injection, the container is. Let's assume BeanA is invoking some method on BeanB. How BeanA got a reference to BeanB is completely irrelevant in the context of the method call.

I´m not aware of any arrow with dependency injection on it.


That's because you model structure in class, not sequence, diagrams.

Can anyone point to any examples?


No, because it wouldn't make sense.


SCJP, SCWCD, SCBCD, SCEA 5
Nps Ferreira
Greenhorn

Joined: Nov 22, 2002
Posts: 9

Hi,

I agree with you, in the sequence diagram it´s a call like another. But in my assignment i have two ways of accessing the session beans, with a service locator and other with dependency injection.
And i have the problem of distinguish the two ways in the diagrams (class or sequence diagrams)

I´ve found i guy that represent the dependency injection in the class diagram with a stereotype <<injected>> in the attribute that represent the session bean that will be invoked.

This is the way?

cheers
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dependecy injection EJB3
 
Similar Threads
Business Logic in EJB3 SessionBean?
DOA as session bean ?
Right Stereotype for EJB3 and annotations
Difference between EJB2 and EJB3?
Location transparency in EJB?