|
From: Niklas T. <ni...@tr...> - 2006-06-20 07:46:06
|
Nicolas De Loof wrote: > Hello guys, > > I've looked at new script support and sounds great for quick design or > prototyping "edit source code, hit refresh and get the result", BUT it > requires to learn yet another langage. > I can agree that "grrovy is great" or "bsh is java like" or any other > enthousiastic comment on scripting languages, but my development team > has lots of junior java developers and my hierarchy has lot's of old > schools men that will make very difficult to accept a "script" language > as a valid technology. > > I'm looking for a way to code scripted spring beans as 100% Java source > code, using full IDE support, so that developer doesn't have to know > some class is used a scripted bean and some other as compiled code. My > first think comes to JSP that are runtime compiled (an re-compiled) by > the container. It would be great to have a similar support for java code > to be "runtime re-compilable". When the code gets fine, it can be > classicaly compiled into a .class and pakaged into the app, by simply > changing the spring context. > > Looking at the way tomcat (jasper) compiles JSP, it seems it uses a > custom classloader to load the runtime-compiled .class. My experience > with classloaders is limited so I can say if it would be easy, but here > is how I'd see this : a FactoryBean creates a proxy for the bean > interface and delegates invocation to a "runtime-compiled" class in a > child classloader. Hot recompilation requires the bean to be stateless, > but this sounds an aceptable constraint if I can code my web controlers > or business services by a quick code/test/code. > > Thanks for any suggestion to make this a reality. > > Nico. Janino, http://www.janino.net/, is a small footprint Java compiler. It's mostly Java 1.4 compatible. Haven't used it myself yet but it looks interesting. It includes a classloader which loads classes directly from Java sources, http://www.janino.net/use.html#class_loader. Regards, Niklas |