* 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
* 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
* Contact list
*/
@Inject
- @NamedCache (cacheName = "contactsCache", managementEnabled = true)
- private transient Cache<Long, Contact> contactsCache;
+ @NamedCache (cacheName = "contactsCache")
+ private Cache<Long, Contact> contactsCache;
/**
* Country instance
* 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
* 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
* 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
* "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
* 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
* 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
* 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)
* "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
* 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)
*/
package org.mxchange.addressbook.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 javax.faces.validator.ValidatorException;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
import org.mxchange.jcontactsbusiness.exceptions.basicdata.BusinessDataNotFoundException;
import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData;
import org.mxchange.jcontactsbusiness.model.basicdata.BusinessDataSessionBeanRemote;
/**
* Business contact EJB
*/
- @EJB (lookup = "java:global/addressbook-ejb/businessData!org.mxchange.jcontactsbusiness.basicdata.BusinessDataSessionBeanRemote")
- private BusinessDataSessionBeanRemote basicDataBean;
+ private static BusinessDataSessionBeanRemote BASIC_DATA_BEAN;
/**
* Default constructor
@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/addressbook-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
Long basicDataId = Long.valueOf(submittedValue);
// Try to get user instance from it
- businessContact = this.basicDataBean.findBasicDataById(basicDataId);
+ businessContact = BASIC_DATA_BEAN.findBasicDataById(basicDataId);
} catch (final NumberFormatException ex) {
// Throw again
throw new ConverterException(ex);
*/
package org.mxchange.addressbook.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.exceptions.employee.CompanyEmployeeNotFoundException;
import org.mxchange.jcontactsbusiness.model.employee.CompanyEmployeeSessionBeanRemote;
import org.mxchange.jcontactsbusiness.model.employee.Employee;
/**
* CompanyEmployee EJB
*/
- @EJB (lookup = "java:global/addressbook-ejb/companyEmployee!org.mxchange.jcontactsbusiness.employee.CompanyEmployeeSessionBeanRemote")
- private CompanyEmployeeSessionBeanRemote companyEmployeeBean;
+ private static CompanyEmployeeSessionBeanRemote COMPANY_EMPLOYEE_BEAN;
/**
* Default constructor
@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/addressbook-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
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);
*/
package org.mxchange.addressbook.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;
/**
* CompanyEmployee EJB
*/
- @EJB (lookup = "java:global/addressbook-ejb/companyEmployee!org.mxchange.jcontactsbusiness.headquarters.CompanyHeadquartersSessionBeanRemote")
- private CompanyHeadquartersSessionBeanRemote companyHeadquartersBean;
+ private static CompanyHeadquartersSessionBeanRemote COMPANY_HEADQUARTERS_BEAN;
/**
* Default constructor
@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/addressbook-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
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);
*/
package org.mxchange.addressbook.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;
/**
* User EJB
*/
- @EJB (lookup = "java:global/addressbook-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote")
- private ContactSessionBeanRemote contactBean;
+ private static ContactSessionBeanRemote CONTACT_BEAN;
/**
* Default constructor
@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/addressbook-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
Long contactId = Long.valueOf(submittedValue);
// Try to get user instance from it
- contact = this.contactBean.findContactById(contactId);
+ contact = CONTACT_BEAN.findContactById(contactId);
} catch (final NumberFormatException ex) {
// Throw again
throw new ConverterException(ex);
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;
/**
* Country bean
*/
- @EJB (lookup = "java:global/addressbook-ejb/country!org.mxchange.jcountry.data.CountrySingletonBeanRemote")
- private CountrySingletonBeanRemote countryBean;
+ private static CountrySingletonBeanRemote COUNTRY_BEAN;
/**
* Default constructor
@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/addressbook-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
}
// Get full list
- List<Country> countryList = this.countryBean.allCountries();
+ List<Country> countryList = COUNTRY_BEAN.allCountries();
// Init value
Country country = null;
*/
package org.mxchange.addressbook.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;
/**
* Phone EJB
*/
- @EJB(lookup = "java:global/addressbook-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote")
- private PhoneSessionBeanRemote phoneBean;
+ private static PhoneSessionBeanRemote PHONE_BEAN;
/**
* Default constructor
@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/addressbook-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
// 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);
*/
package org.mxchange.addressbook.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;
/**
* Phone EJB
*/
- @EJB(lookup = "java:global/addressbook-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote")
- private PhoneSessionBeanRemote phoneBean;
+ private static PhoneSessionBeanRemote PHONE_BEAN;
/**
* Default constructor
@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/addressbook-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
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);
*/
package org.mxchange.addressbook.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;
/**
* Phone EJB
*/
- @EJB (lookup = "java:global/addressbook-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote")
- private PhoneSessionBeanRemote phoneBean;
+ private static PhoneSessionBeanRemote PHONE_BEAN;
/**
* Default constructor
@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/addressbook-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
Long mobileId = Long.valueOf(submittedValue);
// Try to get mobile instance from it
- mobile = this.phoneBean.findMobileNumberById(mobileId);
+ mobile = PHONE_BEAN.findMobileNumberById(mobileId);
} catch (final NumberFormatException ex) {
// Throw again
throw new ConverterException(ex);
*/
package org.mxchange.addressbook.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;
/**
* User EJB
*/
- @EJB(lookup = "java:global/addressbook-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote")
- private UserSessionBeanRemote userBean;
+ private static UserSessionBeanRemote USER_BEAN;
/**
* Default constructor
@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/addressbook-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
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);
package org.mxchange.addressbook.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.model.basicdata.BusinessDataSessionBeanRemote;
import org.mxchange.jcoreee.validator.string.BaseStringValidator;
public class AddressbookCompanyNameValidator 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/addressbook-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/addressbook-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
checkExisting = Boolean.parseBoolean((String) attribute);
}
- Boolean nameExists = this.basicDataBean.isCompanyNameUsed(companyName);
+ // Check if name is already used
+ Boolean nameExists = BASIC_DATA_BEAN.isCompanyNameUsed(companyName);
// Is the user id valid?
if ((!nameExists) && (checkExisting)) {
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;
/**
* Contact session-scoped bean
*/
- @EJB (lookup = "java:global/addressbook-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote")
- private ContactSessionBeanRemote contactBean;
+ private static ContactSessionBeanRemote CONTACT_BEAN;
/**
* Email pattern
@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/addressbook-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
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)) {
// 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);
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
package org.mxchange.addressbook.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;
public class AddressbookUserIdValidator 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/addressbook-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote")
- private UserSessionBeanRemote userBean;
+ private static final long serialVersionUID = 12_869_569_314_764_690L;
/**
* Default constructor
@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/addressbook-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
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) {