/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
public class ServerNotifForwarder {
this.mbeanServer = mbeanServer;
this.notifBuffer = notifBuffer;
this.connectionId = connectionId;
}
final NotificationFilter filter)
throws InstanceNotFoundException, IOException {
"Add a listener at " + name);
}
checkState();
// Explicitly check MBeanPermission for addNotificationListener
//
if (notificationAccessController != null) {
}
try {
boolean instanceOf =
new PrivilegedExceptionAction<Boolean>() {
}
});
if (!instanceOf) {
throw new IllegalArgumentException("The specified MBean [" +
name + "] is not a " +
"NotificationBroadcaster " +
"object.");
}
} catch (PrivilegedActionException e) {
throw (InstanceNotFoundException) extractException(e);
}
// 6238731: set the default domain if no domain is set.
try {
} catch (MalformedObjectNameException mfoe) {
// impossible, but...
throw ioe;
}
}
synchronized (listenerMap) {
// Tread carefully because if set.size() == 1 it may be the
// Collections.singleton we make here, which is unmodifiable.
else {
}
}
return id;
}
throws Exception {
"Remove some listeners from " + name);
}
checkState();
// Explicitly check MBeanPermission for removeNotificationListener
//
if (notificationAccessController != null) {
}
try {
} catch (Exception e) {
// Give back the first exception
//
re = e;
}
}
}
throw re;
}
}
throws
}
checkState();
" is not registered.");
}
}
synchronized (listenerMap) {
// Tread carefully because if set.size() == 1 it may be a
// Collections.singleton, which is unmodifiable.
throw new ListenerNotFoundException("Listener not found");
else
}
}
/* This is the object that will apply our filtering to candidate
* notifications. First of all, if there are no listeners for the
* ObjectName that the notification is coming from, we go no further.
* Then, for each listener, we must apply the corresponding filter (if any)
* and ignore the listener if the filter rejects. Finally, we apply
* some access checks which may also reject the listener.
*
* A given notification may trigger several listeners on the same MBean,
* which is why listenerMap is a Map<ObjectName, Set<IdAndFilter>> and
* why we add the found notifications to a supplied List rather than
* just returning a boolean.
*/
// We proceed in two stages here, to avoid holding the listenerMap
// lock while invoking the filters (which are user code).
final IdAndFilter[] candidates;
synchronized (listenerMap) {
return;
}
}
// We don't synchronize on targetedNotifs, because it is a local
// variable of our caller and no other thread can see it.
final TargetedNotification tn =
}
}
}
};
long timeout,
int maxNotifications) {
"startSequenceNumber is " + startSequenceNumber +
", the timeout is " + timeout +
", the maxNotifications is " + maxNotifications);
}
try {
t, maxNotifications);
} catch (InterruptedException ire) {
}
}
return nr;
}
// The standard RMI connector client will register a listener on the MBeanServerDelegate
// in order to be told when MBeans are unregistered. We snoop on fetched notifications
// so that we can know too, and remove the corresponding entry from the listenerMap.
// See 6957378.
return;
}
// This is a notification from the MBeanServerDelegate.
if (n instanceof MBeanServerNotification &&
synchronized (listenerMap) {
}
}
}
}
}
}
public void terminate() {
}
synchronized(terminationLock) {
if (terminated) {
return;
}
terminated = true;
synchronized(listenerMap) {
listenerMap.clear();
}
}
}
}
//----------------
// PRIVATE METHODS
//----------------
}
synchronized(terminationLock) {
if (terminated) {
throw new IOException("The connection has been terminated.");
}
}
}
synchronized(listenerCounterLock) {
return listenerCounter++;
}
}
/**
* Explicitly check the MBeanPermission for
* the current access control context.
*/
public final void checkMBeanPermission(
throws InstanceNotFoundException, SecurityException {
}
static void checkMBeanPermission(
throws InstanceNotFoundException, SecurityException {
try {
new PrivilegedExceptionAction<ObjectInstance>() {
public ObjectInstance run()
throws InstanceNotFoundException {
}
});
} catch (PrivilegedActionException e) {
throw (InstanceNotFoundException) extractException(e);
}
null,
name,
actions);
}
}
/**
* Check if the caller has the right to get the following notifications.
*/
try {
if (checkNotificationEmission) {
}
if (notificationAccessController != null) {
}
return true;
} catch (SecurityException e) {
"caller didn't have the required access rights");
}
return false;
} catch (Exception e) {
"got an unexpected exception: " + e);
}
return false;
}
}
/**
* Iterate until we extract the real exception
* from a stack of PrivilegedActionExceptions.
*/
while (e instanceof PrivilegedActionException) {
e = ((PrivilegedActionException)e).getException();
}
return e;
}
private static class IdAndFilter {
}
return this.id;
}
return this.filter;
}
public int hashCode() {
}
return ((o instanceof IdAndFilter) &&
}
}
//------------------
// PRIVATE VARIABLES
//------------------
private final long connectionTimeout;
private boolean terminated = false;
NotificationBroadcaster.class.getName();
private final boolean checkNotificationEmission;
}