Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
joram
joram
Commits
103dd915
Commit
103dd915
authored
Nov 13, 2017
by
afreyssin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug fix: Adds a static collection referencing all valid client context in the server (JORAM-281).
parent
87541ec5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
4 deletions
+63
-4
joram/joram/mom/core/src/main/java/org/objectweb/joram/mom/proxies/ClientContext.java
...n/java/org/objectweb/joram/mom/proxies/ClientContext.java
+39
-2
joram/joram/mom/core/src/main/java/org/objectweb/joram/mom/proxies/UserAgent.java
.../main/java/org/objectweb/joram/mom/proxies/UserAgent.java
+24
-2
No files found.
joram/joram/mom/core/src/main/java/org/objectweb/joram/mom/proxies/ClientContext.java
View file @
103dd915
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2003 - 201
2
ScalAgent Distributed Technologies
* Copyright (C) 2003 - 201
7
ScalAgent Distributed Technologies
* Copyright (C) 2004 France Telecom R&D
* Copyright (C) 2003 - 2004 Bull SA
*
...
...
@@ -507,5 +507,42 @@ public class ClientContext implements java.io.Serializable, Encodable {
}
}
}
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
;
}
}
joram/joram/mom/core/src/main/java/org/objectweb/joram/mom/proxies/UserAgent.java
View file @
103dd915
...
...
@@ -34,8 +34,10 @@ import java.io.Serializable;
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 @@ import fr.dyade.aaa.util.management.MXWrapper;
* destinations replies to clients.
*/
public
final
class
UserAgent
extends
Agent
implements
UserAgentMBean
,
ProxyAgentItf
{
/** define serialVersionUID for interoperability */
private
static
final
long
serialVersionUID
=
1L
;
...
...
@@ -343,6 +344,24 @@ public final class UserAgent extends Agent implements UserAgentMBean, ProxyAgent
*/
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>
...
...
@@ -1154,6 +1173,7 @@ public final class UserAgent extends Agent implements UserAgentMBean, ProxyAgent
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 @@ public final class UserAgent extends Agent implements UserAgentMBean, ProxyAgent
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 @@ public final class UserAgent extends Agent implements UserAgentMBean, ProxyAgent
// Finally, deleting the context:
ClientContext
cc
=
contexts
.
remove
(
new
Integer
(
key
));
removeValidCC
(
cc
);
cc
.
delete
();
activeCtx
=
null
;
...
...
@@ -3698,7 +3720,7 @@ public final class UserAgent extends Agent implements UserAgentMBean, ProxyAgent
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
));
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment