1 //
2 // ========================================================================
3 // Copyright (c) 1995-2016 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 * @param <TYPE> the trigger type
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 public JavaMonitorTrigger(ObjectName nameObject, String attributeName, String id, String name, boolean dynamic)
39 throws IllegalArgumentException
40 {
41 super(nameObject, attributeName);
42
43 _id = id;
44 _name = name;
45 _dynamic = dynamic;
46 }
47
48 /* ------------------------------------------------------------ */
49 /**
50 * @see org.eclipse.jetty.monitor.triggers.AttrEventTrigger#match(java.lang.Comparable)
51 */
52 @Override
53 public boolean match(Comparable<TYPE> value)
54 {
55 return _dynamic ? true : (_count++ < 1);
56 }
57
58 protected boolean getSaveAll()
59 {
60 return false;
61 }
62
63 @Override
64 public String getID()
65 {
66 return _id;
67 }
68
69 @Override
70 public String getNameString()
71 {
72 return _name;
73 }
74 }