*/
package org.mxchange.jjobs.beans.country;
+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.jcoreee.jcache.Cached;
-import org.mxchange.jcountry.data.Country;
-import org.mxchange.jcountry.data.CountrySingletonBeanRemote;
import org.mxchange.jcountry.events.ObservableAdminAddedCountryEvent;
-import org.mxchange.jjobs.beans.BaseJobsController;
+import org.mxchange.jcountry.model.data.Country;
+import org.mxchange.jcountry.model.data.CountrySingletonBeanRemote;
+import org.mxchange.jjobs.beans.BaseJobsBean;
/**
* A country bean
*/
@Named ("countryController")
@RequestScoped
-public class JobsCountryWebRequestBean extends BaseJobsController implements JobsCountryWebRequestController {
+public class JobsCountryWebRequestBean extends BaseJobsBean implements JobsCountryWebRequestController {
/**
* Serial number
/**
* Remote country EJB
*/
- @EJB (lookup = "java:global/jjobs-ejb/country!org.mxchange.jcountry.data.CountrySingletonBeanRemote")
+ @EJB (lookup = "java:global/jjobs-ejb/country!org.mxchange.jcountry.model.data.CountrySingletonBeanRemote")
private CountrySingletonBeanRemote countryBean;
/**
* List of all countries
*/
@Inject
- @Cached (cacheName = "countryCache")
- private transient Cache<Long, Country> countryCache;
+ @NamedCache (cacheName = "countryCache")
+ private Cache<Long, Country> countryCache;
/**
* Default constructor
@SuppressWarnings ("ReturnOfCollectionOrArrayField")
public List<Country> allCountries () {
// Init list
- List<Country> list = new LinkedList<>();
+ final List<Country> list = new LinkedList<>();
// Get iterator
- Iterator<Cache.Entry<Long, Country>> iterator = this.countryCache.iterator();
+ final Iterator<Cache.Entry<Long, Country>> iterator = this.countryCache.iterator();
// Loop over all
while (iterator.hasNext()) {
// Is cache there?
if (!this.countryCache.iterator().hasNext()) {
// Get whole list
- List<Country> list = this.countryBean.allCountries();
+ final List<Country> countries = this.countryBean.allCountries();
// Add all
- for (final Iterator<Country> iterator = list.iterator(); iterator.hasNext();) {
- // Get next element
- final Country next = iterator.next();
-
+ for (final Country country : countries) {
// Add it to cache
- this.countryCache.put(next.getCountryId(), next);
+ this.countryCache.put(country.getCountryId(), country);
}
}
}