Migrate sal-common-testutil odlparent-1.8.0-Carbon
[controller.git] / opendaylight / commons / protocol-framework / src / main / java / org / opendaylight / controller / config / yang / protocol / framework / ReconnectImmediatelyStrategyFactoryModule.java
1 /*
2  * Copyright (c) 2014 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 package org.opendaylight.controller.config.yang.protocol.framework;
9
10 import io.netty.util.concurrent.EventExecutor;
11
12 import org.opendaylight.controller.config.api.JmxAttributeValidationException;
13 import org.opendaylight.protocol.framework.ReconnectImmediatelyStrategy;
14 import org.opendaylight.protocol.framework.ReconnectStrategy;
15 import org.opendaylight.protocol.framework.ReconnectStrategyFactory;
16
17 /**
18 *
19 */
20 @Deprecated
21 public final class ReconnectImmediatelyStrategyFactoryModule extends org.opendaylight.controller.config.yang.protocol.framework.AbstractReconnectImmediatelyStrategyFactoryModule
22  {
23
24     public ReconnectImmediatelyStrategyFactoryModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
25         super(identifier, dependencyResolver);
26     }
27
28     public ReconnectImmediatelyStrategyFactoryModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
29             final ReconnectImmediatelyStrategyFactoryModule oldModule, final java.lang.AutoCloseable oldInstance) {
30
31         super(identifier, dependencyResolver, oldModule, oldInstance);
32     }
33
34     @Override
35     protected void customValidation(){
36         JmxAttributeValidationException.checkNotNull(getReconnectTimeout(), "value is not set.", reconnectTimeoutJmxAttribute);
37         JmxAttributeValidationException.checkCondition(getReconnectTimeout() >= 0, "value " + getReconnectTimeout() + " is less than 0",
38                 reconnectTimeoutJmxAttribute);
39     }
40
41     @Override
42     public java.lang.AutoCloseable createInstance() {
43         return new ReconnectImmediatelyStrategyFactoryCloseable(getReconnectExecutorDependency(), getReconnectTimeout());
44     }
45
46     private static final class ReconnectImmediatelyStrategyFactoryCloseable implements ReconnectStrategyFactory, AutoCloseable {
47
48         private final EventExecutor executor;
49         private final int timeout;
50
51         public ReconnectImmediatelyStrategyFactoryCloseable(final EventExecutor executor, final int timeout) {
52             this.executor = executor;
53             this.timeout = timeout;
54         }
55
56         @Override
57         public void close() throws Exception {
58             // no-op
59         }
60
61         @Override
62         public ReconnectStrategy createReconnectStrategy() {
63             return new ReconnectImmediatelyStrategy(this.executor, this.timeout);
64         }
65
66     }
67 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.