Refactor Java agent to let applications manage the log handlers
[lttng-ust.git] / liblttng-ust-java-agent / java / lttng-ust-agent-common / org / lttng / ust / agent / ILttngAgent.java
diff --git a/liblttng-ust-java-agent/java/lttng-ust-agent-common/org/lttng/ust/agent/ILttngAgent.java b/liblttng-ust-java-agent/java/lttng-ust-agent-common/org/lttng/ust/agent/ILttngAgent.java
new file mode 100644 (file)
index 0000000..044bdf0
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2015 - EfficiOS Inc., Alexandre Montplaisir <alexmonthy@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License, version 2.1 only,
+ * as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.lttng.ust.agent;
+
+/**
+ * Interface to define LTTng Java agents.
+ *
+ * An "agent" is a representative of an LTTng session daemon in the Java world.
+ * It tracks the settings of a tracing session as they defined in the session
+ * daemon.
+ *
+ * It also track the current logging handlers that are sending events to UST.
+ *
+ * @author Alexandre Montplaisir
+ *
+ * @param <T>
+ *            The type of logging handler that should register to this agent
+ */
+public interface ILttngAgent<T extends ILttngHandler> {
+
+       // ------------------------------------------------------------------------
+       // Agent configuration elements
+       // ------------------------------------------------------------------------
+
+       /**
+        * Tracing domains. Corresponds to domains defined by LTTng Tools.
+        */
+       enum Domain {
+               JUL(3), LOG4J(4);
+               private int value;
+
+               private Domain(int value) {
+                       this.value = value;
+               }
+
+               public int value() {
+                       return value;
+               }
+       }
+
+       /**
+        * The tracing domain of this agent.
+        *
+        * @return The tracing domain.
+        */
+       Domain getDomain();
+
+       // ------------------------------------------------------------------------
+       // Log handler registering
+       // ------------------------------------------------------------------------
+
+       /**
+        * Register a handler to this agent.
+        *
+        * @param handler
+        *            The handler to register
+        */
+       void registerHandler(T handler);
+
+       /**
+        * Deregister a handler from this agent.
+        *
+        * @param handler
+        *            The handler to deregister.
+        */
+       void unregisterHandler(T handler);
+
+       // ------------------------------------------------------------------------
+       // Tracing session parameters
+       // ------------------------------------------------------------------------
+
+       /**
+        * Query if a given event is currently enabled in a current tracing session,
+        * meaning it should be sent to UST. May be quicker than listing all events
+        * via {@link #listEnabledEvents()}.
+        *
+        * @param eventName
+        *            The name of the event to check.
+        * @return True if the event is currently enabled, false if it is not.
+        */
+       boolean isEventEnabled(String eventName);
+
+       /**
+        * List the all events currently enabled in the current tracing sessions.
+        *
+        * @return The list of enabled events
+        */
+       Iterable<String> listEnabledEvents();
+}
This page took 0.025923 seconds and 4 git commands to generate.