| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ProcessFactoryFinder |
|
| 1.6666666666666667;1.667 |
| 1 | /* | |
| 2 | Copyright (C) 2007 Grid Systems, S.A. | |
| 3 | ||
| 4 | This library is free software; you can redistribute it and/or | |
| 5 | modify it under the terms of the GNU Lesser General Public | |
| 6 | License as published by the Free Software Foundation; either | |
| 7 | version 2.1 of the License, or (at your option) any later version. | |
| 8 | ||
| 9 | This library is distributed in the hope that it will be useful, | |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 12 | Lesser General Public License for more details. | |
| 13 | ||
| 14 | You should have received a copy of the GNU Lesser General Public | |
| 15 | License along with this library; if not, write to the Free Software | |
| 16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
| 17 | */ | |
| 18 | package nextgrid.api.pom; | |
| 19 | ||
| 20 | import org.apache.commons.discovery.tools.DiscoverSingleton; | |
| 21 | ||
| 22 | /** | |
| 23 | * Type description. | |
| 24 | * | |
| 25 | * @author Rodrigo Ruiz | |
| 26 | */ | |
| 27 | public final class ProcessFactoryFinder { | |
| 28 | ||
| 29 | /** | |
| 30 | * Hidden to prevent instantiation. | |
| 31 | */ | |
| 32 | 0 | private ProcessFactoryFinder() { |
| 33 | 0 | } |
| 34 | ||
| 35 | /** | |
| 36 | * Cleans the cached factory instance. This method can be used to | |
| 37 | * clean up the system before shutting down, or to force a new instance | |
| 38 | * to be created the next time {@link #getFactory()} is invoked. | |
| 39 | * | |
| 40 | */ | |
| 41 | public static void release() { | |
| 42 | 0 | DiscoverSingleton.release(ProcessFactory.class); |
| 43 | 0 | } |
| 44 | ||
| 45 | /** | |
| 46 | * Gets a process factory instance. | |
| 47 | * | |
| 48 | * @return A ProcessFactory instance | |
| 49 | */ | |
| 50 | public static ProcessFactory getFactory() { | |
| 51 | 0 | Object instance = DiscoverSingleton.find(ProcessFactory.class); |
| 52 | 0 | if (instance == null) { |
| 53 | 0 | throw new InternalError("Could not find a ProcessFactory implementation"); |
| 54 | } | |
| 55 | ||
| 56 | 0 | return (ProcessFactory)instance; |
| 57 | } | |
| 58 | } |