?
Solved

java polymorphism EJB MDB

Posted on 2013-05-27
1
Medium Priority
?
698 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 2000 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

AWS Certified Solutions Architect - Associate

This course has been developed to provide you with the requisite knowledge to not only pass the AWS CSA certification exam but also gain the hands-on experience required to become a qualified AWS Solutions architect working in a real-world environment.

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month14 days, 6 hours left to enroll

770 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