diff --git a/spring-framework-reference/css/html/highlight.css b/spring-framework-reference/css/html/highlight.css new file mode 100644 index 00000000000..ffefef72de8 --- /dev/null +++ b/spring-framework-reference/css/html/highlight.css @@ -0,0 +1,35 @@ +/* + code highlight CSS resemblign the Eclipse IDE default color schema + @author Costin Leau +*/ + +.hl-keyword { + color: #7F0055; + font-weight: bold; +} + +.hl-comment { + color: #3F5F5F; + font-style: italic; +} + +.hl-multiline-comment { + color: #3F5FBF; + font-style: italic; +} + +.hl-tag { + color: #3F7F7F; +} + +.hl-attribute { + color: #7F007F; +} + +.hl-value { + color: #2A00FF; +} + +.hl-string { + color: #2A00FF; +} \ No newline at end of file diff --git a/spring-framework-reference/css/html/stylesheet.css b/spring-framework-reference/css/html/stylesheet.css index 54e4ba762ca..77569070a95 100644 --- a/spring-framework-reference/css/html/stylesheet.css +++ b/spring-framework-reference/css/html/stylesheet.css @@ -1,3 +1,5 @@ +@IMPORT url("highlight.css"); + html { padding: 0pt; margin: 0pt; @@ -22,7 +24,7 @@ hr { background: gray; } -h1,h2,h3 { +h1,h2,h3,h4 { color: #234623; font-family: Arial, Sans-serif; } @@ -37,6 +39,7 @@ pre.programlisting { padding: 7pt 3pt; border: 1pt solid black; background: #eeeeee; + clear: both; } div.table { @@ -54,3 +57,43 @@ div.table td { padding-left: 7px; padding-right: 7px; } + +.sidebar { + float: right; + margin: 10px 0 10px 30px; + padding: 10px 20px 20px 20px; + width: 33%; + border: 1px solid black; + background-color: #F4F4F4; + font-size: 14px; +} + +.mediaobject { + padding-top: 30px; + padding-bottom: 30px; +} + +.legalnotice { + font-family: Verdana, Arial, helvetica, sans-serif; + font-size: 12px; + font-style: italic; +} + +p.releaseinfo { + font-size: 100%; + font-weight: bold; + font-family: Verdana, Arial, helvetica, sans-serif; + padding-top: 10px; +} + +p.pubdate { + font-size: 120%; + font-weight: bold; + font-family: Verdana, Arial, helvetica, sans-serif; +} + +span.productname { + font-size: 200%; + font-weight: bold; + font-family: Verdana, Arial, helvetica, sans-serif; +} diff --git a/spring-framework-reference/src/beans.xml b/spring-framework-reference/src/beans.xml index 954812e54e6..cd746acf4c7 100644 --- a/spring-framework-reference/src/beans.xml +++ b/spring-framework-reference/src/beans.xml @@ -204,30 +204,30 @@ Find below an example of the basic structure of XML-based configuration metadata. - <?xml version="1.0" encoding="UTF-8"?> -<beans xmlns="http://www.springframework.org/schema/beans" + + - <bean id="..." class="..."> - <!-- collaborators and configuration for this bean go here --> - </bean> + + + - <bean id="..." class="..."> - <!-- collaborators and configuration for this bean go here --> - </bean> + + + - <!-- more bean definitions go here --> + -</beans> +]]>
Instantiating a container Instantiating a Spring IoC container is straightforward. - ApplicationContext context = new ClassPathXmlApplicationContext( + ApplicationContext context = new ClassPathXmlApplicationContext( new String[] {"services.xml", "daos.xml"}); // an ApplicationContext is also a BeanFactory (via inheritance) @@ -251,7 +251,7 @@ BeanFactory factory = context; load bean definitions from another file (or files). Let's look at a sample: - <beans> + <beans> <import resource="services.xml"/> <import resource="resources/messageSource.xml"/> @@ -531,7 +531,7 @@ BeanFactory factory = context; XML-based configuration metadata this may be accomplished via the use of the <alias/> element. - <alias name="fromName" alias="toName"/> + <alias name="fromName" alias="toName"/> In this case, a bean in the same container which is named 'fromName', may also after the use of this alias @@ -547,7 +547,7 @@ BeanFactory factory = context; easily handled by adding to the MyApp XML fragment the following standalone aliases: - <alias name="componentA-dataSource" alias="componentB-dataSource"/> + <alias name="componentA-dataSource" alias="componentB-dataSource"/> <alias name="componentA-dataSource" alias="myApp-dataSource" /> Now each component and the main application can refer to the @@ -637,7 +637,7 @@ BeanFactory factory = context; When using XML-based configuration metadata you can specify your bean class like so: - <bean id="exampleBean" class="examples.ExampleBean"/> + <bean id="exampleBean" class="examples.ExampleBean"/> <bean name="anotherExample" class="examples.ExampleBeanTwo"/> @@ -669,7 +669,7 @@ BeanFactory factory = context; this example, the createInstance() method must be a static method. - <bean id="exampleBean" + <bean id="exampleBean" class="examples.ExampleBean2" factory-method="createInstance"/> @@ -695,7 +695,7 @@ BeanFactory factory = context; name of the factory method itself must be set using the 'factory-method' attribute. - <!-- the factory bean, which contains a method called createInstance() --> + <!-- the factory bean, which contains a method called createInstance() --> <bean id="serviceLocator" class="com.foo.DefaultServiceLocator"> <!-- inject any dependencies required by this locator bean --> </bean> @@ -740,7 +740,7 @@ BeanFactory factory = context; BeanFactory you would create one and read in some bean definitions in the XML format as follows: - Resource res = new FileSystemResource("beans.xml"); + Resource res = new FileSystemResource("beans.xml"); BeanFactory factory = new XmlBeanFactory(res); Basically that is all there is to it. Using @@ -806,7 +806,7 @@ BeanFactory factory = new XmlBeanFactory(res); constructor injection. Notice that there is nothing special about this class. - public class SimpleMovieLister { + public class SimpleMovieLister { // the SimpleMovieLister has a dependency on a MovieFinder private MovieFinder movieFinder; @@ -830,7 +830,7 @@ BeanFactory factory = new XmlBeanFactory(res); constructor when it is being instantiated. Consider the following class: - package x.y; + package x.y; public class Foo { @@ -846,7 +846,7 @@ public class Foo { specify the constructor argument indexes and / or types explicitly. - <beans> + <beans> <bean name="foo" class="x.y.Foo"> <constructor-arg> <bean class="x.y.Bar"/> @@ -864,7 +864,7 @@ public class Foo { determine the type of the value, and so cannot match by type without help. Consider the following class: - package examples; + package examples; public class ExampleBean { @@ -888,7 +888,7 @@ public class ExampleBean { the constructor argument using the 'type' attribute. For example: - <bean id="exampleBean" class="examples.ExampleBean"> + <bean id="exampleBean" class="examples.ExampleBean"> <constructor-arg type="int" value="7500000"/> <constructor-arg type="java.lang.String" value="42"/> </bean> @@ -901,7 +901,7 @@ public class ExampleBean { explicitly by use of the index attribute. For example: - <bean id="exampleBean" class="examples.ExampleBean"> + <bean id="exampleBean" class="examples.ExampleBean"> <constructor-arg index="0" value="7500000"/> <constructor-arg index="1" value="42"/> </bean> @@ -927,7 +927,7 @@ public class ExampleBean { special about this class... it is plain old Java. - public class SimpleMovieLister { + public class SimpleMovieLister { // the SimpleMovieLister has a dependency on the MovieFinder private MovieFinder movieFinder; @@ -1099,7 +1099,7 @@ public class ExampleBean { setter-based DI. Find below a small part of a Spring XML configuration file specifying some bean definitions. - <bean id="exampleBean" class="examples.ExampleBean"> + <bean id="exampleBean" class="examples.ExampleBean"> <!-- setter injection using the nested <ref/> element --> <property name="beanOne"><ref bean="anotherExampleBean"/></property> @@ -1112,7 +1112,7 @@ public class ExampleBean { <bean id="anotherExampleBean" class="examples.AnotherBean"/> <bean id="yetAnotherBean" class="examples.YetAnotherBean"/> - public class ExampleBean { + public class ExampleBean { private AnotherBean beanOne; private YetAnotherBean beanTwo; @@ -1135,7 +1135,7 @@ public class ExampleBean { properties specified in the XML file. Find below an example of using constructor-based DI. - <bean id="exampleBean" class="examples.ExampleBean"> + <bean id="exampleBean" class="examples.ExampleBean"> <!-- constructor injection using the nested <ref/> element --> <constructor-arg> @@ -1151,7 +1151,7 @@ public class ExampleBean { <bean id="anotherExampleBean" class="examples.AnotherBean"/> <bean id="yetAnotherBean" class="examples.YetAnotherBean"/> - public class ExampleBean { + public class ExampleBean { private AnotherBean beanOne; private YetAnotherBean beanTwo; @@ -1173,7 +1173,7 @@ public class ExampleBean { constructor, Spring is told to call a static factory method to return an instance of the object: - <bean id="exampleBean" class="examples.ExampleBean" + <bean id="exampleBean" class="examples.ExampleBean" factory-method="createInstance"> <constructor-arg ref="anotherExampleBean"/> <constructor-arg ref="yetAnotherBean"/> @@ -1183,7 +1183,7 @@ public class ExampleBean { <bean id="anotherExampleBean" class="examples.AnotherBean"/> <bean id="yetAnotherBean" class="examples.YetAnotherBean"/> - public class ExampleBean { + public class ExampleBean { // a private constructor private ExampleBean(...) { @@ -1240,7 +1240,7 @@ public class ExampleBean { String to the actual type of the property or argument. - <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> + <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <!-- results in a setDriverClassName(String) call --> <property name="driverClassName"> @@ -1264,7 +1264,7 @@ public class ExampleBean { 'value' attribute, the above bean definition reads like so: - <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> + <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <!-- results in a setDriverClassName(String) call --> <property name="driverClassName" value="com.mysql.jdbc.Driver"/> @@ -1280,7 +1280,7 @@ public class ExampleBean { can also configure a java.util.Properties instance like so: - <bean id="mappings" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> + <bean id="mappings" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <!-- typed as a java.util.Properties --> <property name="properties"> @@ -1308,7 +1308,7 @@ public class ExampleBean { container (to a <constructor-arg/> or <property/> element). - <bean id="theTargetBean" class="..."/> + <bean id="theTargetBean" class="..."/> <bean id="theClientBean" class="..."> <property name="targetName"> @@ -1320,7 +1320,7 @@ public class ExampleBean { exactly equivalent (at runtime) to the following snippet: - <bean id="theTargetBean" class="..." /> + <bean id="theTargetBean" class="..." /> <bean id="client" class="..."> <property name="targetName" value="theTargetBean" /> @@ -1346,7 +1346,7 @@ public class ExampleBean { XML parser itself to validate the bean id even earlier, at XML document parse time. - <property name="targetName"> + <property name="targetName"> <!-- a bean with an id of 'theTargetBean' must exist; otherwise an XML exception will be thrown --> <idref local="theTargetBean"/> </property> @@ -1387,7 +1387,7 @@ public class ExampleBean { bean, or one of the values in the 'name' attribute of the target bean. - <ref bean="someBean"/> + <ref bean="someBean"/> Specifying the target bean by using the local attribute leverages the ability of the XML parser to validate XML id @@ -1399,7 +1399,7 @@ public class ExampleBean { about errors as early as possible) if the target bean is in the same XML file. - <ref local="someBean"/> + <ref local="someBean"/> Specifying the target bean by using the 'parent' attribute allows a reference to be created @@ -1413,12 +1413,12 @@ public class ExampleBean { in a parent container with some sort of proxy which will have the same name as the parent bean. - <!-- in the parent context --> + <!-- in the parent context --> <bean id="accountService" class="com.foo.SimpleAccountService"> <!-- insert dependencies as required as here --> </bean> - <!-- in the child (descendant) context --> + <!-- in the child (descendant) context --> <bean id="accountService" <-- notice that the name of this bean is the same as the name of the 'parent' bean class="org.springframework.aop.framework.ProxyFactoryBean"> @@ -1441,7 +1441,7 @@ public class ExampleBean { best not to even specify any id or name value because the id or name value simply will be ignored by the container. - <bean id="outer" class="..."> + <bean id="outer" class="..."> <!-- instead of using a reference to a target bean, simply define the target bean inline --> <property name="target"> <bean class="com.example.Person"> <!-- this is the inner bean --> @@ -1474,7 +1474,7 @@ public class ExampleBean { Properties, respectively, to be defined and set. - <bean id="moreComplexObject" class="example.ComplexObject"> + <bean id="moreComplexObject" class="example.ComplexObject"> <!-- results in a setAdminEmails(java.util.Properties) call --> <property name="adminEmails"> <props> @@ -1525,7 +1525,7 @@ public class ExampleBean { value, can also again be any of the following elements: - bean | ref | idref | list | set | map | props | value | null + bean | ref | idref | list | set | map | props | value | null
Collection merging @@ -1554,7 +1554,7 @@ public class ExampleBean { Find below an example of the collection merging feature: - <beans> + <beans> <bean id="parent" abstract="true" class="example.ComplexObject"> <property name="adminEmails"> <props> @@ -1642,7 +1642,7 @@ support=support@example.co.uk instances will be converted to the appropriate type prior to being added to the Collection. - public class Foo { + public class Foo { private Map<String, Float> accounts; @@ -1651,7 +1651,7 @@ support=support@example.co.uk } } - <beans> + <beans> <bean id="foo" class="x.y.Foo"> <property name="accounts"> <map> @@ -1686,7 +1686,7 @@ support=support@example.co.uk email property being set to the empty String value ("") - <bean class="ExampleBean"> + <bean class="ExampleBean"> <property name="email"><value/></property> </bean> @@ -1695,7 +1695,7 @@ support=support@example.co.uk <null> element may be used to indicate a null value. For example: - <bean class="ExampleBean"> + <bean class="ExampleBean"> <property name="email"><null/></property> </bean> @@ -1724,25 +1724,25 @@ support=support@example.co.uk embedding a full <value/> element. Therefore, the following: - <property name="myProperty"> + <property name="myProperty"> <value>hello</value> </property> - <constructor-arg> + <constructor-arg> <value>hello</value> </constructor-arg> - <entry key="myKey"> + <entry key="myKey"> <value>hello</value> </entry> are equivalent to: - <property name="myProperty" value="hello"/> + <property name="myProperty" value="hello"/> - <constructor-arg value="hello"/> + <constructor-arg value="hello"/> - <entry key="myKey" value="hello"/> + <entry key="myKey" value="hello"/> The <property/> and <constructor-arg/> elements support a @@ -1750,19 +1750,19 @@ support=support@example.co.uk used instead of a full nested <ref/> element. Therefore, the following: - <property name="myProperty"> + <property name="myProperty"> <ref bean="myBean"> </property> - <constructor-arg> + <constructor-arg> <ref bean="myBean"> </constructor-arg> ... are equivalent to: - <property name="myProperty" ref="myBean"/> + <property name="myProperty" ref="myBean"/> - <constructor-arg ref="myBean"/> + <constructor-arg ref="myBean"/> Note however that the shortcut form is equivalent to a <ref bean="xxx"> element; there is no @@ -1775,7 +1775,7 @@ support=support@example.co.uk 'value' / 'value-ref' attributes. Therefore, the following: - <entry> + <entry> <key> <ref bean="myKeyBean" /> </key> @@ -1784,7 +1784,7 @@ support=support@example.co.uk is equivalent to: - <entry key-ref="myKeyBean" value-ref="myValueBean"/> + <entry key-ref="myKeyBean" value-ref="myValueBean"/> Again, the shortcut form is equivalent to a <ref bean="xxx"> element; there is no shortcut for @@ -1818,7 +1818,7 @@ support=support@example.co.uk the end: the first is using the standard XML format whereas the second example is using the p-namespace. - <beans xmlns="http://www.springframework.org/schema/beans" + <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans @@ -1842,7 +1842,7 @@ support=support@example.co.uk This next example includes two more bean definitions that both have a reference to another bean: - <beans xmlns="http://www.springframework.org/schema/beans" + <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans @@ -1899,7 +1899,7 @@ support=support@example.co.uk the final property name are not null. Consider the following bean definition... - <bean id="foo" class="foo.Bar"> + <bean id="foo" class="foo.Bar"> <property name="fred.bob.sammy" value="123" /> </bean> @@ -1933,7 +1933,7 @@ support=support@example.co.uk 'depends-on' attribute to express a dependency on a single bean. - <bean id="beanOne" class="ExampleBean" depends-on="<bean id="beanOne" class="ExampleBean" depends-on="manager"/> <bean id="manager" class="ManagerBean" /> @@ -1943,7 +1943,7 @@ support=support@example.co.uk 'depends-on' attribute, with commas, whitespace and semicolons all valid delimiters, like so: - <bean id="beanOne" class="ExampleBean" depends-on="manager,accountDao"> + <bean id="beanOne" class="ExampleBean" depends-on="manager,accountDao"> <property name="manager" ref="manager" /> </bean> @@ -1990,7 +1990,7 @@ support=support@example.co.uk the 'lazy-init' attribute on the <bean/> element; for example: - <bean id="lazy" class="com.foo.ExpensiveToCreateBean" <bean id="lazy" class="com.foo.ExpensiveToCreateBean" lazy-init="true"/> <bean name="not.lazy" class="com.foo.AnotherBean"/> @@ -2020,7 +2020,7 @@ support=support@example.co.uk attribute on the <beans/> element; for example: - <beans default-lazy-init="true"> + <beans default-lazy-init="true"> <!-- no beans will be pre-instantiated... --> </beans>
@@ -2343,7 +2343,7 @@ support=support@example.co.uk
typically new) bean B instance every time it needs it. Find below an admittedly somewhat contrived example of this approach: - // a class that uses a stateful Command-style class to perform some processing + // a class that uses a stateful Command-style class to perform some processing package fiona.apple; // lots of Spring-API imports @@ -2410,7 +2410,7 @@ public class CommandManager implements BeanFactoryAware { Spring dependencies, as can be seen in this reworked example below: - package fiona.apple; + package fiona.apple; // no more Spring imports! @@ -2433,14 +2433,14 @@ public abstract class CommandManager { is to be 'injected' must have a signature of the following form: - <public|protected> [abstract] <return-type> theMethodName(no-arguments); + <public|protected> [abstract] <return-type> theMethodName(no-arguments); If the method is abstract, the dynamically-generated subclass will implement the method. Otherwise, the dynamically-generated subclass will override the concrete method defined in the original class. Let's look at an example: - <!-- a stateful bean deployed as a prototype (non-singleton) --> + <!-- a stateful bean deployed as a prototype (non-singleton) --> <bean id="command" class="fiona.apple.AsyncCommand" scope="prototype"> <!-- inject dependencies here as required --> </bean> @@ -2501,7 +2501,7 @@ public abstract class CommandManager { Consider the following class, with a method computeValue, which we want to override: - public class MyValueCalculator { + public class MyValueCalculator { public String computeValue(String input) { // some real code... @@ -2515,7 +2515,7 @@ public abstract class CommandManager { org.springframework.beans.factory.support.MethodReplacer interface provides the new method definition. - /** meant to be used to override the existing computeValue(String) + /** meant to be used to override the existing computeValue(String) implementation in MyValueCalculator */ public class ReplacementComputeValue implements MethodReplacer { @@ -2531,7 +2531,7 @@ public class ReplacementComputeValue implements MethodReplacer { The bean definition to deploy the original class and specify the method override would look like this: - <bean id="myValueCalculator class="x.y.z.MyValueCalculator"> + <bean id="myValueCalculator class="x.y.z.MyValueCalculator"> <!-- arbitrary method replacement --> <replaced-method name="computeValue" replacer="replacementComputeValue"> <arg-type>String</arg-type> @@ -2550,7 +2550,7 @@ public class ReplacementComputeValue implements MethodReplacer { fully qualified type name. For example, all the following would match java.lang.String. - java.lang.String + java.lang.String String Str @@ -2724,7 +2724,7 @@ public class ReplacementComputeValue implements MethodReplacer { default scope in Spring. To define a bean as a singleton in XML, you would write configuration like so: - <bean id="accountService" class="com.foo.DefaultAccountService"/> + <bean id="accountService" class="com.foo.DefaultAccountService"/> <!-- the following is equivalent, though redundant (singleton scope is the default); using spring-beans-2.0.dtd --> <bean id="accountService" class="com.foo.DefaultAccountService" scope="singleton"/> @@ -2768,7 +2768,7 @@ public class ReplacementComputeValue implements MethodReplacer { To define a bean as a prototype in XML, you would write configuration like so: - <!-- using spring-beans-2.0.dtd --> + <!-- using spring-beans-2.0.dtd --> <bean id="accountService" class="com.foo.DefaultAccountService" scope="prototype"/> <!-- the following is equivalent and preserved for backward compatibility in spring-beans.dtd --> @@ -2907,7 +2907,7 @@ public class ReplacementComputeValue implements MethodReplacer { the declarations in your web application's 'web.xml' file. - <web-app> + <web-app> ... <listener> <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class> @@ -2925,7 +2925,7 @@ public class ReplacementComputeValue implements MethodReplacer { mapping depends on the surrounding web application configuration and so you will have to change it as appropriate.) - <web-app> + <web-app> .. <filter> <filter-name>requestContextFilter</filter-name> @@ -2952,7 +2952,7 @@ public class ReplacementComputeValue implements MethodReplacer { Consider the following bean definition: - <bean id="loginAction" class="com.foo.LoginAction" scope="request"/> + <bean id="loginAction" class="com.foo.LoginAction" scope="request"/> With the above bean definition in place, the Spring container will create a brand new instance of the @@ -2974,7 +2974,7 @@ public class ReplacementComputeValue implements MethodReplacer { Consider the following bean definition: - <bean id="userPreferences" class="com.foo.UserPreferences" scope="session"/> + <bean id="userPreferences" class="com.foo.UserPreferences" scope="session"/> With the above bean definition in place, the Spring container will create a brand new instance of the @@ -3001,7 +3001,7 @@ public class ReplacementComputeValue implements MethodReplacer { Consider the following bean definition: - <bean id="userPreferences" class="com.foo.UserPreferences" scope="globalSession"/> + <bean id="userPreferences" class="com.foo.UserPreferences" scope="globalSession"/> The global session scope is similar to the standard HTTP Session scope (why as well as the how behind it. - <?xml version="1.0" encoding="UTF-8"?> + <?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:aop="http://www.springframework.org/schema/aop" @@ -3093,7 +3093,7 @@ http://www.springframework.org/schema/aop http://www.springframework.org/schema/ bean definition as it stands is incomplete): - <bean id="userPreferences" class="com.foo.UserPreferences" scope="session"/> + <bean id="userPreferences" class="com.foo.UserPreferences" scope="session"/> <bean id="userManager" class="com.foo.UserManager"> <property name="userPreferences" ref="userPreferences"/> @@ -3148,7 +3148,7 @@ http://www.springframework.org/schema/aop http://www.springframework.org/schema/ globalSession-scoped beans into collaborating objects: - <bean id="userPreferences" class="com.foo.UserPreferences" scope="session"> + <bean id="userPreferences" class="com.foo.UserPreferences" scope="session"> <aop:scoped-proxy/> </bean> @@ -3181,7 +3181,7 @@ http://www.springframework.org/schema/aop http://www.springframework.org/schema/ collaborators into which the scoped bean is injected must be referencing the bean via one of its interfaces. - <!-- DefaultUserPreferences implements the UserPreferences interface --> + <!-- DefaultUserPreferences implements the UserPreferences interface --> <bean id="userPreferences" class="com.foo.DefaultUserPreferences" scope="session"> <aop:scoped-proxy proxy-target-class="false"/> </bean> @@ -3235,7 +3235,7 @@ http://www.springframework.org/schema/aop http://www.springframework.org/schema/ of the bean, after having bound it to the session for future reference). - Object get(String name, ObjectFactory objectFactory) + Object get(String name, ObjectFactory objectFactory) The second method should remove the object from the underlying scope. The session scope implementation for example, removes the @@ -3243,20 +3243,20 @@ http://www.springframework.org/schema/aop http://www.springframework.org/schema/ returned (you are allowed to return null if the object with the specified name wasn't found) - Object remove(String name) + Object remove(String name) The third method is used to register callbacks the scope should execute when it is destroyed or when the specified object in the scope is destroyed. Please refer to the Javadoc or a Spring scope implementation for more information on destruction callbacks. - void registerDestructionCallback(String name, Runnable destructionCallback) + void registerDestructionCallback(String name, Runnable destructionCallback) The last method deals with obtaining the conversation identifier for the underlying scope. This identifier is different for each scope. For a session for example, this can be the session identifier. - String getConversationId() + String getConversationId()
@@ -3272,7 +3272,7 @@ http://www.springframework.org/schema/aop http://www.springframework.org/schema/ BeanFactory implementations that ship with Spring); this central method is displayed below: - void registerScope(String scopeName, Scope scope); + void registerScope(String scopeName, Scope scope); The first argument to the registerScope(..) method is the unique name @@ -3287,7 +3287,7 @@ http://www.springframework.org/schema/aop http://www.springframework.org/schema/ Scope implementation, and you have registered it like so: - // note: the ThreadScope class does // note: the ThreadScope class does not ship with the Spring Framework Scope customScope = new ThreadScope(); beanFactory.registerScope("thread", customScope); @@ -3296,7 +3296,7 @@ beanFactory.registerScope("thread", customScope rules of your custom Scope like so: - <bean id="..." class="..." scope="thread"/> + <bean id="..." class="..." scope="thread"/> If you have your own custom Scope implementation(s), you are not just limited to only programmatic @@ -3309,7 +3309,7 @@ beanFactory.registerScope("thread", customScope CustomScopeConfigurer class is shown below: - <?xml version="1.0" encoding="UTF-8"?> + <?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:aop="http://www.springframework.org/schema/aop" @@ -3337,16 +3337,16 @@ http://www.springframework.org/schema/aop http://www.springframework.org/schema/ </bean> </beans> + + + Note that, when placing a <aop:scoped-proxy/> in a FactoryBean + implementation, it is the factory bean itself that is scoped, not the object returned from + getObject(). +
- - Note that, when placing a <aop:scoped-proxy/> in a FactoryBean - implementation, it is the factory bean itself that is scoped, not the object returned from - getObject(). - -
Customizing the nature of a bean @@ -3386,7 +3386,7 @@ http://www.springframework.org/schema/aop http://www.springframework.org/schema/ InitializingBean interface specifies exactly one method: - void afterPropertiesSet() throws Exception; + void afterPropertiesSet() throws Exception; Generally, the use of the InitializingBean interface can be @@ -3397,9 +3397,9 @@ http://www.springframework.org/schema/aop http://www.springframework.org/schema/ 'init-method' attribute. For example, the following definition: - <bean id="exampleInitBean" class="examples.ExampleBean" init-method="init"/> + <bean id="exampleInitBean" class="examples.ExampleBean" init-method="init"/> - public class ExampleBean { + public class ExampleBean { public void init() { // do some initialization work @@ -3408,9 +3408,9 @@ http://www.springframework.org/schema/aop http://www.springframework.org/schema/ ...is exactly the same as... - <bean id="exampleInitBean" class="examples.AnotherExampleBean"/> + <bean id="exampleInitBean" class="examples.AnotherExampleBean"/> - public class AnotherExampleBean implements InitializingBean { + public class AnotherExampleBean implements InitializingBean { public void afterPropertiesSet() { // do some initialization work @@ -3430,7 +3430,7 @@ http://www.springframework.org/schema/aop http://www.springframework.org/schema/ DisposableBean interface specifies a single method: - void destroy() throws Exception; + void destroy() throws Exception; Generally, the use of the DisposableBean callback interface can be @@ -3442,9 +3442,9 @@ http://www.springframework.org/schema/aop http://www.springframework.org/schema/ <bean/>. For example, the following definition: - <bean id="exampleInitBean" class="examples.ExampleBean" destroy-method="cleanup"/> + <bean id="exampleInitBean" class="examples.ExampleBean" destroy-method="cleanup"/> - public class ExampleBean { + public class ExampleBean { public void cleanup() { // do some destruction work (like releasing pooled connections) @@ -3453,9 +3453,9 @@ http://www.springframework.org/schema/aop http://www.springframework.org/schema/ ...is exactly the same as... - <bean id="exampleInitBean" class="examples.AnotherExampleBean"/> + <bean id="exampleInitBean" class="examples.AnotherExampleBean"/> - public class AnotherExampleBean implements DisposableBean { + public class AnotherExampleBean implements DisposableBean { public void destroy() { // do some destruction work (like releasing pooled connections) @@ -3499,7 +3499,7 @@ http://www.springframework.org/schema/aop http://www.springframework.org/schema/ destroy callback methods are to be called destroy(). This leads to classes like so... - public class DefaultBlogService implements BlogService { + public class DefaultBlogService implements BlogService { private BlogDao blogDao; @@ -3515,7 +3515,7 @@ http://www.springframework.org/schema/aop http://www.springframework.org/schema/ } } - <beans default-init-method="init"> + <beans default-init-method="init"> <bean id="blogService" class="com.foo.DefaultBlogService"> <property name="blogDao" ref="blogDao" /> @@ -3662,7 +3662,7 @@ http://www.springframework.org/schema/aop http://www.springframework.org/schema/ declared on the AbstractApplicationContext class. To wit... - import org.springframework.context.support.AbstractApplicationContext; + import org.springframework.context.support.AbstractApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public final class Boot { @@ -3694,7 +3694,7 @@ public final class Boot { BeanFactory that created it, when it is created by that BeanFactory. - public interface BeanFactoryAware { + public interface BeanFactoryAware { void setBeanFactory(BeanFactory beanFactory) throws BeansException; } @@ -3740,7 +3740,7 @@ public final class Boot { ObjectFactoryCreatingFactoryBean with the name of the bean that is to be looked up. Let's look at an example: - package x.y; + package x.y; public class NewsFeed { @@ -3755,7 +3755,7 @@ public class NewsFeed { } } - package x.y; + package x.y; import org.springframework.beans.factory.ObjectFactory; @@ -3780,7 +3780,7 @@ public class NewsFeedManager { ObjectFactoryCreatingFactoryBean approach. - <beans> + <beans> <bean id="newsFeedManager" class="x.y.NewsFeedManager"> <property name="factory"> <bean @@ -3803,7 +3803,7 @@ class="org.springframework.beans.factory.config.ObjectFactoryCreatingFactoryBean NewsFeedManager's printNews() method. - import org.springframework.context.ApplicationContext; + import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import x.y.NewsFeedManager; @@ -3821,7 +3821,7 @@ public class Main { The output from running the above program will look like so (results will of course vary on your machine). - x.y.NewsFeed@1292d26: '... that's fit to print!' + x.y.NewsFeed@1292d26: '... that's fit to print!' x.y.NewsFeed@5329c5: '... that's fit to print!' As of Spring 2.5, you can rely upon autowiring of the @@ -3883,7 +3883,7 @@ x.y.NewsFeed@5329c5: '... that's fit to print!' indicated simply by using the 'parent' attribute, specifying the parent bean as the value of this attribute. - <bean id="inheritedTestBean" abstract="true" + <bean id="inheritedTestBean" abstract="true" class="org.springframework.beans.TestBean"> <property name="name" value="parent"/> <property name="age" value="1"/> @@ -3921,7 +3921,7 @@ x.y.NewsFeed@5329c5: '... that's fit to print!' class, and so explicitly marking the parent bean definition as abstract is required: - <bean id="inheritedTestBeanWithoutClass" abstract="true"> + <bean id="inheritedTestBeanWithoutClass" abstract="true"> <property name="name" value="parent"/> <property name="age" value="1"/> </bean> @@ -4052,7 +4052,7 @@ x.y.NewsFeed@5329c5: '... that's fit to print!' implementation, bean post-processors explicitly have to be registered, with code like this: - ConfigurableBeanFactory factory = new XmlBeanFactory(...); + ConfigurableBeanFactory factory = new XmlBeanFactory(...); // now register any needed BeanPostProcessor instances MyBeanPostProcessor postProcessor = new MyBeanPostProcessor(); @@ -4114,7 +4114,7 @@ factory.addBeanPostProcessor(postProcessor); BeanPostProcessor implementation class definition: - package scripting; + package scripting; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.BeansException; @@ -4132,7 +4132,7 @@ public class InstantiationTracingBeanPostProcessor implements BeanPostProcessor } } - <?xml version="1.0" encoding="UTF-8"?> + <?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" @@ -4164,7 +4164,7 @@ http://www.springframework.org/schema/lang http://www.springframework.org/schema Find below a small driver script to exercise the above code and configuration; - import org.springframework.context.ApplicationContext; + import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.scripting.Messenger; @@ -4262,7 +4262,7 @@ org.springframework.scripting.groovy.GroovyMessenger@272961 applying a BeanFactoryPostProcessor is manual, and will be similar to this: - XmlBeanFactory factory = new XmlBeanFactory(new FileSystemResource("beans.xml")); + XmlBeanFactory factory = new XmlBeanFactory(new FileSystemResource("beans.xml")); // bring in some property values from a Properties file PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer(); @@ -4322,7 +4322,7 @@ cfg.postProcessBeanFactory(factory); the metadata which will replace some properties of the DataSource: - <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> + <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <value>classpath:com/foo/jdbc.properties</value> </property> @@ -4339,7 +4339,7 @@ cfg.postProcessBeanFactory(factory); The actual values come from another file in the standard Java Properties format: - jdbc.driverClassName=org.hsqldb.jdbcDriver + jdbc.driverClassName=org.hsqldb.jdbcDriver jdbc.url=jdbc:hsqldb:hsql://production:9002 jdbc.username=sa jdbc.password=root @@ -4349,7 +4349,7 @@ jdbc.password=root dedicated configuration element. Multiple locations may be provided as a comma-separated list for the location attribute. - <context:property-placeholder location="classpath:com/foo/jdbc.properties"/> + <context:property-placeholder location="classpath:com/foo/jdbc.properties"/> The PropertyPlaceholderConfigurer doesn't only look for properties in the Properties file @@ -4372,7 +4372,7 @@ jdbc.password=root you have to pick a particular implementation class at runtime. For example: - <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> + <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <value>classpath:com/foo/strategy.properties</value> </property> @@ -4415,11 +4415,11 @@ jdbc.password=root Properties file configuration lines are expected to be in the format: - beanName.property=value + beanName.property=value An example properties file might look like this: - dataSource.driverClassName=com.mysql.jdbc.Driver + dataSource.driverClassName=com.mysql.jdbc.Driver dataSource.url=jdbc:mysql:mydb This example file would be usable against a container definition @@ -4432,7 +4432,7 @@ dataSource.url=jdbc:mysql:mydb is already non-null (presumably initialized by the constructors). In this example... - foo.fred.bob.sammy=123 + foo.fred.bob.sammy=123 ... the sammy property of the bob property of the fred @@ -4448,7 +4448,7 @@ dataSource.url=jdbc:mysql:mydb Spring 2.5, it is possible to configure property overriding with a dedicated configuration element: - <context:property-override location="classpath:override.properties"/> + <context:property-override location="classpath:override.properties"/>
@@ -4738,7 +4738,7 @@ dataSource.url=jdbc:mysql:mydb source. The ResourceBundleMessageSource is more interesting and is the one we will provide an example for: - <beans> + <beans> <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> <property name="basenames"> @@ -4759,10 +4759,10 @@ dataSource.url=jdbc:mysql:mydb example, lets assume the contents of two of the above resource bundle files are... - # in 'format.properties' + # in 'format.properties' message=Alligators rock! - # in 'exceptions.properties' + # in 'exceptions.properties' argument.required=The '{0}' argument is required. Some (admittedly trivial) driver code to exercise the @@ -4772,7 +4772,7 @@ argument.required=The '{0}' argument is required. implementations and so can be cast to the MessageSource interface. - public static void main(String[] args) { + public static void main(String[] args) { MessageSource resources = new ClassPathXmlApplicationContext("beans.xml"); String message = resources.getMessage("message", null, "Default", null); System.out.println(message); @@ -4798,7 +4798,7 @@ argument.required=The '{0}' argument is required. converted into Strings and inserted into placeholders in the lookup message. This is perhaps best explained with an example: - <beans> + <beans> <!-- this MessageSource is being used in a web application --> <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> @@ -4812,7 +4812,7 @@ argument.required=The '{0}' argument is required. </beans> - public class Example { + public class Example { private MessageSource messages; @@ -4851,7 +4851,7 @@ argument.required=The '{0}' argument is required. # in 'exceptions_en_GB.properties' argument.required=Ebagum lad, the '{0}' argument is required, I say, required. - public static void main(final String[] args) { + public static void main(final String[] args) { MessageSource resources = new ClassPathXmlApplicationContext("beans.xml"); String message = resources.getMessage("argument.required", new Object [] {"userDao"}, "Required", Locale.UK); @@ -4997,7 +4997,7 @@ argument.required=Ebagum lad, the '{0}' argument is required, I say, required.Let's look at an example. First, the ApplicationContext: - <bean id="emailer" class="example.EmailBean"> + <bean id="emailer" class="example.EmailBean"> <property name="blackList"> <list> <value>black@list.org</value> @@ -5013,7 +5013,7 @@ argument.required=Ebagum lad, the '{0}' argument is required, I say, required.Now, let's look at the actual classes: - public class EmailBean implements ApplicationContextAware { + public class EmailBean implements ApplicationContextAware { private List blackList; private ApplicationContext ctx; @@ -5036,7 +5036,7 @@ argument.required=Ebagum lad, the '{0}' argument is required, I say, required. - public class BlackListNotifier implements ApplicationListener { + public class BlackListNotifier implements ApplicationListener { private String notificationAddress; @@ -5137,7 +5137,7 @@ argument.required=Ebagum lad, the '{0}' argument is required, I say, required.ApplicationContext using the ContextLoaderListener as follows: - <context-param> + <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/daoContext.xml /WEB-INF/applicationContext.xml</param-value> </context-param> @@ -5313,7 +5313,7 @@ argument.required=Ebagum lad, the '{0}' argument is required, I say, required.context' namespace): - <?xml version="1.0" encoding="UTF-8"?> + <?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:context="http://www.springframework.org/schema/context" @@ -5350,7 +5350,7 @@ argument.required=Ebagum lad, the '{0}' argument is required, I say, required.The @Required annotation applies to bean property setter methods, as in the following example: - public class SimpleMovieLister { + public class SimpleMovieLister { private MovieFinder movieFinder; @@ -5378,7 +5378,7 @@ argument.required=Ebagum lad, the '{0}' argument is required, I say, required.As expected, the @Autowired annotation may be applied to "traditional" setter methods: - public class SimpleMovieLister { + public class SimpleMovieLister { private MovieFinder movieFinder; @@ -5393,7 +5393,7 @@ argument.required=Ebagum lad, the '{0}' argument is required, I say, required.The annotation may also be applied to methods with arbitrary names and/or multiple arguments: - public class MovieRecommender { + public class MovieRecommender { private MovieCatalog movieCatalog; @@ -5411,7 +5411,7 @@ argument.required=Ebagum lad, the '{0}' argument is required, I say, required.The @Autowired annotation may even be applied on constructors and fields: - public class MovieRecommender { + public class MovieRecommender { @Autowired private MovieCatalog movieCatalog; @@ -5432,7 +5432,7 @@ argument.required=Ebagum lad, the '{0}' argument is required, I say, required. - public class MovieRecommender { + public class MovieRecommender { @Autowired private MovieCatalog[] movieCatalogs; @@ -5442,7 +5442,7 @@ argument.required=Ebagum lad, the '{0}' argument is required, I say, required.The same applies for typed collections: - public class MovieRecommender { + public class MovieRecommender { private Set<MovieCatalog> movieCatalogs; @@ -5459,7 +5459,7 @@ argument.required=Ebagum lad, the '{0}' argument is required, I say, required. - public class MovieRecommender { + public class MovieRecommender { private Map<String, MovieCatalog> movieCatalogs; @@ -5477,7 +5477,7 @@ argument.required=Ebagum lad, the '{0}' argument is required, I say, required.required dependencies. This behavior can be changed as demonstrated below. - public class SimpleMovieLister { + public class SimpleMovieLister { private MovieFinder movieFinder; @@ -5517,7 +5517,7 @@ argument.required=Ebagum lad, the '{0}' argument is required, I say, required.ResourcePatternResolver) will be automatically resolved, with no special setup necessary. - public class MovieRecommender { + public class MovieRecommender { @Autowired private ApplicationContext context; @@ -5540,7 +5540,7 @@ argument.required=Ebagum lad, the '{0}' argument is required, I say, required. - public class MovieRecommender { + public class MovieRecommender { @Autowired @Qualifier("main") @@ -5553,7 +5553,7 @@ argument.required=Ebagum lad, the '{0}' argument is required, I say, required. - public class MovieRecommender { + public class MovieRecommender { private MovieCatalog movieCatalog; @@ -5572,7 +5572,7 @@ argument.required=Ebagum lad, the '{0}' argument is required, I say, required. - <?xml version="1.0" encoding="UTF-8"?> + <?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:context="http://www.springframework.org/schema/context" @@ -5652,7 +5652,7 @@ argument.required=Ebagum lad, the '{0}' argument is required, I say, required.@Qualifier annotation within your definition: - @Target({ElementType.FIELD, ElementType.PARAMETER}) + @Target({ElementType.FIELD, ElementType.PARAMETER}) @Retention(RetentionPolicy.RUNTIME) @Qualifier public @interface Genre { @@ -5663,7 +5663,7 @@ public @interface Genre { Then you can provide the custom qualifier on autowired fields and parameters: - public class MovieRecommender { + public class MovieRecommender { @Autowired @Genre("Action") @@ -5689,7 +5689,7 @@ public @interface Genre { 'short' class name. Both are demonstrated in the following example. - <?xml version="1.0" encoding="UTF-8"?> + <?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:context="http://www.springframework.org/schema/context" @@ -5727,7 +5727,7 @@ public @interface Genre { Internet connection is available. First define the simple annotation: - @Target({ElementType.FIELD, ElementType.PARAMETER}) + @Target({ElementType.FIELD, ElementType.PARAMETER}) @Retention(RetentionPolicy.RUNTIME) @Qualifier public @interface Offline { @@ -5737,7 +5737,7 @@ public @interface Offline { Then add the annotation to the field or property to be autowired: - public class MovieRecommender { + public class MovieRecommender { @Autowired @Offline @@ -5749,7 +5749,7 @@ public @interface Offline { Now the bean definition only needs a qualifier 'type': - <bean class="example.SimpleMovieCatalog"> + <bean class="example.SimpleMovieCatalog"> <qualifier type="Offline"/> <!-- inject any dependencies required by this bean --> </bean> @@ -5762,7 +5762,7 @@ public @interface Offline { be considered an autowire candidate. As an example, consider the following annotation definition: - @Target({ElementType.FIELD, ElementType.PARAMETER}) + @Target({ElementType.FIELD, ElementType.PARAMETER}) @Retention(RetentionPolicy.RUNTIME) @Qualifier public @interface MovieQualifier { @@ -5774,7 +5774,7 @@ public @interface MovieQualifier { In this case Format is an enum: - public enum Format { + public enum Format { VHS, DVD, BLURAY } @@ -5783,7 +5783,7 @@ public @interface MovieQualifier { and include values for both attributes: 'genre' and 'format'. - public class MovieRecommender { + public class MovieRecommender { @Autowired @MovieQualifier(format=Format.VHS, genre="Action") @@ -5813,7 +5813,7 @@ public @interface MovieQualifier { provided within the <meta/> tags if no such qualifier is present (see the last 2 bean definitions below). - <?xml version="1.0" encoding="UTF-8"?> + <?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:context="http://www.springframework.org/schema/context" @@ -5865,7 +5865,7 @@ public @interface MovieQualifier { even if they are not themselves annotated with Spring's @Qualifier annotation. - <bean id="customAutowireConfigurer" class="org.springframework.beans.factory.annotation.CustomAutowireConfigurer"> + <bean id="customAutowireConfigurer" class="org.springframework.beans.factory.annotation.CustomAutowireConfigurer"> <property name="customQualifierTypes"> <set> <value>example.CustomQualifier</value> @@ -5908,7 +5908,7 @@ public @interface MovieQualifier { injected. In other words, it follows by-name semantics as demonstrated in this example: - public class SimpleMovieLister { + public class SimpleMovieLister { private MovieFinder movieFinder; @@ -5925,7 +5925,7 @@ public @interface MovieQualifier { property name. So the following example is going to have the bean with name "movieFinder" injected into its setter method: - public class SimpleMovieLister { + public class SimpleMovieLister { private MovieFinder movieFinder; @@ -5964,7 +5964,7 @@ public @interface MovieQualifier { The "context" field will simply be injected based on the known resolvable dependency type ApplicationContext. - public class MovieRecommender { + public class MovieRecommender { @Resource private CustomerPreferenceDao customerPreferenceDao; @@ -6000,7 +6000,7 @@ public @interface MovieQualifier { cache will be pre-populated upon initialization and cleared upon destruction. - public class CachingMovieLister { + public class CachingMovieLister { @PostConstruct public void populateMovieCache() { @@ -6088,7 +6088,7 @@ public @interface MovieQualifier { ApplicationContext. For example, the following two classes are eligible for such autodetection: - @Service + @Service public class SimpleMovieLister { private MovieFinder movieFinder; @@ -6099,7 +6099,7 @@ public class SimpleMovieLister { } } - @Repository + @Repository public class JpaMovieFinder implements MovieFinder { // implementation elided for clarity } @@ -6110,7 +6110,7 @@ public class JpaMovieFinder implements MovieFinder { alternatively a comma-separated list could be specified that included the parent package of each class). - <?xml version="1.0" encoding="UTF-8"?> + <?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:context="http://www.springframework.org/schema/context" @@ -6211,7 +6211,7 @@ public class JpaMovieFinder implements MovieFinder { @Repository annotations and using "stub" repositories instead. - <beans ...> + <beans ...> <context:component-scan base-package="org.example"> <context:include-filter type="regex" expression=".*Stub.*Repository"/> @@ -6251,12 +6251,12 @@ public class JpaMovieFinder implements MovieFinder { the following two components were detected, the names would be 'myMovieLister' and 'movieFinderImpl': - @Service("myMovieLister") + @Service("myMovieLister") public class SimpleMovieLister { // ... } - @Repository + @Repository public class MovieFinderImpl implements MovieFinder { // ... } @@ -6271,7 +6271,7 @@ public class MovieFinderImpl implements MovieFinder { scanner: - <beans ...> + <beans ...> <context:component-scan base-package="org.example" name-generator="org.example.MyNameGenerator" /> @@ -6293,7 +6293,7 @@ public class MovieFinderImpl implements MovieFinder { @Scope annotation as well. Simply provide the name of the scope within the annotation, such as: - @Scope("prototype") + @Scope("prototype") @Repository public class MovieFinderImpl implements MovieFinder { // ... @@ -6309,7 +6309,7 @@ public class MovieFinderImpl implements MovieFinder { scanner: - <beans ...> + <beans ...> <context:component-scan base-package="org.example" scope-resolver="org.example.MyScopeResolver" /> @@ -6325,7 +6325,7 @@ public class MovieFinderImpl implements MovieFinder { 'interfaces', and 'targetClass'. For example, the following configuration will result in standard JDK dynamic proxies: - <beans ...> + <beans ...> <context:component-scan base-package="org.example" scoped-proxy="interfaces" /> @@ -6351,19 +6351,19 @@ public class MovieFinderImpl implements MovieFinder { be provided with type-level annotations on the candidate class. The following three examples demonstrate this technique. - @Component + @Component @Qualifier("Action") public class ActionMovieCatalog implements MovieCatalog { // ... } - @Component + @Component @Genre("Action") public class ActionMovieCatalog implements MovieCatalog { // ... } - @Component + @Component @Offline public class CachingMovieCatalog implements MovieCatalog { // ... @@ -6384,7 +6384,7 @@ public class CachingMovieCatalog implements MovieCatalog { The context namespace introduced in Spring 2.5 provides a load-time-weaver element. - <beans ...> + <beans ...> <context:load-time-weaver/> diff --git a/spring-framework-reference/styles/html/custom.xsl b/spring-framework-reference/styles/html/custom.xsl index 7d06277d3d9..1786089c5d1 100644 --- a/spring-framework-reference/styles/html/custom.xsl +++ b/spring-framework-reference/styles/html/custom.xsl @@ -20,45 +20,114 @@ --> + xmlns:xslthl="http://xslthl.sf.net" + exclude-result-prefixes="xslthl" + version='1.0'> - 1 - 0 - 1 + 1 + 0 + 1 - - images/ - .gif - - 120 - images/callouts/ - .gif + + images/ + .gif + + 120 + images/callouts/ + .gif - - css/stylesheet.css - text/css - book toc,title + + css/stylesheet.css + text/css + book toc,title - text-align: left + text-align: left - - - - + + + + - - + + + + + 3 - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Begin Google Analytics code + + + End Google Analytics code + + + + + Begin LoopFuse code + + + End LoopFuse code + + + \ No newline at end of file diff --git a/spring-framework-reference/styles/pdf/custom.xsl b/spring-framework-reference/styles/pdf/custom.xsl index 6b565db4d3f..23666fd86e1 100644 --- a/spring-framework-reference/styles/pdf/custom.xsl +++ b/spring-framework-reference/styles/pdf/custom.xsl @@ -20,410 +20,487 @@ --> + xmlns:fo="http://www.w3.org/1999/XSL/Format" + xmlns:xslthl="http://xslthl.sf.net" + exclude-result-prefixes="xslthl" + version='1.0'> - - '1' - @file.prefix@@dbf.xsl@/images/ - - + + '1' + @file.prefix@@dbf.xsl@/images/ + + - - - + + + - - - - + + + + + Header + ################################################### --> - - - - - - -5em - -5em - + + + + + + -5em + -5em + + Table of Contents + ################################################### --> - - book toc,title - + + book toc,title + + Custom Header + ################################################### --> - - - - - + + + + + - - - - - - - please define productname in your docbook file! - - - + + + + + + + please define productname in your docbook file! + + + - - - - - - + + + + + + - - - - - + + + + + - - - + + + - - - + + + - - - - - + + + + + + Custom Footer + ################################################### --> - - - - - + + + + + - - - - - - - - - - + + + + + + + + + + - - - + + + - - - - - - + + + + + + - - - + + + - - - - - + + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - - - + + + + + - - - + + + + Extensions + ################################################### --> - - 1 - 0 - 1 - 1 + + 1 + 0 + 1 + 1 + Paper & Page Size + ################################################### --> - - 0 - 0 - 0 + + 0 + 0 + 0 + Fonts & Styles + ################################################### --> - false + false - - 11 - 8 + + 11 + 8 - - 1.4 + + 1.4 - - - left - bold - - - pt - - + + + left + bold + + + pt + + - - - - - - - - - - - - 0.8em - 0.8em - 0.8em - - - pt - - 0.1em - 0.1em - 0.1em - - - 0.6em - 0.6em - 0.6em - - - pt - - 0.1em - 0.1em - 0.1em - - - 0.4em - 0.4em - 0.4em - - - pt - - 0.1em - 0.1em - 0.1em - - - + + + + + + + + - - - 4pt - 4pt - 4pt - 4pt - + + + 0.8em + 0.8em + 0.8em + + + pt + + 0.1em + 0.1em + 0.1em + + + 0.6em + 0.6em + 0.6em + + + pt + + 0.1em + 0.1em + 0.1em + + + 0.4em + 0.4em + 0.4em + + + pt + + 0.1em + 0.1em + 0.1em + - - 0.1pt - 0.1pt + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Tables + ################################################### --> - - - - + + + 4pt + 4pt + 4pt + 4pt + - - + + 0.1pt + 0.1pt + Labels + ################################################### --> - - - - - pt - - + + + + - - 1em - 1em - 1em - - + + - #444444 - solid - 0.1pt - 0.5em - 0.5em - 0.5em - 0.5em - 0.5em - 0.5em - + + + + + + + pt + + + + + 1em + 1em + 1em + 0.1em + 0.1em + 0.1em + + #444444 + solid + 0.1pt + 0.5em + 0.5em + 0.5em + 0.5em + 0.5em + 0.5em + - 1 - - #F0F0F0 - + 1 + + #F0F0F0 + - - 0.1em - 0.1em - 0.1em - 0.1em - 0.1em - 0.1em - + + 0.1em + 0.1em + 0.1em + 0.1em + 0.1em + 0.1em + - - 0.5em - 0.5em - 0.5em - 0.1em - 0.1em - 0.1em - always - + + 0.5em + 0.5em + 0.5em + 0.1em + 0.1em + 0.1em + always + + Title information for Figures, Examples etc. + ################################################### --> - - normal - italic - - - pt - - false - 0.1em - 0.1em - 0.1em - + + normal + italic + + + pt + + false + 0.1em + 0.1em + 0.1em + + Callouts + ################################################### --> - - 0 - 1 + + 0 + 1 - - 90 + + 90 + Misc + ################################################### --> - - - figure after - example after - equation before - table before - procedure before - + + + figure after + example after + equation before + table before + procedure before + - - 1 + + 1 - 0pt + 0pt + + + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - \ No newline at end of file