From 012be9c1423e995bcd276933e58525a91fcdf589 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Mon, 15 Feb 2016 19:54:25 +0100 Subject: [PATCH] converters don't have a postconstruct possiblity and no injections/EJBs. So you need to do it the old-fashioned way over constructor and lookup. --- .../converter/country/CountryConverter.java | 15 +++++++-------- .../smsprovider/SmsProviderConverter.java | 13 ++++++------- .../addressbook/converter/user/UserConverter.java | 7 ++++--- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/java/org/mxchange/addressbook/converter/country/CountryConverter.java b/src/java/org/mxchange/addressbook/converter/country/CountryConverter.java index 6606143d..c758b39d 100644 --- a/src/java/org/mxchange/addressbook/converter/country/CountryConverter.java +++ b/src/java/org/mxchange/addressbook/converter/country/CountryConverter.java @@ -19,18 +19,16 @@ package org.mxchange.addressbook.converter.country; import java.text.MessageFormat; import java.util.List; import java.util.Objects; -import javax.annotation.PostConstruct; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.convert.Converter; import javax.faces.convert.FacesConverter; -import javax.inject.Inject; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; -import org.mxchange.addressbook.beans.country.CountryWebApplicationController; import org.mxchange.jcoreeelogger.beans.local.logger.Log; import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal; +import org.mxchange.jcountry.data.AddressbookCountrySingletonBeanRemote; import org.mxchange.jcountry.data.Country; /** @@ -44,8 +42,7 @@ public class CountryConverter implements Converter { /** * Country bean */ - @Inject - private CountryWebApplicationController countryController; + private AddressbookCountrySingletonBeanRemote countryController; /** * Logger instance @@ -56,7 +53,7 @@ public class CountryConverter implements Converter { @Override public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { // Trace message - this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: contect={0},component={1},submittedValue={2} - CALLED!", context, component, submittedValue)); //NOI18N + this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: contect={0},component={1},submittedValue={2},this.countryController={3} - CALLED!", context, component, submittedValue, this.countryController)); //NOI18N // Get full list List countryList = this.countryController.allCountries(); @@ -120,8 +117,7 @@ public class CountryConverter implements Converter { /** * Initialization of this converter */ - @PostConstruct - public void init () { + public CountryConverter () { // Try to get it try { // Get initial context @@ -129,6 +125,9 @@ public class CountryConverter implements Converter { // Lookup logger this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N + + // ... and country controller + this.countryController = (AddressbookCountrySingletonBeanRemote) context.lookup("java:global/addressbook-ejb/country!org.mxchange.jcountry.data.AddressbookCountrySingletonBeanRemote"); //NOI18N } catch (final NamingException ex) { // Continue to throw it throw new RuntimeException("context.lookup() failed.", ex); //NOI18N diff --git a/src/java/org/mxchange/addressbook/converter/smsprovider/SmsProviderConverter.java b/src/java/org/mxchange/addressbook/converter/smsprovider/SmsProviderConverter.java index 0769fb53..464c113e 100644 --- a/src/java/org/mxchange/addressbook/converter/smsprovider/SmsProviderConverter.java +++ b/src/java/org/mxchange/addressbook/converter/smsprovider/SmsProviderConverter.java @@ -19,18 +19,16 @@ package org.mxchange.addressbook.converter.smsprovider; import java.text.MessageFormat; import java.util.List; import java.util.Objects; -import javax.annotation.PostConstruct; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.convert.Converter; import javax.faces.convert.FacesConverter; -import javax.inject.Inject; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; -import org.mxchange.addressbook.beans.smsprovider.SmsProviderWebApplicationController; import org.mxchange.jcoreeelogger.beans.local.logger.Log; import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal; +import org.mxchange.jphone.phonenumbers.smsprovider.AddressbookSmsProviderSingletonBeanRemote; import org.mxchange.jphone.phonenumbers.smsprovider.SmsProvider; /** @@ -50,8 +48,7 @@ public class SmsProviderConverter implements Converter { /** * SMS provider bean */ - @Inject - private SmsProviderWebApplicationController providerController; + private AddressbookSmsProviderSingletonBeanRemote providerController; @Override public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { @@ -120,8 +117,7 @@ public class SmsProviderConverter implements Converter { /** * Initialization of this converter */ - @PostConstruct - public void init () { + public SmsProviderConverter () { // Try to get it try { // Get initial context @@ -129,6 +125,9 @@ public class SmsProviderConverter implements Converter { // Lookup logger this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N + + /// and SMS provider controller + this.providerController = (AddressbookSmsProviderSingletonBeanRemote) context.lookup("java:global/addressbook-ejb/smsprovider!org.mxchange.jphone.phonenumbers.smsprovider.AddressbookSmsProviderSingletonBeanRemote"); //NOI18N } catch (final NamingException ex) { // Continue to throw it throw new RuntimeException("context.lookup() failed.", ex); //NOI18N diff --git a/src/java/org/mxchange/addressbook/converter/user/UserConverter.java b/src/java/org/mxchange/addressbook/converter/user/UserConverter.java index d5e77694..769dc443 100644 --- a/src/java/org/mxchange/addressbook/converter/user/UserConverter.java +++ b/src/java/org/mxchange/addressbook/converter/user/UserConverter.java @@ -17,7 +17,6 @@ package org.mxchange.addressbook.converter.user; import java.text.MessageFormat; -import javax.annotation.PostConstruct; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.convert.Converter; @@ -115,8 +114,7 @@ public class UserConverter implements Converter { /** * Initialization of this converter */ - @PostConstruct - public void init () { + public UserConverter () { // Try to get it try { // Get initial context @@ -124,6 +122,9 @@ public class UserConverter implements Converter { // Lookup logger this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N + + // ... and user controller + this.userController = (UserWebSessionController) context.lookup("java:global/juser-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N } catch (final NamingException ex) { // Continue to throw it throw new RuntimeException("context.lookup() failed.", ex); //NOI18N -- 2.39.5