// javadoc inherited.
public Device getDevice(final HttpHeaders headers, final String defaultDeviceName)
throws DeviceRepositoryException {
DefaultDevice device = null;
if (headers != null) {
try {
RepositoryConnection connection = repository.connect();
try {
final DeviceIdentificationResult identificationResult =
DevicesHelper.getDevice(
connection, headers, accessor, unknownDevicesLogger, defaultDeviceName);
device = identificationResult.getDevice();
if (device != null) {
device.setIdentificationHeaderNames(
identificationResult.getHeaderNamesUsed());
}
} finally {
repository.disconnect(connection);
}