]> git.mxchange.org Git - jjobs-war.git/blobdiff - src/java/org/mxchange/jjobs/beans/country/JobsAdminCountryWebRequestBean.java
Please cherry-pick:
[jjobs-war.git] / src / java / org / mxchange / jjobs / beans / country / JobsAdminCountryWebRequestBean.java
index 0b9697b7b4a5e639771c55c6d3b8e4065e6b7c25..e730dd54e51bf15dd00d6d32b18afe91ac288034 100644 (file)
@@ -19,23 +19,20 @@ package org.mxchange.jjobs.beans.country;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Objects;
-import javax.annotation.PostConstruct;
+import javax.ejb.EJB;
 import javax.enterprise.context.RequestScoped;
 import javax.enterprise.event.Event;
 import javax.enterprise.inject.Any;
 import javax.faces.view.facelets.FaceletException;
 import javax.inject.Inject;
 import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.jcountry.data.Country;
-import org.mxchange.jcountry.data.CountryData;
-import org.mxchange.jcountry.data.CountrySingletonBeanRemote;
 import org.mxchange.jcountry.events.AdminAddedCountryEvent;
 import org.mxchange.jcountry.events.ObservableAdminAddedCountryEvent;
 import org.mxchange.jcountry.exceptions.CountryAlreadyAddedException;
-import org.mxchange.jjobs.beans.BaseJobsController;
+import org.mxchange.jcountry.model.data.Country;
+import org.mxchange.jcountry.model.data.CountryData;
+import org.mxchange.jcountry.model.data.CountrySingletonBeanRemote;
+import org.mxchange.jjobs.beans.BaseJobsBean;
 
 /**
  * An administrative country bean
@@ -44,7 +41,7 @@ import org.mxchange.jjobs.beans.BaseJobsController;
  */
 @Named ("adminCountryController")
 @RequestScoped
-public class JobsAdminCountryWebRequestBean extends BaseJobsController implements JobsAdminCountryWebRequestController {
+public class JobsAdminCountryWebRequestBean extends BaseJobsBean implements JobsAdminCountryWebRequestController {
 
        /**
         * Serial number
@@ -66,6 +63,7 @@ public class JobsAdminCountryWebRequestBean extends BaseJobsController implement
        /**
         * Remote country EJB
         */
+       @EJB (lookup = "java:global/jjobs-ejb/country!org.mxchange.jcountry.model.data.CountrySingletonBeanRemote")
        private CountrySingletonBeanRemote countryBean;
 
        /**
@@ -77,7 +75,7 @@ public class JobsAdminCountryWebRequestBean extends BaseJobsController implement
         * Regular country controller
         */
        @Inject
-       private JobsCountryWebApplicationController countryController;
+       private JobsCountryWebRequestController countryController;
 
        /**
         * Local dial prefix
@@ -117,7 +115,7 @@ public class JobsAdminCountryWebRequestBean extends BaseJobsController implement
         */
        public String addCountry () {
                // Create new country object
-               Country country = new CountryData();
+               final Country country = new CountryData();
 
                // Add all data
                country.setCountryAbroadDialPrefix(this.getCountryAbroadDialPrefix());
@@ -134,7 +132,7 @@ public class JobsAdminCountryWebRequestBean extends BaseJobsController implement
                }
 
                // Init variable
-               Country updatedCountry = null;
+               final Country updatedCountry;
 
                try {
                        // Send country to bean
@@ -263,24 +261,6 @@ public class JobsAdminCountryWebRequestBean extends BaseJobsController implement
                this.countryPhoneCode = countryPhoneCode;
        }
 
-       /**
-        * Post-construction method
-        */
-       @PostConstruct
-       public void init () {
-               // Try this
-               try {
-                       // Get initial context
-                       Context context = new InitialContext();
-
-                       // Try to lookup the bean
-                       this.countryBean = (CountrySingletonBeanRemote) context.lookup("java:global/jjobs-ejb/country!org.mxchange.jcountry.data.CountrySingletonBeanRemote"); //NOI18N
-               } catch (final NamingException ex) {
-                       // Continue to throw
-                       throw new FaceletException(ex);
-               }
-       }
-
        /**
         * Clears this bean's data. This should be called after a form has been
         * submitted and the processing of the form was successful.
@@ -308,15 +288,15 @@ public class JobsAdminCountryWebRequestBean extends BaseJobsController implement
                boolean isAdded = false;
 
                // Now get whole ist
-               List<Country> countries = this.countryController.allCountries();
+               final List<Country> countries = this.countryController.allCountries();
 
                // Get iterator from it
-               Iterator<Country> iterator = countries.iterator();
+               final Iterator<Country> iterator = countries.iterator();
 
                // Check whole list
                while (iterator.hasNext()) {
                        // Get next country
-                       Country next = iterator.next();
+                       final Country next = iterator.next();
 
                        // Is country code or i18n the same?
                        if ((Objects.equals(country.getCountryCode(), next.getCountryCode())) || (Objects.equals(country.getCountryI18nKey(), next.getCountryI18nKey()))) {