From 7b5bbd9b02588733012dbc1fb194db3f6f99d2c8 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Fri, 4 Sep 2015 21:45:39 +0200 Subject: [PATCH] =?utf8?q?Moved=20from=20jshop=20as=20they=20are=20really?= =?utf8?q?=20generic=20now=20Signed-off-by:Roland=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../jsfcore/beans/BaseFrameworkBean.java | 74 +++++++++++++++++++ .../mxchange/jsfcore/beans/FrameworkBean.java | 34 +++++++++ 2 files changed, 108 insertions(+) create mode 100644 src/org/mxchange/jsfcore/beans/BaseFrameworkBean.java create mode 100644 src/org/mxchange/jsfcore/beans/FrameworkBean.java diff --git a/src/org/mxchange/jsfcore/beans/BaseFrameworkBean.java b/src/org/mxchange/jsfcore/beans/BaseFrameworkBean.java new file mode 100644 index 0000000..a104ce1 --- /dev/null +++ b/src/org/mxchange/jsfcore/beans/BaseFrameworkBean.java @@ -0,0 +1,74 @@ +/* + * 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.jsfcore.beans; + +import javax.enterprise.context.Dependent; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +/** + * A general bean class. Do not put things in here that are not serializable. + * The logger is currently not serializeable, so you will get error messages. + * + * @author Roland Haeder + */ +@Dependent +public abstract class BaseFrameworkBean implements FrameworkBean { + + /** + * Serial number + */ + private static final long serialVersionUID = 83258139481372814L; + + /** + * Class' logger + */ + private final Logger LOG; + + /** + * Initializer + */ + { + // Get logger + this.LOG = LogManager.getLogger(this); + } + + /** + * Protected constructor, please don't add init() call here. + */ + protected BaseFrameworkBean () { + } + + /** + * Getter for logger + * + * @return Logger + */ + protected Logger getLogger () { + return this.LOG; + } + + /** + * Super initialization method. Do not set @PostConstruct here. If you overwrite this method, please call it + * before (!) your own initialization. + * + * @throws RuntimeException If something unexpected happens + */ + @Override + public void init () throws RuntimeException { + } +} diff --git a/src/org/mxchange/jsfcore/beans/FrameworkBean.java b/src/org/mxchange/jsfcore/beans/FrameworkBean.java new file mode 100644 index 0000000..639a5e9 --- /dev/null +++ b/src/org/mxchange/jsfcore/beans/FrameworkBean.java @@ -0,0 +1,34 @@ +/* + * 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.jsfcore.beans; + +import java.io.Serializable; + +/** + * A general bean interface + * + * @author Roland Haeder + */ +public interface FrameworkBean extends Serializable { + + /** + * Initializes this bean, mostly done with @PostConstruct + * + * @throws RuntimeException If something happens, no checked exceptions are allowed + */ + public void init () throws RuntimeException; +} -- 2.39.5