]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Sun, 3 Sep 2017 15:50:06 +0000 (17:50 +0200)
committerRoland Häder <roland@mxchange.org>
Sat, 16 Sep 2017 13:45:01 +0000 (15:45 +0200)
- removed not needed constructor from converter/validator
- reverted `@EJB` annotation in mobile-provider converter as it was not working

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/pizzaapplication/converter/contact/PizzaContactConverter.java
src/java/org/mxchange/pizzaapplication/converter/mobile/PizzaMobileNumberConverter.java
src/java/org/mxchange/pizzaapplication/converter/mobileprovider/PizzaMobileProviderConverter.java
src/java/org/mxchange/pizzaapplication/validator/birthday/PizzaBirthdayValidator.java
src/java/org/mxchange/pizzaapplication/validator/url/PizzaUrlValidator.java
src/java/org/mxchange/pizzaapplication/validator/user/PizzaUserIdValidator.java

index 2cfd87ab43f3adc2517423bb545dd85a36fecb50..2db3f4cc834908ce7f27e61173390c18dbb6afc3 100644 (file)
@@ -43,12 +43,6 @@ public class PizzaContactConverter implements Converter<Contact> {
         */
        private static ContactSessionBeanRemote CONTACT_BEAN;
 
-       /**
-        * Default constructor
-        */
-       public PizzaContactConverter () {
-       }
-
        @Override
        public Contact getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
                // Is the instance there?
index 9973054f5f8deced72067a1984d9e2144dfe5ccf..aeb56be29331652e8e564d0d15839caf3b28f265 100644 (file)
@@ -43,12 +43,6 @@ public class PizzaMobileNumberConverter implements Converter<DialableMobileNumbe
         */
        private static PhoneSessionBeanRemote PHONE_BEAN;
 
-       /**
-        * Default constructor
-        */
-       public PizzaMobileNumberConverter () {
-       }
-
        @Override
        public DialableMobileNumber getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
                // Is the instance there?
index 07fc7e83f5acc92c297ce4cedeaa67e99d1f7e7b..278b4331c0d0ae7bf61e4926339125aebfe55937 100644 (file)
@@ -18,11 +18,15 @@ package org.mxchange.pizzaapplication.converter.mobileprovider;
 
 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.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
 import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
 import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote;
 
@@ -37,17 +41,24 @@ public class PizzaMobileProviderConverter implements Converter<MobileProvider> {
        /**
         * Mobile provider bean
         */
-       @EJB(lookup = "java:global/jfinancials-ejb/mobileprovider!org.mxchange.jphone.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote")
-       private MobileProviderSingletonBeanRemote mobileProviderBean;
-
-       /**
-        * Default constructor
-        */
-       public PizzaMobileProviderConverter () {
-       }
+       private static MobileProviderSingletonBeanRemote MOBILE_PROVIDER_BEAN;
 
        @Override
        public MobileProvider getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
+               // Is the instance there?
+               if (MOBILE_PROVIDER_BEAN == null) {
+                       try {
+                               // Not yet, attempt lookup
+                               Context initial = new InitialContext();
+
+                               // Lookup EJB
+                               MOBILE_PROVIDER_BEAN = (MobileProviderSingletonBeanRemote) initial.lookup("java:global/jfinancials-ejb/mobileprovider!org.mxchange.jphone.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote");
+                       } 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
@@ -58,7 +69,7 @@ public class PizzaMobileProviderConverter implements Converter<MobileProvider> {
                }
 
                // Get full list
-               List<MobileProvider> providerList = this.mobileProviderBean.allMobileProviders();
+               List<MobileProvider> providerList = this.MOBILE_PROVIDER_BEAN.allMobileProviders();
 
                // Init value
                MobileProvider provider = null;
index 5dbc3fd19eb2aa53229ac834b5baee4012f84990..a730a0d88641092df199fdea2b15e91c7c4b2639 100644 (file)
@@ -36,12 +36,6 @@ public class PizzaBirthdayValidator extends BaseDateValidator {
         */
        private static final long serialVersionUID = 28_735_756_819_460L;
 
-       /**
-        * Default constructor
-        */
-       public PizzaBirthdayValidator () {
-       }
-
        @Override
        public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException {
                // All accepted, required fields
index 101fd758f6f85b54783a22c9650edc339420fb9a..579d9c083199abe3e612c20389af8f89c29b41e0 100644 (file)
@@ -49,12 +49,6 @@ public class PizzaUrlValidator extends BaseStringValidator {
         */
        private static final long serialVersionUID = 187_536_745_607_193L;
 
-       /**
-        * Default constructor
-        */
-       public PizzaUrlValidator () {
-       }
-
        @Override
        public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException {
                // The required field
index abde9cee486a23d72a1d80dec6136b4b279d5a76..bb8dda7ecf85dfe777fd3a15c573258b59080e7a 100644 (file)
@@ -46,12 +46,6 @@ public class PizzaUserIdValidator extends BaseNumberValidator {
         */
        private static final long serialVersionUID = 12_869_569_314_764_690L;
 
-       /**
-        * Default constructor
-        */
-       public PizzaUserIdValidator () {
-       }
-
        @Override
        public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException {
                // Is the instance there?