Coverage Report - org.owasp.dependencycheck.data.UpdateService
 
Classes in this File Line Coverage Branch Coverage Complexity
UpdateService
0%
0/7
0%
0/2
1.333
 
 1  
 /*
 2  
  * This file is part of dependency-check-core.
 3  
  *
 4  
  * Dependency-check-core is free software: you can redistribute it and/or modify it
 5  
  * under the terms of the GNU General Public License as published by the Free
 6  
  * Software Foundation, either version 3 of the License, or (at your option) any
 7  
  * later version.
 8  
  *
 9  
  * Dependency-check-core is distributed in the hope that it will be useful, but
 10  
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  
  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 12  
  * details.
 13  
  *
 14  
  * You should have received a copy of the GNU General Public License along with
 15  
  * dependency-check-core. If not, see http://www.gnu.org/licenses/.
 16  
  *
 17  
  * Copyright (c) 2012 Jeremy Long. All Rights Reserved.
 18  
  */
 19  
 package org.owasp.dependencycheck.data;
 20  
 
 21  
 import java.util.Iterator;
 22  
 import java.util.ServiceLoader;
 23  
 
 24  
 /**
 25  
  *
 26  
  * @author Jeremy Long (jeremy.long@owasp.org)
 27  
  */
 28  
 public final class UpdateService {
 29  
 
 30  
     /**
 31  
      * the singleton reference to the service.
 32  
      */
 33  
     private static UpdateService service;
 34  
     /**
 35  
      * the service loader for CachedWebDataSource.
 36  
      */
 37  
     private final ServiceLoader<CachedWebDataSource> loader;
 38  
 
 39  
     /**
 40  
      * Creates a new instance of UpdateService
 41  
      */
 42  0
     private UpdateService() {
 43  0
         loader = ServiceLoader.load(CachedWebDataSource.class);
 44  0
     }
 45  
 
 46  
     /**
 47  
      * Retrieve the singleton instance of UpdateService.
 48  
      *
 49  
      * @return a singleton UpdateService.
 50  
      */
 51  
     public static synchronized UpdateService getInstance() {
 52  0
         if (service == null) {
 53  0
             service = new UpdateService();
 54  
         }
 55  0
         return service;
 56  
     }
 57  
 
 58  
     /**
 59  
      * Returns an Iterator for all instances of the CachedWebDataSource
 60  
      * interface.
 61  
      *
 62  
      * @return an iterator of CachedWebDataSource.
 63  
      */
 64  
     public Iterator<CachedWebDataSource> getDataSources() {
 65  0
         return loader.iterator();
 66  
     }
 67  
 }