/**
* Mobile provider bean
*/
- private MobileProviderSingletonBeanRemote mobileRemoteBean;
+ private static MobileProviderSingletonBeanRemote MOBILE_PROVIDER_BEAN;
/**
- * Initialization of this converter
+ * Default constructor
*/
public PizzaMobileProviderConverter () {
}
return null;
}
- synchronized (this) {
- // Is the EJB instanciated?
- if (null == this.mobileRemoteBean) {
- // Try to get it
- try {
- // Get initial context
- Context initialContext = new InitialContext();
-
- /// and mobile provider controller
- this.mobileRemoteBean = (MobileProviderSingletonBeanRemote) initialContext.lookup("java:global/pizzaservice-ejb/mobileprovider!org.mxchange.jphone.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote"); //NOI18N
- } catch (final NamingException ex) {
- // Continue to throw it
- throw new ConverterException(MessageFormat.format("initialContext.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
- }
+ // Is the bean there?
+ // @TODO Requires this synchronization or is it (sync) confusing the container?
+ if (null == PizzaMobileProviderConverter.MOBILE_PROVIDER_BEAN) {
+ // Try to get it
+ try {
+ // Get initial context
+ Context initialContext = new InitialContext();
+
+ /// and mobile provider controller
+ PizzaMobileProviderConverter.MOBILE_PROVIDER_BEAN = (MobileProviderSingletonBeanRemote) initialContext.lookup("java:global/pizzaapplication-ejb/mobileprovider!org.mxchange.jphone.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote"); //NOI18N
+ } catch (final NamingException ex) {
+ // Continue to throw it
+ throw new ConverterException(MessageFormat.format("initialContext.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
}
}
// Get full list
- List<MobileProvider> providerList = this.mobileRemoteBean.allMobileProvider();
+ List<MobileProvider> providerList = PizzaMobileProviderConverter.MOBILE_PROVIDER_BEAN.allMobileProvider();
// Init value
MobileProvider provider = null;
@Override
public String getAsString (final FacesContext context, final UIComponent component, final Object value) {
// Is the object null?
- if ((null == value) || ((String.valueOf(value)).isEmpty())) {
+ if ((null == value) || (String.valueOf(value).isEmpty())) {
// Is null
return ""; //NOI18N
} else if (!(value instanceof MobileProvider)) {
// Not same interface
- throw new IllegalArgumentException(MessageFormat.format("value {0} does not implement MobileProvider.", value)); //NOI18N
+ throw new IllegalArgumentException(MessageFormat.format("value[]={0} does not implement MobileProvider.", value.getClass().getSimpleName())); //NOI18N
}
- // Return category id
+ // Return id number
return String.valueOf(((MobileProvider) value).getProviderId());
}