]> git.mxchange.org Git - jfinancials-war.git/blobdiff - src/java/org/mxchange/jfinancials/beans/mobileprovider/FinancialsMobileProviderWebRequestBean.java
Updated copyright year
[jfinancials-war.git] / src / java / org / mxchange / jfinancials / beans / mobileprovider / FinancialsMobileProviderWebRequestBean.java
index 51aac6d3bf19c28f0f58b39e38610ec628e4ea07..64fe9f4658a1e01f07124ba31cc81f71194e08cc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016, 2017 Roland Häder
+ * Copyright (C) 2016 - 2022 Free Software Foundation
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as
  */
 package org.mxchange.jfinancials.beans.mobileprovider;
 
-import fish.payara.cdi.jsr107.impl.NamedCache;
-import java.text.MessageFormat;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import javax.annotation.PostConstruct;
-import javax.cache.Cache;
 import javax.ejb.EJB;
 import javax.enterprise.context.RequestScoped;
-import javax.enterprise.event.Observes;
-import javax.inject.Inject;
 import javax.inject.Named;
-import org.mxchange.jfinancials.beans.BaseFinancialsController;
-import org.mxchange.jphone.events.mobileprovider.added.AdminAddedMobileProviderEvent;
-import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
-import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote;
+import org.mxchange.jfinancials.beans.BaseFinancialsBean;
+import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote;
 
 /**
  * A general bean for mobile providers
@@ -40,7 +29,7 @@ import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProviderSingletonBe
  */
 @Named ("mobileProviderController")
 @RequestScoped
-public class FinancialsMobileProviderWebRequestBean extends BaseFinancialsController implements FinancialsMobileProviderWebRequestController {
+public class FinancialsMobileProviderWebRequestBean extends BaseFinancialsBean implements FinancialsMobileProviderWebRequestController {
 
        /**
         * Serial number
@@ -50,16 +39,9 @@ public class FinancialsMobileProviderWebRequestBean extends BaseFinancialsContro
        /**
         * Remote EJB for mobile providers (regular)
         */
-       @EJB (lookup = "java:global/jfinancials-ejb/mobileprovider!org.mxchange.jphone.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote")
+       @EJB (lookup = "java:global/jfinancials-ejb/mobileProvider!org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote")
        private MobileProviderSingletonBeanRemote mobileProviderBean;
 
-       /**
-        * "Cached" list of mobile providers
-        */
-       @Inject
-       @NamedCache (cacheName = "mobileProviderCache", managementEnabled = true)
-       private transient Cache<Long, MobileProvider> mobileProviderCache;
-
        /**
         * Default constructor
         */
@@ -67,74 +49,4 @@ public class FinancialsMobileProviderWebRequestBean extends BaseFinancialsContro
                // Call super constructor
                super();
        }
-
-       /**
-        * Observes events being fired after the administrator has added a new
-        * mobile provider
-        * <p>
-        * @param event Event being fired
-        */
-       public void afterAdminAddedMobileProviderEvent (@Observes final AdminAddedMobileProviderEvent event) {
-               // Is all valid?
-               if (null == event) {
-                       // Throw NPE
-                       throw new NullPointerException("event is null"); //NOI18N
-               } else if (event.getAddedMobileProvider() == null) {
-                       // Throw again ...
-                       throw new NullPointerException("event.addedMobileProvider is null"); //NOI18N
-               } else if (event.getAddedMobileProvider().getProviderId() == null) {
-                       // And again ...
-                       throw new NullPointerException("event.addedMobileProvider.providerId is null"); //NOI18N
-               } else if (event.getAddedMobileProvider().getProviderId() < 1) {
-                       // Id is invalid
-                       throw new IllegalArgumentException(MessageFormat.format("event.addedMobileProvider.providerId={0} is not valid.", event.getAddedMobileProvider().getProviderId())); //NOI18N
-               }
-
-               // Add it to the list
-               this.mobileProviderCache.put(event.getAddedMobileProvider().getProviderId(), event.getAddedMobileProvider());
-       }
-
-       @Override
-       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
-       public List<MobileProvider> allMobileProviders () {
-               // Init list
-               List<MobileProvider> list = new LinkedList<>();
-
-               // Get iterator
-               Iterator<Cache.Entry<Long, MobileProvider>> iterator = this.mobileProviderCache.iterator();
-
-               // Loop over all
-               while (iterator.hasNext()) {
-                       // Get next entry
-                       final Cache.Entry<Long, MobileProvider> next = iterator.next();
-
-                       // Add value to list
-                       list.add(next.getValue());
-               }
-
-               // Return it
-               return list;
-       }
-
-       /**
-        * Post-construction method
-        */
-       @PostConstruct
-       public void init () {
-               // Is cache there?
-               if (!this.mobileProviderCache.iterator().hasNext()) {
-                       // Get whole list
-                       List<MobileProvider> list = this.mobileProviderBean.allMobileProviders();
-
-                       // Add all
-                       for (final Iterator<MobileProvider> iterator = list.iterator(); iterator.hasNext();) {
-                               // Get next element
-                               final MobileProvider next = iterator.next();
-
-                               // Add it to cache
-                               this.mobileProviderCache.put(next.getProviderId(), next);
-                       }
-               }
-       }
-
 }