InstanceNetworkInfoServiceImpl.java
1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Service
* org.apache.sling.discovery.InstanceDescription
*/
package com.adobe.granite.offloading.impl;
import com.adobe.granite.offloading.api.InstanceNetworkInfoService;
import com.adobe.granite.offloading.impl.util.OffloadingUtil;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.discovery.InstanceDescription;
@Component
@Service(value={InstanceNetworkInfoService.class})
public class InstanceNetworkInfoServiceImpl
implements InstanceNetworkInfoService {
static final int DEFAULT_PORT = 4502;
@Override
public Set<String> getListeningAddresses(InstanceDescription instance) {
HashSet<String> addresses = new HashSet<String>();
String endpointsString = instance.getProperty("org.apache.sling.instance.endpoints");
Set<String> endpoints = OffloadingUtil.expandCSV(endpointsString);
for (String endpoint : endpoints) {
addresses.add(OffloadingUtil.getHostFromEndpoint(endpoint));
}
return addresses;
}
@Override
public int getListeningPort(InstanceDescription instance) {
String endpoint;
int port = -1;
String endpointsString = instance.getProperty("org.apache.sling.instance.endpoints");
Set<String> endpoints = OffloadingUtil.expandCSV(endpointsString);
Iterator<String> i$ = endpoints.iterator();
while (i$.hasNext() && (port = OffloadingUtil.getPortFromEndpoint(endpoint = i$.next())) == -1) {
}
if (port == -1) {
port = 4502;
}
return port;
}
}