Java Reference
In-Depth Information
Again,itsimplyreturns
true
,justastheJavaversiondid.Ratherthancompiling thisclass
and deploying it as usual, however, this time I want to create a refreshable bean. To do so,
I need to work with the
lang
namespace in the Spring configuration file (assuming I'm
using XML; alternatives exist for Java configuration files). I also need to deploy the source
code itself, rather than the compiled version of this file.
Deploying source
Note that for refreshable beans you deploy the source, not the compiled bean.
The next listing shows the bean configuration file with both evaluators. Note the addition
of the
lang
namespace and the Groovy bean.
Listing 7.12. The bean configuration file with the refreshable Groovy evaluator bean
Groovy provides a namespace for beans from dynamic languages, including Groovy,
BeanShell, and JRuby. One of the elements declared in that namespace is
<lang:
groovy>
, whose
script-source
attribute is used to point to the source code of a
Groovy class. Note that unlike the Java evaluator bean in the same file, this attribute points
to the actual source file, rather than the compiled bean. The other important attribute forthe
element is
refresh-check-delay
, which indicates the time period, in milliseconds,
after which Spring will check to see if the source file has changed. Here the delay has been
set to one second.