1 // ======================================================================== 2 // Copyright (c) Webtide LLC 3 // ------------------------------------------------------------------------ 4 // All rights reserved. This program and the accompanying materials 5 // are made available under the terms of the Eclipse Public License v1.0 6 // and Apache License v2.0 which accompanies this distribution. 7 // The Eclipse Public License is available at 8 // http://www.eclipse.org/legal/epl-v10.html 9 // The Apache License v2.0 is available at 10 // http://www.opensource.org/licenses/apache2.0.php 11 // You may elect to redistribute this code under either of these licenses. 12 // ======================================================================== 13 14 package org.eclipse.jetty.monitor.integration; 15 16 import javax.management.MalformedObjectNameException; 17 import javax.management.ObjectName; 18 19 import org.eclipse.jetty.monitor.triggers.AttrEventTrigger; 20 21 22 /* ------------------------------------------------------------ */ 23 /** 24 */ 25 public class JavaMonitorTrigger <TYPE extends Comparable<TYPE>> 26 extends AttrEventTrigger<TYPE> 27 { 28 private final String _id; 29 private final String _name; 30 private final boolean _dynamic; 31 private int _count; 32 33 /* ------------------------------------------------------------ */ 34 /** 35 * @param nameObject 36 * @param attributeName 37 * @param id 38 * @param dynamic 39 * @throws IllegalArgumentException 40 */ 41 public JavaMonitorTrigger(ObjectName nameObject, String attributeName, String id, String name, boolean dynamic) 42 throws IllegalArgumentException 43 { 44 super(nameObject, attributeName); 45 46 _id = id; 47 _name = name; 48 _dynamic = dynamic; 49 } 50 51 /* ------------------------------------------------------------ */ 52 /** 53 * @see org.eclipse.jetty.monitor.triggers.AttrEventTrigger#match(java.lang.Comparable) 54 */ 55 @Override 56 public boolean match(Comparable<TYPE> value) 57 { 58 return _dynamic ? true : (_count++ < 1); 59 } 60 61 protected boolean getSaveAll() 62 { 63 return false; 64 } 65 66 @Override 67 public String getID() 68 { 69 return _id; 70 } 71 72 @Override 73 public String getNameString() 74 { 75 return _name; 76 } 77 }