Java Runtime


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Java Runtime

  1. #1
    Sam Guest

    Java Runtime


    I need to instantiate an object at runtime without nowing the class definistion
    before runtime. The class information is stored in an XML file. For example,
    If I have an XML file that has tablename and attributes (fields) and the
    values of the fields. I don't want to build beans for all table names. I
    want to have an XML file (so that users and NOT programmers can modify).
    If we add a new entry (a new tablename and new fields) to the XML file, the
    factory class will generate the instances for each table in runtime. Of course
    there is generic logic for the getters and setters of the generated Instantiaded
    classes.

    The point is: I don't want to hard code table names and table fields in the
    java code. I want my java code to read an XML file and generate the necessary
    code for the beans.

    Is it possible. Any guidance is appriciated.


  2. #2
    MarkN Guest

    Re: Java Runtime


    This can be done. Servlets are dynamically created from JSPs. Check the
    Feb 2002 issue of JDJ page 54 (Dynamic Code Generation).



    "Sam" <samirtoday@yahoo.com> wrote:
    >
    >I need to instantiate an object at runtime without nowing the class definistion
    >before runtime. The class information is stored in an XML file. For example,
    >If I have an XML file that has tablename and attributes (fields) and the
    >values of the fields. I don't want to build beans for all table names. I
    >want to have an XML file (so that users and NOT programmers can modify).
    >If we add a new entry (a new tablename and new fields) to the XML file,

    the
    >factory class will generate the instances for each table in runtime. Of

    course
    >there is generic logic for the getters and setters of the generated Instantiaded
    >classes.
    >
    >The point is: I don't want to hard code table names and table fields in

    the
    >java code. I want my java code to read an XML file and generate the necessary
    >code for the beans.
    >
    >Is it possible. Any guidance is appriciated.
    >



  3. #3
    Chris Guest

    Re: Java Runtime


    I must be missing the point entirely. To me it sounds like you just want
    to create a generic Table.class that contains an internal 'name' property
    and a HashMap which maps dynamic field names (keys) to collections of data
    (values). Why would you need dynamic code generation to achieve this functionality?

    What am I missing here?


    "Sam" <samirtoday@yahoo.com> wrote:
    >
    >I need to instantiate an object at runtime without nowing the class definistion
    >before runtime. The class information is stored in an XML file. For example,
    >If I have an XML file that has tablename and attributes (fields) and the
    >values of the fields. I don't want to build beans for all table names. I
    >want to have an XML file (so that users and NOT programmers can modify).
    >If we add a new entry (a new tablename and new fields) to the XML file,

    the
    >factory class will generate the instances for each table in runtime. Of

    course
    >there is generic logic for the getters and setters of the generated Instantiaded
    >classes.
    >
    >The point is: I don't want to hard code table names and table fields in

    the
    >java code. I want my java code to read an XML file and generate the necessary
    >code for the beans.
    >
    >Is it possible. Any guidance is appriciated.
    >



  4. #4
    MarkN Guest

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center