1 /*
2  * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * This code is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 only, as
7  * published by the Free Software Foundation.  Oracle designates this
8  * particular file as subject to the "Classpath" exception as provided
9  * by Oracle in the LICENSE file that accompanied this code.
10  *
11  * This code is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14  * version 2 for more details (a copy is included in the LICENSE file that
15  * accompanied this code).
16  *
17  * You should have received a copy of the GNU General Public License version
18  * 2 along with this work; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22  * or visit www.oracle.com if you need additional information or have any
23  * questions.
24  */
25 
26 package com.sun.jmx.remote.internal;
27 
28 import javax.management.NotificationFilter;
29 import javax.management.NotificationListener;
30 import javax.management.ObjectName;
31 
32 import javax.security.auth.Subject;
33 
34 
35 /**
36  * <p>An identified listener.  A listener has an Integer id that is
37  * unique per connector server.  It selects notifications based on the
38  * ObjectName of the originator and an optional
39  * NotificationFilter.</p>
40  */
41 public class ClientListenerInfo {
ClientListenerInfo(Integer listenerID, ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback, Subject delegationSubject)42     public ClientListenerInfo(Integer listenerID,
43                               ObjectName name,
44                               NotificationListener listener,
45                               NotificationFilter filter,
46                               Object handback,
47                               Subject delegationSubject) {
48         this.listenerID = listenerID;
49         this.name = name;
50         this.listener = listener;
51         this.filter = filter;
52         this.handback = handback;
53         this.delegationSubject = delegationSubject;
54     }
55 
getObjectName()56     public ObjectName getObjectName() {
57         return name;
58     }
59 
getListenerID()60     public Integer getListenerID() {
61         return listenerID;
62     }
63 
getNotificationFilter()64     public NotificationFilter getNotificationFilter() {
65         return filter;
66     }
67 
getListener()68     public NotificationListener getListener() {
69         return listener;
70     }
71 
getHandback()72     public Object getHandback() {
73         return handback;
74     }
75 
getDelegationSubject()76     public Subject getDelegationSubject() {
77         return delegationSubject;
78     }
79 
80 
sameAs(ObjectName name)81     public boolean sameAs(ObjectName name) {
82         return (getObjectName().equals(name));
83     }
84 
85 
sameAs(ObjectName name, NotificationListener listener)86     public boolean sameAs(ObjectName name, NotificationListener listener) {
87         return ( getObjectName().equals(name) &&
88                  getListener() == listener);
89     }
90 
91 
sameAs(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback)92     public boolean sameAs(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) {
93         return ( getObjectName().equals(name) &&
94                  getListener() == listener &&
95                  getNotificationFilter() == filter &&
96                  getHandback() == handback);
97     }
98 
99     private final ObjectName name;
100     private final Integer listenerID;
101     private final NotificationFilter filter;
102 
103     private final NotificationListener listener;
104     private final Object handback;
105     private final Subject delegationSubject;
106 }
107