If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

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.

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.
>

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.
>