001/* 002 * #%L 003 * Netarchivesuite - monitor 004 * %% 005 * Copyright (C) 2005 - 2018 The Royal Danish Library, 006 * the National Library of France and the Austrian National Library. 007 * %% 008 * This program is free software: you can redistribute it and/or modify 009 * it under the terms of the GNU Lesser General Public License as 010 * published by the Free Software Foundation, either version 2.1 of the 011 * License, or (at your option) any later version. 012 * 013 * This program is distributed in the hope that it will be useful, 014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 016 * GNU General Lesser Public License for more details. 017 * 018 * You should have received a copy of the GNU General Lesser Public 019 * License along with this program. If not, see 020 * <http://www.gnu.org/licenses/lgpl-2.1.html>. 021 * #L% 022 */ 023package dk.netarkivet.monitor.jmx; 024 025import java.util.Set; 026 027import javax.management.ObjectName; 028 029import dk.netarkivet.common.exceptions.ArgumentNotValid; 030import dk.netarkivet.common.exceptions.IOFailure; 031 032/** 033 * JMX interface for connection objects that can be used for accessing MBeans on remote servers. Connection method and 034 * policies are implementation-dependent. 035 */ 036public interface JMXProxyConnection { 037 /** 038 * Method to create a proxy to a given MBean on some remote server. Example use: 039 * <p> 040 * SingleLogRecord logMsg = (SingleLogRecord) myJMXProxyFactory.createProxy(myObjectName,SingleLogRecord.class); 041 * 042 * @param name The name of an MBean on some remote server. 043 * @param intf The interface that the returned proxy should implement. 044 * @param <T> 045 * @return an object implementing T. This object forwards all method calls to the named MBean. 046 */ 047 <T> T createProxy(ObjectName name, Class<T> intf); 048 049 /** 050 * Get the set of ObjectNames from the remote MBeanserver, that matches the given query. 051 * 052 * @param query the given query 053 * @return the set of ObjectNames, that matches the given query. 054 * @throws IOFailure on communication trouble. 055 * @throws ArgumentNotValid on null or empty query. 056 */ 057 Set<ObjectName> query(String query); 058 059 /** 060 * Returns true if this object still can return usable proxies. 061 * 062 * @return True if we can return usable proxies. Otherwise, somebody may have to make a new instance of 063 * JMXProxyFactory to get new proxies. 064 */ 065 boolean isLive(); 066}