b9abdf0e23e66feb871d156f1e26f8028f39a60e
[bgpcep.git] / pcep / impl-config / src / main / java / org / opendaylight / controller / config / yang / pcep / impl / PCEPSessionProposalFactoryImplModule.java
1 /*
2  * Copyright (c) 2013 Cisco 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 /**
9  * Generated file
10
11  * Generated from: yang module name: pcep-impl  yang module local name: pcep-session-proposal-factory-impl
12  * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
13  * Generated at: Wed Nov 06 13:16:39 CET 2013
14  *
15  * Do not modify this file unless it is present under src/main directory
16  */
17 package org.opendaylight.controller.config.yang.pcep.impl;
18
19 import java.net.InetSocketAddress;
20
21 import org.opendaylight.controller.config.api.JmxAttributeValidationException;
22 import org.opendaylight.protocol.pcep.PCEPSessionProposalFactory;
23 import org.opendaylight.protocol.pcep.impl.BasePCEPSessionProposalFactory;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
27
28 /**
29  *
30  */
31 public final class PCEPSessionProposalFactoryImplModule extends
32 org.opendaylight.controller.config.yang.pcep.impl.AbstractPCEPSessionProposalFactoryImplModule {
33
34         private static final Logger LOG = LoggerFactory.getLogger(PCEPSessionProposalFactoryImplModule.class);
35
36         public PCEPSessionProposalFactoryImplModule(final org.opendaylight.controller.config.api.ModuleIdentifier name,
37                         final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
38                 super(name, dependencyResolver);
39         }
40
41         public PCEPSessionProposalFactoryImplModule(final org.opendaylight.controller.config.api.ModuleIdentifier name,
42                         final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
43                         final PCEPSessionProposalFactoryImplModule oldModule, final java.lang.AutoCloseable oldInstance) {
44                 super(name, dependencyResolver, oldModule, oldInstance);
45         }
46
47         @Override
48         public void customValidation() {
49                 JmxAttributeValidationException.checkNotNull(getDeadTimerValue(), "value is not set.", deadTimerValueJmxAttribute);
50                 JmxAttributeValidationException.checkNotNull(getKeepAliveTimerValue(), "value is not set.", keepAliveTimerValueJmxAttribute);
51                 if (getKeepAliveTimerValue() != 0) {
52                         JmxAttributeValidationException.checkCondition(getKeepAliveTimerValue() >= 1, "minimum value is 1.",
53                                         keepAliveTimerValueJmxAttribute);
54                         if (getDeadTimerValue() != 0 && (getDeadTimerValue() / getKeepAliveTimerValue() != 4)) {
55                                 LOG.warn("DeadTimerValue should be 4 times greater than KeepAliveTimerValue");
56                         }
57                 }
58         }
59
60         @Override
61         public java.lang.AutoCloseable createInstance() {
62                 final BasePCEPSessionProposalFactory inner = new BasePCEPSessionProposalFactory(getDeadTimerValue(), getKeepAliveTimerValue());
63                 return new PCEPSessionProposalFactoryCloseable(inner);
64         }
65
66         private static final class PCEPSessionProposalFactoryCloseable implements PCEPSessionProposalFactory, AutoCloseable {
67
68                 private final BasePCEPSessionProposalFactory inner;
69
70                 public PCEPSessionProposalFactoryCloseable(final BasePCEPSessionProposalFactory inner) {
71                         this.inner = inner;
72                 }
73
74                 @Override
75                 public void close() throws Exception {
76                 }
77
78                 @Override
79                 public Open getSessionProposal(final InetSocketAddress inetSocketAddress, final int i) {
80                         return this.inner.getSessionProposal(inetSocketAddress, i);
81                 }
82         }
83 }