|
17 | 17 |
|
18 | 18 | import in.ankushs.dbip.model.GeoAttributes; |
19 | 19 | import in.ankushs.dbip.model.GeoAttributesImpl; |
| 20 | +import in.ankushs.dbip.parser.CsvParser; |
20 | 21 | import in.ankushs.dbip.parser.CsvParserImpl; |
21 | 22 | import in.ankushs.dbip.repository.DbIpRepository; |
22 | 23 | import in.ankushs.dbip.repository.JavaMapDbIpRepositoryImpl; |
|
31 | 32 | public final class ResourceImporter { |
32 | 33 |
|
33 | 34 | private static final Logger logger = LoggerFactory.getLogger(ResourceImporter.class); |
34 | | - private final DbIpRepository repository = new JavaMapDbIpRepositoryImpl(); |
35 | | - private ResourceImporter instance = null; |
| 35 | + private final DbIpRepository repository = JavaMapDbIpRepositoryImpl.getInstance(); |
| 36 | + private final CsvParser csvParser = CsvParserImpl.getInstance(); |
| 37 | + private static ResourceImporter instance = null; |
36 | 38 |
|
37 | | - public ResourceImporter getInstance() { |
| 39 | + private ResourceImporter(){} |
| 40 | + |
| 41 | + public static ResourceImporter getInstance() { |
38 | 42 | if (instance == null) { |
39 | 43 | return new ResourceImporter(); |
40 | 44 | } |
@@ -66,7 +70,7 @@ public void load(final File file) { |
66 | 70 | int i = 0; |
67 | 71 | while ((line = reader.readLine()) != null) { |
68 | 72 | i++; |
69 | | - final String[] array = new CsvParserImpl().parseRecord(line); |
| 73 | + final String[] array = csvParser.parseRecord(line); |
70 | 74 | final GeoAttributes geoAttributes = new GeoAttributesImpl.Builder().withCity(array[4]) |
71 | 75 | .withCountry(CountryResolver.resolveToFullName(array[2])).withProvince(array[3]) |
72 | 76 | .withEndIp(InetAddresses.forString(array[1])).withStartIp(InetAddresses.forString(array[0])) |
|
0 commit comments