]> git.mxchange.org Git - jfinancials-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>
Fri, 1 Sep 2017 22:22:54 +0000 (00:22 +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/jfinancials/converter/business/basicdata/FinancialsBusinessContactConverter.java
src/java/org/mxchange/jfinancials/converter/business/company_employee/FinancialsCompanyEmployeeConverter.java
src/java/org/mxchange/jfinancials/converter/business/headquarters/FinancialsCompanyHeadquartersConverter.java
src/java/org/mxchange/jfinancials/converter/contact/FinancialsContactConverter.java
src/java/org/mxchange/jfinancials/converter/country/FinancialsCountryConverter.java
src/java/org/mxchange/jfinancials/converter/fax/FinancialsFaxNumberConverter.java
src/java/org/mxchange/jfinancials/converter/landline/FinancialsLandLineNumberConverter.java
src/java/org/mxchange/jfinancials/converter/mobile/FinancialsMobileNumberConverter.java
src/java/org/mxchange/jfinancials/converter/mobileprovider/FinancialsMobileProviderConverter.java
src/java/org/mxchange/jfinancials/converter/user/FinancialsUserConverter.java
src/java/org/mxchange/jfinancials/validator/business/basicdata/FinancialsCompanyNameValidator.java
src/java/org/mxchange/jfinancials/validator/emailaddress/FinancialsEmailAddressValidator.java
src/java/org/mxchange/jfinancials/validator/user/FinancialsUserIdValidator.java

index 1a9ecaee56a43433c1ecf1a390c72bfe56736c3d..6c2d275f67f0a2bba9a5ac01bee982e104ffeafa 100644 (file)
  */
 package org.mxchange.jfinancials.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 (value = "BusinessContactConverter", managed = true)
 public class FinancialsBusinessContactConverter 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 FinancialsBusinessContactConverter implements Converter<BusinessBas
                        return null;
                }
 
-               // Is the bean there?
-               // @TODO Requires this synchronization or is it (sync) confusing the container?
-               if (null == FinancialsBusinessContactConverter.BASIC_DATA_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // ... and user controller
-                               FinancialsBusinessContactConverter.BASIC_DATA_BEAN = (BusinessDataSessionBeanRemote) initialContext.lookup("java:global/jfinancials-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 FinancialsBusinessContactConverter implements Converter<BusinessBas
                        Long contactId = Long.valueOf(submittedValue);
 
                        // Try to get user instance from it
-                       businessContact = FinancialsBusinessContactConverter.BASIC_DATA_BEAN.findBasicDataById(contactId);
+                       businessContact = this.basicDataBean.findBasicDataById(contactId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index 3698e94fbcbc34c708ce6cebdd549ce1e308f4e7..62738e14143c39f908e41f667a371492b1b655b3 100644 (file)
  */
 package org.mxchange.jfinancials.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 (value = "CompanyEmployeeConverter", managed = true)
 public class FinancialsCompanyEmployeeConverter 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 FinancialsCompanyEmployeeConverter implements Converter<Employee> {
                        return null;
                }
 
-               // Is the bean there?
-               // @TODO Requires this synchronization or is it (sync) confusing the container?
-               if (null == FinancialsCompanyEmployeeConverter.COMPANY_EMPLOYEE_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // ... and user controller
-                               FinancialsCompanyEmployeeConverter.COMPANY_EMPLOYEE_BEAN = (CompanyEmployeeSessionBeanRemote) initialContext.lookup("java:global/jfinancials-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 FinancialsCompanyEmployeeConverter implements Converter<Employee> {
                        Long employeeId = Long.valueOf(submittedValue);
 
                        // Try to get user instance from it
-                       companyEmployee = FinancialsCompanyEmployeeConverter.COMPANY_EMPLOYEE_BEAN.findCompanyEmployeeById(employeeId);
+                       companyEmployee = this.companyEmployeeBean.findCompanyEmployeeById(employeeId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index a596dbc7f4aaeeca9a432279b3a9e32bf52b96cd..ecc131074bf7bbc01757b031c3a1b0e87a7ddd83 100644 (file)
  */
 package org.mxchange.jfinancials.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 (value = "CompanyHeadquartersConverter", managed = true)
 public class FinancialsCompanyHeadquartersConverter 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 FinancialsCompanyHeadquartersConverter implements Converter<Headqua
                        return null;
                }
 
-               // Is the bean there?
-               // @TODO Requires this synchronization or is it (sync) confusing the container?
-               if (null == FinancialsCompanyHeadquartersConverter.COMPANY_HEADQUARTERS_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // ... and user controller
-                               FinancialsCompanyHeadquartersConverter.COMPANY_HEADQUARTERS_BEAN = (CompanyHeadquartersSessionBeanRemote) initialContext.lookup("java:global/jfinancials-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 FinancialsCompanyHeadquartersConverter implements Converter<Headqua
                        Long headquartersId = Long.valueOf(submittedValue);
 
                        // Try to get user instance from it
-                       companyHeadquarters = FinancialsCompanyHeadquartersConverter.COMPANY_HEADQUARTERS_BEAN.findCompanyHeadquartersById(headquartersId);
+                       companyHeadquarters = this.companyHeadquartersBean.findCompanyHeadquartersById(headquartersId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index 6d3f2fae0934ac14b3ec6cb00290d6a64462684f..8832300a53a7e3d872772b51c6b61c1fb68b0591 100644 (file)
  */
 package org.mxchange.jfinancials.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 (value = "ContactConverter", managed = true)
 public class FinancialsContactConverter implements Converter<Contact> {
 
        /**
         * Contact 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 FinancialsContactConverter implements Converter<Contact> {
                        return null;
                }
 
-               // Is the bean there?
-               // @TODO Requires this synchronization or is it (sync) confusing the container?
-               if (null == FinancialsContactConverter.CONTACT_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // ... and user controller
-                               FinancialsContactConverter.CONTACT_BEAN = (ContactSessionBeanRemote) initialContext.lookup("java:global/jfinancials-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 FinancialsContactConverter implements Converter<Contact> {
                        Long contactId = Long.valueOf(submittedValue);
 
                        // Try to get user instance from it
-                       contact = FinancialsContactConverter.CONTACT_BEAN.findContactById(contactId);
+                       contact = this.contactBean.findContactById(contactId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index f7d568308b4cb99c84c3400c4ef5693f4bd69577..b7689982645cfe67b311e0a463e4ca259451b7bd 100644 (file)
  */
 package org.mxchange.jfinancials.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 (value = "CountryConverter", managed = true)
 public class FinancialsCountryConverter 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 FinancialsCountryConverter implements Converter<Country> {
                        return null;
                }
 
-               // Is the bean there?
-               // @TODO Requires this synchronization or is it (sync) confusing the container?
-               if (null == FinancialsCountryConverter.COUNTRY_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // ... and country bean
-                               FinancialsCountryConverter.COUNTRY_BEAN = (CountrySingletonBeanRemote) initialContext.lookup("java:global/jfinancials-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 = FinancialsCountryConverter.COUNTRY_BEAN.allCountries();
+               List<Country> countryList = this.countryBean.allCountries();
 
                // Init value
                Country country = null;
index b2c21469698acf410926b6d813e6d2565a3c7f07..41a269bf5bc72f52b56dc0d95cfd94bb9c0c70eb 100644 (file)
  */
 package org.mxchange.jfinancials.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 (value = "FaxNumberConverter", managed = true)
 public class FinancialsFaxNumberConverter 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 FinancialsFaxNumberConverter implements Converter<DialableFaxNumber
                        return null;
                }
 
-               // Is the bean there?
-               // @TODO Requires this synchronization or is it (sync) confusing the container?
-               if (null == FinancialsFaxNumberConverter.PHONE_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // ... and user controller
-                               FinancialsFaxNumberConverter.PHONE_BEAN = (PhoneSessionBeanRemote) initialContext.lookup("java:global/jfinancials-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 FinancialsFaxNumberConverter 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 = FinancialsFaxNumberConverter.PHONE_BEAN.findFaxNumberById(faxNumberId);
+                       faxNumber = this.phoneBean.findFaxNumberById(faxNumberId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index f0f8faf5022e4fc1f17fc836b8636bd805fbea72..070f99c6c3dfcd2743d6847fa307bea398ab532d 100644 (file)
  */
 package org.mxchange.jfinancials.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 (value = "LandLineNumberConverter", managed = true)
 public class FinancialsLandLineNumberConverter 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 FinancialsLandLineNumberConverter implements Converter<DialableLand
                        return null;
                }
 
-               // Is the bean there?
-               // @TODO Requires this synchronization or is it (sync) confusing the container?
-               if (null == FinancialsLandLineNumberConverter.PHONE_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // ... and user controller
-                               FinancialsLandLineNumberConverter.PHONE_BEAN = (PhoneSessionBeanRemote) initialContext.lookup("java:global/jfinancials-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 FinancialsLandLineNumberConverter implements Converter<DialableLand
                        Long landLineNumberId = Long.valueOf(submittedValue);
 
                        // Try to get mobile instance from it
-                       landLineNumber = FinancialsLandLineNumberConverter.PHONE_BEAN.findLandLineNumberById(landLineNumberId);
+                       landLineNumber = this.phoneBean.findLandLineNumberById(landLineNumberId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index 6091eec5eb6d5da339447a0e22fd3b7bc17a82aa..9ec30910873dc0f1afca0fdf70f6b879a1256a2d 100644 (file)
  */
 package org.mxchange.jfinancials.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 (value = "MobileNumberConverter", managed = true)
 public class FinancialsMobileNumberConverter 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 FinancialsMobileNumberConverter implements Converter<DialableMobile
                        return null;
                }
 
-               // Is the bean there?
-               // @TODO Requires this synchronization or is it (sync) confusing the container?
-               if (null == FinancialsMobileNumberConverter.PHONE_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // ... and user controller
-                               FinancialsMobileNumberConverter.PHONE_BEAN = (PhoneSessionBeanRemote) initialContext.lookup("java:global/jfinancials-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 mobile = null;
 
@@ -83,7 +65,7 @@ public class FinancialsMobileNumberConverter implements Converter<DialableMobile
                        Long mobileId = Long.valueOf(submittedValue);
 
                        // Try to get mobile instance from it
-                       mobile = FinancialsMobileNumberConverter.PHONE_BEAN.findMobileNumberById(mobileId);
+                       mobile = this.phoneBean.findMobileNumberById(mobileId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index d99ae480e15e2ffdff2c550828deb2e9ed37f201..c31b7ad6978f285ed0357a01923bea336e994da5 100644 (file)
  */
 package org.mxchange.jfinancials.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;
 
@@ -41,7 +37,8 @@ public class FinancialsMobileProviderConverter implements Converter<MobileProvid
        /**
         * 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 FinancialsMobileProviderConverter implements Converter<MobileProvid
                        return null;
                }
 
-               // Is the bean there?
-               // @TODO Requires this synchronization or is it (sync) confusing the container?
-               if (null == FinancialsMobileProviderConverter.MOBILE_PROVIDER_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               /// and mobile provider controller
-                               FinancialsMobileProviderConverter.MOBILE_PROVIDER_BEAN = (MobileProviderSingletonBeanRemote) initialContext.lookup("java:global/jfinancials-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 = FinancialsMobileProviderConverter.MOBILE_PROVIDER_BEAN.allMobileProvider();
+               List<MobileProvider> providerList = this.mobileProviderBean.allMobileProvider();
 
                // Init value
                MobileProvider provider = null;
index a4cdd0a2e2223e70f2e5f7ae0bc42c5f031f74c8..32d3e1e2a6d49e27f0d2dfc130744df7c67ba399 100644 (file)
  */
 package org.mxchange.jfinancials.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 (value = "UserConverter", managed = true)
 public class FinancialsUserConverter 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 FinancialsUserConverter implements Converter<User> {
                        return null;
                }
 
-               // Is the bean there?
-               // @TODO Requires this synchronization or is it (sync) confusing the container?
-               if (null == FinancialsUserConverter.USER_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // ... and user controller
-                               FinancialsUserConverter.USER_BEAN = (UserSessionBeanRemote) initialContext.lookup("java:global/jfinancials-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 FinancialsUserConverter implements Converter<User> {
                        Long userId = Long.valueOf(submittedValue);
 
                        // Try to get user instance from it
-                       user = FinancialsUserConverter.USER_BEAN.findUserById(userId);
+                       user = this.userBean.findUserById(userId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index b67bc4d9721b30f7474311ac159b5accf35b850f..258303e20d3ee83da95d1e2c8dfb1fe1a0c4a2a9 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.basicdata.BusinessDataSessionBeanRemote;
 import org.mxchange.jcoreee.validator.string.BaseStringValidator;
 
@@ -34,18 +31,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 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 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 = (BusinessDataSessionBeanRemote) initialContext.lookup("java:global/jfinancials-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 = FinancialsCompanyNameValidator.BASIC_DATA_BEAN.isCompanyNameUsed(companyName);
+               Boolean nameExists = this.basicDataBean.isCompanyNameUsed(companyName);
 
                // Is the user id valid?
                if ((!nameExists) && (checkExisting)) {
index e65c45165c8f2acc3920ed8c4d0dd80d56804522..a185a4fdd9f0afccf2965d533548758acfff430d 100644 (file)
@@ -18,14 +18,12 @@ package org.mxchange.jfinancials.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;
 
@@ -34,13 +32,14 @@ import org.mxchange.jcoreee.validator.string.BaseStringValidator;
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-@FacesValidator ("EmailAddressValidator")
+@FacesValidator (value = "EmailAddressValidator", managed = true)
 public class FinancialsEmailAddressValidator 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 FinancialsEmailAddressValidator 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 == FinancialsEmailAddressValidator.CONTACT_BEAN) {
-                       // Try it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // Try to lookup
-                               FinancialsEmailAddressValidator.CONTACT_BEAN = (ContactSessionBeanRemote) initialContext.lookup("java:global/jfinancials-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 = FinancialsEmailAddressValidator.CONTACT_BEAN.isEmailAddressRegistered(emailAddress);
+               Boolean isRegistered = this.contactBean.isEmailAddressRegistered(emailAddress);
 
                // Is the email address already registered?
                if ((!clientId.endsWith("resendEmailAddress")) && (isRegistered)) { //NOI18N
index 0f32f99ee7ed6493692787ca5c929de62e158d24..ff6ec55a807c7d8842dafcd2f27540d1567a5cd6 100644 (file)
 package org.mxchange.jfinancials.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;
 
@@ -34,18 +31,19 @@ import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-@FacesValidator ("UserIdValidator")
+@FacesValidator (value = "UserIdValidator", managed = true)
 public class FinancialsUserIdValidator 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 FinancialsUserIdValidator 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 == FinancialsUserIdValidator.USER_BEAN) {
-                       // Try to get it
-                       try {
-                               // Get initial context
-                               Context initialContext = new InitialContext();
-
-                               // ... and user controller
-                               FinancialsUserIdValidator.USER_BEAN = (UserSessionBeanRemote) initialContext.lookup("java:global/jfinancials-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 = FinancialsUserIdValidator.USER_BEAN.ifUserIdExists(userId);
+               Boolean ifUserExists = this.userBean.ifUserIdExists(userId);
 
                // Is the user id valid?
                if (!ifUserExists) {