]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Sun, 3 Sep 2017 02:40:58 +0000 (04:40 +0200)
committerRoland Häder <roland@mxchange.org>
Sat, 16 Sep 2017 13:43:28 +0000 (15:43 +0200)
- if you get something about non-serializable injection, strange things happen,
  sometimes it works here, sometimes not ... :-(
- had to go back to programatic JNDI lookup in converters/validators as the JSF
  2.3 version + xsd reference did mess around with faces-config.xml
  auto-complete (NetBeans) and it looks like that context parameters are not
  loaded
- this way, some lookup() calls are not saved (unmanaged by container) but at
  least it works

Signed-off-by: Roland Häder <roland@mxchange.org>
22 files changed:
src/java/org/mxchange/pizzaapplication/beans/business/basicdata/PizzaBusinessDataWebRequestBean.java
src/java/org/mxchange/pizzaapplication/beans/business/employee/PizzaCompanyEmployeeWebRequestBean.java
src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebRequestBean.java
src/java/org/mxchange/pizzaapplication/beans/contact/phone/PizzaContactPhoneWebRequestBean.java
src/java/org/mxchange/pizzaapplication/beans/country/PizzaCountryWebRequestBean.java
src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestBean.java
src/java/org/mxchange/pizzaapplication/beans/phone/PizzaPhoneWebRequestBean.java
src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebRequestBean.java
src/java/org/mxchange/pizzaapplication/beans/user/activity/PizzaUserActivityWebRequestBean.java
src/java/org/mxchange/pizzaapplication/beans/user/email_address/PizzaEmailChangeWebRequestBean.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/user/PizzaUserConverter.java
src/java/org/mxchange/pizzaapplication/validator/business/basicdata/PizzaCompanyNameValidator.java
src/java/org/mxchange/pizzaapplication/validator/emailaddress/PizzaEmailAddressValidator.java
src/java/org/mxchange/pizzaapplication/validator/user/PizzaUserIdValidator.java

index bdd880e7d676b530ee02ee12f1e62f8dbda0f392..6e0f01c1488de9d63397776dadbcda33d8d43ed6 100644 (file)
@@ -58,8 +58,8 @@ public class PizzaBusinessDataWebRequestBean extends BasePizzaController impleme
         * A list of all registered companies (globally)
         */
        @Inject
-       @NamedCache (cacheName = "basicDataCache", managementEnabled = true)
-       private transient Cache<Long, BusinessBasicData> basicDataCache;
+       @NamedCache (cacheName = "basicDataCache")
+       private Cache<Long, BusinessBasicData> basicDataCache;
 
        /**
         * EJB for general basic business data purposes
index f7ec105acffb9367742883b1522795f53fddaa2f..f129bbdd042ee69df9a60863d119a75ff2a6c9e2 100644 (file)
@@ -54,8 +54,8 @@ public class PizzaCompanyEmployeeWebRequestBean extends BasePizzaController impl
         * List of all company employees
         */
        @Inject
-       @NamedCache (cacheName = "companyEmployeeCache", managementEnabled = true)
-       private transient Cache<Long, Employee> companyEmployeeCache;
+       @NamedCache (cacheName = "companyEmployeeCache")
+       private Cache<Long, Employee> companyEmployeeCache;
 
        /**
         * Default constructor
index 7d374b892c6ba9bc741dca530a7e365bcf680dd2..beb6b4a50c6833f32d0ab09380b82300d49668cb 100644 (file)
@@ -102,8 +102,8 @@ public class PizzaContactWebRequestBean extends BasePizzaController implements P
         * Contact list
         */
        @Inject
-       @NamedCache (cacheName = "contactsCache", managementEnabled = true)
-       private transient Cache<Long, Contact> contactsCache;
+       @NamedCache (cacheName = "contactsCache")
+       private Cache<Long, Contact> contactsCache;
 
        /**
         * Country instance
@@ -119,8 +119,8 @@ public class PizzaContactWebRequestBean extends BasePizzaController implements P
         * Email address list
         */
        @Inject
-       @NamedCache (cacheName = "emailAddressCache", managementEnabled = true)
-       private transient Cache<Long, String> emailAddressCache;
+       @NamedCache (cacheName = "emailAddressCache")
+       private Cache<Long, String> emailAddressCache;
 
        /**
         * Email address repeated
index 7c1ffd64a40b36f9a87289b8da61cdc8fcaf66d8..f8179638e46b73a05ccb18fd10b1bfb680d97dc9 100644 (file)
@@ -69,8 +69,8 @@ public class PizzaContactPhoneWebRequestBean extends BasePizzaController impleme
         * relationship (one contact, many numbers).
         */
        @Inject
-       @NamedCache (cacheName = "contactsPhoneCache", managementEnabled = true)
-       private transient Cache<DialableNumber, List<Contact>> contactsPhoneCache;
+       @NamedCache (cacheName = "contactsPhoneCache")
+       private Cache<DialableNumber, List<Contact>> contactsPhoneCache;
 
        /**
         * fax number
index eaa490f3daf913cace132a60167685601c297c93..16a09c03771706d1e3e14bd07e52834b2f1f5a68 100644 (file)
@@ -57,8 +57,8 @@ public class PizzaCountryWebRequestBean extends BasePizzaController implements P
         * List of all countries
         */
        @Inject
-       @NamedCache (cacheName = "countryCache", managementEnabled = true)
-       private transient Cache<Long, Country> countryCache;
+       @NamedCache (cacheName = "countryCache")
+       private Cache<Long, Country> countryCache;
 
        /**
         * Default constructor
index 4eacb4e0c1037e415c642c537d93db5676901b65..1929e20fb662fb669cfac439c3e9a3ed5451eb93 100644 (file)
@@ -57,8 +57,8 @@ public class PizzaMobileProviderWebRequestBean extends BasePizzaController imple
         * "Cached" list of mobile providers
         */
        @Inject
-       @NamedCache (cacheName = "mobileProviderCache", managementEnabled = true)
-       private transient Cache<Long, MobileProvider> mobileProviderCache;
+       @NamedCache (cacheName = "mobileProviderCache")
+       private Cache<Long, MobileProvider> mobileProviderCache;
 
        /**
         * Default constructor
index dca8cd8ce22776aa5a6856c6e715c9aa115a212d..4cbf5f834ddcccabaea5b284ef2e48029ce7b3f1 100644 (file)
@@ -66,22 +66,22 @@ public class PizzaPhoneWebRequestBean extends BasePizzaController implements Piz
         * All fax numbers
         */
        @Inject
-       @NamedCache (cacheName = "faxNumberCache", managementEnabled = true)
-       private transient Cache<Long, DialableFaxNumber> faxNumberCache;
+       @NamedCache (cacheName = "faxNumberCache")
+       private Cache<Long, DialableFaxNumber> faxNumberCache;
 
        /**
         * All land-line numbers
         */
        @Inject
-       @NamedCache (cacheName = "landLineNumberCache", managementEnabled = true)
-       private transient Cache<Long, DialableLandLineNumber> landLineNumberCache;
+       @NamedCache (cacheName = "landLineNumberCache")
+       private Cache<Long, DialableLandLineNumber> landLineNumberCache;
 
        /**
         * All mobile numbers
         */
        @Inject
-       @NamedCache (cacheName = "mobileNumberCache", managementEnabled = true)
-       private transient Cache<Long, DialableMobileNumber> mobileNumberCache;
+       @NamedCache (cacheName = "mobileNumberCache")
+       private Cache<Long, DialableMobileNumber> mobileNumberCache;
 
        /**
         * General EJB for phone numbers
index a86c718694a0cc8c2dd92d5c9a320f00a1d287c8..af507220cab9baf55e41a11c9528f3155ab1b686 100644 (file)
@@ -119,8 +119,8 @@ public class PizzaUserWebRequestBean extends BasePizzaController implements Pizz
         * A list of all user profiles
         */
        @Inject
-       @NamedCache (cacheName = "userCache", managementEnabled = true)
-       private transient Cache<Long, User> userCache;
+       @NamedCache (cacheName = "userCache")
+       private Cache<Long, User> userCache;
 
        /**
         * User id
@@ -142,8 +142,8 @@ public class PizzaUserWebRequestBean extends BasePizzaController implements Pizz
         * User name list
         */
        @Inject
-       @NamedCache (cacheName = "userNameCache", managementEnabled = true)
-       private transient Cache<Long, String> userNameCache;
+       @NamedCache (cacheName = "userNameCache")
+       private Cache<Long, String> userNameCache;
 
        /**
         * User password (clear-text from web form)
index c9857a1247b17473ae12be9accade86401204ed1..48fa139f12d581f33db87dc5861ad84f05c98220 100644 (file)
@@ -79,8 +79,8 @@ public class PizzaUserActivityWebRequestBean extends BasePizzaController impleme
         * "Cache" for activity log per user
         */
        @Inject
-       @NamedCache (cacheName = "userActivityCache", managementEnabled = true)
-       private transient Cache<User, List<LogableUserActivity>> userActivityCache;
+       @NamedCache (cacheName = "userActivityCache")
+       private Cache<User, List<LogableUserActivity>> userActivityCache;
 
        /**
         * Default constructor
index 9391927abb19d8b8c109cac7e632c68671876bd2..239ea9a6f28912dd2aa290962b5ccd0221ed53d6 100644 (file)
@@ -79,8 +79,8 @@ public class PizzaEmailChangeWebRequestBean extends BasePizzaController implemen
         * Local list of already queued email addresses
         */
        @Inject
-       @NamedCache (cacheName = "queuedEmailCache", managementEnabled = true)
-       private transient Cache<String, Boolean> queuedEmailCache;
+       @NamedCache (cacheName = "queuedEmailCache")
+       private Cache<String, Boolean> queuedEmailCache;
 
        /**
         * Login controller (bean)
index a1a771f2b186bc9b7a2c83906d1ada27bd03daa2..b2d7f0903665fc17743cc7318e1e8b6d3cd85c7b 100644 (file)
  */
 package org.mxchange.pizzaapplication.converter.business.basicdata;
 
-import javax.ejb.EJB;
+import javax.faces.application.FacesMessage;
 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 org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicCompanyDataNotFoundException;
+import javax.faces.validator.ValidatorException;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jcontactsbusiness.basicdata.BusinessBasicData;
+import org.mxchange.jcontactsbusiness.basicdata.BusinessDataSessionBeanRemote;
 
 /**
  * Converter for contact id <-> valid business contact instance
@@ -35,17 +40,24 @@ public class PizzaBusinessContactConverter implements Converter<BusinessBasicDat
        /**
         * Business contact EJB
         */
-       @EJB (lookup = "java:global/jfinancials-ejb/businessData!org.mxchange.jcontactsbusiness.basicdata.BusinessDataSessionBeanRemote")
-       private BusinessDataSessionBeanRemote basicDataBean;
-
-       /**
-        * Default constructor
-        */
-       public PizzaBusinessContactConverter () {
-       }
+       private static BusinessDataSessionBeanRemote BASIC_DATA_BEAN;
 
        @Override
        public BusinessBasicData getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
+               // Is the instance there?
+               if (BASIC_DATA_BEAN == null) {
+                       try {
+                               // Not yet, attempt lookup
+                               Context initial = new InitialContext();
+
+                               // Lookup EJB
+                               BASIC_DATA_BEAN = (BusinessDataSessionBeanRemote) initial.lookup("java:global/jfinancials-ejb/businessData!org.mxchange.jcontactsbusiness.basicdata.BusinessDataSessionBeanRemote");
+                       } catch (final NamingException ex) {
+                               // Throw it again
+                               throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup EJB", ex.getMessage()), ex);
+                       }
+               }
+
                // Is the value null or empty?
                if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
                        // Warning message
@@ -63,7 +75,7 @@ public class PizzaBusinessContactConverter implements Converter<BusinessBasicDat
                        Long basicDataId = Long.valueOf(submittedValue);
 
                        // Try to get user instance from it
-                       businessContact = this.basicDataBean.findBasicDataById(basicDataId);
+                       businessContact = BASIC_DATA_BEAN.findBasicDataById(contactId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index eb2703b208c1b2e34d03a8017a936edfb7bbf36f..706e0d8177aa44ff07cd9a4672569136c16e4446 100644 (file)
  */
 package org.mxchange.pizzaapplication.converter.business.company_employee;
 
-import javax.ejb.EJB;
+import javax.faces.application.FacesMessage;
 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.faces.validator.ValidatorException;
+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;
 
 /**
@@ -35,17 +41,24 @@ public class PizzaCompanyEmployeeConverter implements Converter<Employee> {
        /**
         * CompanyEmployee EJB
         */
-       @EJB (lookup = "java:global/jfinancials-ejb/companyEmployee!org.mxchange.jcontactsbusiness.employee.CompanyEmployeeSessionBeanRemote")
-       private CompanyEmployeeSessionBeanRemote companyEmployeeBean;
-
-       /**
-        * Default constructor
-        */
-       public PizzaCompanyEmployeeConverter () {
-       }
+       private static CompanyEmployeeSessionBeanRemote COMPANY_EMPLOYEE_BEAN;
 
        @Override
        public Employee getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
+               // Is the instance there?
+               if (COMPANY_EMPLOYEE_BEAN == null) {
+                       try {
+                               // Not yet, attempt lookup
+                               Context initial = new InitialContext();
+
+                               // Lookup EJB
+                               COMPANY_EMPLOYEE_BEAN = (CompanyEmployeeSessionBeanRemote) initial.lookup("java:global/jfinancials-ejb/companyEmployee!org.mxchange.jcontactsbusiness.employee.CompanyEmployeeSessionBeanRemote");
+                       } catch (final NamingException ex) {
+                               // Throw it again
+                               throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup EJB", ex.getMessage()), ex);
+                       }
+               }
+
                // Is the value null or empty?
                if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
                        // Warning message
@@ -63,7 +76,7 @@ public class PizzaCompanyEmployeeConverter implements Converter<Employee> {
                        Long employeeId = Long.valueOf(submittedValue);
 
                        // Try to get user instance from it
-                       companyEmployee = this.companyEmployeeBean.findCompanyEmployeeById(employeeId);
+                       companyEmployee = COMPANY_EMPLOYEE_BEAN.findCompanyEmployeeById(employeeId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index 1233fa4a93baaf98167af3f80b55135f9265a76d..59dc0148039e5a50393c6ffa96bea3f89cccbb76 100644 (file)
  */
 package org.mxchange.pizzaapplication.converter.business.headquarters;
 
-import javax.ejb.EJB;
+import javax.faces.application.FacesMessage;
 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.faces.validator.ValidatorException;
+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;
@@ -37,17 +41,24 @@ public class PizzaCompanyHeadquartersConverter implements Converter<Headquarters
        /**
         * CompanyEmployee EJB
         */
-       @EJB (lookup = "java:global/jfinancials-ejb/companyEmployee!org.mxchange.jcontactsbusiness.headquarters.CompanyHeadquartersSessionBeanRemote")
-       private CompanyHeadquartersSessionBeanRemote companyHeadquartersBean;
-
-       /**
-        * Default constructor
-        */
-       public PizzaCompanyHeadquartersConverter () {
-       }
+       private static CompanyHeadquartersSessionBeanRemote COMPANY_HEADQUARTERS_BEAN;
 
        @Override
        public HeadquartersData getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
+               // Is the instance there?
+               if (COMPANY_HEADQUARTERS_BEAN == null) {
+                       try {
+                               // Not yet, attempt lookup
+                               Context initial = new InitialContext();
+
+                               // Lookup EJB
+                               COMPANY_HEADQUARTERS_BEAN = (CompanyHeadquartersSessionBeanRemote) initial.lookup("java:global/jfinancials-ejb/companyEmployee!org.mxchange.jcontactsbusiness.headquarters.CompanyHeadquartersSessionBeanRemote");
+                       } catch (final NamingException ex) {
+                               // Throw it again
+                               throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup EJB", ex.getMessage()), ex);
+                       }
+               }
+
                // Is the value null or empty?
                if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
                        // Warning message
@@ -65,7 +76,7 @@ public class PizzaCompanyHeadquartersConverter implements Converter<Headquarters
                        Long headquartersId = Long.valueOf(submittedValue);
 
                        // Try to get user instance from it
-                       companyHeadquarters = this.companyHeadquartersBean.findCompanyHeadquartersById(headquartersId);
+                       companyHeadquarters = COMPANY_HEADQUARTERS_BEAN.findCompanyHeadquartersById(headquartersId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index d486439d65c3bde4a167411f0192fcefc6d126eb..2cfd87ab43f3adc2517423bb545dd85a36fecb50 100644 (file)
  */
 package org.mxchange.pizzaapplication.converter.contact;
 
-import javax.ejb.EJB;
+import javax.faces.application.FacesMessage;
 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.faces.validator.ValidatorException;
+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;
@@ -37,8 +41,7 @@ public class PizzaContactConverter implements Converter<Contact> {
        /**
         * User EJB
         */
-       @EJB (lookup = "java:global/jfinancials-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote")
-       private ContactSessionBeanRemote contactBean;
+       private static ContactSessionBeanRemote CONTACT_BEAN;
 
        /**
         * Default constructor
@@ -48,6 +51,20 @@ public class PizzaContactConverter implements Converter<Contact> {
 
        @Override
        public Contact getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
+               // Is the instance there?
+               if (CONTACT_BEAN == null) {
+                       try {
+                               // Not yet, attempt lookup
+                               Context initial = new InitialContext();
+
+                               // Lookup EJB
+                               CONTACT_BEAN = (ContactSessionBeanRemote) initial.lookup("java:global/jfinancials-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote");
+                       } catch (final NamingException ex) {
+                               // Throw it again
+                               throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup EJB", ex.getMessage()), ex);
+                       }
+               }
+
                // Is the value null or empty?
                if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
                        // Warning message
@@ -65,7 +82,7 @@ public class PizzaContactConverter implements Converter<Contact> {
                        Long contactId = Long.valueOf(submittedValue);
 
                        // Try to get user instance from it
-                       contact = this.contactBean.findContactById(contactId);
+                       contact = this.CONTACT_BEAN.findContactById(contactId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index e63d29f26e633982cb11caa928a9373c4e538c5e..542b631e86a967b641dd366914fc930c61746b12 100644 (file)
@@ -18,12 +18,16 @@ package org.mxchange.pizzaapplication.converter.country;
 
 import java.util.List;
 import java.util.Objects;
-import javax.ejb.EJB;
+import javax.faces.application.FacesMessage;
 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.faces.validator.ValidatorException;
+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;
 
@@ -38,17 +42,24 @@ public class PizzaCountryConverter implements Converter<Country> {
        /**
         * Country bean
         */
-       @EJB (lookup = "java:global/jfinancials-ejb/country!org.mxchange.jcountry.data.CountrySingletonBeanRemote")
-       private CountrySingletonBeanRemote countryBean;
-
-       /**
-        * Default constructor
-        */
-       public PizzaCountryConverter () {
-       }
+       private static CountrySingletonBeanRemote COUNTRY_BEAN;
 
        @Override
        public Country getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
+               // Is the instance there?
+               if (COUNTRY_BEAN == null) {
+                       try {
+                               // Not yet, attempt lookup
+                               Context initial = new InitialContext();
+
+                               // Lookup EJB
+                               COUNTRY_BEAN = (CountrySingletonBeanRemote) initial.lookup("java:global/jfinancials-ejb/country!org.mxchange.jcountry.data.CountrySingletonBeanRemote");
+                       } catch (final NamingException ex) {
+                               // Throw it again
+                               throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup EJB", ex.getMessage()), ex);
+                       }
+               }
+
                // Is the value null or empty?
                if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
                        // Warning message
@@ -59,7 +70,7 @@ public class PizzaCountryConverter implements Converter<Country> {
                }
 
                // Get full list
-               List<Country> countryList = this.countryBean.allCountries();
+               List<Country> countryList = COUNTRY_BEAN.allCountries();
 
                // Init value
                Country country = null;
index 7e947b239aa56fce78a284815010d594668191f7..1e031fca9c36ce805b3695e95318bc1ba4b2da24 100644 (file)
  */
 package org.mxchange.pizzaapplication.converter.fax;
 
-import javax.ejb.EJB;
+import javax.faces.application.FacesMessage;
 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.faces.validator.ValidatorException;
+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;
@@ -37,17 +41,24 @@ public class PizzaFaxNumberConverter implements Converter<DialableFaxNumber> {
        /**
         * Phone EJB
         */
-       @EJB(lookup = "java:global/jfinancials-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote")
-       private PhoneSessionBeanRemote phoneBean;
-
-       /**
-        * Default constructor
-        */
-       public PizzaFaxNumberConverter () {
-       }
+       private static PhoneSessionBeanRemote PHONE_BEAN;
 
        @Override
        public DialableFaxNumber getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
+               // Is the instance there?
+               if (PHONE_BEAN == null) {
+                       try {
+                               // Not yet, attempt lookup
+                               Context initial = new InitialContext();
+
+                               // Lookup EJB
+                               PHONE_BEAN = (PhoneSessionBeanRemote) initial.lookup("java:global/jfinancials-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote");
+                       } catch (final NamingException ex) {
+                               // Throw it again
+                               throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup EJB", ex.getMessage()), ex);
+                       }
+               }
+
                // Log message
                // @TODO Not possible here: this.loggerBeanLocal.logTrace(MessageFormat.format("{0}.getAsObject: context={1},component={2},submittedValue={3} - CALLED!", this.getClass().getSimpleName(), context, component, submittedValue)); //NOI18N
 
@@ -70,7 +81,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 = this.phoneBean.findFaxNumberById(faxNumberId);
+                       faxNumber = PHONE_BEAN.findFaxNumberById(faxNumberId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index fb7750547a3c20c9177025d71c75316d76b5856b..0fc2270cf886b8e05b7280f3bbe8211bb3c55310 100644 (file)
  */
 package org.mxchange.pizzaapplication.converter.landline;
 
-import javax.ejb.EJB;
+import javax.faces.application.FacesMessage;
 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.faces.validator.ValidatorException;
+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;
@@ -37,17 +41,24 @@ public class PizzaLandLineNumberConverter implements Converter<DialableLandLineN
        /**
         * Phone EJB
         */
-       @EJB(lookup = "java:global/jfinancials-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote")
-       private PhoneSessionBeanRemote phoneBean;
-
-       /**
-        * Default constructor
-        */
-       public PizzaLandLineNumberConverter () {
-       }
+       private static PhoneSessionBeanRemote PHONE_BEAN;
 
        @Override
        public DialableLandLineNumber getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
+               // Is the instance there?
+               if (PHONE_BEAN == null) {
+                       try {
+                               // Not yet, attempt lookup
+                               Context initial = new InitialContext();
+
+                               // Lookup EJB
+                               PHONE_BEAN = (PhoneSessionBeanRemote) initial.lookup("java:global/jfinancials-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote");
+                       } catch (final NamingException ex) {
+                               // Throw it again
+                               throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup EJB", ex.getMessage()), ex);
+                       }
+               }
+
                // Is the value null or empty?
                if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
                        // Warning message
@@ -65,7 +76,7 @@ public class PizzaLandLineNumberConverter implements Converter<DialableLandLineN
                        Long landLineNumberId = Long.valueOf(submittedValue);
 
                        // Try to get mobile instance from it
-                       landLineNumber = this.phoneBean.findLandLineNumberById(landLineNumberId);
+                       landLineNumber = PHONE_BEAN.findLandLineNumberById(landLineNumberId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index 281cd848c33930274caa290c85a1448143ace2ec..9973054f5f8deced72067a1984d9e2144dfe5ccf 100644 (file)
  */
 package org.mxchange.pizzaapplication.converter.mobile;
 
-import javax.ejb.EJB;
+import javax.faces.application.FacesMessage;
 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.faces.validator.ValidatorException;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
 import org.mxchange.jphone.exceptions.PhoneEntityNotFoundException;
 import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
 import org.mxchange.jphone.model.phonenumbers.phone.PhoneSessionBeanRemote;
@@ -37,8 +41,7 @@ public class PizzaMobileNumberConverter implements Converter<DialableMobileNumbe
        /**
         * Phone EJB
         */
-       @EJB (lookup = "java:global/jfinancials-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote")
-       private PhoneSessionBeanRemote phoneBean;
+       private static PhoneSessionBeanRemote PHONE_BEAN;
 
        /**
         * Default constructor
@@ -48,6 +51,20 @@ public class PizzaMobileNumberConverter implements Converter<DialableMobileNumbe
 
        @Override
        public DialableMobileNumber getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
+               // Is the instance there?
+               if (PHONE_BEAN == null) {
+                       try {
+                               // Not yet, attempt lookup
+                               Context initial = new InitialContext();
+
+                               // Lookup EJB
+                               PHONE_BEAN = (PhoneSessionBeanRemote) initial.lookup("java:global/jfinancials-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote");
+                       } catch (final NamingException ex) {
+                               // Throw it again
+                               throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup EJB", ex.getMessage()), ex);
+                       }
+               }
+
                // Is the value null or empty?
                if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
                        // Warning message
@@ -68,7 +85,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 = this.phoneBean.findMobileNumberById(mobileId);
+                       mobileNumber = PHONE_BEAN.findMobileNumberById(mobileId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index 6a718577d53a13a90901baab4461d5120739e478..bcdee373c67f4d9c298367eacc9b98a1cddf69e1 100644 (file)
  */
 package org.mxchange.pizzaapplication.converter.user;
 
-import javax.ejb.EJB;
+import javax.faces.application.FacesMessage;
 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;
@@ -37,17 +40,24 @@ public class PizzaUserConverter implements Converter<User> {
        /**
         * User EJB
         */
-       @EJB(lookup = "java:global/jfinancials-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote")
-       private UserSessionBeanRemote userBean;
-
-       /**
-        * Default constructor
-        */
-       public PizzaUserConverter () {
-       }
+       private static UserSessionBeanRemote USER_BEAN;
 
        @Override
        public User getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
+               // Is the instance there?
+               if (USER_BEAN == null) {
+                       try {
+                               // Not yet, attempt lookup
+                               Context initial = new InitialContext();
+
+                               // Lookup EJB
+                               USER_BEAN = (UserSessionBeanRemote) initial.lookup("java:global/jfinancials-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote");
+                       } catch (final NamingException ex) {
+                               // Throw it again
+                               throw new ConverterException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup EJB", ex.getMessage()), ex);
+                       }
+               }
+
                // Is the value null or empty?
                if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
                        // Warning message
@@ -65,7 +75,7 @@ public class PizzaUserConverter implements Converter<User> {
                        Long userId = Long.valueOf(submittedValue);
 
                        // Try to get user instance from it
-                       user = this.userBean.findUserById(userId);
+                       user = USER_BEAN.findUserById(userId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index 155d0d608373eb8e422d1368204cdbe1057c8d55..3c9f5572537ba11e7ef0b822772539cac4ae4159 100644 (file)
 package org.mxchange.pizzaapplication.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.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;
 
 /**
@@ -30,22 +33,35 @@ import org.mxchange.jcoreee.validator.string.BaseStringValidator;
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-@FacesValidator (value = "CompanyNameValidator", managed = true)
+@FacesValidator ("CompanyNameValidator")
 public class PizzaCompanyNameValidator extends BaseStringValidator {
 
        /**
-        * Serial number
+        * Business contact EJB
         */
-       private static final long serialVersionUID = 57_283_657_476_561L;
+       private static BusinessDataSessionBeanRemote BASIC_DATA_BEAN;
 
        /**
-        * Business contact EJB
+        * Serial number
         */
-       @EJB (lookup = "java:global/jfinancials-ejb/businessData!org.mxchange.jcontactsbusiness.basicdata.BusinessDataSessionBeanRemote")
-       private BusinessDataSessionBeanRemote basicDataBean;
+       private static final long serialVersionUID = 57_283_657_476_561L;
 
        @Override
        public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException {
+               // Is the instance there?
+               if (BASIC_DATA_BEAN == null) {
+                       try {
+                               // Not yet, attempt lookup
+                               Context initial = new InitialContext();
+
+                               // Lookup EJB
+                               BASIC_DATA_BEAN = (BusinessDataSessionBeanRemote) initial.lookup("java:global/jfinancials-ejb/businessData!org.mxchange.jcontactsbusiness.basicdata.BusinessDataSessionBeanRemote");
+                       } catch (final NamingException ex) {
+                               // Throw it again
+                               throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup EJB", ex.getMessage()), ex);
+                       }
+               }
+
                // All accepted, required fields
                String[] requiredFields = {"companyName"}; //NOI18N
 
@@ -74,7 +90,7 @@ public class PizzaCompanyNameValidator extends BaseStringValidator {
                }
 
                // Check if name is already used
-               Boolean nameExists = this.basicDataBean.isCompanyNameUsed(companyName);
+               Boolean nameExists = BASIC_DATA_BEAN.isCompanyNameUsed(companyName);
 
                // Is the user id valid?
                if ((!nameExists) && (checkExisting)) {
index 9f29d9c8a05dcc5dfb7cff7220da548a0fffb7a3..2035efeea4ba32432b3f85ba5d2d2ee34051e6a0 100644 (file)
@@ -18,12 +18,14 @@ 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.model.contact.ContactSessionBeanRemote;
 import org.mxchange.jcoreee.validator.string.BaseStringValidator;
 
@@ -38,8 +40,7 @@ public class PizzaEmailAddressValidator extends BaseStringValidator {
        /**
         * Contact session-scoped bean
         */
-       @EJB (lookup = "java:global/jfinancials-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote")
-       private ContactSessionBeanRemote contactBean;
+       private static ContactSessionBeanRemote CONTACT_BEAN;
 
        /**
         * Email pattern
@@ -56,15 +57,22 @@ public class PizzaEmailAddressValidator extends BaseStringValidator {
         */
        private static final long serialVersionUID = 187_536_745_607_192L;
 
-       /**
-        * Default constructor
-        */
-       public PizzaEmailAddressValidator () {
-       }
-
        @Override
        public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException {
-               System.out.println(this.getClass().getSimpleName() + ".validate(): component.clientId=" + component.getClientId());
+               // Is the instance there?
+               if (CONTACT_BEAN == null) {
+                       try {
+                               // Not yet, attempt lookup
+                               Context initial = new InitialContext();
+
+                               // Lookup EJB
+                               CONTACT_BEAN = (ContactSessionBeanRemote) initial.lookup("java:global/jfinancials-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote");
+                       } catch (final NamingException ex) {
+                               // Throw it again
+                               throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup EJB", ex.getMessage()), ex);
+                       }
+               }
+
                // The required field
                String[] requiredFields = {"emailAddress", "emailAddressRepeat", "resendEmailAddress"}; //NOI18N
 
@@ -75,7 +83,6 @@ public class PizzaEmailAddressValidator extends BaseStringValidator {
                if (component.getAttributes().containsKey("allowEmptyValue")) { //NOI18N
                        // Get attribute
                        Object attribute = component.getAttributes().get("allowEmptyValue"); //NOI18N
-                       System.out.println(this.getClass().getSimpleName() + ".validate():attribute=" + attribute);
 
                        // Make sure, it is Boolean as no String is accepted anymore
                        if (!(attribute instanceof String)) {
@@ -86,7 +93,6 @@ public class PizzaEmailAddressValidator extends BaseStringValidator {
                        // Securely cast it
                        allowEmptyValue = Boolean.parseBoolean((String) attribute);
                }
-               System.out.println(this.getClass().getSimpleName() + ".validate(): allowEmptyValue=" + allowEmptyValue);
 
                // Pre-validation (example: not null, not a string, empty string ...)
                super.preValidate(context, component, value, requiredFields, allowEmptyValue);
@@ -121,7 +127,7 @@ public class PizzaEmailAddressValidator extends BaseStringValidator {
                String clientId = component.getClientId();
 
                // Is it registered?
-               Boolean isRegistered = this.contactBean.isEmailAddressRegistered(emailAddress);
+               Boolean isRegistered = CONTACT_BEAN.isEmailAddressRegistered(emailAddress);
 
                // Is the email address already registered?
                if ((!clientId.endsWith("resendEmailAddress")) && (isRegistered)) { //NOI18N
index 57a8f6ec65258027b852b1814d22cb4c575c512f..abde9cee486a23d72a1d80dec6136b4b279d5a76 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.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;
 
@@ -35,15 +37,14 @@ import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
 public class PizzaUserIdValidator extends BaseNumberValidator {
 
        /**
-        * Serial number
+        * Remote bean
         */
-       private static final long serialVersionUID = 12_869_569_314_764_690L;
+       private static UserSessionBeanRemote USER_BEAN;
 
        /**
-        * Remote bean
+        * Serial number
         */
-       @EJB (lookup = "java:global/jfinancials-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote")
-       private UserSessionBeanRemote userBean;
+       private static final long serialVersionUID = 12_869_569_314_764_690L;
 
        /**
         * Default constructor
@@ -53,6 +54,20 @@ public class PizzaUserIdValidator extends BaseNumberValidator {
 
        @Override
        public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException {
+               // Is the instance there?
+               if (USER_BEAN == null) {
+                       try {
+                               // Not yet, attempt lookup
+                               Context initial = new InitialContext();
+
+                               // Lookup EJB
+                               USER_BEAN = (UserSessionBeanRemote) initial.lookup("java:global/jfinancials-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote");
+                       } catch (final NamingException ex) {
+                               // Throw it again
+                               throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup EJB", ex.getMessage()), ex);
+                       }
+               }
+
                // All accepted, required fields
                String[] requiredFields = {"userId"}; //NOI18N
 
@@ -63,7 +78,7 @@ public class PizzaUserIdValidator extends BaseNumberValidator {
                Long userId = (Long) value;
 
                // Define variable
-               Boolean ifUserExists = this.userBean.ifUserIdExists(userId);
+               Boolean ifUserExists = USER_BEAN.ifUserIdExists(userId);
 
                // Is the user id valid?
                if (!ifUserExists) {