bsh-with-xsd.xml 2.8 KB
Newer Older
1 2
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
3 4 5 6
	   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-2.5.xsd

7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
				http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd">

	<lang:bsh id="messenger" script-source="classpath:org/springframework/scripting/bsh/Messenger.bsh"
			script-interfaces="org.springframework.scripting.Messenger"
			init-method="init" destroy-method="destroy">
		<lang:property name="message" value="Hello World!"/>
	</lang:bsh>

	<lang:bsh id="messengerPrototype" script-source="classpath:org/springframework/scripting/bsh/Messenger.bsh"
			script-interfaces="org.springframework.scripting.ConfigurableMessenger"
			scope="prototype" init-method="init" destroy-method="destroy">
		<lang:property name="message" value="Hello World!"/>
	</lang:bsh>

	<lang:bsh id="messengerImpl" script-source="classpath:org/springframework/scripting/bsh/MessengerImpl.bsh"
			init-method="init" destroy-method="destroy">
		<lang:property name="message" value="Hello World!"/>
	</lang:bsh>

	<lang:bsh id="messengerInstance" script-source="classpath:org/springframework/scripting/bsh/MessengerInstance.bsh"
			init-method="init" destroy-method="destroy">
		<lang:property name="message" value="Hello World!"/>
	</lang:bsh>

	<lang:bsh id="messengerByType" script-source="classpath:org/springframework/scripting/bsh/MessengerImpl.bsh"
			autowire="byType" dependency-check="objects" init-method="init" destroy-method="destroy">
	</lang:bsh>

	<lang:bsh id="messengerByName" script-source="classpath:org/springframework/scripting/bsh/MessengerImpl.bsh"
			autowire="byName" init-method="init" destroy-method="destroy">
	</lang:bsh>

P
Phillip Webb 已提交
39
	<bean id="testBean" class="org.springframework.tests.sample.beans.TestBean"/>
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54

	<lang:bsh id="calculator" script-interfaces="org.springframework.scripting.Calculator">
		<lang:inline-script>
			int add(int x, int y) {
				return x + y;
			}
		</lang:inline-script>
	</lang:bsh>

	<lang:bsh id="refreshableMessenger" script-interfaces="org.springframework.scripting.Messenger"
			script-source="classpath:org/springframework/scripting/bsh/Messenger.bsh" refresh-check-delay="5000"
			init-method="init" destroy-method="destroy">
		<lang:property name="message" value="Hello World!"/>
	</lang:bsh>

55 56 57 58
<lang:bsh id="eventListener" script-interfaces="org.springframework.context.ApplicationListener,org.springframework.scripting.Messenger" >
<lang:inline-script><![CDATA[
int count;
void onApplicationEvent (org.springframework.context.ApplicationEvent event) { count++; System.out.println(event); }
59
String getMessage() { return "count=" + count; }
60 61 62
]]></lang:inline-script>
</lang:bsh>

63
</beans>