forked from community/product-iots
commit
9fb543ff6d
@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!--
|
||||
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ you may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<AnalyticsConfiguration>
|
||||
<!--
|
||||
Server URL of the remote DAS/BAM/CEP server used to collect statistics. Must
|
||||
be specified in protocol://hostname:port/ format.
|
||||
|
||||
An event can also be published to multiple Receiver Groups each having 1 or more receivers. Receiver
|
||||
Groups are delimited by curly braces whereas receivers are delimited by commas.
|
||||
Ex - Multiple Receivers within a single group
|
||||
tcp://localhost:7612/,tcp://localhost:7613/,tcp://localhost:7614/
|
||||
Ex - Multiple Receiver Groups with two receivers each
|
||||
{tcp://localhost:7612/,tcp://localhost:7613},{tcp://localhost:7712/,tcp://localhost:7713/}
|
||||
-->
|
||||
<Enabled>true</Enabled>
|
||||
<ReceiverServerUrl>tcp://localhost:7611</ReceiverServerUrl>
|
||||
<AdminUsername>admin</AdminUsername>
|
||||
<AdminPassword>admin</AdminPassword>
|
||||
</AnalyticsConfiguration>
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.event.input.adapter.extensions.util;
|
||||
|
||||
import org.wso2.carbon.base.ServerConfiguration;
|
||||
import org.wso2.carbon.core.util.Utils;
|
||||
|
||||
public class PropertyUtils {
|
||||
private static final String MQTT_PORT = "\\$\\{mqtt.broker.port\\}";
|
||||
private static final String MQTT_BROKER_HOST = "\\$\\{mqtt.broker.host\\}";
|
||||
private static final String CARBON_CONFIG_PORT_OFFSET = "Ports.Offset";
|
||||
private static final String DEFAULT_CARBON_SERVER_HOST_PROPERTY = "server.host";
|
||||
private static final int CARBON_DEFAULT_PORT_OFFSET = 0;
|
||||
private static final int DEFAULT_MQTT_PORT = 1883;
|
||||
|
||||
//This method is only used if the mb features are within DAS.
|
||||
public static String replaceMqttProperty (String urlWithPlaceholders) {
|
||||
urlWithPlaceholders = Utils.replaceSystemProperty(urlWithPlaceholders);
|
||||
urlWithPlaceholders = urlWithPlaceholders.replaceAll(MQTT_PORT, "" + (DEFAULT_MQTT_PORT + getPortOffset()));
|
||||
urlWithPlaceholders = urlWithPlaceholders.replaceAll(MQTT_BROKER_HOST, System.getProperty(DEFAULT_CARBON_SERVER_HOST_PROPERTY,
|
||||
"localhost"));
|
||||
return urlWithPlaceholders;
|
||||
}
|
||||
|
||||
private static int getPortOffset() {
|
||||
ServerConfiguration carbonConfig = ServerConfiguration.getInstance();
|
||||
String portOffset = System.getProperty("portOffset",
|
||||
carbonConfig.getFirstProperty(CARBON_CONFIG_PORT_OFFSET));
|
||||
try {
|
||||
if ((portOffset != null)) {
|
||||
return Integer.parseInt(portOffset.trim());
|
||||
} else {
|
||||
return CARBON_DEFAULT_PORT_OFFSET;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
return CARBON_DEFAULT_PORT_OFFSET;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue