spring in action 2.0读书笔记(三)
<bean id="baseSaxophonist" ref="saxophone" /><property name="song" value="Jingle Bells" /></bean><bean id="kenny" parent="baseSaxophonist" /><bean id="david" parent="baseSaxophonist" />
<bean id="magicBox" replacer="tigerReplacer" /></bean> <bean id="tigerReplacer" /> import org.springframework.beans.factory.support.MethodReplacer;public class TigerReplacer implements MethodReplacer { public Object reimplement(Object target, Method method, Object[] args) throws Throwable { return "A ferocious tiger"; }}<bean id="stevie" bean="guitar" /></bean>
<bean id="pianist" /> </property></bean>
@Configurable("pianist")public class Instrumentalist implements Performer {…}<aop:spring-configured />
public class PhoneEditor extends java.beans.PropertyEditorSupport { //text value example “111-111-111” public void setAsText(String textValue) { String areaCode = textValue.substring(0,3); String prefix = textValue.substring(4,7); String number = textValue.substring(8); PhoneNumber phone = new PhoneNumber(areaCode, prefix, number); setValue(phone); }}<bean name="code"><bean id="propertyConfigurer" value="jdbc.properties" /></bean><bean id="dataSource"value="${database.url}" /> <property name="driverClassName" value="${database.driver}" /> <property name="username" value="${database.user}" /> <property name="password" value="${database.password}" /></bean><bean id="messageSource"name="code">class HeartbeatForwarder implements ApplicationListener { public void onApplicationEvent(ApplicationEvent event) { if (event instanceof HeartbeatEvent) { System.out.println("Received heartbeat event: " + event.getTimestamp()); } }}class HeartbeatTask extends TimerTask implements ApplicationEventPublisherAware { private ApplicationEventPublisher eventPublisher; public void run() { HeartbeatEvent event = new HeartbeatEvent(this); eventPublisher.publishEvent(event); } public void setApplicationEventPublisher(ApplicationEventPublisher eventPublisher) { this.eventPublisher = eventPublisher; }}<lang:jruby id="lime" script-source="classpath:com/springinaction/scripting/Lime.rb" script-interfaces="com.springinaction.scripting.Lime" />
<lang:groovy id="coconut"script-source="classpath:com/springinaction/scripting/Coconut.groovy"> <lang:property name="lime" ref="lime" /></lang:groovy>
<lang:jruby id="lime"script-source="classpath:com/springinaction/scripting/Lime.rb"script-interfaces="com.springinaction.scripting.Lime"refresh-check-delay="5000"/>
<lang:bsh id="lime" script-interfaces="com.springinaction.scripting.Lime"><lang:inline-script><![CDATA[void drink() {System.out.println("Called the doctor woke him up!");}]]></lang:inline-script></lang:bsh>