From 739f0a5e5236b3c748ed2465820899b01c98f9af Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Fri, 19 Feb 2016 15:30:58 +0100 Subject: [PATCH] Organized members to general structure --- .../addressbook/AddressbookIdValidator.java | 40 +++++++-------- .../validator/user/UserIdValidator.java | 49 ++++++++++--------- 2 files changed, 45 insertions(+), 44 deletions(-) diff --git a/src/org/mxchange/addressbook/validator/addressbook/AddressbookIdValidator.java b/src/org/mxchange/addressbook/validator/addressbook/AddressbookIdValidator.java index daccc42..e396e44 100644 --- a/src/org/mxchange/addressbook/validator/addressbook/AddressbookIdValidator.java +++ b/src/org/mxchange/addressbook/validator/addressbook/AddressbookIdValidator.java @@ -56,6 +56,26 @@ public class AddressbookIdValidator extends BaseLongValidator { @Log private LoggerBeanLocal loggerBeanLocal; + /** + * Public consutructor + */ + public AddressbookIdValidator () { + // Try to get it + try { + // Get initial context + Context context = new InitialContext(); + + // 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.addressbookBean = (AddressbookSessionBeanRemote) context.lookup("java:global/addressbook-ejb/addressbook!org.mxchange.addressbook.model.addressbook.AddressbookSessionBeanRemote"); //NOI18N + } catch (final NamingException ex) { + // Continue to throw it + throw new RuntimeException("context.lookup() failed.", ex); //NOI18N + } + } + @Override public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException { // Trace message @@ -97,24 +117,4 @@ public class AddressbookIdValidator extends BaseLongValidator { // Trace message this.loggerBeanLocal.logTrace("validate: EXIT!"); //NOI18N } - - /** - * Public consutructor - */ - public AddressbookIdValidator () { - // Try to get it - try { - // Get initial context - Context context = new InitialContext(); - - // 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.addressbookBean = (AddressbookSessionBeanRemote) context.lookup("java:global/addressbook-ejb/addressbook!org.mxchange.addressbook.model.addressbook.AddressbookSessionBeanRemote"); //NOI18N - } catch (final NamingException ex) { - // Continue to throw it - throw new RuntimeException("context.lookup() failed.", ex); //NOI18N - } - } } diff --git a/src/org/mxchange/addressbook/validator/user/UserIdValidator.java b/src/org/mxchange/addressbook/validator/user/UserIdValidator.java index 2f50468..9333f73 100644 --- a/src/org/mxchange/addressbook/validator/user/UserIdValidator.java +++ b/src/org/mxchange/addressbook/validator/user/UserIdValidator.java @@ -54,16 +54,36 @@ public class UserIdValidator extends BaseLongValidator implements Validator { */ private static final long serialVersionUID = 12_869_569_314_764_690L; + /** + * Logger instance + */ + @Log + private LoggerBeanLocal loggerBeanLocal; + /** * Remote bean */ private UserSessionBeanRemote userBean; /** - * Logger instance + * Initialization of this converter */ - @Log - private LoggerBeanLocal loggerBeanLocal; + public UserIdValidator () { + // Try to get it + try { + // Get initial context + Context context = new InitialContext(); + + // 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.userBean = (UserSessionBeanRemote) 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 + } + } /** * Event fired when the user registration is complete @@ -93,13 +113,13 @@ public class UserIdValidator extends BaseLongValidator implements Validator { User registeredUser = event.getUser(); // Debug message - System.out.println(MessageFormat.format("UserIdValidator:afterRegistrationEvent: registeredUser={0}", registeredUser)); //NOI18N + this.loggerBeanLocal.logDebug(MessageFormat.format("UserIdValidator:afterRegistrationEvent: registeredUser={0}", registeredUser)); //NOI18N // Update cache UserIdValidator.cachedStatus.add(registeredUser.getUserId()); // Trace message - System.out.println("UserIdValidator:afterRegistrationEvent: EXIT!"); //NOI18N + this.loggerBeanLocal.logTrace("UserIdValidator:afterRegistrationEvent: EXIT!"); //NOI18N } @Override @@ -141,23 +161,4 @@ public class UserIdValidator extends BaseLongValidator implements Validator { this.loggerBeanLocal.logTrace("validate: EXIT!"); //NOI18N } - /** - * Initialization of this converter - */ - public UserIdValidator () { - // Try to get it - try { - // Get initial context - Context context = new InitialContext(); - - // 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.userBean = (UserSessionBeanRemote) 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