1 16 17 package org.springframework.orm.toplink; 18 19 import oracle.toplink.exceptions.TopLinkException; 20 import oracle.toplink.exceptions.ValidationException; 21 import oracle.toplink.sessionbroker.SessionBroker; 22 import oracle.toplink.sessions.Session; 23 24 48 public class SessionBrokerSessionFactory extends AbstractSessionFactory { 49 50 private final SessionBroker sessionBroker; 51 52 53 57 public SessionBrokerSessionFactory(SessionBroker broker) { 58 this.sessionBroker = broker; 59 } 60 61 62 69 public Session createSession() throws TopLinkException { 70 try { 71 return createClientSession(); 72 } 73 catch (ValidationException ex) { 74 logger.debug( 75 "Could not create TopLink client session for SessionBroker - returning SessionBroker itself", ex); 76 return getMasterSession(); 77 } 78 } 79 80 83 protected Session getMasterSession() { 84 return this.sessionBroker; 85 } 86 87 91 protected Session createClientSession() throws TopLinkException { 92 return this.sessionBroker.acquireClientSessionBroker(); 93 } 94 95 96 101 public void close() { 102 this.sessionBroker.logout(); 103 this.sessionBroker.release(); 104 } 105 106 } 107 | Popular Tags |