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
15 package org.eclipse.jetty.monitor.jmx;
16
17 import static java.util.UUID.randomUUID;
18
19 /* ------------------------------------------------------------ */
20 /**
21 * EventTrigger
22 *
23 * Abstract base class for all EventTrigger implementations.
24 * Used to determine whether the necessary conditions for
25 * triggering an event are present.
26 */
27 public abstract class EventTrigger
28 {
29 private final String _id;
30
31 /* ------------------------------------------------------------ */
32 /**
33 * Construct an event trigger
34 */
35 public EventTrigger()
36 {
37 _id = randomUUID().toString();
38 }
39
40 /* ------------------------------------------------------------ */
41 /**
42 * Retrieve the identification string of the event trigger
43 *
44 * @return unique identification string
45 */
46 public String getID()
47 {
48 return _id;
49 }
50
51 /* ------------------------------------------------------------ */
52 /**
53 * Abstract method to verify if the event trigger conditions
54 * are in the appropriate state for an event to be triggered
55 *
56 * @return true to trigger an event
57 */
58 public abstract boolean match(long timestamp) throws Exception;
59
60 /* ------------------------------------------------------------ */
61 /**
62 * Retrieve the event state associated with specified invocation
63 * of the event trigger match method
64 *
65 * @param timestamp time stamp associated with invocation
66 * @return event state or null if not found
67 */
68 public abstract EventState<?> getState(long timestamp);
69 }