001: /**
002: * Sequoia: Database clustering technology.
003: * Copyright (C) 2006 Continuent, Inc.
004: * Contact: sequoia@continuent.org
005: *
006: * Licensed under the Apache License, Version 2.0 (the "License");
007: * you may not use this file except in compliance with the License.
008: * You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing, software
013: * distributed under the License is distributed on an "AS IS" BASIS,
014: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: *
018: * Initial developer(s): Emmanuel Cecchet.
019: * Contributor(s): ______________________.
020: */package org.continuent.sequoia.controller.virtualdatabase;
021:
022: import java.io.Serializable;
023:
024: /**
025: * This class defines a ConnectionContext to carry information about the
026: * connection to gather metadata.
027: *
028: * @author <a href="mailto:emmanuel.cecchet@continuent.com">Emmanuel Cecchet</a>
029: * @version 1.0
030: */
031: public class ConnectionContext implements Serializable {
032: private static final long serialVersionUID = 4211807376311527783L;
033:
034: private String login;
035: private boolean isPersistentConnection;
036: private long persistentConnectionId;
037: private long currentTid;
038: private boolean isStartedTransaction;
039:
040: /**
041: * Creates a new <code>ConnectionContext</code> object
042: *
043: * @param login login of the connection
044: * @param isTransaction true if the connection is not in autocommit
045: * @param transactionId transaction id (if isTransaction is true)
046: * @param isPersistent true if the connection is persistent
047: * @param persistentId persistent connection id if the connection is
048: * persistent
049: */
050: public ConnectionContext(String login, boolean isTransaction,
051: long transactionId, boolean isPersistent, long persistentId) {
052: this .login = login;
053: isStartedTransaction = isTransaction;
054: currentTid = transactionId;
055: isPersistentConnection = isPersistent;
056: persistentConnectionId = persistentId;
057: }
058:
059: /**
060: * Returns the transaction id (only makes sense if isStartedTransaction is
061: * true).
062: *
063: * @return Returns the transaction id.
064: */
065: public final long getTransactionId() {
066: return currentTid;
067: }
068:
069: /**
070: * Returns the login value.
071: *
072: * @return Returns the login.
073: */
074: public final String getLogin() {
075: return login;
076: }
077:
078: /**
079: * Returns the persistentConnectionId value.
080: *
081: * @return Returns the persistentConnectionId.
082: */
083: public final long getPersistentConnectionId() {
084: return persistentConnectionId;
085: }
086:
087: /**
088: * Returns the isPersistentConnection value.
089: *
090: * @return Returns the isPersistentConnection.
091: */
092: public final boolean isPersistentConnection() {
093: return isPersistentConnection;
094: }
095:
096: /**
097: * Returns the isStartedTransaction value.
098: *
099: * @return Returns the isStartedTransaction.
100: */
101: public final boolean isStartedTransaction() {
102: return isStartedTransaction;
103: }
104:
105: /**
106: * Sets the isStartedTransaction value.
107: *
108: * @param isStartedTransaction The isStartedTransaction to set.
109: */
110: public final void setStartedTransaction(boolean isStartedTransaction) {
111: this.isStartedTransaction = isStartedTransaction;
112: }
113:
114: }
|