Re: Compile java sources inside J2EE component
From: Stefan Siegl (Stefan.Siegl_at_gmx.de)
Date: 09/07/04
- Next message: Dan: "Quartz Scheduler in Weblogic 8.1 SP3"
- Previous message: Samagna: "Calling a C++ dll from Java"
- In reply to: Chris Uppal: "Re: Compile java sources inside J2EE component"
- Next in thread: Sudsy: "Re: Compile java sources inside J2EE component"
- Reply: Sudsy: "Re: Compile java sources inside J2EE component"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 07 Sep 2004 12:33:33 +0200
Chris Uppal wrote:
Hi Chris, thanks for your thoughts about the topic :)
> Stefan Siegl wrote:
>
>
>>So much for the introduction ;). After creating the source files I need
>>to compile them at runtime, is there a possibility to do so?
>
>
> Yes. You can invoke Sun's compiler directly (I can't remember the precise
> class off-hand, but it's mentioned in another thread in this newsgroup today).
> Andrew's warning is to be taken seriously, but I wouldn't let it worry /me/ --
> I believe that Sun are intending to provide a public API to compilation soon
> (and that it only missed 1.5 because of time pressure), so I'd hope that if Sun
> do remove the private classes, then they'll replace them with something else
> you can use. You can always fall back to using javac if it really becomes
> necessary, anyway.
>
> However, if /I/ were doing this then I think I'd look at the option of
> interpreting the meta-model directly, rather than generating new classes. I
> think that would be easier, and I can't imagine it causing performance
> problems. Still, there's nothing wrong with generating classes, if that's
> what appeals to you, so...
I also thought about that, but there are also drawbacks.
The model and the data is not tightly connected. If just have instances
of meta classes and data (inside generic DTO's with a HashMap that
stores key (=attribute name) and value (=value of the attribute)), I
still have to check if this data is valid according to the model. If I
would have classes I could use the Java Reflection and just try to set
these attributes according to the given generic DTO. The check will then
be done through the Reflection mechanism.
What I did not describe so far is that my meta model allows to add rules
to the model. This should provide the possiblity to put constraints on
the model (i.e. each employee be older than 18). During the code
generation I could create checks for these rules and inform the caller
using an exception if he does not stick to these rules. If I use the
meta model instances I additionally have to check these rules. An other
idea I had for rules is to allow derivation rules to define how derived
attributes are defined. This could also done with code generation but is
much more complex when just checking the metamodel.
The last thing is that the persistence will get a bit more complex.
But I will thing about that again. Perhaps the code generation,
compilation and unloading are much more complex so that this does not
justify that approach.
> One thing that isn't helped by classloaders is migrating the state
of the
> system as it is modified. If you create a new "version" of a class, the
> instances of the existing class won't be migrated. You'll have to transfer the
> state of the system from the old collection of objects to the new. Somehow...
>
> Again, I think that migration would probably be easier if you were interpreting
> the meta-model, and that's one reason why I'd consider that first.
This class and object lifecycle is not directly part of my master
thesis, meaning that I do not have to provide a complete and working
solution for that (which does not mean, that I do not want to do that
*g*). Currently I was thinking that I will just store the database
storing the old data and create a new database for the new schema and
provide a way to read the old data and transfer them to the new schema.
>
> -- chris
Thanks again,
Stefan
- Next message: Dan: "Quartz Scheduler in Weblogic 8.1 SP3"
- Previous message: Samagna: "Calling a C++ dll from Java"
- In reply to: Chris Uppal: "Re: Compile java sources inside J2EE component"
- Next in thread: Sudsy: "Re: Compile java sources inside J2EE component"
- Reply: Sudsy: "Re: Compile java sources inside J2EE component"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|