Author: Jiangnan Baiyi
When Wang Jiawei met du Kefeng and spring met Ruby. The crraig Wils that came up with this question is definitely a gossip, promoting spring 2. feature integrated with dynamic languages.
This feature aims to enable classes written in dynamic languages to be well integrated into the big framework of Java/spring, and be whitewashed into a common member in the application context, it has good interaction and injection capabilities with other pojo and can be exported to various services by DWR, xfire, and quartz.
Very simple, the/springside-bookstore/src/.../plugins/WebService/applicationContext-webservice-client.xml file in springside shows all usage.
<? XML version = "1.0" encoding = "UTF-8"?>
<Beans xmlns = "http://www.springframework.org/schema/beans" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
Xmlns: lang = "http://www.springframework.org/schema/lang"
Xsi: schemalocation ="
Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
Http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd ">
<! -- Groovy web service client -->
<LANG: groovy id = "bookserviceclient"
Refresh-check-delay = "60000"
Script-source = "classpath: ORG/springside/bookstore/plugins/WebService/service/bookserviceclient. Groovy">
<LANG: property name = "serviceurl" value = "http: // localhost: 8080/springside/service/bookservice"/>
</Lang: groovy>
</Beans>
Note that spring 2.0 provides the <LANG: Language> shorthand for language integration. For details, see chapter 24th of spring reference documentation.
The first property, refresh-check-delay, is used to scan script changes and reload it at intervals.
The second property script-source points to scriptsouce. <LANG: Property> interprets spring's favorite IOC and injects the serviceur variable.
Of course, there is no miracle in the world. Spring and groovy and jruby use an interface to define the connection points. When spring uses bookserviceclient bean, it actually uses the bookservice interface. Groovy is a close cousin of Java, so you can directly implements bookservice interface in the class, while jruby must pass interface as a construction parameter to rubyscriptfactory. In this way, we have to explicitly define all functions, parameters, and return value types of interfaces in groovy. Ruby's Miss method and groovy's mop reflection are useless.
The stage has been set up and the boundaries have been blurred. Next we will look at everyone's imagination like AOP.