/*
- * Copyright (C) 2016 Roland Haeder
+ * Copyright (C) 2016, 2017 Roland Häder
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
+import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.event.Event;
import javax.enterprise.inject.Any;
import javax.naming.NamingException;
import org.mxchange.addressbook.beans.BaseAddressbookController;
import org.mxchange.jcountry.data.Country;
-import org.mxchange.jphone.events.AdminAddedMobileProviderEvent;
-import org.mxchange.jphone.events.AdminMobileProviderAddedEvent;
+import org.mxchange.jphone.events.mobileprovider.added.AdminAddedMobileProviderEvent;
+import org.mxchange.jphone.events.mobileprovider.added.AdminMobileProviderAddedEvent;
import org.mxchange.jphone.exceptions.MobileProviderAlreadyAddedException;
import org.mxchange.jphone.phonenumbers.mobileprovider.AdminMobileProviderSessionBeanRemote;
import org.mxchange.jphone.phonenumbers.mobileprovider.CellphoneProvider;
/**
* Administrative bean (controller) for mobile provider
* <p>
- * @author Roland Haeder<roland@mxchange.org>
+ * @author Roland Häder<roland@mxchange.org>
*/
@Named ("adminMobileProviderController")
@RequestScoped
* Default constructor
*/
public AddressbookAdminMobileProviderWebRequestBean () {
- // Try it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup the beans
- this.adminRemoteBean = (AdminMobileProviderSessionBeanRemote) context.lookup("java:global/addressbook-ejb/adminmobileprovider!org.mxchange.jphone.phonenumbers.mobileprovider.AdminMobileProviderSessionBeanRemote"); //NOI18N
- } catch (final NamingException e) {
- // Throw it again
- throw new FaceletException(e);
- }
+ // Call super constructor
+ super();
}
@Override
this.providerName = providerName;
}
+ /**
+ * Post-construction method
+ */
+ @PostConstruct
+ public void init () {
+ // Try it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup the beans
+ this.adminRemoteBean = (AdminMobileProviderSessionBeanRemote) context.lookup("java:global/addressbook-ejb/adminMobileProvider!org.mxchange.jphone.phonenumbers.mobileprovider.AdminMobileProviderSessionBeanRemote"); //NOI18N
+ } catch (final NamingException e) {
+ // Throw it again
+ throw new FaceletException(e);
+ }
+ }
+
/**
* Checks whether if the given mobile provider is already created by
* checking both dial prefix and country.
boolean isFound = false;
// Get list of all providers
- List<MobileProvider> providers = this.mobileController.allMobileProvider();
+ List<MobileProvider> providers = this.mobileController.allMobileProviders();
// Get iterator from it
Iterator<MobileProvider> iterator = providers.iterator();