From: Rick E. <spr...@us...> - 2006-04-19 15:41:09
|
Update of /cvsroot/springframework/spring/docs/reference/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22166/docs/reference/src Modified Files: beans.xml Log Message: Reformatted the code blocks in light of the larger font size change. Index: beans.xml =================================================================== RCS file: /cvsroot/springframework/spring/docs/reference/src/beans.xml,v retrieving revision 1.95 retrieving revision 1.96 diff -C2 -d -r1.95 -r1.96 *** beans.xml 19 Apr 2006 13:38:00 -0000 1.95 --- beans.xml 19 Apr 2006 15:41:04 -0000 1.96 *************** *** 644,651 **** <programlisting><![CDATA[public class SimpleMovieLister { ! ]]><lineannotation>// the <classname>SimpleMovieLister</classname> has a dependency on the <interfacename>MovieFinder</interfacename> <emphasis>interface</emphasis></lineannotation><![CDATA[ private MovieFinder movieFinder; ! ]]><lineannotation>// a setter method so that the Spring container can 'inject' an appropriate <interfacename>MovieFinder</interfacename> <emphasis>implementation</emphasis></lineannotation><![CDATA[ public void setMoveFinder(MovieFinder movieFinder) { this.movieFinder = movieFinder; --- 644,651 ---- <programlisting><![CDATA[public class SimpleMovieLister { ! ]]><lineannotation>// the <classname>SimpleMovieLister</classname> has a dependency on the <interfacename>MovieFinder</interfacename></lineannotation><![CDATA[ private MovieFinder movieFinder; ! ]]><lineannotation>// a setter method so that the Spring container can 'inject' a <interfacename>MovieFinder</interfacename></lineannotation><![CDATA[ public void setMoveFinder(MovieFinder movieFinder) { this.movieFinder = movieFinder; *************** *** 673,680 **** <programlisting><![CDATA[public class SimpleMovieLister { ! ]]><lineannotation>// the <classname>SimpleMovieLister</classname> has a dependency on the <interfacename>MovieFinder</interfacename> <emphasis>interface</emphasis></lineannotation><![CDATA[ private MovieFinder movieFinder; ! ]]><lineannotation>// a constructor so that the Spring container can 'inject' an appropriate <interfacename>MovieFinder</interfacename> <emphasis>implementation</emphasis></lineannotation><![CDATA[ public SimpleMovieLister(MovieFinder movieFinder) { this.movieFinder = movieFinder; --- 673,680 ---- <programlisting><![CDATA[public class SimpleMovieLister { ! ]]><lineannotation>// the <classname>SimpleMovieLister</classname> has a dependency on the <interfacename>MovieFinder</interfacename></lineannotation><![CDATA[ private MovieFinder movieFinder; ! ]]><lineannotation>// a constructor so that the Spring container can 'inject' a <interfacename>MovieFinder</interfacename></lineannotation><![CDATA[ public SimpleMovieLister(MovieFinder movieFinder) { this.movieFinder = movieFinder; *************** *** 883,887 **** private int i; ! public ExampleBean(AnotherBean anotherBean, YetAnotherBean yetAnotherBean, int i) { this.beanOne = anotherBean; this.beanTwo = yetAnotherBean; --- 883,888 ---- private int i; ! public ExampleBean( ! AnotherBean anotherBean, YetAnotherBean yetAnotherBean, int i) { this.beanOne = anotherBean; this.beanTwo = yetAnotherBean; *************** *** 915,921 **** } ! // a static factory method ! // the arguments to this method can be considered the dependencies of the bean that ! // is returned, regardless of how those arguments are actually used. public static ExampleBean createInstance ( AnotherBean anotherBean, YetAnotherBean yetAnotherBean, int i) { --- 916,922 ---- } ! // a static factory method; the arguments to this method can be ! // considered the dependencies of the bean that is returned, ! // regardless of how those arguments are actually used. public static ExampleBean createInstance ( AnotherBean anotherBean, YetAnotherBean yetAnotherBean, int i) { *************** *** 989,994 **** public class ExampleBean { ! private int years; ]]><lineannotation>// No. of years to the calculate the Ultimate Answer</lineannotation><![CDATA[ ! private String ultimateAnswer; ]]><lineannotation>// The Answer to Life, the Universe, and Everything</lineannotation><![CDATA[ public ExampleBean(int years, String ultimateAnswer) { --- 990,998 ---- public class ExampleBean { ! ]]><lineannotation>// No. of years to the calculate the Ultimate Answer</lineannotation><![CDATA[ ! private int years; ! ! ]]><lineannotation>// The Answer to Life, the Universe, and Everything</lineannotation><![CDATA[ ! private String ultimateAnswer; public ExampleBean(int years, String ultimateAnswer) { *************** *** 1041,1061 **** <section id="beans-value-element"> <title>The <literal>value</literal> element</title> ! <para>The <literal>value</literal> element specifies a property or ! constructor argument as a human-readable string representation. As ! mentioned in detail <link linkend="beans-factory-collaborators-propertyeditor">previously</link>, ! JavaBeans PropertyEditors are used to convert these string values from ! a <literal>java.lang.String</literal> to the actual property or ! argument type.<programlisting><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</value> ! </property> ! <property name="url"> ! <value>jdbc:mysql://localhost:3306/mydb</value> ! </property> ! <property name="username"> ! <value>root</value> ! </property> ! </bean></programlisting></para> </section> <section id="beans-null-element"> --- 1045,1069 ---- <section id="beans-value-element"> <title>The <literal>value</literal> element</title> ! <para> ! The <literal>value</literal> element specifies a property or ! constructor argument as a human-readable string representation. As ! mentioned in detail <link linkend="beans-factory-collaborators-propertyeditor">previously</link>, ! JavaBeans PropertyEditors are used to convert these string values from ! a <literal>java.lang.String</literal> to the actual property or ! argument type. ! </para> ! <programlisting><![CDATA[<bean id="myDataSource" destroy-method="close" ! class="org.apache.commons.dbcp.BasicDataSource"> ! <!-- results in a setDriverClassName(String) call --> ! <property name="driverClassName"> ! <value>com.mysql.jdbc.Driver</value> ! </property> ! <property name="url"> ! <value>jdbc:mysql://localhost:3306/mydb</value> ! </property> ! <property name="username"> ! <value>root</value> ! </property> ! </bean>]]></programlisting> </section> <section id="beans-null-element"> *************** *** 1275,1279 **** </para> <programlisting><![CDATA[<property name="targetName"> ! ]]><lineannotation><!-- a bean with an id of 'target' must exist, else an XML parse exception will be thrown --></lineannotation><![CDATA[ <idref local="theTargetBean"/> </property>]]></programlisting> --- 1283,1289 ---- </para> <programlisting><![CDATA[<property name="targetName"> ! ]]><lineannotation><!-- ! a bean with an id of 'target' must exist, else an XML exception will be thrown ! --></lineannotation><![CDATA[ <idref local="theTargetBean"/> </property>]]></programlisting> *************** *** 1818,1872 **** <section id="beans-factory-dependencies"> <title>Checking for dependencies</title> ! <para>Spring has the ability to try to check for the existence of ! unresolved dependencies of a bean deployed into the BeanFactory. These ! are JavaBeans properties of the bean, which do not have actual values ! set for them in the bean definition, or alternately provided ! automatically by the autowiring feature.</para> ! <para>This feature is sometimes useful when you want to ensure that all ! properties (or all properties of a certain type) are set on a bean. Of ! course, in many cases a bean class will have default values for many ! properties, or some properties do not apply to all usage scenarios, so ! this feature is of limited use. Dependency checking can also be enabled ! and disabled per bean, just as with the autowiring functionality. The ! default is to <emphasis>not</emphasis> check dependencies. Dependency ! checking can be handled in several different modes. In an ! XmlBeanFactory, this is specified via the ! <literal>dependency-check</literal> attribute in a bean definition, ! which may have the following values.<table frame="all"> ! <title>Dependency checking modes</title> ! <tgroup cols="2"> ! <colspec colname="c1" colwidth="1*" /> ! <colspec colname="c2" colwidth="5*" /> ! <thead> ! <row> ! <entry>Mode</entry> ! <entry>Explanation</entry> ! </row> ! </thead> ! <tbody> ! <row> ! <entry>none</entry> ! <entry>No dependency checking. Properties of the bean which ! have no value specified for them are simply not set.</entry> ! </row> ! <row> ! <entry>simple</entry> ! <entry>Dependency checking is performed for primitive types ! and collections (everything except collaborators, i.e. other ! beans)</entry> ! </row> ! <row> ! <entry>object</entry> ! <entry>Dependency checking is performed for ! collaborators</entry> ! </row> ! <row> ! <entry>all</entry> ! <entry>Dependency checking is done for collaborators, ! primitive types and collections</entry> ! </row> ! </tbody> ! </tgroup> ! </table></para> </section> </section> --- 1828,1892 ---- <section id="beans-factory-dependencies"> <title>Checking for dependencies</title> ! <para> ! Spring has the ability to try to check for the existence of ! unresolved dependencies of a bean deployed into the BeanFactory. These ! are JavaBeans properties of the bean, which do not have actual values ! set for them in the bean definition, or alternately provided ! automatically by the autowiring feature. ! </para> ! <para> ! This feature is sometimes useful when you want to ensure that all ! properties (or all properties of a certain type) are set on a bean. Of ! course, in many cases a bean class will have default values for many ! properties, or some properties do not apply to all usage scenarios, so ! this feature is of limited use. Dependency checking can also be enabled ! and disabled per bean, just as with the autowiring functionality. The ! default is to <emphasis>not</emphasis> check dependencies. Dependency ! checking can be handled in several different modes. In an ! <classname>XmlBeanFactory</classname>, this is specified via the ! <literal>dependency-check</literal> attribute in a bean definition, ! which may have the following values. ! </para> ! <table frame="all"> ! <title>Dependency checking modes</title> ! <tgroup cols="2"> ! <colspec colname="c1" colwidth="1*" /> ! <colspec colname="c2" colwidth="5*" /> ! <thead> ! <row> ! <entry>Mode</entry> ! <entry>Explanation</entry> ! </row> ! </thead> ! <tbody> ! <row> ! <entry>none</entry> ! <entry>No dependency checking. Properties of the bean which ! have no value specified for them are simply not set.</entry> ! </row> ! <row> ! <entry>simple</entry> ! <entry>Dependency checking is performed for primitive types ! and collections (everything except collaborators, i.e. other ! beans)</entry> ! </row> ! <row> ! <entry>object</entry> ! <entry>Dependency checking is performed for ! collaborators</entry> ! </row> ! <row> ! <entry>all</entry> ! <entry>Dependency checking is done for collaborators, ! primitive types and collections</entry> ! </row> ! </tbody> ! </tgroup> ! </table> ! <para> ! If you are using Java5 (and thus have access to source level annotations), ! you may find the section entitled <xref linkend="metadata-annotations-required"/> ! (in the chapter entitled <xref linkend="metadata"/>) to be of interest. ! </para> </section> </section> *************** *** 2147,2151 **** <bean id="newsFeedManager" class="x.y.NewsFeedManager"> <property name="factory"> ! <bean class="org.springframework.beans.factory.config.ObjectFactoryCreatingFactoryBean"> <property name="targetBeanName"> <idref local="newsFeed" /> --- 2167,2172 ---- <bean id="newsFeedManager" class="x.y.NewsFeedManager"> <property name="factory"> ! <bean ! class="org.springframework.beans.factory.config.ObjectFactoryCreatingFactoryBean"> <property name="targetBeanName"> <idref local="newsFeed" /> *************** *** 2172,2176 **** public static void main(String[] args) throws Exception { ! <interfacename>ApplicationContext</interfacename> ctx = new ClassPathXmlApplicationContext("beans.xml"); NewsFeedManager manager = (NewsFeedManager) ctx.getBean("newsFeedManager"); manager.printNews(); --- 2193,2197 ---- public static void main(String[] args) throws Exception { ! ApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml"); NewsFeedManager manager = (NewsFeedManager) ctx.getBean("newsFeedManager"); manager.printNews(); *************** *** 2259,2263 **** </bean> ! <bean id="inheritsWithDifferentClass" class="org.springframework.beans.DerivedTestBean" parent="inheritedTestBean" init-method="initialize"> <property name="name" value="override"/> --- 2280,2285 ---- </bean> ! <bean id="inheritsWithDifferentClass" ! class="org.springframework.beans.DerivedTestBean" parent="inheritedTestBean" init-method="initialize"> <property name="name" value="override"/> *************** *** 2461,2465 **** we will apply a <interfacename>PropertyPlaceholderConfigurer</interfacename> to the <interfacename>BeanFactory</interfacename> which will replace some properties of the datasource:</para> ! <programlisting><![CDATA[<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${jdbc.driverClassName}"/> <property name="url" value="${jdbc.url}"/> --- 2483,2488 ---- we will apply a <interfacename>PropertyPlaceholderConfigurer</interfacename> to the <interfacename>BeanFactory</interfacename> which will replace some properties of the datasource:</para> ! <programlisting><![CDATA[<bean id="dataSource" destroy-method="close" ! class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="${jdbc.driverClassName}"/> <property name="url" value="${jdbc.url}"/> *************** *** 2785,2789 **** specify the locale that we want to resolve our (British) messages against.</para> <programlisting><![CDATA[# in 'exceptions_en_GB.properties' ! argument.required=Ebagum lad, the '{0}' argument is required, I say, I say, required.]]></programlisting> <programlisting><![CDATA[public static void main(final String[] args) { MessageSource resources = new ClassPathXmlApplicationContext("beans.xml"); --- 2808,2812 ---- specify the locale that we want to resolve our (British) messages against.</para> <programlisting><![CDATA[# in 'exceptions_en_GB.properties' ! argument.required=Ebagum lad, the '{0}' argument is required, I say, required.]]></programlisting> <programlisting><![CDATA[public static void main(final String[] args) { MessageSource resources = new ClassPathXmlApplicationContext("beans.xml"); *************** *** 2793,2797 **** }]]></programlisting> <para>The resulting output from the runnning of the above program will be...</para> ! <programlisting><![CDATA[Ebagum lad, the 'userDao' argument is required, I say, I say, required.]]></programlisting> <para>The <classname>MessageSourceAware</classname> interface can also be used to acquire a reference to any <classname>MessageSource</classname> that has been defined. Any bean --- 2816,2820 ---- }]]></programlisting> <para>The resulting output from the runnning of the above program will be...</para> ! <programlisting><![CDATA[Ebagum lad, the 'userDao' argument is required, I say, required.]]></programlisting> <para>The <classname>MessageSourceAware</classname> interface can also be used to acquire a reference to any <classname>MessageSource</classname> that has been defined. Any bean *************** *** 3159,3165 **** // will result in 11, which is the value of property 'spouse.age' of bean 'person' ! <bean id="theAge" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"> ! <property name="targetBeanName"><value>person</value></property> ! <property name="propertyPath"><value>spouse.age</value></property> </bean>]]></programlisting> <para> --- 3182,3189 ---- // will result in 11, which is the value of property 'spouse.age' of bean 'person' ! <bean id="theAge" ! class="org.springframework.beans.factory.config.PropertyPathFactoryBean"> ! <property name="targetBeanName" value="person"/> ! <property name="propertyPath" value="spouse.age"/> </bean>]]></programlisting> <para> *************** *** 3167,3174 **** </para> <programlisting><![CDATA[// will result in 12, which is the value of property 'age' of the inner bean ! <bean id="theAge" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"> <property name="targetObject"> <bean class="org.springframework.beans.TestBean"> ! <property name="age"><value>12</value></property> </bean> </property> --- 3191,3199 ---- </para> <programlisting><![CDATA[// will result in 12, which is the value of property 'age' of the inner bean ! <bean id="theAge" ! class="org.springframework.beans.factory.config.PropertyPathFactoryBean"> <property name="targetObject"> <bean class="org.springframework.beans.TestBean"> ! <property name="age" value="12"/> </bean> </property> *************** *** 3179,3183 **** </para> <programlisting><![CDATA[// will result in 10, which is the value of property 'age' of bean 'person' ! <bean id="person.age" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>]]></programlisting> <para> This form does mean that there is no choice in the name of the bean, --- 3204,3209 ---- </para> <programlisting><![CDATA[// will result in 10, which is the value of property 'age' of bean 'person' ! <bean id="person.age" ! class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>]]></programlisting> <para> This form does mean that there is no choice in the name of the bean, *************** *** 3188,3192 **** <programlisting><![CDATA[<bean id="..." class="..."> <property name="age"> ! <bean id="person.age" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/> </property> </bean>]]></programlisting> --- 3214,3219 ---- <programlisting><![CDATA[<bean id="..." class="..."> <property name="age"> ! <bean id="person.age" ! class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/> </property> </bean>]]></programlisting> *************** *** 3223,3227 **** </para> <programlisting><![CDATA[<bean id="java.sql.Connection.TRANSACTION_SERIALIZABLE" ! class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean"/>]]></programlisting> <para> This does mean that there is no longer any choice in what the bean id is (so --- 3250,3254 ---- </para> <programlisting><![CDATA[<bean id="java.sql.Connection.TRANSACTION_SERIALIZABLE" ! class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean"/>]]></programlisting> <para> This does mean that there is no longer any choice in what the bean id is (so *************** *** 3234,3238 **** <property name="isolation"> <bean id="java.sql.Connection.TRANSACTION_SERIALIZABLE" ! class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean" /> </property> </bean>]]></programlisting> --- 3261,3265 ---- <property name="isolation"> <bean id="java.sql.Connection.TRANSACTION_SERIALIZABLE" ! class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean" /> </property> </bean>]]></programlisting> *************** *** 3303,3316 **** initialization: </para> ! <programlisting><![CDATA[<bean id="force-init" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> ! <property name="staticMethod"><value>com.example.MyClass.initialize</value></property> ! </bean> ! <bean id="bean1" class="..." depends-on="force-init"> ... ! </bean>]]></programlisting> <para> ! Note that the definition for ! <literal>bean1</literal> has used the <literal>depends-on</literal> attribute to refer to the <literal>force-init</literal> bean, which will trigger initializing <literal>force-init</literal> first, and thus calling --- 3330,3344 ---- initialization: </para> ! <programlisting><![CDATA[<bean id="force-init" ! class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> ! <property name="staticMethod" value="com.example.MyClass.initialize"/> ! </bean> ! <bean id="bean1" class="..." depends-on="force-init"> ... ! </bean>]]></programlisting> <para> ! Note that the definition for the <literal>bean1</literal> bean ! has used the <literal>depends-on</literal> attribute to refer to the <literal>force-init</literal> bean, which will trigger initializing <literal>force-init</literal> first, and thus calling *************** *** 3322,3327 **** a <literal>static</literal> factory method: </para> ! <programlisting><![CDATA[<bean id="myClass" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> ! <property name="staticMethod"><value>com.whatever.MyClassFactory.getInstance</value></property> </bean>]]></programlisting> <para> --- 3350,3357 ---- a <literal>static</literal> factory method: </para> ! <programlisting><![CDATA[<bean id="myClass" ! class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> ! <property name="staticMethod" ! value="com.whatever.MyClassFactory.getInstance"/> </bean>]]></programlisting> <para> *************** *** 3330,3339 **** verbose, but it works.) </para> ! <programlisting><![CDATA[<bean id="sysProps" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> <property name="targetClass"><value>java.lang.System</value></property> <property name="targetMethod"><value>getProperties</value></property> </bean> ! <bean id="javaVersion" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> <property name="targetObject"><ref local="sysProps"/></property> <property name="targetMethod"><value>getProperty</value></property> --- 3360,3371 ---- verbose, but it works.) </para> ! <programlisting><![CDATA[<bean id="sysProps" ! class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> <property name="targetClass"><value>java.lang.System</value></property> <property name="targetMethod"><value>getProperties</value></property> </bean> ! <bean id="javaVersion" ! class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> <property name="targetObject"><ref local="sysProps"/></property> <property name="targetMethod"><value>getProperty</value></property> *************** *** 3454,3458 **** <listener> ! <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> --- 3486,3492 ---- <listener> ! <listener-class> ! org.springframework.web.context.ContextLoaderListener ! </listener-class> </listener> *************** *** 3460,3464 **** <servlet> <servlet-name>context</servlet-name> ! <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> --- 3494,3500 ---- <servlet> <servlet-name>context</servlet-name> ! <servlet-class> ! org.springframework.web.context.ContextLoaderServlet ! </servlet-class> <load-on-startup>1</load-on-startup> </servlet> |