1 16 package org.springframework.webflow.conversation.impl; 17 18 import org.apache.commons.logging.Log; 19 import org.apache.commons.logging.LogFactory; 20 import org.springframework.core.JdkVersion; 21 22 29 public class ConversationLockFactory { 30 31 private static final Log logger = LogFactory.getLog(ConversationLockFactory.class); 32 33 private static boolean utilConcurrentPresent; 34 35 static { 36 try { 37 Class.forName("EDU.oswego.cs.dl.util.concurrent.ReentrantLock"); 38 utilConcurrentPresent = true; 39 } 40 catch (ClassNotFoundException ex) { 41 utilConcurrentPresent = false; 42 } 43 } 44 45 50 public static ConversationLock createLock() { 51 if (JdkVersion.getMajorJavaVersion() >= JdkVersion.JAVA_15) { 52 return new JdkConcurrentConversationLock(); 53 } 54 else if (utilConcurrentPresent) { 55 return new UtilConcurrentConversationLock(); 56 } 57 else { 58 logger.warn("Unable to enable conversation locking. Switch to Java 5 or above, " 59 + "or put the 'util.concurrent' package on the classpath " 60 + "to enable locking in your environment."); 61 return NoOpConversationLock.INSTANCE; 62 } 63 } 64 } | Popular Tags |