mx4j/src/core/mx4j/remote/rmi RMIRemoteNotificationClientHandler.java,1.3,1.4
Simone Bordet <[email protected]> Sun, 12 Jun 2005 22:34:32 +0000
| Newsgroups | gmane.comp.java.mx4j.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/mx4j/mx4j/src/core/mx4j/remote/rmi
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18325/src/core/mx4j/remote/rmi
Modified Files:
RMIRemoteNotificationClientHandler.java
Log Message:
Fixed bug #1219367: the RMIConnector was not passing the default loader to the client notification handler, making impossible to unmarshal custom notifications known only to server side.
Index: RMIRemoteNotificationClientHandler.java
===================================================================
RCS file: /cvsroot/mx4j/mx4j/src/core/mx4j/remote/rmi/RMIRemoteNotificationClientHandler.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** RMIRemoteNotificationClientHandler.java 13 Nov 2004 16:38:35 -0000 1.3
--- RMIRemoteNotificationClientHandler.java 12 Jun 2005 22:34:30 -0000 1.4
***************
*** 10,14 ****
--- 10,17 ----
import java.io.IOException;
+ import java.security.AccessController;
+ import java.security.PrivilegedAction;
import java.util.Map;
+
import javax.management.remote.NotificationResult;
import javax.management.remote.rmi.RMIConnection;
***************
*** 26,39 ****
{
private final RMIConnection connection;
! public RMIRemoteNotificationClientHandler(RMIConnection connection, ConnectionNotificationEmitter emitter, HeartBeat heartbeat, Map environment)
{
super(emitter, heartbeat, environment);
this.connection = connection;
}
protected NotificationResult fetchNotifications(long sequence, int maxNumber, long timeout) throws IOException
{
return connection.fetchNotifications(sequence, maxNumber, timeout);
}
}
--- 29,77 ----
{
private final RMIConnection connection;
+ private final ClassLoader defaultLoader;
! public RMIRemoteNotificationClientHandler(RMIConnection connection, ClassLoader defaultLoader, ConnectionNotificationEmitter emitter, HeartBeat heartbeat, Map environment)
{
super(emitter, heartbeat, environment);
this.connection = connection;
+ this.defaultLoader = defaultLoader;
}
protected NotificationResult fetchNotifications(long sequence, int maxNumber, long timeout) throws IOException
{
+ ClassLoader currentLoader = Thread.currentThread().getContextClassLoader();
+ if (defaultLoader == null || defaultLoader.equals(currentLoader))
+ {
+ return invokeFetchNotifications(sequence, maxNumber, timeout);
+ }
+ else
+ {
+ try
+ {
+ setContextClassLoader(defaultLoader);
+ return invokeFetchNotifications(sequence, maxNumber, timeout);
+ }
+ finally
+ {
+ setContextClassLoader(currentLoader);
+ }
+ }
+ }
+
+ private NotificationResult invokeFetchNotifications(long sequence, int maxNumber, long timeout) throws IOException
+ {
return connection.fetchNotifications(sequence, maxNumber, timeout);
}
+
+ private void setContextClassLoader(final ClassLoader loader)
+ {
+ AccessController.doPrivileged(new PrivilegedAction()
+ {
+ public Object run()
+ {
+ Thread.currentThread().setContextClassLoader(loader);
+ return null;
+ }
+ });
+ }
}
-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games. How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20