bsh-with-xsd.xml 2.9 KB
Newer Older
1 2
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
J
Juergen Hoeller 已提交
3 4
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xmlns:lang="http://www.springframework.org/schema/lang"
S
Spring Operator 已提交
5 6
		xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.5.xsd
				http://www.springframework.org/schema/lang https://www.springframework.org/schema/lang/spring-lang-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

	<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"
31
			autowire="byType" init-method="init" destroy-method="destroy">
32 33 34 35 36 37
	</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 已提交
38
	<bean id="testBean" class="org.springframework.tests.sample.beans.TestBean"/>
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53

	<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>

J
Juergen Hoeller 已提交
54 55 56 57 58 59 60
    <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); }
            String getMessage() { return "count=" + count; }
        ]]></lang:inline-script>
    </lang:bsh>
61

62
</beans>