From d256d02fc21566c6420add3a639447f41fd9def1 Mon Sep 17 00:00:00 2001 From: David Syer Date: Fri, 13 Nov 2009 07:48:33 +0000 Subject: [PATCH] SPR-5917 Add docs on Lifecycle git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@2428 50f2f4bb-b051-0410-bef5-90022cba6387 --- spring-framework-reference/src/jdbc.xml | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/spring-framework-reference/src/jdbc.xml b/spring-framework-reference/src/jdbc.xml index bb0e78838cc..11b7ae20889 100644 --- a/spring-framework-reference/src/jdbc.xml +++ b/spring-framework-reference/src/jdbc.xml @@ -2624,7 +2624,7 @@ clobReader.close(); The SQL standard allows for selecting rows based on an expression that includes a variable list of values. A typical example would be - "select * from T_ACTOR where id in (1, 2, 3). This variable + select * from T_ACTOR where id in (1, 2, 3). This variable list is not directly supported for prepared statements by the JDBC standard; you cannot declare a variable number of placeholders. You need a number of variations with the desired number of placeholders prepared, @@ -2648,8 +2648,8 @@ clobReader.close(); In addition to the primitive values in the value list, you can create a java.util.List of object arrays. This list would support multiple expressions defined for the in - clause such as "select * from T_ACTOR where (id, last_name) in - ((1, 'Johnson'), (2, 'Harrop'))". This + clause such as select * from T_ACTOR where (id, last_name) in + ((1, 'Johnson'), (2, 'Harrop')). This of course requires that your database supports this syntax. @@ -2975,18 +2975,34 @@ public class DataAccessUnitTestTemplate { The first option might be easy if the application is in your control, and not otherwise. Some suggestions for how to implement this are + Make the cache initialize lazily on first usage, which improves application startup time + + Have your cache or a separate component that + initializes the cache implement Lifecycle or + SmartLifecycle. When the application context + starts up a SmartLifecycle can be automatically + started if its autoStartup flag is set, + and a Lifecycle can be started + manually by calling + ConfigurableApplicationContext.start() on the + enclosing context. + + + Use a Spring ApplicationEvent or similar custom observer mechanism to trigger the cache initialization. ContextRefreshedEvent is always published by the context when it is ready for use (after all beans have been - initialized), so that is often a useful hook. + initialized), so that is often a useful hook (this is + how the SmartLifecycle works by default). + The second option can also be easy. Some suggestions on how to