Create pcep topology parent aggregator
[bgpcep.git] / pcep / topology / topology-provider / src / main / java / org / opendaylight / controller / config / yang / pcep / topology / provider / Stateful07TopologySessionListenerModule.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 /**
9  * Generated file
10
11  * Generated from: yang module name: config-pcep-topology-provider  yang module local name: pcep-topology-stateful07
12  * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
13  * Generated at: Mon Jan 27 11:08:05 CET 2014
14  *
15  * Do not modify this file unless it is present under src/main directory
16  */
17 package org.opendaylight.controller.config.yang.pcep.topology.provider;
18
19 import com.google.common.reflect.AbstractInvocationHandler;
20 import com.google.common.reflect.Reflection;
21 import java.lang.reflect.Method;
22 import org.opendaylight.bgpcep.pcep.topology.provider.TopologySessionListenerFactory;
23 import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
24 import org.osgi.framework.BundleContext;
25
26 /**
27  * @deprecated Replaced by blueprint wiring
28  */
29 public final class Stateful07TopologySessionListenerModule extends
30         org.opendaylight.controller.config.yang.pcep.topology.provider.AbstractStateful07TopologySessionListenerModule {
31     private BundleContext bundleContext;
32
33     public Stateful07TopologySessionListenerModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
34             final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
35         super(identifier, dependencyResolver);
36     }
37
38     public Stateful07TopologySessionListenerModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
39             final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
40             final Stateful07TopologySessionListenerModule oldModule, final java.lang.AutoCloseable oldInstance) {
41         super(identifier, dependencyResolver, oldModule, oldInstance);
42     }
43
44     @Override
45     protected void customValidation() {
46         // Add custom validation for module attributes here.
47     }
48
49     @Override
50     public java.lang.AutoCloseable createInstance() {
51         final WaitingServiceTracker<TopologySessionListenerFactory> tracker = WaitingServiceTracker
52             .create(TopologySessionListenerFactory.class, this.bundleContext);
53         final TopologySessionListenerFactory service = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
54
55         return Reflection.newProxy(AutoCloseableService.class, new AbstractInvocationHandler() {
56             @Override
57             protected Object handleInvocation(final Object proxy, final Method method, final Object[] args) throws Throwable {
58                 if (method.getName().equals("close")) {
59                     tracker.close();
60                     return null;
61                 } else {
62                     return method.invoke(service, args);
63                 }
64             }
65         });
66     }
67
68     void setBundleContext(final BundleContext bundleContext) {
69         this.bundleContext = bundleContext;
70     }
71
72     private interface AutoCloseableService extends TopologySessionListenerFactory, AutoCloseable {
73     }
74 }