*/
package org.opendaylight.transportpce.networkmodel;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
import org.opendaylight.mdsal.binding.api.NotificationService;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.transportpce.common.InstanceIdentifiers;
import org.opendaylight.transportpce.common.NetworkUtils;
+import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
+import org.opendaylight.transportpce.common.mapping.PortMapping;
import org.opendaylight.transportpce.common.network.NetworkTransactionService;
import org.opendaylight.transportpce.networkmodel.listeners.PortMappingListener;
import org.opendaylight.transportpce.networkmodel.listeners.ServiceHandlerListener;
import org.opendaylight.transportpce.networkmodel.service.FrequenciesService;
+import org.opendaylight.transportpce.networkmodel.service.NetworkModelService;
import org.opendaylight.transportpce.networkmodel.util.TpceNetwork;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev220630.TransportpceNetworkutilsService;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.Network;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev201125.TransportpceServicehandlerListener;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.concepts.ObjectRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@Component
public class NetworkModelProvider {
private static final Logger LOG = LoggerFactory.getLogger(NetworkModelProvider.class);
private final NetConfTopologyListener topologyListener;
private ListenerRegistration<NetConfTopologyListener> dataTreeChangeListenerRegistration;
private ListenerRegistration<PortMappingListener> mappingListenerRegistration;
- private ObjectRegistration<TransportpceNetworkutilsService> networkutilsServiceRpcRegistration;
+ private @NonNull Registration networkutilsServiceRpcRegistration;
private TpceNetwork tpceNetwork;
private ListenerRegistration<TransportpceServicehandlerListener> serviceHandlerListenerRegistration;
private NotificationService notificationService;
private FrequenciesService frequenciesService;
private PortMappingListener portMappingListener;
- public NetworkModelProvider(NetworkTransactionService networkTransactionService, final DataBroker dataBroker,
- final RpcProviderService rpcProviderService, final TransportpceNetworkutilsService networkutilsService,
- final NetConfTopologyListener topologyListener, NotificationService notificationService,
- FrequenciesService frequenciesService, PortMappingListener portMappingListener) {
+ @Activate
+ public NetworkModelProvider(@Reference NetworkTransactionService networkTransactionService,
+ @Reference final DataBroker dataBroker,
+ @Reference final RpcProviderService rpcProviderService,
+ @Reference final NetworkModelService networkModelService,
+ @Reference DeviceTransactionManager deviceTransactionManager,
+ @Reference PortMapping portMapping,
+ @Reference NotificationService notificationService,
+ @Reference FrequenciesService frequenciesService) {
this.dataBroker = dataBroker;
this.rpcProviderService = rpcProviderService;
- this.networkutilsService = networkutilsService;
- this.topologyListener = topologyListener;
- this.tpceNetwork = new TpceNetwork(networkTransactionService);
this.notificationService = notificationService;
this.frequenciesService = frequenciesService;
- this.portMappingListener = portMappingListener;
+ this.networkutilsService = new NetworkUtilsImpl(dataBroker);
+ this.topologyListener = new NetConfTopologyListener(networkModelService, dataBroker, deviceTransactionManager,
+ portMapping);
+ this.tpceNetwork = new TpceNetwork(networkTransactionService);
+ this.portMappingListener = new PortMappingListener(networkModelService);
+ this.init();
}
/**
* Method called when the blueprint container is created.
*/
- public void init() {
+ private void init() {
LOG.info("NetworkModelProvider Session Initiated");
tpceNetwork.createLayer(NetworkUtils.CLLI_NETWORK_ID);
tpceNetwork.createLayer(NetworkUtils.UNDERLAY_NETWORK_ID);
InstanceIdentifiers.NETCONF_TOPOLOGY_II.child(Node.class)), topologyListener);
mappingListenerRegistration = dataBroker.registerDataTreeChangeListener(
DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION, MAPPING_II), portMappingListener);
- networkutilsServiceRpcRegistration =
- rpcProviderService.registerRpcImplementation(TransportpceNetworkutilsService.class, networkutilsService);
- TransportpceServicehandlerListener serviceHandlerListner =
- new ServiceHandlerListener(frequenciesService);
+ networkutilsServiceRpcRegistration = rpcProviderService
+ .registerRpcImplementation(TransportpceNetworkutilsService.class, networkutilsService);
+ TransportpceServicehandlerListener serviceHandlerListner = new ServiceHandlerListener(frequenciesService);
serviceHandlerListenerRegistration = notificationService.registerNotificationListener(serviceHandlerListner);
}
/**
* Method called when the blueprint container is destroyed.
*/
+ @Deactivate
public void close() {
LOG.info("NetworkModelProvider Closed");
if (dataTreeChangeListenerRegistration != null) {