e072369b7ecafb1f30fa69bcb7ed5c05e907e0f5
[packetcable.git] / packetcable-consumer / src / main / java / org / opendaylight / controller / config / yang / config / pcmm_service / impl / PcmmServiceModule.java
1 /*
2  * Copyright 2015, CableLabs
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.controller.config.yang.config.pcmm_service.impl;
9
10 import org.opendaylight.controller.org.pcmm.api.PcmmService;
11 import org.opendaylight.controller.org.pcmm.impl.PcmmServiceImpl;
12 //import org.opendaylight.yang.gen.v1.urn.opendaylight.packetcable.service.rev140120.PacketcableServiceService;
13 import org.opendaylight.yangtools.concepts.Registration;
14
15 public class PcmmServiceModule
16                 extends
17                 org.opendaylight.controller.config.yang.config.pcmm_service.impl.AbstractPcmmServiceModule {
18         public PcmmServiceModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
19                 super(identifier, dependencyResolver);
20         }
21
22         public PcmmServiceModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.config.pcmm_service.impl.PcmmServiceModule oldModule, java.lang.AutoCloseable oldInstance) {
23                 super(identifier, dependencyResolver, oldModule, oldInstance);
24         }
25
26         @Override
27         public void customValidation() {
28                 // add custom validation form module attributes here.
29         }
30
31         @Override
32         public java.lang.AutoCloseable createInstance() {
33                 // PacketcableServiceService packetcableServiceService =
34                 // getRpcRegistryDependency().getRpcService(PacketcableServiceService.class);
35                 final PcmmService pcmmService = new PcmmServiceImpl();
36                 final Registration pcmmListenerReg = getNotificationServiceDependency().registerNotificationListener(pcmmService);
37                 final PcmmServiceRuntimeRegistration runtimeReg = getRootRuntimeBeanRegistratorWrapper().register(pcmmService);
38                 return new AutoCloseablePcmmService(pcmmListenerReg, runtimeReg);
39         }
40
41         class AutoCloseablePcmmService extends PcmmServiceImpl implements
42                         AutoCloseable {
43
44                 private PcmmServiceRuntimeRegistration runtimeReg;
45                 private Registration pcmmListenerReg;
46
47                 public AutoCloseablePcmmService(Registration pcmmListenerReg, PcmmServiceRuntimeRegistration runtimeReg) {
48                         super();
49                         this.runtimeReg = runtimeReg;
50                         this.pcmmListenerReg = pcmmListenerReg;
51                 }
52
53                 @Override
54                 public void close() throws Exception {
55                         pcmmListenerReg.close();
56                         runtimeReg.close();
57                 }
58
59         }
60 }