From af672f6dc87071158b31e9661d4776a8eb6e700c Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Mon, 15 Feb 2016 19:54:16 +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 | 13 ++++++------- .../converter/smsprovider/SmsProviderConverter.java | 13 ++++++------- .../addressbook/converter/user/UserConverter.java | 9 ++++----- 3 files changed, 16 insertions(+), 19 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..a70df8ce 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 @@ -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..2b2c2f2b 100644 --- a/src/java/org/mxchange/addressbook/converter/user/UserConverter.java +++ b/src/java/org/mxchange/addressbook/converter/user/UserConverter.java @@ -17,13 +17,11 @@ 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; import javax.faces.convert.ConverterException; import javax.faces.convert.FacesConverter; -import javax.inject.Inject; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; @@ -50,7 +48,6 @@ public class UserConverter implements Converter { /** * User bean */ - @Inject private UserWebSessionController userController; @Override @@ -115,8 +112,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 +120,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