+/*
+ * Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook.beans.localization;
+
+import java.util.Locale;
+import javax.annotation.PostConstruct;
+import javax.faces.bean.SessionScoped;
+import javax.faces.context.FacesContext;
+import javax.inject.Named;
+import org.mxchange.jcoreee.database.BaseDatabaseBean;
+
+/**
+ * A session bean for handling localization/internationalization changes. This
+ * class is based on an example at [1] from mkyong.
+ * <p>
+ * 1: http://www.mkyong.com/jsf2/jsf-2-internationalization-example/
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@Named ("localization")
+@SessionScoped
+public class AddressbookLocalizationSessionBean extends BaseDatabaseBean implements LocalizationSessionController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 1_867_671_657_629_601_528L;
+
+ /**
+ * Current Locale
+ */
+ private Locale locale;
+
+ @Override
+ public Locale getLocale () {
+ return this.locale;
+ }
+
+ @Override
+ public void setLocale (final Locale locale) {
+ this.locale = locale;
+ }
+
+ /**
+ * Initializer for this bean
+ */
+ @PostConstruct
+ public void init () {
+ // Create locale instance from context
+ Locale loc = FacesContext.getCurrentInstance().getExternalContext().getRequestLocale();
+
+ // Set it here
+ this.setLocale(loc);
+ }
+
+}