About Question enthuware.oce-ejbd.v6.2.413 :

Moderator: admin

Post Reply
rkbansal83
Posts: 33
Joined: Sat Nov 24, 2012 8:52 am
Contact:

About Question enthuware.oce-ejbd.v6.2.413 :

Post by rkbansal83 »

I did not get why option 4 is correct.

@Resource
private Queue omQueue;
By simply specifying this in my code, how do I know which JMS queue I am referring to .
I had to specify @Resource with name attribute only . Please correct me if I am missing something here ?

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.413 :

Post by admin »

In no information is provided, the container injects the object that is most suitable. If there is an ambiguity, an error will occur at deployment time.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.

rkbansal83
Posts: 33
Joined: Sat Nov 24, 2012 8:52 am
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.413 :

Post by rkbansal83 »

I did not get what do you mean when you said "most suitable object" ?

We can have any number of JMS queues present on JMS provider , how does the EJB container decide the suitability . Please elaborate ?

Also , Can you please tell me if any such thing is specified in EJB specfications ?

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.413 :

Post by admin »

rkbansal83 wrote:I did not get what do you mean when you said "most suitable object" ?

We can have any number of JMS queues present on JMS provider , how does the EJB container decide the suitability . Please elaborate ?

Also , Can you please tell me if any such thing is specified in EJB specfications ?
Well, it depends on the container. Generally, the objects are injected based on their type. In case of JMS destinations, if the container is unable to figure out, it might prevent deployment or it might hookup with an object that you don't want.
The specification does not specify this behavior. That is why it is container specific.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

hellovn
Posts: 2
Joined: Wed Apr 17, 2013 1:17 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.413 :

Post by hellovn »

Answer (a) @Resource(name="OrderManagerQueue")
public static Queue omQueue

So we can not use static for a queue inject but we can use static for @EJB injection?

himaiMinh
Posts: 358
Joined: Fri Nov 29, 2013 8:26 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.413 :

Post by himaiMinh »

To answer this question:
@Resource(name="OrderManagerQueue")
public static Queue omQueue

So we can not use static for a queue inject but we can use static for @EJB injection?
There is an EJB programming restriction that we should not use declare static field, except static final field.
Correct me if I am wrong.

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.413 :

Post by admin »

That is right. static is not allowed. That is why option 1 is incorrect.
If you like our products and services, please help us by posting your review here.

aazizi.tarik
Posts: 31
Joined: Sun Dec 27, 2015 1:47 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.413 :

Post by aazizi.tarik »

Hi Paul,

I know that its out of the scope of the exam, but could you tell how we can tell the container wich Queue to use exactly? is there an atttribute for that in the ejb-jar.xml?

Thanks in advance

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.413 :

Post by admin »

Generally, the containers ( such as wsad or weblogic etc) provide a way for the deployer to tie the actual queue available in the container to the names used in the application. They have a UI for doing this.
If you like our products and services, please help us by posting your review here.

Gerardo
Posts: 16
Joined: Tue Nov 08, 2016 9:39 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.413 :

Post by Gerardo »

Hi,

¿Is "static" not allowed only for "Queue"?

In the following link there is defined a "ConnectionFactory" and "Queue" using a "static variable":
https://docs.oracle.com/cd/E19798-01/82 ... index.html

@Resource(lookup = "jms/ConnectionFactory")
private static ConnectionFactory connectionFactory;

@Resource(lookup = "jms/Queue")
private static Queue queue;

Thanks in advance

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.413 :

Post by admin »

Beans are not allowed to have static fields. The examples shown in your link are not beans. They are code snippets for some client code.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 23 guests