alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Spring Framework example source code file (groovyContext.xml)

This example Spring Framework source code file (groovyContext.xml) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Spring Framework tags/keywords

calculator, groovycalculator, groovymessenger, groovymessenger, hello, hello, messenger, string, utf-8, utf-8, world, world

The Spring Framework groovyContext.xml source code

<?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"
 		default-lazy-init="true">

	<bean class="org.springframework.scripting.support.ScriptFactoryPostProcessor"/>

	<bean id="calculator"
		  class="org.springframework.scripting.groovy.GroovyScriptFactory">
		<constructor-arg>
			<value>inline:
package org.springframework.scripting.groovy;
import org.springframework.scripting.Calculator
class GroovyCalculator implements Calculator {
	int add(int x, int y) {
	   return x + y;
	}
}
			</value>
		</constructor-arg>
	</bean>

	<bean id="messenger"
		  class="org.springframework.scripting.groovy.GroovyScriptFactory">
		<constructor-arg value="classpath:org/springframework/scripting/groovy/Messenger.groovy"/>
		<property name="message" value="Hello World!"/>
	</bean>

	<bean id="messengerPrototype"
		  class="org.springframework.scripting.groovy.GroovyScriptFactory"
		  scope="prototype">
		<constructor-arg value="classpath:org/springframework/scripting/groovy/Messenger.groovy"/>
		<property name="message" value="Hello World!"/>
	</bean>

	<bean id="messengerInstance"
		  class="org.springframework.scripting.groovy.GroovyScriptFactory">
		<constructor-arg value="classpath:org/springframework/scripting/groovy/MessengerInstance.groovy"/>
		<property name="message" ref="myMessage"/>
	</bean>

  <bean id="messengerInstanceInline"
      class="org.springframework.scripting.groovy.GroovyScriptFactory">
    <constructor-arg>
      <value>inline:
package org.springframework.scripting.groovy;
import org.springframework.scripting.Messenger
class GroovyMessenger implements Messenger {
  def String message;
}
return new GroovyMessenger();
      </value>
    </constructor-arg>
    <property name="message" ref="myMessage"/>
  </bean>

	<bean id="myMessage" class="java.lang.String">
		<constructor-arg value="Hello World!"/>
	</bean>

	<lang:groovy id="refreshableFactory" refresh-check-delay="5000"
			script-source="org/springframework/scripting/groovy/TestFactoryBean.groovy"/>

	<lang:groovy id="factory" script-source="classpath:org/springframework/scripting/groovy/TestFactoryBean.groovy"/>

</beans>

Other Spring Framework examples (source code examples)

Here is a short list of links related to this Spring Framework groovyContext.xml source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.