c68503c0fa313bbbd48a3d3cd5538f489acaeaf3
[controller.git] / opendaylight / md-sal / sal-remoterpc-connector / src / main / java / org / opendaylight / controller / config / yang / config / remote_rpc_connector / RemoteRPCBrokerModule.java
1 /*
2  * Copyright (c) 2015 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 package org.opendaylight.controller.config.yang.config.remote_rpc_connector;
10
11 import akka.actor.ActorSystem;
12 import org.opendaylight.controller.remote.rpc.RemoteRpcProviderConfig;
13 import org.opendaylight.controller.remote.rpc.RemoteRpcProviderFactory;
14 import org.opendaylight.controller.sal.core.api.Broker;
15 import org.osgi.framework.BundleContext;
16
17 public class RemoteRPCBrokerModule extends org.opendaylight.controller.config.yang.config.remote_rpc_connector.AbstractRemoteRPCBrokerModule {
18     private BundleContext bundleContext;
19     public RemoteRPCBrokerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
20         super(identifier, dependencyResolver);
21     }
22
23     public RemoteRPCBrokerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.config.remote_rpc_connector.RemoteRPCBrokerModule oldModule, java.lang.AutoCloseable oldInstance) {
24         super(identifier, dependencyResolver, oldModule, oldInstance);
25     }
26
27     @Override
28     public void customValidation() {
29         // add custom validation form module attributes here.
30     }
31
32     @Override
33     public boolean canReuseInstance(AbstractRemoteRPCBrokerModule oldModule) {
34         return true;
35     }
36
37     @Override
38     public java.lang.AutoCloseable createInstance() {
39         Broker broker = getDomBrokerDependency();
40
41         ActorSystem actorSystem = getActorSystemProviderDependency().getActorSystem();
42         RemoteRpcProviderConfig config = new RemoteRpcProviderConfig.Builder(actorSystem.name())
43                 .metricCaptureEnabled(getEnableMetricCapture())
44                 .mailboxCapacity(getBoundedMailboxCapacity())
45                 .build();
46
47         return RemoteRpcProviderFactory.createInstance(broker, bundleContext, actorSystem, config);
48     }
49
50     public void setBundleContext(BundleContext bundleContext) {
51         this.bundleContext = bundleContext;
52     }
53 }