]> git.mxchange.org Git - pizzaservice-ejb.git/commitdiff
This bean cannot be singleton as more than one admin may be logged in. It should...
authorRoland Haeder <roland@mxchange.org>
Sun, 17 Apr 2016 14:21:28 +0000 (16:21 +0200)
committerRoland Haeder <roland@mxchange.org>
Sun, 17 Apr 2016 14:24:40 +0000 (16:24 +0200)
lib/jphone-lib.jar
src/java/org/mxchange/jphone/phonenumbers/mobileprovider/PizzaAdminMobileProviderSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jphone/phonenumbers/mobileprovider/PizzaAdminMobileProviderSingletonBean.java [deleted file]

index 2ef50fea49574a9cb8b9915913eb0925e02ff0c2..ff6e0d8aa2b2e41f74b78c3ce34b1b9c1d316176 100644 (file)
Binary files a/lib/jphone-lib.jar and b/lib/jphone-lib.jar differ
diff --git a/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/PizzaAdminMobileProviderSessionBean.java b/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/PizzaAdminMobileProviderSessionBean.java
new file mode 100644 (file)
index 0000000..ceda588
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * 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.jphone.phonenumbers.mobileprovider;
+
+import java.text.MessageFormat;
+import java.util.GregorianCalendar;
+import javax.ejb.Stateless;
+import org.mxchange.jcoreee.database.BaseDatabaseBean;
+import org.mxchange.jphone.exceptions.MobileProviderAlreadyAddedException;
+
+/**
+ * An administrative singleton EJB for mobile provider informations
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@Stateless (name = "adminmobileprovider", description = "A singleton session bean for mobile provider informations, admin-edition")
+public class PizzaAdminMobileProviderSessionBean extends BaseDatabaseBean implements AdminMobileProviderSessionBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 15_846_983_298_691_207L;
+
+       @Override
+       public MobileProvider addMobileProvider (final MobileProvider mobileProvider) throws MobileProviderAlreadyAddedException {
+               // Log trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("addMobileProvider: mobileProvider={0} - CALLED!", mobileProvider)); //NOI18N
+
+               // Is the instance valid?
+               if (null == mobileProvider) {
+                       // Throw NPE
+                       throw new NullPointerException("mobileProvider is null"); //NOI18N
+               } else if (mobileProvider.getProviderDialPrefix() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("mobileProvider.providerDialPrefix is null"); //NOI18N
+               } else if (mobileProvider.getProviderDialPrefix() < 1) {
+                       // Not valid
+                       throw new IllegalArgumentException(MessageFormat.format("mobileProvider.providerDialPrefix={0} is not valid.", mobileProvider.getProviderDialPrefix())); //NOI18N
+               } else if (mobileProvider.getProviderCountry() == null) {
+                       // Throw again a NPE
+                       throw new NullPointerException("mobileProvider.providerCountry is null"); //NOI18N
+               } else if (mobileProvider.getProviderMailPattern() == null) {
+                       // ... and again ...
+                       throw new NullPointerException("mobileProvider.providerMailPattern is null"); //NOI18N
+               } else if (mobileProvider.getProviderMailPattern().isEmpty()) {
+                       // Empty pattern set (not allowed)
+                       throw new IllegalArgumentException("mobileProvider.providerMailPattern is empty."); //NOI18N
+               } else if (!mobileProvider.getProviderMailPattern().contains("%s")) { //NOI18N
+                       // No place-holder found
+                       throw new IllegalArgumentException(MessageFormat.format("mobileProvider.providerMailPattern={0} does not contain '%s' which is need to be replaced with the full mobile number.", mobileProvider.getProviderMailPattern())); //NOI18N
+               } else if (mobileProvider.getProviderName() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("mobileProvider.providerName is null"); //NOI18N
+               } else if (mobileProvider.getProviderName().isEmpty()) {
+                       // Empty name is not allowed
+                       throw new IllegalArgumentException("mobileProvider.providerName is empty"); //NOI18N
+               }
+
+               // Set creation timestamp
+               mobileProvider.setProviderEntryCreated(new GregorianCalendar());
+
+               // Persist it
+               this.getEntityManager().persist(mobileProvider);
+
+               // ... and flush it to get id back
+               this.getEntityManager().flush();
+
+               // Log trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("addMobileProvider: mobileProvider.providerId={0} - EXIT!", mobileProvider.getProviderId())); //NOI18N
+
+               // Return updated
+               return mobileProvider;
+       }
+
+}
diff --git a/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/PizzaAdminMobileProviderSingletonBean.java b/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/PizzaAdminMobileProviderSingletonBean.java
deleted file mode 100644 (file)
index 4ba7008..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2016 Roland Haeder
- *
- * 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.jphone.phonenumbers.mobileprovider;
-
-import java.text.MessageFormat;
-import java.util.GregorianCalendar;
-import javax.ejb.Singleton;
-import javax.ejb.Startup;
-import org.mxchange.jcoreee.database.BaseDatabaseBean;
-import org.mxchange.jphone.exceptions.MobileProviderAlreadyAddedException;
-
-/**
- * An administrative singleton EJB for mobile provider informations
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-@Startup
-@Singleton (name = "adminmobileprovider", mappedName = "ejb/pizzaservice-singleton-admin-mobile-provider", description = "A singleton session bean for mobile provider informations, admin-edition")
-public class PizzaAdminMobileProviderSingletonBean extends BaseDatabaseBean implements AdminMobileProviderSingletonBeanRemote {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 15_846_983_298_691_207L;
-
-       @Override
-       public MobileProvider addMobileProvider (final MobileProvider mobileProvider) throws MobileProviderAlreadyAddedException {
-               // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("addMobileProvider: mobileProvider={0} - CALLED!", mobileProvider)); //NOI18N
-
-               // Is the instance valid?
-               if (null == mobileProvider) {
-                       // Throw NPE
-                       throw new NullPointerException("mobileProvider is null"); //NOI18N
-               } else if (mobileProvider.getProviderDialPrefix() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("mobileProvider.providerDialPrefix is null"); //NOI18N
-               } else if (mobileProvider.getProviderDialPrefix() < 1) {
-                       // Not valid
-                       throw new IllegalArgumentException(MessageFormat.format("mobileProvider.providerDialPrefix={0} is not valid.", mobileProvider.getProviderDialPrefix())); //NOI18N
-               } else if (mobileProvider.getProviderCountry() == null) {
-                       // Throw again a NPE
-                       throw new NullPointerException("mobileProvider.providerCountry is null"); //NOI18N
-               } else if (mobileProvider.getProviderMailPattern() == null) {
-                       // ... and again ...
-                       throw new NullPointerException("mobileProvider.providerMailPattern is null"); //NOI18N
-               } else if (mobileProvider.getProviderMailPattern().isEmpty()) {
-                       // Empty pattern set (not allowed)
-                       throw new IllegalArgumentException("mobileProvider.providerMailPattern is empty."); //NOI18N
-               } else if (!mobileProvider.getProviderMailPattern().contains("%s")) { //NOI18N
-                       // No place-holder found
-                       throw new IllegalArgumentException(MessageFormat.format("mobileProvider.providerMailPattern={0} does not contain '%s' which is need to be replaced with the full mobile number.", mobileProvider.getProviderMailPattern())); //NOI18N
-               } else if (mobileProvider.getProviderName() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("mobileProvider.providerName is null"); //NOI18N
-               } else if (mobileProvider.getProviderName().isEmpty()) {
-                       // Empty name is not allowed
-                       throw new IllegalArgumentException("mobileProvider.providerName is empty"); //NOI18N
-               }
-
-               // Set creation timestamp
-               mobileProvider.setProviderEntryCreated(new GregorianCalendar());
-
-               // Persist it
-               this.getEntityManager().persist(mobileProvider);
-
-               // ... and flush it to get id back
-               this.getEntityManager().flush();
-
-               // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("addMobileProvider: mobileProvider.providerId={0} - EXIT!", mobileProvider.getProviderId())); //NOI18N
-
-               // Return updated
-               return mobileProvider;
-       }
-
-}