From 6362c4404e289019adc482b71e98d9ac4c7313ee Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Wed, 9 Sep 2015 00:09:23 +0200 Subject: [PATCH] =?utf8?q?Added=20annotation=20@Log=20for=20type-safety,?= =?utf8?q?=20according=20to=20website=20Signed-off-by:Roland=20H=C3=A4der?= =?utf8?q?=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/java/org/mxchange/jcoreeelogger/Log.java | 36 +++++++++++++++++++ .../mxchange/jcoreeelogger/LoggerFactory.java | 1 + .../beans/local/logger/LoggerBean.java | 2 ++ 3 files changed, 39 insertions(+) create mode 100644 src/java/org/mxchange/jcoreeelogger/Log.java diff --git a/src/java/org/mxchange/jcoreeelogger/Log.java b/src/java/org/mxchange/jcoreeelogger/Log.java new file mode 100644 index 0000000..4f2a82c --- /dev/null +++ b/src/java/org/mxchange/jcoreeelogger/Log.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2015 KLC + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.jcoreeelogger; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import javax.inject.Qualifier; + +/** + * Logger annotation. This file has been taken from + * http://memorynotfound.com/java-se-unit-testing-cdi-junit-jboss-weld-se/ and has been slightly modified to make + * it compile + * + * @author Roland Haeder + */ +@Qualifier +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.TYPE, }) +public @interface Log { +} diff --git a/src/java/org/mxchange/jcoreeelogger/LoggerFactory.java b/src/java/org/mxchange/jcoreeelogger/LoggerFactory.java index a50873f..b9858b3 100644 --- a/src/java/org/mxchange/jcoreeelogger/LoggerFactory.java +++ b/src/java/org/mxchange/jcoreeelogger/LoggerFactory.java @@ -36,6 +36,7 @@ public class LoggerFactory { } @Produces + @Log public Logger getLogger (final InjectionPoint caller) { return LogManager.getLogger(caller.getMember().getDeclaringClass().getName()); } diff --git a/src/java/org/mxchange/jcoreeelogger/beans/local/logger/LoggerBean.java b/src/java/org/mxchange/jcoreeelogger/beans/local/logger/LoggerBean.java index 2ca017d..b1f0538 100644 --- a/src/java/org/mxchange/jcoreeelogger/beans/local/logger/LoggerBean.java +++ b/src/java/org/mxchange/jcoreeelogger/beans/local/logger/LoggerBean.java @@ -20,6 +20,7 @@ import javax.ejb.Singleton; import javax.ejb.Startup; import javax.inject.Inject; import org.apache.logging.log4j.Logger; +import org.mxchange.jcoreeelogger.Log; /** * A "centralized" logger bean @@ -34,6 +35,7 @@ public class LoggerBean implements LoggerBeanLocal { * Logger instance */ @Inject + @Log private Logger logger; @Override -- 2.39.5