| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package net.sf.arestc.core; |
| 22 |
|
|
| 23 |
|
import java.util.Map; |
| 24 |
|
|
| 25 |
|
import net.sf.arestc.configuration.CommunicationBuilder; |
| 26 |
|
import net.sf.arestc.configuration.ServicesConfigurationFactory; |
| 27 |
|
import net.sf.arestc.core.services.RESTService; |
| 28 |
|
|
| 29 |
|
import org.apache.commons.configuration.ConfigurationException; |
| 30 |
|
import org.apache.commons.httpclient.HttpClient; |
| 31 |
|
import org.apache.log4j.Logger; |
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
@author |
| 37 |
|
|
|
|
|
| 71% |
Uncovered Elements: 9 (31) |
Complexity: 11 |
Complexity Density: 0.5 |
|
| 38 |
|
public class ARESTConnector { |
| 39 |
|
|
| 40 |
|
|
| 41 |
|
private HttpClient client; |
| 42 |
|
|
| 43 |
|
|
| 44 |
|
private ConnectorTypes type; |
| 45 |
|
|
| 46 |
|
|
| 47 |
|
private Map<String, RESTService> services; |
| 48 |
|
|
| 49 |
|
|
| 50 |
|
private static final Logger LOGGER = Logger.getLogger(ARESTConnector.class |
| 51 |
|
.getName()); |
| 52 |
|
|
| 53 |
|
|
| 54 |
|
|
| 55 |
|
|
| 56 |
|
@param |
| 57 |
|
|
| 58 |
|
@throws |
| 59 |
|
|
| 60 |
|
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.33 |
|
| 61 |
12
|
public ARESTConnector(final ConnectorTypes type)... |
| 62 |
|
throws ConfigurationException { |
| 63 |
12
|
try { |
| 64 |
12
|
this.type = type; |
| 65 |
12
|
services = ServicesConfigurationFactory._instance.configure(); |
| 66 |
|
|
| 67 |
12
|
client = new CommunicationBuilder().getMultithreadedClient(); |
| 68 |
|
} catch (final ConfigurationException e) { |
| 69 |
0
|
LOGGER.error(e); |
| 70 |
0
|
throw e; |
| 71 |
|
} |
| 72 |
|
} |
| 73 |
|
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.33 |
|
| 74 |
0
|
public ARESTConnector(final ConnectorTypes type, final String servicesFile,... |
| 75 |
|
final String communicationFileName) throws ConfigurationException { |
| 76 |
0
|
try { |
| 77 |
0
|
this.type = type; |
| 78 |
0
|
services = ServicesConfigurationFactory._instance |
| 79 |
|
.configure(servicesFile); |
| 80 |
|
|
| 81 |
0
|
client = new CommunicationBuilder() |
| 82 |
|
.getMultithreadedClient(communicationFileName); |
| 83 |
|
} catch (final ConfigurationException e) { |
| 84 |
0
|
LOGGER.error(e); |
| 85 |
0
|
throw e; |
| 86 |
|
} |
| 87 |
|
} |
| 88 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 89 |
1
|
public HttpClient getClient() {... |
| 90 |
1
|
return client; |
| 91 |
|
} |
| 92 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 93 |
1
|
public Map<String, RESTService> getServices() {... |
| 94 |
1
|
return services; |
| 95 |
|
} |
| 96 |
|
|
| 97 |
|
|
| 98 |
|
|
| 99 |
|
|
| 100 |
|
@param |
| 101 |
|
|
| 102 |
|
@return |
| 103 |
|
@throws |
| 104 |
|
|
| 105 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 106 |
12
|
public ConnectorResponse serve(final ConnectorRequest request)... |
| 107 |
|
throws CommandException { |
| 108 |
12
|
if (!services.containsKey(request.getServiceName()) |
| 109 |
|
&& !ConnectorTypes.DUMMY.equals(type)) { |
| 110 |
1
|
throw new CommandException("Service does not exist.", |
| 111 |
|
new IllegalStateException()); |
| 112 |
|
} |
| 113 |
11
|
final ConnectorContext context = new ConnectorContext(client, |
| 114 |
|
services.get(request.getServiceName())); |
| 115 |
11
|
final ConnectorCommand firstLink = type.chain(context, |
| 116 |
|
request.getStartTransformer(), request.getEndTransformer()); |
| 117 |
|
|
| 118 |
11
|
firstLink.process(request, context); |
| 119 |
|
|
| 120 |
11
|
return new StandardConnectorResponse(context); |
| 121 |
|
} |
| 122 |
|
|
| 123 |
|
|
| 124 |
|
|
| 125 |
|
|
| 126 |
|
@param |
| 127 |
|
|
| 128 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 129 |
1
|
public void setClient(final HttpClient client) {... |
| 130 |
1
|
this.client = client; |
| 131 |
|
} |
| 132 |
|
|
| 133 |
|
|
| 134 |
|
|
| 135 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 136 |
1
|
public void shutdown() {... |
| 137 |
1
|
new CommunicationBuilder().shutdownCommunication(); |
| 138 |
|
} |
| 139 |
|
} |