Package org.apache.groovy.plugin
Class GroovyRunnerRegistry
java.lang.Object
org.apache.groovy.plugin.GroovyRunnerRegistry
- All Implemented Interfaces:
- java.lang.Iterable<GroovyRunner>,- java.util.Map<java.lang.String,GroovyRunner>
public class GroovyRunnerRegistry extends java.lang.Object implements java.util.Map<java.lang.String,GroovyRunner>, java.lang.Iterable<GroovyRunner>
Registry of services that implement the 
GroovyRunner interface.
 
 This registry makes use of the ServiceLoader facility. The
 preferred method for registering new GroovyRunner providers
 is to place them in a provider-configuration file in the resource
 directory META-INF/services. The preferred method for accessing
 the registered runners is by making use of the Iterable
 interface using an enhanced for-loop.
 
 For compatibility with previous versions, this registry implements the
 Map interface. All null keys and values will be ignored
 and no exception thrown, except where noted.
 
 By default the registry contains runners that are capable of running
 JUnit 3 and JUnit 4 test classes if those libraries
 are available to the class loader.
- Since:
- 2.5.0
- 
Nested Class SummaryNested classes/interfaces inherited from interface java.util.Mapjava.util.Map.Entry<K extends java.lang.Object,V extends java.lang.Object>
- 
Method SummaryModifier and Type Method Description voidclear()Clears all registered runners from the registry and resets the registry so that it contains only the default set of runners.booleancontainsKey(java.lang.Object key)Returnstrueif a runner was registered with the specified key.booleancontainsValue(java.lang.Object runner)Returnstrueif registry contains the given runner instance.java.util.Set<java.util.Map.Entry<java.lang.String,GroovyRunner>>entrySet()Returns a set of entries for registered runners.GroovyRunnerget(java.lang.Object key)Returns the registered runner for the specified key.static GroovyRunnerRegistrygetInstance()Returns a reference to the one and only registry instance.booleanisEmpty()Returnstrueif the registry contains no runners, elsefalse.java.util.Iterator<GroovyRunner>iterator()Returns an iterator for all runners that are registered.java.util.Set<java.lang.String>keySet()Set of all keys associated with registered runners.voidload(java.lang.ClassLoader classLoader)LoadsGroovyRunnerinstances using theServiceLoaderfacility.GroovyRunnerput(java.lang.String key, GroovyRunner runner)Registers a runner with the specified key.voidputAll(java.util.Map<? extends java.lang.String,? extends GroovyRunner> m)Adds all entries from the given Map to the registry.GroovyRunnerremove(java.lang.Object key)Removes a registered runner from the registry.intsize()Returns the number of registered runners.java.lang.StringtoString()java.util.Collection<GroovyRunner>values()Returns a collection of all registered runners.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.IterableforEach, spliteratorMethods inherited from interface java.util.Mapcompute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
- 
Method Details- 
getInstanceReturns a reference to the one and only registry instance.- Returns:
- registry instance
 
- 
loadpublic void load(java.lang.ClassLoader classLoader)LoadsGroovyRunnerinstances using theServiceLoaderfacility.- Parameters:
- classLoader- used to locate provider-configuration files and classes
 
- 
iteratorReturns an iterator for all runners that are registered. The returned iterator is a snapshot of the registry at the time the iterator is created. This iterator does not support removal.- Specified by:
- iteratorin interface- java.lang.Iterable<GroovyRunner>
- Returns:
- iterator for all registered runners
 
- 
sizepublic int size()Returns the number of registered runners.- Specified by:
- sizein interface- java.util.Map<java.lang.String,GroovyRunner>
- Returns:
- number of registered runners
 
- 
isEmptypublic boolean isEmpty()Returnstrueif the registry contains no runners, elsefalse.- Specified by:
- isEmptyin interface- java.util.Map<java.lang.String,GroovyRunner>
- Returns:
- trueif no runners are registered
 
- 
containsKeypublic boolean containsKey(java.lang.Object key)Returnstrueif a runner was registered with the specified key.- Specified by:
- containsKeyin interface- java.util.Map<java.lang.String,GroovyRunner>
- Parameters:
- key- for the registered runner
- Returns:
- trueif a runner was registered with given key
 
- 
containsValuepublic boolean containsValue(java.lang.Object runner)Returnstrueif registry contains the given runner instance.- Specified by:
- containsValuein interface- java.util.Map<java.lang.String,GroovyRunner>
- Parameters:
- runner- instance of a GroovyRunner
- Returns:
- trueif the given runner is registered
 
- 
getReturns the registered runner for the specified key.- Specified by:
- getin interface- java.util.Map<java.lang.String,GroovyRunner>
- Parameters:
- key- used to lookup the runner
- Returns:
- the runner registered with the given key
 
- 
putRegisters a runner with the specified key.- Specified by:
- putin interface- java.util.Map<java.lang.String,GroovyRunner>
- Parameters:
- key- to associate with the runner
- runner- the runner to register
- Returns:
- the previously registered runner for the given key,
          if no runner was previously registered for the key
          then null
 
- 
removeRemoves a registered runner from the registry.- Specified by:
- removein interface- java.util.Map<java.lang.String,GroovyRunner>
- Parameters:
- key- of the runner to remove
- Returns:
- the runner instance that was removed, if no runner
          instance was removed then null
 
- 
putAllAdds all entries from the given Map to the registry. Any entries in the provided Map that contain anullkey or value will be ignored.- Specified by:
- putAllin interface- java.util.Map<java.lang.String,GroovyRunner>
- Parameters:
- m- entries to add to the registry
- Throws:
- java.lang.NullPointerException- if the given Map is- null
 
- 
clearpublic void clear()Clears all registered runners from the registry and resets the registry so that it contains only the default set of runners.- Specified by:
- clearin interface- java.util.Map<java.lang.String,GroovyRunner>
 
- 
keySetpublic java.util.Set<java.lang.String> keySet()Set of all keys associated with registered runners. This is a snapshot of the registry and any subsequent registry changes will not be reflected in the set.- Specified by:
- keySetin interface- java.util.Map<java.lang.String,GroovyRunner>
- Returns:
- an unmodifiable set of keys for registered runners
 
- 
valuesReturns a collection of all registered runners. This is a snapshot of the registry and any subsequent registry changes will not be reflected in the collection.- Specified by:
- valuesin interface- java.util.Map<java.lang.String,GroovyRunner>
- Returns:
- an unmodifiable collection of registered runner instances
 
- 
entrySetReturns a set of entries for registered runners. This is a snapshot of the registry and any subsequent registry changes will not be reflected in the set.- Specified by:
- entrySetin interface- java.util.Map<java.lang.String,GroovyRunner>
- Returns:
- an unmodifiable set of registered runner entries
 
- 
toStringpublic java.lang.String toString()- Overrides:
- toStringin class- java.lang.Object
 
 
-