8eb504a033325152703e2f3a34fc1eee544cd1e3
[hc2vpp.git] /
1 package org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.vpp.jvpp.cfg.rev160406;
2
3 import java.io.IOException;
4 import org.openvpp.jvpp.JVppImpl;
5 import org.openvpp.jvpp.VppJNIConnection;
6 import org.openvpp.jvpp.future.FutureJVppFacade;
7 import org.slf4j.Logger;
8 import org.slf4j.LoggerFactory;
9
10 public class VppJvppImplModule extends org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.vpp.jvpp.cfg.rev160406.AbstractVppJvppImplModule {
11
12     private static final Logger LOG = LoggerFactory.getLogger(VppJvppImplModule.class);
13
14     public VppJvppImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
15         super(identifier, dependencyResolver);
16     }
17
18     public VppJvppImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.vpp.jvpp.cfg.rev160406.VppJvppImplModule oldModule, java.lang.AutoCloseable oldInstance) {
19         super(identifier, dependencyResolver, oldModule, oldInstance);
20     }
21
22     @Override
23     public void customValidation() {
24         // add custom validation form module attributes here.
25     }
26
27     @Override
28     public java.lang.AutoCloseable createInstance() {
29         try {
30             final JVppImpl jVpp = new JVppImpl(new VppJNIConnection(getName()));
31             LOG.info("JVpp connection opened successfully as: {}", getName());
32             return new FutureJVppFacade(jVpp) {
33                 @Override
34                 public void close() throws Exception {
35                     super.close();
36                     LOG.info("Closing JVpp connection: {}", getName());
37                     jVpp.close();
38                 }
39             };
40         } catch (IOException e) {
41             throw new IllegalStateException("Unable to open VPP management connection", e);
42         }
43     }
44
45 }