📄 mbeanserverinvocationhandler.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc (build 1.4.2_02) on Thu Nov 13 17:20:52 PST 2003 --><TITLE>MBeanServerInvocationHandler (Java 2 Platform Ent. Ed. v1.4)</TITLE><META NAME="keywords" CONTENT="javax.management.MBeanServerInvocationHandler class"><LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style"><SCRIPT type="text/javascript">function windowTitle(){ parent.document.title="MBeanServerInvocationHandler (Java 2 Platform Ent. Ed. v1.4)";}</SCRIPT></HEAD><BODY BGCOLOR="white" onload="windowTitle();"><!-- ========= START OF TOP NAVBAR ======= --><A NAME="navbar_top"><!-- --></A><A HREF="#skip-navbar_top" title="Skip navigation links"></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""><TR><TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Ent. Ed. v1.4</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../javax/management/MBeanServerFactory.html" title="class in javax.management"><B>PREV CLASS</B></A> <A HREF="../../javax/management/MBeanServerNotification.html" title="class in javax.management"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../index.html" target="_top"><B>FRAMES</B></A> <A HREF="MBeanServerInvocationHandler.html" target="_top"><B>NO FRAMES</B></A> <SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--></SCRIPT><NOSCRIPT> <A HREF="../../allclasses-noframe.html"><B>All Classes</B></A></NOSCRIPT></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: NESTED | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><A NAME="skip-navbar_top"></A><!-- ========= END OF TOP NAVBAR ========= --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">javax.management</FONT><BR>Class MBeanServerInvocationHandler</H2><PRE><A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html" title="class or interface in java.lang">java.lang.Object</A> <IMG SRC="../../resources/inherit.gif" ALT="extended by"><B>javax.management.MBeanServerInvocationHandler</B></PRE><DL><DT><B>All Implemented Interfaces:</B> <DD><A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/reflect/InvocationHandler.html" title="class or interface in java.lang.reflect">InvocationHandler</A></DD></DL><HR><DL><DT>public class <B>MBeanServerInvocationHandler</B><DT>extends <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A><DT>implements <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/reflect/InvocationHandler.html" title="class or interface in java.lang.reflect">InvocationHandler</A></DL><P><p><A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/reflect/InvocationHandler.html" title="class or interface in java.lang.reflect"><CODE>InvocationHandler</CODE></A> that forwards methods in an MBean's management interface through the MBean server to the MBean.</p> <p>Given an <A HREF="../../javax/management/MBeanServerConnection.html" title="interface in javax.management"><CODE>MBeanServerConnection</CODE></A>, the <A HREF="../../javax/management/ObjectName.html" title="class in javax.management"><CODE>ObjectName</CODE></A> of an MBean within that MBean server, and a Java interface <code>Intf</code> that describes the management interface of the MBean using the patterns for a Standard MBean, this class can be used to construct a proxy for the MBean. The proxy implements the interface <code>Intf</code> such that all of its methods are forwarded through the MBean server to the MBean.</p> <p>If you have an MBean server <code>mbs</code> containing an MBean with <A HREF="../../javax/management/ObjectName.html" title="class in javax.management"><CODE>ObjectName</CODE></A> <code>name</code>, and if the MBean's management interface is described by the Java interface <code>Intf</code>, you can construct a proxy for the MBean like this:</p> <pre> Intf proxy = (Intf) MBeanServerInvocationHandler.<A HREF="../../javax/management/MBeanServerInvocationHandler.html#newProxyInstance(javax.management.MBeanServerConnection, javax.management.ObjectName, java.lang.Class, boolean)"><CODE>newProxyInstance</CODE></A>(mbs, name, Intf.class, false); </pre> <p>Suppose, for example, <code>Intf</code> looks like this:</p> <pre> public interface Intf { public String getSomeAttribute(); public void setSomeAttribute(String value); public void someOperation(String param1, int param2); } </pre> <p>Then you can execute:</p> <ul> <li><code>proxy.getSomeAttribute()</code> which will result in a call to <code>mbs.</code><A HREF="../../javax/management/MBeanServerConnection.html#getAttribute(javax.management.ObjectName, java.lang.String)"><CODE>getAttribute</CODE></A><code>(name, "SomeAttribute")</code>. <li><code>proxy.setSomeAttribute("whatever")</code> which will result in a call to <code>mbs.</code><A HREF="../../javax/management/MBeanServerConnection.html#setAttribute(javax.management.ObjectName, javax.management.Attribute)"><CODE>setAttribute</CODE></A><code>(name, new Attribute("SomeAttribute", "whatever"))</code>. <li><code>proxy.someOperation("param1", 2)</code> which will be translated into a call to <code>mbs.</code><A HREF="../../javax/management/MBeanServerConnection.html#invoke(javax.management.ObjectName, java.lang.String, java.lang.Object[], java.lang.String[])"><CODE>invoke</CODE></A><code>(name, "someOperation", <etc>)</code>. </ul> <p>If the last parameter to <A HREF="../../javax/management/MBeanServerInvocationHandler.html#newProxyInstance(javax.management.MBeanServerConnection, javax.management.ObjectName, java.lang.Class, boolean)"><CODE>newProxyInstance</CODE></A> is <code>true</code>, then the MBean is assumed to be a <A HREF="../../javax/management/NotificationBroadcaster.html" title="interface in javax.management"><CODE>NotificationBroadcaster</CODE></A> or <A HREF="../../javax/management/NotificationEmitter.html" title="interface in javax.management"><CODE>NotificationEmitter</CODE></A> and the returned proxy will implement <A HREF="../../javax/management/NotificationEmitter.html" title="interface in javax.management"><CODE>NotificationEmitter</CODE></A>. A call to <A HREF="../../javax/management/NotificationBroadcaster.html#addNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object)"><CODE>NotificationBroadcaster.addNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object)</CODE></A> on the proxy will result in a call to <A HREF="../../javax/management/MBeanServerConnection.html#addNotificationListener(javax.management.ObjectName, javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object)"><CODE>MBeanServerConnection.addNotificationListener(ObjectName, NotificationListener, NotificationFilter, Object)</CODE></A>, and likewise for the other methods of <A HREF="../../javax/management/NotificationBroadcaster.html" title="interface in javax.management"><CODE>NotificationBroadcaster</CODE></A> and <A HREF="../../javax/management/NotificationEmitter.html" title="interface in javax.management"><CODE>NotificationEmitter</CODE></A>.</p> <p>The methods <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html#toString()" title="class or interface in java.lang"><CODE>Object.toString()</CODE></A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html#hashCode()" title="class or interface in java.lang"><CODE>Object.hashCode()</CODE></A>, and <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html#equals(java.lang.Object)" title="class or interface in java.lang"><CODE>Object.equals(Object)</CODE></A>, when invoked on a proxy using this invocation handler, are forwarded to the MBean server as methods on the proxied MBean. This will only work if the MBean declares those methods in its management interface.</p><P><P><DL><DT><B>Since:</B></DT> <DD>JMX 1.2</DD></DL><HR><P><!-- ======== NESTED CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><!-- ======== CONSTRUCTOR SUMMARY ======== --><A NAME="constructor_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Constructor Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../javax/management/MBeanServerInvocationHandler.html#MBeanServerInvocationHandler(javax.management.MBeanServerConnection, javax.management.ObjectName)">MBeanServerInvocationHandler</A></B>(<A HREF="../../javax/management/MBeanServerConnection.html" title="interface in javax.management">MBeanServerConnection</A> connection, <A HREF="../../javax/management/ObjectName.html" title="class in javax.management">ObjectName</A> objectName)</CODE><BR> Invocation handler that forwards methods through an MBean server. </TD></TR></TABLE> <!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -