/** * Returns a new or existing InvitationsMonitor for a given connection. * * @param conn the connection to monitor for room invitations. * @return a new or existing InvitationsMonitor for a given connection. */ public static InvitationsMonitor getInvitationsMonitor(Connection conn) { synchronized (monitors) { if (!monitors.containsKey(conn)) { // We need to use a WeakReference because the monitor references the // connection and this could prevent the GC from collecting the monitor // when no other object references the monitor monitors.put(conn, new WeakReference<InvitationsMonitor>(new InvitationsMonitor(conn))); } // Return the InvitationsMonitor that monitors the connection return monitors.get(conn).get(); } }
/** * Returns a new or existing InvitationsMonitor for a given connection. * * @param conn the connection to monitor for room invitations. * @return a new or existing InvitationsMonitor for a given connection. */ public static InvitationsMonitor getInvitationsMonitor(Connection conn) { synchronized (monitors) { if (!monitors.containsKey(conn)) { // We need to use a WeakReference because the monitor references the // connection and this could prevent the GC from collecting the monitor // when no other object references the monitor monitors.put(conn, new WeakReference<InvitationsMonitor>(new InvitationsMonitor(conn))); } // Return the InvitationsMonitor that monitors the connection return monitors.get(conn).get(); } }
/** * Returns a new or existing InvitationsMonitor for a given connection. * * @param conn the connection to monitor for room invitations. * @return a new or existing InvitationsMonitor for a given connection. */ public static InvitationsMonitor getInvitationsMonitor(Connection conn) { synchronized (monitors) { if (!monitors.containsKey(conn)) { // We need to use a WeakReference because the monitor references the // connection and this could prevent the GC from collecting the monitor // when no other object references the monitor monitors.put(conn, new WeakReference<InvitationsMonitor>(new InvitationsMonitor(conn))); } // Return the InvitationsMonitor that monitors the connection return monitors.get(conn).get(); } }
/** * Returns a new or existing InvitationsMonitor for a given connection. * * @param conn the connection to monitor for room invitations. * @return a new or existing InvitationsMonitor for a given connection. */ public static InvitationsMonitor getInvitationsMonitor(XMPPConnection conn) { synchronized (monitors) { if (!monitors.containsKey(conn)) { // We need to use a WeakReference because the monitor references the // connection and this could prevent the GC from collecting the monitor // when no other object references the monitor monitors.put(conn, new WeakReference(new InvitationsMonitor(conn))); } // Return the InvitationsMonitor that monitors the connection return (InvitationsMonitor) ((WeakReference) monitors.get(conn)).get(); } }