[Reflection] Possible to query instance of abstract top level classwithout having the .class file o

S

Stefan Siegl

Hi,

I have a J2EE component that provides access to a repository in which a
model for a customer relationship management (CRM) system is kept. The
(M1 layer) model of the CRM can be changed during runtime using an
provided API. The component additionally stores data according to the
current model. In order to access this data (M0 layer) an API needs to
be provided that is not dependent on the current model (because this
model can change all the time and therefore the access interface would
change as well).

What we know about the model is that the top most classes are always the
same abstract classes with the CRMElement class being the super class of
the complete hierarchy.

What i basically wanted to do is create a generic API to access this
data without using the concrete subclasses of the model that may be
created and changed during runtime.

Possible code example:
----------------------

// creation of a specific subtype of an abstract class called "Human"
CRMElement e = DMA.create(“Human”);
e = DMA.setAttribute(e, "name", "some name");
e = DMA.setAttribute(e, "age", new Integer(25));

// retrieving information
CRMElement e = DMA.findById(“someId”);

What i do not know for sure is if the reflection mechanism works when
retrieving the data. I mean the component accessing my API will get an
instance of the class CRMElement which may be in fact an instance of the
class "Human".

Is it possible for the other component to query all possible methods
(even those of the human) althought the component do not have the .class
file of "Human"?

Thanks for your time,
Stefan
 
D

David Hilsee

Is it possible for the other component to query all possible methods
(even those of the human) althought the component do not have the .class
file of "Human"?

This makes no sense to me. You want to query the methods of a class when
you do not have access to its definition? So if I have written a class
"Human" that is sitting on my local machine right here, you want to query
it? That can't be what you mean. What are you trying to do?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top