235ba2317c22b03609f57bee7d48ff25cacc03b0
[bgpcep.git] / bgp / rib-impl-config / src / main / java / org / opendaylight / controller / config / yang / bgp / rib / impl / BGPMessageFactoryImplModule.java
1 /**
2  * Generated file
3
4  * Generated from: yang module name: bgp-rib-impl  yang module local name: bgp-message-factory-impl
5  * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
6  * Generated at: Wed Nov 06 13:02:31 CET 2013
7  *
8  * Do not modify this file unless it is present under src/main directory
9  */
10 package org.opendaylight.controller.config.yang.bgp.rib.impl;
11
12 import org.opendaylight.protocol.bgp.parser.BGPMessageFactory;
13 import org.opendaylight.protocol.bgp.parser.impl.BGPMessageFactoryImpl;
14 import org.opendaylight.protocol.bgp.parser.spi.pojo.ServiceLoaderBGPExtensionProviderContext;
15 import org.opendaylight.protocol.framework.DeserializerException;
16 import org.opendaylight.protocol.framework.DocumentedException;
17 import org.opendaylight.yangtools.yang.binding.Notification;
18
19 /**
20 *
21 */
22 public final class BGPMessageFactoryImplModule
23                 extends
24                 org.opendaylight.controller.config.yang.bgp.rib.impl.AbstractBGPMessageFactoryImplModule {
25
26         public BGPMessageFactoryImplModule(
27                         org.opendaylight.controller.config.api.ModuleIdentifier name,
28                         org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
29                 super(name, dependencyResolver);
30         }
31
32         public BGPMessageFactoryImplModule(
33                         org.opendaylight.controller.config.api.ModuleIdentifier name,
34                         org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
35                         BGPMessageFactoryImplModule oldModule,
36                         java.lang.AutoCloseable oldInstance) {
37                 super(name, dependencyResolver, oldModule, oldInstance);
38         }
39
40         @Override
41         public void validate() {
42                 super.validate();
43                 // Add custom validation for module attributes here.
44         }
45
46         @Override
47         public java.lang.AutoCloseable createInstance() {
48                 try {
49                         return new BGPMessageFactoryCloseable(new BGPMessageFactoryImpl(
50                                         ServiceLoaderBGPExtensionProviderContext
51                                                         .createConsumerContext().getMessageRegistry()));
52                 } catch (Exception e) {
53                         throw new RuntimeException("Failed to create consumer context.", e);
54                 }
55         }
56
57         private static class BGPMessageFactoryCloseable implements
58                         BGPMessageFactory, AutoCloseable {
59                 private final BGPMessageFactoryImpl inner;
60
61                 public BGPMessageFactoryCloseable(
62                                 BGPMessageFactoryImpl bgpMessageFactory) {
63                         this.inner = bgpMessageFactory;
64                 }
65
66                 @Override
67                 public void close() throws Exception {
68                         // NOOP
69                 }
70
71                 @Override
72                 public Notification parse(byte[] bytes) throws DeserializerException,
73                                 DocumentedException {
74                         return inner.parse(bytes);
75                 }
76
77                 @Override
78                 public byte[] put(Notification bgpMessage) {
79                         return inner.put(bgpMessage);
80                 }
81         }
82 }