@Test public void testMonitorFactoryGroupCache() throws Exception { Monitor monitor1 = monitorFactory.getMonitor(URL.valueOf("dubbo: Monitor monitor2 = monitorFactory.getMonitor(URL.valueOf("dubbo: Assert.assertNotSame(monitor1, monitor2); }
public Monitor getMonitor(URL url) { url = url.setPath(MonitorService.class.getName()).addParameter(Constants.INTERFACE_KEY, MonitorService.class.getName()); String key = url.toServiceString(); LOCK.lock(); try { Monitor monitor = MONITORS.get(key); if (monitor != null) { return monitor; } monitor = createMonitor(url); if (monitor == null) { throw new IllegalStateException("Can not create monitor " + url); } MONITORS.put(key, monitor); return monitor; } finally { LOCK.unlock(); } }
AbstractMonitorFactory implements MonitorFactory { public Monitor getMonitor(URL url) { url = url.setPath(MonitorService.class.getName()).addParameter(Constants.INTERFACE_KEY, MonitorService.class.getName()); String key = url.toServiceString(); LOCK.lock(); try { Monitor monitor = MONITORS.get(key); if (monitor != null) { return monitor; } monitor = createMonitor(url); if (monitor == null) { throw new IllegalStateException("Can not create monitor " + url); } MONITORS.put(key, monitor); return monitor; } finally { LOCK.unlock(); } } }
AbstractMonitorFactory implements MonitorFactory { public Monitor getMonitor(URL url) { url = url.setPath(MonitorService.class.getName()).addParameter(Constants.INTERFACE_KEY, MonitorService.class.getName()); String key = url.toServiceString(); LOCK.lock(); try { Monitor monitor = MONITORS.get(key); if (monitor != null) { return monitor; } monitor = createMonitor(url); if (monitor == null) { throw new IllegalStateException("Can not create monitor " + url); } MONITORS.put(key, monitor); return monitor; } finally { LOCK.unlock(); } }  }
AbstractMonitorFactory implements MonitorFactory { public Monitor getMonitor(URL url) { url = url.setPath(MonitorService.class.getName()).addParameter(Constants.INTERFACE_KEY, MonitorService.class.getName()); String key = url.toServiceString(); LOCK.lock(); try { Monitor monitor = MONITORS.get(key); if (monitor != null) { return monitor; } monitor = createMonitor(url); if (monitor == null) { throw new IllegalStateException("Can not create monitor " + url); } MONITORS.put(key, monitor); return monitor; } finally { LOCK.unlock(); } }  static Collection<Monitor> getMonitors(); Monitor getMonitor(URL url); }
AbstractMonitorFactory implements MonitorFactory { public Monitor getMonitor(URL url) { url = url.setPath(MonitorService.class.getName()).addParameter(Constants.INTERFACE_KEY, MonitorService.class.getName()); String key = url.toServiceString(); LOCK.lock(); try { Monitor monitor = MONITORS.get(key); if (monitor != null) { return monitor; } monitor = createMonitor(url); if (monitor == null) { throw new IllegalStateException("Can not create monitor " + url); } MONITORS.put(key, monitor); return monitor; } finally { LOCK.unlock(); } }  static Collection<Monitor> getMonitors(); Monitor getMonitor(URL url);  }