Solved

java polymorphism EJB MDB

Posted on 2013-05-27
1
679 Views
Last Modified: 2013-06-01
Hi,

I was reading as

java is single dispatch language.
polymorphism works on method calls but not on method parameters


onMessage() of MDB takes Message as parameter where no compile time check happens.
onMessage() needs cast to Message to sub interface or impl to process message.


I am not clear on what above statements means.
Any links, sample code, resources, ideas highly appreciated. Thanks in advace
0
Comment
Question by:gudii9
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 19

Accepted Solution

by:
Jim Cakalic earned 500 total points
ID: 39202219
Here's an example from the Java EE Tutorial:
http://docs.oracle.com/javaee/6/tutorial/doc/bnbpo.html

The Message interface itself enumerates methods for accessing/modifying header properties and message acknowledgement. It is in each of its subinterfaces that the methods are defined for accessing/modifying the message body. So, for example, TextMessage defines the getText/setText methods.

You should know, from the design, what kind of message you are expecting (typically a TextMessage but could be something else). As per the tutorial link, you can interrogate the object you receive in onMessage using instanceof and then cast it to the correct subinterface to process the body or take an error handling path.

Regards,
Jim Cakalic
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Facing this issue for maven proxy setting 2 27
Java program running SQL query 5 48
running on tomcat not jboss eap 7.0 3 30
Java List 4 38
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question