001    // jademx - JADE management using JMX
002    // Copyright 2005 Caboodle Networks, Inc.
003    //
004    // This library is free software; you can redistribute it and/or
005    // modify it under the terms of the GNU Lesser General Public
006    // License as published by the Free Software Foundation; either
007    // version 2.1 of the License, or (at your option) any later version.
008    //
009    // This library is distributed in the hope that it will be useful,
010    // but WITHOUT ANY WARRANTY; without even the implied warranty of
011    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012    // Lesser General Public License for more details.
013    //
014    // You should have received a copy of the GNU Lesser General Public
015    // License along with this library; if not, write to the Free Software
016    // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
017    
018    package jade.jademx.agent;
019    
020    import jade.jademx.mbean.JademxException;
021    
022    import javax.management.MBeanServer;
023    import javax.management.ObjectName;
024    
025    /** 
026     * proxy agent corresponding to JademxPingAgent.
027     * The purpose of this class is to have access to the dynamic JMX interface
028     * presented by a JademxAgent without having to use the cumbersome dynamic
029     * syntax for interacting with that interface.
030     * @author David Bernstein, <a href="http://www.caboodlenetworks.com"
031     *  >Caboodle Networks, Inc.</a>
032     */
033    public class JademxPingAgentProxy extends JademxAgentProxy {
034        
035        /**
036         * make a JademxPingAgentProxy
037         * @param objectName agent's ObjectName
038         * @param mBeanServer agent's MBeanServer
039         */
040        public JademxPingAgentProxy( ObjectName objectName, MBeanServer mBeanServer ) {
041            super( objectName, mBeanServer );
042        }
043        
044        //
045        // PROXIED METHODS
046        //
047        
048        // attribute Response
049        
050        /**
051         * proxy for @see JademxPingAgent#setResponse(String)
052         * @param response response to set
053         * @throws JademxException on problem
054         */
055        public void setResponse( String response ) throws JademxException {
056            setAttribute( JademxPingAgent.ATTR_RESPONSE_NAME, response );
057        }
058        
059        /**
060         * proxy for @see JademxPingAgent#getResponse()
061         * @return response
062         * @throws JademxException on problem
063         */
064        public String getResponse() throws JademxException  {
065            return (String)getAttribute( JademxPingAgent.ATTR_RESPONSE_NAME );
066        }
067        
068        // operation ping
069        
070        /**
071         * proxy for @see JademxPingAgent#ping(String)
072         * @return current response
073         * @throws JademxException on problem
074         */
075        public String ping( String pingeeAgentFullName ) throws JademxException {
076            return (String)invoke( 
077                    JademxPingAgent.OPER_PING_NAME, 
078                    new Object[]{ pingeeAgentFullName },
079                    JademxPingAgent.OPER_PING_SIGNATURE );
080        }
081        
082    }