/** * Allows the MBean to perform any operations it needs before being registered in the MBean * server. If the name of the MBean is not specified, the MBean can provide a name for its * registration. If any exception is raised, the MBean will not be registered in the MBean server. * * @param server The MBean server in which the MBean will be registered. * @param name The object name of the MBean. * @return The name of the MBean registered. * @exception java.lang.Exception This exception should be caught by the MBean server and * re-thrown as an {@link javax.management.MBeanRegistrationException}. */ public ObjectName preRegister(MBeanServer server, ObjectName name) throws java.lang.Exception { if (logger.finerOn()) { logger.finer("preRegister ", "object name = " + name); } responderObjectName = name; // ---------------- // Should we act as a spy ? // ---------------- spy = (String) name.getKeyProperty(SPY); // ---------------- // Should we Send event // ---------------- noEvent = (String) name.getKeyProperty("PRIVATE_NO_EVENT"); // ---------------- // Initialise local pointer to the Core Management MBeanServer // ---------------- this.cmf = server; // ---------------- // Return part // ---------------- return name; }
public synchronized Collection<GarbageCollectorMXBean> getGarbageCollectorMXBeans() throws IOException { // TODO: How to deal with changes to the list?? if (garbageCollectorMBeans == null) { ObjectName gcName = null; try { gcName = new ObjectName(GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + ",*"); } catch (MalformedObjectNameException e) { // should not reach here assert (false); } Set<ObjectName> mbeans = server.queryNames(gcName, null); if (mbeans != null) { garbageCollectorMBeans = new ArrayList<GarbageCollectorMXBean>(); Iterator<ObjectName> iterator = mbeans.iterator(); while (iterator.hasNext()) { ObjectName on = (ObjectName) iterator.next(); String name = GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + ",name=" + on.getKeyProperty("name"); GarbageCollectorMXBean mBean = newPlatformMXBeanProxy(server, name, GarbageCollectorMXBean.class); garbageCollectorMBeans.add(mBean); } } } return garbageCollectorMBeans; }
/** * Allows the MBean to perform any operations it needs before being registered in the MBean * server. If the name of the MBean is not specified, the MBean can provide a name for its * registration. If any exception is raised, the MBean will not be registered in the MBean server. * * @param server The MBean server in which the MBean will be registered. * @param name The object name of the MBean. This name is null if the name parameter to one of the * createMBean or registerMBean methods in the MBeanServer interface is null. In that case, * this method will try to guess its MBean name by examining its configuration data. If its * configuration data is null (nothing was provided in the constructor) or doesn't contain a * name, this method returns {@code null}, and registration will fail. * <p>Otherwise, if {@code name} wasn't {@code null} or if a default name could be * constructed, the name of the configuration will be set to the value of the ObjectName's * {@code name=} key, and the configuration data will always be renamed to reflect this * change. * @return The name under which the MBean is to be registered. * @throws Exception This exception will be caught by the MBean server and re-thrown as an * MBeanRegistrationException. */ public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception { if (name == null) { if (config == null) return null; if (config.getName() == null) return null; name = ScanManager.makeMBeanName(ScanDirConfigMXBean.class, config.getName()); } objectName = name; mbeanServer = server; synchronized (this) { configname = name.getKeyProperty("name"); if (config == null) config = new ScanManagerConfig(configname); else config = config.copy(configname); } return name; }