From dc42360d34217de267febabebd8b7f0212aba244 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 27 Apr 2016 10:03:16 +0200 Subject: [PATCH] Cleanup: (don't cherry-pick, repeat it all) - removed mapped names as they are container-specific, better is to use the long portable JNDI names (with interface) - sorted imports MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../contact/PizzaContactSessionBean.java | 2 +- .../data/PizzaCountrySingletonBean.java | 2 +- .../RateCalcEmailDeliveryMessageBean.java | 120 ++++++++++++++++++ .../PizzaAdminMobileProviderSessionBean.java | 1 + .../PizzaMobileProviderSingletonBean.java | 2 +- .../PizzaAdminContactPhoneSessionBean.java | 3 +- .../phone/PizzaAdminPhoneSessionBean.java | 3 +- .../phone/PizzaPhoneSessionBean.java | 3 +- .../login/PizzaUserLoginSessionBean.java | 3 +- .../PizzaUserRegistrationSessionBean.java | 3 +- .../model/user/PizzaUserSessionBean.java | 2 +- 11 files changed, 135 insertions(+), 9 deletions(-) create mode 100644 src/java/org/mxchange/jmailee/model/delivery/RateCalcEmailDeliveryMessageBean.java diff --git a/src/java/org/mxchange/jcontacts/contact/PizzaContactSessionBean.java b/src/java/org/mxchange/jcontacts/contact/PizzaContactSessionBean.java index a9505ee..9cd13d5 100644 --- a/src/java/org/mxchange/jcontacts/contact/PizzaContactSessionBean.java +++ b/src/java/org/mxchange/jcontacts/contact/PizzaContactSessionBean.java @@ -32,7 +32,7 @@ import org.mxchange.jcontacts.contact.utils.ContactUtils; *

* @author Roland Haeder */ -@Stateless (name = "contact", mappedName = "ejb/stateless-pizza-contact", description = "A bean handling contact data") +@Stateless (name = "contact", description = "A bean handling contact data") public class PizzaContactSessionBean extends BasePizzaDatabaseBean implements ContactSessionBeanRemote { /** diff --git a/src/java/org/mxchange/jcountry/data/PizzaCountrySingletonBean.java b/src/java/org/mxchange/jcountry/data/PizzaCountrySingletonBean.java index feb8340..814e9e9 100644 --- a/src/java/org/mxchange/jcountry/data/PizzaCountrySingletonBean.java +++ b/src/java/org/mxchange/jcountry/data/PizzaCountrySingletonBean.java @@ -33,7 +33,7 @@ import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean; * @author Roland Haeder */ @Startup -@Singleton (name = "country", mappedName = "ejb/pizzaservice-singleton-country", description = "A singleton session bean for country informations") +@Singleton (name = "country", description = "A singleton session bean for country informations") public class PizzaCountrySingletonBean extends BasePizzaDatabaseBean implements CountrySingletonBeanRemote { /** diff --git a/src/java/org/mxchange/jmailee/model/delivery/RateCalcEmailDeliveryMessageBean.java b/src/java/org/mxchange/jmailee/model/delivery/RateCalcEmailDeliveryMessageBean.java new file mode 100644 index 0000000..4c509b0 --- /dev/null +++ b/src/java/org/mxchange/jmailee/model/delivery/RateCalcEmailDeliveryMessageBean.java @@ -0,0 +1,120 @@ +/* + * Copyright (C) 2016 Cho-Time GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.mxchange.jmailee.model.delivery; + +import java.io.Serializable; +import java.text.MessageFormat; +import javax.ejb.ActivationConfigProperty; +import javax.ejb.MessageDriven; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageListener; +import javax.jms.ObjectMessage; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import org.mxchange.jcoreeelogger.beans.local.logger.Log; +import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal; + +/** + * A message queue for sending out emails + *

+ * @author Roland Haeder + */ +@MessageDriven ( + name = "rateCalcEmail", + description = "A message bean for email delivery", + activationConfig = { + @ActivationConfigProperty (propertyName = "destinationLookup", propertyValue = "jms/jratecalc-email-queue"), + @ActivationConfigProperty (propertyName = "destinationType", propertyValue = "javax.jms.Queue") + } +) +public class RateCalcEmailDeliveryMessageBean implements MessageListener { + + /** + * Logger bean + */ + @Log + private LoggerBeanLocal loggerBeanLocal; + + /** + * Default constructor + */ + public RateCalcEmailDeliveryMessageBean () { + 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 + } catch (final NamingException ex) { + // Continue to throw + throw new RuntimeException(MessageFormat.format("context.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N + } + } + + @Override + public void onMessage (final Message message) { + // Trace message + this.loggerBeanLocal.logTrace(MessageFormat.format("onMessage: message={0} - CALLED!", message)); //NOI18N + + // Is the message castable to ObjectMessage? + if (null == message) { + // message is null + throw new NullPointerException("message is null"); //NOI18N + } else if (!(message instanceof ObjectMessage)) { + // Not castable + throw new ClassCastException(MessageFormat.format("message cannot be casted to ObjectMessage: {0}", message)); //NOI18N + } + + // Securely cast it + ObjectMessage objectMessage = (ObjectMessage) message; + + // Init instance + Serializable object; + + try { + // Get object from it + object = objectMessage.getObject(); + } catch (final JMSException ex) { + // Log exception ... + this.loggerBeanLocal.logException(ex); + + // ... and don't continue + return; + } + + // Debug message + this.loggerBeanLocal.logDebug(MessageFormat.format("onMessage: object={0}", object)); //NOI18N + + // Does this object implement WrapableCheckout ? + if (null == object) { + // object cannot be null + throw new NullPointerException("object is null"); //NOI18N + } else if (!(object instanceof WrapableEmailDelivery)) { + // Not proper interface used + throw new ClassCastException(MessageFormat.format("object does not implement WrapableEmailDelivery: {0}", object)); //NOI18N + } + + // Cast the object to the wrapper interface + WrapableEmailDelivery emailDelivery = (WrapableEmailDelivery) object; + + // Trace message + this.loggerBeanLocal.logTrace("onMessage: EXIT!"); //NOI18N + } + +} diff --git a/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/PizzaAdminMobileProviderSessionBean.java b/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/PizzaAdminMobileProviderSessionBean.java index 25df8fd..153d3c9 100644 --- a/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/PizzaAdminMobileProviderSessionBean.java +++ b/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/PizzaAdminMobileProviderSessionBean.java @@ -16,6 +16,7 @@ */ package org.mxchange.jphone.phonenumbers.mobileprovider; +import de.chotime.jratecalc.database.BaseRateCalcDatabaseBean; import java.text.MessageFormat; import java.util.GregorianCalendar; import javax.ejb.Stateless; diff --git a/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/PizzaMobileProviderSingletonBean.java b/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/PizzaMobileProviderSingletonBean.java index 8e30b7d..df30806 100644 --- a/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/PizzaMobileProviderSingletonBean.java +++ b/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/PizzaMobileProviderSingletonBean.java @@ -29,7 +29,7 @@ import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean; * @author Roland Haeder */ @Startup -@Singleton (name = "mobileprovider", mappedName = "ejb/pizzaservice-singleton-mobile-provider", description = "A singleton session bean for mobile provider informations") +@Singleton (name = "mobileprovider", description = "A singleton session bean for mobile provider informations") public class PizzaMobileProviderSingletonBean extends BasePizzaDatabaseBean implements MobileProviderSingletonBeanRemote { /** diff --git a/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaAdminContactPhoneSessionBean.java b/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaAdminContactPhoneSessionBean.java index a0e1954..2a06c35 100644 --- a/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaAdminContactPhoneSessionBean.java +++ b/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaAdminContactPhoneSessionBean.java @@ -16,6 +16,7 @@ */ package org.mxchange.jphone.phonenumbers.phone; +import de.chotime.jratecalc.database.BaseRateCalcDatabaseBean; import java.text.MessageFormat; import java.util.List; import javax.ejb.Stateless; @@ -31,7 +32,7 @@ import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean; *

* @author Roland Haeder */ -@Stateless (name = "admincontactphone", mappedName = "ejb/stateless-pizza-admin-contact-phone", description = "Administrative bean handling contact's phone data") +@Stateless (name = "admincontactphone", description = "Administrative bean handling contact's phone data") public class PizzaAdminContactPhoneSessionBean extends BasePizzaDatabaseBean implements AdminContactsPhoneSessionBeanRemote { /** diff --git a/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaAdminPhoneSessionBean.java b/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaAdminPhoneSessionBean.java index 2f99c1c..eb37c9d 100644 --- a/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaAdminPhoneSessionBean.java +++ b/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaAdminPhoneSessionBean.java @@ -16,6 +16,7 @@ */ package org.mxchange.jphone.phonenumbers.phone; +import de.chotime.jratecalc.database.BaseRateCalcDatabaseBean; import javax.ejb.Stateless; import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean; @@ -24,7 +25,7 @@ import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean; *

* @author Roland Haeder */ -@Stateless (name = "adminphone", mappedName = "ejb/stateless-pizza-admin-phone", description = "Administrative bean handling phone data") +@Stateless (name = "adminphone", description = "Administrative bean handling phone data") public class PizzaAdminPhoneSessionBean extends BasePizzaDatabaseBean implements AdminPhoneSessionBeanRemote { /** diff --git a/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaPhoneSessionBean.java b/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaPhoneSessionBean.java index a7c0e1c..dfd3def 100644 --- a/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaPhoneSessionBean.java +++ b/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaPhoneSessionBean.java @@ -16,6 +16,7 @@ */ package org.mxchange.jphone.phonenumbers.phone; +import de.chotime.jratecalc.database.BaseRateCalcDatabaseBean; import java.text.MessageFormat; import javax.ejb.Stateless; import javax.persistence.NoResultException; @@ -29,7 +30,7 @@ import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean; *

* @author Roland Haeder */ -@Stateless (name = "phone", mappedName = "ejb/stateless-pizza-phone", description = "A bean handling phone data") +@Stateless (name = "phone", description = "A bean handling phone data") public class PizzaPhoneSessionBean extends BasePizzaDatabaseBean implements PhoneSessionBeanRemote { /** diff --git a/src/java/org/mxchange/jusercore/model/login/PizzaUserLoginSessionBean.java b/src/java/org/mxchange/jusercore/model/login/PizzaUserLoginSessionBean.java index 240d98b..15bb461 100644 --- a/src/java/org/mxchange/jusercore/model/login/PizzaUserLoginSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/login/PizzaUserLoginSessionBean.java @@ -16,6 +16,7 @@ */ package org.mxchange.jusercore.model.login; +import de.chotime.jratecalc.database.BaseRateCalcDatabaseBean; import java.text.MessageFormat; import javax.ejb.EJB; import javax.ejb.Stateless; @@ -36,7 +37,7 @@ import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean; *

* @author Roland Haeder */ -@Stateless (name = "login", mappedName = "ejb/stateless-pizza-login", description = "A bean handling the user login") +@Stateless (name = "login", description = "A bean handling the user login") public class PizzaUserLoginSessionBean extends BasePizzaDatabaseBean implements UserLoginSessionBeanRemote { /** diff --git a/src/java/org/mxchange/jusercore/model/register/PizzaUserRegistrationSessionBean.java b/src/java/org/mxchange/jusercore/model/register/PizzaUserRegistrationSessionBean.java index 8e9fd9b..7dcb5f3 100644 --- a/src/java/org/mxchange/jusercore/model/register/PizzaUserRegistrationSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/register/PizzaUserRegistrationSessionBean.java @@ -16,6 +16,7 @@ */ package org.mxchange.jusercore.model.register; +import de.chotime.jratecalc.database.BaseRateCalcDatabaseBean; import java.text.MessageFormat; import javax.ejb.EJB; import javax.ejb.Stateless; @@ -30,7 +31,7 @@ import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean; *

* @author Roland Haeder */ -@Stateless (name = "register", mappedName = "ejb/stateless-pizza-register", description = "A bean handling the user registration") +@Stateless (name = "register", description = "A bean handling the user registration") public class PizzaUserRegistrationSessionBean extends BasePizzaDatabaseBean implements UserRegistrationSessionBeanRemote { /** diff --git a/src/java/org/mxchange/jusercore/model/user/PizzaUserSessionBean.java b/src/java/org/mxchange/jusercore/model/user/PizzaUserSessionBean.java index 299e9e5..2ce8972 100644 --- a/src/java/org/mxchange/jusercore/model/user/PizzaUserSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/user/PizzaUserSessionBean.java @@ -39,7 +39,7 @@ import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean; *

* @author Roland Haeder */ -@Stateless (name = "user", mappedName = "ejb/stateless-pizza-user", description = "A bean handling the user data") +@Stateless (name = "user", description = "A bean handling the user data") public class PizzaUserSessionBean extends BasePizzaDatabaseBean implements UserSessionBeanRemote { /** -- 2.39.5