OW2 Consortium joram

Compare Revisions

Ignore whitespace Rev 6541 → Rev 6542

/trunk/joram/joram/mom/core/src/main/java/org/objectweb/joram/mom/proxies/ClientContext.java
1,6 → 1,6
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2003 - 2012 ScalAgent Distributed Technologies
* Copyright (C) 2003 - 2017 ScalAgent Distributed Technologies
* Copyright (C) 2004 France Telecom R&D
* Copyright (C) 2003 - 2004 Bull SA
*
507,5 → 507,42
}
 
}
}
 
class CCUID {
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ctxid;
result = prime * result + ((ua == null) ? 0 : ua.hashCode());
return result;
}
 
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
CCUID other = (CCUID) obj;
if (ctxid != other.ctxid)
return false;
if (ua == null) {
if (other.ua != null)
return false;
} else if (!ua.equals(other.ua))
return false;
return true;
}
 
AgentId ua = null;
int ctxid = -1;
 
CCUID(AgentId ua, int ctxid) {
this.ua = ua;
this.ctxid = ctxid;
}
}
/trunk/joram/joram/mom/core/src/main/java/org/objectweb/joram/mom/proxies/UserAgent.java
34,8 → 34,10
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.LinkedHashMap;
181,7 → 183,6
* destinations replies to clients.
*/
public final class UserAgent extends Agent implements UserAgentMBean, ProxyAgentItf {
 
/** define serialVersionUID for interoperability */
private static final long serialVersionUID = 1L;
 
344,6 → 345,24
private Map<Integer, ClientContext> contexts;
 
/**
* Static collection referencing all valid context in the server.
* It allows to avoid to reply to request from closed context (JORAM-281).
*/
private static Set<CCUID> validCC = Collections.synchronizedSet(new HashSet<CCUID>());
protected static void addValidCC(ClientContext cc) {
validCC.add(new CCUID(cc.getProxyId(), cc.getId()));
}
protected static void removeValidCC(ClientContext cc) {
validCC.remove(new CCUID(cc.getProxyId(), cc.getId()));
}
public static boolean isValidCC(AgentId ua, int ctxid) {
return validCC.contains(new CCUID(ua, ctxid));
}
 
/**
* Table holding the <code>ClientSubscription</code> instances.
* <p>
* <b>Key:</b> subscription name<br>
1154,6 → 1173,7
cc.setProxyId(getId());
cc.setProxyAgent(this);
contexts.put(cc.getId(), cc);
addValidCC(cc);
} catch (Exception exc) {
logger.log(BasicLevel.ERROR,
"ClientContext named [" + persistedClientNames[i] + "] could not be loaded", exc);
1646,6 → 1666,7
activeCtx.setProxyAgent(this);
modifiedClient(activeCtx);
contexts.put(new Integer(key), activeCtx);
addValidCC(activeCtx);
 
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, "Connection " + key + " opened.");
2630,6 → 2651,7
 
// Finally, deleting the context:
ClientContext cc = contexts.remove(new Integer(key));
removeValidCC(cc);
cc.delete();
 
activeCtx = null;
3698,7 → 3720,7
if(logger.isLoggable(BasicLevel.DEBUG)) {
logger.log(BasicLevel.DEBUG,"Contexts:");
for(Integer k : contexts.keySet()) {
logger.log(BasicLevel.DEBUG,k+" : "+contexts.get(k));
logger.log(BasicLevel.DEBUG, k + " : " + contexts.get(k));
}
}