]> git.mxchange.org Git - pizzaservice-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>
Sat, 16 Sep 2017 12:52:56 +0000 (14:52 +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>
14 files changed:
src/java/org/mxchange/jfinancials/validator/business/basicdata/FinancialsCompanyNameValidator.java
src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestBean.java
src/java/org/mxchange/pizzaapplication/converter/business/basicdata/PizzaBusinessContactConverter.java
src/java/org/mxchange/pizzaapplication/converter/business/company_employee/PizzaCompanyEmployeeConverter.java
src/java/org/mxchange/pizzaapplication/converter/business/headquarters/PizzaCompanyHeadquartersConverter.java
src/java/org/mxchange/pizzaapplication/converter/contact/PizzaContactConverter.java
src/java/org/mxchange/pizzaapplication/converter/country/PizzaCountryConverter.java
src/java/org/mxchange/pizzaapplication/converter/fax/PizzaFaxNumberConverter.java
src/java/org/mxchange/pizzaapplication/converter/landline/PizzaLandLineNumberConverter.java
src/java/org/mxchange/pizzaapplication/converter/mobile/PizzaMobileNumberConverter.java
src/java/org/mxchange/pizzaapplication/converter/mobileprovider/PizzaMobileProviderConverter.java
src/java/org/mxchange/pizzaapplication/converter/user/PizzaUserConverter.java
src/java/org/mxchange/pizzaapplication/validator/emailaddress/PizzaEmailAddressValidator.java
src/java/org/mxchange/pizzaapplication/validator/user/PizzaUserIdValidator.java

index 41bd9f7691d26b27ff748ee6a27e80592b8ff5c6..e1f1b854199eaec79a759ba63a6017bd71181512 100644 (file)
 package org.mxchange.jfinancials.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.model.basicdata.BasicCompanyDataSessionBeanRemote;
 import org.mxchange.jcoreee.validator.string.BaseStringValidator;
 
 /**
@@ -34,18 +30,19 @@ import org.mxchange.jcoreee.validator.string.BaseStringValidator;
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-@FacesValidator ("CompanyNameValidator")
+@FacesValidator (value = "CompanyNameValidator", managed = true)
 public class FinancialsCompanyNameValidator extends BaseStringValidator {
 
        /**
-        * Business contact EJB
+        * Serial number
         */
-       private static BasicCompanyDataSessionBeanRemote 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 +73,8 @@ public class FinancialsCompanyNameValidator 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 == FinancialsCompanyNameValidator.BASIC_DATA_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // ... and user controller
-                               FinancialsCompanyNameValidator.BASIC_DATA_BEAN = (BasicCompanyDataSessionBeanRemote) initialContext.lookup("java:global/addressbook-ejb/basicCompanyData!org.mxchange.jcontactsbusiness.model.basicdata.BasicCompanyDataSessionBeanRemote"); //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 = FinancialsCompanyNameValidator.BASIC_DATA_BEAN.isCompanyNameUsed(companyName);
+               Boolean nameExists = this.basicDataBean.isCompanyNameUsed(companyName);
 
                // Is the user id valid?
                if ((!nameExists) && (checkExisting)) {
index 7406a224a92d17eeba981f230e3b8938dc4693be..b42f1bc181e4a80420cdc30c9cc1988419648c10 100644 (file)
@@ -50,7 +50,7 @@ public class PizzaMobileProviderWebRequestBean extends BasePizzaController imple
        /**
         * Remote EJB for mobile providers (regular)
         */
-       @EJB (lookup = "java:global/pizzaservice-ejb/mobileprovider!org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote")
+       @EJB (lookup = "java:global/pizzaservice-ejb/mobileProvider!org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote")
        private MobileProviderSingletonBeanRemote mobileRemoteBean;
 
        /**
index 165d6e7837b7bfea3c55f98e715452169fa7df6e..a1a771f2b186bc9b7a2c83906d1ada27bd03daa2 100644 (file)
  */
 package org.mxchange.pizzaapplication.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.model.basicdata.BusinessBasicData;
-import org.mxchange.jcontactsbusiness.model.basicdata.BasicCompanyDataSessionBeanRemote;
 import org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicCompanyDataNotFoundException;
 
 /**
@@ -34,13 +29,14 @@ import org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicCompanyDataNotFo
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-@FacesConverter (value = "BusinessContactConverter")
+@FacesConverter ("BusinessContactConverter")
 public class PizzaBusinessContactConverter implements Converter<BusinessBasicData> {
 
        /**
         * Business contact EJB
         */
-       private static BasicCompanyDataSessionBeanRemote BASIC_DATA_BEAN;
+       @EJB (lookup = "java:global/jfinancials-ejb/businessData!org.mxchange.jcontactsbusiness.basicdata.BusinessDataSessionBeanRemote")
+       private BusinessDataSessionBeanRemote basicDataBean;
 
        /**
         * Default constructor
@@ -59,22 +55,6 @@ public class PizzaBusinessContactConverter implements Converter<BusinessBasicDat
                        return null;
                }
 
-               // Is the bean there?
-               // @TODO Requires this synchronization or is it (sync) confusing the container?
-               if (null == PizzaBusinessContactConverter.BASIC_DATA_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // ... and user controller
-                               PizzaBusinessContactConverter.BASIC_DATA_BEAN = (BasicCompanyDataSessionBeanRemote) initialContext.lookup("java:global/pizzaapplication-ejb/basicCompanyData!org.mxchange.jcontactsbusiness.model.basicdata.BasicCompanyDataSessionBeanRemote"); //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 +63,7 @@ public class PizzaBusinessContactConverter implements Converter<BusinessBasicDat
                        Long basicDataId = Long.valueOf(submittedValue);
 
                        // Try to get user instance from it
-                       businessContact = PizzaBusinessContactConverter.BASIC_DATA_BEAN.findBasicDataById(basicDataId);
+                       businessContact = this.basicDataBean.findBasicDataById(basicDataId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index 1d35ec117eed194acd9bf35c4df9765725240aae..eb2703b208c1b2e34d03a8017a936edfb7bbf36f 100644 (file)
  */
 package org.mxchange.pizzaapplication.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.model.employee.CompanyEmployeeSessionBeanRemote;
-import org.mxchange.jcontactsbusiness.model.employee.Employee;
 import org.mxchange.jcontactsbusiness.exceptions.employee.CompanyEmployeeNotFoundException;
 
 /**
@@ -34,13 +29,14 @@ import org.mxchange.jcontactsbusiness.exceptions.employee.CompanyEmployeeNotFoun
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-@FacesConverter (value = "CompanyEmployeeConverter")
+@FacesConverter ("CompanyEmployeeConverter")
 public class PizzaCompanyEmployeeConverter 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 +55,6 @@ public class PizzaCompanyEmployeeConverter implements Converter<Employee> {
                        return null;
                }
 
-               // Is the bean there?
-               // @TODO Requires this synchronization or is it (sync) confusing the container?
-               if (null == PizzaCompanyEmployeeConverter.COMPANY_EMPLOYEE_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // ... and user controller
-                               PizzaCompanyEmployeeConverter.COMPANY_EMPLOYEE_BEAN = (CompanyEmployeeSessionBeanRemote) initialContext.lookup("java:global/pizzaservice-ejb/companyEmployee!org.mxchange.jcontactsbusiness.model.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 +63,7 @@ public class PizzaCompanyEmployeeConverter implements Converter<Employee> {
                        Long employeeId = Long.valueOf(submittedValue);
 
                        // Try to get user instance from it
-                       companyEmployee = PizzaCompanyEmployeeConverter.COMPANY_EMPLOYEE_BEAN.findCompanyEmployeeById(employeeId);
+                       companyEmployee = this.companyEmployeeBean.findCompanyEmployeeById(employeeId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index 2bd8e3a4c6178add87d13367360f624a499e27bf..1233fa4a93baaf98167af3f80b55135f9265a76d 100644 (file)
  */
 package org.mxchange.pizzaapplication.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.model.headquarters.CompanyHeadquartersSessionBeanRemote;
 import org.mxchange.jcontactsbusiness.model.headquarters.HeadquartersData;
@@ -34,13 +31,14 @@ import org.mxchange.jcontactsbusiness.model.headquarters.HeadquartersData;
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-@FacesConverter (value = "CompanyHeadquartersConverter")
+@FacesConverter ("CompanyHeadquartersConverter")
 public class PizzaCompanyHeadquartersConverter 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 PizzaCompanyHeadquartersConverter implements Converter<Headquarters
                        return null;
                }
 
-               // Is the bean there?
-               // @TODO Requires this synchronization or is it (sync) confusing the container?
-               if (null == PizzaCompanyHeadquartersConverter.COMPANY_HEADQUARTERS_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // ... and user controller
-                               PizzaCompanyHeadquartersConverter.COMPANY_HEADQUARTERS_BEAN = (CompanyHeadquartersSessionBeanRemote) initialContext.lookup("java:global/jjobs-ejb/companyEmployee!org.mxchange.jcontactsbusiness.model.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 PizzaCompanyHeadquartersConverter implements Converter<Headquarters
                        Long headquartersId = Long.valueOf(submittedValue);
 
                        // Try to get user instance from it
-                       companyHeadquarters = PizzaCompanyHeadquartersConverter.COMPANY_HEADQUARTERS_BEAN.findCompanyHeadquartersById(headquartersId);
+                       companyHeadquarters = this.companyHeadquartersBean.findCompanyHeadquartersById(headquartersId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index bde36fc94b49e5de91269eeda07c9157f6467d6f..d486439d65c3bde4a167411f0192fcefc6d126eb 100644 (file)
  */
 package org.mxchange.pizzaapplication.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.exceptions.ContactNotFoundException;
 import org.mxchange.jcontacts.model.contact.Contact;
 import org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote;
-import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
 
 /**
  * Converter for contact id <-> valid contact instance
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-@FacesConverter (value = "ContactConverter")
+@FacesConverter ("ContactConverter")
 public class PizzaContactConverter 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 PizzaContactConverter implements Converter<Contact> {
                        return null;
                }
 
-               // Is the bean there?
-               // @TODO Requires this synchronization or is it (sync) confusing the container?
-               if (null == PizzaContactConverter.CONTACT_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // ... and user controller
-                               PizzaContactConverter.CONTACT_BEAN = (ContactSessionBeanRemote) initialContext.lookup("java:global/pizzaapplication-ejb/contact!org.mxchange.jcontacts.model.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 PizzaContactConverter implements Converter<Contact> {
                        Long contactId = Long.valueOf(submittedValue);
 
                        // Try to get user instance from it
-                       contact = PizzaContactConverter.CONTACT_BEAN.findContactById(contactId);
+                       contact = this.contactBean.findContactById(contactId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index 56e749bbe51a2ed869b484a1fcee6e7400552e97..e63d29f26e633982cb11caa928a9373c4e538c5e 100644 (file)
  */
 package org.mxchange.pizzaapplication.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.model.data.Country;
 import org.mxchange.jcountry.model.data.CountrySingletonBeanRemote;
 
@@ -35,13 +32,14 @@ import org.mxchange.jcountry.model.data.CountrySingletonBeanRemote;
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-@FacesConverter (value = "CountryConverter")
+@FacesConverter ("CountryConverter")
 public class PizzaCountryConverter 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 PizzaCountryConverter implements Converter<Country> {
                        return null;
                }
 
-               // Is the bean there?
-               // @TODO Requires this synchronization or is it (sync) confusing the container?
-               if (null == PizzaCountryConverter.COUNTRY_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // ... and country bean
-                               PizzaCountryConverter.COUNTRY_BEAN = (CountrySingletonBeanRemote) initialContext.lookup("java:global/pizzaapplication-ejb/country!org.mxchange.jcountry.model.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 = PizzaCountryConverter.COUNTRY_BEAN.allCountries();
+               List<Country> countryList = this.countryBean.allCountries();
 
                // Init value
                Country country = null;
index cbde7f55714cbf274abade9f4965ae745587705f..7e947b239aa56fce78a284815010d594668191f7 100644 (file)
  */
 package org.mxchange.pizzaapplication.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.model.phonenumbers.fax.DialableFaxNumber;
 import org.mxchange.jphone.model.phonenumbers.phone.PhoneSessionBeanRemote;
@@ -34,13 +31,14 @@ import org.mxchange.jphone.model.phonenumbers.phone.PhoneSessionBeanRemote;
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-@FacesConverter (value = "FaxNumberConverter")
+@FacesConverter ("FaxNumberConverter")
 public class PizzaFaxNumberConverter 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 PizzaFaxNumberConverter implements Converter<DialableFaxNumber> {
                        return null;
                }
 
-               // Is the bean there?
-               // @TODO Requires this synchronization or is it (sync) confusing the container?
-               if (null == PizzaFaxNumberConverter.PHONE_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // ... and user controller
-                               PizzaFaxNumberConverter.PHONE_BEAN = (PhoneSessionBeanRemote) initialContext.lookup("java:global/pizzaapplication-ejb/phone!org.mxchange.jphone.model.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 PizzaFaxNumberConverter 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 = PizzaFaxNumberConverter.PHONE_BEAN.findFaxNumberById(faxNumberId);
+                       faxNumber = this.phoneBean.findFaxNumberById(faxNumberId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index 4ee530f8da5063663c4e425e7a2fa8a453540248..fb7750547a3c20c9177025d71c75316d76b5856b 100644 (file)
  */
 package org.mxchange.pizzaapplication.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.model.phonenumbers.landline.DialableLandLineNumber;
 import org.mxchange.jphone.model.phonenumbers.phone.PhoneSessionBeanRemote;
@@ -34,13 +31,14 @@ import org.mxchange.jphone.model.phonenumbers.phone.PhoneSessionBeanRemote;
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-@FacesConverter (value = "LandLineNumberConverter")
+@FacesConverter ("LandLineNumberConverter")
 public class PizzaLandLineNumberConverter 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 PizzaLandLineNumberConverter implements Converter<DialableLandLineN
                        return null;
                }
 
-               // Is the bean there?
-               // @TODO Requires this synchronization or is it (sync) confusing the container?
-               if (null == PizzaLandLineNumberConverter.PHONE_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // ... and user controller
-                               PizzaLandLineNumberConverter.PHONE_BEAN = (PhoneSessionBeanRemote) initialContext.lookup("java:global/pizzaapplication-ejb/phone!org.mxchange.jphone.model.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 PizzaLandLineNumberConverter implements Converter<DialableLandLineN
                        Long landLineNumberId = Long.valueOf(submittedValue);
 
                        // Try to get mobile instance from it
-                       landLineNumber = PizzaLandLineNumberConverter.PHONE_BEAN.findLandLineNumberById(landLineNumberId);
+                       landLineNumber = this.phoneBean.findLandLineNumberById(landLineNumberId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index f4405c2c039afdafdd82c90be8ef748522556c7f..281cd848c33930274caa290c85a1448143ace2ec 100644 (file)
  */
 package org.mxchange.pizzaapplication.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.model.phonenumbers.model.mobile.DialableMobileNumber;
+import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
 import org.mxchange.jphone.model.phonenumbers.phone.PhoneSessionBeanRemote;
 
 /**
@@ -34,13 +31,14 @@ import org.mxchange.jphone.model.phonenumbers.phone.PhoneSessionBeanRemote;
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-@FacesConverter (value = "MobileNumberConverter")
+@FacesConverter ("MobileNumberConverter")
 public class PizzaMobileNumberConverter 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 PizzaMobileNumberConverter implements Converter<DialableMobileNumbe
                        return null;
                }
 
-               // Is the bean there?
-               // @TODO Requires this synchronization or is it (sync) confusing the container?
-               if (null == PizzaMobileNumberConverter.PHONE_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // ... and user controller
-                               PizzaMobileNumberConverter.PHONE_BEAN = (PhoneSessionBeanRemote) initialContext.lookup("java:global/pizzaapplication-ejb/phone!org.mxchange.jphone.model.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;
 
@@ -86,7 +68,7 @@ public class PizzaMobileNumberConverter implements Converter<DialableMobileNumbe
                        // NOISY-DEBUG: this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: userId{0}", userId)); //NOI18N
 
                        // Try to get mobile instance from it
-                       mobileNumber = PizzaMobileNumberConverter.PHONE_BEAN.findMobileNumberById(mobileId);
+                       mobileNumber = this.phoneBean.findMobileNumberById(mobileId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index 4c1d78bf6cb61233a1895cd8946bd38952a756b4..07fc7e83f5acc92c297ce4cedeaa67e99d1f7e7b 100644 (file)
  */
 package org.mxchange.pizzaapplication.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.model.phonenumbers.model.mobileprovider.MobileProvider;
+import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
 import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote;
 
 /**
@@ -41,7 +37,8 @@ public class PizzaMobileProviderConverter 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 PizzaMobileProviderConverter implements Converter<MobileProvider> {
                        return null;
                }
 
-               // Is the bean there?
-               // @TODO Requires this synchronization or is it (sync) confusing the container?
-               if (null == PizzaMobileProviderConverter.MOBILE_PROVIDER_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               /// and mobile provider controller
-                               PizzaMobileProviderConverter.MOBILE_PROVIDER_BEAN = (MobileProviderSingletonBeanRemote) initialContext.lookup("java:global/pizzaapplication-ejb/mobileprovider!org.mxchange.jphone.model.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 = PizzaMobileProviderConverter.MOBILE_PROVIDER_BEAN.allMobileProvider();
+               List<MobileProvider> providerList = this.mobileProviderBean.allMobileProviders();
 
                // Init value
                MobileProvider provider = null;
index d7910c0778ac2a08eeee9ddb8d037d0b4766d80a..6a718577d53a13a90901baab4461d5120739e478 100644 (file)
  */
 package org.mxchange.pizzaapplication.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 PizzaUserConverter 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 PizzaUserConverter implements Converter<User> {
                        return null;
                }
 
-               // Is the bean there?
-               // @TODO Requires this synchronization or is it (sync) confusing the container?
-               if (null == PizzaUserConverter.USER_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // ... and user controller
-                               PizzaUserConverter.USER_BEAN = (UserSessionBeanRemote) initialContext.lookup("java:global/pizzaapplication-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 PizzaUserConverter implements Converter<User> {
                        Long userId = Long.valueOf(submittedValue);
 
                        // Try to get user instance from it
-                       user = PizzaUserConverter.USER_BEAN.findUserById(userId);
+                       user = this.userBean.findUserById(userId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index a6edb3513f31411632ffc4e76e276da081878111..9f29d9c8a05dcc5dfb7cff7220da548a0fffb7a3 100644 (file)
@@ -18,15 +18,13 @@ package org.mxchange.pizzaapplication.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.jcontacts.model.contact.ContactSessionBeanRemote;
 import org.mxchange.jcoreee.validator.string.BaseStringValidator;
 
 /**
@@ -40,7 +38,8 @@ public class PizzaEmailAddressValidator 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 PizzaEmailAddressValidator 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 == PizzaEmailAddressValidator.CONTACT_BEAN) {
-                       // Try it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // Try to lookup
-                               PizzaEmailAddressValidator.CONTACT_BEAN = (ContactSessionBeanRemote) initialContext.lookup("java:global/pizzaapplication-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 = PizzaEmailAddressValidator.CONTACT_BEAN.isEmailAddressRegistered(emailAddress);
+               Boolean isRegistered = this.contactBean.isEmailAddressRegistered(emailAddress);
 
                // Is the email address already registered?
                if ((!clientId.endsWith("resendEmailAddress")) && (isRegistered)) { //NOI18N
index f72bcb944489182b2defd54c7ff8d906f45f762a..57a8f6ec65258027b852b1814d22cb4c575c512f 100644 (file)
 package org.mxchange.pizzaapplication.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 PizzaUserIdValidator 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 PizzaUserIdValidator 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 == PizzaUserIdValidator.USER_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // ... and user controller
-                               PizzaUserIdValidator.USER_BEAN = (UserSessionBeanRemote) initialContext.lookup("java:global/pizzaapplication-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 = PizzaUserIdValidator.USER_BEAN.ifUserIdExists(userId);
+               Boolean ifUserExists = this.userBean.ifUserIdExists(userId);
 
                // Is the user id valid?
                if (!ifUserExists) {