Bug-194: Moved programming configuration artifacts
[bgpcep.git] / programming / impl / src / main / java / org / opendaylight / controller / config / yang / programming / impl / InstructionSchedulerImplModule.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: config-programming-impl  yang module local name: instruction-scheduler-impl
12  * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
13  * Generated at: Mon Nov 18 16:50:17 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.programming.impl;
18
19 import com.google.common.util.concurrent.ListenableFuture;
20 import com.google.common.util.concurrent.ListeningExecutorService;
21 import com.google.common.util.concurrent.MoreExecutors;
22
23 import java.util.concurrent.Executors;
24
25 import org.opendaylight.bgpcep.programming.impl.ProgrammingServiceImpl;
26 import org.opendaylight.bgpcep.programming.spi.Instruction;
27 import org.opendaylight.bgpcep.programming.spi.InstructionScheduler;
28 import org.opendaylight.bgpcep.programming.spi.SchedulerException;
29 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev130930.ProgrammingService;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev130930.SubmitInstructionInput;
32
33 /**
34  *
35  */
36 public final class InstructionSchedulerImplModule extends
37         org.opendaylight.controller.config.yang.programming.impl.AbstractInstructionSchedulerImplModule {
38
39     public InstructionSchedulerImplModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
40             final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
41         super(identifier, dependencyResolver);
42     }
43
44     public InstructionSchedulerImplModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
45             final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
46             final InstructionSchedulerImplModule oldModule, final java.lang.AutoCloseable oldInstance) {
47         super(identifier, dependencyResolver, oldModule, oldInstance);
48     }
49
50     @Override
51     protected void customValidation() {
52         // Add custom validation for module attributes here.
53     }
54
55     @Override
56     public java.lang.AutoCloseable createInstance() {
57         final ListeningExecutorService exec = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor());
58
59         final ProgrammingServiceImpl inst = new ProgrammingServiceImpl(getDataProviderDependency(), getNotificationServiceDependency(), exec, getTimerDependency());
60
61         final RpcRegistration<ProgrammingService> reg = getRpcRegistryDependency().addRpcImplementation(ProgrammingService.class, inst);
62
63         final class ProgrammingServiceImplCloseable implements InstructionScheduler, AutoCloseable {
64             @Override
65             public void close() throws Exception {
66                 try {
67                     reg.close();
68                 } finally {
69                     try {
70                         inst.close();
71                     } finally {
72                         exec.shutdown();
73                     }
74                 }
75             }
76
77             @Override
78             public ListenableFuture<Instruction> scheduleInstruction(final SubmitInstructionInput input) throws SchedulerException {
79                 return inst.scheduleInstruction(input);
80             }
81         }
82
83         return new ProgrammingServiceImplCloseable();
84     }
85 }