]> git.mxchange.org Git - pizzaservice-ejb.git/commitdiff
Cleanup: (don't cherry-pick, repeat it all)
authorRoland Häder <roland@mxchange.org>
Wed, 27 Apr 2016 08:03:16 +0000 (10:03 +0200)
committerRoland Haeder <roland@mxchange.org>
Wed, 27 Apr 2016 19:09:50 +0000 (21:09 +0200)
- removed mapped names as they are container-specific, better is to use the long portable JNDI names (with interface)
- sorted imports

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jcontacts/contact/PizzaContactSessionBean.java
src/java/org/mxchange/jcountry/data/PizzaCountrySingletonBean.java
src/java/org/mxchange/jmailee/model/delivery/RateCalcEmailDeliveryMessageBean.java [new file with mode: 0644]
src/java/org/mxchange/jphone/phonenumbers/mobileprovider/PizzaAdminMobileProviderSessionBean.java
src/java/org/mxchange/jphone/phonenumbers/mobileprovider/PizzaMobileProviderSingletonBean.java
src/java/org/mxchange/jphone/phonenumbers/phone/PizzaAdminContactPhoneSessionBean.java
src/java/org/mxchange/jphone/phonenumbers/phone/PizzaAdminPhoneSessionBean.java
src/java/org/mxchange/jphone/phonenumbers/phone/PizzaPhoneSessionBean.java
src/java/org/mxchange/jusercore/model/login/PizzaUserLoginSessionBean.java
src/java/org/mxchange/jusercore/model/register/PizzaUserRegistrationSessionBean.java
src/java/org/mxchange/jusercore/model/user/PizzaUserSessionBean.java

index a9505eef8b32eb4dbbedbccab5dc0d7239eab83f..9cd13d5b1ef73c8466ed211b99ab23208dd8da69 100644 (file)
@@ -32,7 +32,7 @@ import org.mxchange.jcontacts.contact.utils.ContactUtils;
  * <p>
  * @author Roland Haeder<roland@mxchange.org>
  */
-@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 {
 
        /**
index feb834039ac8926851e978e6ffc764cb866da89b..814e9e939c9c0a7eef5ead79cc235358fb06dac1 100644 (file)
@@ -33,7 +33,7 @@ import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
  * @author Roland Haeder<roland@mxchange.org>
  */
 @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 (file)
index 0000000..4c509b0
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+ */
+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
+ * <p>
+ * @author Roland Haeder<rhaeder@cho-time.de>
+ */
+@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
+       }
+
+}
index 25df8fd2b758259970ded798d977ee2d6a0d14cf..153d3c9d79b95b3520b63086519c80cd52029dcc 100644 (file)
@@ -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;
index 8e30b7db52bf5cbd5f00b02a06d727422076afa0..df30806368d7fa962b7f71a84093a87b2b8acdba 100644 (file)
@@ -29,7 +29,7 @@ import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
  * @author Roland Haeder<roland@mxchange.org>
  */
 @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 {
 
        /**
index a0e1954c0529db64f9b600d544e0614fb6c7aa4b..2a06c359273be01588e70da3fb314716f7cbda0b 100644 (file)
@@ -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;
  * <p>
  * @author Roland Haeder<roland@mxchange.org>
  */
-@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 {
 
        /**
index 2f99c1c48341a628d67f1e830c135f7052fa68ed..eb37c9d772fee1202ef35003d6290855205a4965 100644 (file)
@@ -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;
  * <p>
  * @author Roland Haeder<roland@mxchange.org>
  */
-@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 {
 
        /**
index a7c0e1ccc825aee2458b06cf6ba8ff0d95acc08b..dfd3defa1109d8675765a5341e24f04b878d64bd 100644 (file)
@@ -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;
  * <p>
  * @author Roland Haeder<roland@mxchange.org>
  */
-@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 {
 
        /**
index 240d98b0b98b6e90c219b4e5556d1ec09d0cecae..15bb461cac7f70d377c32f264a86b31ea77dfca5 100644 (file)
@@ -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;
  * <p>
  * @author Roland Haeder<roland@mxchange.org>
  */
-@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 {
 
        /**
index 8e9fd9ba3a054931f3f5f2a47ca6056c70e1c619..7dcb5f34045f0d77bd2748c3b0c27706967178d5 100644 (file)
@@ -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;
  * <p>
  * @author Roland Haeder<roland@mxchange.org>
  */
-@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 {
 
        /**
index 299e9e5eb5b4578f68b59714ff824a94a009e896..2ce897289601945ebb23155c0f6f16dbd7797b28 100644 (file)
@@ -39,7 +39,7 @@ import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
  * <p>
  * @author Roland Haeder<roland@mxchange.org>
  */
-@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 {
 
        /**