001: /**
002: * High Availability Service (HA) for JOnAS
003: *
004: * Copyright (C) 2006 Distributed Systems Lab.
005: * Universidad Polit??cnica de Madrid (Spain)
006: * Contact: http://lsd.ls.fi.upm.es/lsd
007: *
008: * This library is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU Lesser General Public
010: * License as published by the Free Software Foundation; either
011: * version 2.1 of the License, or any later version.
012: *
013: * This library is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016: * Lesser General Public License for more details.
017: *
018: * You should have received a copy of the GNU Lesser General Public
019: * License along with this library; if not, write to the Free Software
020: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
021: * USA
022: *
023: * --------------------------------------------------------------------------
024: * $Id: HACurrentContext.java 9280 2006-08-01 10:15:24Z japaz $
025: * --------------------------------------------------------------------------
026: */package org.objectweb.jonas.ha.interceptor;
027:
028: import java.util.Stack;
029:
030: import org.objectweb.carol.cmi.ha.RequestId;
031: import org.objectweb.carol.cmi.ha.ViewIdWrapper;
032:
033: /**
034: * This is the class stored in the Thread local variable of HACurrent class and
035: * represents the thread associated HA context
036: * @author Francisco Perez-Sorrosal (fpsorrosal@no-spam@fi.upm.es)
037: * @author Alberto Paz-Jimenez (apaz@no-spam@fi.upm.es)
038: */
039: public class HACurrentContext {
040: /**
041: * Holds info about the request chain
042: */
043: private Stack requests = new Stack();
044:
045: /**
046: * Holds the on failover info
047: */
048: private boolean onFailover = false;
049:
050: /**
051: * ViewIdWrapper
052: */
053: private ViewIdWrapper wrapper = null;
054:
055: /**
056: * Constructor
057: */
058: public HACurrentContext() {
059: }
060:
061: /**
062: * Set the requests
063: * @param reqs the requests
064: */
065: public void setRequests(Stack reqs) {
066: requests = reqs;
067: }
068:
069: /**
070: * Get the requests
071: * @return the requests
072: */
073: public Stack getRequests() {
074: return requests;
075: }
076:
077: /**
078: * Put the request as the las request
079: */
080: public void putNextReq(RequestId nextReq) {
081: // Check that the request is not in the Stack
082: if (requests.contains(nextReq)) {
083: while (!requests.peek().equals(nextReq)) {
084: requests.pop();
085: }
086: } else {
087: requests.push(nextReq);
088: }
089: }
090:
091: /**
092: * @return Returns the onFailover.
093: */
094: public boolean isOnFailover() {
095: return onFailover;
096: }
097:
098: /**
099: * @param onFailover The onFailover to set.
100: */
101: public void setOnFailover(boolean onFailover) {
102: this .onFailover = onFailover;
103: }
104:
105: public ViewIdWrapper getViewIdWrapper() {
106: return wrapper;
107: }
108:
109: public void setViewIdWrapper(ViewIdWrapper wrapper) {
110: this.wrapper = wrapper;
111: }
112: }
|