use annotations instead of XML for Blueprint
[ovsdb.git] / library / impl / src / main / java / org / opendaylight / ovsdb / lib / impl / OvsdbConnectionServiceConfigurator.java
1 /*
2  * Copyright © 2014, 2017 Red Hat, 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.ovsdb.lib.impl;
10
11 import java.util.Map;
12 import org.slf4j.Logger;
13 import org.slf4j.LoggerFactory;
14
15 public class OvsdbConnectionServiceConfigurator {
16
17     private static final Logger LOG = LoggerFactory.getLogger(OvsdbConnectionServiceConfigurator.class);
18
19     private static final String JSON_RPC_DECODER_MAX_FRAME_LENGTH_PARAM = "json-rpc-decoder-max-frame-length";
20     private static final String USE_SSL_PARAM = "use-ssl";
21     private static final String OVSDB_RPC_TASK_TIMEOUT_PARAM = "ovsdb-rpc-task-timeout";
22     private static final String OVSDB_LISTENER_PORT_PARAM = "ovsdb-listener-port";
23     private final OvsdbConnectionService ovsdbconnection;
24
25     public OvsdbConnectionServiceConfigurator(OvsdbConnectionService ovsdbconnection) {
26         this.ovsdbconnection = ovsdbconnection;
27     }
28
29     public void setOvsdbRpcTaskTimeout(int timeout) {
30         ovsdbconnection.setOvsdbRpcTaskTimeout(timeout);
31     }
32
33     public void setUseSsl(boolean flag) {
34         ovsdbconnection.setUseSsl(flag);
35     }
36
37     public void setJsonRpcDecoderMaxFrameLength(int maxFrameLength) {
38         ovsdbconnection.setJsonRpcDecoderMaxFrameLength(maxFrameLength);
39     }
40
41     public void setOvsdbListenerIp(String ip) {
42         ovsdbconnection.setOvsdbListenerIp(ip);
43     }
44
45     public void setOvsdbListenerPort(int portNumber) {
46         ovsdbconnection.setOvsdbListenerPort(portNumber);
47     }
48
49     public void updateConfigParameter(Map<String, Object> configParameters) {
50         if (configParameters != null && !configParameters.isEmpty()) {
51             LOG.debug("Config parameters received : {}", configParameters.entrySet());
52             for (Map.Entry<String, Object> paramEntry : configParameters.entrySet()) {
53                 if (paramEntry.getKey().equalsIgnoreCase(OVSDB_RPC_TASK_TIMEOUT_PARAM)) {
54                     ovsdbconnection.setOvsdbRpcTaskTimeout(Integer.parseInt((String) paramEntry.getValue()));
55                 } else if (paramEntry.getKey().equalsIgnoreCase(USE_SSL_PARAM)) {
56                     ovsdbconnection.setUseSsl(Boolean.parseBoolean(paramEntry.getValue().toString()));
57                 }
58
59             }
60         }
61     }
62 }
63