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