249 // not found - load any new monitors, and try again.
250 getNewMonitors(monitors);
251 m = monitors.get(name);
252 }
253 if (m == null) {
254 // still not found, look for aliases
255 m = findByAlias(name);
256 }
257 }
258 return m;
259 }
260
261 /**
262 * Find all Instrumentation objects with names matching the given pattern.
263 *
264 * This method returns a {@link List} of Monitor objects such that
265 * the name of each object matches the given pattern.
266 *
267 * @param patternString a string containing a pattern as described in
268 * {@link java.util.regex.Pattern}.
269 * @return List<Monitor> - a List of {@link Monitor} objects that can be used to
270 * monitor the instrumentation objects whose names match
271 * the given pattern. If no instrumentation objects have`
272 * names matching the given pattern, then an empty List
273 * is returned.
274 * @throws MonitorException Thrown if an error occurs while communicating
275 * with the target Java Virtual Machine.
276 * @see java.util.regex.Pattern
277 */
278 public List<Monitor> findByPattern(String patternString)
279 throws MonitorException, PatternSyntaxException {
280
281 synchronized(this) {
282 if (monitors.isEmpty()) {
283 buildMonitorMap(monitors);
284 } else {
285 getNewMonitors(monitors);
286 }
287 }
288
289 Pattern pattern = Pattern.compile(patternString);
|
249 // not found - load any new monitors, and try again.
250 getNewMonitors(monitors);
251 m = monitors.get(name);
252 }
253 if (m == null) {
254 // still not found, look for aliases
255 m = findByAlias(name);
256 }
257 }
258 return m;
259 }
260
261 /**
262 * Find all Instrumentation objects with names matching the given pattern.
263 *
264 * This method returns a {@link List} of Monitor objects such that
265 * the name of each object matches the given pattern.
266 *
267 * @param patternString a string containing a pattern as described in
268 * {@link java.util.regex.Pattern}.
269 * @return {@code List<Monitor>} - a List of {@link Monitor}
270 * objects that can be used to
271 * monitor the instrumentation objects whose names match
272 * the given pattern. If no instrumentation objects have`
273 * names matching the given pattern, then an empty List
274 * is returned.
275 * @throws MonitorException Thrown if an error occurs while communicating
276 * with the target Java Virtual Machine.
277 * @see java.util.regex.Pattern
278 */
279 public List<Monitor> findByPattern(String patternString)
280 throws MonitorException, PatternSyntaxException {
281
282 synchronized(this) {
283 if (monitors.isEmpty()) {
284 buildMonitorMap(monitors);
285 } else {
286 getNewMonitors(monitors);
287 }
288 }
289
290 Pattern pattern = Pattern.compile(patternString);
|