]> git.mxchange.org Git - pizzaservice-swing.git/blob - src/org/mxchange/pizzaapplication/BasePizzaServiceSystem.java
Continued a bit:
[pizzaservice-swing.git] / src / org / mxchange / pizzaapplication / BasePizzaServiceSystem.java
1 /*
2  * Copyright (C) 2016, 2017 Roland Häder
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 package org.mxchange.pizzaapplication;
18
19 import java.text.MessageFormat;
20 import javax.naming.Context;
21 import javax.naming.InitialContext;
22 import javax.naming.NamingException;
23 import org.mxchange.jcore.BaseFrameworkSystem;
24 import org.mxchange.jcoreeelogger.beans.local.logger.Log;
25 import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
26
27 /**
28  * A general Pizza-Service class
29  * <p>
30  * @author Roland Häder<roland@mxchange.org>
31  */
32 public abstract class BasePizzaServiceSystem extends BaseFrameworkSystem {
33
34         /**
35          * Logger instance
36          */
37         @Log
38         private LoggerBeanLocal loggerBeanLocal;
39
40         /**
41          * Protected constructor
42          */
43         protected BasePizzaServiceSystem () {
44                 // Try it
45                 try {
46                         // Get initial context
47                         Context context = new InitialContext();
48
49                         // Lookup logger
50                         this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N
51                 } catch (final NamingException ex) {
52                         // Throw again
53                         throw new RuntimeException(MessageFormat.format("context.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
54                 }
55         }
56
57         /**
58          * Getter for logger instance
59          * <p>
60          * @return Logger instance
61          */
62         protected LoggerBeanLocal getLogger () {
63                 return this.loggerBeanLocal;
64         }
65 }