]> git.mxchange.org Git - jjobs-war.git/commitdiff
Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Tue, 29 Aug 2017 20:32:55 +0000 (22:32 +0200)
committerRoland Häder <roland@mxchange.org>
Tue, 29 Aug 2017 20:38:20 +0000 (22:38 +0200)
- rewrote initializeList() a bit to become PostConstruct as the injection is
  already done early
- remote more JNDI lookups from PostConstruct-annotated method to @EJB
  annotation

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jjobs/beans/business/basicdata/JobsBusinessDataWebSessionBean.java
src/java/org/mxchange/jjobs/beans/business/employee/JobsCompanyEmployeeWebRequestBean.java
src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java
src/java/org/mxchange/jjobs/beans/country/JobsCountryWebApplicationBean.java
src/java/org/mxchange/jjobs/beans/mobileprovider/JobsMobileProviderWebRequestBean.java
src/java/org/mxchange/jjobs/beans/phone/JobsPhoneWebApplicationBean.java
src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestBean.java
src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionBean.java
src/java/org/mxchange/jjobs/beans/user/activity/JobsUserActivityWebApplicationBean.java
src/java/org/mxchange/jjobs/beans/user/confirmlink/JobsConfirmationLinkWebRequestBean.java
src/java/org/mxchange/jjobs/beans/user/email_address/JobsEmailChangeWebSessionBean.java

index 5c8cd4699633285e71a540931dca683e3faf9db3..3a8b29ea85194f33acd2700f4f538049b780439b 100644 (file)
@@ -19,6 +19,7 @@ package org.mxchange.jjobs.beans.business.basicdata;
 import java.text.MessageFormat;
 import java.util.LinkedList;
 import java.util.List;
+import javax.annotation.PostConstruct;
 import javax.ejb.EJB;
 import javax.enterprise.context.SessionScoped;
 import javax.enterprise.event.Observes;
@@ -153,9 +154,6 @@ public class JobsBusinessDataWebSessionBean extends BaseJobsController implement
                        throw new IllegalArgumentException("event.basicData.companyName is empty");
                }
 
-               // Initialize list
-               this.initializeList();
-
                // Add it to list
                this.businessContacts.add(event.getBasicData());
        }
@@ -167,9 +165,6 @@ public class JobsBusinessDataWebSessionBean extends BaseJobsController implement
         */
        @SuppressWarnings ("ReturnOfCollectionOrArrayField")
        public List<BusinessBasicData> allCompanyBasicData () {
-               // Initialize list
-               this.initializeList();
-
                // Return it
                return this.businessContacts;
        }
@@ -339,12 +334,10 @@ public class JobsBusinessDataWebSessionBean extends BaseJobsController implement
        /**
         * Initializer method
         */
-       private void initializeList () {
-               // Is the list empty?
-               if (this.businessContacts.isEmpty()) {
-                       // Init user's contact list
-                       this.businessContacts.addAll(this.adminBusinessDataBean.allCompanyBasicData());
-               }
+       @PostConstruct
+       public void initializeList () {
+               // Init user's contact list
+               this.businessContacts.addAll(this.adminBusinessDataBean.allCompanyBasicData());
        }
 
 }
index 995bb55a39bff461cdc89e7518be4fa1baa4b04c..e5f255cf2b3ef2e4d9d7639836b994a130cc7c97 100644 (file)
@@ -19,12 +19,9 @@ package org.mxchange.jjobs.beans.business.employee;
 import java.util.LinkedList;
 import java.util.List;
 import javax.annotation.PostConstruct;
+import javax.ejb.EJB;
 import javax.enterprise.context.SessionScoped;
-import javax.faces.view.facelets.FaceletException;
 import javax.inject.Named;
-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.jjobs.beans.BaseJobsController;
@@ -46,6 +43,7 @@ public class JobsCompanyEmployeeWebRequestBean extends BaseJobsController implem
        /**
         * EJB for general company employee purposes
         */
+       @EJB (lookup = "java:global/jjobs-ejb/companyEmployee!org.mxchange.jcontactsbusiness.employee.CompanyEmployeeSessionBeanRemote")
        private CompanyEmployeeSessionBeanRemote companyEmployeeBean;
 
        /**
@@ -79,18 +77,6 @@ public class JobsCompanyEmployeeWebRequestBean extends BaseJobsController implem
         */
        @PostConstruct
        public void init () {
-               // Try it
-               try {
-                       // Get initial context
-                       Context context = new InitialContext();
-
-                       // Try to lookup
-                       this.companyEmployeeBean = (CompanyEmployeeSessionBeanRemote) context.lookup("java:global/jjobs-ejb/companyEmployee!org.mxchange.jcontactsbusiness.employee.CompanyEmployeeSessionBeanRemote"); //NOI18N
-               } catch (final NamingException e) {
-                       // Throw again
-                       throw new FaceletException(e);
-               }
-
                // Get all entries from remote bean
                List<Employee> employees = this.companyEmployeeBean.allCompanyEmployees();
 
index 2dad3ec217a6fa38e27b9aa6d07c1bce6c88c006..142a4d2379fb59aa49d88787b589b8ee66373002 100644 (file)
@@ -24,14 +24,12 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Objects;
 import javax.annotation.PostConstruct;
+import javax.ejb.EJB;
 import javax.enterprise.context.SessionScoped;
 import javax.enterprise.event.Observes;
 import javax.faces.view.facelets.FaceletException;
 import javax.inject.Inject;
 import javax.inject.Named;
-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.contact.ContactUtils;
@@ -95,6 +93,7 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
        /**
         * EJB for general contact purposes
         */
+       @EJB (lookup = "java:global/jjobs-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote")
        private ContactSessionBeanRemote contactBean;
 
        /**
@@ -1015,18 +1014,6 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
         */
        @PostConstruct
        public void init () {
-               // Try it
-               try {
-                       // Get initial context
-                       Context context = new InitialContext();
-
-                       // Try to lookup
-                       this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/jjobs-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N
-               } catch (final NamingException e) {
-                       // Throw again
-                       throw new FaceletException(e);
-               }
-
                // Get full email address list for reducing EJB calls
                this.emailAddressList.addAll(this.contactBean.getEmailAddressList());
 
index ceffa6bbd16df7344b9646b7b8b046df3f07f3fc..967e1abb59bb7329a86a9161c47fb82abb5e799d 100644 (file)
@@ -19,13 +19,10 @@ package org.mxchange.jjobs.beans.country;
 import java.text.MessageFormat;
 import java.util.List;
 import javax.annotation.PostConstruct;
+import javax.ejb.EJB;
 import javax.enterprise.context.ApplicationScoped;
 import javax.enterprise.event.Observes;
-import javax.faces.view.facelets.FaceletException;
 import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
 import org.mxchange.jcountry.data.Country;
 import org.mxchange.jcountry.data.CountrySingletonBeanRemote;
 import org.mxchange.jcountry.events.ObservableAdminAddedCountryEvent;
@@ -48,6 +45,7 @@ public class JobsCountryWebApplicationBean extends BaseJobsController implements
        /**
         * Remote country EJB
         */
+       @EJB (lookup = "java:global/jjobs-ejb/country!org.mxchange.jcountry.data.CountrySingletonBeanRemote")
        private CountrySingletonBeanRemote countryBean;
 
        /**
@@ -101,18 +99,6 @@ public class JobsCountryWebApplicationBean extends BaseJobsController implements
         */
        @PostConstruct
        public void init () {
-               // Try this
-               try {
-                       // Get initial context
-                       Context context = new InitialContext();
-
-                       // Try to lookup the bean
-                       this.countryBean = (CountrySingletonBeanRemote) context.lookup("java:global/jjobs-ejb/country!org.mxchange.jcountry.data.CountrySingletonBeanRemote"); //NOI18N
-               } catch (final NamingException ex) {
-                       // Continue to throw
-                       throw new FaceletException(ex);
-               }
-
                // "Cache" country list as this will not change so often.
                this.countryList = this.countryBean.allCountries();
        }
index a4c8529a88d7f329b6bedc812930814980215db7..30ea72ae5cd305495425b3cca96162bd105ca92c 100644 (file)
@@ -19,13 +19,10 @@ package org.mxchange.jjobs.beans.mobileprovider;
 import java.text.MessageFormat;
 import java.util.List;
 import javax.annotation.PostConstruct;
+import javax.ejb.EJB;
 import javax.enterprise.context.SessionScoped;
 import javax.enterprise.event.Observes;
-import javax.faces.view.facelets.FaceletException;
 import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
 import org.mxchange.jjobs.beans.BaseJobsController;
 import org.mxchange.jphone.events.mobileprovider.added.AdminAddedMobileProviderEvent;
 import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
@@ -53,6 +50,7 @@ public class JobsMobileProviderWebRequestBean extends BaseJobsController impleme
        /**
         * Remote EJB for mobile providers (regular)
         */
+       @EJB (lookup = "java:global/jjobs-ejb/mobileprovider!org.mxchange.jphone.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote")
        private MobileProviderSingletonBeanRemote mobileRemoteBean;
 
        /**
@@ -100,18 +98,6 @@ public class JobsMobileProviderWebRequestBean extends BaseJobsController impleme
         */
        @PostConstruct
        public void init () {
-               // Try it
-               try {
-                       // Get initial context
-                       Context context = new InitialContext();
-
-                       // Try to lookup the beans
-                       this.mobileRemoteBean = (MobileProviderSingletonBeanRemote) context.lookup("java:global/jjobs-ejb/mobileProvider!org.mxchange.jphone.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote"); //NOI18N
-               } catch (final NamingException e) {
-                       // Throw it again
-                       throw new FaceletException(e);
-               }
-
                // Init list of mobile providers
                this.mobileProviders = this.mobileRemoteBean.allMobileProvider();
        }
index 027d49d8ccd56bb70e8d12751e6b8f53945bf0f1..664ca38382a7a8564fc2bd4b5b52a1d7edea1d61 100644 (file)
@@ -21,13 +21,10 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Objects;
 import javax.annotation.PostConstruct;
+import javax.ejb.EJB;
 import javax.enterprise.context.ApplicationScoped;
 import javax.enterprise.event.Observes;
-import javax.faces.view.facelets.FaceletException;
 import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
 import org.mxchange.jcontacts.contact.Contact;
 import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent;
 import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent;
@@ -79,6 +76,7 @@ public class JobsPhoneWebApplicationBean extends BaseJobsController implements J
        /**
         * General EJB for phone numbers
         */
+       @EJB (lookup = "java:global/jjobs-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote")
        private PhoneSessionBeanRemote phoneBean;
 
        /**
@@ -500,18 +498,6 @@ public class JobsPhoneWebApplicationBean extends BaseJobsController implements J
         */
        @PostConstruct
        public void init () {
-               // Try it
-               try {
-                       // Get initial context
-                       Context context = new InitialContext();
-
-                       // Try to lookup the beans
-                       this.phoneBean = (PhoneSessionBeanRemote) context.lookup("java:global/jjobs-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote"); //NOI18N
-               } catch (final NamingException e) {
-                       // Throw it again
-                       throw new FaceletException(e);
-               }
-
                // All phone numbers
                this.allMobileNumbers().addAll(this.phoneBean.allMobileNumbers());
                this.allFaxNumbers().addAll(this.phoneBean.allFaxNumbers());
index 6e05959bb1cc7ed7459984c75ec211e783c41816..b6a1c79c51beee8d9107f6f455a936c3aa12e9f5 100644 (file)
@@ -19,7 +19,7 @@ package org.mxchange.jjobs.beans.user;
 import java.text.MessageFormat;
 import java.util.Locale;
 import java.util.Objects;
-import javax.annotation.PostConstruct;
+import javax.ejb.EJB;
 import javax.enterprise.context.RequestScoped;
 import javax.enterprise.event.Event;
 import javax.enterprise.event.Observes;
@@ -29,9 +29,6 @@ import javax.faces.context.FacesContext;
 import javax.faces.view.facelets.FaceletException;
 import javax.inject.Inject;
 import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
 import org.mxchange.jcontacts.contact.Contact;
 import org.mxchange.jcoreee.utils.FacesUtils;
 import org.mxchange.jjobs.beans.BaseJobsController;
@@ -98,6 +95,7 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J
        /**
         * Administrative user EJB
         */
+       @EJB (lookup = "java:global/jjobs-ejb/adminUser!org.mxchange.jusercore.model.user.AdminUserSessionBeanRemote")
        private AdminUserSessionBeanRemote adminUserBean;
 
        /**
@@ -139,6 +137,7 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J
        /**
         * General user EJB
         */
+       @EJB (lookup = "java:global/jjobs-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote")
        private UserSessionBeanRemote userBean;
 
        /**
@@ -215,7 +214,7 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J
         * @return Redirect outcome
         */
        public String addUser () {
-               System.out.println("addUser: this.contact="+this.getContact());
+               System.out.println("addUser: this.contact=" + this.getContact());
                // As the form cannot validate the data (required="true"), check it here
                if (this.getUserName() == null) {
                        // Throw NPE
@@ -633,25 +632,6 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J
                this.userPasswordRepeat = userPasswordRepeat;
        }
 
-       /**
-        * Post-construction method
-        */
-       @PostConstruct
-       public void init () {
-               // Try it
-               try {
-                       // Get initial context
-                       Context context = new InitialContext();
-
-                       // Try to lookup
-                       this.userBean = (UserSessionBeanRemote) context.lookup("java:global/jjobs-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
-                       this.adminUserBean = (AdminUserSessionBeanRemote) context.lookup("java:global/jjobs-ejb/adminUser!org.mxchange.jusercore.model.user.AdminUserSessionBeanRemote"); //NOI18N
-               } catch (final NamingException e) {
-                       // Throw again
-                       throw new FaceletException(e);
-               }
-       }
-
        /**
         * Locks selected user's account. This method makes sure that a lock reason
         * is provided that th user later can read on login attempts.
index ed1350e7f2a34e04f4efedded4641c1452eb0238..5c9c1a9ccd21e790e239618f9ec517e57efda0e1 100644 (file)
@@ -22,6 +22,7 @@ import java.util.List;
 import java.util.Locale;
 import java.util.Objects;
 import javax.annotation.PostConstruct;
+import javax.ejb.EJB;
 import javax.enterprise.context.SessionScoped;
 import javax.enterprise.event.Event;
 import javax.enterprise.event.Observes;
@@ -30,9 +31,6 @@ import javax.faces.context.FacesContext;
 import javax.faces.view.facelets.FaceletException;
 import javax.inject.Inject;
 import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
 import org.mxchange.jcontacts.contact.Contact;
 import org.mxchange.jcoreee.events.locale.ObservableLocaleChangeEvent;
 import org.mxchange.jjobs.beans.BaseJobsController;
@@ -111,6 +109,7 @@ public class JobsUserWebSessionBean extends BaseJobsController implements JobsUs
        /**
         * Remote user bean
         */
+       @EJB (lookup = "java:global/jjobs-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote")
        private UserSessionBeanRemote userBean;
 
        /**
@@ -832,18 +831,6 @@ public class JobsUserWebSessionBean extends BaseJobsController implements JobsUs
         */
        @PostConstruct
        public void init () {
-               // Try it
-               try {
-                       // Get initial context
-                       Context context = new InitialContext();
-
-                       // Try to lookup
-                       this.userBean = (UserSessionBeanRemote) context.lookup("java:global/jjobs-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
-               } catch (final NamingException e) {
-                       // Throw again
-                       throw new FaceletException(e);
-               }
-
                // Initialize user list
                this.userList = this.userBean.allUsers();
 
index a23698c45cc94b28056ff57234d2a121026bc308..0af72e5236fb9067ecf54ba8520e2e6b38c66941 100644 (file)
@@ -24,13 +24,10 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import javax.annotation.PostConstruct;
+import javax.ejb.EJB;
 import javax.enterprise.context.ApplicationScoped;
 import javax.enterprise.event.Observes;
-import javax.faces.view.facelets.FaceletException;
 import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
 import org.mxchange.jjobs.beans.BaseJobsController;
 import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
 import org.mxchange.jusercore.events.user.created.ObservableCreatedUserEvent;
@@ -74,6 +71,7 @@ public class JobsUserActivityWebApplicationBean extends BaseJobsController imple
        /**
         * EJB for user activity log
         */
+       @EJB (lookup = "java:global/jjobs-ejb/userActivity!org.mxchange.jusercore.model.user.activity.UserActivityLogSessionBeanRemote")
        private UserActivityLogSessionBeanRemote userActivityBean;
 
        /**
@@ -544,18 +542,6 @@ public class JobsUserActivityWebApplicationBean extends BaseJobsController imple
         */
        @PostConstruct
        public void init () {
-               // Try to get EJB instance
-               try {
-                       // Get initial context
-                       Context context = new InitialContext();
-
-                       // Try to lookup
-                       this.userActivityBean = (UserActivityLogSessionBeanRemote) context.lookup("java:global/jjobs-ejb/userActivity!org.mxchange.jusercore.model.user.activity.UserActivityLogSessionBeanRemote"); //NOI18N
-               } catch (final NamingException e) {
-                       // Throw again
-                       throw new FaceletException(e);
-               }
-
                // Get whole list
                List<LogableUserActivity> list = this.userActivityBean.fetchAllUserActivityLog();
 
index 0b6b912c7dd979b5c5aca9afaee8a79d4a145cd4..7f13740fab56d74637844ae3a949d5a3bcc7a70c 100644 (file)
@@ -20,16 +20,13 @@ import java.text.MessageFormat;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Objects;
-import javax.annotation.PostConstruct;
+import javax.ejb.EJB;
 import javax.enterprise.context.RequestScoped;
 import javax.enterprise.event.Event;
 import javax.enterprise.inject.Any;
 import javax.faces.view.facelets.FaceletException;
 import javax.inject.Inject;
 import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
 import org.mxchange.jcoreee.events.helper.clear.HelperCleanupEvent;
 import org.mxchange.jcoreee.events.helper.clear.ObservableHelperCleanupEvent;
 import org.mxchange.jcoreee.utils.FacesUtils;
@@ -74,6 +71,7 @@ public class JobsConfirmationLinkWebRequestBean extends BaseJobsController imple
        /**
         * Remote user bean
         */
+       @EJB (lookup = "java:global/jjobs-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote")
        private UserSessionBeanRemote userBean;
 
        /**
@@ -114,24 +112,6 @@ public class JobsConfirmationLinkWebRequestBean extends BaseJobsController imple
                this.confirmationKey = confirmationKey;
        }
 
-       /**
-        * Post-construction method
-        */
-       @PostConstruct
-       public void init () {
-               // Try it
-               try {
-                       // Get initial context
-                       Context context = new InitialContext();
-
-                       // Try to lookup
-                       this.userBean = (UserSessionBeanRemote) context.lookup("java:global/jjobs-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
-               } catch (final NamingException e) {
-                       // Throw again
-                       throw new FaceletException(e);
-               }
-       }
-
        @Override
        public void maybeConfirmUserAccount () {
                // Trace message
index 2e223024a279874304998389c70c42329ae8a26b..9de30f10b8a469993f789a6734a5a86701ea5ede 100644 (file)
@@ -20,13 +20,11 @@ import java.text.MessageFormat;
 import java.util.List;
 import java.util.Objects;
 import javax.annotation.PostConstruct;
+import javax.ejb.EJB;
 import javax.enterprise.context.SessionScoped;
 import javax.faces.view.facelets.FaceletException;
 import javax.inject.Inject;
 import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
 import org.mxchange.jcontacts.contact.Contact;
 import org.mxchange.jcoreee.utils.FacesUtils;
 import org.mxchange.jjobs.beans.BaseJobsController;
@@ -70,6 +68,7 @@ public class JobsEmailChangeWebSessionBean extends BaseJobsController implements
        /**
         * Remote email change bean
         */
+       @EJB (lookup = "java:global/jjobs-ejb/userEmailChange!org.mxchange.jusercore.model.user.email_address.UserEmailChangeSessionBeanRemote")
        private UserEmailChangeSessionBeanRemote emailChangeBean;
 
        /**
@@ -197,18 +196,6 @@ public class JobsEmailChangeWebSessionBean extends BaseJobsController implements
         */
        @PostConstruct
        public void init () {
-               // Try it
-               try {
-                       // Get initial context
-                       Context context = new InitialContext();
-
-                       // Try to lookup
-                       this.emailChangeBean = (UserEmailChangeSessionBeanRemote) context.lookup("java:global/jjobs-ejb/userEmailChange!org.mxchange.jusercore.model.email_address.EmailChangeSessionBeanRemote"); //NOI18N
-               } catch (final NamingException e) {
-                       // Throw again
-                       throw new FaceletException(e);
-               }
-
                // Init list
                this.emailAddresses = this.emailChangeBean.allQueuedAddresses();
        }