You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2020/08/22 23:50:40 UTC
[qpid-broker-j] 03/05: QPID-8368: [Broker-J] Make GrayLogger
implementations conditionally available
This is an automated email from the ASF dual-hosted git repository.
orudyy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-broker-j.git
commit e89981067878c904786bb7ff1fb6aa51a002b8a9
Author: Alex Rudyy <or...@apache.org>
AuthorDate: Sat Aug 22 22:07:27 2020 +0100
QPID-8368: [Broker-J] Make GrayLogger implementations conditionally available
---
.../logging/logback/BrokerGraylogLoggerImpl.java | 3 +-
.../qpid/server/logging/logback/GelfCheck.java | 37 ++++++++++++++++++++++
.../logback/VirtualHostGraylogLoggerImpl.java | 3 +-
3 files changed, 41 insertions(+), 2 deletions(-)
diff --git a/broker-plugins/graylog-logging-logback/src/main/java/org/apache/qpid/server/logging/logback/BrokerGraylogLoggerImpl.java b/broker-plugins/graylog-logging-logback/src/main/java/org/apache/qpid/server/logging/logback/BrokerGraylogLoggerImpl.java
index 420d979..e75a6fd 100644
--- a/broker-plugins/graylog-logging-logback/src/main/java/org/apache/qpid/server/logging/logback/BrokerGraylogLoggerImpl.java
+++ b/broker-plugins/graylog-logging-logback/src/main/java/org/apache/qpid/server/logging/logback/BrokerGraylogLoggerImpl.java
@@ -41,7 +41,8 @@ import java.util.Set;
public class BrokerGraylogLoggerImpl extends AbstractBrokerLogger<BrokerGraylogLoggerImpl>
implements BrokerGraylogLogger<BrokerGraylogLoggerImpl>
{
- @ManagedObjectFactoryConstructor
+ @ManagedObjectFactoryConstructor(conditionallyAvailable = true,
+ condition = "org.apache.qpid.server.logging.logback.GelfCheck#isAvailable()")
public BrokerGraylogLoggerImpl(Map<String, Object> attributes, Broker<?> broker)
{
super(attributes, broker);
diff --git a/broker-plugins/graylog-logging-logback/src/main/java/org/apache/qpid/server/logging/logback/GelfCheck.java b/broker-plugins/graylog-logging-logback/src/main/java/org/apache/qpid/server/logging/logback/GelfCheck.java
new file mode 100644
index 0000000..3b21892
--- /dev/null
+++ b/broker-plugins/graylog-logging-logback/src/main/java/org/apache/qpid/server/logging/logback/GelfCheck.java
@@ -0,0 +1,37 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.logging.logback;
+
+public class GelfCheck
+{
+ public static boolean isAvailable()
+ {
+ try
+ {
+ Class.forName("de.siegmar.logbackgelf.GelfEncoder");
+ return true;
+ }
+ catch (ClassNotFoundException | NoClassDefFoundError e)
+ {
+ return false;
+ }
+ }
+}
diff --git a/broker-plugins/graylog-logging-logback/src/main/java/org/apache/qpid/server/logging/logback/VirtualHostGraylogLoggerImpl.java b/broker-plugins/graylog-logging-logback/src/main/java/org/apache/qpid/server/logging/logback/VirtualHostGraylogLoggerImpl.java
index de95e63..0a4f38c 100644
--- a/broker-plugins/graylog-logging-logback/src/main/java/org/apache/qpid/server/logging/logback/VirtualHostGraylogLoggerImpl.java
+++ b/broker-plugins/graylog-logging-logback/src/main/java/org/apache/qpid/server/logging/logback/VirtualHostGraylogLoggerImpl.java
@@ -92,7 +92,8 @@ public class VirtualHostGraylogLoggerImpl extends AbstractVirtualHostLogger<Virt
private AsyncAppender _appender;
- @ManagedObjectFactoryConstructor
+ @ManagedObjectFactoryConstructor(conditionallyAvailable = true,
+ condition = "org.apache.qpid.server.logging.logback.GelfCheck#isAvailable()")
public VirtualHostGraylogLoggerImpl(Map<String, Object> attributes, VirtualHost<?> virtualHost)
{
super(attributes, virtualHost);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org