jdk/src/share/classes/javax/management/remote/rmi/RMIConnector.java
changeset 19791 d0bcc2086175
parent 18206 136373d8d805
child 20851 9f284cf7836b
equal deleted inserted replaced
19790:d97d46e9bddf 19791:d0bcc2086175
   403                 logger.trace("getMBeanServerConnection","[" + this.toString() +
   403                 logger.trace("getMBeanServerConnection","[" + this.toString() +
   404                         "] is not connected.");
   404                         "] is not connected.");
   405             throw new IOException("Not connected");
   405             throw new IOException("Not connected");
   406         }
   406         }
   407 
   407 
   408         MBeanServerConnection rmbsc = rmbscMap.get(delegationSubject);
   408         return getConnectionWithSubject(delegationSubject);
   409         if (rmbsc != null) {
       
   410             return rmbsc;
       
   411         }
       
   412 
       
   413         rmbsc = new RemoteMBeanServerConnection(delegationSubject);
       
   414         rmbscMap.put(delegationSubject, rmbsc);
       
   415         return rmbsc;
       
   416     }
   409     }
   417 
   410 
   418     public void
   411     public void
   419             addConnectionNotificationListener(NotificationListener listener,
   412             addConnectionNotificationListener(NotificationListener listener,
   420             NotificationFilter filter,
   413             NotificationFilter filter,
  1829         s.defaultWriteObject();
  1822         s.defaultWriteObject();
  1830     }
  1823     }
  1831 
  1824 
  1832     // Initialization of transient variables.
  1825     // Initialization of transient variables.
  1833     private void initTransients() {
  1826     private void initTransients() {
  1834         rmbscMap = new WeakHashMap<Subject, MBeanServerConnection>();
  1827         rmbscMap = new WeakHashMap<Subject, WeakReference<MBeanServerConnection>>();
  1835         connected = false;
  1828         connected = false;
  1836         terminated = false;
  1829         terminated = false;
  1837 
  1830 
  1838         connectionBroadcaster = new NotificationBroadcasterSupport();
  1831         connectionBroadcaster = new NotificationBroadcasterSupport();
  1839     }
  1832     }
  2007             ReflectUtil.checkPackageAccess(name);
  2000             ReflectUtil.checkPackageAccess(name);
  2008             return Class.forName(name, false, loader);
  2001             return Class.forName(name, false, loader);
  2009         }
  2002         }
  2010 
  2003 
  2011         private final ClassLoader loader;
  2004         private final ClassLoader loader;
       
  2005     }
       
  2006 
       
  2007     private MBeanServerConnection getConnectionWithSubject(Subject delegationSubject) {
       
  2008         MBeanServerConnection conn = null;
       
  2009 
       
  2010         if (delegationSubject == null) {
       
  2011             if (nullSubjectConnRef == null
       
  2012                     || (conn = nullSubjectConnRef.get()) == null) {
       
  2013                 conn = new RemoteMBeanServerConnection(null);
       
  2014                 nullSubjectConnRef = new WeakReference(conn);
       
  2015             }
       
  2016         } else {
       
  2017             WeakReference<MBeanServerConnection> wr = rmbscMap.get(delegationSubject);
       
  2018             if (wr == null || (conn = wr.get()) == null) {
       
  2019                 conn = new RemoteMBeanServerConnection(delegationSubject);
       
  2020                 rmbscMap.put(delegationSubject, new WeakReference(conn));
       
  2021             }
       
  2022         }
       
  2023         return conn;
  2012     }
  2024     }
  2013 
  2025 
  2014     /*
  2026     /*
  2015        The following section of code avoids a class loading problem
  2027        The following section of code avoids a class loading problem
  2016        with RMI.  The problem is that an RMI stub, when deserializing
  2028        with RMI.  The problem is that an RMI stub, when deserializing
  2549     private transient RMIConnection connection;
  2561     private transient RMIConnection connection;
  2550     private transient String connectionId;
  2562     private transient String connectionId;
  2551 
  2563 
  2552     private transient long clientNotifSeqNo = 0;
  2564     private transient long clientNotifSeqNo = 0;
  2553 
  2565 
  2554     private transient WeakHashMap<Subject, MBeanServerConnection> rmbscMap;
  2566     private transient WeakHashMap<Subject, WeakReference<MBeanServerConnection>> rmbscMap;
       
  2567     private transient WeakReference<MBeanServerConnection> nullSubjectConnRef = null;
  2555 
  2568 
  2556     private transient RMINotifClient rmiNotifClient;
  2569     private transient RMINotifClient rmiNotifClient;
  2557     // = new RMINotifClient(new Integer(0));
  2570     // = new RMINotifClient(new Integer(0));
  2558 
  2571 
  2559     private transient long clientNotifCounter = 0;
  2572     private transient long clientNotifCounter = 0;