diff options
| author | doko <doko@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-06-28 13:29:13 +0000 |
|---|---|---|
| committer | doko <doko@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-06-28 13:29:13 +0000 |
| commit | 1020ce5944edde4364baef4d371cd4f9b0dae721 (patch) | |
| tree | 602cd7aa7c947386134690d8e0f6b53abcdeacb9 /libjava/classpath/javax/management | |
| parent | 9f41ce98ce6f4f7c8ac5e2c4b6e5d27e10201015 (diff) | |
| download | ppe42-gcc-1020ce5944edde4364baef4d371cd4f9b0dae721.tar.gz ppe42-gcc-1020ce5944edde4364baef4d371cd4f9b0dae721.zip | |
libjava/
2008-06-28 Matthias Klose <doko@ubuntu.com>
Import GNU Classpath (classpath-0_97_2-release).
* Regenerate class and header files.
* Regenerate auto* files.
* gcj/javaprims.h: Define jobjectRefType.
* jni.cc (_Jv_JNI_GetObjectRefType): New (stub only).
(_Jv_JNIFunctions): Initialize GetObjectRefType.
* gnu/classpath/jdwp/VMVirtualMachine.java,
java/security/VMSecureRandom.java: Merge from classpath.
* HACKING: Fix typo.
* ChangeLog-2007: New file.
* configure.ac: Set JAVAC, pass --disable-regen-headers to classpath.
libjava/classpath/
2008-06-28 Matthias Klose <doko@ubuntu.com>
* m4/ac_prog_javac.m4: Disable check for JAVAC, when
not configured with --enable-java-maintainer-mode.
* aclocal.m4, configure: Regenerate.
* native/jni/gstreamer-peer/Makefile.am: Do not link with
libclasspathnative.
* native/jni/gstreamer-peer/Makefile.in: Regenerate.
* tools/Makefile.am, lib/Makefile.am: Use JAVAC for setting
JCOMPILER, drop flags not understood by gcj.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@137223 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/javax/management')
11 files changed, 1789 insertions, 8 deletions
diff --git a/libjava/classpath/javax/management/MBeanPermission.java b/libjava/classpath/javax/management/MBeanPermission.java index 2c8dfbd622d..1ee0e710433 100644 --- a/libjava/classpath/javax/management/MBeanPermission.java +++ b/libjava/classpath/javax/management/MBeanPermission.java @@ -224,7 +224,7 @@ public class MBeanPermission * or either <code>null</code> or <code>"-"</code> for a * value which may be implied by any member, but not * imply any member itself. - * @param objectName the {@link ObjectName} to which this permission applies, + * @param name the {@link ObjectName} to which this permission applies, * or <code>null</code> for a value which may be implied by * any object name, but not imply any object name itself. * @param actions the actions associated with this permission. diff --git a/libjava/classpath/javax/management/NotificationBroadcasterSupport.java b/libjava/classpath/javax/management/NotificationBroadcasterSupport.java index 59d9ec28e16..7eba6eccf25 100644 --- a/libjava/classpath/javax/management/NotificationBroadcasterSupport.java +++ b/libjava/classpath/javax/management/NotificationBroadcasterSupport.java @@ -105,7 +105,7 @@ public class NotificationBroadcasterSupport */ public NotificationBroadcasterSupport() { - this(null, null); + this(null, (MBeanNotificationInfo[]) null); } /** @@ -124,7 +124,7 @@ public class NotificationBroadcasterSupport */ public NotificationBroadcasterSupport(Executor executor) { - this(executor, null); + this(executor, (MBeanNotificationInfo) null); } /** diff --git a/libjava/classpath/javax/management/ObjectName.java b/libjava/classpath/javax/management/ObjectName.java index 4ea21cdc7ae..1fb51506f04 100644 --- a/libjava/classpath/javax/management/ObjectName.java +++ b/libjava/classpath/javax/management/ObjectName.java @@ -39,7 +39,6 @@ package javax.management; import java.io.Serializable; -import java.util.Collections; import java.util.Hashtable; import java.util.Iterator; import java.util.Map; diff --git a/libjava/classpath/javax/management/StandardMBean.java b/libjava/classpath/javax/management/StandardMBean.java index 37483845376..bd59c68ae22 100644 --- a/libjava/classpath/javax/management/StandardMBean.java +++ b/libjava/classpath/javax/management/StandardMBean.java @@ -228,13 +228,13 @@ public class StandardMBean Method getter; try { - getter = iface.getMethod("get" + name, null); + getter = iface.getMethod("get" + name); } catch (NoSuchMethodException e) { try { - getter = iface.getMethod("is" + name, null); + getter = iface.getMethod("is" + name); } catch (NoSuchMethodException ex) { @@ -246,7 +246,7 @@ public class StandardMBean Object result; try { - result = getter.invoke(impl, null); + result = getter.invoke(impl); } catch (IllegalAccessException e) { diff --git a/libjava/classpath/javax/management/openmbean/ArrayType.java b/libjava/classpath/javax/management/openmbean/ArrayType.java index 42f80623d9a..e6cf5261aaa 100644 --- a/libjava/classpath/javax/management/openmbean/ArrayType.java +++ b/libjava/classpath/javax/management/openmbean/ArrayType.java @@ -39,7 +39,6 @@ package javax.management.openmbean; import java.lang.reflect.Array; -import java.util.Arrays; import java.util.HashMap; import java.util.Map; diff --git a/libjava/classpath/javax/management/package.html b/libjava/classpath/javax/management/package.html new file mode 100644 index 00000000000..3543eec908c --- /dev/null +++ b/libjava/classpath/javax/management/package.html @@ -0,0 +1,197 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<!-- package.html - describes classes in javax.management package. + Copyright (C) 2007 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath 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 for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. --> + +<html> +<head><title>GNU Classpath - javax.management</title></head> + +<body> + +<p> +Provides the core classes for the Java Management Extensions (JMX). This API +builds on the notion of Java beans by providing a layer of abstraction between +the beans themselves and the method of accessing them. Instead of being accessed +directly, management beans or <strong>MBeans</strong> are usually accessed via +a management server (an implementation of the @see MBeanServer interface). Thus, +the bean itself may be a simple Java object or it may be something +more complicated (for example, the server may map from Java to SNMP). The server may +also retrieve the bean from some remote location rather than using a local object. +</p> +<p> +Management beans are usually used for monitoring and/or configuration +of a particular entity. For example, the platform management beans +found in the @see java.lang.management package allow the user +to obtain information about the operating system, current memory usage, etc. +as well as turning on and off certain additional facilities. To this end, +an MBean consists of: +</p> +<ul> +<li><emph>attributes</emph> that may be read and/or written to.</li> +<li><emph>operations</emph> which may be performed.</li> +<li><emph>notifications</emph> that may emitted by the bean and listened for by users.</li> +</ul> +<p> +The most common type of management bean is the @see StandardMBean, A standard MBean +relies on the naming patterns established by the JavaBeans framework; the value of an +attribute <code>name</code> is retrieved by an accessor method named <code>getName</code> +and changed by a mutator method called <code>setName</code>. If the mutator is absent, +the attribute is read only. Naming is also used to associate the implementation of a +bean with its interface; an bean <code>Person</code> is assumed to be an implementation +of the interface <code>PersonMBean</code> (and vice versa). To avoid these naming constraints, +the @see StandardMBean class may be used. +</p> +<p> +<h2>Types of Beans</h2> +<p> +The @see StandardMBean class is one example of a @see DynamicMBean where the attributes and +operations of the bean are provided dynamically via the methods provided. With the +@see StandardMBean class, this simply means that the class uses reflection to access the +appropriate methods of the bean implementation. In a more complex scenario, the bean's +data could be supplied from a file or over the network. +</p> +<p> +Once we start talking about accessing beans over network and platform boundaries, we run +in to the issue of how to deal with the types utilised by these beans. Simple types, such +as numbers and strings, are usually fine but more complex types need special treatment. +An <emph>Open MBean</emph> is one that only uses a specific set of types defined in the +@see javax.management.openmbean package, allowing both sides of a remote connection to provide +this subset of types and thus interact. An @see MXBean goes a stage further, and defines +a method whereby a normal Java MBean may become an Open MBean by performing a defined mapping +on the types of the bean. For example, a @see java.util.List or @see java.util.Set of a +particular type becomes an array of the same type. +</p> +<h2>Accessing Beans</h2> +<p> +Although beans can be accessed like normal objects, the normal way of accessing them is +via an @see MBeanServer. This provides the abstraction from the bean's implementation to +a set of attributes, operations and notifications. The server identifies each bean via +an @see ObjectName. This name is unique to a particular bean and is used to identify the +bean when retrieving the value of an attribute or invoking an operation. Essentially, most +methods provided by the server are the same as those provided by the @see DynamicMBean +interface, except that each takes this additional @link ObjectName parameter to identify the +bean being accessed. +</p> +<p> +The @see MBeanServerFactory keeps track of the current MBean servers in use and allows new +ones to be created. A special @see MBeanServer instance, called the <emph>platform MBean +server</emph>, is created when the Java virtual machine is started and a reference to this +may be obtained from the @see ManagementFactory using +@see ManagementFactory#getPlatformMBeanServer(). This primarily exists for the purpose of +creating and registering the platform MBeans, described in @see java.lang.management, which +provide access to information about the underlying operating system, memory usage, the behaviour +of the garbage collector, etc. but is equally suitable for creating and registering your own +beans. Alternatively, a server instance may be obtained from the @see MBeanServerFactory. +</p> +<p> +A bean obtains an @link ObjectName by registering with the server. This operation can be +performed either by passing an existing instance to the @see MBeanServer#registerMBean method +or by using the @see MBeanServer#createMBean method to simultaneously create the bean and +register it with the server. During the registration process, the bean may perform some +arbitrary behaviour if it implements the @link MBeanRegistration interface. The same is +true when unregistering a bean. +</p> +<p> +To actually access the attributes and operations of a bean via the server, we use code +like the following: +</p> +<pre> +// First we obtain the platform MBean server which has the platform MBeans registered +MBeanServer server = ManagementFactory.getPlatformMBeanServer(); +// We also need the object name of the memory bean so we can address it +ObjectName name = new ObjectName(ManagementFactory.MEMORY_MXBEAN_NAME); +// Next we obtain the value of the 'verbose' attribute +// What actually happens here is that the server invokes the 'isVerbose' method of +// the MemoryMXBean +boolean verbose = server.getAttribute(name, "verbose"); +// We can also set the value of verbose. Again the server is actually performing +// a setVerbose(val) on the bean but we don't need to know this. +Attribute attrib = new Attribute("verbose", true); +server.setAttribute(name, attrib); +// We can also invoke the 'gc' operation which calls the garbage collector. +server.invoke(name, "gc", new Object[]{}, new String[]{}); +</pre> +<p> +As noted above, the server is simply making basic method calls on the object using +reflection. However, the server provides a layer of abstraction which means that something +more complicated could actually be going on. The lines above are equally applicable, for +example, if <code>server</code> is instead an @see MBeanServerConnection connecting us +to a distant computer. +</p> +<p> +This rather hideous code can be simplified back into simple method calls on an object, +so that we get the best of both worlds. This is achieved using a <emph>MBean proxy</emph>: +<pre> +MBeanServer server = ManagementFactory.getPlatformMBeanServer(); +ObjectName name = new ObjectName(ManagementFactory.MEMORY_MXBEAN_NAME); +MemoryMXBean bean = JMX.newMBeanProxy(server, name, MemoryMXBean.class); +boolean verbose = bean.isVerbose(); +bean.setVerbose(true); +bean.gc(); +</pre> +<p> +See how much simpler the operations are? The proxy handles the task of translating the method +calls into appropriate invocations of methods on the server, simplifying the code for the user. +</p> +<p> +Finally, we have assumed in the code above that the @see ObjectName of the bean is known. +If this is not the case, then the server's database can be searched. The @see Query class +provides appropriate operators (e.g. boolean (and,or), value comparison (>, <)) for +building up relatively complex queries. Once constructed, a query may be passed to either +the @see MBeanServer#queryNames or @see MBeanServer#queryMBeans to obtain an appropriate +set of @see ObjectName or MBean instances. +</p> +<h2>Notifications</h2> +<p> +MBeans also have the capability to emit events. Beans which do so implement either the +@see NotificationBroadcaster or @see NotificationEmitter interface (the difference between +the two is simply the existence of a better removal method in the newer +@see NotificationEmitter interface, which otherwise extends @see NotificationBroadcaster), +usually by extending the @see NotificationBroadcasterSupport class. As is usual with event +handling, other classes may <emph>signup</emph> to receive events via the +@see NotificationListener interface. The signup process can include registering a filter +(an implementation of @see NotificationFilter) so that only certain events reach the +listener and others are discarded. +</p> +<h2>Remote Access</h2> +<p> +The subpackage @see javax.management.remote provides facilities to access remote MBean +servers. This consists of a <emph>connector</emph> framework which abstracts the method +of accessing remote servers from the actual implementation, so that the same method is +used to connect to a remote server, regardless of how it is accessed. +</p> +</body> +</html> diff --git a/libjava/classpath/javax/management/remote/NotificationResult.java b/libjava/classpath/javax/management/remote/NotificationResult.java new file mode 100644 index 00000000000..c0b2d9ba1a6 --- /dev/null +++ b/libjava/classpath/javax/management/remote/NotificationResult.java @@ -0,0 +1,166 @@ +/* NotificationResult.java -- Wrapper for a series of buffered notifications. + Copyright (C) 2008 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath 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 for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package javax.management.remote; + +import java.io.Serializable; + +/** + * <p> + * Wraps the result of a query for buffered notifications. In a remote + * scenario, it may be more practical for the server to buffer individual + * notifications from its beans and then return them in bulk on request. + * This class contains the notifications returned by such a request. + * </p> + * <p> + * It consists of a series of {@link Notification} and identifier pairs, + * wrapped in a {@link TargetedNotification} object. The identifiers + * serve to pair up the notification with the listener that requested + * it. Two positive numbers are also included: the first sequence number + * used by the returned notifications, and the sequence number of the + * notification which will be returned by the next query. The first + * sequence number may be greater than the next sequence number if some + * notifications have been lost. + * </p> + * + * @author Andrew John Hughes (gnu_andrew@member.fsf.org) + * @since 1.5 + */ +public class NotificationResult + implements Serializable +{ + + /** + * Compatible with JDK 1.6 + */ + private static final long serialVersionUID = 1191800228721395279L; + + /** + * The sequence number of the first notification. + */ + private long earliestSequenceNumber; + + /** + * The sequence number of the next notification to be + * returned by a future query. + */ + private long nextSequenceNumber; + + /** + * The pairs of notifications and identifiers returned + * by the query. + */ + private TargetedNotification[] targetedNotifications; + + /** + * Constructs a new {@link NotificationResult} using the specified + * sequence numbers and the supplied array of notification pairs. + * + * @param startSeqNumber the sequence number of the first notification + * being returned. + * @param nextSeqNumber the sequence numbr of the next notification + * that will be returned from a future query. + * @param notifications the notification and identifier pairs. This + * may be empty. + * @throws IllegalArgumentException if a sequence number is negative + * or <code>notifications</code> is + * <code>null</code>. + */ + public NotificationResult(long startSeqNumber, long nextSeqNumber, + TargetedNotification[] notifications) + { + if (startSeqNumber < 0) + throw new IllegalArgumentException("Starting sequence number is " + + "less than 0."); + if (nextSeqNumber < 0) + throw new IllegalArgumentException("Next sequence number is " + + "less than 0."); + if (notifications == null) + throw new IllegalArgumentException("The array of notifications is null."); + earliestSequenceNumber = startSeqNumber; + nextSequenceNumber = nextSeqNumber; + targetedNotifications = notifications; + } + + /** + * Returns the sequence number of the earliest notification + * in the buffer. + * + * @return the sequence number of the earliest notification. + */ + public long getEarliestSequenceNumber() + { + return earliestSequenceNumber; + } + + /** + * Returns the sequence number of the next notification to + * be returned by a future query. + * + * @return the sequence number of the next notification. + */ + public long getNextSequenceNumber() + { + return nextSequenceNumber; + } + + /** + * Returns the notification and identifier pairs returned + * by the query. + * + * @return the notification and identifier pairs. + */ + public TargetedNotification[] getTargetedNotifications() + { + return targetedNotifications; + } + + /** + * Returns a textual representation of the object. + * + * @return a textual representation. + */ + public String toString() + { + return getClass().getName() + + "[earliestSequenceNumber=" + earliestSequenceNumber + + ",nextSequenceNumber=" + nextSequenceNumber + + ",targetedNotifications=" + targetedNotifications + + "]"; + } + +} diff --git a/libjava/classpath/javax/management/remote/TargetedNotification.java b/libjava/classpath/javax/management/remote/TargetedNotification.java new file mode 100644 index 00000000000..c383c9184c0 --- /dev/null +++ b/libjava/classpath/javax/management/remote/TargetedNotification.java @@ -0,0 +1,127 @@ +/* TargetedNotificaton.java -- Wrapper for a notification and identifier pair. + Copyright (C) 2008 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath 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 for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package javax.management.remote; + +import java.io.Serializable; + +import javax.management.Notification; + +/** + * Wraps a notification with an identifier that specifies + * the listener which received it. + * + * @author Andrew John Hughes (gnu_andrew@member.fsf.org) + * @since 1.5 + */ +public class TargetedNotification + implements Serializable +{ + + /** + * Compatible with JDK 1.6 + */ + private static final long serialVersionUID = 7676132089779300926L; + + /** + * The notification that was recieved by the listener. + */ + private Notification notif; + + /** + * The identifier for the listener that received the notification; + */ + private Integer id; + + /** + * Constructs a new {@link TargetedNotification} which connects + * the supplied notification with the specified identifier. The + * identifier matches one of those returned by a previous call + * to add a new notification listener. + * + * @param notif the notification. + * @param id the identifier of the listener that received the + * notification. + * @throws IllegalArgumentException if either argument is + * <code>null</code>. + */ + public TargetedNotification(Notification notif, Integer id) + { + if (notif == null) + throw new IllegalArgumentException("The notification is null."); + if (id == null) + throw new IllegalArgumentException("The identifier is null."); + this.notif = notif; + this.id = id; + } + + /** + * Returns the notification. + * + * @return the notification. + */ + public Notification getNotification() + { + return notif; + } + + /** + * Returns the identifier for the listener + * which received the notification. + * + * @return the identifier. + */ + public Integer getListenerID() + { + return id; + } + + /** + * Returns a textual representation of the object. + * + * @return a textual representation. + */ + public String toString() + { + return getClass().getName() + + "[notif=" + notif + + ",id=" + id + + "]"; + } + +} + diff --git a/libjava/classpath/javax/management/remote/package.html b/libjava/classpath/javax/management/remote/package.html new file mode 100644 index 00000000000..f1d469f3ab1 --- /dev/null +++ b/libjava/classpath/javax/management/remote/package.html @@ -0,0 +1,53 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<!-- package.html - describes classes in javax.management.remote package. + Copyright (C) 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath 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 for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. --> + +<html> +<head><title>GNU Classpath - javax.management.remote</title></head> + +<body> + +<p> +Provides a framework for accessing remote MBean servers. The JMX +remote API introduces the notion of a <emph>connector</emph>. On +the server side, the connector wraps the MBean server, processing +calls from remote clients. The client sends its requests via +a connector which is responsible for transmitting the request +to the server. +</p> +</body> +</html> diff --git a/libjava/classpath/javax/management/remote/rmi/RMIConnection.java b/libjava/classpath/javax/management/remote/rmi/RMIConnection.java new file mode 100644 index 00000000000..38fb544fe45 --- /dev/null +++ b/libjava/classpath/javax/management/remote/rmi/RMIConnection.java @@ -0,0 +1,1151 @@ +/* RMIConnection.java -- RMI object representing a MBean server connection. + Copyright (C) 2007, 2008 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath 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 for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package javax.management.remote.rmi; + +import java.io.Closeable; +import java.io.IOException; + +import java.rmi.MarshalledObject; +import java.rmi.Remote; + +import java.util.Set; + +import javax.management.AttributeList; +import javax.management.AttributeNotFoundException; +import javax.management.InstanceAlreadyExistsException; +import javax.management.InstanceNotFoundException; +import javax.management.IntrospectionException; +import javax.management.InvalidAttributeValueException; +import javax.management.ListenerNotFoundException; +import javax.management.MBeanInfo; +import javax.management.MBeanException; +import javax.management.MBeanRegistrationException; +import javax.management.NotCompliantMBeanException; +import javax.management.ObjectInstance; +import javax.management.ObjectName; +import javax.management.ReflectionException; + +import javax.management.remote.NotificationResult; + +import javax.security.auth.Subject; + +/** + * <p> + * RMI interface for forwarding requests to a remote + * {@link javax.management.MBeanServer}. This interface + * parallels the {@link javax.management.MBeanServerConnection} + * interface, providing a way of invoking those methods using + * the RMI protocol. When a client wishes to call a method + * of an MBean server using RMI, the method is called on the stub + * on the client side, which serializes the object parameters + * and sends them to the server where they are deserialized and + * an implementation of this interface forwards them to the + * appropriate MBean server. Return values follow the same + * process, only in reverse. Each client obtains its own + * implementation of this interface from an {@link RMIServer} + * instance. + * </p> + * <p> + * Implementations of this interface do more than simply + * forward requests directly to the server. The arguments + * of the server methods are wrapped in {@link MarshalledObject} + * instances, so that the correct classloader can be used to + * deserialize the arguments. When a method is called, the + * implementation must first retrieve the appropriate classloader + * and then use it to deserialize the marshalled object. Unless + * explicitly specified in the documentation for the method, + * a parameter of the type {@link MarshalledObject} or an array + * of that type should not be {@code null}. + * </p> + * <p> + * Security is also handled by this interface, as the methods + * use an additional {@link javax.security.auth.Subject} parameter + * for role delegation. + * </p> + * + * @author Andrew John Hughes (gnu_andrew@member.fsf.org) + * @since 1.5 + */ +public interface RMIConnection + extends Closeable, Remote +{ + + /** + * Handles {@link + * MBeanServerConnection#addNotificationListener(ObjectName, + * ObjectName, NotificationFilter, Object)} by + * registering the supplied listener with the specified management + * bean. Notifications emitted by the management bean are forwarded + * to the listener via the server, which will convert any MBean + * references in the source to portable {@link ObjectName} + * instances. The notification is otherwise unchanged. The filter + * and handback object are wrapped in a {@link MarshalledObject} + * so that they are deserialised using the bean's classloader. + * + * @param name the name of the management bean with which the listener + * should be registered. + * @param listener the listener which will handle notifications from + * the bean. + * @param filter a wrapper containing a filter to apply to incoming + * notifications, or <code>null</code> if no filtering + * should be applied. + * @param passback a wrapper containing an object to be passed to the + * listener when a notification is emitted. + * @param delegationSubject a {@link javax.security.auth.Subject} instance + * containing the delegation principles or + * {@code null} if authentication is used. + * @throws InstanceNotFoundException if the name of the management bean + * could not be resolved. + * @throws RuntimeOperationsException if the bean associated with the given + * object name is not a + * {@link NotificationListener}. This + * exception wraps an + * {@link IllegalArgumentException}. + * @throws SecurityException if the client or delegated subject (if any) + * does not have permission to invoke this operation. + * @throws IOException if an I/O error occurred in communicating with + * the bean server. + * @see #removeNotificationListener(ObjectName, ObjectName, + * javax.security.auth.Subject) + * @see #removeNotificationListener(ObjectName, ObjectName, + * java.rmi.MarshalledObject, + * java.rmi.MarshalledObject, + * javax.security.auth.Subject) + * @see #removeNotificationListeners(ObjectName, Integer[], + * javax.security.auth.Subject) + * @see NotificationBroadcaster#addNotificationListener(NotificationListener, + * NotificationFilter, + * Object) + */ + void addNotificationListener(ObjectName name, ObjectName listener, + MarshalledObject filter, MarshalledObject passback, + Subject delegationSubject) + throws InstanceNotFoundException, IOException; + + /** + * Handles {@link + * MBeanServerConnection#addNotificationListener(ObjectName, + * NotificationListener, NotificationFilter, Object)} by + * registering for notifications from the specified management + * beans. The array of filters is assumed to be aligned with + * the array of bean names, so that the notifications from each + * bean are matched against the appropriate filter (or left as + * is if the filter is {@code null}. Notifications emitted by + * the management beans are forwarded to a local listener created + * by this method, via the server, which converts any MBean + * references in the source to portable {@link ObjectName} + * instances. The notification is otherwise unchanged. + * </p> + * <p> + * This local listener buffers the notifications for retrieval by + * {@link #fetchNotifications(long,int,long). This method returns + * an array of listener identifiers which aligns with the supplied + * array of beans so that the appropriate listener can be identified + * by the client, which retains its own listener and handback object. + * The filters are wrapped in {@link MarshalledObject}s so that they are + * deserialised using the bean's classloader. + * </p> + * + * @param names the names of the management bean whose notifications + * should be recorded. + * @param filters an array of wrappers containing filters to apply to + * incoming notifications. An element may be <code>null</code> + * if no filtering should be applied to a bean's notifications. + * @param delegationSubjects an array of {@link javax.security.auth.Subject} + * instances containing the delegation principles for + * each listener. An element may be {@code null} if + * authentication is used instead, or the entire + * argument itself may be {@code null}. In the latter + * case, this is treated as an array of {@code null} + * values. + * @return an array of integers which act as listener identifiers, so that + * notifications retrieved from {@link #fetchNotifications(long,int,long) + * can be matched to the beans they were emitted from. The array is + * aligned against the array of beans supplied to this methods, so that + * the identifier in position 0 represents the bean in position 0 of the + * input array. + * @throws IllegalArgumentException if the {@code names} or {@code filters} array + * is {@code null}, the {@code names} array contains + * a {@code null} value or the three arrays are not + * of the same size. + * @throws ClassCastException if an element of the {@code filters} array unmarshalls + * as a non-null object that is not a {@link NotificationFilter}. + * @throws InstanceNotFoundException if the name of one of the management beans + * could not be resolved. + * @throws SecurityException if, for one of the beans, the client or delegated subject + * (if any) does not have permission to invoke this operation. + * @throws IOException if an I/O error occurred in communicating with + * the bean server. + * @see #removeNotificationListener(ObjectName, ObjectName, + * javax.security.auth.Subject) + * @see #removeNotificationListener(ObjectName, ObjectName, + * java.rmi.MarshalledObject, + * java.rmi.MarshalledObject, + * javax.security.auth.Subject) + * @see #removeNotificationListeners(ObjectName, Integer[], + * javax.security.auth.Subject) + * @see NotificationBroadcaster#addNotificationListener(NotificationListener, + * NotificationFilter, + * Object) + */ + Integer[] addNotificationListeners(ObjectName[] names, MarshalledObject[] filters, + Subject[] delegationSubjects) + throws InstanceNotFoundException, IOException; + + /** + * Closes the connection and unexports the RMI object implementing this + * interface. Following this call, future method calls to this instance + * will fail. + * + * @throws IOException if there is an I/O error in transmitting the close + * request via RMI, closing the connection, or unexporting + * the RMI object. + */ + void close() + throws IOException; + + /** + * <p> + * Handles {@link + * MBeanServerConnection#createMBean(String, ObjectName, + * Object[], String[])}. The array of parameters is wrapped in + * a {@link MarshalledObject} so that it is deserialised using the + * bean's classloader. + * </p> + * <p> + * Instantiates a new instance of the specified management bean + * using the given constructor and registers it with the server + * under the supplied name. The class is loaded using the + * {@link javax.management.loading.ClassLoaderRepository default + * loader repository} of the server. + * </p> + * <p> + * If the name supplied is <code>null</code>, then the bean is + * expected to implement the {@link MBeanRegistration} interface. + * The {@link MBeanRegistration#preRegister preRegister} method + * of this interface will be used to obtain the name in this case. + * </p> + * + * @param className the class of the management bean, of which + * an instance should be created. + * @param name the name to register the new bean with. This may + * be <code>null</code>. + * @param params the parameters for the bean's constructor, encapsulated + * in a {@link MarshalledObject}. If this parameter is + * <code>null</code>, it will be judged equivalent to an + * empty array. + * @param sig the signature of the constructor to use. If this parameter + * is <code>null</code>, it will be judged equivalent to an + * empty array. + * @param delegationSubject an instance of {@link javax.security.auth.Subject} + * containing the delegation principles. This may be + * {@code null} is authentication is used instead. + * @return an {@link ObjectInstance} containing the {@link ObjectName} + * and Java class name of the created instance. + * @throws ReflectionException if an exception occurs in creating + * an instance of the bean. + * @throws InstanceAlreadyExistsException if a matching instance + * already exists. + * @throws MBeanRegistrationException if an exception occurs in + * calling the preRegister + * method. + * @throws MBeanException if the bean's constructor throws an exception. + * @throws NotCompliantMBeanException if the created bean is not + * compliant with the JMX specification. + * @throws RuntimeOperationsException if an {@link IllegalArgumentException} + * is thrown by the server due to a + * <code>null</code> class name or object + * name or if the object name is a pattern. + * @throws SecurityException if the client or delegated subject (if any) does + * not have permission to invoke this operation. + * @throws IOException if an I/O error occurred in communicating with + * the bean server. + */ + ObjectInstance createMBean(String className, ObjectName name, + MarshalledObject params, String[] sig, + Subject delegationSubject) + throws ReflectionException, InstanceAlreadyExistsException, + MBeanRegistrationException, MBeanException, + NotCompliantMBeanException, IOException; + + /** + * <p> + * Handles {@link + * MBeanServerConnection#createMBean(String, ObjectName, + * ObjectName, Object[], String[])}. The array of parameters is + * wrapped in a {@link MarshalledObject} so that it is deserialised + * using the bean's classloader. + * </p> + * <p> + * Instantiates a new instance of the specified management bean + * using the given constructor and registers it with the server + * under the supplied name. The class is loaded using the + * given class loader. If this argument is <code>null</code>, + * then the same class loader as was used to load the server + * is used. + * </p> + * <p> + * If the name supplied is <code>null</code>, then the bean is + * expected to implement the {@link MBeanRegistration} interface. + * The {@link MBeanRegistration#preRegister preRegister} method + * of this interface will be used to obtain the name in this case. + * </p> + * + * @param className the class of the management bean, of which + * an instance should be created. + * @param name the name to register the new bean with. This may + * be <code>null</code>. + * @param loaderName the name of the class loader. + * @param params the parameters for the bean's constructor, encapsulated + * in a {@link MarshalledObject}. If this parameter is + * <code>null</code>, it will be judged equivalent to an + * empty array. + * @param sig the signature of the constructor to use. If this parameter + * is <code>null</code>, it will be judged equivalent to an + * empty array. + * @param delegationSubject an instance of {@link javax.security.auth.Subject} + * containing the delegation principles. This may be + * {@code null} is authentication is used instead. + * @return an {@link ObjectInstance} containing the {@link ObjectName} + * and Java class name of the created instance. + * @throws ReflectionException if an exception occurs in creating + * an instance of the bean. + * @throws InstanceAlreadyExistsException if a matching instance + * already exists. + * @throws MBeanRegistrationException if an exception occurs in + * calling the preRegister + * method. + * @throws MBeanException if the bean's constructor throws an exception. + * @throws NotCompliantMBeanException if the created bean is not + * compliant with the JMX specification. + * @throws InstanceNotFoundException if the specified class loader is not + * registered with the server. + * @throws RuntimeOperationsException if an {@link IllegalArgumentException} + * is thrown by the server due to a + * <code>null</code> class name or object + * name or if the object name is a pattern. + * @throws SecurityException if the client or delegated subject (if any) does + * not have permission to invoke this operation. + * @throws IOException if an I/O error occurred in communicating with + * the bean server. + */ + ObjectInstance createMBean(String className, ObjectName name, + ObjectName loaderName, MarshalledObject params, + String[] sig, Subject delegationSubject) + throws ReflectionException, InstanceAlreadyExistsException, + MBeanRegistrationException, MBeanException, + NotCompliantMBeanException, InstanceNotFoundException, + IOException; + + /** + * <p> + * Handles {@link + * MBeanServerConnection#createMBean(String, ObjectName, + * ObjectName)} by instantiating a new instance of the specified + * management bean using the default constructor and registering + * it with the server under the supplied name. The class is loaded + * using the given class loader. If this argument is <code>null</code>, + * then the same class loader as was used to load the server + * is used. + * </p> + * <p> + * If the name supplied is <code>null</code>, then the bean is + * expected to implement the {@link MBeanRegistration} interface. + * The {@link MBeanRegistration#preRegister preRegister} method + * of this interface will be used to obtain the name in this case. + * </p> + * <p> + * This method is equivalent to calling {@link + * #createMBean(String, ObjectName, ObjectName, Object[], String) + * <code>createMBean(className, name, loaderName, (Object[]) null, + * (String) null)</code>} with <code>null</code> parameters + * and signature. + * </p> + * + * @param className the class of the management bean, of which + * an instance should be created. + * @param name the name to register the new bean with. This may + * be <code>null</code>. + * @param loaderName the name of the class loader. + * @param delegationSubject an instance of {@link javax.security.auth.Subject} + * containing the delegation principles. This may be + * {@code null} is authentication is used instead. + * @return an {@link ObjectInstance} containing the {@link ObjectName} + * and Java class name of the created instance. + * @throws ReflectionException if an exception occurs in creating + * an instance of the bean. + * @throws InstanceAlreadyExistsException if a matching instance + * already exists. + * @throws MBeanRegistrationException if an exception occurs in + * calling the preRegister + * method. + * @throws MBeanException if the bean's constructor throws an exception. + * @throws NotCompliantMBeanException if the created bean is not + * compliant with the JMX specification. + * @throws InstanceNotFoundException if the specified class loader is not + * registered with the server. + * @throws RuntimeOperationsException if an {@link IllegalArgumentException} + * is thrown by the server due to a + * <code>null</code> class name or object + * name or if the object name is a pattern. + * @throws SecurityException if the client or delegated subject (if any) does + * not have permission to invoke this operation. + * @throws IOException if an I/O error occurred in communicating with + * the bean server. + * @see #createMBean(String, ObjectName, ObjectName, MarshalledObject, + * String[], Subject) + */ + ObjectInstance createMBean(String className, ObjectName name, + ObjectName loaderName, Subject delegationSubject) + throws ReflectionException, InstanceAlreadyExistsException, + MBeanRegistrationException, MBeanException, + NotCompliantMBeanException, InstanceNotFoundException, + IOException; + + /** + * <p> + * Handles {@link + * MBeanServerConnection#createMBean(String, ObjectName)} by + * instantiating a new instance of the specified management bean + * using the default constructor and registering it with the server + * under the supplied name. The class is loaded using the + * {@link javax.management.loading.ClassLoaderRepository default + * loader repository} of the server. + * </p> + * <p> + * If the name supplied is <code>null</code>, then the bean is + * expected to implement the {@link MBeanRegistration} interface. + * The {@link MBeanRegistration#preRegister preRegister} method + * of this interface will be used to obtain the name in this case. + * </p> + * <p> + * This method is equivalent to calling {@link + * #createMBean(String, ObjectName, Object[], String[]) + * <code>createMBean(className, name, (Object[]) null, + * (String[]) null)</code>} with <code>null</code> parameters + * and signature. + * </p> + * + * @param className the class of the management bean, of which + * an instance should be created. + * @param name the name to register the new bean with. This may + * be <code>null</code>. + * @param delegationSubject an instance of {@link javax.security.auth.Subject} + * containing the delegation principles. This may be + * {@code null} is authentication is used instead. + * @return an {@link ObjectInstance} containing the {@link ObjectName} + * and Java class name of the created instance. + * @throws ReflectionException if an exception occurs in creating + * an instance of the bean. + * @throws InstanceAlreadyExistsException if a matching instance + * already exists. + * @throws MBeanRegistrationException if an exception occurs in + * calling the preRegister + * method. + * @throws MBeanException if the bean's constructor throws an exception. + * @throws NotCompliantMBeanException if the created bean is not + * compliant with the JMX specification. + * @throws RuntimeOperationsException if an {@link IllegalArgumentException} + * is thrown by the server due to a + * <code>null</code> class name or object + * name or if the object name is a pattern. + * @throws SecurityException if the client or delegated subject (if any) does + * not have permission to invoke this operation. + * @throws IOException if an I/O error occurred in communicating with + * the bean server. + * @see #createMBean(String, ObjectName, MarshalledObject, String[], Subject) + */ + ObjectInstance createMBean(String className, ObjectName name, + Subject delegationSubject) + throws ReflectionException, InstanceAlreadyExistsException, + MBeanRegistrationException, MBeanException, + NotCompliantMBeanException, IOException; + + /** + * <p> + * Retrieves any waiting notifications from the server. When notifications + * are requested using the {@link #addNotificationListeners(ObjectName[], + * MarshalledObject[], Subject[])} method, the server sets up an internal + * listener to receive notifications from the bean and buffer them. When + * this method is called, these buffered notifications can be retrieved. + * </p> + * <p> + * The blocking behaviour of this method depends on the timeout value specified. + * If there are no waiting notifications in the buffer, a value of 0 will cause + * the method to return immediately. Conversely, if the value is + * {@link Long#MAX_VALUE}, then it will wait indefinitely until a notification + * arrives. For any other value, it waits until a notification arrives or the + * number of milliseconds specified by the timeout value is exceeded. The + * behaviour for a negative timeout value is undefined. + * </p> + * <p> + * For a notification to be returned, the following criteria must be fulfilled: + * </p> + * <ul> + * <li>the client must have previously requested notifications from at least + * one bean</li> + * <li>a bean from which notifications have been requested must have emitted + * a notification since the last call to this method</li> + * <li>the emitted notification must pass through any filters established + * when notifications were requested</li> + * <li>the sequence number of the notification must be greater than or equal + * to the specified sequence number (if non-negative)</li> + * </ul> + * + * @param sequenceNumber the sequence number of each notification returned + * must be greater than or equal to this value. If + * the number is negative, this is interpreted as + * meaning the sequence number of the next notification + * and so all notifications are allowed through. + * @param maxNotifications the maximum number of notifications to return. + * This does not include any duplicates so the + * number of actual notifications returned may + * be larger. + * @param timeout the number of milliseconds to wait for a notification + * if the buffer is empty. <code>0</code> causes the + * method to return immediately even if there are no + * notifications available (non-blocking behaviour) while + * a value of {@link Long#MAX_VALUE} causes it to wait + * indefinitely (blocking behaviour). The response to + * a negative value is undefined. + * @return a {@link NotificationResult} object containing the buffered + * notifications. + * @throws IOException if an I/O error occurs. + */ + NotificationResult fetchNotifications(long sequenceNumber, + int maxNotifications, + long timeout) + throws IOException; + + /** + * Handles {@link + * MBeanServerConnection#getAttribute(ObjectName, String)}, + * returning the value of the supplied attribute from the specified + * management bean. + * + * @param bean the bean to retrieve the value from. + * @param name the name of the attribute to retrieve. + * @param delegationSubject an instance of {@link javax.security.auth.Subject} + * containing the delegation principles. This may be + * {@code null} is authentication is used instead. + * @return the value of the attribute. + * @throws AttributeNotFoundException if the attribute could not be + * accessed from the bean. + * @throws MBeanException if the management bean's accessor throws + * an exception. + * @throws InstanceNotFoundException if the bean can not be found. + * @throws ReflectionException if an exception was thrown in trying + * to invoke the bean's accessor. + * @throws RuntimeOperationsException if an {@link IllegalArgumentException} + * is thrown by the server due to a + * <code>null</code> bean or attribute + * name. + * @throws SecurityException if the client or delegated subject (if any) does + * not have permission to invoke this operation. + * @throws IOException if an I/O error occurred in communicating with + * the bean server. + * @see DynamicMBean#getAttribute(String) + */ + Object getAttribute(ObjectName bean, String name, Subject delegationSubject) + throws MBeanException, AttributeNotFoundException, + InstanceNotFoundException, ReflectionException, + IOException; + + /** + * Handles {@link + * MBeanServerConnection#getAttribute(ObjectName, String)}, + * returning the values of the named attributes from the specified + * management bean. + * + * @param bean the bean to retrieve the value from. + * @param names the names of the attributes to retrieve. + * @param delegationSubject an instance of {@link javax.security.auth.Subject} + * containing the delegation principles. This may be + * {@code null} is authentication is used instead. + * @return the values of the attributes. + * @throws InstanceNotFoundException if the bean can not be found. + * @throws ReflectionException if an exception was thrown in trying + * to invoke the bean's accessor. + * @throws RuntimeOperationsException if an {@link IllegalArgumentException} + * is thrown by the server due to a + * <code>null</code> bean or attribute + * name. + * @throws SecurityException if the client or delegated subject (if any) does + * not have permission to invoke this operation. + * @throws IOException if an I/O error occurred in communicating with + * the bean server. + * @see DynamicMBean#getAttributes(String[]) + */ + AttributeList getAttributes(ObjectName bean, String[] names, + Subject delegationSubject) + throws InstanceNotFoundException, ReflectionException, + IOException; + + /** + * Returns the unique identifier for this connection to the RMI + * server. + * + * @return the connection ID. + * @throws IOException if an I/O error occurred. + */ + String getConnectionId() + throws IOException; + + /** + * Handles {@link + * MBeanServerConnection#getDefaultDomain()} by returning the default + * domain this server applies to beans that have no specified domain. + * + * @param delegationSubject an instance of {@link javax.security.auth.Subject} + * containing the delegation principles. This may be + * {@code null} is authentication is used instead. + * @return the default domain. + * @throws SecurityException if the client or delegated subject (if any) does + * not have permission to invoke this operation. + * @throws IOException if an I/O error occurred in communicating with + * the bean server. + */ + String getDefaultDomain(Subject delegationSubject) + throws IOException; + + /** + * Handles {@link + * MBeanServerConnection#getDomains()} by returning an array + * containing all the domains used by beans registered with + * this server. The ordering of the array is undefined. + * + * @param delegationSubject an instance of {@link javax.security.auth.Subject} + * containing the delegation principles. This may be + * {@code null} is authentication is used instead. + * @return the list of domains. + * @throws SecurityException if the client or delegated subject (if any) does + * not have permission to invoke this operation. + * @throws IOException if an I/O error occurred in communicating with + * the bean server. + * @see ObjectName#getDomain() + */ + String[] getDomains(Subject delegationSubject) + throws IOException; + + /** + * Handles {@link + * MBeanServerConnection#getMBeanCount()} by returning the number of + * management beans registered with this server. + * + * @param delegationSubject an instance of {@link javax.security.auth.Subject} + * containing the delegation principles. This may be + * {@code null} is authentication is used instead. + * @return the number of registered beans. + * @throws SecurityException if the client or delegated subject (if any) does + * not have permission to invoke this operation. + * @throws IOException if an I/O error occurred in communicating with + * the bean server. + */ + Integer getMBeanCount(Subject delegationSubject) + throws IOException; + + /** + * Handles {@link + * MBeanServerConnection#getMBeanInfo(ObjectName)} by returning + * information on the given management bean. + * + * @param name the name of the management bean. + * @param delegationSubject an instance of {@link javax.security.auth.Subject} + * containing the delegation principles. This may be + * {@code null} is authentication is used instead. + * @return an instance of {@link MBeanInfo} for the bean. + * @throws IntrospectionException if an exception occurs in examining + * the bean. + * @throws InstanceNotFoundException if the bean can not be found. + * @throws ReflectionException if an exception occurs when trying + * to invoke {@link DynamicMBean#getMBeanInfo()} + * on the bean. + * @throws SecurityException if the client or delegated subject (if any) does + * not have permission to invoke this operation. + * @throws IOException if an I/O error occurred in communicating with + * the bean server. + * @see DynamicMBean#getMBeanInfo() + */ + MBeanInfo getMBeanInfo(ObjectName name, Subject delegationSubject) + throws InstanceNotFoundException, IntrospectionException, + ReflectionException, IOException; + + /** + * Handles {@link + * MBeanServerConnection#getObjectInstance(ObjectName)} by returning + * the {@link ObjectInstance} created for the specified management + * bean on registration. + * + * @param name the name of the bean. + * @param delegationSubject an instance of {@link javax.security.auth.Subject} + * containing the delegation principles. This may be + * {@code null} is authentication is used instead. + * @return the corresponding {@link ObjectInstance} instance. + * @throws InstanceNotFoundException if the bean can not be found. + * @throws SecurityException if the client or delegated subject (if any) does + * not have permission to invoke this operation. + * @throws IOException if an I/O error occurred in communicating with + * the bean server. + * @see #createMBean(String, ObjectName, Subject) + */ + ObjectInstance getObjectInstance(ObjectName name, Subject delegationSubject) + throws InstanceNotFoundException, IOException; + + /** + * <p> + * Handles {@link + * MBeanServerConnection#invoke(ObjectName, String, Object[], + * String[])}. The array of parameters is wrapped in a + * {@link MarshalledObject} so that it is deserialised + * using the bean's classloader. + * </p> + * <p> + * Invokes the supplied operation on the specified management + * bean. The class objects specified in the signature are loaded + * using the same class loader as was used for the management bean. + * + * @param bean the management bean whose operation should be invoked. + * @param name the name of the operation to invoke. + * @param params the parameters for the bean's constructor, encapsulated + * in a {@link MarshalledObject}. If this parameter is + * <code>null</code>, it will be judged equivalent to an + * empty array. + * @param sig the signature of the constructor to use. If this parameter + * is <code>null</code>, it will be judged equivalent to an + * empty array. The class objects will be loaded using the + * bean's classloader. + * @param delegationSubject an instance of {@link javax.security.auth.Subject} + * containing the delegation principles. This may be + * {@code null} is authentication is used instead. + * @return the return value of the method. + * @throws InstanceNotFoundException if the bean can not be found. + * @throws MBeanException if the method invoked throws an exception. + * @throws ReflectionException if an exception is thrown in invoking the + * method. + * @throws SecurityException if the client or delegated subject (if any) does + * not have permission to invoke this operation. + * @throws IOException if an I/O error occurred in communicating with + * the bean server. + * @see DynamicMBean#invoke(String, Object[], String[]) + */ + Object invoke(ObjectName bean, String name, MarshalledObject params, + String[] sig, Subject delegationSubject) + throws InstanceNotFoundException, MBeanException, + ReflectionException, IOException; + + /** + * <p> + * Handles {@link + * MBeanServerConnection#isInstanceOf(ObjectName, String) by + * returning true if the specified management bean is an instance + * of the supplied class. + * </p> + * <p> + * A bean, B, is an instance of a class, C, if either of the following + * conditions holds: + * </p> + * <ul> + * <li>The class name in B's {@link MBeanInfo} is equal to the supplied + * name.</li> + * <li>Both the class of B and C were loaded by the same class loader, + * and B is assignable to C.</li> + * </ul> + * + * @param name the name of the management bean. + * @param className the name of the class to test if <code>name</code> is + * an instance of. + * @param delegationSubject an instance of {@link javax.security.auth.Subject} + * containing the delegation principles. This may be + * {@code null} is authentication is used instead. + * @return true if either B is directly an instance of the named class, + * or B is assignable to the class, given that both it and B's + * current class were loaded using the same class loader. + * @throws InstanceNotFoundException if the bean can not be found. + * @throws SecurityException if the client or delegated subject (if any) does + * not have permission to invoke this operation. + * @throws IOException if an I/O error occurred in communicating with + * the bean server. + */ + boolean isInstanceOf(ObjectName name, String className, + Subject delegationSubject) + throws InstanceNotFoundException, IOException; + + /** + * Handles {@link + * MBeanServerConnection#isRegistered(ObjectName) by returning + * true if the specified management bean is registered with + * the server. + * + * @param name the name of the management bean. + * @param delegationSubject an instance of {@link javax.security.auth.Subject} + * containing the delegation principles. This may be + * {@code null} is authentication is used instead. + * @return true if the bean is registered. + * @throws RuntimeOperationsException if an {@link IllegalArgumentException} + * is thrown by the server due to a + * <code>null</code> bean name. + * @throws SecurityException if the client or delegated subject (if any) does + * not have permission to invoke this operation. + * @throws IOException if an I/O error occurred in communicating with + * the bean server. + */ + boolean isRegistered(ObjectName name, Subject delegationSubject) + throws IOException; + + /** + * <p> + * Handles {@link + * MBeanServerConnection#queryMBeans(ObjectName, QueryExp)}. + * The query expression is wrapped in a {@link MarshalledObject} + * so that it is deserialised using the bean's classloader. + * </p> + * <p> + * Returns a set of {@link ObjectInstance}s matching the specified + * criteria. The full set of beans registered with the server + * are passed through two filters: + * </p> + * <ol> + * <li>Pattern matching is performed using the supplied + * {@link ObjectName}.</li> + * <li>The supplied query expression is applied.</li> + * </ol> + * <p> + * If both the object name and the query expression are <code>null</code>, + * or the object name has no domain and no key properties, + * no filtering will be performed and all beans are returned. + * </p> + * + * @param name an {@link ObjectName} to use as a filter. + * @param query a query expression to apply to each of the beans that match + * the given object name, encapsulated in a + * {@link MarshalledObject}. If a <code>null</code> value is + * encapsulated, then the beans will only be filtered using + * pattern matching on the supplied {@link ObjectName}. + * @param delegationSubject an instance of {@link javax.security.auth.Subject} + * containing the delegation principles. This may be + * {@code null} is authentication is used instead. + * @return a set of {@link ObjectInstance}s matching the filtered beans. + * This is empty if no beans survived the filters. + * @throws IOException if an I/O error occurred in communicating with + * the bean server. + * @throws SecurityException if the client or delegated subject (if any) does + * not have permission to invoke this operation. + */ + Set<ObjectInstance> queryMBeans(ObjectName name, MarshalledObject query, + Subject delegationSubject) + throws IOException; + + /** + * <p> + * Handles {@link + * MBeanServerConnection#queryNames(ObjectName, QueryExp)}. + * The query expression is wrapped in a {@link MarshalledObject} + * so that it is deserialised using the bean's classloader. + * </p> + * <p> + * Returns a set of {@link ObjectName}s matching the specified + * criteria. The full set of beans registered with the server + * are passed through two filters: + * </p> + * <ol> + * <li>Pattern matching is performed using the supplied + * {@link ObjectName}.</li> + * <li>The supplied query expression is applied.</li> + * </ol> + * <p> + * If both the object name and the query expression are <code>null</code>, + * or the object name has no domain and no key properties, + * no filtering will be performed and all beans are returned. + * </p> + * + * @param name an {@link ObjectName} to use as a filter. + * @param query a query expression to apply to each of the beans that match + * the given object name, encapsulated in a + * {@link MarshalledObject}. If a <code>null</code> value is + * encapsulated, then the beans will only be filtered using + * pattern matching on the supplied {@link ObjectName}. + * @param delegationSubject an instance of {@link javax.security.auth.Subject} + * containing the delegation principles. This may be + * {@code null} is authentication is used instead. + * @return a set of {@link ObjectName}s matching the filtered beans. + * @throws SecurityException if the client or delegated subject (if any) does + * not have permission to invoke this operation. + * @throws IOException if an I/O error occurred in communicating with + * the bean server. + */ + Set<ObjectName> queryNames(ObjectName name, MarshalledObject query, + Subject delegationSubject) + throws IOException; + + /** + * <p> + * Handles {@link + * MBeanServerConnection#removeNotificationListener(ObjectName, + * ObjectName, NotificationFilter, Object)}. Both the filter and + * the handback object are wrapped in a {@link MarshalledObject} + * so that they are deserialised using the bean's classloader. + * </p> + * <p> + * Removes the specified listener from the list of recipients + * of notifications from the supplied bean. Only the first instance with + * the supplied filter and passback object is removed. + * <code>null</code> is used as a valid value for these parameters, + * rather than as a way to remove all registration instances for + * the specified listener; for this behaviour instead, see + * {@link #removeNotificationListener(ObjectName, NotificationListener)}. + * </p> + * + * @param name the name of the management bean from which the + * listener should be removed. + * @param listener the listener to remove. + * @param filter a wrapper containing the filter of the listener + * to remove. + * @param passback a wrapper containing the handback object of the + * listener to remove. + * @param delegationSubject a {@link javax.security.auth.Subject} instance + * containing the delegation principles or + * {@code null} if authentication is used. + * @throws InstanceNotFoundException if the bean can not be found. + * @throws ListenerNotFoundException if the specified listener + * is not registered with the bean. + * @throws SecurityException if the client or delegated subject (if any) does + * not have permission to invoke this operation. + * @throws IOException if an I/O error occurred in communicating with + * the bean server. + * @see #addNotificationListener(ObjectName, NotificationListener, + * MarshalledObject, MarshalledObject, Subject) + * @see NotificationEmitter#removeNotificationListener(NotificationListener, + * NotificationFilter, + * Object) + */ + void removeNotificationListener(ObjectName name, + ObjectName listener, + MarshalledObject filter, + MarshalledObject passback, + Subject delegationSubject) + throws InstanceNotFoundException, ListenerNotFoundException, + IOException; + + /** + * Handles {@link + * MBeanServerConnection#removeNotificationListener(ObjectName, + * ObjectName)} by removing the specified listener from the list + * of recipients of notifications from the supplied bean. This + * includes all combinations of filters and passback objects + * registered for this listener. For more specific removal of + * listeners, see {@link #removeNotificationListener(ObjectName, + * ObjectName,MarshalledObject,MarshalledObject,Subject)} + * + * @param name the name of the management bean from which the + * listener should be removed. + * @param listener the name of the listener to remove. + * @param delegationSubject a {@link javax.security.auth.Subject} instance + * containing the delegation principles or + * {@code null} if authentication is used. + * @throws InstanceNotFoundException if a name doesn't match a registered + * bean. + * @throws ListenerNotFoundException if the specified listener + * is not registered with the bean. + * @throws SecurityException if the client or delegated subject (if any) does + * not have permission to invoke this operation. + * @throws IOException if an I/O error occurred in communicating with + * the bean server. + * @see #addNotificationListener(ObjectName, NotificationListener, + * MarshalledObject, MarshalledObject, Subject) + * @see NotificationBroadcaster#removeNotificationListener(NotificationListener) + */ + void removeNotificationListener(ObjectName name, ObjectName listener, + Subject delegationSubject) + throws InstanceNotFoundException, ListenerNotFoundException, + IOException; + + /** + * Removes one or more {@link NotificationListener}s from the specified + * management bean. This method corresponds to + * {@link #addNotificationListeners(ObjectName[], MarshalledObject[], + * Subject)} and provides a different way of handling + * MBeanServerConnection#removeNotificationListener(ObjectName, + * ObjectName)} and + * {@link MBeanServerConnection#removeNotificationListener(ObjectName, + * ObjectName, NotificationFilter, Object)} by using the integer + * identifiers provided by the + * {@link #addNotificationListeners(ObjectName[], MarshalledObject[], + * Subject)} method to select the listeners to remove. + * + * @param name the name of the management bean from which the + * listeners should be removed. + * @param listenerIds the identifiers of the listeners to remove. + * @param delegationSubject a {@link javax.security.auth.Subject} instance + * containing the delegation principles or + * {@code null} if authentication is used. + * @throws InstanceNotFoundException if a name doesn't match a registered + * bean. + * @throws ListenerNotFoundException if the specified listener + * is not registered with the bean. + * @throws SecurityException if the client or delegated subject (if any) does + * not have permission to invoke this operation. + * @throws IOException if an I/O error occurred in communicating with + * the bean server. + * @throws IllegalArgumentException if either <code>name</code>, + * <code>listenerIds</code> or an element + * of <code>listenerIds</code> + * is <code>null</code>. + * @see #addNotificationListeners(ObjectName[], MarshalledObject[], Subject) + */ + void removeNotificationListeners(ObjectName name, Integer[] listenerIds, + Subject delegationSubject) + throws InstanceNotFoundException, ListenerNotFoundException, + IOException; + + /** + * Handles {@link + * MBeanServerConnection#setAttribute(ObjectName, Attribute)} + * by setting the value of the specified attribute of the supplied + * management bean. The attribute is wrapped in a + * {@link MarshalledObject} so that it is deserialised using the + * bean's classloader. + * + * @param name the name of the management bean. + * @param attribute the attribute to set, encapsulated in a + * {@link MarshalledObject}. + * @param delegationSubject a {@link javax.security.auth.Subject} instance + * containing the delegation principles or + * {@code null} if authentication is used. + * @throws InstanceNotFoundException if the bean can not be found. + * @throws AttributeNotFoundException if the attribute does not + * correspond to an attribute + * of the bean. + * @throws InvalidAttributeValueException if the value is invalid + * for this particular + * attribute of the bean. + * @throws MBeanException if setting the attribute causes + * the bean to throw an exception (which + * becomes the cause of this exception). + * @throws ReflectionException if an exception occurred in trying + * to use the reflection interface + * to lookup the attribute. The + * thrown exception is the cause of + * this exception. + * @throws RuntimeOperationsException if an {@link IllegalArgumentException} + * is thrown by the server due to a + * <code>null</code> bean or attribute + * name. + * @throws SecurityException if the client or delegated subject (if any) does + * not have permission to invoke this operation. + * @throws IOException if an I/O error occurred in communicating with + * the bean server. + * @see #getAttribute(ObjectName, String, Subject) + * @see javax.management.DynamicMBean#setAttribute(Attribute) + */ + void setAttribute(ObjectName name, MarshalledObject attribute, + Subject delegationSubject) + throws InstanceNotFoundException, AttributeNotFoundException, + InvalidAttributeValueException, MBeanException, + ReflectionException, IOException; + + /** + * Handles {@link + * MBeanServerConnection#setAttributes(ObjectName, AttributeList)} + * by setting the value of each of the specified attributes + * of the supplied management bean to that specified by + * the {@link Attribute} object. The returned list contains + * the attributes that were set and their new values. + * The attribute list is wrapped in a {@link MarshalledObject} so + * that it is deserialised using the bean's classloader. + * + * @param name the name of the management bean. + * @param attributes the attributes to set, encapsulated in a + * {@link MarshalledObject}. + * @param delegationSubject a {@link javax.security.auth.Subject} instance + * containing the delegation principles or + * {@code null} if authentication is used. + * @return a list of the changed attributes. + * @throws InstanceNotFoundException if the bean can not be found. + * @throws ReflectionException if an exception occurred in trying + * to use the reflection interface + * to lookup the attribute. The + * thrown exception is the cause of + * this exception. + * @throws RuntimeOperationsException if an {@link IllegalArgumentException} + * is thrown by the server due to a + * <code>null</code> bean or attribute + * list. + * @throws SecurityException if the client or delegated subject (if any) does + * not have permission to invoke this operation. + * @throws IOException if an I/O error occurred in communicating with + * the bean server. + * @see #getAttributes(ObjectName, String[]) + * @see DynamicMBean#setAttributes(AttributeList) + */ + AttributeList setAttributes(ObjectName name, MarshalledObject attributes, + Subject delegationSubject) + throws InstanceNotFoundException, ReflectionException, + IOException; + + /** + * Handles {@link + * MBeanServerConnection#unregisterMBean(ObjectName)} by unregistering + * the specified management bean. Following this operation, + * the bean instance is no longer accessible from the server via this + * name. Prior to unregistering the bean, the + * {@link MBeanRegistration#preDeregister()} method will be called if + * the bean implements the {@link MBeanRegistration} interface. + * + * @param name the name of the management bean. + * @param delegationSubject a {@link javax.security.auth.Subject} instance + * containing the delegation principles or + * {@code null} if authentication is used. + * @throws InstanceNotFoundException if the bean can not be found. + * @throws MBeanRegistrationException if an exception occurs in + * calling the preDeregister + * method. + * @throws RuntimeOperationsException if an {@link IllegalArgumentException} + * is thrown by the server due to a + * <code>null</code> bean name or a + * request being made to unregister the + * {@link MBeanServerDelegate} bean. + * @throws SecurityException if the client or delegated subject (if any) does + * not have permission to invoke this operation. + * @throws IOException if an I/O error occurred in communicating with + * the bean server. + */ + void unregisterMBean(ObjectName name, Subject delegationSubject) + throws InstanceNotFoundException, MBeanRegistrationException, + IOException; + +} diff --git a/libjava/classpath/javax/management/remote/rmi/RMIServer.java b/libjava/classpath/javax/management/remote/rmi/RMIServer.java new file mode 100644 index 00000000000..d862372ace7 --- /dev/null +++ b/libjava/classpath/javax/management/remote/rmi/RMIServer.java @@ -0,0 +1,89 @@ +/* RMIServer.java -- RMI object for connecting to an RMI JMX connector. + Copyright (C) 2007 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath 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 for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package javax.management.remote.rmi; + +import java.io.IOException; + +import java.rmi.Remote; +import java.rmi.RemoteException; + +/** + * RMI interface for obtaining an instance of an + * {@link RMIConnection}. An implementation of this + * interface exists for each RMI connector. + * + * @author Andrew John Hughes (gnu_andrew@member.fsf.org) + * @since 1.5 + */ +public interface RMIServer + extends Remote +{ + + /** + * Returns the version of the RMI connection protocol used + * by this server. The returned string takes the form of + * <emph>protocol-version implementation-name</emph> where + * <emph>protocol-version</emph> is a series of two or more + * non-negative integers, separated by a decimal point (.) + * (currently {@code 1.0}) and <emph>implementation-name</emph> + * is the string {@code "GNU Classpath"} followed by the version + * of GNU Classpath in use. + * + * @return the string specified above. + * @throws RemoteException if there is a problem with the transfer + * of the string via RMI. + */ + String getVersion() + throws RemoteException; + + /** + * Constructs and returns a new RMI connection using the specified + * authentication credentials. Each client calls this method to + * obtain a connection to the server. + * + * @param credentials a user-defined object passed to the server + * to authenticate the client. May be {@code null}. + * @return the new connection. + * @throws IOException if the new connection can not be created or + * exported, or an error occurs in the RMI transmission. + * @throws SecurityException if the client could not be authenticated + * correctly using the supplied credientials. + */ + RMIConnection newClient(Object credentials) + throws IOException; +} |

