From: Roland Haeder Date: Wed, 9 Sep 2015 08:17:20 +0000 (+0200) Subject: Log and LoggerFactory must still reside in same package ... Well, the beans.xml did... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2af92daaf61e66fe580a88b3fdcace47b6af0ce5;p=jcore-logger-ejb.git Log and LoggerFactory must still reside in same package ... Well, the beans.xml did the final trick. Signed-off-by:Roland Häder --- diff --git a/lib/jshop-ee-lib.jar b/lib/jshop-ee-lib.jar index e9ef1ea..657fb70 100644 Binary files a/lib/jshop-ee-lib.jar and b/lib/jshop-ee-lib.jar differ diff --git a/src/conf/beans.xml b/src/conf/beans.xml new file mode 100644 index 0000000..0f4e2aa --- /dev/null +++ b/src/conf/beans.xml @@ -0,0 +1,6 @@ + + + diff --git a/src/java/log4j2.xml b/src/java/log4j2.xml new file mode 100644 index 0000000..1ebbd9f --- /dev/null +++ b/src/java/log4j2.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + diff --git a/src/java/org/mxchange/jcoreeelogger/Log.java b/src/java/org/mxchange/jcoreeelogger/Log.java deleted file mode 100644 index 4f2a82c..0000000 --- a/src/java/org/mxchange/jcoreeelogger/Log.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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 deleted file mode 100644 index b9858b3..0000000 --- a/src/java/org/mxchange/jcoreeelogger/LoggerFactory.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 javax.enterprise.inject.Produces; -import javax.enterprise.inject.spi.InjectionPoint; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -public class LoggerFactory { - - /** - * Own logger - */ - private final Logger logger; - - /** - * Factory method - */ - public LoggerFactory () { - this.logger = LogManager.getLogger(this.getClass().getName()); - } - - @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/Log.java b/src/java/org/mxchange/jcoreeelogger/beans/local/logger/Log.java new file mode 100644 index 0000000..3aba73f --- /dev/null +++ b/src/java/org/mxchange/jcoreeelogger/beans/local/logger/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.beans.local.logger; + +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 work. + * + * @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/beans/local/logger/LoggerBean.java b/src/java/org/mxchange/jcoreeelogger/beans/local/logger/LoggerBean.java index b1f0538..a64cd8a 100644 --- a/src/java/org/mxchange/jcoreeelogger/beans/local/logger/LoggerBean.java +++ b/src/java/org/mxchange/jcoreeelogger/beans/local/logger/LoggerBean.java @@ -20,7 +20,6 @@ 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 @@ -38,6 +37,12 @@ public class LoggerBean implements LoggerBeanLocal { @Log private Logger logger; + /** + * Default constructor + */ + public LoggerBean () { + } + @Override public void logDebug (final String message) { // Deligate to logger diff --git a/src/java/org/mxchange/jcoreeelogger/beans/local/logger/LoggerFactory.java b/src/java/org/mxchange/jcoreeelogger/beans/local/logger/LoggerFactory.java new file mode 100644 index 0000000..0fec8f1 --- /dev/null +++ b/src/java/org/mxchange/jcoreeelogger/beans/local/logger/LoggerFactory.java @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2015 Roland Haeder + * + * 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.beans.local.logger; + +import javax.enterprise.inject.Produces; +import javax.enterprise.inject.spi.InjectionPoint; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +/** + * A logger factory + * + * @author Roland Haeder + */ +public class LoggerFactory { + + /** + * Own logger + */ + private final Logger logger; + + /** + * Factory method + */ + public LoggerFactory () { + this.logger = LogManager.getLogger(this.getClass().getName()); + } + + @Produces + @Log + public Logger getLogger (final InjectionPoint caller) { + return LogManager.getLogger(caller.getMember().getDeclaringClass().getName()); + } +}