Merge "Exception for URI /restconf/operations/module_name:rpc ended with slash"
[controller.git] / opendaylight / md-sal / sal-remoterpc-connector / implementation / src / main / java / org / opendaylight / controller / config / yang / md / sal / remote / rpc / ZeroMQServerModule.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.md.sal.remote.rpc;
9
10 import org.opendaylight.controller.sal.connector.remoterpc.*;
11 import org.opendaylight.controller.sal.core.api.Broker;
12 import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry;
13 import org.osgi.framework.BundleContext;
14
15 /**
16 *
17 */
18 public final class ZeroMQServerModule extends org.opendaylight.controller.config.yang.md.sal.remote.rpc.AbstractZeroMQServerModule
19  {
20
21     private static final Integer ZEROMQ_ROUTER_PORT = 5554;
22     private BundleContext bundleContext;
23
24     public ZeroMQServerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
25         super(identifier, dependencyResolver);
26     }
27
28     public ZeroMQServerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
29             ZeroMQServerModule oldModule, java.lang.AutoCloseable oldInstance) {
30
31         super(identifier, dependencyResolver, oldModule, oldInstance);
32     }
33
34     @Override
35     protected void customValidation(){
36         // Add custom validation for module attributes here.
37     }
38
39     @Override
40     public java.lang.AutoCloseable createInstance() {
41         
42         Broker broker = getDomBrokerDependency();
43
44         final int port = getPort() != null ? getPort() : ZEROMQ_ROUTER_PORT;
45
46         ServerImpl serverImpl = new ServerImpl(port);
47         
48         ClientImpl clientImpl = new ClientImpl();
49
50     RoutingTableProvider provider = new RoutingTableProvider(bundleContext);//,serverImpl);
51
52
53     facade.setRoutingTableProvider(provider );
54     facade.setContext(bundleContext);
55     facade.setRpcProvisionRegistry((RpcProvisionRegistry) broker);
56
57     broker.registerProvider(facade, bundleContext);
58     return facade;
59   }
60
61   public void setBundleContext(BundleContext bundleContext) {
62     this.bundleContext = bundleContext;
63   }
64 }