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.MalformedObjectNameException; 22 import javax.management.ObjectName; 23 24 import org.eclipse.jetty.monitor.triggers.AttrEventTrigger; 25 26 27 /* ------------------------------------------------------------ */ 28 /** 29 */ 30 public class JavaMonitorTrigger <TYPE extends Comparable<TYPE>> 31 extends AttrEventTrigger<TYPE> 32 { 33 private final String _id; 34 private final String _name; 35 private final boolean _dynamic; 36 private int _count; 37 38 /* ------------------------------------------------------------ */ 39 /** 40 * @param nameObject 41 * @param attributeName 42 * @param id 43 * @param dynamic 44 * @throws IllegalArgumentException 45 */ 46 public JavaMonitorTrigger(ObjectName nameObject, String attributeName, String id, String name, boolean dynamic) 47 throws IllegalArgumentException 48 { 49 super(nameObject, attributeName); 50 51 _id = id; 52 _name = name; 53 _dynamic = dynamic; 54 } 55 56 /* ------------------------------------------------------------ */ 57 /** 58 * @see org.eclipse.jetty.monitor.triggers.AttrEventTrigger#match(java.lang.Comparable) 59 */ 60 @Override 61 public boolean match(Comparable<TYPE> value) 62 { 63 return _dynamic ? true : (_count++ < 1); 64 } 65 66 protected boolean getSaveAll() 67 { 68 return false; 69 } 70 71 @Override 72 public String getID() 73 { 74 return _id; 75 } 76 77 @Override 78 public String getNameString() 79 { 80 return _name; 81 } 82 }