Got a very nice article of Dynamic Java Programing:
Write code that can respond to changes at runtime
SummaryDid you ever wish your Java code could be dynamic like JavaServer Pages? That it could be modified and recompiled at runtime, with your application updating itself on the fly? This article shows you how to make your code dynamic. As such, some of your source code will be deployed, instead of compiled binary code. Any changes to the source code will cause it to be recompiled and the class to be reloaded. Your application will then run on the new class, and users will see the change immediately. This article covers not only runtime source compilation and class reloading, but also a design that separates the dynamic code from its caller. The caller holds a static reference to the dynamic code, and no matter how the dynamic code reloads at runtime, the caller can always access the up-to-date class without updating the reference. In this way, dynamic code changes are transparent to the client.
JavaServer Pages (JSP) is a more flexible technology than servlets because it can respond to dynamic changes at runtime. Can you imagine a common Java class that has this dynamic capability too? It would be interesting if you could modify the implementation of a service without redeploying it and update your application on the fly.
The article explains how to write dynamic Java code. It discusses runtime source code compilation, class reloading, and the use of the Proxy design pattern to make modifications to a dynamic class transparent to its caller.
For whole doc: http://www.javaworld.com/javaworld/jw-06-2006/jw-0612-dynamic.html
Have fun with Java !
No comments:
Post a Comment