• 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

Dependecy injection EJB3

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Nps Ferreira
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
reply
    Bookmark Topic Watch Topic
  • New Topic