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

Discussion in 'Java' started by Stefan Siegl, Aug 18, 2004.

  1. Stefan Siegl

    Stefan Siegl Guest

    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
    Stefan Siegl, Aug 18, 2004
    #1
    1. Advertising

  2. Stefan Siegl

    David Hilsee Guest

    Re: [Reflection] Possible to query instance of abstract top level class without having the .class file of the concrete class?

    "Stefan Siegl" <> wrote in message
    news:...
    <snip>
    > 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?

    --
    David Hilsee
    David Hilsee, Aug 19, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matthias Kaeppler
    Replies:
    1
    Views:
    417
    R.F. Pels
    May 22, 2005
  2. Sameer
    Replies:
    4
    Views:
    572
    Roedy Green
    Aug 31, 2005
  3. Peter Parker

    abstract class and reflection

    Peter Parker, Oct 28, 2006, in forum: Java
    Replies:
    1
    Views:
    303
    =?ISO-8859-1?Q?Arne_Vajh=F8j?=
    Oct 28, 2006
  4. pabbu
    Replies:
    8
    Views:
    707
    Marc Boyer
    Nov 7, 2005
  5. Replies:
    4
    Views:
    798
    Rolf Magnus
    May 17, 2006
Loading...

Share This Page