From e5f709af7011a884d85a777f59f6355396749495 Mon Sep 17 00:00:00 2001
From: Roland Haeder <roland@mxchange.org>
Date: Sun, 11 Oct 2015 21:57:34 +0200
Subject: [PATCH] Continued: - removed jcountry-lib as this is not working -
 implemented method to get all countries

---
 lib/jcountry-lib.jar                          | Bin 363 -> 0 bytes
 nbproject/build-impl.xml                      |   2 -
 nbproject/genfiles.properties                 |   4 +-
 nbproject/project.properties                  |   3 -
 nbproject/project.xml                         |   4 --
 .../beans/country/CountryWebBean.java         |  58 ++++++++++++++----
 .../beans/gender/GenderWebBean.java           |   1 -
 7 files changed, 47 insertions(+), 25 deletions(-)
 delete mode 100644 lib/jcountry-lib.jar

diff --git a/lib/jcountry-lib.jar b/lib/jcountry-lib.jar
deleted file mode 100644
index 7f61f695fc83f28a4d8e7e1b0eb34fc44c578b38..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 363
zcmWIWW@h1HVBlb2*tWvkodF4OGO#fCx`sIFdiuHP|2xIN5CB)Y6{xgqRzGt(P&o*T
z03lqducM!*n`>~0p067tg8*0_WGYA<2>2%EWu~PTm*|G278Pga=UFKj>KX8IIp!gW
zI2I%(XQV0s#ekBQdM3PF&PAz-C8;U8PL&|_7J3HpW(K-RM&=3{{zZw&IjIWH`9%f!
zMTsRq6E%6cc)0?+8JR?war+G77y*X2j$lWj`V*lQ)29%PAaY5gHju>T?*MOBHjoM?
MAgl$_H$WT)0F0|gcmMzZ

diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml
index 3afa43c8..3240e969 100644
--- a/nbproject/build-impl.xml
+++ b/nbproject/build-impl.xml
@@ -1034,7 +1034,6 @@ exists or setup the property manually. For example like this:
         <copyfiles files="${file.reference.jcoreee.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.jcore-logger-lib.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.jcountry-core.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
-        <copyfiles files="${file.reference.jcountry-lib.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.jcontacts-core.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.jcontacts-business-core.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.jcontacts-lib.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
@@ -1052,7 +1051,6 @@ exists or setup the property manually. For example like this:
         <copyfiles files="${file.reference.jcoreee.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
         <copyfiles files="${file.reference.jcore-logger-lib.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
         <copyfiles files="${file.reference.jcountry-core.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
-        <copyfiles files="${file.reference.jcountry-lib.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
         <copyfiles files="${file.reference.jcontacts-core.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
         <copyfiles files="${file.reference.jcontacts-business-core.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
         <copyfiles files="${file.reference.jcontacts-lib.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties
index 61bd5aed..bddbeed8 100644
--- a/nbproject/genfiles.properties
+++ b/nbproject/genfiles.properties
@@ -3,6 +3,6 @@ build.xml.script.CRC32=be5f34f7
 build.xml.stylesheet.CRC32=651128d4@1.68.1.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=b91929ff
-nbproject/build-impl.xml.script.CRC32=b3fbd4a7
+nbproject/build-impl.xml.data.CRC32=794ded5f
+nbproject/build-impl.xml.script.CRC32=e6d84652
 nbproject/build-impl.xml.stylesheet.CRC32=99ea4b56@1.68.1.1
diff --git a/nbproject/project.properties b/nbproject/project.properties
index f0edbd56..73110f8a 100644
--- a/nbproject/project.properties
+++ b/nbproject/project.properties
@@ -44,7 +44,6 @@ file.reference.jcore-logger-lib.jar=lib/jcore-logger-lib.jar
 file.reference.jcore.jar=lib/jcore.jar
 file.reference.jcoreee.jar=lib/jcoreee.jar
 file.reference.jcountry-core.jar=lib/jcountry-core.jar
-file.reference.jcountry-lib.jar=lib/jcountry-lib.jar
 file.reference.jphone-core.jar=lib/jphone-core.jar
 file.reference.juser-core.jar=lib/juser-core.jar
 file.reference.juser-lib.jar=lib/juser-lib.jar
@@ -66,7 +65,6 @@ javac.classpath=\
     ${file.reference.jcoreee.jar}:\
     ${file.reference.jcore-logger-lib.jar}:\
     ${file.reference.jcountry-core.jar}:\
-    ${file.reference.jcountry-lib.jar}:\
     ${file.reference.jcontacts-core.jar}:\
     ${file.reference.jcontacts-business-core.jar}:\
     ${file.reference.jcontacts-lib.jar}:\
@@ -122,7 +120,6 @@ source.reference.jcore-logger-lib.jar=../jcore-logger-lib/src/
 source.reference.jcore.jar=../jcore/src/
 source.reference.jcoreee.jar=../jcoreee/src/
 source.reference.jcountry-core.jar=../jcountry-core/src/
-source.reference.jcountry-lib.jar=../jcountry-lib/src/
 source.reference.jphone-core.jar=../jphone-core/src/
 source.reference.juser-core.jar=../juser-core/src/
 source.reference.juser-lib.jar=../juser-lib/src/
diff --git a/nbproject/project.xml b/nbproject/project.xml
index a34b45f1..75f2f1bb 100644
--- a/nbproject/project.xml
+++ b/nbproject/project.xml
@@ -22,10 +22,6 @@
                     <file>${file.reference.jcountry-core.jar}</file>
                     <path-in-war>WEB-INF/lib</path-in-war>
                 </library>
-                <library dirs="200">
-                    <file>${file.reference.jcountry-lib.jar}</file>
-                    <path-in-war>WEB-INF/lib</path-in-war>
-                </library>
                 <library dirs="200">
                     <file>${file.reference.jcontacts-core.jar}</file>
                     <path-in-war>WEB-INF/lib</path-in-war>
diff --git a/src/java/org/mxchange/addressbook/beans/country/CountryWebBean.java b/src/java/org/mxchange/addressbook/beans/country/CountryWebBean.java
index 158abc05..2657c3bf 100644
--- a/src/java/org/mxchange/addressbook/beans/country/CountryWebBean.java
+++ b/src/java/org/mxchange/addressbook/beans/country/CountryWebBean.java
@@ -3,23 +3,28 @@ package org.mxchange.addressbook.beans.country;
 /*
  * 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 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.
+ * 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/>.
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
  */
-
-
+import java.util.List;
+import javax.annotation.PostConstruct;
 import javax.enterprise.context.ApplicationScoped;
+import javax.faces.view.facelets.FaceletException;
 import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jcountry.data.AddressbookCountrySingletonBeanRemote;
 import org.mxchange.jcountry.data.Country;
 
 /**
@@ -36,14 +41,41 @@ public class CountryWebBean implements CountryWebController {
 	 */
 	private static final long serialVersionUID = 176_985_298_681_742_960L;
 
+	/**
+	 * Remote country EJB
+	 */
+	private AddressbookCountrySingletonBeanRemote countryBean;
+
+	/**
+	 * List of all countries
+	 */
+	private List<Country> countryList;
+
 	/**
 	 * Default constructor
 	 */
 	public CountryWebBean () {
+		// Try this
+		try {
+			// Get initial context
+			Context context = new InitialContext();
+
+			// Try to lookup the bean
+			this.countryBean = (AddressbookCountrySingletonBeanRemote) context.lookup("ejb/singleton-country");
+		} catch (final NamingException ex) {
+			// Continue to throw
+			throw new FaceletException(ex);
+		}
 	}
 
 	@Override
 	public Country[] allCountries () {
-		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+		// Return "cached" version
+		return (Country[]) this.countryList.toArray();
+	}
+
+	@PostConstruct
+	public void init () {
+		this.countryList = this.countryBean.allCountries();
 	}
 }
diff --git a/src/java/org/mxchange/addressbook/beans/gender/GenderWebBean.java b/src/java/org/mxchange/addressbook/beans/gender/GenderWebBean.java
index f35f4603..a315d4a8 100644
--- a/src/java/org/mxchange/addressbook/beans/gender/GenderWebBean.java
+++ b/src/java/org/mxchange/addressbook/beans/gender/GenderWebBean.java
@@ -51,7 +51,6 @@ public class GenderWebBean implements GenderWebController {
 	@Override
 	public List<Gender> getSelectableGenders () {
 		// Init array
-		// TODO Call EJB here?
 		List<Gender> genders = GenderUtils.selectableGenders();
 
 		// Return it
-- 
2.39.5