1 21 package oracle.toplink.essentials.threetier; 23 24 import oracle.toplink.essentials.internal.databaseaccess.*; 25 import oracle.toplink.essentials.sessions.Login; 26 import oracle.toplink.essentials.exceptions.*; 27 28 34 public class ExternalConnectionPool extends ConnectionPool { 35 protected Accessor cachedConnection; 36 37 41 public ExternalConnectionPool() { 42 super(); 43 } 44 45 49 public ExternalConnectionPool(String name, Login login, ServerSession owner) { 50 super(name, login, 0, 0, owner); 51 } 52 53 58 public synchronized Accessor acquireConnection() throws ConcurrencyException { 59 return (Accessor)getCachedConnection().clone(); 60 } 61 62 67 protected Accessor getCachedConnection() { 68 return cachedConnection; 69 } 70 71 75 public boolean hasConnectionAvailable() { 76 return true; 77 } 78 79 83 public boolean isThereConflictBetweenLoginAndType() { 84 return !getLogin().shouldUseExternalConnectionPooling(); 85 } 86 87 91 public synchronized void releaseConnection(Accessor connection) throws DatabaseException { 92 getConnectionsUsed().removeElement(connection); 93 connection.closeConnection(); 94 notify(); 95 } 96 97 101 protected void setCachedConnection(Accessor cachedConnection) { 102 this.cachedConnection = cachedConnection; 103 } 104 105 109 public synchronized void shutDown() { 110 setIsConnected(false); 112 } 113 114 119 public synchronized void startUp() { 120 setCachedConnection(buildConnection()); 121 setIsConnected(true); 122 } 123 } 124 | Popular Tags |