Probably a bad idea (or again its in Spring already!) but ....
For diagnostics I created a simple bean that announced its construction
and property setting very loudly ( a banner in the log file).
But, despite the other methods of accomplishing this, like tailing the log
file and redirecting to a grep or using a debugger, this leads to:
why even have to create these temporary or minor classes?
What if a bean definition could be implemented inline right in the bean
descriptor? Sounds horrible, I know. But this is not like Jelly, an XML language, rather its
just a conveniant well-known approach (very easy to misuse too). Ant and Maven, for example,
already allow scripting.
This could be used with AOP, inserting advise via scripting.
The above creation of a throwaway POJO would be a no brainer. The script
could be in any script language but the default is a scripted Java syntax
(there are many Java script compilers such as BeanShell or Janino).
See http://www.janino.net and http://www.beanshell.org
Thus a possible bean definition could be:
-- J. BetancourtCode:<bean id="shouter"> <property name="msg"><value>Hello world!</value></property> <package>com.........util</package> <!-- optional? --> <script language="beanshell"> <!-- or jython,Groovy,Janino,Rhino --> <![CDATA[ public class Shout { protected String msg; // stuff snipped ..... } ]]> </script> </bean>


Reply With Quote