1. /*
  2. * @(#)ListenerInfo.java 1.4 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.jmx.remote.internal;
  8. import javax.management.NotificationFilter;
  9. import javax.management.NotificationListener;
  10. import javax.management.ObjectName;
  11. import javax.security.auth.Subject;
  12. /**
  13. * <p>An identified listener. A listener has an Integer id that is
  14. * unique per connector server. It selects notifications based on the
  15. * ObjectName of the originator and an optional
  16. * NotificationFilter.</p>
  17. *
  18. * <p>Two ListenerInfo objects are considered equal if and only if
  19. * they have the same listenerId. This means that ListenerInfo
  20. * objects can be stored in a Set or Map and retrieved using another
  21. * ListenerInfo with the same listenerId but arbitrary ObjectNme and
  22. * NotificationFilter values.</p>
  23. */
  24. public class ListenerInfo {
  25. public ListenerInfo(Integer listenerID,
  26. ObjectName name,
  27. NotificationFilter filter) {
  28. this.listenerID = listenerID;
  29. this.name = name;
  30. this.filter = filter;
  31. }
  32. public ListenerInfo(Integer listenerID,
  33. ObjectName name,
  34. NotificationListener listener,
  35. NotificationFilter filter,
  36. Object handback,
  37. Subject delegationSubject) {
  38. this.listenerID = listenerID;
  39. this.name = name;
  40. this.listener = listener;
  41. this.filter = filter;
  42. this.handback = handback;
  43. this.delegationSubject = delegationSubject;
  44. }
  45. public boolean equals(Object o) {
  46. if (!(o instanceof ListenerInfo)) {
  47. return false;
  48. }
  49. return listenerID.equals(((ListenerInfo)o).listenerID);
  50. }
  51. public int hashCode() {
  52. return listenerID.intValue();
  53. }
  54. public ObjectName getObjectName() {
  55. return name;
  56. }
  57. public Integer getListenerID() {
  58. return listenerID;
  59. }
  60. public NotificationFilter getNotificationFilter() {
  61. return filter;
  62. }
  63. public NotificationListener getListener() {
  64. return listener;
  65. }
  66. public Object getHandback() {
  67. return handback;
  68. }
  69. public Subject getDelegationSubject() {
  70. return delegationSubject;
  71. }
  72. private ObjectName name;
  73. private Integer listenerID;
  74. private NotificationFilter filter;
  75. private NotificationListener listener = null;
  76. private Object handback = null;
  77. private Subject delegationSubject = null;
  78. }