How this works in run time?

83 views
Skip to first unread message

Thamizharasu S

unread,
Jul 10, 2010, 1:28:50 PM7/10/10
to play-framework
Hi All,

I am new to Play framework and this is my first post.

"Play doesn’t use any class files; instead it reads the Java source
files directly. Under the hood we use the Eclipse compiler to compile
Java sources on the fly"

I read the above statement in the document section. While runtime how
the class files will be loaded and can any one explains the mechanism?

Thanks,
Thamizharasu S

Jean-Francois Poux

unread,
Jul 10, 2010, 3:17:26 PM7/10/10
to play-framework
Hi,

In short, when a Java application is running, it requires the current
ClassLoader (java.lang.ClassLoader) of the VM to define its classes,
that's to say take some binary data and transform then into Class
objects that can be used. A typical ClassLoader will open .class files
on disk or in archive and make then Class objects. In Play, the
ApplicationClassloader (classloading package) is used to do this job.
Instead of reading .class files, it will have the ApplicationCompiler
(that's where Eclipse's JDT is used) read source files and compile
them, before actually making the Class objects available to the VM.
Controlling the ClassLoading process allows us to do cool stuf like:

- If you run your application in production mode, play will pre-
compile all your application, it almost behaves like a standard app.
But when running in Dev mode, Play will check if for modifications in
your application, recompile and replace/hot swap outdated code
automatically.
- Play will enhance your code, that's to say the framework will do a
part of the coding for you. By example, JPAEnhancer will add count(),
findAll() methods implementation to your model objects.
- You can ask play questions regarding the current Classpath, like get
all subclasses of a given class
(ApplicationClasses.getAssignableClasses()), get ll classes with a
given annotation (ApplicationClasses.getAnnotatedClasses()), are
iterate over the classes of your application cleanly
(ApplicationClasses.all()).

Regards,
Jean-Francois

sas

unread,
Jul 11, 2010, 3:09:31 PM7/11/10
to play-framework
very interesting explanation indeed

I think it would be a very good idea to add a "behind the scenes"
section in play's documentation to explain the inner working of the
framework...
Reply all
Reply to author
Forward
0 new messages