Rewire SwitchConnectionProvider configuration
[openflowplugin.git] / openflowjava / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / core / SwitchConnectionProviderFactoryImpl.java
1 /*
2  * Copyright (c) 2016 Brocade Communications Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.openflowjava.protocol.impl.core;
9
10 import static java.util.Objects.requireNonNull;
11
12 import javax.inject.Inject;
13 import javax.inject.Singleton;
14 import org.opendaylight.infrautils.diagstatus.DiagStatusService;
15 import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
16 import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProviderFactory;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.config.rev160506.SwitchConnectionConfig;
18 import org.osgi.service.component.annotations.Activate;
19 import org.osgi.service.component.annotations.Component;
20 import org.osgi.service.component.annotations.Reference;
21
22 /**
23  * Implementation of the SwitchConnectionProviderFactory interface.
24  */
25 @Singleton
26 @Component
27 public class SwitchConnectionProviderFactoryImpl implements SwitchConnectionProviderFactory {
28     private final DiagStatusService diagStatus;
29
30     @Inject
31     @Activate
32     public SwitchConnectionProviderFactoryImpl(@Reference final DiagStatusService diagStatus) {
33         this.diagStatus = requireNonNull(diagStatus);
34     }
35
36     @Override
37     public SwitchConnectionProvider newInstance(final SwitchConnectionConfig config) {
38         return new SwitchConnectionProviderImpl(diagStatus, new ConnectionConfigurationImpl(config));
39     }
40 }