jdk/src/java.management/share/classes/sun/management/NotificationEmitterSupport.java
equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
32 import javax.management.NotificationFilter; |
32 import javax.management.NotificationFilter; |
33 import javax.management.NotificationListener; |
33 import javax.management.NotificationListener; |
34 |
34 |
35 import java.util.List; |
35 import java.util.List; |
36 import java.util.ArrayList; |
36 import java.util.ArrayList; |
37 import java.util.ListIterator; |
|
38 import java.util.Collections; |
37 import java.util.Collections; |
39 |
38 |
40 /** |
39 /** |
41 * Abstract helper class for notification emitter support. |
40 * Abstract helper class for notification emitter support. |
42 */ |
41 */ |
43 abstract class NotificationEmitterSupport implements NotificationEmitter { |
42 public abstract class NotificationEmitterSupport implements NotificationEmitter { |
44 |
43 |
45 protected NotificationEmitterSupport() { |
44 protected NotificationEmitterSupport() { |
46 } |
45 } |
47 |
46 |
48 private Object listenerLock = new Object(); |
47 private Object listenerLock = new Object(); |
133 } else { |
132 } else { |
134 throw new ListenerNotFoundException("Listener not registered"); |
133 throw new ListenerNotFoundException("Listener not registered"); |
135 } |
134 } |
136 } |
135 } |
137 |
136 |
138 void sendNotification(Notification notification) { |
137 public void sendNotification(Notification notification) { |
139 |
138 |
140 if (notification == null) { |
139 if (notification == null) { |
141 return; |
140 return; |
142 } |
141 } |
143 |
142 |
160 } |
159 } |
161 } |
160 } |
162 } |
161 } |
163 } |
162 } |
164 |
163 |
165 boolean hasListeners() { |
164 public boolean hasListeners() { |
166 synchronized (listenerLock) { |
165 synchronized (listenerLock) { |
167 return !listenerList.isEmpty(); |
166 return !listenerList.isEmpty(); |
168 } |
167 } |
169 } |
168 } |
170 |
169 |