From: Roland Haeder Date: Tue, 8 Sep 2015 22:09:23 +0000 (+0200) Subject: Added annotation @Log for type-safety, according to website X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6362c4404e289019adc482b71e98d9ac4c7313ee;p=jcore-logger-ejb.git Added annotation @Log for type-safety, according to website Signed-off-by:Roland Häder --- 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