Skip to content

Commit fc2d8ba

Browse files
committed
SPR-5917 Add docs on Lifecycle
1 parent e8845c7 commit fc2d8ba

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

spring-framework-reference/src/jdbc.xml

+20-4
Original file line numberDiff line numberDiff line change
@@ -2624,7 +2624,7 @@ clobReader.close();</programlisting>
26242624

26252625
<para>The SQL standard allows for selecting rows based on an expression
26262626
that includes a variable list of values. A typical example would be
2627-
"select * from <code>T_ACTOR where id in (1, 2, 3)</code>. This variable
2627+
<code>select * from T_ACTOR where id in (1, 2, 3)</code>. This variable
26282628
list is not directly supported for prepared statements by the JDBC
26292629
standard; you cannot declare a variable number of placeholders. You need
26302630
a number of variations with the desired number of placeholders prepared,
@@ -2648,8 +2648,8 @@ clobReader.close();</programlisting>
26482648
<para>In addition to the primitive values in the value list, you can
26492649
create a <classname>java.util.List</classname> of object arrays. This
26502650
list would support multiple expressions defined for the <code>in</code>
2651-
clause such as "<symbol>select * from T_ACTOR where (id, last_name) in
2652-
((1, 'Johnson'), (2, 'Harrop'))</symbol>". <!--Is the preceding punctuated correctly? I'm not sure what to put in code font. TR: OK.-->This
2651+
clause such as <code>select * from T_ACTOR where (id, last_name) in
2652+
((1, 'Johnson'), (2, 'Harrop'))</code>. This
26532653
of course requires that your database supports this syntax.</para>
26542654
</section>
26552655

@@ -2975,18 +2975,34 @@ public class DataAccessUnitTestTemplate {
29752975
<para>The first option might be easy if the application is in your
29762976
control, and not otherwise. Some suggestions for how to implement this
29772977
are<itemizedlist>
2978+
29782979
<listitem>
29792980
<para>Make the cache initialize lazily on first usage, which
29802981
improves application startup time</para>
29812982
</listitem>
29822983

2984+
<listitem>
2985+
<para>Have your cache or a separate component that
2986+
initializes the cache implement <code>Lifecycle</code> or
2987+
<code>SmartLifecycle</code>. When the application context
2988+
starts up a <code>SmartLifecycle</code> can be automatically
2989+
started if its <code>autoStartup</code> flag is set,
2990+
and a <code>Lifecycle</code> can be started
2991+
manually by calling
2992+
<code>ConfigurableApplicationContext.start()</code> on the
2993+
enclosing context.
2994+
</para>
2995+
</listitem>
2996+
29832997
<listitem>
29842998
<para>Use a Spring <code>ApplicationEvent</code> or similar
29852999
custom observer mechanism to trigger the cache initialization.
29863000
<code>ContextRefreshedEvent</code> is always published by the
29873001
context when it is ready for use (after all beans have been
2988-
initialized), so that is often a useful hook.</para>
3002+
initialized), so that is often a useful hook (this is
3003+
how the <code>SmartLifecycle</code> works by default).</para>
29893004
</listitem>
3005+
29903006
</itemizedlist></para>
29913007

29923008
<para>The second option can also be easy. Some suggestions on how to

0 commit comments

Comments
 (0)