From: Roland Haeder Date: Tue, 8 Sep 2015 21:37:06 +0000 (+0200) Subject: Changed jcore-ee-logger to a EJB (not really, but maybe this way it works???) + got... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=52efbabef0bd57d570b2ed1effc880f8598241fc;p=jcore-logger-ejb.git Changed jcore-ee-logger to a EJB (not really, but maybe this way it works???) + got rid of no more needed jars Signed-off-by:Roland Häder --- diff --git a/build.xml b/build.xml index 8f572f5..00f31ae 100644 --- a/build.xml +++ b/build.xml @@ -7,7 +7,7 @@ - + Builds, tests, and runs the project jcore-ee-logger. diff --git a/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar b/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar index eaf6790..2cc00f0 100644 Binary files a/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar and b/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar differ diff --git a/lib/javaee-api-7.0/javaee-api-7.0.jar b/lib/javaee-api-7.0/javaee-api-7.0.jar deleted file mode 100644 index 9e38d4c..0000000 Binary files a/lib/javaee-api-7.0/javaee-api-7.0.jar and /dev/null differ diff --git a/lib/javaee-api-7.0/javaee-doc-api.jar b/lib/javaee-api-7.0/javaee-doc-api.jar deleted file mode 100644 index 2859e3d..0000000 Binary files a/lib/javaee-api-7.0/javaee-doc-api.jar and /dev/null differ diff --git a/lib/jcore.jar b/lib/jcore.jar deleted file mode 100644 index 217c364..0000000 Binary files a/lib/jcore.jar and /dev/null differ diff --git a/lib/nblibraries.properties b/lib/nblibraries.properties index 1f1df42..6d0afb5 100644 --- a/lib/nblibraries.properties +++ b/lib/nblibraries.properties @@ -2,9 +2,3 @@ libs.CopyLibs.classpath=\ ${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar libs.CopyLibs.displayName=CopyLibs Task libs.CopyLibs.prop-version=2.0 -libs.javaee-api-7.0.classpath=\ - ${base}/javaee-api-7.0/javaee-api-7.0.jar -libs.javaee-api-7.0.displayName=Java EE 7 API Library -libs.javaee-api-7.0.javadoc=\ - ${base}/javaee-api-7.0/javaee-doc-api.jar -libs.javaee-api-7.0.prop-maven-dependencies=javax:javaee-api:7.0:jar diff --git a/nbproject/ant-deploy.xml b/nbproject/ant-deploy.xml new file mode 100644 index 0000000..2d5f877 --- /dev/null +++ b/nbproject/ant-deploy.xml @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml index 50db30a..3a9d199 100644 --- a/nbproject/build-impl.xml +++ b/nbproject/build-impl.xml @@ -8,42 +8,35 @@ is divided into following sections: - initialization - compilation - - jar + - dist - execution - debugging - javadoc - - test compilation - - test execution - - test debugging - - applet - cleanup --> - - + + + - + - + - - - + @@ -67,84 +60,23 @@ is divided into following sections: - + + + + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + @@ -162,25 +94,42 @@ is divided into following sections: + + + + + - - + + - - - - + + + + + + + + + + + + + - - - + + + + + - @@ -192,21 +141,18 @@ is divided into following sections: - - - - - - - + - - + + + + + @@ -217,10 +163,6 @@ is divided into following sections: - - - - @@ -243,24 +185,52 @@ is divided into following sections: + + + + + + + + - + Must set src.dir Must set test.src.dir Must set build.dir + Must set build.generated.dir Must set dist.dir Must set build.classes.dir Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir Must set build.classes.excludes Must set dist.jar + + + + + + + + + +The Java EE server classpath is not correctly set up - server home directory is missing. +Either open the project in the IDE and assign the server or setup the server classpath manually. +For example like this: + ant -Dj2ee.server.home=<app_server_installation_directory> + + +The Java EE server classpath is not correctly set up. Your active server type is ${j2ee.server.type}. +Either open the project in the IDE and assign the server or setup the server classpath manually. +For example like this: + ant -Duser.properties.file=<path_to_property_file> (where you put the property "j2ee.platform.classpath" in a .properties file) +or ant -Dj2ee.platform.classpath=<server_classpath> (where no properties file is used) + - + @@ -269,23 +239,23 @@ is divided into following sections: - + - + - + - + @@ -295,12 +265,10 @@ is divided into following sections: - - @@ -310,22 +278,22 @@ is divided into following sections: - + - + - + - + @@ -335,7 +303,6 @@ is divided into following sections: - @@ -343,10 +310,10 @@ is divided into following sections: - + - + @@ -355,7 +322,7 @@ is divided into following sections: - + Must set javac.includes @@ -370,9 +337,7 @@ is divided into following sections: - - - + @@ -398,15 +363,14 @@ is divided into following sections: - + - - + @@ -421,15 +385,15 @@ is divided into following sections: - + - - + + @@ -445,6 +409,7 @@ is divided into following sections: + @@ -452,7 +417,7 @@ is divided into following sections: - + @@ -468,7 +433,7 @@ is divided into following sections: - + @@ -480,7 +445,7 @@ is divided into following sections: - + @@ -492,63 +457,63 @@ is divided into following sections: - + - + - + - + - + - + - + - + + + - - + - + - + - - + @@ -565,15 +530,15 @@ is divided into following sections: - + - - + + @@ -589,6 +554,7 @@ is divided into following sections: + @@ -597,21 +563,21 @@ is divided into following sections: - + - + - + - + @@ -624,33 +590,32 @@ is divided into following sections: - + - - + - + - + - + - + @@ -658,21 +623,22 @@ is divided into following sections: - + + + - - + - + - + @@ -680,52 +646,28 @@ is divided into following sections: - + - + - - - - - - - - - - - - - - - - - - - + + - - - + - - - - + - + @@ -736,27 +678,19 @@ is divided into following sections: - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - + - - + - + @@ -766,6 +700,11 @@ is divided into following sections: + + + + + @@ -788,98 +727,41 @@ is divided into following sections: - + + - - + - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +The libs.CopyLibs.classpath property is not set up. +This property must point to +org-netbeans-modules-java-j2seproject-copylibstask.jar file which is part +of NetBeans IDE installation and is usually located at +<netbeans_installation>/java<version>/ant/extra folder. +Either open the project in the IDE and make sure CopyLibs library +exists or setup the property manually. For example like this: + ant -Dlibs.CopyLibs.classpath=a/path/to/org-netbeans-modules-java-j2seproject-copylibstask.jar + + - @@ -900,264 +782,268 @@ is divided into following sections: - - - - - - - - - - - - - - - - + + + + - - - + + + - - + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + + + + + + + + + - - - - + + + + - + Must select some files in the IDE or set javac.includes - - + - + - - - - - + - - - - - - - - - - - - + + + + + + - - - - + + + + + + - - - - - - - + + + + + + + - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - + + + + + + - - - - + + + + + + + + + + - - - + - - + + - - - - - - + + + + + + + + + + + - - + + + - - Must select one file in the IDE or set run.class - + + + - + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class - + + + + - - + + + - - - - - - - - - + + + + + + + + + + + + - - - + + - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - + Must select one file in the IDE or set main.class + - + Must set fix.includes - + - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - + + + + + + This target only works when run from inside the NetBeans IDE. + @@ -1167,6 +1053,7 @@ is divided into following sections: + @@ -1176,8 +1063,21 @@ is divided into following sections: + + + + + + + + + + + + + @@ -1187,61 +1087,38 @@ is divided into following sections: - + - + + + - - Must select one file in the IDE or set run.class - - + + - - - Must select some files in the IDE or set test.includes + + - - Must select one file in the IDE or set run.class - - - - - Must select one file in the IDE or set applet.url - - + + - + - - - - - - - - - - - - + - + - + - - @@ -1252,27 +1129,23 @@ is divided into following sections: - + - + + - - - - - + + @@ -1286,13 +1159,9 @@ is divided into following sections: - + Must select some files in the IDE or set javac.includes - - - - - + @@ -1300,15 +1169,13 @@ is divided into following sections: - + Some tests failed; see details above. @@ -1321,7 +1188,7 @@ is divided into following sections: Must select some files in the IDE or set test.includes - + Some tests failed; see details above. @@ -1330,109 +1197,48 @@ is divided into following sections: Must select some files in the IDE or set test.class Must select some method in the IDE or set test.method - + Some tests failed; see details above. Must select one file in the IDE or set test.class - + Must select one file in the IDE or set test.class Must select some method in the IDE or set test.method - + - + - + - + - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - + - + - - - - - - - - - - - - - - - - - - - + + + + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties index 3a96618..c1f6051 100644 --- a/nbproject/genfiles.properties +++ b/nbproject/genfiles.properties @@ -1,8 +1,8 @@ -build.xml.data.CRC32=6405b2ee -build.xml.script.CRC32=b92565f5 -build.xml.stylesheet.CRC32=8064a381@1.75.2.48 +build.xml.data.CRC32=2d3b532f +build.xml.script.CRC32=122158a6 +build.xml.stylesheet.CRC32=5910fda3@1.51.1 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=6405b2ee -nbproject/build-impl.xml.script.CRC32=dae3119a -nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48 +nbproject/build-impl.xml.data.CRC32=2d3b532f +nbproject/build-impl.xml.script.CRC32=0ca2d175 +nbproject/build-impl.xml.stylesheet.CRC32=6096d939@1.51.1 diff --git a/nbproject/project.properties b/nbproject/project.properties index c06c85a..8e47e03 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -3,47 +3,49 @@ annotation.processing.enabled.in.editor=true annotation.processing.processors.list= annotation.processing.run.all.processors=true annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output -application.title=jcore-ee-logger -application.vendor=Roland Haeder -auxiliary.org-netbeans-spi-editor-hints-projects.perProjectHintSettingsFile=nbproject/cfg_hints.xml build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form -# This directory is removed when the project is cleaned: +build.classes.excludes=**/*.java,**/*.form,**/.nbattrs build.dir=build +build.ear.classes.dir=${build.dir}/classes build.generated.dir=${build.dir}/generated build.generated.sources.dir=${build.dir}/generated-sources -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore build.test.classes.dir=${build.dir}/test/classes build.test.results.dir=${build.dir}/test/results -# Uncomment to specify the preferred debugger connection transport: -#debug.transport=dt_socket -debug.classpath=\ - ${run.classpath} +debug.classpath=${javac.classpath}:${build.classes.dir} debug.test.classpath=\ ${run.test.classpath} -# Files in build.classes.dir which should be excluded from distribution jar -dist.archive.excludes= -# This directory is removed when the project is cleaned: dist.dir=dist -dist.jar=${dist.dir}/jcore-ee-logger.jar +dist.ear.jar=${dist.dir}/${jar.name} +dist.jar=${dist.dir}/${jar.name} dist.javadoc.dir=${dist.dir}/javadoc endorsed.classpath= excludes= +file.reference.cdi-api.jar=lib/cdi-api.jar +file.reference.jshop-ee-lib.jar=lib/jshop-ee-lib.jar file.reference.log4j-api-2.3.jar=lib/log4j-api-2.3.jar file.reference.log4j-core-2.3.jar=lib/log4j-core-2.3.jar file.reference.log4j-web-2.3.jar=lib/log4j-web-2.3.jar includes=** -jar.archive.disabled=${jnlp.enabled} +j2ee.compile.on.save=true +j2ee.deploy.on.save=true +j2ee.platform=1.5 +j2ee.platform.classpath=${j2ee.server.middleware}/mq/lib/jaxm-api.jar:${j2ee.server.home}/modules/endorsed/javax.annotation-api.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api.jar:${j2ee.server.home}/modules/javax.batch-api.jar:${j2ee.server.home}/modules/javax.security.auth.message-api.jar:${j2ee.server.home}/modules/javax.faces.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl-api.jar:${j2ee.server.home}/modules/javax.transaction-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/javax.interceptor-api.jar:${j2ee.server.home}/modules/javax.inject.jar:${j2ee.server.home}/modules/javax.resource-api.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent-api.jar:${j2ee.server.home}/modules/javax.el.jar:${j2ee.server.home}/modules/javax.ejb-api.jar:${j2ee.server.home}/modules/javax.xml.rpc-api.jar:${j2ee.server.home}/modules/javax.security.jacc-api.jar:${j2ee.server.home}/modules/javax.json.jar:${j2ee.server.home}/modules/javax.xml.registry-api.jar:${j2ee.server.home}/modules/javax.websocket-api.jar:${j2ee.server.home}/modules/javax.management.j2ee-api.jar:${j2ee.server.home}/modules/javax.servlet-api.jar:${j2ee.server.home}/modules/javax.jms-api.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.home}/modules/javax.enterprise.deploy-api.jar:${j2ee.server.home}/modules/bean-validator.jar:${j2ee.server.home}/modules/javax.ws.rs-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp-api.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/weld-osgi-bundle.jar:${j2ee.server.home}/modules/javax.persistence.jar +j2ee.platform.embeddableejb.classpath=${j2ee.server.home}/lib/embedded/glassfish-embedded-static-shell.jar +j2ee.platform.wscompile.classpath=${j2ee.server.home}/modules/webservices-osgi.jar +j2ee.platform.wsgen.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api.jar +j2ee.platform.wsimport.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api.jar +j2ee.platform.wsit.classpath= +j2ee.server.type=gfv3ee6 jar.compress=false -jar.index=${jnlp.enabled} +jar.name=jcore-ee-logger.jar +jars.in.ejbjar=false javac.classpath=\ + ${file.reference.cdi-api.jar}:\ + ${file.reference.jshop-ee-lib.jar}:\ ${file.reference.log4j-api-2.3.jar}:\ ${file.reference.log4j-core-2.3.jar}:\ - ${file.reference.log4j-web-2.3.jar}:\ - ${libs.javaee-api-7.0.classpath} -# Space-separated list of extra javac options -javac.compilerargs=-Xlint:unchecked -Xlint:deprecation + ${file.reference.log4j-web-2.3.jar} +javac.debug=true javac.deprecation=true javac.processorpath=\ ${javac.classpath} @@ -52,46 +54,31 @@ javac.target=1.7 javac.test.classpath=\ ${javac.classpath}:\ ${build.classes.dir} -javac.test.processorpath=\ - ${javac.test.classpath} +javac.test.processorpath=${javac.test.classpath} javadoc.additionalparam= javadoc.author=true javadoc.encoding=${source.encoding} javadoc.noindex=false javadoc.nonavbar=false javadoc.notree=false +javadoc.preview=true javadoc.private=true javadoc.splitindex=true javadoc.use=true javadoc.version=true -javadoc.windowtitle=EE Logger Bean -jnlp.codebase.type=no.codebase -jnlp.descriptor=application -jnlp.enabled=false -jnlp.mixed.code=default -jnlp.offline-allowed=false -jnlp.signed=false -jnlp.signing= -jnlp.signing.alias= -jnlp.signing.keystore= -# Optional override of default Codebase manifest attribute, use to prevent RIAs from being repurposed -manifest.custom.codebase= -# Optional override of default Permissions manifest attribute (supported values: sandbox, all-permissions) -manifest.custom.permissions= -meta.inf.dir=${src.dir}/META-INF -mkdist.disabled=false +javadoc.windowtitle=Core EE Logger +meta.inf=${source.root}/conf +meta.inf.excludes=sun-cmp-mappings.xml platform.active=default_platform project.license=gpl30 -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project. -# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. -# To set system properties for unit tests define test-sys-prop.name=value: -run.jvmargs= +resource.dir=setup run.test.classpath=\ ${javac.test.classpath}:\ ${build.test.classes.dir} +# Space-separated list of JVM arguments used when running a class with a main method or a unit test +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value): +runmain.jvmargs= source.encoding=UTF-8 -src.dir=src +source.root=src +src.dir=${source.root}/java test.src.dir=test diff --git a/nbproject/project.xml b/nbproject/project.xml index 803d371..b0238b6 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -1,9 +1,15 @@ - org.netbeans.modules.java.j2seproject + org.netbeans.modules.j2ee.ejbjarproject - + jcore-ee-logger + 1.6.5 + file.reference.cdi-api.jar + file.reference.jshop-ee-lib.jar + file.reference.log4j-api-2.3.jar + file.reference.log4j-core-2.3.jar + file.reference.log4j-web-2.3.jar @@ -12,7 +18,7 @@ - .\lib\nblibraries.properties + ./lib/nblibraries.properties diff --git a/src/conf/MANIFEST.MF b/src/conf/MANIFEST.MF new file mode 100644 index 0000000..59499bc --- /dev/null +++ b/src/conf/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/src/java/org/mxchange/jcoreeelogger/LoggerFactory.java b/src/java/org/mxchange/jcoreeelogger/LoggerFactory.java new file mode 100644 index 0000000..934de2a --- /dev/null +++ b/src/java/org/mxchange/jcoreeelogger/LoggerFactory.java @@ -0,0 +1,42 @@ +/* + * 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 + 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 new file mode 100644 index 0000000..ad64314 --- /dev/null +++ b/src/java/org/mxchange/jcoreeelogger/beans/local/logger/LoggerBean.java @@ -0,0 +1,112 @@ +/* + * 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.ejb.Singleton; +import javax.ejb.Startup; +import javax.inject.Inject; +import org.apache.logging.log4j.Logger; + +/** + * A "centralized" logger bean + * + * @author Roland Haeder + */ +@Startup +@Singleton(name = "logger", mappedName = "logger") +public class LoggerBean implements LoggerBeanLocal { + + /** + * Logger instance + */ + @Inject + private Logger logger; + + @Override + public void logDebug (String message) { + // Deligate to logger + this.getLogger().debug(message); + } + + @Override + public void logDebug (String message, Throwable cause) { + // Deligate to logger + this.getLogger().debug(message, cause); + } + + @Override + public void logException (final Throwable throwable) { + // Deligate to logger + this.getLogger().catching(throwable); + } + + @Override + public void logFatal (final String message, final Throwable cause) { + // Deligate to logger + this.getLogger().fatal(message, cause); + } + + @Override + public void logInfo (final String message) { + // Deligate to logger + this.getLogger().info(message); + } + + @Override + public void logFatal (final String message) { + // Deligate to logger + this.getLogger().fatal(message); + } + + @Override + public void logInfo (final String message, final Throwable cause) { + // Deligate to logger + this.getLogger().info(message, cause); + } + + @Override + public void logTrace (final String message) { + // Deligate to logger + this.getLogger().trace(message); + } + + @Override + public void logTrace (final String message, final Throwable cause) { + // Deligate to logger + this.getLogger().trace(message, cause); + } + + @Override + public void logWarning (final String message) { + // Deligate to logger + this.getLogger().warn(message); + } + + @Override + public void logWarning (final String message, final Throwable cause) { + // Deligate to logger + this.getLogger().warn(message, cause); + } + + /** + * Getter for logger + * @return Logger + */ + private Logger getLogger () { + return this.logger; + } +} diff --git a/src/java/org/mxchange/jcoreeelogger/beans/local/logger/LoggerBeanLocal.java b/src/java/org/mxchange/jcoreeelogger/beans/local/logger/LoggerBeanLocal.java new file mode 100644 index 0000000..344d988 --- /dev/null +++ b/src/java/org/mxchange/jcoreeelogger/beans/local/logger/LoggerBeanLocal.java @@ -0,0 +1,109 @@ +/* + * 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.ejb.Local; + +/** + *An interface for "centralized" logger + * + * @author Roland Haeder + */ +@Local +public interface LoggerBeanLocal { + /** + * Log an exception + * + * @param throwable Thrown exception + */ + public void logException (final Throwable throwable); + + /** + * Log a debug message + * + * @param message Message to log + */ + public void logDebug (final String message); + + /** + * Log a trace message + * + * @param message Message to log + */ + public void logTrace (final String message); + + /** + * Log a info message + * + * @param message Message to log + */ + public void logInfo (final String message); + + /** + * Log a warning message + * + * @param message Message to log + */ + public void logWarning (final String message); + + /** + * Log a fatal message + * + * @param message Message to log + */ + public void logFatal (final String message); + + /** + * Log a trace message and cause + * + * @param message Message to log + * @param cause Causing exception + */ + public void logTrace (final String message, final Throwable cause); + + /** + * Log a info message and cause + * + * @param message Message to log + * @param cause Causing exception + */ + public void logInfo (final String message, final Throwable cause); + + /** + * Log a debug message and cause + * + * @param message Message to log + * @param cause Causing exception + */ + public void logDebug (final String message, final Throwable cause); + + /** + * Log a warning message and cause + * + * @param message Message to log + * @param cause Causing exception + */ + public void logWarning (final String message, final Throwable cause); + + /** + * Log a fatal message and cause + * + * @param message Message to log + * @param cause Causing exception + */ + public void logFatal (final String message, final Throwable cause); +} diff --git a/src/org/mxchange/jcoreeelogger/LoggerFactory.java b/src/org/mxchange/jcoreeelogger/LoggerFactory.java deleted file mode 100644 index 934de2a..0000000 --- a/src/org/mxchange/jcoreeelogger/LoggerFactory.java +++ /dev/null @@ -1,42 +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 - Logger getLogger (final InjectionPoint caller) { - return LogManager.getLogger(caller.getMember().getDeclaringClass().getName()); - } -} diff --git a/src/org/mxchange/jcoreeelogger/beans/local/logger/LoggerBean.java b/src/org/mxchange/jcoreeelogger/beans/local/logger/LoggerBean.java deleted file mode 100644 index ad64314..0000000 --- a/src/org/mxchange/jcoreeelogger/beans/local/logger/LoggerBean.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * 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.ejb.Singleton; -import javax.ejb.Startup; -import javax.inject.Inject; -import org.apache.logging.log4j.Logger; - -/** - * A "centralized" logger bean - * - * @author Roland Haeder - */ -@Startup -@Singleton(name = "logger", mappedName = "logger") -public class LoggerBean implements LoggerBeanLocal { - - /** - * Logger instance - */ - @Inject - private Logger logger; - - @Override - public void logDebug (String message) { - // Deligate to logger - this.getLogger().debug(message); - } - - @Override - public void logDebug (String message, Throwable cause) { - // Deligate to logger - this.getLogger().debug(message, cause); - } - - @Override - public void logException (final Throwable throwable) { - // Deligate to logger - this.getLogger().catching(throwable); - } - - @Override - public void logFatal (final String message, final Throwable cause) { - // Deligate to logger - this.getLogger().fatal(message, cause); - } - - @Override - public void logInfo (final String message) { - // Deligate to logger - this.getLogger().info(message); - } - - @Override - public void logFatal (final String message) { - // Deligate to logger - this.getLogger().fatal(message); - } - - @Override - public void logInfo (final String message, final Throwable cause) { - // Deligate to logger - this.getLogger().info(message, cause); - } - - @Override - public void logTrace (final String message) { - // Deligate to logger - this.getLogger().trace(message); - } - - @Override - public void logTrace (final String message, final Throwable cause) { - // Deligate to logger - this.getLogger().trace(message, cause); - } - - @Override - public void logWarning (final String message) { - // Deligate to logger - this.getLogger().warn(message); - } - - @Override - public void logWarning (final String message, final Throwable cause) { - // Deligate to logger - this.getLogger().warn(message, cause); - } - - /** - * Getter for logger - * @return Logger - */ - private Logger getLogger () { - return this.logger; - } -} diff --git a/src/org/mxchange/jcoreeelogger/beans/local/logger/LoggerBeanLocal.java b/src/org/mxchange/jcoreeelogger/beans/local/logger/LoggerBeanLocal.java deleted file mode 100644 index 344d988..0000000 --- a/src/org/mxchange/jcoreeelogger/beans/local/logger/LoggerBeanLocal.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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.ejb.Local; - -/** - *An interface for "centralized" logger - * - * @author Roland Haeder - */ -@Local -public interface LoggerBeanLocal { - /** - * Log an exception - * - * @param throwable Thrown exception - */ - public void logException (final Throwable throwable); - - /** - * Log a debug message - * - * @param message Message to log - */ - public void logDebug (final String message); - - /** - * Log a trace message - * - * @param message Message to log - */ - public void logTrace (final String message); - - /** - * Log a info message - * - * @param message Message to log - */ - public void logInfo (final String message); - - /** - * Log a warning message - * - * @param message Message to log - */ - public void logWarning (final String message); - - /** - * Log a fatal message - * - * @param message Message to log - */ - public void logFatal (final String message); - - /** - * Log a trace message and cause - * - * @param message Message to log - * @param cause Causing exception - */ - public void logTrace (final String message, final Throwable cause); - - /** - * Log a info message and cause - * - * @param message Message to log - * @param cause Causing exception - */ - public void logInfo (final String message, final Throwable cause); - - /** - * Log a debug message and cause - * - * @param message Message to log - * @param cause Causing exception - */ - public void logDebug (final String message, final Throwable cause); - - /** - * Log a warning message and cause - * - * @param message Message to log - * @param cause Causing exception - */ - public void logWarning (final String message, final Throwable cause); - - /** - * Log a fatal message and cause - * - * @param message Message to log - * @param cause Causing exception - */ - public void logFatal (final String message, final Throwable cause); -}