kelly martin ([info]kelly_lynn) wrote,
@ 2006-04-16 15:27:00
Previous Entry  Add to memories!  Tell a Friend!  Next Entry
I had an idea in the shower today, for something that might be useful. But I don't want to reinvent the wheel.

I want something for use in a Tomcat servlet that, given an arbitrary class, will use introspection to examine the servlet request and create a new instance of the class with its nontransient instance variables initialized against properly named form values from the request. Initially, I'm willing to do the introspection at runtime, but it would be best if factory methods can be developed at runtime to generate the instance from the servlet request (perhaps as a constructor?). I know, I could just write them by hand, but that's tedious and increases maintenance.

If someone's already done this, please point me in the right direction. If this is a bad idea, tell me why (and not just because Java is evil/stupid/bad, I don't want a language war).



(Post a new comment)


[info]lisanys
2006-04-16 10:02 pm UTC (link)
I am not familiar with Java, what is introspection? Why is this useful? Is this simply like reflection and a modular class setup ?

(Reply to this) (Thread)


[info]kelly_lynn
2006-04-16 11:38 pm UTC (link)
Reflection (java.lang.reflect) is how one does introspection in Java.

The idea is that one defines the class and then lets something else write the instantiator. Less code maintenance that way.

(Reply to this) (Parent)(Thread)


[info]lisanys
2006-04-17 07:42 am UTC (link)
Then you have essentially created an abstract class, no?

(Reply to this) (Parent)(Thread)


[info]kelly_lynn
2006-04-17 12:12 pm UTC (link)
Not exactly, no.

(Reply to this) (Parent)


Create an Account
Forgot your login or password?
Login w/ OpenID
English • Español • Deutsch • Русский…