]> git.mxchange.org Git - jjobs-war.git/commitdiff
Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Fri, 1 Sep 2017 22:22:54 +0000 (00:22 +0200)
committerRoland Häder <roland@mxchange.org>
Sun, 3 Sep 2017 16:11:19 +0000 (18:11 +0200)
- I accidently (oversaw it) used Converter<MyPoji> which is JSF 2.3 (beta
  currently) way, now I could revert it, but better is to stay.
- made all converters/validators that invoke business methods (EJB) managed
  so the annotation EJB will work again.

Signed-off-by: Roland Häder <roland@mxchange.org>
13 files changed:
src/java/org/mxchange/jjobs/converter/business/basicdata/JobsBusinessContactConverter.java
src/java/org/mxchange/jjobs/converter/business/company_employee/JobsCompanyEmployeeConverter.java
src/java/org/mxchange/jjobs/converter/business/headquarters/JobsCompanyHeadquartersConverter.java
src/java/org/mxchange/jjobs/converter/contact/JobsContactConverter.java
src/java/org/mxchange/jjobs/converter/country/JobsCountryConverter.java
src/java/org/mxchange/jjobs/converter/fax/JobsFaxNumberConverter.java
src/java/org/mxchange/jjobs/converter/landline/JobsLandLineNumberConverter.java
src/java/org/mxchange/jjobs/converter/mobile/JobsMobileNumberConverter.java
src/java/org/mxchange/jjobs/converter/mobileprovider/JobsMobileProviderConverter.java
src/java/org/mxchange/jjobs/converter/user/JobsUserConverter.java
src/java/org/mxchange/jjobs/validator/business/basicdata/JobsCompanyNameValidator.java
src/java/org/mxchange/jjobs/validator/emailaddress/JobsEmailAddressValidator.java
src/java/org/mxchange/jjobs/validator/user/JobsUserIdValidator.java

index 6183845a6ec4eedc843f9974306a4d3ba3e3aaa6..4354ee61f39931d7afb8797e52a30a0737bab385 100644 (file)
  */
 package org.mxchange.jjobs.converter.business.basicdata;
 
-import java.text.MessageFormat;
+import javax.ejb.EJB;
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 import javax.faces.convert.Converter;
 import javax.faces.convert.ConverterException;
 import javax.faces.convert.FacesConverter;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
 import org.mxchange.jcontactsbusiness.basicdata.BusinessBasicData;
 import org.mxchange.jcontactsbusiness.basicdata.BusinessDataSessionBeanRemote;
 import org.mxchange.jcontactsbusiness.exceptions.basicdata.BusinessDataNotFoundException;
@@ -34,13 +31,14 @@ import org.mxchange.jcontactsbusiness.exceptions.basicdata.BusinessDataNotFoundE
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-@FacesConverter (value = "BusinessContactConverter")
+@FacesConverter ("BusinessContactConverter")
 public class JobsBusinessContactConverter implements Converter<BusinessBasicData> {
 
        /**
         * Business contact EJB
         */
-       private static BusinessDataSessionBeanRemote BASIC_DATA_BEAN;
+       @EJB (lookup = "java:global/jfinancials-ejb/businessData!org.mxchange.jcontactsbusiness.basicdata.BusinessDataSessionBeanRemote")
+       private BusinessDataSessionBeanRemote basicDataBean;
 
        /**
         * Default constructor
@@ -59,22 +57,6 @@ public class JobsBusinessContactConverter implements Converter<BusinessBasicData
                        return null;
                }
 
-               // Is the bean there?
-               // @TODO Requires this synchronization or is it (sync) confusing the container?
-               if (null == JobsBusinessContactConverter.BASIC_DATA_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // ... and user controller
-                               JobsBusinessContactConverter.BASIC_DATA_BEAN = (BusinessDataSessionBeanRemote) initialContext.lookup("java:global/jjobs-ejb/businessData!org.mxchange.jcontactsbusiness.basicdata.BusinessDataSessionBeanRemote"); //NOI18N
-                       } catch (final NamingException ex) {
-                               // Continue to throw it
-                               throw new ConverterException(MessageFormat.format("initialContext.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
-                       }
-               }
-
                // Init instance
                BusinessBasicData businessContact = null;
 
@@ -83,7 +65,7 @@ public class JobsBusinessContactConverter implements Converter<BusinessBasicData
                        Long basicDataId = Long.valueOf(submittedValue);
 
                        // Try to get user instance from it
-                       businessContact = JobsBusinessContactConverter.BASIC_DATA_BEAN.findBasicDataById(basicDataId);
+                       businessContact = this.basicDataBean.findBasicDataById(basicDataId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index 68f5c4fd7d738d4cad0824bad336ce205e8d9235..4e21174a7e0b13aff7de413abb634f836c72cfc5 100644 (file)
  */
 package org.mxchange.jjobs.converter.business.company_employee;
 
-import java.text.MessageFormat;
+import javax.ejb.EJB;
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 import javax.faces.convert.Converter;
 import javax.faces.convert.ConverterException;
 import javax.faces.convert.FacesConverter;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
 import org.mxchange.jcontactsbusiness.employee.CompanyEmployeeSessionBeanRemote;
 import org.mxchange.jcontactsbusiness.employee.Employee;
 import org.mxchange.jcontactsbusiness.exceptions.employee.CompanyEmployeeNotFoundException;
@@ -34,13 +31,14 @@ import org.mxchange.jcontactsbusiness.exceptions.employee.CompanyEmployeeNotFoun
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-@FacesConverter (value = "CompanyEmployeeConverter")
+@FacesConverter ("CompanyEmployeeConverter")
 public class JobsCompanyEmployeeConverter implements Converter<Employee> {
 
        /**
         * CompanyEmployee EJB
         */
-       private static CompanyEmployeeSessionBeanRemote COMPANY_EMPLOYEE_BEAN;
+       @EJB (lookup = "java:global/jfinancials-ejb/companyEmployee!org.mxchange.jcontactsbusiness.employee.CompanyEmployeeSessionBeanRemote")
+       private CompanyEmployeeSessionBeanRemote companyEmployeeBean;
 
        /**
         * Default constructor
@@ -59,22 +57,6 @@ public class JobsCompanyEmployeeConverter implements Converter<Employee> {
                        return null;
                }
 
-               // Is the bean there?
-               // @TODO Requires this synchronization or is it (sync) confusing the container?
-               if (null == JobsCompanyEmployeeConverter.COMPANY_EMPLOYEE_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // ... and user controller
-                               JobsCompanyEmployeeConverter.COMPANY_EMPLOYEE_BEAN = (CompanyEmployeeSessionBeanRemote) initialContext.lookup("java:global/jjobs-ejb/companyEmployee!org.mxchange.jcontactsbusiness.employee.CompanyEmployeeSessionBeanRemote"); //NOI18N
-                       } catch (final NamingException ex) {
-                               // Continue to throw it
-                               throw new ConverterException(MessageFormat.format("initialContext.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
-                       }
-               }
-
                // Init instance
                Employee companyEmployee = null;
 
@@ -83,7 +65,7 @@ public class JobsCompanyEmployeeConverter implements Converter<Employee> {
                        Long employeeId = Long.valueOf(submittedValue);
 
                        // Try to get user instance from it
-                       companyEmployee = JobsCompanyEmployeeConverter.COMPANY_EMPLOYEE_BEAN.findCompanyEmployeeById(employeeId);
+                       companyEmployee = this.companyEmployeeBean.findCompanyEmployeeById(employeeId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index bf3d0a52f5ec08068dd58fa4262bf38e04f225a9..98dab59d39c0c5b4e88061d8711d37a54aa13b80 100644 (file)
  */
 package org.mxchange.jjobs.converter.business.headquarters;
 
-import java.text.MessageFormat;
+import javax.ejb.EJB;
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 import javax.faces.convert.Converter;
 import javax.faces.convert.ConverterException;
 import javax.faces.convert.FacesConverter;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
 import org.mxchange.jcontactsbusiness.exceptions.headquarters.CompanyHeadquartersNotFoundException;
 import org.mxchange.jcontactsbusiness.headquarters.CompanyHeadquartersSessionBeanRemote;
 import org.mxchange.jcontactsbusiness.headquarters.HeadquartersData;
@@ -34,13 +31,14 @@ import org.mxchange.jcontactsbusiness.headquarters.HeadquartersData;
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-@FacesConverter (value = "CompanyHeadquartersConverter")
+@FacesConverter ("CompanyHeadquartersConverter")
 public class JobsCompanyHeadquartersConverter implements Converter<HeadquartersData> {
 
        /**
         * CompanyEmployee EJB
         */
-       private static CompanyHeadquartersSessionBeanRemote COMPANY_HEADQUARTERS_BEAN;
+       @EJB (lookup = "java:global/jfinancials-ejb/companyEmployee!org.mxchange.jcontactsbusiness.headquarters.CompanyHeadquartersSessionBeanRemote")
+       private CompanyHeadquartersSessionBeanRemote companyHeadquartersBean;
 
        /**
         * Default constructor
@@ -59,22 +57,6 @@ public class JobsCompanyHeadquartersConverter implements Converter<HeadquartersD
                        return null;
                }
 
-               // Is the bean there?
-               // @TODO Requires this synchronization or is it (sync) confusing the container?
-               if (null == JobsCompanyHeadquartersConverter.COMPANY_HEADQUARTERS_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // ... and user controller
-                               JobsCompanyHeadquartersConverter.COMPANY_HEADQUARTERS_BEAN = (CompanyHeadquartersSessionBeanRemote) initialContext.lookup("java:global/jjobs-ejb/companyEmployee!org.mxchange.jcontactsbusiness.headquarters.CompanyHeadquartersSessionBeanRemote"); //NOI18N
-                       } catch (final NamingException ex) {
-                               // Continue to throw it
-                               throw new ConverterException(MessageFormat.format("initialContext.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
-                       }
-               }
-
                // Init instance
                HeadquartersData companyHeadquarters = null;
 
@@ -83,7 +65,7 @@ public class JobsCompanyHeadquartersConverter implements Converter<HeadquartersD
                        Long headquartersId = Long.valueOf(submittedValue);
 
                        // Try to get user instance from it
-                       companyHeadquarters = JobsCompanyHeadquartersConverter.COMPANY_HEADQUARTERS_BEAN.findCompanyHeadquartersById(headquartersId);
+                       companyHeadquarters = this.companyHeadquartersBean.findCompanyHeadquartersById(headquartersId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index 12f3829727ae1109a58a2b87ca3d8cf879de80c1..f170e455839f6fe50e5499d53282eb05bc012c80 100644 (file)
  */
 package org.mxchange.jjobs.converter.contact;
 
-import java.text.MessageFormat;
+import javax.ejb.EJB;
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 import javax.faces.convert.Converter;
 import javax.faces.convert.ConverterException;
 import javax.faces.convert.FacesConverter;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
 import org.mxchange.jcontacts.contact.Contact;
 import org.mxchange.jcontacts.contact.ContactSessionBeanRemote;
 import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
@@ -34,13 +31,14 @@ import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-@FacesConverter (value = "ContactConverter")
+@FacesConverter ("ContactConverter")
 public class JobsContactConverter implements Converter<Contact> {
 
        /**
         * User EJB
         */
-       private static ContactSessionBeanRemote CONTACT_BEAN;
+       @EJB (lookup = "java:global/jfinancials-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote")
+       private ContactSessionBeanRemote contactBean;
 
        /**
         * Default constructor
@@ -59,22 +57,6 @@ public class JobsContactConverter implements Converter<Contact> {
                        return null;
                }
 
-               // Is the bean there?
-               // @TODO Requires this synchronization or is it (sync) confusing the container?
-               if (null == JobsContactConverter.CONTACT_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // ... and user controller
-                               JobsContactConverter.CONTACT_BEAN = (ContactSessionBeanRemote) initialContext.lookup("java:global/jjobs-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N
-                       } catch (final NamingException ex) {
-                               // Continue to throw it
-                               throw new ConverterException(MessageFormat.format("initialContext.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
-                       }
-               }
-
                // Init instance
                Contact contact = null;
 
@@ -83,7 +65,7 @@ public class JobsContactConverter implements Converter<Contact> {
                        Long contactId = Long.valueOf(submittedValue);
 
                        // Try to get user instance from it
-                       contact = JobsContactConverter.CONTACT_BEAN.findContactById(contactId);
+                       contact = this.contactBean.findContactById(contactId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index b03055e56f3512d0677dd23444798bedd9d9a908..645957d5bf6a38bff14bbac549e08d418e4551c0 100644 (file)
  */
 package org.mxchange.jjobs.converter.country;
 
-import java.text.MessageFormat;
 import java.util.List;
 import java.util.Objects;
+import javax.ejb.EJB;
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 import javax.faces.convert.Converter;
 import javax.faces.convert.ConverterException;
 import javax.faces.convert.FacesConverter;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
 import org.mxchange.jcountry.data.Country;
 import org.mxchange.jcountry.data.CountrySingletonBeanRemote;
 
@@ -35,13 +32,14 @@ import org.mxchange.jcountry.data.CountrySingletonBeanRemote;
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-@FacesConverter (value = "CountryConverter")
+@FacesConverter ("CountryConverter")
 public class JobsCountryConverter implements Converter<Country> {
 
        /**
         * Country bean
         */
-       private static CountrySingletonBeanRemote COUNTRY_BEAN;
+       @EJB (lookup = "java:global/jfinancials-ejb/country!org.mxchange.jcountry.data.CountrySingletonBeanRemote")
+       private CountrySingletonBeanRemote countryBean;
 
        /**
         * Default constructor
@@ -60,24 +58,8 @@ public class JobsCountryConverter implements Converter<Country> {
                        return null;
                }
 
-               // Is the bean there?
-               // @TODO Requires this synchronization or is it (sync) confusing the container?
-               if (null == JobsCountryConverter.COUNTRY_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // ... and country bean
-                               JobsCountryConverter.COUNTRY_BEAN = (CountrySingletonBeanRemote) initialContext.lookup("java:global/jjobs-ejb/country!org.mxchange.jcountry.data.CountrySingletonBeanRemote"); //NOI18N
-                       } catch (final NamingException ex) {
-                               // Continue to throw it
-                               throw new ConverterException(MessageFormat.format("initialContext.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
-                       }
-               }
-
                // Get full list
-               List<Country> countryList = JobsCountryConverter.COUNTRY_BEAN.allCountries();
+               List<Country> countryList = this.countryBean.allCountries();
 
                // Init value
                Country country = null;
index 5b5e6812ba5351b7543d96f0007b846d11ff2894..7e5436e88e3c4bb4914eee8253da1db9dd3aee9e 100644 (file)
  */
 package org.mxchange.jjobs.converter.fax;
 
-import java.text.MessageFormat;
+import javax.ejb.EJB;
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 import javax.faces.convert.Converter;
 import javax.faces.convert.ConverterException;
 import javax.faces.convert.FacesConverter;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
 import org.mxchange.jphone.exceptions.PhoneEntityNotFoundException;
 import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
 import org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote;
@@ -34,13 +31,14 @@ import org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote;
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-@FacesConverter (value = "FaxNumberConverter")
+@FacesConverter ("FaxNumberConverter")
 public class JobsFaxNumberConverter implements Converter<DialableFaxNumber> {
 
        /**
         * Phone EJB
         */
-       private static PhoneSessionBeanRemote PHONE_BEAN;
+       @EJB(lookup = "java:global/jfinancials-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote")
+       private PhoneSessionBeanRemote phoneBean;
 
        /**
         * Default constructor
@@ -62,22 +60,6 @@ public class JobsFaxNumberConverter implements Converter<DialableFaxNumber> {
                        return null;
                }
 
-               // Is the bean there?
-               // @TODO Requires this synchronization or is it (sync) confusing the container?
-               if (null == JobsFaxNumberConverter.PHONE_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // ... and user controller
-                               JobsFaxNumberConverter.PHONE_BEAN = (PhoneSessionBeanRemote) initialContext.lookup("java:global/jjobs-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote"); //NOI18N
-                       } catch (final NamingException ex) {
-                               // Continue to throw it
-                               throw new RuntimeException(MessageFormat.format("context.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
-                       }
-               }
-
                // Init instance
                DialableFaxNumber faxNumber = null;
 
@@ -88,7 +70,7 @@ public class JobsFaxNumberConverter implements Converter<DialableFaxNumber> {
                        // Log message
                        // @TODO Not possible here: this.loggerBeanLocal.logDebug(MessageFormat.format("{0}.getAsObject: faxNumberId={1}", this.getClass().getSimpleName(), faxNumberId)); //NOI18N
                        // Try to get mobile instance from it
-                       faxNumber = JobsFaxNumberConverter.PHONE_BEAN.findFaxNumberById(faxNumberId);
+                       faxNumber = this.phoneBean.findFaxNumberById(faxNumberId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index 4ef3f81f34da227a571434b6f0dab67f4ed20883..ef4076855575d45414ddaf27886fec9f764c8415 100644 (file)
  */
 package org.mxchange.jjobs.converter.landline;
 
-import java.text.MessageFormat;
+import javax.ejb.EJB;
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 import javax.faces.convert.Converter;
 import javax.faces.convert.ConverterException;
 import javax.faces.convert.FacesConverter;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
 import org.mxchange.jphone.exceptions.PhoneEntityNotFoundException;
 import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
 import org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote;
@@ -34,13 +31,14 @@ import org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote;
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-@FacesConverter (value = "LandLineNumberConverter")
+@FacesConverter ("LandLineNumberConverter")
 public class JobsLandLineNumberConverter implements Converter<DialableLandLineNumber> {
 
        /**
         * Phone EJB
         */
-       private static PhoneSessionBeanRemote PHONE_BEAN;
+       @EJB(lookup = "java:global/jfinancials-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote")
+       private PhoneSessionBeanRemote phoneBean;
 
        /**
         * Default constructor
@@ -59,22 +57,6 @@ public class JobsLandLineNumberConverter implements Converter<DialableLandLineNu
                        return null;
                }
 
-               // Is the bean there?
-               // @TODO Requires this synchronization or is it (sync) confusing the container?
-               if (null == JobsLandLineNumberConverter.PHONE_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // ... and user controller
-                               JobsLandLineNumberConverter.PHONE_BEAN = (PhoneSessionBeanRemote) initialContext.lookup("java:global/jjobs-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote"); //NOI18N
-                       } catch (final NamingException ex) {
-                               // Continue to throw it
-                               throw new RuntimeException(MessageFormat.format("context.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
-                       }
-               }
-
                // Init instance
                DialableLandLineNumber landLineNumber = null;
 
@@ -83,7 +65,7 @@ public class JobsLandLineNumberConverter implements Converter<DialableLandLineNu
                        Long landLineNumberId = Long.valueOf(submittedValue);
 
                        // Try to get mobile instance from it
-                       landLineNumber = JobsLandLineNumberConverter.PHONE_BEAN.findLandLineNumberById(landLineNumberId);
+                       landLineNumber = this.phoneBean.findLandLineNumberById(landLineNumberId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index 9476eec7fd56d5a16513734713f57684df21c11a..cb3d1f1e49c14c455cab0cd2666437406b5c0936 100644 (file)
  */
 package org.mxchange.jjobs.converter.mobile;
 
-import java.text.MessageFormat;
+import javax.ejb.EJB;
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 import javax.faces.convert.Converter;
 import javax.faces.convert.ConverterException;
 import javax.faces.convert.FacesConverter;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
 import org.mxchange.jphone.exceptions.PhoneEntityNotFoundException;
 import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
 import org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote;
@@ -34,13 +31,14 @@ import org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote;
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-@FacesConverter (value = "MobileNumberConverter")
+@FacesConverter ("MobileNumberConverter")
 public class JobsMobileNumberConverter implements Converter<DialableMobileNumber> {
 
        /**
         * Phone EJB
         */
-       private static PhoneSessionBeanRemote PHONE_BEAN;
+       @EJB (lookup = "java:global/jfinancials-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote")
+       private PhoneSessionBeanRemote phoneBean;
 
        /**
         * Default constructor
@@ -59,22 +57,6 @@ public class JobsMobileNumberConverter implements Converter<DialableMobileNumber
                        return null;
                }
 
-               // Is the bean there?
-               // @TODO Requires this synchronization or is it (sync) confusing the container?
-               if (null == JobsMobileNumberConverter.PHONE_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // ... and user controller
-                               JobsMobileNumberConverter.PHONE_BEAN = (PhoneSessionBeanRemote) initialContext.lookup("java:global/jjobs-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote"); //NOI18N
-                       } catch (final NamingException ex) {
-                               // Continue to throw it
-                               throw new ConverterException(MessageFormat.format("initialContext.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
-                       }
-               }
-
                // Init instance
                DialableMobileNumber mobileNumber = null;
 
@@ -83,7 +65,7 @@ public class JobsMobileNumberConverter implements Converter<DialableMobileNumber
                        Long mobileNumberId = Long.valueOf(submittedValue);
 
                        // Try to get mobile instance from it
-                       mobileNumber = JobsMobileNumberConverter.PHONE_BEAN.findMobileNumberById(mobileNumberId);
+                       mobileNumber = this.phoneBean.findMobileNumberById(mobileNumberId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index 4e1ca05bccde439344ba6af8915e35211af8fa75..7dbdd42ffcb73067506deca45e7f4ed9acb17f54 100644 (file)
  */
 package org.mxchange.jjobs.converter.mobileprovider;
 
-import java.text.MessageFormat;
 import java.util.List;
 import java.util.Objects;
+import javax.ejb.EJB;
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 import javax.faces.convert.Converter;
-import javax.faces.convert.ConverterException;
 import javax.faces.convert.FacesConverter;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
 import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
 import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote;
 
@@ -35,13 +31,14 @@ import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProviderSingletonBe
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-@FacesConverter (value = "MobileProviderConverter")
+@FacesConverter ("MobileProviderConverter")
 public class JobsMobileProviderConverter implements Converter<MobileProvider> {
 
        /**
         * Mobile provider bean
         */
-       private static MobileProviderSingletonBeanRemote MOBILE_PROVIDER_BEAN;
+       @EJB(lookup = "java:global/jfinancials-ejb/mobileprovider!org.mxchange.jphone.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote")
+       private MobileProviderSingletonBeanRemote mobileProviderBean;
 
        /**
         * Default constructor
@@ -60,24 +57,8 @@ public class JobsMobileProviderConverter implements Converter<MobileProvider> {
                        return null;
                }
 
-               // Is the bean there?
-               // @TODO Requires this synchronization or is it (sync) confusing the container?
-               if (null == JobsMobileProviderConverter.MOBILE_PROVIDER_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               /// and mobile provider controller
-                               JobsMobileProviderConverter.MOBILE_PROVIDER_BEAN = (MobileProviderSingletonBeanRemote) initialContext.lookup("java:global/jjobs-ejb/mobileprovider!org.mxchange.jphone.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote"); //NOI18N
-                       } catch (final NamingException ex) {
-                               // Continue to throw it
-                               throw new ConverterException(MessageFormat.format("initialContext.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
-                       }
-               }
-
                // Get full list
-               List<MobileProvider> providerList = JobsMobileProviderConverter.MOBILE_PROVIDER_BEAN.allMobileProvider();
+               List<MobileProvider> providerList = this.mobileProviderBean.allMobileProvider();
 
                // Init value
                MobileProvider provider = null;
index e06a2d32d9a0f07ca4c882365ad1016b56fcc6db..3704b454f0a217af552c5a8b9e6676af69305f82 100644 (file)
  */
 package org.mxchange.jjobs.converter.user;
 
-import java.text.MessageFormat;
+import javax.ejb.EJB;
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 import javax.faces.convert.Converter;
 import javax.faces.convert.ConverterException;
 import javax.faces.convert.FacesConverter;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
 import org.mxchange.jusercore.exceptions.UserNotFoundException;
 import org.mxchange.jusercore.model.user.User;
 import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
@@ -34,13 +31,14 @@ import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-@FacesConverter (value = "UserConverter")
+@FacesConverter ("UserConverter")
 public class JobsUserConverter implements Converter<User> {
 
        /**
         * User EJB
         */
-       private static UserSessionBeanRemote USER_BEAN;
+       @EJB(lookup = "java:global/jfinancials-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote")
+       private UserSessionBeanRemote userBean;
 
        /**
         * Default constructor
@@ -59,22 +57,6 @@ public class JobsUserConverter implements Converter<User> {
                        return null;
                }
 
-               // Is the bean there?
-               // @TODO Requires this synchronization or is it (sync) confusing the container?
-               if (null == JobsUserConverter.USER_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // ... and user controller
-                               JobsUserConverter.USER_BEAN = (UserSessionBeanRemote) initialContext.lookup("java:global/jjobs-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
-                       } catch (final NamingException ex) {
-                               // Continue to throw it
-                               throw new RuntimeException(MessageFormat.format("initialContext.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
-                       }
-               }
-
                // Init instance
                User user = null;
 
@@ -83,7 +65,7 @@ public class JobsUserConverter implements Converter<User> {
                        Long userId = Long.valueOf(submittedValue);
 
                        // Try to get user instance from it
-                       user = JobsUserConverter.USER_BEAN.findUserById(userId);
+                       user = this.userBean.findUserById(userId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index bbebec9f3d6f3b85d0fde37744549384cc31e38c..a5230f64e825ef0fa91aa1687dba7dbc39733fb0 100644 (file)
 package org.mxchange.jjobs.validator.business.basicdata;
 
 import java.text.MessageFormat;
+import javax.ejb.EJB;
 import javax.faces.application.FacesMessage;
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
-import javax.faces.convert.ConverterException;
 import javax.faces.validator.FacesValidator;
 import javax.faces.validator.ValidatorException;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
 import org.mxchange.jcontactsbusiness.basicdata.BusinessDataSessionBeanRemote;
 import org.mxchange.jcoreee.validator.string.BaseStringValidator;
 
@@ -38,14 +35,15 @@ import org.mxchange.jcoreee.validator.string.BaseStringValidator;
 public class JobsCompanyNameValidator extends BaseStringValidator {
 
        /**
-        * Business contact EJB
+        * Serial number
         */
-       private static BusinessDataSessionBeanRemote BASIC_DATA_BEAN;
+       private static final long serialVersionUID = 57_283_657_476_561L;
 
        /**
-        * Serial number
+        * Business contact EJB
         */
-       private static final long serialVersionUID = 57_283_657_476_561L;
+       @EJB (lookup = "java:global/jfinancials-ejb/businessData!org.mxchange.jcontactsbusiness.basicdata.BusinessDataSessionBeanRemote")
+       private BusinessDataSessionBeanRemote basicDataBean;
 
        @Override
        public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException {
@@ -76,24 +74,8 @@ public class JobsCompanyNameValidator extends BaseStringValidator {
                        checkExisting = Boolean.parseBoolean((String) attribute);
                }
 
-               // Is the bean not yet set?
-               // @TODO Requires this synchronization or is it (sync) confusing the container?
-               if (null == JobsCompanyNameValidator.BASIC_DATA_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // ... and user controller
-                               JobsCompanyNameValidator.BASIC_DATA_BEAN = (BusinessDataSessionBeanRemote) initialContext.lookup("java:global/jjobs-ejb/businessData!org.mxchange.jcontactsbusiness.basicdata.BusinessDataSessionBeanRemote"); //NOI18N
-                       } catch (final NamingException ex) {
-                               // Continue to throw it
-                               throw new ConverterException(MessageFormat.format("initialContext.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
-                       }
-               }
-
                // Check if name is already used
-               Boolean nameExists = JobsCompanyNameValidator.BASIC_DATA_BEAN.isCompanyNameUsed(companyName);
+               Boolean nameExists = this.basicDataBean.isCompanyNameUsed(companyName);
 
                // Is the user id valid?
                if ((!nameExists) && (checkExisting)) {
index 639cbab7a6486136369cc0407a9c331ba6193ecb..57f93ffa9fab82a7ef1ec062ea3b492de6dcd695 100644 (file)
@@ -18,14 +18,12 @@ package org.mxchange.jjobs.validator.emailaddress;
 
 import java.text.MessageFormat;
 import java.util.regex.Pattern;
+import javax.ejb.EJB;
 import javax.faces.application.FacesMessage;
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 import javax.faces.validator.FacesValidator;
 import javax.faces.validator.ValidatorException;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
 import org.mxchange.jcontacts.contact.ContactSessionBeanRemote;
 import org.mxchange.jcoreee.validator.string.BaseStringValidator;
 
@@ -40,7 +38,8 @@ public class JobsEmailAddressValidator extends BaseStringValidator {
        /**
         * Contact session-scoped bean
         */
-       private static ContactSessionBeanRemote CONTACT_BEAN;
+       @EJB (lookup = "java:global/jfinancials-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote")
+       private ContactSessionBeanRemote contactBean;
 
        /**
         * Email pattern
@@ -118,27 +117,11 @@ public class JobsEmailAddressValidator extends BaseStringValidator {
                        throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_WARN, message, message));
                }
 
-               // Is the bean not yet set?
-               // @TODO Requires this synchronization or is it (sync) confusing the container?
-               if (null == JobsEmailAddressValidator.CONTACT_BEAN) {
-                       // Try it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // Try to lookup
-                               JobsEmailAddressValidator.CONTACT_BEAN = (ContactSessionBeanRemote) initialContext.lookup("java:global/jjobs-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N
-                       } catch (final NamingException ex) {
-                               // Continue to throw it
-                               throw new ValidatorException(new FacesMessage(MessageFormat.format("initialContext.lookup() failed: {0}", ex.getMessage())), ex); //NOI18N
-                       }
-               }
-
                // Get client id (aka form id)
                String clientId = component.getClientId();
 
                // Is it registered?
-               Boolean isRegistered = JobsEmailAddressValidator.CONTACT_BEAN.isEmailAddressRegistered(emailAddress);
+               Boolean isRegistered = this.contactBean.isEmailAddressRegistered(emailAddress);
 
                // Is the email address already registered?
                if ((!clientId.endsWith("resendEmailAddress")) && (isRegistered)) { //NOI18N
index 6660e660cf0a40be2a1abd000b47cc0eccd96244..99a1b7a303dedd18a05157c1b36206efda938691 100644 (file)
 package org.mxchange.jjobs.validator.user;
 
 import java.text.MessageFormat;
+import javax.ejb.EJB;
 import javax.faces.application.FacesMessage;
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
-import javax.faces.convert.ConverterException;
 import javax.faces.validator.FacesValidator;
 import javax.faces.validator.ValidatorException;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
 import org.mxchange.jcoreee.validator.number.BaseNumberValidator;
 import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
 
@@ -38,14 +35,15 @@ import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
 public class JobsUserIdValidator extends BaseNumberValidator {
 
        /**
-        * Remote bean
+        * Serial number
         */
-       private static UserSessionBeanRemote USER_BEAN;
+       private static final long serialVersionUID = 12_869_569_314_764_690L;
 
        /**
-        * Serial number
+        * Remote bean
         */
-       private static final long serialVersionUID = 12_869_569_314_764_690L;
+       @EJB (lookup = "java:global/jfinancials-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote")
+       private UserSessionBeanRemote userBean;
 
        /**
         * Default constructor
@@ -64,24 +62,8 @@ public class JobsUserIdValidator extends BaseNumberValidator {
                // Cast value
                Long userId = (Long) value;
 
-               // Is the bean not yet set?
-               // @TODO Requires this synchronization or is it (sync) confusing the container?
-               if (null == JobsUserIdValidator.USER_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // ... and user controller
-                               JobsUserIdValidator.USER_BEAN = (UserSessionBeanRemote) initialContext.lookup("java:global/jjobs-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
-                       } catch (final NamingException ex) {
-                               // Continue to throw it
-                               throw new ConverterException(MessageFormat.format("initialContext.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
-                       }
-               }
-
                // Define variable
-               Boolean ifUserExists = JobsUserIdValidator.USER_BEAN.ifUserIdExists(userId);
+               Boolean ifUserExists = this.userBean.ifUserIdExists(userId);
 
                // Is the user id valid?
                if (!ifUserExists) {